From 8da1f266b2955b2181f54d6d12447458649f367f Mon Sep 17 00:00:00 2001 From: Vilsol Date: Wed, 25 Jun 2025 02:24:21 +0300 Subject: [PATCH 1/2] feat: modpacks --- api/api.go | 2 + conversion/ent_to_graphql.go | 29 + db/modpack.go | 71 + db/schema/mod.go | 3 + db/schema/modpack.go | 59 + db/schema/modpack_mods.go | 42 + db/schema/modpack_release.go | 46 + db/schema/modpack_tags.go | 41 + db/schema/modpack_target.go | 43 + db/schema/tag.go | 3 + generated/conv/modpack.go | 109 + generated/conv/modpack_release.go | 36 + generated/docs/docs.go | 839 + generated/docs/swagger.json | 839 + generated/docs/swagger.yaml | 544 + generated/ent/client.go | 919 +- generated/ent/ent.go | 10 + generated/ent/hook/hook.go | 60 + generated/ent/intercept/intercept.go | 150 + generated/ent/internal/schema.go | 2 +- generated/ent/migrate/schema.go | 153 + generated/ent/mod.go | 40 +- generated/ent/mod/mod.go | 61 + generated/ent/mod/where.go | 46 + generated/ent/mod_create.go | 32 + generated/ent/mod_query.go | 181 +- generated/ent/mod_update.go | 163 + generated/ent/modpack.go | 391 + generated/ent/modpack/modpack.go | 409 + generated/ent/modpack/where.go | 1070 ++ generated/ent/modpack_create.go | 1530 ++ generated/ent/modpack_delete.go | 88 + generated/ent/modpack_query.go | 1208 ++ generated/ent/modpack_update.go | 1558 ++ generated/ent/modpackmod.go | 162 + generated/ent/modpackmod/modpackmod.go | 106 + generated/ent/modpackmod/where.go | 280 + generated/ent/modpackmod_create.go | 577 + generated/ent/modpackmod_delete.go | 87 + generated/ent/modpackmod_query.go | 626 + generated/ent/modpackmod_update.go | 473 + generated/ent/modpackrelease.go | 188 + .../ent/modpackrelease/modpackrelease.go | 124 + generated/ent/modpackrelease/where.go | 474 + generated/ent/modpackrelease_create.go | 785 + generated/ent/modpackrelease_delete.go | 88 + generated/ent/modpackrelease_query.go | 629 + generated/ent/modpackrelease_update.go | 461 + generated/ent/modpacktag.go | 151 + generated/ent/modpacktag/modpacktag.go | 98 + generated/ent/modpacktag/where.go | 210 + generated/ent/modpacktag_create.go | 524 + generated/ent/modpacktag_delete.go | 87 + generated/ent/modpacktag_query.go | 626 + generated/ent/modpacktag_update.go | 439 + generated/ent/modpacktarget.go | 141 + generated/ent/modpacktarget/modpacktarget.go | 84 + generated/ent/modpacktarget/where.go | 242 + generated/ent/modpacktarget_create.go | 582 + generated/ent/modpacktarget_delete.go | 88 + generated/ent/modpacktarget_query.go | 629 + generated/ent/modpacktarget_update.go | 356 + generated/ent/mutation.go | 4097 +++- generated/ent/predicate/predicate.go | 15 + generated/ent/runtime/runtime.go | 78 + generated/ent/tag.go | 38 +- generated/ent/tag/tag.go | 61 + generated/ent/tag/where.go | 46 + generated/ent/tag_create.go | 32 + generated/ent/tag_query.go | 217 +- generated/ent/tag_update.go | 163 + generated/ent/tx.go | 15 + generated/generated.go | 15830 ++++++++++------ generated/models_gen.go | 154 + go.mod | 3 + go.sum | 6 + gql/directive.go | 23 + gql/resolver.go | 8 + gql/resolver_modpacks.go | 543 + gqlgen.yml | 12 + .../sql/20250623121418_add_modpacks.down.sql | 14 + .../sql/20250623121418_add_modpacks.up.sql | 66 + migrations/sql/atlas.sum | 4 +- models/filters.go | 51 + nodes/modpack.go | 146 + nodes/node_types.go | 3 + nodes/routes.go | 9 + schemas/directives.graphql | 1 + schemas/modpack.graphql | 125 + storage/storage.go | 12 + tests/modpack_db_test.go | 480 + tests/modpack_rest_test.go | 347 + tests/utils_test.go | 182 + 93 files changed, 36968 insertions(+), 5907 deletions(-) create mode 100644 db/modpack.go create mode 100644 db/schema/modpack.go create mode 100644 db/schema/modpack_mods.go create mode 100644 db/schema/modpack_release.go create mode 100644 db/schema/modpack_tags.go create mode 100644 db/schema/modpack_target.go create mode 100644 generated/conv/modpack.go create mode 100644 generated/conv/modpack_release.go create mode 100644 generated/ent/modpack.go create mode 100644 generated/ent/modpack/modpack.go create mode 100644 generated/ent/modpack/where.go create mode 100644 generated/ent/modpack_create.go create mode 100644 generated/ent/modpack_delete.go create mode 100644 generated/ent/modpack_query.go create mode 100644 generated/ent/modpack_update.go create mode 100644 generated/ent/modpackmod.go create mode 100644 generated/ent/modpackmod/modpackmod.go create mode 100644 generated/ent/modpackmod/where.go create mode 100644 generated/ent/modpackmod_create.go create mode 100644 generated/ent/modpackmod_delete.go create mode 100644 generated/ent/modpackmod_query.go create mode 100644 generated/ent/modpackmod_update.go create mode 100644 generated/ent/modpackrelease.go create mode 100644 generated/ent/modpackrelease/modpackrelease.go create mode 100644 generated/ent/modpackrelease/where.go create mode 100644 generated/ent/modpackrelease_create.go create mode 100644 generated/ent/modpackrelease_delete.go create mode 100644 generated/ent/modpackrelease_query.go create mode 100644 generated/ent/modpackrelease_update.go create mode 100644 generated/ent/modpacktag.go create mode 100644 generated/ent/modpacktag/modpacktag.go create mode 100644 generated/ent/modpacktag/where.go create mode 100644 generated/ent/modpacktag_create.go create mode 100644 generated/ent/modpacktag_delete.go create mode 100644 generated/ent/modpacktag_query.go create mode 100644 generated/ent/modpacktag_update.go create mode 100644 generated/ent/modpacktarget.go create mode 100644 generated/ent/modpacktarget/modpacktarget.go create mode 100644 generated/ent/modpacktarget/where.go create mode 100644 generated/ent/modpacktarget_create.go create mode 100644 generated/ent/modpacktarget_delete.go create mode 100644 generated/ent/modpacktarget_query.go create mode 100644 generated/ent/modpacktarget_update.go create mode 100644 gql/resolver_modpacks.go create mode 100644 migrations/sql/20250623121418_add_modpacks.down.sql create mode 100644 migrations/sql/20250623121418_add_modpacks.up.sql create mode 100644 nodes/modpack.go create mode 100755 schemas/modpack.graphql create mode 100644 tests/modpack_db_test.go create mode 100644 tests/modpack_rest_test.go diff --git a/api/api.go b/api/api.go index 56beb34f..21a3c511 100644 --- a/api/api.go +++ b/api/api.go @@ -156,6 +156,8 @@ func Setup(ctx context.Context) *echo.Echo { nodes.RegisterModRoutes(v1.Group("/mod")) nodes.RegisterModsRoutes(v1.Group("/mods")) nodes.RegisterVersionRoutes(v1.Group("/version")) + nodes.RegisterModpackRoutes(v1.Group("/modpack")) + nodes.RegisterModpacksRoutes(v1.Group("/modpacks")) v2 := e.Group("/v2") diff --git a/conversion/ent_to_graphql.go b/conversion/ent_to_graphql.go index 29a61749..fb0aab0d 100644 --- a/conversion/ent_to_graphql.go +++ b/conversion/ent_to_graphql.go @@ -127,6 +127,35 @@ type VirustotalResult interface { ConvertSlice(source []*ent.VirustotalResult) []*generated.VirustotalResult } +// goverter:converter +// goverter:output:file ../generated/conv/modpack.go +// goverter:output:package conv +// goverter:extend TimeToString UIntToInt Int64ToInt EntModpackTargetToString +type Modpack interface { + // goverter:map Edges.Targets Targets + // goverter:map Edges.Tags Tags + // goverter:map Edges.ModpackMods Mods + // goverter:map Edges.Parent Parent + // goverter:map Edges.Releases Releases + // goverter:map Edges.Children Children + // goverter:ignore Creator + Convert(source *ent.Modpack) *generated.Modpack + ConvertSlice(source []*ent.Modpack) []*generated.Modpack +} + +func EntModpackTargetToString(t *ent.ModpackTarget) string { + return t.TargetName +} + +// goverter:converter +// goverter:output:file ../generated/conv/modpack_release.go +// goverter:output:package conv +// goverter:extend TimeToString +type ModpackRelease interface { + Convert(source *ent.ModpackRelease) *generated.ModpackRelease + ConvertSlice(source []*ent.ModpackRelease) []*generated.ModpackRelease +} + func TimeToString(i time.Time) string { return i.Format(time.RFC3339) } diff --git a/db/modpack.go b/db/modpack.go new file mode 100644 index 00000000..9b0e5d93 --- /dev/null +++ b/db/modpack.go @@ -0,0 +1,71 @@ +package db + +import ( + "strings" + + "entgo.io/ent/dialect/sql" + + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/models" +) + +func ConvertModpackFilter(query *ent.ModpackQuery, filter *models.ModpackFilter, count bool) *ent.ModpackQuery { + if len(filter.IDs) > 0 { + query = query.Where(modpack.IDIn(filter.IDs...)) + } else if filter != nil { + if !count { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset) + } + + if filter.OrderBy != nil && *filter.OrderBy != generated.ModpackFieldsSearch { + query = query.Order(sql.OrderByField( + filter.OrderBy.String(), + OrderToOrder(filter.Order.String()), + ).ToFunc()) + } + + if filter.Search != nil && *filter.Search != "" { + cleanSearch := strings.ReplaceAll(strings.TrimSpace(*filter.Search), " ", " & ") + + query = query.Where(func(s *sql.Selector) { + join := sql.Select("id") + join = join.AppendSelectExprAs( + sql.P(func(builder *sql.Builder) { + builder.WriteString("similarity(name, ").Arg(cleanSearch).WriteString(") * 2"). + WriteString(" + "). + WriteString("similarity(short_description, ").Arg(cleanSearch).WriteString(")"). + WriteString(" + "). + WriteString("similarity(full_description, ").Arg(cleanSearch).WriteString(") * 0.5") + }), + "s", + ) + join.From(sql.Table(modpack.Table)).As("t1") + s.Join(join).On(s.C(modpack.FieldID), join.C("id")) + }) + + query = query.Where(func(s *sql.Selector) { + s.Where(sql.ExprP(`"t1"."s" > 0.2`)) + }) + + if !count && *filter.OrderBy == generated.ModpackFieldsSearch { + query = query.Order(func(s *sql.Selector) { + s.OrderExpr(sql.ExprP(`"t1"."s" DESC`)) + }) + } + } + + if filter.Hidden == nil || !(*filter.Hidden) { + query = query.Where(modpack.Hidden(false)) + } + + if len(filter.TagIDs) > 0 { + query = query.Where(modpack.HasTagsWith(tag.IDIn(filter.TagIDs...))) + } + } + return query +} diff --git a/db/schema/mod.go b/db/schema/mod.go index 9e4ef29a..34157a16 100644 --- a/db/schema/mod.go +++ b/db/schema/mod.go @@ -63,5 +63,8 @@ func (Mod) Edges() []ent.Edge { edge.From("dependents", Version.Type). Ref("dependencies"). Through("version_dependencies", VersionDependency.Type), + edge.From("modpacks", Modpack.Type). + Ref("mods"). + Through("modpack_mods", ModpackMod.Type), } } diff --git a/db/schema/modpack.go b/db/schema/modpack.go new file mode 100644 index 00000000..3b2a3ae0 --- /dev/null +++ b/db/schema/modpack.go @@ -0,0 +1,59 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type Modpack struct { + ent.Schema +} + +func (Modpack) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + } +} + +func (Modpack) Fields() []ent.Field { + return []ent.Field{ + field.String("name"), + field.String("short_description").MaxLen(128), + field.String("full_description"), + field.String("logo").Optional(), + field.String("logo_thumbhash").Optional(), + field.String("creator_id"), + field.Uint("views").Default(0), + field.Uint("hotness").Default(0), + field.Uint("installs").Default(0), + field.Uint("popularity").Default(0), + field.Bool("hidden").Default(false), + field.String("parent_id").Optional().Immutable(), + } +} + +func (Modpack) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("children", Modpack.Type). + Annotations(entsql.OnDelete(entsql.Restrict)), + edge.From("parent", Modpack.Type). + Ref("children"). + Field("parent_id"). + Unique(). + Immutable(). + Annotations(entsql.OnDelete(entsql.Restrict)), + edge.To("targets", ModpackTarget.Type). + Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("releases", ModpackRelease.Type). + Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("mods", Mod.Type). + Through("modpack_mods", ModpackMod.Type). + Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("tags", Tag.Type). + Through("modpack_tags", ModpackTag.Type). + Annotations(entsql.OnDelete(entsql.Cascade)), + } +} diff --git a/db/schema/modpack_mods.go b/db/schema/modpack_mods.go new file mode 100644 index 00000000..06908e91 --- /dev/null +++ b/db/schema/modpack_mods.go @@ -0,0 +1,42 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type ModpackMod struct { + ent.Schema +} + +func (ModpackMod) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("modpack_id", "mod_id"), + } +} + +func (ModpackMod) Fields() []ent.Field { + return []ent.Field{ + field.String("modpack_id"), + field.String("mod_id"), + field.String("version_constraint"), + } +} + +func (ModpackMod) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("modpack", Modpack.Type). + Unique(). + Required(). + Field("modpack_id"). + Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("mod", Mod.Type). + Unique(). + Required(). + Field("mod_id"). + Annotations(entsql.OnDelete(entsql.Cascade)), + } +} diff --git a/db/schema/modpack_release.go b/db/schema/modpack_release.go new file mode 100644 index 00000000..1075148d --- /dev/null +++ b/db/schema/modpack_release.go @@ -0,0 +1,46 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type ModpackRelease struct { + ent.Schema +} + +func (ModpackRelease) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + } +} + +func (ModpackRelease) Fields() []ent.Field { + return []ent.Field{ + field.String("modpack_id"), + field.String("version"), + field.String("changelog"), + field.String("lockfile"), + } +} + +func (ModpackRelease) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("modpack", Modpack.Type). + Ref("releases"). + Field("modpack_id"). + Unique(). + Required(). + Annotations(entsql.OnDelete(entsql.Cascade)), + } +} + +func (ModpackRelease) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("modpack_id", "version").Unique(), + } +} diff --git a/db/schema/modpack_tags.go b/db/schema/modpack_tags.go new file mode 100644 index 00000000..1a84f5ce --- /dev/null +++ b/db/schema/modpack_tags.go @@ -0,0 +1,41 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type ModpackTag struct { + ent.Schema +} + +func (ModpackTag) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("modpack_id", "tag_id"), + } +} + +func (ModpackTag) Fields() []ent.Field { + return []ent.Field{ + field.String("modpack_id"), + field.String("tag_id"), + } +} + +func (ModpackTag) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("modpack", Modpack.Type). + Unique(). + Required(). + Field("modpack_id"). + Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("tag", Tag.Type). + Unique(). + Required(). + Field("tag_id"). + Annotations(entsql.OnDelete(entsql.Cascade)), + } +} diff --git a/db/schema/modpack_target.go b/db/schema/modpack_target.go new file mode 100644 index 00000000..80562854 --- /dev/null +++ b/db/schema/modpack_target.go @@ -0,0 +1,43 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type ModpackTarget struct { + ent.Schema +} + +func (ModpackTarget) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + } +} + +func (ModpackTarget) Fields() []ent.Field { + return []ent.Field{ + field.String("modpack_id"), + field.String("target_name"), + } +} + +func (ModpackTarget) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("modpack", Modpack.Type). + Ref("targets"). + Field("modpack_id"). + Unique(). + Required(). + Annotations(entsql.OnDelete(entsql.Cascade)), + } +} + +func (ModpackTarget) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("modpack_id", "target_name").Unique(), + } +} diff --git a/db/schema/tag.go b/db/schema/tag.go index 6dd5a308..3b833ea0 100644 --- a/db/schema/tag.go +++ b/db/schema/tag.go @@ -33,5 +33,8 @@ func (Tag) Edges() []ent.Edge { edge.From("guides", Guide.Type). Ref("tags"). Through("guide_tags", GuideTag.Type), + edge.From("modpacks", Modpack.Type). + Ref("tags"). + Through("modpack_tags", ModpackTag.Type), } } diff --git a/generated/conv/modpack.go b/generated/conv/modpack.go new file mode 100644 index 00000000..d908aaf5 --- /dev/null +++ b/generated/conv/modpack.go @@ -0,0 +1,109 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter + +package conv + +import ( + conversion "github.com/satisfactorymodding/smr-api/conversion" + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type ModpackImpl struct{} + +func (c *ModpackImpl) Convert(source *ent.Modpack) *generated.Modpack { + var pGeneratedModpack *generated.Modpack + if source != nil { + var generatedModpack generated.Modpack + generatedModpack.ID = (*source).ID + generatedModpack.Name = (*source).Name + generatedModpack.ShortDescription = (*source).ShortDescription + generatedModpack.FullDescription = (*source).FullDescription + pString := (*source).Logo + generatedModpack.Logo = &pString + pString2 := (*source).LogoThumbhash + generatedModpack.LogoThumbhash = &pString2 + generatedModpack.CreatorID = (*source).CreatorID + generatedModpack.Views = conversion.UIntToInt((*source).Views) + generatedModpack.Installs = conversion.UIntToInt((*source).Installs) + generatedModpack.Hotness = conversion.UIntToInt((*source).Hotness) + generatedModpack.Popularity = conversion.UIntToInt((*source).Popularity) + generatedModpack.UpdatedAt = conversion.TimeToString((*source).UpdatedAt) + generatedModpack.CreatedAt = conversion.TimeToString((*source).CreatedAt) + generatedModpack.Hidden = (*source).Hidden + pString3 := (*source).ParentID + generatedModpack.ParentID = &pString3 + generatedModpack.Parent = c.Convert((*source).Edges.Parent) + generatedModpack.Children = c.ConvertSlice((*source).Edges.Children) + if (*source).Edges.Tags != nil { + generatedModpack.Tags = make([]*generated.Tag, len((*source).Edges.Tags)) + for i := 0; i < len((*source).Edges.Tags); i++ { + generatedModpack.Tags[i] = c.pEntTagToPGeneratedTag((*source).Edges.Tags[i]) + } + } + if (*source).Edges.Targets != nil { + generatedModpack.Targets = make([]string, len((*source).Edges.Targets)) + for j := 0; j < len((*source).Edges.Targets); j++ { + generatedModpack.Targets[j] = conversion.EntModpackTargetToString((*source).Edges.Targets[j]) + } + } + if (*source).Edges.ModpackMods != nil { + generatedModpack.Mods = make([]*generated.ModpackModEntry, len((*source).Edges.ModpackMods)) + for k := 0; k < len((*source).Edges.ModpackMods); k++ { + generatedModpack.Mods[k] = c.pEntModpackModToPGeneratedModpackModEntry((*source).Edges.ModpackMods[k]) + } + } + if (*source).Edges.Releases != nil { + generatedModpack.Releases = make([]*generated.ModpackRelease, len((*source).Edges.Releases)) + for l := 0; l < len((*source).Edges.Releases); l++ { + generatedModpack.Releases[l] = c.pEntModpackReleaseToPGeneratedModpackRelease((*source).Edges.Releases[l]) + } + } + pGeneratedModpack = &generatedModpack + } + return pGeneratedModpack +} +func (c *ModpackImpl) ConvertSlice(source []*ent.Modpack) []*generated.Modpack { + var pGeneratedModpackList []*generated.Modpack + if source != nil { + pGeneratedModpackList = make([]*generated.Modpack, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedModpackList[i] = c.Convert(source[i]) + } + } + return pGeneratedModpackList +} +func (c *ModpackImpl) pEntModpackModToPGeneratedModpackModEntry(source *ent.ModpackMod) *generated.ModpackModEntry { + var pGeneratedModpackModEntry *generated.ModpackModEntry + if source != nil { + var generatedModpackModEntry generated.ModpackModEntry + generatedModpackModEntry.ModID = (*source).ModID + generatedModpackModEntry.VersionConstraint = (*source).VersionConstraint + pGeneratedModpackModEntry = &generatedModpackModEntry + } + return pGeneratedModpackModEntry +} +func (c *ModpackImpl) pEntModpackReleaseToPGeneratedModpackRelease(source *ent.ModpackRelease) *generated.ModpackRelease { + var pGeneratedModpackRelease *generated.ModpackRelease + if source != nil { + var generatedModpackRelease generated.ModpackRelease + generatedModpackRelease.ID = (*source).ID + generatedModpackRelease.Version = (*source).Version + generatedModpackRelease.CreatedAt = conversion.TimeToString((*source).CreatedAt) + generatedModpackRelease.Lockfile = (*source).Lockfile + generatedModpackRelease.Changelog = (*source).Changelog + pGeneratedModpackRelease = &generatedModpackRelease + } + return pGeneratedModpackRelease +} +func (c *ModpackImpl) pEntTagToPGeneratedTag(source *ent.Tag) *generated.Tag { + var pGeneratedTag *generated.Tag + if source != nil { + var generatedTag generated.Tag + generatedTag.ID = (*source).ID + generatedTag.Name = (*source).Name + generatedTag.Description = (*source).Description + pGeneratedTag = &generatedTag + } + return pGeneratedTag +} diff --git a/generated/conv/modpack_release.go b/generated/conv/modpack_release.go new file mode 100644 index 00000000..aa558da9 --- /dev/null +++ b/generated/conv/modpack_release.go @@ -0,0 +1,36 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter + +package conv + +import ( + conversion "github.com/satisfactorymodding/smr-api/conversion" + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type ModpackReleaseImpl struct{} + +func (c *ModpackReleaseImpl) Convert(source *ent.ModpackRelease) *generated.ModpackRelease { + var pGeneratedModpackRelease *generated.ModpackRelease + if source != nil { + var generatedModpackRelease generated.ModpackRelease + generatedModpackRelease.ID = (*source).ID + generatedModpackRelease.Version = (*source).Version + generatedModpackRelease.CreatedAt = conversion.TimeToString((*source).CreatedAt) + generatedModpackRelease.Lockfile = (*source).Lockfile + generatedModpackRelease.Changelog = (*source).Changelog + pGeneratedModpackRelease = &generatedModpackRelease + } + return pGeneratedModpackRelease +} +func (c *ModpackReleaseImpl) ConvertSlice(source []*ent.ModpackRelease) []*generated.ModpackRelease { + var pGeneratedModpackReleaseList []*generated.ModpackRelease + if source != nil { + pGeneratedModpackReleaseList = make([]*generated.ModpackRelease, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedModpackReleaseList[i] = c.Convert(source[i]) + } + } + return pGeneratedModpackReleaseList +} diff --git a/generated/docs/docs.go b/generated/docs/docs.go index 3a3e6eb8..7019466a 100644 --- a/generated/docs/docs.go +++ b/generated/docs/docs.go @@ -311,6 +311,227 @@ const docTemplate = `{ } } }, + "/modpacks": { + "get": { + "description": "Retrieve a list of modpacks", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a list of Modpacks", + "parameters": [ + { + "type": "integer", + "description": "How many modpacks to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of modpacks to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at", + "name", + "views", + "installs", + "hotness", + "popularity", + "search" + ], + "type": "string", + "description": "Order by field", + "name": "order_by", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "Order of results", + "name": "order", + "in": "query" + }, + { + "type": "string", + "description": "Search string", + "name": "search", + "in": "query" + }, + { + "type": "boolean", + "description": "Include hidden modpacks", + "name": "hidden", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Modpack" + } + } + } + } + ] + } + } + } + } + }, + "/modpacks/{modpackId}": { + "get": { + "description": "Retrieve a single modpack by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a single Modpack", + "parameters": [ + { + "type": "string", + "description": "Modpack ID", + "name": "modpackId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/generated.Modpack" + } + } + } + ] + } + }, + "404": { + "description": "Not Found", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/nodes.ErrorResponse" + } + } + } + ] + } + } + } + } + }, + "/modpacks/{modpackId}/releases/{version}": { + "get": { + "description": "Retrieve a specific release of a modpack", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a Modpack Release", + "parameters": [ + { + "type": "string", + "description": "Modpack ID", + "name": "modpackId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Release Version", + "name": "version", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/generated.ModpackRelease" + } + } + } + ] + } + }, + "404": { + "description": "Not Found", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/nodes.ErrorResponse" + } + } + } + ] + } + } + } + } + }, "/mods": { "get": { "description": "Retrieve a list of mods", @@ -759,6 +980,624 @@ const docTemplate = `{ } } } + }, + "definitions": { + "generated.Compatibility": { + "type": "object", + "properties": { + "note": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/generated.CompatibilityState" + } + } + }, + "generated.CompatibilityInfo": { + "type": "object", + "properties": { + "EA": { + "$ref": "#/definitions/generated.Compatibility" + }, + "EXP": { + "$ref": "#/definitions/generated.Compatibility" + } + } + }, + "generated.CompatibilityState": { + "type": "string", + "enum": [ + "Works", + "Damaged", + "Broken" + ], + "x-enum-varnames": [ + "CompatibilityStateWorks", + "CompatibilityStateDamaged", + "CompatibilityStateBroken" + ] + }, + "generated.Group": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "generated.Guide": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "guide": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "short_description": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/generated.User" + }, + "user_id": { + "type": "string" + }, + "views": { + "type": "integer" + } + } + }, + "generated.LatestVersions": { + "type": "object", + "properties": { + "alpha": { + "$ref": "#/definitions/generated.Version" + }, + "beta": { + "$ref": "#/definitions/generated.Version" + }, + "release": { + "$ref": "#/definitions/generated.Version" + } + } + }, + "generated.Mod": { + "type": "object", + "properties": { + "approved": { + "type": "boolean" + }, + "authors": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.UserMod" + } + }, + "compatibility": { + "$ref": "#/definitions/generated.CompatibilityInfo" + }, + "created_at": { + "type": "string" + }, + "creator_id": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "full_description": { + "type": "string" + }, + "hidden": { + "type": "boolean" + }, + "hotness": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "last_version_date": { + "type": "string" + }, + "latestVersions": { + "$ref": "#/definitions/generated.LatestVersions" + }, + "logo": { + "type": "string" + }, + "logo_thumbhash": { + "type": "string" + }, + "mod_reference": { + "type": "string" + }, + "name": { + "type": "string" + }, + "popularity": { + "type": "integer" + }, + "short_description": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "toggle_explicit_content": { + "type": "boolean" + }, + "toggle_network_use": { + "type": "boolean" + }, + "updated_at": { + "type": "string" + }, + "version": { + "$ref": "#/definitions/generated.Version" + }, + "versions": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Version" + } + }, + "views": { + "type": "integer" + } + } + }, + "generated.Modpack": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Modpack" + } + }, + "created_at": { + "type": "string" + }, + "creator": { + "$ref": "#/definitions/generated.User" + }, + "creator_id": { + "type": "string" + }, + "full_description": { + "type": "string" + }, + "hidden": { + "type": "boolean" + }, + "hotness": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "installs": { + "type": "integer" + }, + "logo": { + "type": "string" + }, + "logo_thumbhash": { + "type": "string" + }, + "mods": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.ModpackModEntry" + } + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/generated.Modpack" + }, + "parent_id": { + "type": "string" + }, + "popularity": { + "type": "integer" + }, + "releases": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.ModpackRelease" + } + }, + "short_description": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "targets": { + "type": "array", + "items": { + "type": "string" + } + }, + "updated_at": { + "type": "string" + }, + "views": { + "type": "integer" + } + } + }, + "generated.ModpackModEntry": { + "type": "object", + "properties": { + "mod_id": { + "type": "string" + }, + "version_constraint": { + "type": "string" + } + } + }, + "generated.ModpackRelease": { + "type": "object", + "properties": { + "changelog": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "lockfile": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "generated.Tag": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "generated.TargetName": { + "type": "string", + "enum": [ + "Windows", + "WindowsServer", + "LinuxServer" + ], + "x-enum-varnames": [ + "TargetNameWindows", + "TargetNameWindowsServer", + "TargetNameLinuxServer" + ] + }, + "generated.User": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "avatar_thumbhash": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "email": { + "type": "string" + }, + "facebook_id": { + "type": "string" + }, + "github_id": { + "type": "string" + }, + "google_id": { + "type": "string" + }, + "groups": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Group" + } + }, + "guides": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Guide" + } + }, + "id": { + "type": "string" + }, + "mods": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.UserMod" + } + }, + "roles": { + "$ref": "#/definitions/generated.UserRoles" + }, + "username": { + "type": "string" + } + } + }, + "generated.UserMod": { + "type": "object", + "properties": { + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "role": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/generated.User" + }, + "user_id": { + "type": "string" + } + } + }, + "generated.UserRoles": { + "type": "object", + "properties": { + "approveMods": { + "type": "boolean" + }, + "approveVersions": { + "type": "boolean" + }, + "deleteContent": { + "type": "boolean" + }, + "editAnyModCompatibility": { + "type": "boolean" + }, + "editBootstrapVersions": { + "type": "boolean" + }, + "editContent": { + "type": "boolean" + }, + "editSatisfactoryVersions": { + "type": "boolean" + }, + "editUsers": { + "type": "boolean" + } + } + }, + "generated.Version": { + "type": "object", + "properties": { + "approved": { + "type": "boolean" + }, + "changelog": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "dependencies": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VersionDependency" + } + }, + "downloads": { + "type": "integer" + }, + "game_version": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "id": { + "type": "string" + }, + "link": { + "type": "string" + }, + "metadata": { + "type": "string" + }, + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "required_on_remote": { + "type": "boolean" + }, + "size": { + "type": "integer" + }, + "sml_version": { + "type": "string" + }, + "stability": { + "$ref": "#/definitions/generated.VersionStabilities" + }, + "targets": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VersionTarget" + } + }, + "updated_at": { + "type": "string" + }, + "version": { + "type": "string" + }, + "virustotal_results": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VirustotalResult" + } + } + } + }, + "generated.VersionDependency": { + "type": "object", + "properties": { + "condition": { + "type": "string" + }, + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "mod_reference": { + "type": "string" + }, + "optional": { + "type": "boolean" + }, + "version": { + "$ref": "#/definitions/generated.Version" + }, + "version_id": { + "type": "string" + } + } + }, + "generated.VersionStabilities": { + "type": "string", + "enum": [ + "alpha", + "beta", + "release" + ], + "x-enum-varnames": [ + "VersionStabilitiesAlpha", + "VersionStabilitiesBeta", + "VersionStabilitiesRelease" + ] + }, + "generated.VersionTarget": { + "type": "object", + "properties": { + "VersionID": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "link": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "targetName": { + "$ref": "#/definitions/generated.TargetName" + } + } + }, + "generated.VirustotalResult": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "file_name": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "id": { + "type": "string" + }, + "safe": { + "type": "boolean" + }, + "updated_at": { + "type": "string" + }, + "version_id": { + "type": "string" + } + } + }, + "nodes.ErrorResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } + } + }, + "nodes.GenericResponse": { + "type": "object", + "properties": { + "data": {}, + "error": {}, + "success": { + "type": "boolean" + } + } + } } }` diff --git a/generated/docs/swagger.json b/generated/docs/swagger.json index 424cfb3b..a46ab745 100644 --- a/generated/docs/swagger.json +++ b/generated/docs/swagger.json @@ -305,6 +305,227 @@ } } }, + "/modpacks": { + "get": { + "description": "Retrieve a list of modpacks", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a list of Modpacks", + "parameters": [ + { + "type": "integer", + "description": "How many modpacks to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of modpacks to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at", + "name", + "views", + "installs", + "hotness", + "popularity", + "search" + ], + "type": "string", + "description": "Order by field", + "name": "order_by", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "Order of results", + "name": "order", + "in": "query" + }, + { + "type": "string", + "description": "Search string", + "name": "search", + "in": "query" + }, + { + "type": "boolean", + "description": "Include hidden modpacks", + "name": "hidden", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Modpack" + } + } + } + } + ] + } + } + } + } + }, + "/modpacks/{modpackId}": { + "get": { + "description": "Retrieve a single modpack by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a single Modpack", + "parameters": [ + { + "type": "string", + "description": "Modpack ID", + "name": "modpackId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/generated.Modpack" + } + } + } + ] + } + }, + "404": { + "description": "Not Found", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/nodes.ErrorResponse" + } + } + } + ] + } + } + } + } + }, + "/modpacks/{modpackId}/releases/{version}": { + "get": { + "description": "Retrieve a specific release of a modpack", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Modpacks" + ], + "summary": "Retrieve a Modpack Release", + "parameters": [ + { + "type": "string", + "description": "Modpack ID", + "name": "modpackId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Release Version", + "name": "version", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/generated.ModpackRelease" + } + } + } + ] + } + }, + "404": { + "description": "Not Found", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/nodes.GenericResponse" + }, + { + "type": "object", + "properties": { + "error": { + "$ref": "#/definitions/nodes.ErrorResponse" + } + } + } + ] + } + } + } + } + }, "/mods": { "get": { "description": "Retrieve a list of mods", @@ -753,5 +974,623 @@ } } } + }, + "definitions": { + "generated.Compatibility": { + "type": "object", + "properties": { + "note": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/generated.CompatibilityState" + } + } + }, + "generated.CompatibilityInfo": { + "type": "object", + "properties": { + "EA": { + "$ref": "#/definitions/generated.Compatibility" + }, + "EXP": { + "$ref": "#/definitions/generated.Compatibility" + } + } + }, + "generated.CompatibilityState": { + "type": "string", + "enum": [ + "Works", + "Damaged", + "Broken" + ], + "x-enum-varnames": [ + "CompatibilityStateWorks", + "CompatibilityStateDamaged", + "CompatibilityStateBroken" + ] + }, + "generated.Group": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "generated.Guide": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "guide": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "short_description": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/generated.User" + }, + "user_id": { + "type": "string" + }, + "views": { + "type": "integer" + } + } + }, + "generated.LatestVersions": { + "type": "object", + "properties": { + "alpha": { + "$ref": "#/definitions/generated.Version" + }, + "beta": { + "$ref": "#/definitions/generated.Version" + }, + "release": { + "$ref": "#/definitions/generated.Version" + } + } + }, + "generated.Mod": { + "type": "object", + "properties": { + "approved": { + "type": "boolean" + }, + "authors": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.UserMod" + } + }, + "compatibility": { + "$ref": "#/definitions/generated.CompatibilityInfo" + }, + "created_at": { + "type": "string" + }, + "creator_id": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "full_description": { + "type": "string" + }, + "hidden": { + "type": "boolean" + }, + "hotness": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "last_version_date": { + "type": "string" + }, + "latestVersions": { + "$ref": "#/definitions/generated.LatestVersions" + }, + "logo": { + "type": "string" + }, + "logo_thumbhash": { + "type": "string" + }, + "mod_reference": { + "type": "string" + }, + "name": { + "type": "string" + }, + "popularity": { + "type": "integer" + }, + "short_description": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "toggle_explicit_content": { + "type": "boolean" + }, + "toggle_network_use": { + "type": "boolean" + }, + "updated_at": { + "type": "string" + }, + "version": { + "$ref": "#/definitions/generated.Version" + }, + "versions": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Version" + } + }, + "views": { + "type": "integer" + } + } + }, + "generated.Modpack": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Modpack" + } + }, + "created_at": { + "type": "string" + }, + "creator": { + "$ref": "#/definitions/generated.User" + }, + "creator_id": { + "type": "string" + }, + "full_description": { + "type": "string" + }, + "hidden": { + "type": "boolean" + }, + "hotness": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "installs": { + "type": "integer" + }, + "logo": { + "type": "string" + }, + "logo_thumbhash": { + "type": "string" + }, + "mods": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.ModpackModEntry" + } + }, + "name": { + "type": "string" + }, + "parent": { + "$ref": "#/definitions/generated.Modpack" + }, + "parent_id": { + "type": "string" + }, + "popularity": { + "type": "integer" + }, + "releases": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.ModpackRelease" + } + }, + "short_description": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Tag" + } + }, + "targets": { + "type": "array", + "items": { + "type": "string" + } + }, + "updated_at": { + "type": "string" + }, + "views": { + "type": "integer" + } + } + }, + "generated.ModpackModEntry": { + "type": "object", + "properties": { + "mod_id": { + "type": "string" + }, + "version_constraint": { + "type": "string" + } + } + }, + "generated.ModpackRelease": { + "type": "object", + "properties": { + "changelog": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "lockfile": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "generated.Tag": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "generated.TargetName": { + "type": "string", + "enum": [ + "Windows", + "WindowsServer", + "LinuxServer" + ], + "x-enum-varnames": [ + "TargetNameWindows", + "TargetNameWindowsServer", + "TargetNameLinuxServer" + ] + }, + "generated.User": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "avatar_thumbhash": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "email": { + "type": "string" + }, + "facebook_id": { + "type": "string" + }, + "github_id": { + "type": "string" + }, + "google_id": { + "type": "string" + }, + "groups": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Group" + } + }, + "guides": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.Guide" + } + }, + "id": { + "type": "string" + }, + "mods": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.UserMod" + } + }, + "roles": { + "$ref": "#/definitions/generated.UserRoles" + }, + "username": { + "type": "string" + } + } + }, + "generated.UserMod": { + "type": "object", + "properties": { + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "role": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/generated.User" + }, + "user_id": { + "type": "string" + } + } + }, + "generated.UserRoles": { + "type": "object", + "properties": { + "approveMods": { + "type": "boolean" + }, + "approveVersions": { + "type": "boolean" + }, + "deleteContent": { + "type": "boolean" + }, + "editAnyModCompatibility": { + "type": "boolean" + }, + "editBootstrapVersions": { + "type": "boolean" + }, + "editContent": { + "type": "boolean" + }, + "editSatisfactoryVersions": { + "type": "boolean" + }, + "editUsers": { + "type": "boolean" + } + } + }, + "generated.Version": { + "type": "object", + "properties": { + "approved": { + "type": "boolean" + }, + "changelog": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "dependencies": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VersionDependency" + } + }, + "downloads": { + "type": "integer" + }, + "game_version": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "id": { + "type": "string" + }, + "link": { + "type": "string" + }, + "metadata": { + "type": "string" + }, + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "required_on_remote": { + "type": "boolean" + }, + "size": { + "type": "integer" + }, + "sml_version": { + "type": "string" + }, + "stability": { + "$ref": "#/definitions/generated.VersionStabilities" + }, + "targets": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VersionTarget" + } + }, + "updated_at": { + "type": "string" + }, + "version": { + "type": "string" + }, + "virustotal_results": { + "type": "array", + "items": { + "$ref": "#/definitions/generated.VirustotalResult" + } + } + } + }, + "generated.VersionDependency": { + "type": "object", + "properties": { + "condition": { + "type": "string" + }, + "mod": { + "$ref": "#/definitions/generated.Mod" + }, + "mod_id": { + "type": "string" + }, + "mod_reference": { + "type": "string" + }, + "optional": { + "type": "boolean" + }, + "version": { + "$ref": "#/definitions/generated.Version" + }, + "version_id": { + "type": "string" + } + } + }, + "generated.VersionStabilities": { + "type": "string", + "enum": [ + "alpha", + "beta", + "release" + ], + "x-enum-varnames": [ + "VersionStabilitiesAlpha", + "VersionStabilitiesBeta", + "VersionStabilitiesRelease" + ] + }, + "generated.VersionTarget": { + "type": "object", + "properties": { + "VersionID": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "link": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "targetName": { + "$ref": "#/definitions/generated.TargetName" + } + } + }, + "generated.VirustotalResult": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "file_name": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "id": { + "type": "string" + }, + "safe": { + "type": "boolean" + }, + "updated_at": { + "type": "string" + }, + "version_id": { + "type": "string" + } + } + }, + "nodes.ErrorResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } + } + }, + "nodes.GenericResponse": { + "type": "object", + "properties": { + "data": {}, + "error": {}, + "success": { + "type": "boolean" + } + } + } } } \ No newline at end of file diff --git a/generated/docs/swagger.yaml b/generated/docs/swagger.yaml index 648d12a8..66f19ccc 100644 --- a/generated/docs/swagger.yaml +++ b/generated/docs/swagger.yaml @@ -1,4 +1,414 @@ basePath: /v1 +definitions: + generated.Compatibility: + properties: + note: + type: string + state: + $ref: '#/definitions/generated.CompatibilityState' + type: object + generated.CompatibilityInfo: + properties: + EA: + $ref: '#/definitions/generated.Compatibility' + EXP: + $ref: '#/definitions/generated.Compatibility' + type: object + generated.CompatibilityState: + enum: + - Works + - Damaged + - Broken + type: string + x-enum-varnames: + - CompatibilityStateWorks + - CompatibilityStateDamaged + - CompatibilityStateBroken + generated.Group: + properties: + id: + type: string + name: + type: string + type: object + generated.Guide: + properties: + created_at: + type: string + guide: + type: string + id: + type: string + name: + type: string + short_description: + type: string + tags: + items: + $ref: '#/definitions/generated.Tag' + type: array + updated_at: + type: string + user: + $ref: '#/definitions/generated.User' + user_id: + type: string + views: + type: integer + type: object + generated.LatestVersions: + properties: + alpha: + $ref: '#/definitions/generated.Version' + beta: + $ref: '#/definitions/generated.Version' + release: + $ref: '#/definitions/generated.Version' + type: object + generated.Mod: + properties: + approved: + type: boolean + authors: + items: + $ref: '#/definitions/generated.UserMod' + type: array + compatibility: + $ref: '#/definitions/generated.CompatibilityInfo' + created_at: + type: string + creator_id: + type: string + downloads: + type: integer + full_description: + type: string + hidden: + type: boolean + hotness: + type: integer + id: + type: string + last_version_date: + type: string + latestVersions: + $ref: '#/definitions/generated.LatestVersions' + logo: + type: string + logo_thumbhash: + type: string + mod_reference: + type: string + name: + type: string + popularity: + type: integer + short_description: + type: string + source_url: + type: string + tags: + items: + $ref: '#/definitions/generated.Tag' + type: array + toggle_explicit_content: + type: boolean + toggle_network_use: + type: boolean + updated_at: + type: string + version: + $ref: '#/definitions/generated.Version' + versions: + items: + $ref: '#/definitions/generated.Version' + type: array + views: + type: integer + type: object + generated.Modpack: + properties: + children: + items: + $ref: '#/definitions/generated.Modpack' + type: array + created_at: + type: string + creator: + $ref: '#/definitions/generated.User' + creator_id: + type: string + full_description: + type: string + hidden: + type: boolean + hotness: + type: integer + id: + type: string + installs: + type: integer + logo: + type: string + logo_thumbhash: + type: string + mods: + items: + $ref: '#/definitions/generated.ModpackModEntry' + type: array + name: + type: string + parent: + $ref: '#/definitions/generated.Modpack' + parent_id: + type: string + popularity: + type: integer + releases: + items: + $ref: '#/definitions/generated.ModpackRelease' + type: array + short_description: + type: string + tags: + items: + $ref: '#/definitions/generated.Tag' + type: array + targets: + items: + type: string + type: array + updated_at: + type: string + views: + type: integer + type: object + generated.ModpackModEntry: + properties: + mod_id: + type: string + version_constraint: + type: string + type: object + generated.ModpackRelease: + properties: + changelog: + type: string + created_at: + type: string + id: + type: string + lockfile: + type: string + version: + type: string + type: object + generated.Tag: + properties: + description: + type: string + id: + type: string + name: + type: string + type: object + generated.TargetName: + enum: + - Windows + - WindowsServer + - LinuxServer + type: string + x-enum-varnames: + - TargetNameWindows + - TargetNameWindowsServer + - TargetNameLinuxServer + generated.User: + properties: + avatar: + type: string + avatar_thumbhash: + type: string + created_at: + type: string + email: + type: string + facebook_id: + type: string + github_id: + type: string + google_id: + type: string + groups: + items: + $ref: '#/definitions/generated.Group' + type: array + guides: + items: + $ref: '#/definitions/generated.Guide' + type: array + id: + type: string + mods: + items: + $ref: '#/definitions/generated.UserMod' + type: array + roles: + $ref: '#/definitions/generated.UserRoles' + username: + type: string + type: object + generated.UserMod: + properties: + mod: + $ref: '#/definitions/generated.Mod' + mod_id: + type: string + role: + type: string + user: + $ref: '#/definitions/generated.User' + user_id: + type: string + type: object + generated.UserRoles: + properties: + approveMods: + type: boolean + approveVersions: + type: boolean + deleteContent: + type: boolean + editAnyModCompatibility: + type: boolean + editBootstrapVersions: + type: boolean + editContent: + type: boolean + editSatisfactoryVersions: + type: boolean + editUsers: + type: boolean + type: object + generated.Version: + properties: + approved: + type: boolean + changelog: + type: string + created_at: + type: string + dependencies: + items: + $ref: '#/definitions/generated.VersionDependency' + type: array + downloads: + type: integer + game_version: + type: string + hash: + type: string + id: + type: string + link: + type: string + metadata: + type: string + mod: + $ref: '#/definitions/generated.Mod' + mod_id: + type: string + required_on_remote: + type: boolean + size: + type: integer + sml_version: + type: string + stability: + $ref: '#/definitions/generated.VersionStabilities' + targets: + items: + $ref: '#/definitions/generated.VersionTarget' + type: array + updated_at: + type: string + version: + type: string + virustotal_results: + items: + $ref: '#/definitions/generated.VirustotalResult' + type: array + type: object + generated.VersionDependency: + properties: + condition: + type: string + mod: + $ref: '#/definitions/generated.Mod' + mod_id: + type: string + mod_reference: + type: string + optional: + type: boolean + version: + $ref: '#/definitions/generated.Version' + version_id: + type: string + type: object + generated.VersionStabilities: + enum: + - alpha + - beta + - release + type: string + x-enum-varnames: + - VersionStabilitiesAlpha + - VersionStabilitiesBeta + - VersionStabilitiesRelease + generated.VersionTarget: + properties: + VersionID: + type: string + hash: + type: string + link: + type: string + size: + type: integer + targetName: + $ref: '#/definitions/generated.TargetName' + type: object + generated.VirustotalResult: + properties: + created_at: + type: string + file_name: + type: string + hash: + type: string + id: + type: string + safe: + type: boolean + updated_at: + type: string + version_id: + type: string + type: object + nodes.ErrorResponse: + properties: + code: + type: integer + message: + type: string + type: object + nodes.GenericResponse: + properties: + data: {} + error: {} + success: + type: boolean + type: object host: api.ficsit.app info: contact: {} @@ -203,6 +613,140 @@ paths: summary: Retrieve all Mod Versions tags: - Mod + /modpacks: + get: + consumes: + - application/json + description: Retrieve a list of modpacks + parameters: + - description: How many modpacks to return + in: query + name: limit + type: integer + - description: Offset for list of modpacks to return + in: query + name: offset + type: integer + - description: Order by field + enum: + - created_at + - updated_at + - name + - views + - installs + - hotness + - popularity + - search + in: query + name: order_by + type: string + - description: Order of results + enum: + - asc + - desc + in: query + name: order + type: string + - description: Search string + in: query + name: search + type: string + - description: Include hidden modpacks + in: query + name: hidden + type: boolean + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/nodes.GenericResponse' + - properties: + data: + items: + $ref: '#/definitions/generated.Modpack' + type: array + type: object + summary: Retrieve a list of Modpacks + tags: + - Modpacks + /modpacks/{modpackId}: + get: + consumes: + - application/json + description: Retrieve a single modpack by ID + parameters: + - description: Modpack ID + in: path + name: modpackId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/nodes.GenericResponse' + - properties: + data: + $ref: '#/definitions/generated.Modpack' + type: object + "404": + description: Not Found + schema: + allOf: + - $ref: '#/definitions/nodes.GenericResponse' + - properties: + error: + $ref: '#/definitions/nodes.ErrorResponse' + type: object + summary: Retrieve a single Modpack + tags: + - Modpacks + /modpacks/{modpackId}/releases/{version}: + get: + consumes: + - application/json + description: Retrieve a specific release of a modpack + parameters: + - description: Modpack ID + in: path + name: modpackId + required: true + type: string + - description: Release Version + in: path + name: version + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/nodes.GenericResponse' + - properties: + data: + $ref: '#/definitions/generated.ModpackRelease' + type: object + "404": + description: Not Found + schema: + allOf: + - $ref: '#/definitions/nodes.GenericResponse' + - properties: + error: + $ref: '#/definitions/nodes.ErrorResponse' + type: object + summary: Retrieve a Modpack Release + tags: + - Modpacks /mods: get: consumes: diff --git a/generated/ent/client.go b/generated/ent/client.go index 229f799d..c62e45cf 100644 --- a/generated/ent/client.go +++ b/generated/ent/client.go @@ -19,6 +19,11 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/satisfactoryversion" "github.com/satisfactorymodding/smr-api/generated/ent/tag" @@ -49,6 +54,16 @@ type Client struct { Mod *ModClient // ModTag is the client for interacting with the ModTag builders. ModTag *ModTagClient + // Modpack is the client for interacting with the Modpack builders. + Modpack *ModpackClient + // ModpackMod is the client for interacting with the ModpackMod builders. + ModpackMod *ModpackModClient + // ModpackRelease is the client for interacting with the ModpackRelease builders. + ModpackRelease *ModpackReleaseClient + // ModpackTag is the client for interacting with the ModpackTag builders. + ModpackTag *ModpackTagClient + // ModpackTarget is the client for interacting with the ModpackTarget builders. + ModpackTarget *ModpackTargetClient // SatisfactoryVersion is the client for interacting with the SatisfactoryVersion builders. SatisfactoryVersion *SatisfactoryVersionClient // Tag is the client for interacting with the Tag builders. @@ -85,6 +100,11 @@ func (c *Client) init() { c.GuideTag = NewGuideTagClient(c.config) c.Mod = NewModClient(c.config) c.ModTag = NewModTagClient(c.config) + c.Modpack = NewModpackClient(c.config) + c.ModpackMod = NewModpackModClient(c.config) + c.ModpackRelease = NewModpackReleaseClient(c.config) + c.ModpackTag = NewModpackTagClient(c.config) + c.ModpackTarget = NewModpackTargetClient(c.config) c.SatisfactoryVersion = NewSatisfactoryVersionClient(c.config) c.Tag = NewTagClient(c.config) c.User = NewUserClient(c.config) @@ -192,6 +212,11 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { GuideTag: NewGuideTagClient(cfg), Mod: NewModClient(cfg), ModTag: NewModTagClient(cfg), + Modpack: NewModpackClient(cfg), + ModpackMod: NewModpackModClient(cfg), + ModpackRelease: NewModpackReleaseClient(cfg), + ModpackTag: NewModpackTagClient(cfg), + ModpackTarget: NewModpackTargetClient(cfg), SatisfactoryVersion: NewSatisfactoryVersionClient(cfg), Tag: NewTagClient(cfg), User: NewUserClient(cfg), @@ -226,6 +251,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) GuideTag: NewGuideTagClient(cfg), Mod: NewModClient(cfg), ModTag: NewModTagClient(cfg), + Modpack: NewModpackClient(cfg), + ModpackMod: NewModpackModClient(cfg), + ModpackRelease: NewModpackReleaseClient(cfg), + ModpackTag: NewModpackTagClient(cfg), + ModpackTarget: NewModpackTargetClient(cfg), SatisfactoryVersion: NewSatisfactoryVersionClient(cfg), Tag: NewTagClient(cfg), User: NewUserClient(cfg), @@ -265,9 +295,10 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.SatisfactoryVersion, - c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, c.Version, - c.VersionDependency, c.VersionTarget, c.VirustotalResult, + c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.Modpack, c.ModpackMod, + c.ModpackRelease, c.ModpackTag, c.ModpackTarget, c.SatisfactoryVersion, c.Tag, + c.User, c.UserGroup, c.UserMod, c.UserSession, c.Version, c.VersionDependency, + c.VersionTarget, c.VirustotalResult, } { n.Use(hooks...) } @@ -277,9 +308,10 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.SatisfactoryVersion, - c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, c.Version, - c.VersionDependency, c.VersionTarget, c.VirustotalResult, + c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.Modpack, c.ModpackMod, + c.ModpackRelease, c.ModpackTag, c.ModpackTarget, c.SatisfactoryVersion, c.Tag, + c.User, c.UserGroup, c.UserMod, c.UserSession, c.Version, c.VersionDependency, + c.VersionTarget, c.VirustotalResult, } { n.Intercept(interceptors...) } @@ -298,6 +330,16 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Mod.mutate(ctx, m) case *ModTagMutation: return c.ModTag.mutate(ctx, m) + case *ModpackMutation: + return c.Modpack.mutate(ctx, m) + case *ModpackModMutation: + return c.ModpackMod.mutate(ctx, m) + case *ModpackReleaseMutation: + return c.ModpackRelease.mutate(ctx, m) + case *ModpackTagMutation: + return c.ModpackTag.mutate(ctx, m) + case *ModpackTargetMutation: + return c.ModpackTarget.mutate(ctx, m) case *SatisfactoryVersionMutation: return c.SatisfactoryVersion.mutate(ctx, m) case *TagMutation: @@ -929,6 +971,22 @@ func (c *ModClient) QueryDependents(m *Mod) *VersionQuery { return query } +// QueryModpacks queries the modpacks edge of a Mod. +func (c *ModClient) QueryModpacks(m *Mod) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(mod.Table, mod.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.ModpacksTable, mod.ModpacksPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryUserMods queries the user_mods edge of a Mod. func (c *ModClient) QueryUserMods(m *Mod) *UserModQuery { query := (&UserModClient{config: c.config}).Query() @@ -977,6 +1035,22 @@ func (c *ModClient) QueryVersionDependencies(m *Mod) *VersionDependencyQuery { return query } +// QueryModpackMods queries the modpack_mods edge of a Mod. +func (c *ModClient) QueryModpackMods(m *Mod) *ModpackModQuery { + query := (&ModpackModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(mod.Table, mod.FieldID, id), + sqlgraph.To(modpackmod.Table, modpackmod.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.ModpackModsTable, mod.ModpackModsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *ModClient) Hooks() []Hook { hooks := c.hooks.Mod @@ -1120,6 +1194,797 @@ func (c *ModTagClient) mutate(ctx context.Context, m *ModTagMutation) (Value, er } } +// ModpackClient is a client for the Modpack schema. +type ModpackClient struct { + config +} + +// NewModpackClient returns a client for the Modpack from the given config. +func NewModpackClient(c config) *ModpackClient { + return &ModpackClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modpack.Hooks(f(g(h())))`. +func (c *ModpackClient) Use(hooks ...Hook) { + c.hooks.Modpack = append(c.hooks.Modpack, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modpack.Intercept(f(g(h())))`. +func (c *ModpackClient) Intercept(interceptors ...Interceptor) { + c.inters.Modpack = append(c.inters.Modpack, interceptors...) +} + +// Create returns a builder for creating a Modpack entity. +func (c *ModpackClient) Create() *ModpackCreate { + mutation := newModpackMutation(c.config, OpCreate) + return &ModpackCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Modpack entities. +func (c *ModpackClient) CreateBulk(builders ...*ModpackCreate) *ModpackCreateBulk { + return &ModpackCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ModpackClient) MapCreateBulk(slice any, setFunc func(*ModpackCreate, int)) *ModpackCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModpackCreateBulk{err: fmt.Errorf("calling to ModpackClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModpackCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModpackCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Modpack. +func (c *ModpackClient) Update() *ModpackUpdate { + mutation := newModpackMutation(c.config, OpUpdate) + return &ModpackUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModpackClient) UpdateOne(m *Modpack) *ModpackUpdateOne { + mutation := newModpackMutation(c.config, OpUpdateOne, withModpack(m)) + return &ModpackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ModpackClient) UpdateOneID(id string) *ModpackUpdateOne { + mutation := newModpackMutation(c.config, OpUpdateOne, withModpackID(id)) + return &ModpackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Modpack. +func (c *ModpackClient) Delete() *ModpackDelete { + mutation := newModpackMutation(c.config, OpDelete) + return &ModpackDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ModpackClient) DeleteOne(m *Modpack) *ModpackDeleteOne { + return c.DeleteOneID(m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ModpackClient) DeleteOneID(id string) *ModpackDeleteOne { + builder := c.Delete().Where(modpack.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ModpackDeleteOne{builder} +} + +// Query returns a query builder for Modpack. +func (c *ModpackClient) Query() *ModpackQuery { + return &ModpackQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModpack}, + inters: c.Interceptors(), + } +} + +// Get returns a Modpack entity by its id. +func (c *ModpackClient) Get(ctx context.Context, id string) (*Modpack, error) { + return c.Query().Where(modpack.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ModpackClient) GetX(ctx context.Context, id string) *Modpack { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryChildren queries the children edge of a Modpack. +func (c *ModpackClient) QueryChildren(m *Modpack) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.ChildrenTable, modpack.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryParent queries the parent edge of a Modpack. +func (c *ModpackClient) QueryParent(m *Modpack) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpack.ParentTable, modpack.ParentColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTargets queries the targets edge of a Modpack. +func (c *ModpackClient) QueryTargets(m *Modpack) *ModpackTargetQuery { + query := (&ModpackTargetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpacktarget.Table, modpacktarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.TargetsTable, modpack.TargetsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryReleases queries the releases edge of a Modpack. +func (c *ModpackClient) QueryReleases(m *Modpack) *ModpackReleaseQuery { + query := (&ModpackReleaseClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpackrelease.Table, modpackrelease.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.ReleasesTable, modpack.ReleasesColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryMods queries the mods edge of a Modpack. +func (c *ModpackClient) QueryMods(m *Modpack) *ModQuery { + query := (&ModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, modpack.ModsTable, modpack.ModsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTags queries the tags edge of a Modpack. +func (c *ModpackClient) QueryTags(m *Modpack) *TagQuery { + query := (&TagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, modpack.TagsTable, modpack.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryModpackMods queries the modpack_mods edge of a Modpack. +func (c *ModpackClient) QueryModpackMods(m *Modpack) *ModpackModQuery { + query := (&ModpackModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpackmod.Table, modpackmod.ModpackColumn), + sqlgraph.Edge(sqlgraph.O2M, true, modpack.ModpackModsTable, modpack.ModpackModsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryModpackTags queries the modpack_tags edge of a Modpack. +func (c *ModpackClient) QueryModpackTags(m *Modpack) *ModpackTagQuery { + query := (&ModpackTagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, id), + sqlgraph.To(modpacktag.Table, modpacktag.ModpackColumn), + sqlgraph.Edge(sqlgraph.O2M, true, modpack.ModpackTagsTable, modpack.ModpackTagsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ModpackClient) Hooks() []Hook { + return c.hooks.Modpack +} + +// Interceptors returns the client interceptors. +func (c *ModpackClient) Interceptors() []Interceptor { + return c.inters.Modpack +} + +func (c *ModpackClient) mutate(ctx context.Context, m *ModpackMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModpackCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModpackUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModpackUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModpackDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Modpack mutation op: %q", m.Op()) + } +} + +// ModpackModClient is a client for the ModpackMod schema. +type ModpackModClient struct { + config +} + +// NewModpackModClient returns a client for the ModpackMod from the given config. +func NewModpackModClient(c config) *ModpackModClient { + return &ModpackModClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modpackmod.Hooks(f(g(h())))`. +func (c *ModpackModClient) Use(hooks ...Hook) { + c.hooks.ModpackMod = append(c.hooks.ModpackMod, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modpackmod.Intercept(f(g(h())))`. +func (c *ModpackModClient) Intercept(interceptors ...Interceptor) { + c.inters.ModpackMod = append(c.inters.ModpackMod, interceptors...) +} + +// Create returns a builder for creating a ModpackMod entity. +func (c *ModpackModClient) Create() *ModpackModCreate { + mutation := newModpackModMutation(c.config, OpCreate) + return &ModpackModCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ModpackMod entities. +func (c *ModpackModClient) CreateBulk(builders ...*ModpackModCreate) *ModpackModCreateBulk { + return &ModpackModCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ModpackModClient) MapCreateBulk(slice any, setFunc func(*ModpackModCreate, int)) *ModpackModCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModpackModCreateBulk{err: fmt.Errorf("calling to ModpackModClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModpackModCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModpackModCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ModpackMod. +func (c *ModpackModClient) Update() *ModpackModUpdate { + mutation := newModpackModMutation(c.config, OpUpdate) + return &ModpackModUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModpackModClient) UpdateOne(mm *ModpackMod) *ModpackModUpdateOne { + mutation := newModpackModMutation(c.config, OpUpdateOne) + mutation.modpack = &mm.ModpackID + mutation.mod = &mm.ModID + return &ModpackModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ModpackMod. +func (c *ModpackModClient) Delete() *ModpackModDelete { + mutation := newModpackModMutation(c.config, OpDelete) + return &ModpackModDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for ModpackMod. +func (c *ModpackModClient) Query() *ModpackModQuery { + return &ModpackModQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModpackMod}, + inters: c.Interceptors(), + } +} + +// QueryModpack queries the modpack edge of a ModpackMod. +func (c *ModpackModClient) QueryModpack(mm *ModpackMod) *ModpackQuery { + return c.Query(). + Where(modpackmod.ModpackID(mm.ModpackID), modpackmod.ModID(mm.ModID)). + QueryModpack() +} + +// QueryMod queries the mod edge of a ModpackMod. +func (c *ModpackModClient) QueryMod(mm *ModpackMod) *ModQuery { + return c.Query(). + Where(modpackmod.ModpackID(mm.ModpackID), modpackmod.ModID(mm.ModID)). + QueryMod() +} + +// Hooks returns the client hooks. +func (c *ModpackModClient) Hooks() []Hook { + return c.hooks.ModpackMod +} + +// Interceptors returns the client interceptors. +func (c *ModpackModClient) Interceptors() []Interceptor { + return c.inters.ModpackMod +} + +func (c *ModpackModClient) mutate(ctx context.Context, m *ModpackModMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModpackModCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModpackModUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModpackModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModpackModDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ModpackMod mutation op: %q", m.Op()) + } +} + +// ModpackReleaseClient is a client for the ModpackRelease schema. +type ModpackReleaseClient struct { + config +} + +// NewModpackReleaseClient returns a client for the ModpackRelease from the given config. +func NewModpackReleaseClient(c config) *ModpackReleaseClient { + return &ModpackReleaseClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modpackrelease.Hooks(f(g(h())))`. +func (c *ModpackReleaseClient) Use(hooks ...Hook) { + c.hooks.ModpackRelease = append(c.hooks.ModpackRelease, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modpackrelease.Intercept(f(g(h())))`. +func (c *ModpackReleaseClient) Intercept(interceptors ...Interceptor) { + c.inters.ModpackRelease = append(c.inters.ModpackRelease, interceptors...) +} + +// Create returns a builder for creating a ModpackRelease entity. +func (c *ModpackReleaseClient) Create() *ModpackReleaseCreate { + mutation := newModpackReleaseMutation(c.config, OpCreate) + return &ModpackReleaseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ModpackRelease entities. +func (c *ModpackReleaseClient) CreateBulk(builders ...*ModpackReleaseCreate) *ModpackReleaseCreateBulk { + return &ModpackReleaseCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ModpackReleaseClient) MapCreateBulk(slice any, setFunc func(*ModpackReleaseCreate, int)) *ModpackReleaseCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModpackReleaseCreateBulk{err: fmt.Errorf("calling to ModpackReleaseClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModpackReleaseCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModpackReleaseCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ModpackRelease. +func (c *ModpackReleaseClient) Update() *ModpackReleaseUpdate { + mutation := newModpackReleaseMutation(c.config, OpUpdate) + return &ModpackReleaseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModpackReleaseClient) UpdateOne(mr *ModpackRelease) *ModpackReleaseUpdateOne { + mutation := newModpackReleaseMutation(c.config, OpUpdateOne, withModpackRelease(mr)) + return &ModpackReleaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ModpackReleaseClient) UpdateOneID(id string) *ModpackReleaseUpdateOne { + mutation := newModpackReleaseMutation(c.config, OpUpdateOne, withModpackReleaseID(id)) + return &ModpackReleaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ModpackRelease. +func (c *ModpackReleaseClient) Delete() *ModpackReleaseDelete { + mutation := newModpackReleaseMutation(c.config, OpDelete) + return &ModpackReleaseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ModpackReleaseClient) DeleteOne(mr *ModpackRelease) *ModpackReleaseDeleteOne { + return c.DeleteOneID(mr.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ModpackReleaseClient) DeleteOneID(id string) *ModpackReleaseDeleteOne { + builder := c.Delete().Where(modpackrelease.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ModpackReleaseDeleteOne{builder} +} + +// Query returns a query builder for ModpackRelease. +func (c *ModpackReleaseClient) Query() *ModpackReleaseQuery { + return &ModpackReleaseQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModpackRelease}, + inters: c.Interceptors(), + } +} + +// Get returns a ModpackRelease entity by its id. +func (c *ModpackReleaseClient) Get(ctx context.Context, id string) (*ModpackRelease, error) { + return c.Query().Where(modpackrelease.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ModpackReleaseClient) GetX(ctx context.Context, id string) *ModpackRelease { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryModpack queries the modpack edge of a ModpackRelease. +func (c *ModpackReleaseClient) QueryModpack(mr *ModpackRelease) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := mr.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpackrelease.Table, modpackrelease.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpackrelease.ModpackTable, modpackrelease.ModpackColumn), + ) + fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ModpackReleaseClient) Hooks() []Hook { + return c.hooks.ModpackRelease +} + +// Interceptors returns the client interceptors. +func (c *ModpackReleaseClient) Interceptors() []Interceptor { + return c.inters.ModpackRelease +} + +func (c *ModpackReleaseClient) mutate(ctx context.Context, m *ModpackReleaseMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModpackReleaseCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModpackReleaseUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModpackReleaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModpackReleaseDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ModpackRelease mutation op: %q", m.Op()) + } +} + +// ModpackTagClient is a client for the ModpackTag schema. +type ModpackTagClient struct { + config +} + +// NewModpackTagClient returns a client for the ModpackTag from the given config. +func NewModpackTagClient(c config) *ModpackTagClient { + return &ModpackTagClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modpacktag.Hooks(f(g(h())))`. +func (c *ModpackTagClient) Use(hooks ...Hook) { + c.hooks.ModpackTag = append(c.hooks.ModpackTag, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modpacktag.Intercept(f(g(h())))`. +func (c *ModpackTagClient) Intercept(interceptors ...Interceptor) { + c.inters.ModpackTag = append(c.inters.ModpackTag, interceptors...) +} + +// Create returns a builder for creating a ModpackTag entity. +func (c *ModpackTagClient) Create() *ModpackTagCreate { + mutation := newModpackTagMutation(c.config, OpCreate) + return &ModpackTagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ModpackTag entities. +func (c *ModpackTagClient) CreateBulk(builders ...*ModpackTagCreate) *ModpackTagCreateBulk { + return &ModpackTagCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ModpackTagClient) MapCreateBulk(slice any, setFunc func(*ModpackTagCreate, int)) *ModpackTagCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModpackTagCreateBulk{err: fmt.Errorf("calling to ModpackTagClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModpackTagCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModpackTagCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ModpackTag. +func (c *ModpackTagClient) Update() *ModpackTagUpdate { + mutation := newModpackTagMutation(c.config, OpUpdate) + return &ModpackTagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModpackTagClient) UpdateOne(mt *ModpackTag) *ModpackTagUpdateOne { + mutation := newModpackTagMutation(c.config, OpUpdateOne) + mutation.modpack = &mt.ModpackID + mutation.tag = &mt.TagID + return &ModpackTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ModpackTag. +func (c *ModpackTagClient) Delete() *ModpackTagDelete { + mutation := newModpackTagMutation(c.config, OpDelete) + return &ModpackTagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for ModpackTag. +func (c *ModpackTagClient) Query() *ModpackTagQuery { + return &ModpackTagQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModpackTag}, + inters: c.Interceptors(), + } +} + +// QueryModpack queries the modpack edge of a ModpackTag. +func (c *ModpackTagClient) QueryModpack(mt *ModpackTag) *ModpackQuery { + return c.Query(). + Where(modpacktag.ModpackID(mt.ModpackID), modpacktag.TagID(mt.TagID)). + QueryModpack() +} + +// QueryTag queries the tag edge of a ModpackTag. +func (c *ModpackTagClient) QueryTag(mt *ModpackTag) *TagQuery { + return c.Query(). + Where(modpacktag.ModpackID(mt.ModpackID), modpacktag.TagID(mt.TagID)). + QueryTag() +} + +// Hooks returns the client hooks. +func (c *ModpackTagClient) Hooks() []Hook { + return c.hooks.ModpackTag +} + +// Interceptors returns the client interceptors. +func (c *ModpackTagClient) Interceptors() []Interceptor { + return c.inters.ModpackTag +} + +func (c *ModpackTagClient) mutate(ctx context.Context, m *ModpackTagMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModpackTagCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModpackTagUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModpackTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModpackTagDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ModpackTag mutation op: %q", m.Op()) + } +} + +// ModpackTargetClient is a client for the ModpackTarget schema. +type ModpackTargetClient struct { + config +} + +// NewModpackTargetClient returns a client for the ModpackTarget from the given config. +func NewModpackTargetClient(c config) *ModpackTargetClient { + return &ModpackTargetClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modpacktarget.Hooks(f(g(h())))`. +func (c *ModpackTargetClient) Use(hooks ...Hook) { + c.hooks.ModpackTarget = append(c.hooks.ModpackTarget, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modpacktarget.Intercept(f(g(h())))`. +func (c *ModpackTargetClient) Intercept(interceptors ...Interceptor) { + c.inters.ModpackTarget = append(c.inters.ModpackTarget, interceptors...) +} + +// Create returns a builder for creating a ModpackTarget entity. +func (c *ModpackTargetClient) Create() *ModpackTargetCreate { + mutation := newModpackTargetMutation(c.config, OpCreate) + return &ModpackTargetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ModpackTarget entities. +func (c *ModpackTargetClient) CreateBulk(builders ...*ModpackTargetCreate) *ModpackTargetCreateBulk { + return &ModpackTargetCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ModpackTargetClient) MapCreateBulk(slice any, setFunc func(*ModpackTargetCreate, int)) *ModpackTargetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModpackTargetCreateBulk{err: fmt.Errorf("calling to ModpackTargetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModpackTargetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModpackTargetCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ModpackTarget. +func (c *ModpackTargetClient) Update() *ModpackTargetUpdate { + mutation := newModpackTargetMutation(c.config, OpUpdate) + return &ModpackTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModpackTargetClient) UpdateOne(mt *ModpackTarget) *ModpackTargetUpdateOne { + mutation := newModpackTargetMutation(c.config, OpUpdateOne, withModpackTarget(mt)) + return &ModpackTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ModpackTargetClient) UpdateOneID(id string) *ModpackTargetUpdateOne { + mutation := newModpackTargetMutation(c.config, OpUpdateOne, withModpackTargetID(id)) + return &ModpackTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ModpackTarget. +func (c *ModpackTargetClient) Delete() *ModpackTargetDelete { + mutation := newModpackTargetMutation(c.config, OpDelete) + return &ModpackTargetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ModpackTargetClient) DeleteOne(mt *ModpackTarget) *ModpackTargetDeleteOne { + return c.DeleteOneID(mt.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ModpackTargetClient) DeleteOneID(id string) *ModpackTargetDeleteOne { + builder := c.Delete().Where(modpacktarget.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ModpackTargetDeleteOne{builder} +} + +// Query returns a query builder for ModpackTarget. +func (c *ModpackTargetClient) Query() *ModpackTargetQuery { + return &ModpackTargetQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModpackTarget}, + inters: c.Interceptors(), + } +} + +// Get returns a ModpackTarget entity by its id. +func (c *ModpackTargetClient) Get(ctx context.Context, id string) (*ModpackTarget, error) { + return c.Query().Where(modpacktarget.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ModpackTargetClient) GetX(ctx context.Context, id string) *ModpackTarget { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryModpack queries the modpack edge of a ModpackTarget. +func (c *ModpackTargetClient) QueryModpack(mt *ModpackTarget) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := mt.ID + step := sqlgraph.NewStep( + sqlgraph.From(modpacktarget.Table, modpacktarget.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpacktarget.ModpackTable, modpacktarget.ModpackColumn), + ) + fromV = sqlgraph.Neighbors(mt.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ModpackTargetClient) Hooks() []Hook { + return c.hooks.ModpackTarget +} + +// Interceptors returns the client interceptors. +func (c *ModpackTargetClient) Interceptors() []Interceptor { + return c.inters.ModpackTarget +} + +func (c *ModpackTargetClient) mutate(ctx context.Context, m *ModpackTargetMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModpackTargetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModpackTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModpackTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModpackTargetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ModpackTarget mutation op: %q", m.Op()) + } +} + // SatisfactoryVersionClient is a client for the SatisfactoryVersion schema. type SatisfactoryVersionClient struct { config @@ -1393,6 +2258,22 @@ func (c *TagClient) QueryGuides(t *Tag) *GuideQuery { return query } +// QueryModpacks queries the modpacks edge of a Tag. +func (c *TagClient) QueryModpacks(t *Tag) *ModpackQuery { + query := (&ModpackClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, id), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.ModpacksTable, tag.ModpacksPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryModTags queries the mod_tags edge of a Tag. func (c *TagClient) QueryModTags(t *Tag) *ModTagQuery { query := (&ModTagClient{config: c.config}).Query() @@ -1425,6 +2306,22 @@ func (c *TagClient) QueryGuideTags(t *Tag) *GuideTagQuery { return query } +// QueryModpackTags queries the modpack_tags edge of a Tag. +func (c *TagClient) QueryModpackTags(t *Tag) *ModpackTagQuery { + query := (&ModpackTagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, id), + sqlgraph.To(modpacktag.Table, modpacktag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.ModpackTagsTable, tag.ModpackTagsColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *TagClient) Hooks() []Hook { hooks := c.hooks.Tag @@ -2719,13 +3616,15 @@ func (c *VirustotalResultClient) mutate(ctx context.Context, m *VirustotalResult // hooks and interceptors per client, for fast access. type ( hooks struct { - Announcement, Guide, GuideTag, Mod, ModTag, SatisfactoryVersion, Tag, User, - UserGroup, UserMod, UserSession, Version, VersionDependency, VersionTarget, + Announcement, Guide, GuideTag, Mod, ModTag, Modpack, ModpackMod, ModpackRelease, + ModpackTag, ModpackTarget, SatisfactoryVersion, Tag, User, UserGroup, UserMod, + UserSession, Version, VersionDependency, VersionTarget, VirustotalResult []ent.Hook } inters struct { - Announcement, Guide, GuideTag, Mod, ModTag, SatisfactoryVersion, Tag, User, - UserGroup, UserMod, UserSession, Version, VersionDependency, VersionTarget, + Announcement, Guide, GuideTag, Mod, ModTag, Modpack, ModpackMod, ModpackRelease, + ModpackTag, ModpackTarget, SatisfactoryVersion, Tag, User, UserGroup, UserMod, + UserSession, Version, VersionDependency, VersionTarget, VirustotalResult []ent.Interceptor } ) diff --git a/generated/ent/ent.go b/generated/ent/ent.go index f85692b0..7c4c4449 100644 --- a/generated/ent/ent.go +++ b/generated/ent/ent.go @@ -16,6 +16,11 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/satisfactoryversion" "github.com/satisfactorymodding/smr-api/generated/ent/tag" @@ -92,6 +97,11 @@ func checkColumn(table, column string) error { guidetag.Table: guidetag.ValidColumn, mod.Table: mod.ValidColumn, modtag.Table: modtag.ValidColumn, + modpack.Table: modpack.ValidColumn, + modpackmod.Table: modpackmod.ValidColumn, + modpackrelease.Table: modpackrelease.ValidColumn, + modpacktag.Table: modpacktag.ValidColumn, + modpacktarget.Table: modpacktarget.ValidColumn, satisfactoryversion.Table: satisfactoryversion.ValidColumn, tag.Table: tag.ValidColumn, user.Table: user.ValidColumn, diff --git a/generated/ent/hook/hook.go b/generated/ent/hook/hook.go index 45849c4c..9f2573ac 100644 --- a/generated/ent/hook/hook.go +++ b/generated/ent/hook/hook.go @@ -69,6 +69,66 @@ func (f ModTagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, erro return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModTagMutation", m) } +// The ModpackFunc type is an adapter to allow the use of ordinary +// function as Modpack mutator. +type ModpackFunc func(context.Context, *ent.ModpackMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModpackFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModpackMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModpackMutation", m) +} + +// The ModpackModFunc type is an adapter to allow the use of ordinary +// function as ModpackMod mutator. +type ModpackModFunc func(context.Context, *ent.ModpackModMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModpackModFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModpackModMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModpackModMutation", m) +} + +// The ModpackReleaseFunc type is an adapter to allow the use of ordinary +// function as ModpackRelease mutator. +type ModpackReleaseFunc func(context.Context, *ent.ModpackReleaseMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModpackReleaseFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModpackReleaseMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModpackReleaseMutation", m) +} + +// The ModpackTagFunc type is an adapter to allow the use of ordinary +// function as ModpackTag mutator. +type ModpackTagFunc func(context.Context, *ent.ModpackTagMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModpackTagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModpackTagMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModpackTagMutation", m) +} + +// The ModpackTargetFunc type is an adapter to allow the use of ordinary +// function as ModpackTarget mutator. +type ModpackTargetFunc func(context.Context, *ent.ModpackTargetMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModpackTargetFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModpackTargetMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModpackTargetMutation", m) +} + // The SatisfactoryVersionFunc type is an adapter to allow the use of ordinary // function as SatisfactoryVersion mutator. type SatisfactoryVersionFunc func(context.Context, *ent.SatisfactoryVersionMutation) (ent.Value, error) diff --git a/generated/ent/intercept/intercept.go b/generated/ent/intercept/intercept.go index d56f178f..cfd82b33 100644 --- a/generated/ent/intercept/intercept.go +++ b/generated/ent/intercept/intercept.go @@ -12,6 +12,11 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/satisfactoryversion" @@ -217,6 +222,141 @@ func (f TraverseModTag) Traverse(ctx context.Context, q ent.Query) error { return fmt.Errorf("unexpected query type %T. expect *ent.ModTagQuery", q) } +// The ModpackFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModpackFunc func(context.Context, *ent.ModpackQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModpackFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModpackQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModpackQuery", q) +} + +// The TraverseModpack type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModpack func(context.Context, *ent.ModpackQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModpack) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModpack) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModpackQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModpackQuery", q) +} + +// The ModpackModFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModpackModFunc func(context.Context, *ent.ModpackModQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModpackModFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModpackModQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModpackModQuery", q) +} + +// The TraverseModpackMod type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModpackMod func(context.Context, *ent.ModpackModQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModpackMod) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModpackMod) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModpackModQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModpackModQuery", q) +} + +// The ModpackReleaseFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModpackReleaseFunc func(context.Context, *ent.ModpackReleaseQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModpackReleaseFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModpackReleaseQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModpackReleaseQuery", q) +} + +// The TraverseModpackRelease type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModpackRelease func(context.Context, *ent.ModpackReleaseQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModpackRelease) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModpackRelease) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModpackReleaseQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModpackReleaseQuery", q) +} + +// The ModpackTagFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModpackTagFunc func(context.Context, *ent.ModpackTagQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModpackTagFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModpackTagQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModpackTagQuery", q) +} + +// The TraverseModpackTag type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModpackTag func(context.Context, *ent.ModpackTagQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModpackTag) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModpackTag) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModpackTagQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModpackTagQuery", q) +} + +// The ModpackTargetFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModpackTargetFunc func(context.Context, *ent.ModpackTargetQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModpackTargetFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModpackTargetQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModpackTargetQuery", q) +} + +// The TraverseModpackTarget type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModpackTarget func(context.Context, *ent.ModpackTargetQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModpackTarget) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModpackTarget) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModpackTargetQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModpackTargetQuery", q) +} + // The SatisfactoryVersionFunc type is an adapter to allow the use of ordinary function as a Querier. type SatisfactoryVersionFunc func(context.Context, *ent.SatisfactoryVersionQuery) (ent.Value, error) @@ -500,6 +640,16 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.ModQuery, predicate.Mod, mod.OrderOption]{typ: ent.TypeMod, tq: q}, nil case *ent.ModTagQuery: return &query[*ent.ModTagQuery, predicate.ModTag, modtag.OrderOption]{typ: ent.TypeModTag, tq: q}, nil + case *ent.ModpackQuery: + return &query[*ent.ModpackQuery, predicate.Modpack, modpack.OrderOption]{typ: ent.TypeModpack, tq: q}, nil + case *ent.ModpackModQuery: + return &query[*ent.ModpackModQuery, predicate.ModpackMod, modpackmod.OrderOption]{typ: ent.TypeModpackMod, tq: q}, nil + case *ent.ModpackReleaseQuery: + return &query[*ent.ModpackReleaseQuery, predicate.ModpackRelease, modpackrelease.OrderOption]{typ: ent.TypeModpackRelease, tq: q}, nil + case *ent.ModpackTagQuery: + return &query[*ent.ModpackTagQuery, predicate.ModpackTag, modpacktag.OrderOption]{typ: ent.TypeModpackTag, tq: q}, nil + case *ent.ModpackTargetQuery: + return &query[*ent.ModpackTargetQuery, predicate.ModpackTarget, modpacktarget.OrderOption]{typ: ent.TypeModpackTarget, tq: q}, nil case *ent.SatisfactoryVersionQuery: return &query[*ent.SatisfactoryVersionQuery, predicate.SatisfactoryVersion, satisfactoryversion.OrderOption]{typ: ent.TypeSatisfactoryVersion, tq: q}, nil case *ent.TagQuery: diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go index 232ecbe6..3425bf0d 100644 --- a/generated/ent/internal/schema.go +++ b/generated/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"github.com/satisfactorymodding/smr-api/db/schema\",\"Package\":\"github.com/satisfactorymodding/smr-api/generated/ent\",\"Schemas\":[{\"name\":\"Announcement\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"message\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"importance\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"Guide\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"guides\",\"unique\":true,\"inverse\":true},{\"name\":\"tags\",\"type\":\"Tag\",\"through\":{\"N\":\"guide_tags\",\"T\":\"GuideTag\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"short_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"guide\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"views\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"GuideTag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"guide\",\"type\":\"Guide\",\"field\":\"guide_id\",\"unique\":true,\"required\":true},{\"name\":\"tag\",\"type\":\"Tag\",\"field\":\"tag_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"guide_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"tag_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"guide_id\",\"tag_id\"],\"StructTag\":null}}},{\"name\":\"Mod\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"versions\",\"type\":\"Version\"},{\"name\":\"authors\",\"type\":\"User\",\"ref_name\":\"mods\",\"through\":{\"N\":\"user_mods\",\"T\":\"UserMod\"},\"inverse\":true},{\"name\":\"tags\",\"type\":\"Tag\",\"through\":{\"N\":\"mod_tags\",\"T\":\"ModTag\"}},{\"name\":\"dependents\",\"type\":\"Version\",\"ref_name\":\"dependencies\",\"through\":{\"N\":\"version_dependencies\",\"T\":\"VersionDependency\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"short_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"full_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo_thumbhash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"source_url\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"creator_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"views\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hotness\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"popularity\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"downloads\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"last_version_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hidden\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"compatibility\",\"type\":{\"Type\":3,\"Ident\":\"*util.CompatibilityInfo\",\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"PkgName\":\"util\",\"Nillable\":true,\"RType\":{\"Name\":\"CompatibilityInfo\",\"Ident\":\"util.CompatibilityInfo\",\"Kind\":22,\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"toggle_network_use\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"toggle_explicit_content\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"fields\":[\"last_version_date\"]},{\"unique\":true,\"fields\":[\"mod_reference\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"ModTag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true},{\"name\":\"tag\",\"type\":\"Tag\",\"field\":\"tag_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"tag_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"mod_id\",\"tag_id\"],\"StructTag\":null}}},{\"name\":\"SatisfactoryVersion\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"version\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"engine_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"4.26\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Tag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mods\",\"type\":\"Mod\",\"ref_name\":\"tags\",\"through\":{\"N\":\"mod_tags\",\"T\":\"ModTag\"},\"inverse\":true},{\"name\":\"guides\",\"type\":\"Guide\",\"ref_name\":\"tags\",\"through\":{\"N\":\"guide_tags\",\"T\":\"GuideTag\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":24,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"optional\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"guides\",\"type\":\"Guide\"},{\"name\":\"sessions\",\"type\":\"UserSession\",\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"user_id\"]}},{\"name\":\"mods\",\"type\":\"Mod\",\"through\":{\"N\":\"user_mods\",\"T\":\"UserMod\"}},{\"name\":\"groups\",\"type\":\"UserGroup\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"avatar_thumbhash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"joined_from\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"banned\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"rank\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"github_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"google_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"optional\":true,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"facebook_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"optional\":true,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"email\"]},{\"unique\":true,\"fields\":[\"github_id\"]},{\"unique\":true,\"fields\":[\"google_id\"]},{\"unique\":true,\"fields\":[\"facebook_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"UserGroup\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"groups\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"group_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"user_id\",\"group_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"UserMod\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"role\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"user_id\",\"mod_id\"],\"StructTag\":null}}},{\"name\":\"UserSession\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"sessions\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"user_agent\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"token\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"Version\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"ref_name\":\"versions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"dependencies\",\"type\":\"Mod\",\"through\":{\"N\":\"version_dependencies\",\"T\":\"VersionDependency\"}},{\"name\":\"targets\",\"type\":\"VersionTarget\"},{\"name\":\"virustotal_results\",\"type\":\"VirustotalResult\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"game_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"required_on_remote\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"downloads\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"stability\",\"type\":{\"Type\":6,\"Ident\":\"util.Stability\",\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"PkgName\":\"util\",\"Nillable\":false,\"RType\":{\"Name\":\"Stability\",\"Ident\":\"util.Stability\",\"Kind\":24,\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"Methods\":{\"Values\":{\"In\":[],\"Out\":[{\"Name\":\"\",\"Ident\":\"[]string\",\"Kind\":23,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"enums\":[{\"N\":\"release\",\"V\":\"release\"},{\"N\":\"beta\",\"V\":\"beta\"},{\"N\":\"alpha\",\"V\":\"alpha\"}],\"default\":true,\"default_value\":\"release\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hotness\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"metadata\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_major\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_minor\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_patch\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"optional\":true,\"validators\":2,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"fields\":[\"approved\"]},{\"fields\":[\"denied\"]},{\"fields\":[\"mod_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"VersionDependency\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"unique\":true,\"required\":true},{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"condition\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"optional\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Fields\":{\"ID\":[\"version_id\",\"mod_id\"],\"StructTag\":null}}},{\"name\":\"VersionTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"ref_name\":\"targets\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"target_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]},{\"name\":\"VirustotalResult\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"ref_name\":\"virustotal_results\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"safe\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"file_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":2,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"safe\"]},{\"unique\":true,\"fields\":[\"hash\",\"version_id\"]},{\"fields\":[\"file_name\"]}]}],\"Features\":[\"sql/modifier\",\"intercept\",\"schema/snapshot\",\"sql/execquery\",\"sql/upsert\"]}" +const Schema = "{\"Schema\":\"github.com/satisfactorymodding/smr-api/db/schema\",\"Package\":\"github.com/satisfactorymodding/smr-api/generated/ent\",\"Schemas\":[{\"name\":\"Announcement\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"message\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"importance\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"Guide\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"guides\",\"unique\":true,\"inverse\":true},{\"name\":\"tags\",\"type\":\"Tag\",\"through\":{\"N\":\"guide_tags\",\"T\":\"GuideTag\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"short_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"guide\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"views\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"GuideTag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"guide\",\"type\":\"Guide\",\"field\":\"guide_id\",\"unique\":true,\"required\":true},{\"name\":\"tag\",\"type\":\"Tag\",\"field\":\"tag_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"guide_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"tag_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"guide_id\",\"tag_id\"],\"StructTag\":null}}},{\"name\":\"Mod\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"versions\",\"type\":\"Version\"},{\"name\":\"authors\",\"type\":\"User\",\"ref_name\":\"mods\",\"through\":{\"N\":\"user_mods\",\"T\":\"UserMod\"},\"inverse\":true},{\"name\":\"tags\",\"type\":\"Tag\",\"through\":{\"N\":\"mod_tags\",\"T\":\"ModTag\"}},{\"name\":\"dependents\",\"type\":\"Version\",\"ref_name\":\"dependencies\",\"through\":{\"N\":\"version_dependencies\",\"T\":\"VersionDependency\"},\"inverse\":true},{\"name\":\"modpacks\",\"type\":\"Modpack\",\"ref_name\":\"mods\",\"through\":{\"N\":\"modpack_mods\",\"T\":\"ModpackMod\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"short_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"full_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo_thumbhash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"source_url\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"creator_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"views\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hotness\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"popularity\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"downloads\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"last_version_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hidden\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"compatibility\",\"type\":{\"Type\":3,\"Ident\":\"*util.CompatibilityInfo\",\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"PkgName\":\"util\",\"Nillable\":true,\"RType\":{\"Name\":\"CompatibilityInfo\",\"Ident\":\"util.CompatibilityInfo\",\"Kind\":22,\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"toggle_network_use\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"toggle_explicit_content\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"fields\":[\"last_version_date\"]},{\"unique\":true,\"fields\":[\"mod_reference\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"ModTag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true},{\"name\":\"tag\",\"type\":\"Tag\",\"field\":\"tag_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"tag_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"mod_id\",\"tag_id\"],\"StructTag\":null}}},{\"name\":\"Modpack\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Modpack\",\"annotations\":{\"EntSQL\":{\"on_delete\":\"RESTRICT\"}}},{\"name\":\"parent\",\"type\":\"Modpack\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true,\"immutable\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"RESTRICT\"}}},{\"name\":\"targets\",\"type\":\"ModpackTarget\",\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}},{\"name\":\"releases\",\"type\":\"ModpackRelease\",\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}},{\"name\":\"mods\",\"type\":\"Mod\",\"through\":{\"N\":\"modpack_mods\",\"T\":\"ModpackMod\"},\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}},{\"name\":\"tags\",\"type\":\"Tag\",\"through\":{\"N\":\"modpack_tags\",\"T\":\"ModpackTag\"},\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"short_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"full_description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"logo_thumbhash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"creator_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"views\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hotness\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"installs\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"popularity\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hidden\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"parent_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"immutable\":true,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"ModpackMod\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"modpack\",\"type\":\"Modpack\",\"field\":\"modpack_id\",\"unique\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}},{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}}],\"fields\":[{\"name\":\"modpack_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_constraint\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"modpack_id\",\"mod_id\"],\"StructTag\":null}}},{\"name\":\"ModpackRelease\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"modpack\",\"type\":\"Modpack\",\"field\":\"modpack_id\",\"ref_name\":\"releases\",\"unique\":true,\"inverse\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"modpack_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"lockfile\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"unique\":true,\"fields\":[\"modpack_id\",\"version\"]}]},{\"name\":\"ModpackTag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"modpack\",\"type\":\"Modpack\",\"field\":\"modpack_id\",\"unique\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}},{\"name\":\"tag\",\"type\":\"Tag\",\"field\":\"tag_id\",\"unique\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}}],\"fields\":[{\"name\":\"modpack_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"tag_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"modpack_id\",\"tag_id\"],\"StructTag\":null}}},{\"name\":\"ModpackTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"modpack\",\"type\":\"Modpack\",\"field\":\"modpack_id\",\"ref_name\":\"targets\",\"unique\":true,\"inverse\":true,\"required\":true,\"annotations\":{\"EntSQL\":{\"on_delete\":\"CASCADE\"}}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"modpack_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"target_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"unique\":true,\"fields\":[\"modpack_id\",\"target_name\"]}]},{\"name\":\"SatisfactoryVersion\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"version\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"engine_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"4.26\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Tag\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mods\",\"type\":\"Mod\",\"ref_name\":\"tags\",\"through\":{\"N\":\"mod_tags\",\"T\":\"ModTag\"},\"inverse\":true},{\"name\":\"guides\",\"type\":\"Guide\",\"ref_name\":\"tags\",\"through\":{\"N\":\"guide_tags\",\"T\":\"GuideTag\"},\"inverse\":true},{\"name\":\"modpacks\",\"type\":\"Modpack\",\"ref_name\":\"tags\",\"through\":{\"N\":\"modpack_tags\",\"T\":\"ModpackTag\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":24,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"optional\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"guides\",\"type\":\"Guide\"},{\"name\":\"sessions\",\"type\":\"UserSession\",\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"user_id\"]}},{\"name\":\"mods\",\"type\":\"Mod\",\"through\":{\"N\":\"user_mods\",\"T\":\"UserMod\"}},{\"name\":\"groups\",\"type\":\"UserGroup\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"avatar_thumbhash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"joined_from\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"banned\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"rank\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"github_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"google_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"optional\":true,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"facebook_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"optional\":true,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"email\"]},{\"unique\":true,\"fields\":[\"github_id\"]},{\"unique\":true,\"fields\":[\"google_id\"]},{\"unique\":true,\"fields\":[\"facebook_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"UserGroup\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"ref_name\":\"groups\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"group_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"user_id\",\"group_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"UserMod\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"role\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"annotations\":{\"Fields\":{\"ID\":[\"user_id\",\"mod_id\"],\"StructTag\":null}}},{\"name\":\"UserSession\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"ref_name\":\"sessions\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"user_agent\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"unique\":true,\"fields\":[\"token\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"Version\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"ref_name\":\"versions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"dependencies\",\"type\":\"Mod\",\"through\":{\"N\":\"version_dependencies\",\"T\":\"VersionDependency\"}},{\"name\":\"targets\",\"type\":\"VersionTarget\"},{\"name\":\"virustotal_results\",\"type\":\"VirustotalResult\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"game_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"required_on_remote\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"downloads\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"stability\",\"type\":{\"Type\":6,\"Ident\":\"util.Stability\",\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"PkgName\":\"util\",\"Nillable\":false,\"RType\":{\"Name\":\"Stability\",\"Ident\":\"util.Stability\",\"Kind\":24,\"PkgPath\":\"github.com/satisfactorymodding/smr-api/util\",\"Methods\":{\"Values\":{\"In\":[],\"Out\":[{\"Name\":\"\",\"Ident\":\"[]string\",\"Kind\":23,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"enums\":[{\"N\":\"release\",\"V\":\"release\"},{\"N\":\"beta\",\"V\":\"beta\"},{\"N\":\"alpha\",\"V\":\"alpha\"}],\"default\":true,\"default_value\":\"release\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hotness\",\"type\":{\"Type\":17,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":7,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"metadata\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_major\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_minor\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_patch\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"optional\":true,\"validators\":2,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]},{\"fields\":[\"approved\"]},{\"fields\":[\"denied\"]},{\"fields\":[\"mod_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"VersionDependency\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"unique\":true,\"required\":true},{\"name\":\"mod\",\"type\":\"Mod\",\"field\":\"mod_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"deleted_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"condition\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"optional\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Fields\":{\"ID\":[\"version_id\",\"mod_id\"],\"StructTag\":null}}},{\"name\":\"VersionTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"ref_name\":\"targets\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"target_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]},{\"name\":\"VirustotalResult\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"version\",\"type\":\"Version\",\"field\":\"version_id\",\"ref_name\":\"virustotal_results\",\"unique\":true,\"inverse\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0}},{\"name\":\"created_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"updated_at\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1}},{\"name\":\"safe\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"file_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"validators\":2,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"safe\"]},{\"unique\":true,\"fields\":[\"hash\",\"version_id\"]},{\"fields\":[\"file_name\"]}]}],\"Features\":[\"sql/modifier\",\"intercept\",\"schema/snapshot\",\"sql/execquery\",\"sql/upsert\"]}" diff --git a/generated/ent/migrate/schema.go b/generated/ent/migrate/schema.go index f84c046d..f115d12e 100644 --- a/generated/ent/migrate/schema.go +++ b/generated/ent/migrate/schema.go @@ -162,6 +162,147 @@ var ( }, }, } + // ModpacksColumns holds the columns for the "modpacks" table. + ModpacksColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString}, + {Name: "short_description", Type: field.TypeString, Size: 128}, + {Name: "full_description", Type: field.TypeString}, + {Name: "logo", Type: field.TypeString, Nullable: true}, + {Name: "logo_thumbhash", Type: field.TypeString, Nullable: true}, + {Name: "creator_id", Type: field.TypeString}, + {Name: "views", Type: field.TypeUint, Default: 0}, + {Name: "hotness", Type: field.TypeUint, Default: 0}, + {Name: "installs", Type: field.TypeUint, Default: 0}, + {Name: "popularity", Type: field.TypeUint, Default: 0}, + {Name: "hidden", Type: field.TypeBool, Default: false}, + {Name: "parent_id", Type: field.TypeString, Nullable: true}, + } + // ModpacksTable holds the schema information for the "modpacks" table. + ModpacksTable = &schema.Table{ + Name: "modpacks", + Columns: ModpacksColumns, + PrimaryKey: []*schema.Column{ModpacksColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "modpacks_modpacks_children", + Columns: []*schema.Column{ModpacksColumns[14]}, + RefColumns: []*schema.Column{ModpacksColumns[0]}, + OnDelete: schema.Restrict, + }, + }, + } + // ModpackModsColumns holds the columns for the "modpack_mods" table. + ModpackModsColumns = []*schema.Column{ + {Name: "version_constraint", Type: field.TypeString}, + {Name: "modpack_id", Type: field.TypeString}, + {Name: "mod_id", Type: field.TypeString}, + } + // ModpackModsTable holds the schema information for the "modpack_mods" table. + ModpackModsTable = &schema.Table{ + Name: "modpack_mods", + Columns: ModpackModsColumns, + PrimaryKey: []*schema.Column{ModpackModsColumns[1], ModpackModsColumns[2]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "modpack_mods_modpacks_modpack", + Columns: []*schema.Column{ModpackModsColumns[1]}, + RefColumns: []*schema.Column{ModpacksColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "modpack_mods_mods_mod", + Columns: []*schema.Column{ModpackModsColumns[2]}, + RefColumns: []*schema.Column{ModsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // ModpackReleasesColumns holds the columns for the "modpack_releases" table. + ModpackReleasesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "version", Type: field.TypeString}, + {Name: "changelog", Type: field.TypeString}, + {Name: "lockfile", Type: field.TypeString}, + {Name: "modpack_id", Type: field.TypeString}, + } + // ModpackReleasesTable holds the schema information for the "modpack_releases" table. + ModpackReleasesTable = &schema.Table{ + Name: "modpack_releases", + Columns: ModpackReleasesColumns, + PrimaryKey: []*schema.Column{ModpackReleasesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "modpack_releases_modpacks_releases", + Columns: []*schema.Column{ModpackReleasesColumns[6]}, + RefColumns: []*schema.Column{ModpacksColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "modpackrelease_modpack_id_version", + Unique: true, + Columns: []*schema.Column{ModpackReleasesColumns[6], ModpackReleasesColumns[3]}, + }, + }, + } + // ModpackTagsColumns holds the columns for the "modpack_tags" table. + ModpackTagsColumns = []*schema.Column{ + {Name: "modpack_id", Type: field.TypeString}, + {Name: "tag_id", Type: field.TypeString}, + } + // ModpackTagsTable holds the schema information for the "modpack_tags" table. + ModpackTagsTable = &schema.Table{ + Name: "modpack_tags", + Columns: ModpackTagsColumns, + PrimaryKey: []*schema.Column{ModpackTagsColumns[0], ModpackTagsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "modpack_tags_modpacks_modpack", + Columns: []*schema.Column{ModpackTagsColumns[0]}, + RefColumns: []*schema.Column{ModpacksColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "modpack_tags_tags_tag", + Columns: []*schema.Column{ModpackTagsColumns[1]}, + RefColumns: []*schema.Column{TagsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // ModpackTargetsColumns holds the columns for the "modpack_targets" table. + ModpackTargetsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "target_name", Type: field.TypeString}, + {Name: "modpack_id", Type: field.TypeString}, + } + // ModpackTargetsTable holds the schema information for the "modpack_targets" table. + ModpackTargetsTable = &schema.Table{ + Name: "modpack_targets", + Columns: ModpackTargetsColumns, + PrimaryKey: []*schema.Column{ModpackTargetsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "modpack_targets_modpacks_targets", + Columns: []*schema.Column{ModpackTargetsColumns[2]}, + RefColumns: []*schema.Column{ModpacksColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "modpacktarget_modpack_id_target_name", + Unique: true, + Columns: []*schema.Column{ModpackTargetsColumns[2], ModpackTargetsColumns[1]}, + }, + }, + } // SatisfactoryVersionsColumns holds the columns for the "satisfactory_versions" table. SatisfactoryVersionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, @@ -519,6 +660,11 @@ var ( GuideTagsTable, ModsTable, ModTagsTable, + ModpacksTable, + ModpackModsTable, + ModpackReleasesTable, + ModpackTagsTable, + ModpackTargetsTable, SatisfactoryVersionsTable, TagsTable, UsersTable, @@ -538,6 +684,13 @@ func init() { GuideTagsTable.ForeignKeys[1].RefTable = TagsTable ModTagsTable.ForeignKeys[0].RefTable = ModsTable ModTagsTable.ForeignKeys[1].RefTable = TagsTable + ModpacksTable.ForeignKeys[0].RefTable = ModpacksTable + ModpackModsTable.ForeignKeys[0].RefTable = ModpacksTable + ModpackModsTable.ForeignKeys[1].RefTable = ModsTable + ModpackReleasesTable.ForeignKeys[0].RefTable = ModpacksTable + ModpackTagsTable.ForeignKeys[0].RefTable = ModpacksTable + ModpackTagsTable.ForeignKeys[1].RefTable = TagsTable + ModpackTargetsTable.ForeignKeys[0].RefTable = ModpacksTable UserGroupsTable.ForeignKeys[0].RefTable = UsersTable UserModsTable.ForeignKeys[0].RefTable = UsersTable UserModsTable.ForeignKeys[1].RefTable = ModsTable diff --git a/generated/ent/mod.go b/generated/ent/mod.go index 79ae3375..c230d24d 100644 --- a/generated/ent/mod.go +++ b/generated/ent/mod.go @@ -79,15 +79,19 @@ type ModEdges struct { Tags []*Tag `json:"tags,omitempty"` // Dependents holds the value of the dependents edge. Dependents []*Version `json:"dependents,omitempty"` + // Modpacks holds the value of the modpacks edge. + Modpacks []*Modpack `json:"modpacks,omitempty"` // UserMods holds the value of the user_mods edge. UserMods []*UserMod `json:"user_mods,omitempty"` // ModTags holds the value of the mod_tags edge. ModTags []*ModTag `json:"mod_tags,omitempty"` // VersionDependencies holds the value of the version_dependencies edge. VersionDependencies []*VersionDependency `json:"version_dependencies,omitempty"` + // ModpackMods holds the value of the modpack_mods edge. + ModpackMods []*ModpackMod `json:"modpack_mods,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [7]bool + loadedTypes [9]bool } // VersionsOrErr returns the Versions value or an error if the edge @@ -126,10 +130,19 @@ func (e ModEdges) DependentsOrErr() ([]*Version, error) { return nil, &NotLoadedError{edge: "dependents"} } +// ModpacksOrErr returns the Modpacks value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) ModpacksOrErr() ([]*Modpack, error) { + if e.loadedTypes[4] { + return e.Modpacks, nil + } + return nil, &NotLoadedError{edge: "modpacks"} +} + // UserModsOrErr returns the UserMods value or an error if the edge // was not loaded in eager-loading. func (e ModEdges) UserModsOrErr() ([]*UserMod, error) { - if e.loadedTypes[4] { + if e.loadedTypes[5] { return e.UserMods, nil } return nil, &NotLoadedError{edge: "user_mods"} @@ -138,7 +151,7 @@ func (e ModEdges) UserModsOrErr() ([]*UserMod, error) { // ModTagsOrErr returns the ModTags value or an error if the edge // was not loaded in eager-loading. func (e ModEdges) ModTagsOrErr() ([]*ModTag, error) { - if e.loadedTypes[5] { + if e.loadedTypes[6] { return e.ModTags, nil } return nil, &NotLoadedError{edge: "mod_tags"} @@ -147,12 +160,21 @@ func (e ModEdges) ModTagsOrErr() ([]*ModTag, error) { // VersionDependenciesOrErr returns the VersionDependencies value or an error if the edge // was not loaded in eager-loading. func (e ModEdges) VersionDependenciesOrErr() ([]*VersionDependency, error) { - if e.loadedTypes[6] { + if e.loadedTypes[7] { return e.VersionDependencies, nil } return nil, &NotLoadedError{edge: "version_dependencies"} } +// ModpackModsOrErr returns the ModpackMods value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) ModpackModsOrErr() ([]*ModpackMod, error) { + if e.loadedTypes[8] { + return e.ModpackMods, nil + } + return nil, &NotLoadedError{edge: "modpack_mods"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Mod) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -356,6 +378,11 @@ func (m *Mod) QueryDependents() *VersionQuery { return NewModClient(m.config).QueryDependents(m) } +// QueryModpacks queries the "modpacks" edge of the Mod entity. +func (m *Mod) QueryModpacks() *ModpackQuery { + return NewModClient(m.config).QueryModpacks(m) +} + // QueryUserMods queries the "user_mods" edge of the Mod entity. func (m *Mod) QueryUserMods() *UserModQuery { return NewModClient(m.config).QueryUserMods(m) @@ -371,6 +398,11 @@ func (m *Mod) QueryVersionDependencies() *VersionDependencyQuery { return NewModClient(m.config).QueryVersionDependencies(m) } +// QueryModpackMods queries the "modpack_mods" edge of the Mod entity. +func (m *Mod) QueryModpackMods() *ModpackModQuery { + return NewModClient(m.config).QueryModpackMods(m) +} + // Update returns a builder for updating this Mod. // Note that you need to call Mod.Unwrap() before calling this method if this Mod // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/generated/ent/mod/mod.go b/generated/ent/mod/mod.go index 7d6572df..0c8732eb 100644 --- a/generated/ent/mod/mod.go +++ b/generated/ent/mod/mod.go @@ -67,12 +67,16 @@ const ( EdgeTags = "tags" // EdgeDependents holds the string denoting the dependents edge name in mutations. EdgeDependents = "dependents" + // EdgeModpacks holds the string denoting the modpacks edge name in mutations. + EdgeModpacks = "modpacks" // EdgeUserMods holds the string denoting the user_mods edge name in mutations. EdgeUserMods = "user_mods" // EdgeModTags holds the string denoting the mod_tags edge name in mutations. EdgeModTags = "mod_tags" // EdgeVersionDependencies holds the string denoting the version_dependencies edge name in mutations. EdgeVersionDependencies = "version_dependencies" + // EdgeModpackMods holds the string denoting the modpack_mods edge name in mutations. + EdgeModpackMods = "modpack_mods" // Table holds the table name of the mod in the database. Table = "mods" // VersionsTable is the table that holds the versions relation/edge. @@ -97,6 +101,11 @@ const ( // DependentsInverseTable is the table name for the Version entity. // It exists in this package in order to avoid circular dependency with the "version" package. DependentsInverseTable = "versions" + // ModpacksTable is the table that holds the modpacks relation/edge. The primary key declared below. + ModpacksTable = "modpack_mods" + // ModpacksInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpacksInverseTable = "modpacks" // UserModsTable is the table that holds the user_mods relation/edge. UserModsTable = "user_mods" // UserModsInverseTable is the table name for the UserMod entity. @@ -118,6 +127,13 @@ const ( VersionDependenciesInverseTable = "version_dependencies" // VersionDependenciesColumn is the table column denoting the version_dependencies relation/edge. VersionDependenciesColumn = "mod_id" + // ModpackModsTable is the table that holds the modpack_mods relation/edge. + ModpackModsTable = "modpack_mods" + // ModpackModsInverseTable is the table name for the ModpackMod entity. + // It exists in this package in order to avoid circular dependency with the "modpackmod" package. + ModpackModsInverseTable = "modpack_mods" + // ModpackModsColumn is the table column denoting the modpack_mods relation/edge. + ModpackModsColumn = "mod_id" ) // Columns holds all SQL columns for mod fields. @@ -157,6 +173,9 @@ var ( // DependentsPrimaryKey and DependentsColumn2 are the table columns denoting the // primary key for the dependents relation (M2M). DependentsPrimaryKey = []string{"version_id", "mod_id"} + // ModpacksPrimaryKey and ModpacksColumn2 are the table columns denoting the + // primary key for the modpacks relation (M2M). + ModpacksPrimaryKey = []string{"modpack_id", "mod_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -380,6 +399,20 @@ func ByDependents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByModpacksCount orders the results by modpacks count. +func ByModpacksCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpacksStep(), opts...) + } +} + +// ByModpacks orders the results by modpacks terms. +func ByModpacks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpacksStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByUserModsCount orders the results by user_mods count. func ByUserModsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -421,6 +454,20 @@ func ByVersionDependencies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOpti sqlgraph.OrderByNeighborTerms(s, newVersionDependenciesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByModpackModsCount orders the results by modpack_mods count. +func ByModpackModsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpackModsStep(), opts...) + } +} + +// ByModpackMods orders the results by modpack_mods terms. +func ByModpackMods(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackModsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newVersionsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -449,6 +496,13 @@ func newDependentsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, DependentsTable, DependentsPrimaryKey...), ) } +func newModpacksStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpacksInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ModpacksTable, ModpacksPrimaryKey...), + ) +} func newUserModsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -470,3 +524,10 @@ func newVersionDependenciesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, VersionDependenciesTable, VersionDependenciesColumn), ) } +func newModpackModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackModsInverseTable, ModpackModsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackModsTable, ModpackModsColumn), + ) +} diff --git a/generated/ent/mod/where.go b/generated/ent/mod/where.go index e5bd0dfa..f6bbf1fc 100644 --- a/generated/ent/mod/where.go +++ b/generated/ent/mod/where.go @@ -1212,6 +1212,29 @@ func HasDependentsWith(preds ...predicate.Version) predicate.Mod { }) } +// HasModpacks applies the HasEdge predicate on the "modpacks" edge. +func HasModpacks() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ModpacksTable, ModpacksPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpacksWith applies the HasEdge predicate on the "modpacks" edge with a given conditions (other predicates). +func HasModpacksWith(preds ...predicate.Modpack) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newModpacksStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasUserMods applies the HasEdge predicate on the "user_mods" edge. func HasUserMods() predicate.Mod { return predicate.Mod(func(s *sql.Selector) { @@ -1281,6 +1304,29 @@ func HasVersionDependenciesWith(preds ...predicate.VersionDependency) predicate. }) } +// HasModpackMods applies the HasEdge predicate on the "modpack_mods" edge. +func HasModpackMods() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackModsTable, ModpackModsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackModsWith applies the HasEdge predicate on the "modpack_mods" edge with a given conditions (other predicates). +func HasModpackModsWith(preds ...predicate.ModpackMod) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newModpackModsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Mod) predicate.Mod { return predicate.Mod(sql.AndPredicates(predicates...)) diff --git a/generated/ent/mod_create.go b/generated/ent/mod_create.go index 1ad9c12f..080a44ac 100644 --- a/generated/ent/mod_create.go +++ b/generated/ent/mod_create.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/generated/ent/user" "github.com/satisfactorymodding/smr-api/generated/ent/version" @@ -361,6 +362,21 @@ func (mc *ModCreate) AddDependents(v ...*Version) *ModCreate { return mc.AddDependentIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (mc *ModCreate) AddModpackIDs(ids ...string) *ModCreate { + mc.mutation.AddModpackIDs(ids...) + return mc +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (mc *ModCreate) AddModpacks(m ...*Modpack) *ModCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mc.AddModpackIDs(ids...) +} + // Mutation returns the ModMutation object of the builder. func (mc *ModCreate) Mutation() *ModMutation { return mc.mutation @@ -715,6 +731,22 @@ func (mc *ModCreate) createSpec() (*Mod, *sqlgraph.CreateSpec) { edge.Target.Fields = specE.Fields _spec.Edges = append(_spec.Edges, edge) } + if nodes := mc.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/generated/ent/mod_query.go b/generated/ent/mod_query.go index 69de4152..f580680e 100644 --- a/generated/ent/mod_query.go +++ b/generated/ent/mod_query.go @@ -13,6 +13,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/tag" @@ -33,9 +35,11 @@ type ModQuery struct { withAuthors *UserQuery withTags *TagQuery withDependents *VersionQuery + withModpacks *ModpackQuery withUserMods *UserModQuery withModTags *ModTagQuery withVersionDependencies *VersionDependencyQuery + withModpackMods *ModpackModQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -161,6 +165,28 @@ func (mq *ModQuery) QueryDependents() *VersionQuery { return query } +// QueryModpacks chains the current query on the "modpacks" edge. +func (mq *ModQuery) QueryModpacks() *ModpackQuery { + query := (&ModpackClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(mod.Table, mod.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.ModpacksTable, mod.ModpacksPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryUserMods chains the current query on the "user_mods" edge. func (mq *ModQuery) QueryUserMods() *UserModQuery { query := (&UserModClient{config: mq.config}).Query() @@ -227,6 +253,28 @@ func (mq *ModQuery) QueryVersionDependencies() *VersionDependencyQuery { return query } +// QueryModpackMods chains the current query on the "modpack_mods" edge. +func (mq *ModQuery) QueryModpackMods() *ModpackModQuery { + query := (&ModpackModClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(mod.Table, mod.FieldID, selector), + sqlgraph.To(modpackmod.Table, modpackmod.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.ModpackModsTable, mod.ModpackModsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Mod entity from the query. // Returns a *NotFoundError when no Mod was found. func (mq *ModQuery) First(ctx context.Context) (*Mod, error) { @@ -423,9 +471,11 @@ func (mq *ModQuery) Clone() *ModQuery { withAuthors: mq.withAuthors.Clone(), withTags: mq.withTags.Clone(), withDependents: mq.withDependents.Clone(), + withModpacks: mq.withModpacks.Clone(), withUserMods: mq.withUserMods.Clone(), withModTags: mq.withModTags.Clone(), withVersionDependencies: mq.withVersionDependencies.Clone(), + withModpackMods: mq.withModpackMods.Clone(), // clone intermediate query. sql: mq.sql.Clone(), path: mq.path, @@ -477,6 +527,17 @@ func (mq *ModQuery) WithDependents(opts ...func(*VersionQuery)) *ModQuery { return mq } +// WithModpacks tells the query-builder to eager-load the nodes that are connected to +// the "modpacks" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithModpacks(opts ...func(*ModpackQuery)) *ModQuery { + query := (&ModpackClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withModpacks = query + return mq +} + // WithUserMods tells the query-builder to eager-load the nodes that are connected to // the "user_mods" edge. The optional arguments are used to configure the query builder of the edge. func (mq *ModQuery) WithUserMods(opts ...func(*UserModQuery)) *ModQuery { @@ -510,6 +571,17 @@ func (mq *ModQuery) WithVersionDependencies(opts ...func(*VersionDependencyQuery return mq } +// WithModpackMods tells the query-builder to eager-load the nodes that are connected to +// the "modpack_mods" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithModpackMods(opts ...func(*ModpackModQuery)) *ModQuery { + query := (&ModpackModClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withModpackMods = query + return mq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -588,14 +660,16 @@ func (mq *ModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mod, err var ( nodes = []*Mod{} _spec = mq.querySpec() - loadedTypes = [7]bool{ + loadedTypes = [9]bool{ mq.withVersions != nil, mq.withAuthors != nil, mq.withTags != nil, mq.withDependents != nil, + mq.withModpacks != nil, mq.withUserMods != nil, mq.withModTags != nil, mq.withVersionDependencies != nil, + mq.withModpackMods != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -647,6 +721,13 @@ func (mq *ModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mod, err return nil, err } } + if query := mq.withModpacks; query != nil { + if err := mq.loadModpacks(ctx, query, nodes, + func(n *Mod) { n.Edges.Modpacks = []*Modpack{} }, + func(n *Mod, e *Modpack) { n.Edges.Modpacks = append(n.Edges.Modpacks, e) }); err != nil { + return nil, err + } + } if query := mq.withUserMods; query != nil { if err := mq.loadUserMods(ctx, query, nodes, func(n *Mod) { n.Edges.UserMods = []*UserMod{} }, @@ -670,6 +751,13 @@ func (mq *ModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mod, err return nil, err } } + if query := mq.withModpackMods; query != nil { + if err := mq.loadModpackMods(ctx, query, nodes, + func(n *Mod) { n.Edges.ModpackMods = []*ModpackMod{} }, + func(n *Mod, e *ModpackMod) { n.Edges.ModpackMods = append(n.Edges.ModpackMods, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -886,6 +974,67 @@ func (mq *ModQuery) loadDependents(ctx context.Context, query *VersionQuery, nod } return nil } +func (mq *ModQuery) loadModpacks(ctx context.Context, query *ModpackQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *Modpack)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Mod) + nids := make(map[string]map[*Mod]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(mod.ModpacksTable) + s.Join(joinT).On(s.C(modpack.FieldID), joinT.C(mod.ModpacksPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(mod.ModpacksPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(mod.ModpacksPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Mod]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Modpack](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "modpacks" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (mq *ModQuery) loadUserMods(ctx context.Context, query *UserModQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *UserMod)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[string]*Mod) @@ -976,6 +1125,36 @@ func (mq *ModQuery) loadVersionDependencies(ctx context.Context, query *VersionD } return nil } +func (mq *ModQuery) loadModpackMods(ctx context.Context, query *ModpackModQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *ModpackMod)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Mod) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpackmod.FieldModID) + } + query.Where(predicate.ModpackMod(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mod.ModpackModsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ModID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "mod_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} func (mq *ModQuery) sqlCount(ctx context.Context) (int, error) { _spec := mq.querySpec() diff --git a/generated/ent/mod_update.go b/generated/ent/mod_update.go index a69d4149..5f7459bc 100644 --- a/generated/ent/mod_update.go +++ b/generated/ent/mod_update.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/generated/ent/user" @@ -435,6 +436,21 @@ func (mu *ModUpdate) AddDependents(v ...*Version) *ModUpdate { return mu.AddDependentIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (mu *ModUpdate) AddModpackIDs(ids ...string) *ModUpdate { + mu.mutation.AddModpackIDs(ids...) + return mu +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (mu *ModUpdate) AddModpacks(m ...*Modpack) *ModUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.AddModpackIDs(ids...) +} + // Mutation returns the ModMutation object of the builder. func (mu *ModUpdate) Mutation() *ModMutation { return mu.mutation @@ -524,6 +540,27 @@ func (mu *ModUpdate) RemoveDependents(v ...*Version) *ModUpdate { return mu.RemoveDependentIDs(ids...) } +// ClearModpacks clears all "modpacks" edges to the Modpack entity. +func (mu *ModUpdate) ClearModpacks() *ModUpdate { + mu.mutation.ClearModpacks() + return mu +} + +// RemoveModpackIDs removes the "modpacks" edge to Modpack entities by IDs. +func (mu *ModUpdate) RemoveModpackIDs(ids ...string) *ModUpdate { + mu.mutation.RemoveModpackIDs(ids...) + return mu +} + +// RemoveModpacks removes "modpacks" edges to Modpack entities. +func (mu *ModUpdate) RemoveModpacks(m ...*Modpack) *ModUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.RemoveModpackIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (mu *ModUpdate) Save(ctx context.Context) (int, error) { if err := mu.defaults(); err != nil { @@ -889,6 +926,51 @@ func (mu *ModUpdate) sqlSave(ctx context.Context) (n int, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if mu.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedModpacksIDs(); len(nodes) > 0 && !mu.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(mu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -1313,6 +1395,21 @@ func (muo *ModUpdateOne) AddDependents(v ...*Version) *ModUpdateOne { return muo.AddDependentIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (muo *ModUpdateOne) AddModpackIDs(ids ...string) *ModUpdateOne { + muo.mutation.AddModpackIDs(ids...) + return muo +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (muo *ModUpdateOne) AddModpacks(m ...*Modpack) *ModUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.AddModpackIDs(ids...) +} + // Mutation returns the ModMutation object of the builder. func (muo *ModUpdateOne) Mutation() *ModMutation { return muo.mutation @@ -1402,6 +1499,27 @@ func (muo *ModUpdateOne) RemoveDependents(v ...*Version) *ModUpdateOne { return muo.RemoveDependentIDs(ids...) } +// ClearModpacks clears all "modpacks" edges to the Modpack entity. +func (muo *ModUpdateOne) ClearModpacks() *ModUpdateOne { + muo.mutation.ClearModpacks() + return muo +} + +// RemoveModpackIDs removes the "modpacks" edge to Modpack entities by IDs. +func (muo *ModUpdateOne) RemoveModpackIDs(ids ...string) *ModUpdateOne { + muo.mutation.RemoveModpackIDs(ids...) + return muo +} + +// RemoveModpacks removes "modpacks" edges to Modpack entities. +func (muo *ModUpdateOne) RemoveModpacks(m ...*Modpack) *ModUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.RemoveModpackIDs(ids...) +} + // Where appends a list predicates to the ModUpdate builder. func (muo *ModUpdateOne) Where(ps ...predicate.Mod) *ModUpdateOne { muo.mutation.Where(ps...) @@ -1797,6 +1915,51 @@ func (muo *ModUpdateOne) sqlSave(ctx context.Context) (_node *Mod, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if muo.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedModpacksIDs(); len(nodes) > 0 && !muo.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.ModpacksTable, + Columns: mod.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(muo.modifiers...) _node = &Mod{config: muo.config} _spec.Assign = _node.assignValues diff --git a/generated/ent/modpack.go b/generated/ent/modpack.go new file mode 100644 index 00000000..698ec82a --- /dev/null +++ b/generated/ent/modpack.go @@ -0,0 +1,391 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" +) + +// Modpack is the model entity for the Modpack schema. +type Modpack struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // ShortDescription holds the value of the "short_description" field. + ShortDescription string `json:"short_description,omitempty"` + // FullDescription holds the value of the "full_description" field. + FullDescription string `json:"full_description,omitempty"` + // Logo holds the value of the "logo" field. + Logo string `json:"logo,omitempty"` + // LogoThumbhash holds the value of the "logo_thumbhash" field. + LogoThumbhash string `json:"logo_thumbhash,omitempty"` + // CreatorID holds the value of the "creator_id" field. + CreatorID string `json:"creator_id,omitempty"` + // Views holds the value of the "views" field. + Views uint `json:"views,omitempty"` + // Hotness holds the value of the "hotness" field. + Hotness uint `json:"hotness,omitempty"` + // Installs holds the value of the "installs" field. + Installs uint `json:"installs,omitempty"` + // Popularity holds the value of the "popularity" field. + Popularity uint `json:"popularity,omitempty"` + // Hidden holds the value of the "hidden" field. + Hidden bool `json:"hidden,omitempty"` + // ParentID holds the value of the "parent_id" field. + ParentID string `json:"parent_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModpackQuery when eager-loading is set. + Edges ModpackEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModpackEdges holds the relations/edges for other nodes in the graph. +type ModpackEdges struct { + // Children holds the value of the children edge. + Children []*Modpack `json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Modpack `json:"parent,omitempty"` + // Targets holds the value of the targets edge. + Targets []*ModpackTarget `json:"targets,omitempty"` + // Releases holds the value of the releases edge. + Releases []*ModpackRelease `json:"releases,omitempty"` + // Mods holds the value of the mods edge. + Mods []*Mod `json:"mods,omitempty"` + // Tags holds the value of the tags edge. + Tags []*Tag `json:"tags,omitempty"` + // ModpackMods holds the value of the modpack_mods edge. + ModpackMods []*ModpackMod `json:"modpack_mods,omitempty"` + // ModpackTags holds the value of the modpack_tags edge. + ModpackTags []*ModpackTag `json:"modpack_tags,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [8]bool +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) ChildrenOrErr() ([]*Modpack, error) { + if e.loadedTypes[0] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackEdges) ParentOrErr() (*Modpack, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: modpack.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// TargetsOrErr returns the Targets value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) TargetsOrErr() ([]*ModpackTarget, error) { + if e.loadedTypes[2] { + return e.Targets, nil + } + return nil, &NotLoadedError{edge: "targets"} +} + +// ReleasesOrErr returns the Releases value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) ReleasesOrErr() ([]*ModpackRelease, error) { + if e.loadedTypes[3] { + return e.Releases, nil + } + return nil, &NotLoadedError{edge: "releases"} +} + +// ModsOrErr returns the Mods value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) ModsOrErr() ([]*Mod, error) { + if e.loadedTypes[4] { + return e.Mods, nil + } + return nil, &NotLoadedError{edge: "mods"} +} + +// TagsOrErr returns the Tags value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) TagsOrErr() ([]*Tag, error) { + if e.loadedTypes[5] { + return e.Tags, nil + } + return nil, &NotLoadedError{edge: "tags"} +} + +// ModpackModsOrErr returns the ModpackMods value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) ModpackModsOrErr() ([]*ModpackMod, error) { + if e.loadedTypes[6] { + return e.ModpackMods, nil + } + return nil, &NotLoadedError{edge: "modpack_mods"} +} + +// ModpackTagsOrErr returns the ModpackTags value or an error if the edge +// was not loaded in eager-loading. +func (e ModpackEdges) ModpackTagsOrErr() ([]*ModpackTag, error) { + if e.loadedTypes[7] { + return e.ModpackTags, nil + } + return nil, &NotLoadedError{edge: "modpack_tags"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Modpack) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modpack.FieldHidden: + values[i] = new(sql.NullBool) + case modpack.FieldViews, modpack.FieldHotness, modpack.FieldInstalls, modpack.FieldPopularity: + values[i] = new(sql.NullInt64) + case modpack.FieldID, modpack.FieldName, modpack.FieldShortDescription, modpack.FieldFullDescription, modpack.FieldLogo, modpack.FieldLogoThumbhash, modpack.FieldCreatorID, modpack.FieldParentID: + values[i] = new(sql.NullString) + case modpack.FieldCreatedAt, modpack.FieldUpdatedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Modpack fields. +func (m *Modpack) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case modpack.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + m.ID = value.String + } + case modpack.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + m.CreatedAt = value.Time + } + case modpack.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + m.UpdatedAt = value.Time + } + case modpack.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + m.Name = value.String + } + case modpack.FieldShortDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field short_description", values[i]) + } else if value.Valid { + m.ShortDescription = value.String + } + case modpack.FieldFullDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field full_description", values[i]) + } else if value.Valid { + m.FullDescription = value.String + } + case modpack.FieldLogo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field logo", values[i]) + } else if value.Valid { + m.Logo = value.String + } + case modpack.FieldLogoThumbhash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field logo_thumbhash", values[i]) + } else if value.Valid { + m.LogoThumbhash = value.String + } + case modpack.FieldCreatorID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field creator_id", values[i]) + } else if value.Valid { + m.CreatorID = value.String + } + case modpack.FieldViews: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field views", values[i]) + } else if value.Valid { + m.Views = uint(value.Int64) + } + case modpack.FieldHotness: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hotness", values[i]) + } else if value.Valid { + m.Hotness = uint(value.Int64) + } + case modpack.FieldInstalls: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field installs", values[i]) + } else if value.Valid { + m.Installs = uint(value.Int64) + } + case modpack.FieldPopularity: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field popularity", values[i]) + } else if value.Valid { + m.Popularity = uint(value.Int64) + } + case modpack.FieldHidden: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field hidden", values[i]) + } else if value.Valid { + m.Hidden = value.Bool + } + case modpack.FieldParentID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field parent_id", values[i]) + } else if value.Valid { + m.ParentID = value.String + } + default: + m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Modpack. +// This includes values selected through modifiers, order, etc. +func (m *Modpack) Value(name string) (ent.Value, error) { + return m.selectValues.Get(name) +} + +// QueryChildren queries the "children" edge of the Modpack entity. +func (m *Modpack) QueryChildren() *ModpackQuery { + return NewModpackClient(m.config).QueryChildren(m) +} + +// QueryParent queries the "parent" edge of the Modpack entity. +func (m *Modpack) QueryParent() *ModpackQuery { + return NewModpackClient(m.config).QueryParent(m) +} + +// QueryTargets queries the "targets" edge of the Modpack entity. +func (m *Modpack) QueryTargets() *ModpackTargetQuery { + return NewModpackClient(m.config).QueryTargets(m) +} + +// QueryReleases queries the "releases" edge of the Modpack entity. +func (m *Modpack) QueryReleases() *ModpackReleaseQuery { + return NewModpackClient(m.config).QueryReleases(m) +} + +// QueryMods queries the "mods" edge of the Modpack entity. +func (m *Modpack) QueryMods() *ModQuery { + return NewModpackClient(m.config).QueryMods(m) +} + +// QueryTags queries the "tags" edge of the Modpack entity. +func (m *Modpack) QueryTags() *TagQuery { + return NewModpackClient(m.config).QueryTags(m) +} + +// QueryModpackMods queries the "modpack_mods" edge of the Modpack entity. +func (m *Modpack) QueryModpackMods() *ModpackModQuery { + return NewModpackClient(m.config).QueryModpackMods(m) +} + +// QueryModpackTags queries the "modpack_tags" edge of the Modpack entity. +func (m *Modpack) QueryModpackTags() *ModpackTagQuery { + return NewModpackClient(m.config).QueryModpackTags(m) +} + +// Update returns a builder for updating this Modpack. +// Note that you need to call Modpack.Unwrap() before calling this method if this Modpack +// was returned from a transaction, and the transaction was committed or rolled back. +func (m *Modpack) Update() *ModpackUpdateOne { + return NewModpackClient(m.config).UpdateOne(m) +} + +// Unwrap unwraps the Modpack entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (m *Modpack) Unwrap() *Modpack { + _tx, ok := m.config.driver.(*txDriver) + if !ok { + panic("ent: Modpack is not a transactional entity") + } + m.config.driver = _tx.drv + return m +} + +// String implements the fmt.Stringer. +func (m *Modpack) String() string { + var builder strings.Builder + builder.WriteString("Modpack(") + builder.WriteString(fmt.Sprintf("id=%v, ", m.ID)) + builder.WriteString("created_at=") + builder.WriteString(m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(m.Name) + builder.WriteString(", ") + builder.WriteString("short_description=") + builder.WriteString(m.ShortDescription) + builder.WriteString(", ") + builder.WriteString("full_description=") + builder.WriteString(m.FullDescription) + builder.WriteString(", ") + builder.WriteString("logo=") + builder.WriteString(m.Logo) + builder.WriteString(", ") + builder.WriteString("logo_thumbhash=") + builder.WriteString(m.LogoThumbhash) + builder.WriteString(", ") + builder.WriteString("creator_id=") + builder.WriteString(m.CreatorID) + builder.WriteString(", ") + builder.WriteString("views=") + builder.WriteString(fmt.Sprintf("%v", m.Views)) + builder.WriteString(", ") + builder.WriteString("hotness=") + builder.WriteString(fmt.Sprintf("%v", m.Hotness)) + builder.WriteString(", ") + builder.WriteString("installs=") + builder.WriteString(fmt.Sprintf("%v", m.Installs)) + builder.WriteString(", ") + builder.WriteString("popularity=") + builder.WriteString(fmt.Sprintf("%v", m.Popularity)) + builder.WriteString(", ") + builder.WriteString("hidden=") + builder.WriteString(fmt.Sprintf("%v", m.Hidden)) + builder.WriteString(", ") + builder.WriteString("parent_id=") + builder.WriteString(m.ParentID) + builder.WriteByte(')') + return builder.String() +} + +// Modpacks is a parsable slice of Modpack. +type Modpacks []*Modpack diff --git a/generated/ent/modpack/modpack.go b/generated/ent/modpack/modpack.go new file mode 100644 index 00000000..ab1d75e1 --- /dev/null +++ b/generated/ent/modpack/modpack.go @@ -0,0 +1,409 @@ +// Code generated by ent, DO NOT EDIT. + +package modpack + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modpack type in the database. + Label = "modpack" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldShortDescription holds the string denoting the short_description field in the database. + FieldShortDescription = "short_description" + // FieldFullDescription holds the string denoting the full_description field in the database. + FieldFullDescription = "full_description" + // FieldLogo holds the string denoting the logo field in the database. + FieldLogo = "logo" + // FieldLogoThumbhash holds the string denoting the logo_thumbhash field in the database. + FieldLogoThumbhash = "logo_thumbhash" + // FieldCreatorID holds the string denoting the creator_id field in the database. + FieldCreatorID = "creator_id" + // FieldViews holds the string denoting the views field in the database. + FieldViews = "views" + // FieldHotness holds the string denoting the hotness field in the database. + FieldHotness = "hotness" + // FieldInstalls holds the string denoting the installs field in the database. + FieldInstalls = "installs" + // FieldPopularity holds the string denoting the popularity field in the database. + FieldPopularity = "popularity" + // FieldHidden holds the string denoting the hidden field in the database. + FieldHidden = "hidden" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeTargets holds the string denoting the targets edge name in mutations. + EdgeTargets = "targets" + // EdgeReleases holds the string denoting the releases edge name in mutations. + EdgeReleases = "releases" + // EdgeMods holds the string denoting the mods edge name in mutations. + EdgeMods = "mods" + // EdgeTags holds the string denoting the tags edge name in mutations. + EdgeTags = "tags" + // EdgeModpackMods holds the string denoting the modpack_mods edge name in mutations. + EdgeModpackMods = "modpack_mods" + // EdgeModpackTags holds the string denoting the modpack_tags edge name in mutations. + EdgeModpackTags = "modpack_tags" + // Table holds the table name of the modpack in the database. + Table = "modpacks" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "modpacks" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "modpacks" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // TargetsTable is the table that holds the targets relation/edge. + TargetsTable = "modpack_targets" + // TargetsInverseTable is the table name for the ModpackTarget entity. + // It exists in this package in order to avoid circular dependency with the "modpacktarget" package. + TargetsInverseTable = "modpack_targets" + // TargetsColumn is the table column denoting the targets relation/edge. + TargetsColumn = "modpack_id" + // ReleasesTable is the table that holds the releases relation/edge. + ReleasesTable = "modpack_releases" + // ReleasesInverseTable is the table name for the ModpackRelease entity. + // It exists in this package in order to avoid circular dependency with the "modpackrelease" package. + ReleasesInverseTable = "modpack_releases" + // ReleasesColumn is the table column denoting the releases relation/edge. + ReleasesColumn = "modpack_id" + // ModsTable is the table that holds the mods relation/edge. The primary key declared below. + ModsTable = "modpack_mods" + // ModsInverseTable is the table name for the Mod entity. + // It exists in this package in order to avoid circular dependency with the "mod" package. + ModsInverseTable = "mods" + // TagsTable is the table that holds the tags relation/edge. The primary key declared below. + TagsTable = "modpack_tags" + // TagsInverseTable is the table name for the Tag entity. + // It exists in this package in order to avoid circular dependency with the "tag" package. + TagsInverseTable = "tags" + // ModpackModsTable is the table that holds the modpack_mods relation/edge. + ModpackModsTable = "modpack_mods" + // ModpackModsInverseTable is the table name for the ModpackMod entity. + // It exists in this package in order to avoid circular dependency with the "modpackmod" package. + ModpackModsInverseTable = "modpack_mods" + // ModpackModsColumn is the table column denoting the modpack_mods relation/edge. + ModpackModsColumn = "modpack_id" + // ModpackTagsTable is the table that holds the modpack_tags relation/edge. + ModpackTagsTable = "modpack_tags" + // ModpackTagsInverseTable is the table name for the ModpackTag entity. + // It exists in this package in order to avoid circular dependency with the "modpacktag" package. + ModpackTagsInverseTable = "modpack_tags" + // ModpackTagsColumn is the table column denoting the modpack_tags relation/edge. + ModpackTagsColumn = "modpack_id" +) + +// Columns holds all SQL columns for modpack fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldName, + FieldShortDescription, + FieldFullDescription, + FieldLogo, + FieldLogoThumbhash, + FieldCreatorID, + FieldViews, + FieldHotness, + FieldInstalls, + FieldPopularity, + FieldHidden, + FieldParentID, +} + +var ( + // ModsPrimaryKey and ModsColumn2 are the table columns denoting the + // primary key for the mods relation (M2M). + ModsPrimaryKey = []string{"modpack_id", "mod_id"} + // TagsPrimaryKey and TagsColumn2 are the table columns denoting the + // primary key for the tags relation (M2M). + TagsPrimaryKey = []string{"modpack_id", "tag_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + ShortDescriptionValidator func(string) error + // DefaultViews holds the default value on creation for the "views" field. + DefaultViews uint + // DefaultHotness holds the default value on creation for the "hotness" field. + DefaultHotness uint + // DefaultInstalls holds the default value on creation for the "installs" field. + DefaultInstalls uint + // DefaultPopularity holds the default value on creation for the "popularity" field. + DefaultPopularity uint + // DefaultHidden holds the default value on creation for the "hidden" field. + DefaultHidden bool + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the Modpack queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByShortDescription orders the results by the short_description field. +func ByShortDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldShortDescription, opts...).ToFunc() +} + +// ByFullDescription orders the results by the full_description field. +func ByFullDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFullDescription, opts...).ToFunc() +} + +// ByLogo orders the results by the logo field. +func ByLogo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLogo, opts...).ToFunc() +} + +// ByLogoThumbhash orders the results by the logo_thumbhash field. +func ByLogoThumbhash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLogoThumbhash, opts...).ToFunc() +} + +// ByCreatorID orders the results by the creator_id field. +func ByCreatorID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatorID, opts...).ToFunc() +} + +// ByViews orders the results by the views field. +func ByViews(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldViews, opts...).ToFunc() +} + +// ByHotness orders the results by the hotness field. +func ByHotness(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHotness, opts...).ToFunc() +} + +// ByInstalls orders the results by the installs field. +func ByInstalls(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInstalls, opts...).ToFunc() +} + +// ByPopularity orders the results by the popularity field. +func ByPopularity(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPopularity, opts...).ToFunc() +} + +// ByHidden orders the results by the hidden field. +func ByHidden(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHidden, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByTargetsCount orders the results by targets count. +func ByTargetsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newTargetsStep(), opts...) + } +} + +// ByTargets orders the results by targets terms. +func ByTargets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTargetsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByReleasesCount orders the results by releases count. +func ByReleasesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newReleasesStep(), opts...) + } +} + +// ByReleases orders the results by releases terms. +func ByReleases(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newReleasesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModsCount orders the results by mods count. +func ByModsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModsStep(), opts...) + } +} + +// ByMods orders the results by mods terms. +func ByMods(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByTagsCount orders the results by tags count. +func ByTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newTagsStep(), opts...) + } +} + +// ByTags orders the results by tags terms. +func ByTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModpackModsCount orders the results by modpack_mods count. +func ByModpackModsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpackModsStep(), opts...) + } +} + +// ByModpackMods orders the results by modpack_mods terms. +func ByModpackMods(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackModsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModpackTagsCount orders the results by modpack_tags count. +func ByModpackTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpackTagsStep(), opts...) + } +} + +// ByModpackTags orders the results by modpack_tags terms. +func ByModpackTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newTargetsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TargetsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TargetsTable, TargetsColumn), + ) +} +func newReleasesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ReleasesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ReleasesTable, ReleasesColumn), + ) +} +func newModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ModsTable, ModsPrimaryKey...), + ) +} +func newTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) +} +func newModpackModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackModsInverseTable, ModpackModsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackModsTable, ModpackModsColumn), + ) +} +func newModpackTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackTagsInverseTable, ModpackTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackTagsTable, ModpackTagsColumn), + ) +} diff --git a/generated/ent/modpack/where.go b/generated/ent/modpack/where.go new file mode 100644 index 00000000..0cd384dc --- /dev/null +++ b/generated/ent/modpack/where.go @@ -0,0 +1,1070 @@ +// Code generated by ent, DO NOT EDIT. + +package modpack + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldName, v)) +} + +// ShortDescription applies equality check predicate on the "short_description" field. It's identical to ShortDescriptionEQ. +func ShortDescription(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldShortDescription, v)) +} + +// FullDescription applies equality check predicate on the "full_description" field. It's identical to FullDescriptionEQ. +func FullDescription(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldFullDescription, v)) +} + +// Logo applies equality check predicate on the "logo" field. It's identical to LogoEQ. +func Logo(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldLogo, v)) +} + +// LogoThumbhash applies equality check predicate on the "logo_thumbhash" field. It's identical to LogoThumbhashEQ. +func LogoThumbhash(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldLogoThumbhash, v)) +} + +// CreatorID applies equality check predicate on the "creator_id" field. It's identical to CreatorIDEQ. +func CreatorID(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldCreatorID, v)) +} + +// Views applies equality check predicate on the "views" field. It's identical to ViewsEQ. +func Views(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldViews, v)) +} + +// Hotness applies equality check predicate on the "hotness" field. It's identical to HotnessEQ. +func Hotness(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldHotness, v)) +} + +// Installs applies equality check predicate on the "installs" field. It's identical to InstallsEQ. +func Installs(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldInstalls, v)) +} + +// Popularity applies equality check predicate on the "popularity" field. It's identical to PopularityEQ. +func Popularity(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldPopularity, v)) +} + +// Hidden applies equality check predicate on the "hidden" field. It's identical to HiddenEQ. +func Hidden(v bool) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldHidden, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldParentID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldName, v)) +} + +// ShortDescriptionEQ applies the EQ predicate on the "short_description" field. +func ShortDescriptionEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldShortDescription, v)) +} + +// ShortDescriptionNEQ applies the NEQ predicate on the "short_description" field. +func ShortDescriptionNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldShortDescription, v)) +} + +// ShortDescriptionIn applies the In predicate on the "short_description" field. +func ShortDescriptionIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionNotIn applies the NotIn predicate on the "short_description" field. +func ShortDescriptionNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionGT applies the GT predicate on the "short_description" field. +func ShortDescriptionGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldShortDescription, v)) +} + +// ShortDescriptionGTE applies the GTE predicate on the "short_description" field. +func ShortDescriptionGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldShortDescription, v)) +} + +// ShortDescriptionLT applies the LT predicate on the "short_description" field. +func ShortDescriptionLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldShortDescription, v)) +} + +// ShortDescriptionLTE applies the LTE predicate on the "short_description" field. +func ShortDescriptionLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldShortDescription, v)) +} + +// ShortDescriptionContains applies the Contains predicate on the "short_description" field. +func ShortDescriptionContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldShortDescription, v)) +} + +// ShortDescriptionHasPrefix applies the HasPrefix predicate on the "short_description" field. +func ShortDescriptionHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldShortDescription, v)) +} + +// ShortDescriptionHasSuffix applies the HasSuffix predicate on the "short_description" field. +func ShortDescriptionHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldShortDescription, v)) +} + +// ShortDescriptionEqualFold applies the EqualFold predicate on the "short_description" field. +func ShortDescriptionEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldShortDescription, v)) +} + +// ShortDescriptionContainsFold applies the ContainsFold predicate on the "short_description" field. +func ShortDescriptionContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldShortDescription, v)) +} + +// FullDescriptionEQ applies the EQ predicate on the "full_description" field. +func FullDescriptionEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldFullDescription, v)) +} + +// FullDescriptionNEQ applies the NEQ predicate on the "full_description" field. +func FullDescriptionNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldFullDescription, v)) +} + +// FullDescriptionIn applies the In predicate on the "full_description" field. +func FullDescriptionIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldFullDescription, vs...)) +} + +// FullDescriptionNotIn applies the NotIn predicate on the "full_description" field. +func FullDescriptionNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldFullDescription, vs...)) +} + +// FullDescriptionGT applies the GT predicate on the "full_description" field. +func FullDescriptionGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldFullDescription, v)) +} + +// FullDescriptionGTE applies the GTE predicate on the "full_description" field. +func FullDescriptionGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldFullDescription, v)) +} + +// FullDescriptionLT applies the LT predicate on the "full_description" field. +func FullDescriptionLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldFullDescription, v)) +} + +// FullDescriptionLTE applies the LTE predicate on the "full_description" field. +func FullDescriptionLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldFullDescription, v)) +} + +// FullDescriptionContains applies the Contains predicate on the "full_description" field. +func FullDescriptionContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldFullDescription, v)) +} + +// FullDescriptionHasPrefix applies the HasPrefix predicate on the "full_description" field. +func FullDescriptionHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldFullDescription, v)) +} + +// FullDescriptionHasSuffix applies the HasSuffix predicate on the "full_description" field. +func FullDescriptionHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldFullDescription, v)) +} + +// FullDescriptionEqualFold applies the EqualFold predicate on the "full_description" field. +func FullDescriptionEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldFullDescription, v)) +} + +// FullDescriptionContainsFold applies the ContainsFold predicate on the "full_description" field. +func FullDescriptionContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldFullDescription, v)) +} + +// LogoEQ applies the EQ predicate on the "logo" field. +func LogoEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldLogo, v)) +} + +// LogoNEQ applies the NEQ predicate on the "logo" field. +func LogoNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldLogo, v)) +} + +// LogoIn applies the In predicate on the "logo" field. +func LogoIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldLogo, vs...)) +} + +// LogoNotIn applies the NotIn predicate on the "logo" field. +func LogoNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldLogo, vs...)) +} + +// LogoGT applies the GT predicate on the "logo" field. +func LogoGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldLogo, v)) +} + +// LogoGTE applies the GTE predicate on the "logo" field. +func LogoGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldLogo, v)) +} + +// LogoLT applies the LT predicate on the "logo" field. +func LogoLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldLogo, v)) +} + +// LogoLTE applies the LTE predicate on the "logo" field. +func LogoLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldLogo, v)) +} + +// LogoContains applies the Contains predicate on the "logo" field. +func LogoContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldLogo, v)) +} + +// LogoHasPrefix applies the HasPrefix predicate on the "logo" field. +func LogoHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldLogo, v)) +} + +// LogoHasSuffix applies the HasSuffix predicate on the "logo" field. +func LogoHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldLogo, v)) +} + +// LogoIsNil applies the IsNil predicate on the "logo" field. +func LogoIsNil() predicate.Modpack { + return predicate.Modpack(sql.FieldIsNull(FieldLogo)) +} + +// LogoNotNil applies the NotNil predicate on the "logo" field. +func LogoNotNil() predicate.Modpack { + return predicate.Modpack(sql.FieldNotNull(FieldLogo)) +} + +// LogoEqualFold applies the EqualFold predicate on the "logo" field. +func LogoEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldLogo, v)) +} + +// LogoContainsFold applies the ContainsFold predicate on the "logo" field. +func LogoContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldLogo, v)) +} + +// LogoThumbhashEQ applies the EQ predicate on the "logo_thumbhash" field. +func LogoThumbhashEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldLogoThumbhash, v)) +} + +// LogoThumbhashNEQ applies the NEQ predicate on the "logo_thumbhash" field. +func LogoThumbhashNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldLogoThumbhash, v)) +} + +// LogoThumbhashIn applies the In predicate on the "logo_thumbhash" field. +func LogoThumbhashIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldLogoThumbhash, vs...)) +} + +// LogoThumbhashNotIn applies the NotIn predicate on the "logo_thumbhash" field. +func LogoThumbhashNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldLogoThumbhash, vs...)) +} + +// LogoThumbhashGT applies the GT predicate on the "logo_thumbhash" field. +func LogoThumbhashGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldLogoThumbhash, v)) +} + +// LogoThumbhashGTE applies the GTE predicate on the "logo_thumbhash" field. +func LogoThumbhashGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldLogoThumbhash, v)) +} + +// LogoThumbhashLT applies the LT predicate on the "logo_thumbhash" field. +func LogoThumbhashLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldLogoThumbhash, v)) +} + +// LogoThumbhashLTE applies the LTE predicate on the "logo_thumbhash" field. +func LogoThumbhashLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldLogoThumbhash, v)) +} + +// LogoThumbhashContains applies the Contains predicate on the "logo_thumbhash" field. +func LogoThumbhashContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldLogoThumbhash, v)) +} + +// LogoThumbhashHasPrefix applies the HasPrefix predicate on the "logo_thumbhash" field. +func LogoThumbhashHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldLogoThumbhash, v)) +} + +// LogoThumbhashHasSuffix applies the HasSuffix predicate on the "logo_thumbhash" field. +func LogoThumbhashHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldLogoThumbhash, v)) +} + +// LogoThumbhashIsNil applies the IsNil predicate on the "logo_thumbhash" field. +func LogoThumbhashIsNil() predicate.Modpack { + return predicate.Modpack(sql.FieldIsNull(FieldLogoThumbhash)) +} + +// LogoThumbhashNotNil applies the NotNil predicate on the "logo_thumbhash" field. +func LogoThumbhashNotNil() predicate.Modpack { + return predicate.Modpack(sql.FieldNotNull(FieldLogoThumbhash)) +} + +// LogoThumbhashEqualFold applies the EqualFold predicate on the "logo_thumbhash" field. +func LogoThumbhashEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldLogoThumbhash, v)) +} + +// LogoThumbhashContainsFold applies the ContainsFold predicate on the "logo_thumbhash" field. +func LogoThumbhashContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldLogoThumbhash, v)) +} + +// CreatorIDEQ applies the EQ predicate on the "creator_id" field. +func CreatorIDEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldCreatorID, v)) +} + +// CreatorIDNEQ applies the NEQ predicate on the "creator_id" field. +func CreatorIDNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldCreatorID, v)) +} + +// CreatorIDIn applies the In predicate on the "creator_id" field. +func CreatorIDIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldCreatorID, vs...)) +} + +// CreatorIDNotIn applies the NotIn predicate on the "creator_id" field. +func CreatorIDNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldCreatorID, vs...)) +} + +// CreatorIDGT applies the GT predicate on the "creator_id" field. +func CreatorIDGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldCreatorID, v)) +} + +// CreatorIDGTE applies the GTE predicate on the "creator_id" field. +func CreatorIDGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldCreatorID, v)) +} + +// CreatorIDLT applies the LT predicate on the "creator_id" field. +func CreatorIDLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldCreatorID, v)) +} + +// CreatorIDLTE applies the LTE predicate on the "creator_id" field. +func CreatorIDLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldCreatorID, v)) +} + +// CreatorIDContains applies the Contains predicate on the "creator_id" field. +func CreatorIDContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldCreatorID, v)) +} + +// CreatorIDHasPrefix applies the HasPrefix predicate on the "creator_id" field. +func CreatorIDHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldCreatorID, v)) +} + +// CreatorIDHasSuffix applies the HasSuffix predicate on the "creator_id" field. +func CreatorIDHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldCreatorID, v)) +} + +// CreatorIDEqualFold applies the EqualFold predicate on the "creator_id" field. +func CreatorIDEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldCreatorID, v)) +} + +// CreatorIDContainsFold applies the ContainsFold predicate on the "creator_id" field. +func CreatorIDContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldCreatorID, v)) +} + +// ViewsEQ applies the EQ predicate on the "views" field. +func ViewsEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldViews, v)) +} + +// ViewsNEQ applies the NEQ predicate on the "views" field. +func ViewsNEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldViews, v)) +} + +// ViewsIn applies the In predicate on the "views" field. +func ViewsIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldViews, vs...)) +} + +// ViewsNotIn applies the NotIn predicate on the "views" field. +func ViewsNotIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldViews, vs...)) +} + +// ViewsGT applies the GT predicate on the "views" field. +func ViewsGT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldViews, v)) +} + +// ViewsGTE applies the GTE predicate on the "views" field. +func ViewsGTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldViews, v)) +} + +// ViewsLT applies the LT predicate on the "views" field. +func ViewsLT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldViews, v)) +} + +// ViewsLTE applies the LTE predicate on the "views" field. +func ViewsLTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldViews, v)) +} + +// HotnessEQ applies the EQ predicate on the "hotness" field. +func HotnessEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldHotness, v)) +} + +// HotnessNEQ applies the NEQ predicate on the "hotness" field. +func HotnessNEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldHotness, v)) +} + +// HotnessIn applies the In predicate on the "hotness" field. +func HotnessIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldHotness, vs...)) +} + +// HotnessNotIn applies the NotIn predicate on the "hotness" field. +func HotnessNotIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldHotness, vs...)) +} + +// HotnessGT applies the GT predicate on the "hotness" field. +func HotnessGT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldHotness, v)) +} + +// HotnessGTE applies the GTE predicate on the "hotness" field. +func HotnessGTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldHotness, v)) +} + +// HotnessLT applies the LT predicate on the "hotness" field. +func HotnessLT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldHotness, v)) +} + +// HotnessLTE applies the LTE predicate on the "hotness" field. +func HotnessLTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldHotness, v)) +} + +// InstallsEQ applies the EQ predicate on the "installs" field. +func InstallsEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldInstalls, v)) +} + +// InstallsNEQ applies the NEQ predicate on the "installs" field. +func InstallsNEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldInstalls, v)) +} + +// InstallsIn applies the In predicate on the "installs" field. +func InstallsIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldInstalls, vs...)) +} + +// InstallsNotIn applies the NotIn predicate on the "installs" field. +func InstallsNotIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldInstalls, vs...)) +} + +// InstallsGT applies the GT predicate on the "installs" field. +func InstallsGT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldInstalls, v)) +} + +// InstallsGTE applies the GTE predicate on the "installs" field. +func InstallsGTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldInstalls, v)) +} + +// InstallsLT applies the LT predicate on the "installs" field. +func InstallsLT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldInstalls, v)) +} + +// InstallsLTE applies the LTE predicate on the "installs" field. +func InstallsLTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldInstalls, v)) +} + +// PopularityEQ applies the EQ predicate on the "popularity" field. +func PopularityEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldPopularity, v)) +} + +// PopularityNEQ applies the NEQ predicate on the "popularity" field. +func PopularityNEQ(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldPopularity, v)) +} + +// PopularityIn applies the In predicate on the "popularity" field. +func PopularityIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldPopularity, vs...)) +} + +// PopularityNotIn applies the NotIn predicate on the "popularity" field. +func PopularityNotIn(vs ...uint) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldPopularity, vs...)) +} + +// PopularityGT applies the GT predicate on the "popularity" field. +func PopularityGT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldPopularity, v)) +} + +// PopularityGTE applies the GTE predicate on the "popularity" field. +func PopularityGTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldPopularity, v)) +} + +// PopularityLT applies the LT predicate on the "popularity" field. +func PopularityLT(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldPopularity, v)) +} + +// PopularityLTE applies the LTE predicate on the "popularity" field. +func PopularityLTE(v uint) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldPopularity, v)) +} + +// HiddenEQ applies the EQ predicate on the "hidden" field. +func HiddenEQ(v bool) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldHidden, v)) +} + +// HiddenNEQ applies the NEQ predicate on the "hidden" field. +func HiddenNEQ(v bool) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldHidden, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...string) predicate.Modpack { + return predicate.Modpack(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDGT applies the GT predicate on the "parent_id" field. +func ParentIDGT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGT(FieldParentID, v)) +} + +// ParentIDGTE applies the GTE predicate on the "parent_id" field. +func ParentIDGTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldGTE(FieldParentID, v)) +} + +// ParentIDLT applies the LT predicate on the "parent_id" field. +func ParentIDLT(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLT(FieldParentID, v)) +} + +// ParentIDLTE applies the LTE predicate on the "parent_id" field. +func ParentIDLTE(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldLTE(FieldParentID, v)) +} + +// ParentIDContains applies the Contains predicate on the "parent_id" field. +func ParentIDContains(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContains(FieldParentID, v)) +} + +// ParentIDHasPrefix applies the HasPrefix predicate on the "parent_id" field. +func ParentIDHasPrefix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasPrefix(FieldParentID, v)) +} + +// ParentIDHasSuffix applies the HasSuffix predicate on the "parent_id" field. +func ParentIDHasSuffix(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldHasSuffix(FieldParentID, v)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.Modpack { + return predicate.Modpack(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.Modpack { + return predicate.Modpack(sql.FieldNotNull(FieldParentID)) +} + +// ParentIDEqualFold applies the EqualFold predicate on the "parent_id" field. +func ParentIDEqualFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldEqualFold(FieldParentID, v)) +} + +// ParentIDContainsFold applies the ContainsFold predicate on the "parent_id" field. +func ParentIDContainsFold(v string) predicate.Modpack { + return predicate.Modpack(sql.FieldContainsFold(FieldParentID, v)) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.Modpack) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Modpack) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTargets applies the HasEdge predicate on the "targets" edge. +func HasTargets() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TargetsTable, TargetsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTargetsWith applies the HasEdge predicate on the "targets" edge with a given conditions (other predicates). +func HasTargetsWith(preds ...predicate.ModpackTarget) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newTargetsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasReleases applies the HasEdge predicate on the "releases" edge. +func HasReleases() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ReleasesTable, ReleasesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasReleasesWith applies the HasEdge predicate on the "releases" edge with a given conditions (other predicates). +func HasReleasesWith(preds ...predicate.ModpackRelease) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newReleasesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasMods applies the HasEdge predicate on the "mods" edge. +func HasMods() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ModsTable, ModsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModsWith applies the HasEdge predicate on the "mods" edge with a given conditions (other predicates). +func HasModsWith(preds ...predicate.Mod) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newModsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTags applies the HasEdge predicate on the "tags" edge. +func HasTags() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates). +func HasTagsWith(preds ...predicate.Tag) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasModpackMods applies the HasEdge predicate on the "modpack_mods" edge. +func HasModpackMods() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackModsTable, ModpackModsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackModsWith applies the HasEdge predicate on the "modpack_mods" edge with a given conditions (other predicates). +func HasModpackModsWith(preds ...predicate.ModpackMod) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newModpackModsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasModpackTags applies the HasEdge predicate on the "modpack_tags" edge. +func HasModpackTags() predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackTagsTable, ModpackTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackTagsWith applies the HasEdge predicate on the "modpack_tags" edge with a given conditions (other predicates). +func HasModpackTagsWith(preds ...predicate.ModpackTag) predicate.Modpack { + return predicate.Modpack(func(s *sql.Selector) { + step := newModpackTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Modpack) predicate.Modpack { + return predicate.Modpack(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Modpack) predicate.Modpack { + return predicate.Modpack(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Modpack) predicate.Modpack { + return predicate.Modpack(sql.NotPredicates(p)) +} diff --git a/generated/ent/modpack_create.go b/generated/ent/modpack_create.go new file mode 100644 index 00000000..b1f34aaa --- /dev/null +++ b/generated/ent/modpack_create.go @@ -0,0 +1,1530 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackCreate is the builder for creating a Modpack entity. +type ModpackCreate struct { + config + mutation *ModpackMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (mc *ModpackCreate) SetCreatedAt(t time.Time) *ModpackCreate { + mc.mutation.SetCreatedAt(t) + return mc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableCreatedAt(t *time.Time) *ModpackCreate { + if t != nil { + mc.SetCreatedAt(*t) + } + return mc +} + +// SetUpdatedAt sets the "updated_at" field. +func (mc *ModpackCreate) SetUpdatedAt(t time.Time) *ModpackCreate { + mc.mutation.SetUpdatedAt(t) + return mc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableUpdatedAt(t *time.Time) *ModpackCreate { + if t != nil { + mc.SetUpdatedAt(*t) + } + return mc +} + +// SetName sets the "name" field. +func (mc *ModpackCreate) SetName(s string) *ModpackCreate { + mc.mutation.SetName(s) + return mc +} + +// SetShortDescription sets the "short_description" field. +func (mc *ModpackCreate) SetShortDescription(s string) *ModpackCreate { + mc.mutation.SetShortDescription(s) + return mc +} + +// SetFullDescription sets the "full_description" field. +func (mc *ModpackCreate) SetFullDescription(s string) *ModpackCreate { + mc.mutation.SetFullDescription(s) + return mc +} + +// SetLogo sets the "logo" field. +func (mc *ModpackCreate) SetLogo(s string) *ModpackCreate { + mc.mutation.SetLogo(s) + return mc +} + +// SetNillableLogo sets the "logo" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableLogo(s *string) *ModpackCreate { + if s != nil { + mc.SetLogo(*s) + } + return mc +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (mc *ModpackCreate) SetLogoThumbhash(s string) *ModpackCreate { + mc.mutation.SetLogoThumbhash(s) + return mc +} + +// SetNillableLogoThumbhash sets the "logo_thumbhash" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableLogoThumbhash(s *string) *ModpackCreate { + if s != nil { + mc.SetLogoThumbhash(*s) + } + return mc +} + +// SetCreatorID sets the "creator_id" field. +func (mc *ModpackCreate) SetCreatorID(s string) *ModpackCreate { + mc.mutation.SetCreatorID(s) + return mc +} + +// SetViews sets the "views" field. +func (mc *ModpackCreate) SetViews(u uint) *ModpackCreate { + mc.mutation.SetViews(u) + return mc +} + +// SetNillableViews sets the "views" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableViews(u *uint) *ModpackCreate { + if u != nil { + mc.SetViews(*u) + } + return mc +} + +// SetHotness sets the "hotness" field. +func (mc *ModpackCreate) SetHotness(u uint) *ModpackCreate { + mc.mutation.SetHotness(u) + return mc +} + +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableHotness(u *uint) *ModpackCreate { + if u != nil { + mc.SetHotness(*u) + } + return mc +} + +// SetInstalls sets the "installs" field. +func (mc *ModpackCreate) SetInstalls(u uint) *ModpackCreate { + mc.mutation.SetInstalls(u) + return mc +} + +// SetNillableInstalls sets the "installs" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableInstalls(u *uint) *ModpackCreate { + if u != nil { + mc.SetInstalls(*u) + } + return mc +} + +// SetPopularity sets the "popularity" field. +func (mc *ModpackCreate) SetPopularity(u uint) *ModpackCreate { + mc.mutation.SetPopularity(u) + return mc +} + +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (mc *ModpackCreate) SetNillablePopularity(u *uint) *ModpackCreate { + if u != nil { + mc.SetPopularity(*u) + } + return mc +} + +// SetHidden sets the "hidden" field. +func (mc *ModpackCreate) SetHidden(b bool) *ModpackCreate { + mc.mutation.SetHidden(b) + return mc +} + +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableHidden(b *bool) *ModpackCreate { + if b != nil { + mc.SetHidden(*b) + } + return mc +} + +// SetParentID sets the "parent_id" field. +func (mc *ModpackCreate) SetParentID(s string) *ModpackCreate { + mc.mutation.SetParentID(s) + return mc +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableParentID(s *string) *ModpackCreate { + if s != nil { + mc.SetParentID(*s) + } + return mc +} + +// SetID sets the "id" field. +func (mc *ModpackCreate) SetID(s string) *ModpackCreate { + mc.mutation.SetID(s) + return mc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (mc *ModpackCreate) SetNillableID(s *string) *ModpackCreate { + if s != nil { + mc.SetID(*s) + } + return mc +} + +// AddChildIDs adds the "children" edge to the Modpack entity by IDs. +func (mc *ModpackCreate) AddChildIDs(ids ...string) *ModpackCreate { + mc.mutation.AddChildIDs(ids...) + return mc +} + +// AddChildren adds the "children" edges to the Modpack entity. +func (mc *ModpackCreate) AddChildren(m ...*Modpack) *ModpackCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mc.AddChildIDs(ids...) +} + +// SetParent sets the "parent" edge to the Modpack entity. +func (mc *ModpackCreate) SetParent(m *Modpack) *ModpackCreate { + return mc.SetParentID(m.ID) +} + +// AddTargetIDs adds the "targets" edge to the ModpackTarget entity by IDs. +func (mc *ModpackCreate) AddTargetIDs(ids ...string) *ModpackCreate { + mc.mutation.AddTargetIDs(ids...) + return mc +} + +// AddTargets adds the "targets" edges to the ModpackTarget entity. +func (mc *ModpackCreate) AddTargets(m ...*ModpackTarget) *ModpackCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mc.AddTargetIDs(ids...) +} + +// AddReleaseIDs adds the "releases" edge to the ModpackRelease entity by IDs. +func (mc *ModpackCreate) AddReleaseIDs(ids ...string) *ModpackCreate { + mc.mutation.AddReleaseIDs(ids...) + return mc +} + +// AddReleases adds the "releases" edges to the ModpackRelease entity. +func (mc *ModpackCreate) AddReleases(m ...*ModpackRelease) *ModpackCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mc.AddReleaseIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (mc *ModpackCreate) AddModIDs(ids ...string) *ModpackCreate { + mc.mutation.AddModIDs(ids...) + return mc +} + +// AddMods adds the "mods" edges to the Mod entity. +func (mc *ModpackCreate) AddMods(m ...*Mod) *ModpackCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mc.AddModIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (mc *ModpackCreate) AddTagIDs(ids ...string) *ModpackCreate { + mc.mutation.AddTagIDs(ids...) + return mc +} + +// AddTags adds the "tags" edges to the Tag entity. +func (mc *ModpackCreate) AddTags(t ...*Tag) *ModpackCreate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mc.AddTagIDs(ids...) +} + +// Mutation returns the ModpackMutation object of the builder. +func (mc *ModpackCreate) Mutation() *ModpackMutation { + return mc.mutation +} + +// Save creates the Modpack in the database. +func (mc *ModpackCreate) Save(ctx context.Context) (*Modpack, error) { + mc.defaults() + return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mc *ModpackCreate) SaveX(ctx context.Context) *Modpack { + v, err := mc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mc *ModpackCreate) Exec(ctx context.Context) error { + _, err := mc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mc *ModpackCreate) ExecX(ctx context.Context) { + if err := mc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mc *ModpackCreate) defaults() { + if _, ok := mc.mutation.CreatedAt(); !ok { + v := modpack.DefaultCreatedAt() + mc.mutation.SetCreatedAt(v) + } + if _, ok := mc.mutation.UpdatedAt(); !ok { + v := modpack.DefaultUpdatedAt() + mc.mutation.SetUpdatedAt(v) + } + if _, ok := mc.mutation.Views(); !ok { + v := modpack.DefaultViews + mc.mutation.SetViews(v) + } + if _, ok := mc.mutation.Hotness(); !ok { + v := modpack.DefaultHotness + mc.mutation.SetHotness(v) + } + if _, ok := mc.mutation.Installs(); !ok { + v := modpack.DefaultInstalls + mc.mutation.SetInstalls(v) + } + if _, ok := mc.mutation.Popularity(); !ok { + v := modpack.DefaultPopularity + mc.mutation.SetPopularity(v) + } + if _, ok := mc.mutation.Hidden(); !ok { + v := modpack.DefaultHidden + mc.mutation.SetHidden(v) + } + if _, ok := mc.mutation.ID(); !ok { + v := modpack.DefaultID() + mc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mc *ModpackCreate) check() error { + if _, ok := mc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Modpack.created_at"`)} + } + if _, ok := mc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Modpack.updated_at"`)} + } + if _, ok := mc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Modpack.name"`)} + } + if _, ok := mc.mutation.ShortDescription(); !ok { + return &ValidationError{Name: "short_description", err: errors.New(`ent: missing required field "Modpack.short_description"`)} + } + if v, ok := mc.mutation.ShortDescription(); ok { + if err := modpack.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Modpack.short_description": %w`, err)} + } + } + if _, ok := mc.mutation.FullDescription(); !ok { + return &ValidationError{Name: "full_description", err: errors.New(`ent: missing required field "Modpack.full_description"`)} + } + if _, ok := mc.mutation.CreatorID(); !ok { + return &ValidationError{Name: "creator_id", err: errors.New(`ent: missing required field "Modpack.creator_id"`)} + } + if _, ok := mc.mutation.Views(); !ok { + return &ValidationError{Name: "views", err: errors.New(`ent: missing required field "Modpack.views"`)} + } + if _, ok := mc.mutation.Hotness(); !ok { + return &ValidationError{Name: "hotness", err: errors.New(`ent: missing required field "Modpack.hotness"`)} + } + if _, ok := mc.mutation.Installs(); !ok { + return &ValidationError{Name: "installs", err: errors.New(`ent: missing required field "Modpack.installs"`)} + } + if _, ok := mc.mutation.Popularity(); !ok { + return &ValidationError{Name: "popularity", err: errors.New(`ent: missing required field "Modpack.popularity"`)} + } + if _, ok := mc.mutation.Hidden(); !ok { + return &ValidationError{Name: "hidden", err: errors.New(`ent: missing required field "Modpack.hidden"`)} + } + return nil +} + +func (mc *ModpackCreate) sqlSave(ctx context.Context) (*Modpack, error) { + if err := mc.check(); err != nil { + return nil, err + } + _node, _spec := mc.createSpec() + if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected Modpack.ID type: %T", _spec.ID.Value) + } + } + mc.mutation.id = &_node.ID + mc.mutation.done = true + return _node, nil +} + +func (mc *ModpackCreate) createSpec() (*Modpack, *sqlgraph.CreateSpec) { + var ( + _node = &Modpack{config: mc.config} + _spec = sqlgraph.NewCreateSpec(modpack.Table, sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString)) + ) + _spec.OnConflict = mc.conflict + if id, ok := mc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := mc.mutation.CreatedAt(); ok { + _spec.SetField(modpack.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := mc.mutation.UpdatedAt(); ok { + _spec.SetField(modpack.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := mc.mutation.Name(); ok { + _spec.SetField(modpack.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := mc.mutation.ShortDescription(); ok { + _spec.SetField(modpack.FieldShortDescription, field.TypeString, value) + _node.ShortDescription = value + } + if value, ok := mc.mutation.FullDescription(); ok { + _spec.SetField(modpack.FieldFullDescription, field.TypeString, value) + _node.FullDescription = value + } + if value, ok := mc.mutation.Logo(); ok { + _spec.SetField(modpack.FieldLogo, field.TypeString, value) + _node.Logo = value + } + if value, ok := mc.mutation.LogoThumbhash(); ok { + _spec.SetField(modpack.FieldLogoThumbhash, field.TypeString, value) + _node.LogoThumbhash = value + } + if value, ok := mc.mutation.CreatorID(); ok { + _spec.SetField(modpack.FieldCreatorID, field.TypeString, value) + _node.CreatorID = value + } + if value, ok := mc.mutation.Views(); ok { + _spec.SetField(modpack.FieldViews, field.TypeUint, value) + _node.Views = value + } + if value, ok := mc.mutation.Hotness(); ok { + _spec.SetField(modpack.FieldHotness, field.TypeUint, value) + _node.Hotness = value + } + if value, ok := mc.mutation.Installs(); ok { + _spec.SetField(modpack.FieldInstalls, field.TypeUint, value) + _node.Installs = value + } + if value, ok := mc.mutation.Popularity(); ok { + _spec.SetField(modpack.FieldPopularity, field.TypeUint, value) + _node.Popularity = value + } + if value, ok := mc.mutation.Hidden(); ok { + _spec.SetField(modpack.FieldHidden, field.TypeBool, value) + _node.Hidden = value + } + if nodes := mc.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpack.ParentTable, + Columns: []string{modpack.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ParentID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.ReleasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mc.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Modpack.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mc *ModpackCreate) OnConflict(opts ...sql.ConflictOption) *ModpackUpsertOne { + mc.conflict = opts + return &ModpackUpsertOne{ + create: mc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mc *ModpackCreate) OnConflictColumns(columns ...string) *ModpackUpsertOne { + mc.conflict = append(mc.conflict, sql.ConflictColumns(columns...)) + return &ModpackUpsertOne{ + create: mc, + } +} + +type ( + // ModpackUpsertOne is the builder for "upsert"-ing + // one Modpack node. + ModpackUpsertOne struct { + create *ModpackCreate + } + + // ModpackUpsert is the "OnConflict" setter. + ModpackUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackUpsert) SetUpdatedAt(v time.Time) *ModpackUpsert { + u.Set(modpack.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateUpdatedAt() *ModpackUpsert { + u.SetExcluded(modpack.FieldUpdatedAt) + return u +} + +// SetName sets the "name" field. +func (u *ModpackUpsert) SetName(v string) *ModpackUpsert { + u.Set(modpack.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateName() *ModpackUpsert { + u.SetExcluded(modpack.FieldName) + return u +} + +// SetShortDescription sets the "short_description" field. +func (u *ModpackUpsert) SetShortDescription(v string) *ModpackUpsert { + u.Set(modpack.FieldShortDescription, v) + return u +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateShortDescription() *ModpackUpsert { + u.SetExcluded(modpack.FieldShortDescription) + return u +} + +// SetFullDescription sets the "full_description" field. +func (u *ModpackUpsert) SetFullDescription(v string) *ModpackUpsert { + u.Set(modpack.FieldFullDescription, v) + return u +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateFullDescription() *ModpackUpsert { + u.SetExcluded(modpack.FieldFullDescription) + return u +} + +// SetLogo sets the "logo" field. +func (u *ModpackUpsert) SetLogo(v string) *ModpackUpsert { + u.Set(modpack.FieldLogo, v) + return u +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateLogo() *ModpackUpsert { + u.SetExcluded(modpack.FieldLogo) + return u +} + +// ClearLogo clears the value of the "logo" field. +func (u *ModpackUpsert) ClearLogo() *ModpackUpsert { + u.SetNull(modpack.FieldLogo) + return u +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (u *ModpackUpsert) SetLogoThumbhash(v string) *ModpackUpsert { + u.Set(modpack.FieldLogoThumbhash, v) + return u +} + +// UpdateLogoThumbhash sets the "logo_thumbhash" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateLogoThumbhash() *ModpackUpsert { + u.SetExcluded(modpack.FieldLogoThumbhash) + return u +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (u *ModpackUpsert) ClearLogoThumbhash() *ModpackUpsert { + u.SetNull(modpack.FieldLogoThumbhash) + return u +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModpackUpsert) SetCreatorID(v string) *ModpackUpsert { + u.Set(modpack.FieldCreatorID, v) + return u +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateCreatorID() *ModpackUpsert { + u.SetExcluded(modpack.FieldCreatorID) + return u +} + +// SetViews sets the "views" field. +func (u *ModpackUpsert) SetViews(v uint) *ModpackUpsert { + u.Set(modpack.FieldViews, v) + return u +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateViews() *ModpackUpsert { + u.SetExcluded(modpack.FieldViews) + return u +} + +// AddViews adds v to the "views" field. +func (u *ModpackUpsert) AddViews(v uint) *ModpackUpsert { + u.Add(modpack.FieldViews, v) + return u +} + +// SetHotness sets the "hotness" field. +func (u *ModpackUpsert) SetHotness(v uint) *ModpackUpsert { + u.Set(modpack.FieldHotness, v) + return u +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateHotness() *ModpackUpsert { + u.SetExcluded(modpack.FieldHotness) + return u +} + +// AddHotness adds v to the "hotness" field. +func (u *ModpackUpsert) AddHotness(v uint) *ModpackUpsert { + u.Add(modpack.FieldHotness, v) + return u +} + +// SetInstalls sets the "installs" field. +func (u *ModpackUpsert) SetInstalls(v uint) *ModpackUpsert { + u.Set(modpack.FieldInstalls, v) + return u +} + +// UpdateInstalls sets the "installs" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateInstalls() *ModpackUpsert { + u.SetExcluded(modpack.FieldInstalls) + return u +} + +// AddInstalls adds v to the "installs" field. +func (u *ModpackUpsert) AddInstalls(v uint) *ModpackUpsert { + u.Add(modpack.FieldInstalls, v) + return u +} + +// SetPopularity sets the "popularity" field. +func (u *ModpackUpsert) SetPopularity(v uint) *ModpackUpsert { + u.Set(modpack.FieldPopularity, v) + return u +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModpackUpsert) UpdatePopularity() *ModpackUpsert { + u.SetExcluded(modpack.FieldPopularity) + return u +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModpackUpsert) AddPopularity(v uint) *ModpackUpsert { + u.Add(modpack.FieldPopularity, v) + return u +} + +// SetHidden sets the "hidden" field. +func (u *ModpackUpsert) SetHidden(v bool) *ModpackUpsert { + u.Set(modpack.FieldHidden, v) + return u +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModpackUpsert) UpdateHidden() *ModpackUpsert { + u.SetExcluded(modpack.FieldHidden) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpack.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackUpsertOne) UpdateNewValues() *ModpackUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(modpack.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(modpack.FieldCreatedAt) + } + if _, exists := u.create.mutation.ParentID(); exists { + s.SetIgnore(modpack.FieldParentID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackUpsertOne) Ignore() *ModpackUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackUpsertOne) DoNothing() *ModpackUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackCreate.OnConflict +// documentation for more info. +func (u *ModpackUpsertOne) Update(set func(*ModpackUpsert)) *ModpackUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackUpsertOne) SetUpdatedAt(v time.Time) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateUpdatedAt() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ModpackUpsertOne) SetName(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateName() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *ModpackUpsertOne) SetShortDescription(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateShortDescription() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateShortDescription() + }) +} + +// SetFullDescription sets the "full_description" field. +func (u *ModpackUpsertOne) SetFullDescription(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetFullDescription(v) + }) +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateFullDescription() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateFullDescription() + }) +} + +// SetLogo sets the "logo" field. +func (u *ModpackUpsertOne) SetLogo(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetLogo(v) + }) +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateLogo() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateLogo() + }) +} + +// ClearLogo clears the value of the "logo" field. +func (u *ModpackUpsertOne) ClearLogo() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.ClearLogo() + }) +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (u *ModpackUpsertOne) SetLogoThumbhash(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetLogoThumbhash(v) + }) +} + +// UpdateLogoThumbhash sets the "logo_thumbhash" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateLogoThumbhash() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateLogoThumbhash() + }) +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (u *ModpackUpsertOne) ClearLogoThumbhash() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.ClearLogoThumbhash() + }) +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModpackUpsertOne) SetCreatorID(v string) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetCreatorID(v) + }) +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateCreatorID() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateCreatorID() + }) +} + +// SetViews sets the "views" field. +func (u *ModpackUpsertOne) SetViews(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *ModpackUpsertOne) AddViews(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateViews() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateViews() + }) +} + +// SetHotness sets the "hotness" field. +func (u *ModpackUpsertOne) SetHotness(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *ModpackUpsertOne) AddHotness(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateHotness() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateHotness() + }) +} + +// SetInstalls sets the "installs" field. +func (u *ModpackUpsertOne) SetInstalls(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetInstalls(v) + }) +} + +// AddInstalls adds v to the "installs" field. +func (u *ModpackUpsertOne) AddInstalls(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.AddInstalls(v) + }) +} + +// UpdateInstalls sets the "installs" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateInstalls() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateInstalls() + }) +} + +// SetPopularity sets the "popularity" field. +func (u *ModpackUpsertOne) SetPopularity(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetPopularity(v) + }) +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModpackUpsertOne) AddPopularity(v uint) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.AddPopularity(v) + }) +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdatePopularity() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdatePopularity() + }) +} + +// SetHidden sets the "hidden" field. +func (u *ModpackUpsertOne) SetHidden(v bool) *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.SetHidden(v) + }) +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModpackUpsertOne) UpdateHidden() *ModpackUpsertOne { + return u.Update(func(s *ModpackUpsert) { + s.UpdateHidden() + }) +} + +// Exec executes the query. +func (u *ModpackUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ModpackUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ModpackUpsertOne.ID is not supported by MySQL driver. Use ModpackUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ModpackUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ModpackCreateBulk is the builder for creating many Modpack entities in bulk. +type ModpackCreateBulk struct { + config + err error + builders []*ModpackCreate + conflict []sql.ConflictOption +} + +// Save creates the Modpack entities in the database. +func (mcb *ModpackCreateBulk) Save(ctx context.Context) ([]*Modpack, error) { + if mcb.err != nil { + return nil, mcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) + nodes := make([]*Modpack, len(mcb.builders)) + mutators := make([]Mutator, len(mcb.builders)) + for i := range mcb.builders { + func(i int, root context.Context) { + builder := mcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ModpackMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = mcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mcb *ModpackCreateBulk) SaveX(ctx context.Context) []*Modpack { + v, err := mcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mcb *ModpackCreateBulk) Exec(ctx context.Context) error { + _, err := mcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mcb *ModpackCreateBulk) ExecX(ctx context.Context) { + if err := mcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Modpack.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mcb *ModpackCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModpackUpsertBulk { + mcb.conflict = opts + return &ModpackUpsertBulk{ + create: mcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mcb *ModpackCreateBulk) OnConflictColumns(columns ...string) *ModpackUpsertBulk { + mcb.conflict = append(mcb.conflict, sql.ConflictColumns(columns...)) + return &ModpackUpsertBulk{ + create: mcb, + } +} + +// ModpackUpsertBulk is the builder for "upsert"-ing +// a bulk of Modpack nodes. +type ModpackUpsertBulk struct { + create *ModpackCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpack.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackUpsertBulk) UpdateNewValues() *ModpackUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(modpack.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(modpack.FieldCreatedAt) + } + if _, exists := b.mutation.ParentID(); exists { + s.SetIgnore(modpack.FieldParentID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Modpack.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackUpsertBulk) Ignore() *ModpackUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackUpsertBulk) DoNothing() *ModpackUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackCreateBulk.OnConflict +// documentation for more info. +func (u *ModpackUpsertBulk) Update(set func(*ModpackUpsert)) *ModpackUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackUpsertBulk) SetUpdatedAt(v time.Time) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateUpdatedAt() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetName sets the "name" field. +func (u *ModpackUpsertBulk) SetName(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateName() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *ModpackUpsertBulk) SetShortDescription(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateShortDescription() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateShortDescription() + }) +} + +// SetFullDescription sets the "full_description" field. +func (u *ModpackUpsertBulk) SetFullDescription(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetFullDescription(v) + }) +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateFullDescription() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateFullDescription() + }) +} + +// SetLogo sets the "logo" field. +func (u *ModpackUpsertBulk) SetLogo(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetLogo(v) + }) +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateLogo() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateLogo() + }) +} + +// ClearLogo clears the value of the "logo" field. +func (u *ModpackUpsertBulk) ClearLogo() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.ClearLogo() + }) +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (u *ModpackUpsertBulk) SetLogoThumbhash(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetLogoThumbhash(v) + }) +} + +// UpdateLogoThumbhash sets the "logo_thumbhash" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateLogoThumbhash() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateLogoThumbhash() + }) +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (u *ModpackUpsertBulk) ClearLogoThumbhash() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.ClearLogoThumbhash() + }) +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModpackUpsertBulk) SetCreatorID(v string) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetCreatorID(v) + }) +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateCreatorID() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateCreatorID() + }) +} + +// SetViews sets the "views" field. +func (u *ModpackUpsertBulk) SetViews(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *ModpackUpsertBulk) AddViews(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateViews() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateViews() + }) +} + +// SetHotness sets the "hotness" field. +func (u *ModpackUpsertBulk) SetHotness(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *ModpackUpsertBulk) AddHotness(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateHotness() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateHotness() + }) +} + +// SetInstalls sets the "installs" field. +func (u *ModpackUpsertBulk) SetInstalls(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetInstalls(v) + }) +} + +// AddInstalls adds v to the "installs" field. +func (u *ModpackUpsertBulk) AddInstalls(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.AddInstalls(v) + }) +} + +// UpdateInstalls sets the "installs" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateInstalls() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateInstalls() + }) +} + +// SetPopularity sets the "popularity" field. +func (u *ModpackUpsertBulk) SetPopularity(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetPopularity(v) + }) +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModpackUpsertBulk) AddPopularity(v uint) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.AddPopularity(v) + }) +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdatePopularity() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdatePopularity() + }) +} + +// SetHidden sets the "hidden" field. +func (u *ModpackUpsertBulk) SetHidden(v bool) *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.SetHidden(v) + }) +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModpackUpsertBulk) UpdateHidden() *ModpackUpsertBulk { + return u.Update(func(s *ModpackUpsert) { + s.UpdateHidden() + }) +} + +// Exec executes the query. +func (u *ModpackUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ModpackCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpack_delete.go b/generated/ent/modpack_delete.go new file mode 100644 index 00000000..af8b3aca --- /dev/null +++ b/generated/ent/modpack_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackDelete is the builder for deleting a Modpack entity. +type ModpackDelete struct { + config + hooks []Hook + mutation *ModpackMutation +} + +// Where appends a list predicates to the ModpackDelete builder. +func (md *ModpackDelete) Where(ps ...predicate.Modpack) *ModpackDelete { + md.mutation.Where(ps...) + return md +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (md *ModpackDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (md *ModpackDelete) ExecX(ctx context.Context) int { + n, err := md.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (md *ModpackDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modpack.Table, sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString)) + if ps := md.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + md.mutation.done = true + return affected, err +} + +// ModpackDeleteOne is the builder for deleting a single Modpack entity. +type ModpackDeleteOne struct { + md *ModpackDelete +} + +// Where appends a list predicates to the ModpackDelete builder. +func (mdo *ModpackDeleteOne) Where(ps ...predicate.Modpack) *ModpackDeleteOne { + mdo.md.mutation.Where(ps...) + return mdo +} + +// Exec executes the deletion query. +func (mdo *ModpackDeleteOne) Exec(ctx context.Context) error { + n, err := mdo.md.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modpack.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mdo *ModpackDeleteOne) ExecX(ctx context.Context) { + if err := mdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpack_query.go b/generated/ent/modpack_query.go new file mode 100644 index 00000000..10d8172d --- /dev/null +++ b/generated/ent/modpack_query.go @@ -0,0 +1,1208 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackQuery is the builder for querying Modpack entities. +type ModpackQuery struct { + config + ctx *QueryContext + order []modpack.OrderOption + inters []Interceptor + predicates []predicate.Modpack + withChildren *ModpackQuery + withParent *ModpackQuery + withTargets *ModpackTargetQuery + withReleases *ModpackReleaseQuery + withMods *ModQuery + withTags *TagQuery + withModpackMods *ModpackModQuery + withModpackTags *ModpackTagQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ModpackQuery builder. +func (mq *ModpackQuery) Where(ps ...predicate.Modpack) *ModpackQuery { + mq.predicates = append(mq.predicates, ps...) + return mq +} + +// Limit the number of records to be returned by this query. +func (mq *ModpackQuery) Limit(limit int) *ModpackQuery { + mq.ctx.Limit = &limit + return mq +} + +// Offset to start from. +func (mq *ModpackQuery) Offset(offset int) *ModpackQuery { + mq.ctx.Offset = &offset + return mq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mq *ModpackQuery) Unique(unique bool) *ModpackQuery { + mq.ctx.Unique = &unique + return mq +} + +// Order specifies how the records should be ordered. +func (mq *ModpackQuery) Order(o ...modpack.OrderOption) *ModpackQuery { + mq.order = append(mq.order, o...) + return mq +} + +// QueryChildren chains the current query on the "children" edge. +func (mq *ModpackQuery) QueryChildren() *ModpackQuery { + query := (&ModpackClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.ChildrenTable, modpack.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryParent chains the current query on the "parent" edge. +func (mq *ModpackQuery) QueryParent() *ModpackQuery { + query := (&ModpackClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpack.ParentTable, modpack.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTargets chains the current query on the "targets" edge. +func (mq *ModpackQuery) QueryTargets() *ModpackTargetQuery { + query := (&ModpackTargetClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpacktarget.Table, modpacktarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.TargetsTable, modpack.TargetsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryReleases chains the current query on the "releases" edge. +func (mq *ModpackQuery) QueryReleases() *ModpackReleaseQuery { + query := (&ModpackReleaseClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpackrelease.Table, modpackrelease.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, modpack.ReleasesTable, modpack.ReleasesColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMods chains the current query on the "mods" edge. +func (mq *ModpackQuery) QueryMods() *ModQuery { + query := (&ModClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, modpack.ModsTable, modpack.ModsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTags chains the current query on the "tags" edge. +func (mq *ModpackQuery) QueryTags() *TagQuery { + query := (&TagClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, modpack.TagsTable, modpack.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryModpackMods chains the current query on the "modpack_mods" edge. +func (mq *ModpackQuery) QueryModpackMods() *ModpackModQuery { + query := (&ModpackModClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpackmod.Table, modpackmod.ModpackColumn), + sqlgraph.Edge(sqlgraph.O2M, true, modpack.ModpackModsTable, modpack.ModpackModsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryModpackTags chains the current query on the "modpack_tags" edge. +func (mq *ModpackQuery) QueryModpackTags() *ModpackTagQuery { + query := (&ModpackTagClient{config: mq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpack.Table, modpack.FieldID, selector), + sqlgraph.To(modpacktag.Table, modpacktag.ModpackColumn), + sqlgraph.Edge(sqlgraph.O2M, true, modpack.ModpackTagsTable, modpack.ModpackTagsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Modpack entity from the query. +// Returns a *NotFoundError when no Modpack was found. +func (mq *ModpackQuery) First(ctx context.Context) (*Modpack, error) { + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modpack.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mq *ModpackQuery) FirstX(ctx context.Context) *Modpack { + node, err := mq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Modpack ID from the query. +// Returns a *NotFoundError when no Modpack ID was found. +func (mq *ModpackQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{modpack.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mq *ModpackQuery) FirstIDX(ctx context.Context) string { + id, err := mq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Modpack entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Modpack entity is found. +// Returns a *NotFoundError when no Modpack entities are found. +func (mq *ModpackQuery) Only(ctx context.Context) (*Modpack, error) { + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modpack.Label} + default: + return nil, &NotSingularError{modpack.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mq *ModpackQuery) OnlyX(ctx context.Context) *Modpack { + node, err := mq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Modpack ID in the query. +// Returns a *NotSingularError when more than one Modpack ID is found. +// Returns a *NotFoundError when no entities are found. +func (mq *ModpackQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{modpack.Label} + default: + err = &NotSingularError{modpack.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mq *ModpackQuery) OnlyIDX(ctx context.Context) string { + id, err := mq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Modpacks. +func (mq *ModpackQuery) All(ctx context.Context) ([]*Modpack, error) { + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll) + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Modpack, *ModpackQuery]() + return withInterceptors[[]*Modpack](ctx, mq, qr, mq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mq *ModpackQuery) AllX(ctx context.Context) []*Modpack { + nodes, err := mq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Modpack IDs. +func (mq *ModpackQuery) IDs(ctx context.Context) (ids []string, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs) + if err = mq.Select(modpack.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mq *ModpackQuery) IDsX(ctx context.Context) []string { + ids, err := mq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mq *ModpackQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount) + if err := mq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mq, querierCount[*ModpackQuery](), mq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mq *ModpackQuery) CountX(ctx context.Context) int { + count, err := mq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mq *ModpackQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist) + switch _, err := mq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mq *ModpackQuery) ExistX(ctx context.Context) bool { + exist, err := mq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModpackQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mq *ModpackQuery) Clone() *ModpackQuery { + if mq == nil { + return nil + } + return &ModpackQuery{ + config: mq.config, + ctx: mq.ctx.Clone(), + order: append([]modpack.OrderOption{}, mq.order...), + inters: append([]Interceptor{}, mq.inters...), + predicates: append([]predicate.Modpack{}, mq.predicates...), + withChildren: mq.withChildren.Clone(), + withParent: mq.withParent.Clone(), + withTargets: mq.withTargets.Clone(), + withReleases: mq.withReleases.Clone(), + withMods: mq.withMods.Clone(), + withTags: mq.withTags.Clone(), + withModpackMods: mq.withModpackMods.Clone(), + withModpackTags: mq.withModpackTags.Clone(), + // clone intermediate query. + sql: mq.sql.Clone(), + path: mq.path, + modifiers: append([]func(*sql.Selector){}, mq.modifiers...), + } +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithChildren(opts ...func(*ModpackQuery)) *ModpackQuery { + query := (&ModpackClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withChildren = query + return mq +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithParent(opts ...func(*ModpackQuery)) *ModpackQuery { + query := (&ModpackClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withParent = query + return mq +} + +// WithTargets tells the query-builder to eager-load the nodes that are connected to +// the "targets" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithTargets(opts ...func(*ModpackTargetQuery)) *ModpackQuery { + query := (&ModpackTargetClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withTargets = query + return mq +} + +// WithReleases tells the query-builder to eager-load the nodes that are connected to +// the "releases" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithReleases(opts ...func(*ModpackReleaseQuery)) *ModpackQuery { + query := (&ModpackReleaseClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withReleases = query + return mq +} + +// WithMods tells the query-builder to eager-load the nodes that are connected to +// the "mods" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithMods(opts ...func(*ModQuery)) *ModpackQuery { + query := (&ModClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withMods = query + return mq +} + +// WithTags tells the query-builder to eager-load the nodes that are connected to +// the "tags" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithTags(opts ...func(*TagQuery)) *ModpackQuery { + query := (&TagClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withTags = query + return mq +} + +// WithModpackMods tells the query-builder to eager-load the nodes that are connected to +// the "modpack_mods" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithModpackMods(opts ...func(*ModpackModQuery)) *ModpackQuery { + query := (&ModpackModClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withModpackMods = query + return mq +} + +// WithModpackTags tells the query-builder to eager-load the nodes that are connected to +// the "modpack_tags" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModpackQuery) WithModpackTags(opts ...func(*ModpackTagQuery)) *ModpackQuery { + query := (&ModpackTagClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withModpackTags = query + return mq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Modpack.Query(). +// GroupBy(modpack.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mq *ModpackQuery) GroupBy(field string, fields ...string) *ModpackGroupBy { + mq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModpackGroupBy{build: mq} + grbuild.flds = &mq.ctx.Fields + grbuild.label = modpack.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.Modpack.Query(). +// Select(modpack.FieldCreatedAt). +// Scan(ctx, &v) +func (mq *ModpackQuery) Select(fields ...string) *ModpackSelect { + mq.ctx.Fields = append(mq.ctx.Fields, fields...) + sbuild := &ModpackSelect{ModpackQuery: mq} + sbuild.label = modpack.Label + sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModpackSelect configured with the given aggregations. +func (mq *ModpackQuery) Aggregate(fns ...AggregateFunc) *ModpackSelect { + return mq.Select().Aggregate(fns...) +} + +func (mq *ModpackQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mq); err != nil { + return err + } + } + } + for _, f := range mq.ctx.Fields { + if !modpack.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mq.path != nil { + prev, err := mq.path(ctx) + if err != nil { + return err + } + mq.sql = prev + } + return nil +} + +func (mq *ModpackQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Modpack, error) { + var ( + nodes = []*Modpack{} + _spec = mq.querySpec() + loadedTypes = [8]bool{ + mq.withChildren != nil, + mq.withParent != nil, + mq.withTargets != nil, + mq.withReleases != nil, + mq.withMods != nil, + mq.withTags != nil, + mq.withModpackMods != nil, + mq.withModpackTags != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Modpack).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Modpack{config: mq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mq.modifiers) > 0 { + _spec.Modifiers = mq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mq.withChildren; query != nil { + if err := mq.loadChildren(ctx, query, nodes, + func(n *Modpack) { n.Edges.Children = []*Modpack{} }, + func(n *Modpack, e *Modpack) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } + if query := mq.withParent; query != nil { + if err := mq.loadParent(ctx, query, nodes, nil, + func(n *Modpack, e *Modpack) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := mq.withTargets; query != nil { + if err := mq.loadTargets(ctx, query, nodes, + func(n *Modpack) { n.Edges.Targets = []*ModpackTarget{} }, + func(n *Modpack, e *ModpackTarget) { n.Edges.Targets = append(n.Edges.Targets, e) }); err != nil { + return nil, err + } + } + if query := mq.withReleases; query != nil { + if err := mq.loadReleases(ctx, query, nodes, + func(n *Modpack) { n.Edges.Releases = []*ModpackRelease{} }, + func(n *Modpack, e *ModpackRelease) { n.Edges.Releases = append(n.Edges.Releases, e) }); err != nil { + return nil, err + } + } + if query := mq.withMods; query != nil { + if err := mq.loadMods(ctx, query, nodes, + func(n *Modpack) { n.Edges.Mods = []*Mod{} }, + func(n *Modpack, e *Mod) { n.Edges.Mods = append(n.Edges.Mods, e) }); err != nil { + return nil, err + } + } + if query := mq.withTags; query != nil { + if err := mq.loadTags(ctx, query, nodes, + func(n *Modpack) { n.Edges.Tags = []*Tag{} }, + func(n *Modpack, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + if query := mq.withModpackMods; query != nil { + if err := mq.loadModpackMods(ctx, query, nodes, + func(n *Modpack) { n.Edges.ModpackMods = []*ModpackMod{} }, + func(n *Modpack, e *ModpackMod) { n.Edges.ModpackMods = append(n.Edges.ModpackMods, e) }); err != nil { + return nil, err + } + } + if query := mq.withModpackTags; query != nil { + if err := mq.loadModpackTags(ctx, query, nodes, + func(n *Modpack) { n.Edges.ModpackTags = []*ModpackTag{} }, + func(n *Modpack, e *ModpackTag) { n.Edges.ModpackTags = append(n.Edges.ModpackTags, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mq *ModpackQuery) loadChildren(ctx context.Context, query *ModpackQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *Modpack)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Modpack) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpack.FieldParentID) + } + query.Where(predicate.Modpack(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(modpack.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ParentID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (mq *ModpackQuery) loadParent(ctx context.Context, query *ModpackQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *Modpack)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*Modpack) + for i := range nodes { + fk := nodes[i].ParentID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(modpack.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (mq *ModpackQuery) loadTargets(ctx context.Context, query *ModpackTargetQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *ModpackTarget)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Modpack) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpacktarget.FieldModpackID) + } + query.Where(predicate.ModpackTarget(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(modpack.TargetsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ModpackID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "modpack_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (mq *ModpackQuery) loadReleases(ctx context.Context, query *ModpackReleaseQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *ModpackRelease)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Modpack) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpackrelease.FieldModpackID) + } + query.Where(predicate.ModpackRelease(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(modpack.ReleasesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ModpackID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "modpack_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (mq *ModpackQuery) loadMods(ctx context.Context, query *ModQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *Mod)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Modpack) + nids := make(map[string]map[*Modpack]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(modpack.ModsTable) + s.Join(joinT).On(s.C(mod.FieldID), joinT.C(modpack.ModsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(modpack.ModsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(modpack.ModsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Modpack]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Mod](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "mods" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (mq *ModpackQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *Tag)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Modpack) + nids := make(map[string]map[*Modpack]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(modpack.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(modpack.TagsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(modpack.TagsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(modpack.TagsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Modpack]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "tags" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (mq *ModpackQuery) loadModpackMods(ctx context.Context, query *ModpackModQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *ModpackMod)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Modpack) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpackmod.FieldModpackID) + } + query.Where(predicate.ModpackMod(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(modpack.ModpackModsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ModpackID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "modpack_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} +func (mq *ModpackQuery) loadModpackTags(ctx context.Context, query *ModpackTagQuery, nodes []*Modpack, init func(*Modpack), assign func(*Modpack, *ModpackTag)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Modpack) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpacktag.FieldModpackID) + } + query.Where(predicate.ModpackTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(modpack.ModpackTagsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ModpackID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "modpack_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} + +func (mq *ModpackQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mq.querySpec() + if len(mq.modifiers) > 0 { + _spec.Modifiers = mq.modifiers + } + _spec.Node.Columns = mq.ctx.Fields + if len(mq.ctx.Fields) > 0 { + _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, mq.driver, _spec) +} + +func (mq *ModpackQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modpack.Table, modpack.Columns, sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString)) + _spec.From = mq.sql + if unique := mq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true + } + if fields := mq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpack.FieldID) + for i := range fields { + if fields[i] != modpack.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if mq.withParent != nil { + _spec.Node.AddColumnOnce(modpack.FieldParentID) + } + } + if ps := mq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mq *ModpackQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mq.driver.Dialect()) + t1 := builder.Table(modpack.Table) + columns := mq.ctx.Fields + if len(columns) == 0 { + columns = modpack.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mq.sql != nil { + selector = mq.sql + selector.Select(selector.Columns(columns...)...) + } + if mq.ctx.Unique != nil && *mq.ctx.Unique { + selector.Distinct() + } + for _, m := range mq.modifiers { + m(selector) + } + for _, p := range mq.predicates { + p(selector) + } + for _, p := range mq.order { + p(selector) + } + if offset := mq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mq *ModpackQuery) Modify(modifiers ...func(s *sql.Selector)) *ModpackSelect { + mq.modifiers = append(mq.modifiers, modifiers...) + return mq.Select() +} + +// ModpackGroupBy is the group-by builder for Modpack entities. +type ModpackGroupBy struct { + selector + build *ModpackQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mgb *ModpackGroupBy) Aggregate(fns ...AggregateFunc) *ModpackGroupBy { + mgb.fns = append(mgb.fns, fns...) + return mgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mgb *ModpackGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy) + if err := mgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackQuery, *ModpackGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) +} + +func (mgb *ModpackGroupBy) sqlScan(ctx context.Context, root *ModpackQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mgb.fns)) + for _, fn := range mgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) + for _, f := range *mgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ModpackSelect is the builder for selecting fields of Modpack entities. +type ModpackSelect struct { + *ModpackQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ms *ModpackSelect) Aggregate(fns ...AggregateFunc) *ModpackSelect { + ms.fns = append(ms.fns, fns...) + return ms +} + +// Scan applies the selector query and scans the result into the given value. +func (ms *ModpackSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect) + if err := ms.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackQuery, *ModpackSelect](ctx, ms.ModpackQuery, ms, ms.inters, v) +} + +func (ms *ModpackSelect) sqlScan(ctx context.Context, root *ModpackQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ms.fns)) + for _, fn := range ms.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ms.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ms.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ms *ModpackSelect) Modify(modifiers ...func(s *sql.Selector)) *ModpackSelect { + ms.modifiers = append(ms.modifiers, modifiers...) + return ms +} diff --git a/generated/ent/modpack_update.go b/generated/ent/modpack_update.go new file mode 100644 index 00000000..13513a40 --- /dev/null +++ b/generated/ent/modpack_update.go @@ -0,0 +1,1558 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackUpdate is the builder for updating Modpack entities. +type ModpackUpdate struct { + config + hooks []Hook + mutation *ModpackMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModpackUpdate builder. +func (mu *ModpackUpdate) Where(ps ...predicate.Modpack) *ModpackUpdate { + mu.mutation.Where(ps...) + return mu +} + +// SetUpdatedAt sets the "updated_at" field. +func (mu *ModpackUpdate) SetUpdatedAt(t time.Time) *ModpackUpdate { + mu.mutation.SetUpdatedAt(t) + return mu +} + +// SetName sets the "name" field. +func (mu *ModpackUpdate) SetName(s string) *ModpackUpdate { + mu.mutation.SetName(s) + return mu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableName(s *string) *ModpackUpdate { + if s != nil { + mu.SetName(*s) + } + return mu +} + +// SetShortDescription sets the "short_description" field. +func (mu *ModpackUpdate) SetShortDescription(s string) *ModpackUpdate { + mu.mutation.SetShortDescription(s) + return mu +} + +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableShortDescription(s *string) *ModpackUpdate { + if s != nil { + mu.SetShortDescription(*s) + } + return mu +} + +// SetFullDescription sets the "full_description" field. +func (mu *ModpackUpdate) SetFullDescription(s string) *ModpackUpdate { + mu.mutation.SetFullDescription(s) + return mu +} + +// SetNillableFullDescription sets the "full_description" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableFullDescription(s *string) *ModpackUpdate { + if s != nil { + mu.SetFullDescription(*s) + } + return mu +} + +// SetLogo sets the "logo" field. +func (mu *ModpackUpdate) SetLogo(s string) *ModpackUpdate { + mu.mutation.SetLogo(s) + return mu +} + +// SetNillableLogo sets the "logo" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableLogo(s *string) *ModpackUpdate { + if s != nil { + mu.SetLogo(*s) + } + return mu +} + +// ClearLogo clears the value of the "logo" field. +func (mu *ModpackUpdate) ClearLogo() *ModpackUpdate { + mu.mutation.ClearLogo() + return mu +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (mu *ModpackUpdate) SetLogoThumbhash(s string) *ModpackUpdate { + mu.mutation.SetLogoThumbhash(s) + return mu +} + +// SetNillableLogoThumbhash sets the "logo_thumbhash" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableLogoThumbhash(s *string) *ModpackUpdate { + if s != nil { + mu.SetLogoThumbhash(*s) + } + return mu +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (mu *ModpackUpdate) ClearLogoThumbhash() *ModpackUpdate { + mu.mutation.ClearLogoThumbhash() + return mu +} + +// SetCreatorID sets the "creator_id" field. +func (mu *ModpackUpdate) SetCreatorID(s string) *ModpackUpdate { + mu.mutation.SetCreatorID(s) + return mu +} + +// SetNillableCreatorID sets the "creator_id" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableCreatorID(s *string) *ModpackUpdate { + if s != nil { + mu.SetCreatorID(*s) + } + return mu +} + +// SetViews sets the "views" field. +func (mu *ModpackUpdate) SetViews(u uint) *ModpackUpdate { + mu.mutation.ResetViews() + mu.mutation.SetViews(u) + return mu +} + +// SetNillableViews sets the "views" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableViews(u *uint) *ModpackUpdate { + if u != nil { + mu.SetViews(*u) + } + return mu +} + +// AddViews adds u to the "views" field. +func (mu *ModpackUpdate) AddViews(u int) *ModpackUpdate { + mu.mutation.AddViews(u) + return mu +} + +// SetHotness sets the "hotness" field. +func (mu *ModpackUpdate) SetHotness(u uint) *ModpackUpdate { + mu.mutation.ResetHotness() + mu.mutation.SetHotness(u) + return mu +} + +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableHotness(u *uint) *ModpackUpdate { + if u != nil { + mu.SetHotness(*u) + } + return mu +} + +// AddHotness adds u to the "hotness" field. +func (mu *ModpackUpdate) AddHotness(u int) *ModpackUpdate { + mu.mutation.AddHotness(u) + return mu +} + +// SetInstalls sets the "installs" field. +func (mu *ModpackUpdate) SetInstalls(u uint) *ModpackUpdate { + mu.mutation.ResetInstalls() + mu.mutation.SetInstalls(u) + return mu +} + +// SetNillableInstalls sets the "installs" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableInstalls(u *uint) *ModpackUpdate { + if u != nil { + mu.SetInstalls(*u) + } + return mu +} + +// AddInstalls adds u to the "installs" field. +func (mu *ModpackUpdate) AddInstalls(u int) *ModpackUpdate { + mu.mutation.AddInstalls(u) + return mu +} + +// SetPopularity sets the "popularity" field. +func (mu *ModpackUpdate) SetPopularity(u uint) *ModpackUpdate { + mu.mutation.ResetPopularity() + mu.mutation.SetPopularity(u) + return mu +} + +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillablePopularity(u *uint) *ModpackUpdate { + if u != nil { + mu.SetPopularity(*u) + } + return mu +} + +// AddPopularity adds u to the "popularity" field. +func (mu *ModpackUpdate) AddPopularity(u int) *ModpackUpdate { + mu.mutation.AddPopularity(u) + return mu +} + +// SetHidden sets the "hidden" field. +func (mu *ModpackUpdate) SetHidden(b bool) *ModpackUpdate { + mu.mutation.SetHidden(b) + return mu +} + +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (mu *ModpackUpdate) SetNillableHidden(b *bool) *ModpackUpdate { + if b != nil { + mu.SetHidden(*b) + } + return mu +} + +// AddChildIDs adds the "children" edge to the Modpack entity by IDs. +func (mu *ModpackUpdate) AddChildIDs(ids ...string) *ModpackUpdate { + mu.mutation.AddChildIDs(ids...) + return mu +} + +// AddChildren adds the "children" edges to the Modpack entity. +func (mu *ModpackUpdate) AddChildren(m ...*Modpack) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.AddChildIDs(ids...) +} + +// AddTargetIDs adds the "targets" edge to the ModpackTarget entity by IDs. +func (mu *ModpackUpdate) AddTargetIDs(ids ...string) *ModpackUpdate { + mu.mutation.AddTargetIDs(ids...) + return mu +} + +// AddTargets adds the "targets" edges to the ModpackTarget entity. +func (mu *ModpackUpdate) AddTargets(m ...*ModpackTarget) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.AddTargetIDs(ids...) +} + +// AddReleaseIDs adds the "releases" edge to the ModpackRelease entity by IDs. +func (mu *ModpackUpdate) AddReleaseIDs(ids ...string) *ModpackUpdate { + mu.mutation.AddReleaseIDs(ids...) + return mu +} + +// AddReleases adds the "releases" edges to the ModpackRelease entity. +func (mu *ModpackUpdate) AddReleases(m ...*ModpackRelease) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.AddReleaseIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (mu *ModpackUpdate) AddModIDs(ids ...string) *ModpackUpdate { + mu.mutation.AddModIDs(ids...) + return mu +} + +// AddMods adds the "mods" edges to the Mod entity. +func (mu *ModpackUpdate) AddMods(m ...*Mod) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.AddModIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (mu *ModpackUpdate) AddTagIDs(ids ...string) *ModpackUpdate { + mu.mutation.AddTagIDs(ids...) + return mu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (mu *ModpackUpdate) AddTags(t ...*Tag) *ModpackUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mu.AddTagIDs(ids...) +} + +// Mutation returns the ModpackMutation object of the builder. +func (mu *ModpackUpdate) Mutation() *ModpackMutation { + return mu.mutation +} + +// ClearChildren clears all "children" edges to the Modpack entity. +func (mu *ModpackUpdate) ClearChildren() *ModpackUpdate { + mu.mutation.ClearChildren() + return mu +} + +// RemoveChildIDs removes the "children" edge to Modpack entities by IDs. +func (mu *ModpackUpdate) RemoveChildIDs(ids ...string) *ModpackUpdate { + mu.mutation.RemoveChildIDs(ids...) + return mu +} + +// RemoveChildren removes "children" edges to Modpack entities. +func (mu *ModpackUpdate) RemoveChildren(m ...*Modpack) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.RemoveChildIDs(ids...) +} + +// ClearTargets clears all "targets" edges to the ModpackTarget entity. +func (mu *ModpackUpdate) ClearTargets() *ModpackUpdate { + mu.mutation.ClearTargets() + return mu +} + +// RemoveTargetIDs removes the "targets" edge to ModpackTarget entities by IDs. +func (mu *ModpackUpdate) RemoveTargetIDs(ids ...string) *ModpackUpdate { + mu.mutation.RemoveTargetIDs(ids...) + return mu +} + +// RemoveTargets removes "targets" edges to ModpackTarget entities. +func (mu *ModpackUpdate) RemoveTargets(m ...*ModpackTarget) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.RemoveTargetIDs(ids...) +} + +// ClearReleases clears all "releases" edges to the ModpackRelease entity. +func (mu *ModpackUpdate) ClearReleases() *ModpackUpdate { + mu.mutation.ClearReleases() + return mu +} + +// RemoveReleaseIDs removes the "releases" edge to ModpackRelease entities by IDs. +func (mu *ModpackUpdate) RemoveReleaseIDs(ids ...string) *ModpackUpdate { + mu.mutation.RemoveReleaseIDs(ids...) + return mu +} + +// RemoveReleases removes "releases" edges to ModpackRelease entities. +func (mu *ModpackUpdate) RemoveReleases(m ...*ModpackRelease) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.RemoveReleaseIDs(ids...) +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (mu *ModpackUpdate) ClearMods() *ModpackUpdate { + mu.mutation.ClearMods() + return mu +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (mu *ModpackUpdate) RemoveModIDs(ids ...string) *ModpackUpdate { + mu.mutation.RemoveModIDs(ids...) + return mu +} + +// RemoveMods removes "mods" edges to Mod entities. +func (mu *ModpackUpdate) RemoveMods(m ...*Mod) *ModpackUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return mu.RemoveModIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (mu *ModpackUpdate) ClearTags() *ModpackUpdate { + mu.mutation.ClearTags() + return mu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (mu *ModpackUpdate) RemoveTagIDs(ids ...string) *ModpackUpdate { + mu.mutation.RemoveTagIDs(ids...) + return mu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (mu *ModpackUpdate) RemoveTags(t ...*Tag) *ModpackUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mu.RemoveTagIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mu *ModpackUpdate) Save(ctx context.Context) (int, error) { + mu.defaults() + return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mu *ModpackUpdate) SaveX(ctx context.Context) int { + affected, err := mu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mu *ModpackUpdate) Exec(ctx context.Context) error { + _, err := mu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mu *ModpackUpdate) ExecX(ctx context.Context) { + if err := mu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mu *ModpackUpdate) defaults() { + if _, ok := mu.mutation.UpdatedAt(); !ok { + v := modpack.UpdateDefaultUpdatedAt() + mu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mu *ModpackUpdate) check() error { + if v, ok := mu.mutation.ShortDescription(); ok { + if err := modpack.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Modpack.short_description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mu *ModpackUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackUpdate { + mu.modifiers = append(mu.modifiers, modifiers...) + return mu +} + +func (mu *ModpackUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modpack.Table, modpack.Columns, sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString)) + if ps := mu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mu.mutation.UpdatedAt(); ok { + _spec.SetField(modpack.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := mu.mutation.Name(); ok { + _spec.SetField(modpack.FieldName, field.TypeString, value) + } + if value, ok := mu.mutation.ShortDescription(); ok { + _spec.SetField(modpack.FieldShortDescription, field.TypeString, value) + } + if value, ok := mu.mutation.FullDescription(); ok { + _spec.SetField(modpack.FieldFullDescription, field.TypeString, value) + } + if value, ok := mu.mutation.Logo(); ok { + _spec.SetField(modpack.FieldLogo, field.TypeString, value) + } + if mu.mutation.LogoCleared() { + _spec.ClearField(modpack.FieldLogo, field.TypeString) + } + if value, ok := mu.mutation.LogoThumbhash(); ok { + _spec.SetField(modpack.FieldLogoThumbhash, field.TypeString, value) + } + if mu.mutation.LogoThumbhashCleared() { + _spec.ClearField(modpack.FieldLogoThumbhash, field.TypeString) + } + if value, ok := mu.mutation.CreatorID(); ok { + _spec.SetField(modpack.FieldCreatorID, field.TypeString, value) + } + if value, ok := mu.mutation.Views(); ok { + _spec.SetField(modpack.FieldViews, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedViews(); ok { + _spec.AddField(modpack.FieldViews, field.TypeUint, value) + } + if value, ok := mu.mutation.Hotness(); ok { + _spec.SetField(modpack.FieldHotness, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedHotness(); ok { + _spec.AddField(modpack.FieldHotness, field.TypeUint, value) + } + if value, ok := mu.mutation.Installs(); ok { + _spec.SetField(modpack.FieldInstalls, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedInstalls(); ok { + _spec.AddField(modpack.FieldInstalls, field.TypeUint, value) + } + if value, ok := mu.mutation.Popularity(); ok { + _spec.SetField(modpack.FieldPopularity, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedPopularity(); ok { + _spec.AddField(modpack.FieldPopularity, field.TypeUint, value) + } + if value, ok := mu.mutation.Hidden(); ok { + _spec.SetField(modpack.FieldHidden, field.TypeBool, value) + } + if mu.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !mu.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !mu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mu.mutation.ReleasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedReleasesIDs(); len(nodes) > 0 && !mu.mutation.ReleasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.ReleasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedModsIDs(); len(nodes) > 0 && !mu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedTagsIDs(); len(nodes) > 0 && !mu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpack.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mu.mutation.done = true + return n, nil +} + +// ModpackUpdateOne is the builder for updating a single Modpack entity. +type ModpackUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModpackMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (muo *ModpackUpdateOne) SetUpdatedAt(t time.Time) *ModpackUpdateOne { + muo.mutation.SetUpdatedAt(t) + return muo +} + +// SetName sets the "name" field. +func (muo *ModpackUpdateOne) SetName(s string) *ModpackUpdateOne { + muo.mutation.SetName(s) + return muo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableName(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetName(*s) + } + return muo +} + +// SetShortDescription sets the "short_description" field. +func (muo *ModpackUpdateOne) SetShortDescription(s string) *ModpackUpdateOne { + muo.mutation.SetShortDescription(s) + return muo +} + +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableShortDescription(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetShortDescription(*s) + } + return muo +} + +// SetFullDescription sets the "full_description" field. +func (muo *ModpackUpdateOne) SetFullDescription(s string) *ModpackUpdateOne { + muo.mutation.SetFullDescription(s) + return muo +} + +// SetNillableFullDescription sets the "full_description" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableFullDescription(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetFullDescription(*s) + } + return muo +} + +// SetLogo sets the "logo" field. +func (muo *ModpackUpdateOne) SetLogo(s string) *ModpackUpdateOne { + muo.mutation.SetLogo(s) + return muo +} + +// SetNillableLogo sets the "logo" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableLogo(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetLogo(*s) + } + return muo +} + +// ClearLogo clears the value of the "logo" field. +func (muo *ModpackUpdateOne) ClearLogo() *ModpackUpdateOne { + muo.mutation.ClearLogo() + return muo +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (muo *ModpackUpdateOne) SetLogoThumbhash(s string) *ModpackUpdateOne { + muo.mutation.SetLogoThumbhash(s) + return muo +} + +// SetNillableLogoThumbhash sets the "logo_thumbhash" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableLogoThumbhash(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetLogoThumbhash(*s) + } + return muo +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (muo *ModpackUpdateOne) ClearLogoThumbhash() *ModpackUpdateOne { + muo.mutation.ClearLogoThumbhash() + return muo +} + +// SetCreatorID sets the "creator_id" field. +func (muo *ModpackUpdateOne) SetCreatorID(s string) *ModpackUpdateOne { + muo.mutation.SetCreatorID(s) + return muo +} + +// SetNillableCreatorID sets the "creator_id" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableCreatorID(s *string) *ModpackUpdateOne { + if s != nil { + muo.SetCreatorID(*s) + } + return muo +} + +// SetViews sets the "views" field. +func (muo *ModpackUpdateOne) SetViews(u uint) *ModpackUpdateOne { + muo.mutation.ResetViews() + muo.mutation.SetViews(u) + return muo +} + +// SetNillableViews sets the "views" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableViews(u *uint) *ModpackUpdateOne { + if u != nil { + muo.SetViews(*u) + } + return muo +} + +// AddViews adds u to the "views" field. +func (muo *ModpackUpdateOne) AddViews(u int) *ModpackUpdateOne { + muo.mutation.AddViews(u) + return muo +} + +// SetHotness sets the "hotness" field. +func (muo *ModpackUpdateOne) SetHotness(u uint) *ModpackUpdateOne { + muo.mutation.ResetHotness() + muo.mutation.SetHotness(u) + return muo +} + +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableHotness(u *uint) *ModpackUpdateOne { + if u != nil { + muo.SetHotness(*u) + } + return muo +} + +// AddHotness adds u to the "hotness" field. +func (muo *ModpackUpdateOne) AddHotness(u int) *ModpackUpdateOne { + muo.mutation.AddHotness(u) + return muo +} + +// SetInstalls sets the "installs" field. +func (muo *ModpackUpdateOne) SetInstalls(u uint) *ModpackUpdateOne { + muo.mutation.ResetInstalls() + muo.mutation.SetInstalls(u) + return muo +} + +// SetNillableInstalls sets the "installs" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableInstalls(u *uint) *ModpackUpdateOne { + if u != nil { + muo.SetInstalls(*u) + } + return muo +} + +// AddInstalls adds u to the "installs" field. +func (muo *ModpackUpdateOne) AddInstalls(u int) *ModpackUpdateOne { + muo.mutation.AddInstalls(u) + return muo +} + +// SetPopularity sets the "popularity" field. +func (muo *ModpackUpdateOne) SetPopularity(u uint) *ModpackUpdateOne { + muo.mutation.ResetPopularity() + muo.mutation.SetPopularity(u) + return muo +} + +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillablePopularity(u *uint) *ModpackUpdateOne { + if u != nil { + muo.SetPopularity(*u) + } + return muo +} + +// AddPopularity adds u to the "popularity" field. +func (muo *ModpackUpdateOne) AddPopularity(u int) *ModpackUpdateOne { + muo.mutation.AddPopularity(u) + return muo +} + +// SetHidden sets the "hidden" field. +func (muo *ModpackUpdateOne) SetHidden(b bool) *ModpackUpdateOne { + muo.mutation.SetHidden(b) + return muo +} + +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (muo *ModpackUpdateOne) SetNillableHidden(b *bool) *ModpackUpdateOne { + if b != nil { + muo.SetHidden(*b) + } + return muo +} + +// AddChildIDs adds the "children" edge to the Modpack entity by IDs. +func (muo *ModpackUpdateOne) AddChildIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.AddChildIDs(ids...) + return muo +} + +// AddChildren adds the "children" edges to the Modpack entity. +func (muo *ModpackUpdateOne) AddChildren(m ...*Modpack) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.AddChildIDs(ids...) +} + +// AddTargetIDs adds the "targets" edge to the ModpackTarget entity by IDs. +func (muo *ModpackUpdateOne) AddTargetIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.AddTargetIDs(ids...) + return muo +} + +// AddTargets adds the "targets" edges to the ModpackTarget entity. +func (muo *ModpackUpdateOne) AddTargets(m ...*ModpackTarget) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.AddTargetIDs(ids...) +} + +// AddReleaseIDs adds the "releases" edge to the ModpackRelease entity by IDs. +func (muo *ModpackUpdateOne) AddReleaseIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.AddReleaseIDs(ids...) + return muo +} + +// AddReleases adds the "releases" edges to the ModpackRelease entity. +func (muo *ModpackUpdateOne) AddReleases(m ...*ModpackRelease) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.AddReleaseIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (muo *ModpackUpdateOne) AddModIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.AddModIDs(ids...) + return muo +} + +// AddMods adds the "mods" edges to the Mod entity. +func (muo *ModpackUpdateOne) AddMods(m ...*Mod) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.AddModIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (muo *ModpackUpdateOne) AddTagIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.AddTagIDs(ids...) + return muo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (muo *ModpackUpdateOne) AddTags(t ...*Tag) *ModpackUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return muo.AddTagIDs(ids...) +} + +// Mutation returns the ModpackMutation object of the builder. +func (muo *ModpackUpdateOne) Mutation() *ModpackMutation { + return muo.mutation +} + +// ClearChildren clears all "children" edges to the Modpack entity. +func (muo *ModpackUpdateOne) ClearChildren() *ModpackUpdateOne { + muo.mutation.ClearChildren() + return muo +} + +// RemoveChildIDs removes the "children" edge to Modpack entities by IDs. +func (muo *ModpackUpdateOne) RemoveChildIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.RemoveChildIDs(ids...) + return muo +} + +// RemoveChildren removes "children" edges to Modpack entities. +func (muo *ModpackUpdateOne) RemoveChildren(m ...*Modpack) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.RemoveChildIDs(ids...) +} + +// ClearTargets clears all "targets" edges to the ModpackTarget entity. +func (muo *ModpackUpdateOne) ClearTargets() *ModpackUpdateOne { + muo.mutation.ClearTargets() + return muo +} + +// RemoveTargetIDs removes the "targets" edge to ModpackTarget entities by IDs. +func (muo *ModpackUpdateOne) RemoveTargetIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.RemoveTargetIDs(ids...) + return muo +} + +// RemoveTargets removes "targets" edges to ModpackTarget entities. +func (muo *ModpackUpdateOne) RemoveTargets(m ...*ModpackTarget) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.RemoveTargetIDs(ids...) +} + +// ClearReleases clears all "releases" edges to the ModpackRelease entity. +func (muo *ModpackUpdateOne) ClearReleases() *ModpackUpdateOne { + muo.mutation.ClearReleases() + return muo +} + +// RemoveReleaseIDs removes the "releases" edge to ModpackRelease entities by IDs. +func (muo *ModpackUpdateOne) RemoveReleaseIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.RemoveReleaseIDs(ids...) + return muo +} + +// RemoveReleases removes "releases" edges to ModpackRelease entities. +func (muo *ModpackUpdateOne) RemoveReleases(m ...*ModpackRelease) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.RemoveReleaseIDs(ids...) +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (muo *ModpackUpdateOne) ClearMods() *ModpackUpdateOne { + muo.mutation.ClearMods() + return muo +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (muo *ModpackUpdateOne) RemoveModIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.RemoveModIDs(ids...) + return muo +} + +// RemoveMods removes "mods" edges to Mod entities. +func (muo *ModpackUpdateOne) RemoveMods(m ...*Mod) *ModpackUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return muo.RemoveModIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (muo *ModpackUpdateOne) ClearTags() *ModpackUpdateOne { + muo.mutation.ClearTags() + return muo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (muo *ModpackUpdateOne) RemoveTagIDs(ids ...string) *ModpackUpdateOne { + muo.mutation.RemoveTagIDs(ids...) + return muo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (muo *ModpackUpdateOne) RemoveTags(t ...*Tag) *ModpackUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return muo.RemoveTagIDs(ids...) +} + +// Where appends a list predicates to the ModpackUpdate builder. +func (muo *ModpackUpdateOne) Where(ps ...predicate.Modpack) *ModpackUpdateOne { + muo.mutation.Where(ps...) + return muo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (muo *ModpackUpdateOne) Select(field string, fields ...string) *ModpackUpdateOne { + muo.fields = append([]string{field}, fields...) + return muo +} + +// Save executes the query and returns the updated Modpack entity. +func (muo *ModpackUpdateOne) Save(ctx context.Context) (*Modpack, error) { + muo.defaults() + return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (muo *ModpackUpdateOne) SaveX(ctx context.Context) *Modpack { + node, err := muo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (muo *ModpackUpdateOne) Exec(ctx context.Context) error { + _, err := muo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (muo *ModpackUpdateOne) ExecX(ctx context.Context) { + if err := muo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (muo *ModpackUpdateOne) defaults() { + if _, ok := muo.mutation.UpdatedAt(); !ok { + v := modpack.UpdateDefaultUpdatedAt() + muo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (muo *ModpackUpdateOne) check() error { + if v, ok := muo.mutation.ShortDescription(); ok { + if err := modpack.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Modpack.short_description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (muo *ModpackUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackUpdateOne { + muo.modifiers = append(muo.modifiers, modifiers...) + return muo +} + +func (muo *ModpackUpdateOne) sqlSave(ctx context.Context) (_node *Modpack, err error) { + if err := muo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modpack.Table, modpack.Columns, sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString)) + id, ok := muo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Modpack.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := muo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpack.FieldID) + for _, f := range fields { + if !modpack.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != modpack.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := muo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := muo.mutation.UpdatedAt(); ok { + _spec.SetField(modpack.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := muo.mutation.Name(); ok { + _spec.SetField(modpack.FieldName, field.TypeString, value) + } + if value, ok := muo.mutation.ShortDescription(); ok { + _spec.SetField(modpack.FieldShortDescription, field.TypeString, value) + } + if value, ok := muo.mutation.FullDescription(); ok { + _spec.SetField(modpack.FieldFullDescription, field.TypeString, value) + } + if value, ok := muo.mutation.Logo(); ok { + _spec.SetField(modpack.FieldLogo, field.TypeString, value) + } + if muo.mutation.LogoCleared() { + _spec.ClearField(modpack.FieldLogo, field.TypeString) + } + if value, ok := muo.mutation.LogoThumbhash(); ok { + _spec.SetField(modpack.FieldLogoThumbhash, field.TypeString, value) + } + if muo.mutation.LogoThumbhashCleared() { + _spec.ClearField(modpack.FieldLogoThumbhash, field.TypeString) + } + if value, ok := muo.mutation.CreatorID(); ok { + _spec.SetField(modpack.FieldCreatorID, field.TypeString, value) + } + if value, ok := muo.mutation.Views(); ok { + _spec.SetField(modpack.FieldViews, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedViews(); ok { + _spec.AddField(modpack.FieldViews, field.TypeUint, value) + } + if value, ok := muo.mutation.Hotness(); ok { + _spec.SetField(modpack.FieldHotness, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedHotness(); ok { + _spec.AddField(modpack.FieldHotness, field.TypeUint, value) + } + if value, ok := muo.mutation.Installs(); ok { + _spec.SetField(modpack.FieldInstalls, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedInstalls(); ok { + _spec.AddField(modpack.FieldInstalls, field.TypeUint, value) + } + if value, ok := muo.mutation.Popularity(); ok { + _spec.SetField(modpack.FieldPopularity, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedPopularity(); ok { + _spec.AddField(modpack.FieldPopularity, field.TypeUint, value) + } + if value, ok := muo.mutation.Hidden(); ok { + _spec.SetField(modpack.FieldHidden, field.TypeBool, value) + } + if muo.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !muo.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ChildrenTable, + Columns: []string{modpack.ChildrenColumn}, + Bidi: true, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if muo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !muo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.TargetsTable, + Columns: []string{modpack.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if muo.mutation.ReleasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedReleasesIDs(); len(nodes) > 0 && !muo.mutation.ReleasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.ReleasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: modpack.ReleasesTable, + Columns: []string{modpack.ReleasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if muo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedModsIDs(); len(nodes) > 0 && !muo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.ModsTable, + Columns: modpack.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if muo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !muo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: modpack.TagsTable, + Columns: modpack.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(muo.modifiers...) + _node = &Modpack{config: muo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpack.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + muo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/modpackmod.go b/generated/ent/modpackmod.go new file mode 100644 index 00000000..46ddcf57 --- /dev/null +++ b/generated/ent/modpackmod.go @@ -0,0 +1,162 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" +) + +// ModpackMod is the model entity for the ModpackMod schema. +type ModpackMod struct { + config `json:"-"` + // ModpackID holds the value of the "modpack_id" field. + ModpackID string `json:"modpack_id,omitempty"` + // ModID holds the value of the "mod_id" field. + ModID string `json:"mod_id,omitempty"` + // VersionConstraint holds the value of the "version_constraint" field. + VersionConstraint string `json:"version_constraint,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModpackModQuery when eager-loading is set. + Edges ModpackModEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModpackModEdges holds the relations/edges for other nodes in the graph. +type ModpackModEdges struct { + // Modpack holds the value of the modpack edge. + Modpack *Modpack `json:"modpack,omitempty"` + // Mod holds the value of the mod edge. + Mod *Mod `json:"mod,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ModpackOrErr returns the Modpack value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackModEdges) ModpackOrErr() (*Modpack, error) { + if e.Modpack != nil { + return e.Modpack, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: modpack.Label} + } + return nil, &NotLoadedError{edge: "modpack"} +} + +// ModOrErr returns the Mod value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackModEdges) ModOrErr() (*Mod, error) { + if e.Mod != nil { + return e.Mod, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: mod.Label} + } + return nil, &NotLoadedError{edge: "mod"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ModpackMod) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modpackmod.FieldModpackID, modpackmod.FieldModID, modpackmod.FieldVersionConstraint: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ModpackMod fields. +func (mm *ModpackMod) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case modpackmod.FieldModpackID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field modpack_id", values[i]) + } else if value.Valid { + mm.ModpackID = value.String + } + case modpackmod.FieldModID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mod_id", values[i]) + } else if value.Valid { + mm.ModID = value.String + } + case modpackmod.FieldVersionConstraint: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version_constraint", values[i]) + } else if value.Valid { + mm.VersionConstraint = value.String + } + default: + mm.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ModpackMod. +// This includes values selected through modifiers, order, etc. +func (mm *ModpackMod) Value(name string) (ent.Value, error) { + return mm.selectValues.Get(name) +} + +// QueryModpack queries the "modpack" edge of the ModpackMod entity. +func (mm *ModpackMod) QueryModpack() *ModpackQuery { + return NewModpackModClient(mm.config).QueryModpack(mm) +} + +// QueryMod queries the "mod" edge of the ModpackMod entity. +func (mm *ModpackMod) QueryMod() *ModQuery { + return NewModpackModClient(mm.config).QueryMod(mm) +} + +// Update returns a builder for updating this ModpackMod. +// Note that you need to call ModpackMod.Unwrap() before calling this method if this ModpackMod +// was returned from a transaction, and the transaction was committed or rolled back. +func (mm *ModpackMod) Update() *ModpackModUpdateOne { + return NewModpackModClient(mm.config).UpdateOne(mm) +} + +// Unwrap unwraps the ModpackMod entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (mm *ModpackMod) Unwrap() *ModpackMod { + _tx, ok := mm.config.driver.(*txDriver) + if !ok { + panic("ent: ModpackMod is not a transactional entity") + } + mm.config.driver = _tx.drv + return mm +} + +// String implements the fmt.Stringer. +func (mm *ModpackMod) String() string { + var builder strings.Builder + builder.WriteString("ModpackMod(") + builder.WriteString("modpack_id=") + builder.WriteString(mm.ModpackID) + builder.WriteString(", ") + builder.WriteString("mod_id=") + builder.WriteString(mm.ModID) + builder.WriteString(", ") + builder.WriteString("version_constraint=") + builder.WriteString(mm.VersionConstraint) + builder.WriteByte(')') + return builder.String() +} + +// ModpackMods is a parsable slice of ModpackMod. +type ModpackMods []*ModpackMod diff --git a/generated/ent/modpackmod/modpackmod.go b/generated/ent/modpackmod/modpackmod.go new file mode 100644 index 00000000..45c20636 --- /dev/null +++ b/generated/ent/modpackmod/modpackmod.go @@ -0,0 +1,106 @@ +// Code generated by ent, DO NOT EDIT. + +package modpackmod + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modpackmod type in the database. + Label = "modpack_mod" + // FieldModpackID holds the string denoting the modpack_id field in the database. + FieldModpackID = "modpack_id" + // FieldModID holds the string denoting the mod_id field in the database. + FieldModID = "mod_id" + // FieldVersionConstraint holds the string denoting the version_constraint field in the database. + FieldVersionConstraint = "version_constraint" + // EdgeModpack holds the string denoting the modpack edge name in mutations. + EdgeModpack = "modpack" + // EdgeMod holds the string denoting the mod edge name in mutations. + EdgeMod = "mod" + // ModpackFieldID holds the string denoting the ID field of the Modpack. + ModpackFieldID = "id" + // ModFieldID holds the string denoting the ID field of the Mod. + ModFieldID = "id" + // Table holds the table name of the modpackmod in the database. + Table = "modpack_mods" + // ModpackTable is the table that holds the modpack relation/edge. + ModpackTable = "modpack_mods" + // ModpackInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpackInverseTable = "modpacks" + // ModpackColumn is the table column denoting the modpack relation/edge. + ModpackColumn = "modpack_id" + // ModTable is the table that holds the mod relation/edge. + ModTable = "modpack_mods" + // ModInverseTable is the table name for the Mod entity. + // It exists in this package in order to avoid circular dependency with the "mod" package. + ModInverseTable = "mods" + // ModColumn is the table column denoting the mod relation/edge. + ModColumn = "mod_id" +) + +// Columns holds all SQL columns for modpackmod fields. +var Columns = []string{ + FieldModpackID, + FieldModID, + FieldVersionConstraint, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the ModpackMod queries. +type OrderOption func(*sql.Selector) + +// ByModpackID orders the results by the modpack_id field. +func ByModpackID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModpackID, opts...).ToFunc() +} + +// ByModID orders the results by the mod_id field. +func ByModID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModID, opts...).ToFunc() +} + +// ByVersionConstraint orders the results by the version_constraint field. +func ByVersionConstraint(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionConstraint, opts...).ToFunc() +} + +// ByModpackField orders the results by modpack field. +func ByModpackField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackStep(), sql.OrderByField(field, opts...)) + } +} + +// ByModField orders the results by mod field. +func ByModField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModStep(), sql.OrderByField(field, opts...)) + } +} +func newModpackStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, ModpackColumn), + sqlgraph.To(ModpackInverseTable, ModpackFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ModpackTable, ModpackColumn), + ) +} +func newModStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, ModColumn), + sqlgraph.To(ModInverseTable, ModFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ModTable, ModColumn), + ) +} diff --git a/generated/ent/modpackmod/where.go b/generated/ent/modpackmod/where.go new file mode 100644 index 00000000..390d9c39 --- /dev/null +++ b/generated/ent/modpackmod/where.go @@ -0,0 +1,280 @@ +// Code generated by ent, DO NOT EDIT. + +package modpackmod + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackID applies equality check predicate on the "modpack_id" field. It's identical to ModpackIDEQ. +func ModpackID(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldModpackID, v)) +} + +// ModID applies equality check predicate on the "mod_id" field. It's identical to ModIDEQ. +func ModID(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldModID, v)) +} + +// VersionConstraint applies equality check predicate on the "version_constraint" field. It's identical to VersionConstraintEQ. +func VersionConstraint(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldVersionConstraint, v)) +} + +// ModpackIDEQ applies the EQ predicate on the "modpack_id" field. +func ModpackIDEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldModpackID, v)) +} + +// ModpackIDNEQ applies the NEQ predicate on the "modpack_id" field. +func ModpackIDNEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNEQ(FieldModpackID, v)) +} + +// ModpackIDIn applies the In predicate on the "modpack_id" field. +func ModpackIDIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldIn(FieldModpackID, vs...)) +} + +// ModpackIDNotIn applies the NotIn predicate on the "modpack_id" field. +func ModpackIDNotIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNotIn(FieldModpackID, vs...)) +} + +// ModpackIDGT applies the GT predicate on the "modpack_id" field. +func ModpackIDGT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGT(FieldModpackID, v)) +} + +// ModpackIDGTE applies the GTE predicate on the "modpack_id" field. +func ModpackIDGTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGTE(FieldModpackID, v)) +} + +// ModpackIDLT applies the LT predicate on the "modpack_id" field. +func ModpackIDLT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLT(FieldModpackID, v)) +} + +// ModpackIDLTE applies the LTE predicate on the "modpack_id" field. +func ModpackIDLTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLTE(FieldModpackID, v)) +} + +// ModpackIDContains applies the Contains predicate on the "modpack_id" field. +func ModpackIDContains(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContains(FieldModpackID, v)) +} + +// ModpackIDHasPrefix applies the HasPrefix predicate on the "modpack_id" field. +func ModpackIDHasPrefix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasPrefix(FieldModpackID, v)) +} + +// ModpackIDHasSuffix applies the HasSuffix predicate on the "modpack_id" field. +func ModpackIDHasSuffix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasSuffix(FieldModpackID, v)) +} + +// ModpackIDEqualFold applies the EqualFold predicate on the "modpack_id" field. +func ModpackIDEqualFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEqualFold(FieldModpackID, v)) +} + +// ModpackIDContainsFold applies the ContainsFold predicate on the "modpack_id" field. +func ModpackIDContainsFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContainsFold(FieldModpackID, v)) +} + +// ModIDEQ applies the EQ predicate on the "mod_id" field. +func ModIDEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldModID, v)) +} + +// ModIDNEQ applies the NEQ predicate on the "mod_id" field. +func ModIDNEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNEQ(FieldModID, v)) +} + +// ModIDIn applies the In predicate on the "mod_id" field. +func ModIDIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldIn(FieldModID, vs...)) +} + +// ModIDNotIn applies the NotIn predicate on the "mod_id" field. +func ModIDNotIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNotIn(FieldModID, vs...)) +} + +// ModIDGT applies the GT predicate on the "mod_id" field. +func ModIDGT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGT(FieldModID, v)) +} + +// ModIDGTE applies the GTE predicate on the "mod_id" field. +func ModIDGTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGTE(FieldModID, v)) +} + +// ModIDLT applies the LT predicate on the "mod_id" field. +func ModIDLT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLT(FieldModID, v)) +} + +// ModIDLTE applies the LTE predicate on the "mod_id" field. +func ModIDLTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLTE(FieldModID, v)) +} + +// ModIDContains applies the Contains predicate on the "mod_id" field. +func ModIDContains(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContains(FieldModID, v)) +} + +// ModIDHasPrefix applies the HasPrefix predicate on the "mod_id" field. +func ModIDHasPrefix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasPrefix(FieldModID, v)) +} + +// ModIDHasSuffix applies the HasSuffix predicate on the "mod_id" field. +func ModIDHasSuffix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasSuffix(FieldModID, v)) +} + +// ModIDEqualFold applies the EqualFold predicate on the "mod_id" field. +func ModIDEqualFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEqualFold(FieldModID, v)) +} + +// ModIDContainsFold applies the ContainsFold predicate on the "mod_id" field. +func ModIDContainsFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContainsFold(FieldModID, v)) +} + +// VersionConstraintEQ applies the EQ predicate on the "version_constraint" field. +func VersionConstraintEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEQ(FieldVersionConstraint, v)) +} + +// VersionConstraintNEQ applies the NEQ predicate on the "version_constraint" field. +func VersionConstraintNEQ(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNEQ(FieldVersionConstraint, v)) +} + +// VersionConstraintIn applies the In predicate on the "version_constraint" field. +func VersionConstraintIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldIn(FieldVersionConstraint, vs...)) +} + +// VersionConstraintNotIn applies the NotIn predicate on the "version_constraint" field. +func VersionConstraintNotIn(vs ...string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldNotIn(FieldVersionConstraint, vs...)) +} + +// VersionConstraintGT applies the GT predicate on the "version_constraint" field. +func VersionConstraintGT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGT(FieldVersionConstraint, v)) +} + +// VersionConstraintGTE applies the GTE predicate on the "version_constraint" field. +func VersionConstraintGTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldGTE(FieldVersionConstraint, v)) +} + +// VersionConstraintLT applies the LT predicate on the "version_constraint" field. +func VersionConstraintLT(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLT(FieldVersionConstraint, v)) +} + +// VersionConstraintLTE applies the LTE predicate on the "version_constraint" field. +func VersionConstraintLTE(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldLTE(FieldVersionConstraint, v)) +} + +// VersionConstraintContains applies the Contains predicate on the "version_constraint" field. +func VersionConstraintContains(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContains(FieldVersionConstraint, v)) +} + +// VersionConstraintHasPrefix applies the HasPrefix predicate on the "version_constraint" field. +func VersionConstraintHasPrefix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasPrefix(FieldVersionConstraint, v)) +} + +// VersionConstraintHasSuffix applies the HasSuffix predicate on the "version_constraint" field. +func VersionConstraintHasSuffix(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldHasSuffix(FieldVersionConstraint, v)) +} + +// VersionConstraintEqualFold applies the EqualFold predicate on the "version_constraint" field. +func VersionConstraintEqualFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldEqualFold(FieldVersionConstraint, v)) +} + +// VersionConstraintContainsFold applies the ContainsFold predicate on the "version_constraint" field. +func VersionConstraintContainsFold(v string) predicate.ModpackMod { + return predicate.ModpackMod(sql.FieldContainsFold(FieldVersionConstraint, v)) +} + +// HasModpack applies the HasEdge predicate on the "modpack" edge. +func HasModpack() predicate.ModpackMod { + return predicate.ModpackMod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, ModpackColumn), + sqlgraph.Edge(sqlgraph.M2O, false, ModpackTable, ModpackColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackWith applies the HasEdge predicate on the "modpack" edge with a given conditions (other predicates). +func HasModpackWith(preds ...predicate.Modpack) predicate.ModpackMod { + return predicate.ModpackMod(func(s *sql.Selector) { + step := newModpackStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasMod applies the HasEdge predicate on the "mod" edge. +func HasMod() predicate.ModpackMod { + return predicate.ModpackMod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, ModColumn), + sqlgraph.Edge(sqlgraph.M2O, false, ModTable, ModColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModWith applies the HasEdge predicate on the "mod" edge with a given conditions (other predicates). +func HasModWith(preds ...predicate.Mod) predicate.ModpackMod { + return predicate.ModpackMod(func(s *sql.Selector) { + step := newModStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ModpackMod) predicate.ModpackMod { + return predicate.ModpackMod(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ModpackMod) predicate.ModpackMod { + return predicate.ModpackMod(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ModpackMod) predicate.ModpackMod { + return predicate.ModpackMod(sql.NotPredicates(p)) +} diff --git a/generated/ent/modpackmod_create.go b/generated/ent/modpackmod_create.go new file mode 100644 index 00000000..b539a3be --- /dev/null +++ b/generated/ent/modpackmod_create.go @@ -0,0 +1,577 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" +) + +// ModpackModCreate is the builder for creating a ModpackMod entity. +type ModpackModCreate struct { + config + mutation *ModpackModMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetModpackID sets the "modpack_id" field. +func (mmc *ModpackModCreate) SetModpackID(s string) *ModpackModCreate { + mmc.mutation.SetModpackID(s) + return mmc +} + +// SetModID sets the "mod_id" field. +func (mmc *ModpackModCreate) SetModID(s string) *ModpackModCreate { + mmc.mutation.SetModID(s) + return mmc +} + +// SetVersionConstraint sets the "version_constraint" field. +func (mmc *ModpackModCreate) SetVersionConstraint(s string) *ModpackModCreate { + mmc.mutation.SetVersionConstraint(s) + return mmc +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mmc *ModpackModCreate) SetModpack(m *Modpack) *ModpackModCreate { + return mmc.SetModpackID(m.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mmc *ModpackModCreate) SetMod(m *Mod) *ModpackModCreate { + return mmc.SetModID(m.ID) +} + +// Mutation returns the ModpackModMutation object of the builder. +func (mmc *ModpackModCreate) Mutation() *ModpackModMutation { + return mmc.mutation +} + +// Save creates the ModpackMod in the database. +func (mmc *ModpackModCreate) Save(ctx context.Context) (*ModpackMod, error) { + return withHooks(ctx, mmc.sqlSave, mmc.mutation, mmc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mmc *ModpackModCreate) SaveX(ctx context.Context) *ModpackMod { + v, err := mmc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mmc *ModpackModCreate) Exec(ctx context.Context) error { + _, err := mmc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmc *ModpackModCreate) ExecX(ctx context.Context) { + if err := mmc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mmc *ModpackModCreate) check() error { + if _, ok := mmc.mutation.ModpackID(); !ok { + return &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing required field "ModpackMod.modpack_id"`)} + } + if _, ok := mmc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod_id", err: errors.New(`ent: missing required field "ModpackMod.mod_id"`)} + } + if _, ok := mmc.mutation.VersionConstraint(); !ok { + return &ValidationError{Name: "version_constraint", err: errors.New(`ent: missing required field "ModpackMod.version_constraint"`)} + } + if len(mmc.mutation.ModpackIDs()) == 0 { + return &ValidationError{Name: "modpack", err: errors.New(`ent: missing required edge "ModpackMod.modpack"`)} + } + if len(mmc.mutation.ModIDs()) == 0 { + return &ValidationError{Name: "mod", err: errors.New(`ent: missing required edge "ModpackMod.mod"`)} + } + return nil +} + +func (mmc *ModpackModCreate) sqlSave(ctx context.Context) (*ModpackMod, error) { + if err := mmc.check(); err != nil { + return nil, err + } + _node, _spec := mmc.createSpec() + if err := sqlgraph.CreateNode(ctx, mmc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} + +func (mmc *ModpackModCreate) createSpec() (*ModpackMod, *sqlgraph.CreateSpec) { + var ( + _node = &ModpackMod{config: mmc.config} + _spec = sqlgraph.NewCreateSpec(modpackmod.Table, nil) + ) + _spec.OnConflict = mmc.conflict + if value, ok := mmc.mutation.VersionConstraint(); ok { + _spec.SetField(modpackmod.FieldVersionConstraint, field.TypeString, value) + _node.VersionConstraint = value + } + if nodes := mmc.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModpackTable, + Columns: []string{modpackmod.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ModpackID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mmc.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModTable, + Columns: []string{modpackmod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ModID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackMod.Create(). +// SetModpackID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackModUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mmc *ModpackModCreate) OnConflict(opts ...sql.ConflictOption) *ModpackModUpsertOne { + mmc.conflict = opts + return &ModpackModUpsertOne{ + create: mmc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mmc *ModpackModCreate) OnConflictColumns(columns ...string) *ModpackModUpsertOne { + mmc.conflict = append(mmc.conflict, sql.ConflictColumns(columns...)) + return &ModpackModUpsertOne{ + create: mmc, + } +} + +type ( + // ModpackModUpsertOne is the builder for "upsert"-ing + // one ModpackMod node. + ModpackModUpsertOne struct { + create *ModpackModCreate + } + + // ModpackModUpsert is the "OnConflict" setter. + ModpackModUpsert struct { + *sql.UpdateSet + } +) + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackModUpsert) SetModpackID(v string) *ModpackModUpsert { + u.Set(modpackmod.FieldModpackID, v) + return u +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackModUpsert) UpdateModpackID() *ModpackModUpsert { + u.SetExcluded(modpackmod.FieldModpackID) + return u +} + +// SetModID sets the "mod_id" field. +func (u *ModpackModUpsert) SetModID(v string) *ModpackModUpsert { + u.Set(modpackmod.FieldModID, v) + return u +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModpackModUpsert) UpdateModID() *ModpackModUpsert { + u.SetExcluded(modpackmod.FieldModID) + return u +} + +// SetVersionConstraint sets the "version_constraint" field. +func (u *ModpackModUpsert) SetVersionConstraint(v string) *ModpackModUpsert { + u.Set(modpackmod.FieldVersionConstraint, v) + return u +} + +// UpdateVersionConstraint sets the "version_constraint" field to the value that was provided on create. +func (u *ModpackModUpsert) UpdateVersionConstraint() *ModpackModUpsert { + u.SetExcluded(modpackmod.FieldVersionConstraint) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModpackModUpsertOne) UpdateNewValues() *ModpackModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackModUpsertOne) Ignore() *ModpackModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackModUpsertOne) DoNothing() *ModpackModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackModCreate.OnConflict +// documentation for more info. +func (u *ModpackModUpsertOne) Update(set func(*ModpackModUpsert)) *ModpackModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackModUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackModUpsertOne) SetModpackID(v string) *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackModUpsertOne) UpdateModpackID() *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateModpackID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *ModpackModUpsertOne) SetModID(v string) *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModpackModUpsertOne) UpdateModID() *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateModID() + }) +} + +// SetVersionConstraint sets the "version_constraint" field. +func (u *ModpackModUpsertOne) SetVersionConstraint(v string) *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.SetVersionConstraint(v) + }) +} + +// UpdateVersionConstraint sets the "version_constraint" field to the value that was provided on create. +func (u *ModpackModUpsertOne) UpdateVersionConstraint() *ModpackModUpsertOne { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateVersionConstraint() + }) +} + +// Exec executes the query. +func (u *ModpackModUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackModCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackModUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// ModpackModCreateBulk is the builder for creating many ModpackMod entities in bulk. +type ModpackModCreateBulk struct { + config + err error + builders []*ModpackModCreate + conflict []sql.ConflictOption +} + +// Save creates the ModpackMod entities in the database. +func (mmcb *ModpackModCreateBulk) Save(ctx context.Context) ([]*ModpackMod, error) { + if mmcb.err != nil { + return nil, mmcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mmcb.builders)) + nodes := make([]*ModpackMod, len(mmcb.builders)) + mutators := make([]Mutator, len(mmcb.builders)) + for i := range mmcb.builders { + func(i int, root context.Context) { + builder := mmcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ModpackModMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mmcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = mmcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mmcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mmcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mmcb *ModpackModCreateBulk) SaveX(ctx context.Context) []*ModpackMod { + v, err := mmcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mmcb *ModpackModCreateBulk) Exec(ctx context.Context) error { + _, err := mmcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmcb *ModpackModCreateBulk) ExecX(ctx context.Context) { + if err := mmcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackMod.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackModUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mmcb *ModpackModCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModpackModUpsertBulk { + mmcb.conflict = opts + return &ModpackModUpsertBulk{ + create: mmcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mmcb *ModpackModCreateBulk) OnConflictColumns(columns ...string) *ModpackModUpsertBulk { + mmcb.conflict = append(mmcb.conflict, sql.ConflictColumns(columns...)) + return &ModpackModUpsertBulk{ + create: mmcb, + } +} + +// ModpackModUpsertBulk is the builder for "upsert"-ing +// a bulk of ModpackMod nodes. +type ModpackModUpsertBulk struct { + create *ModpackModCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModpackModUpsertBulk) UpdateNewValues() *ModpackModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackMod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackModUpsertBulk) Ignore() *ModpackModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackModUpsertBulk) DoNothing() *ModpackModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackModCreateBulk.OnConflict +// documentation for more info. +func (u *ModpackModUpsertBulk) Update(set func(*ModpackModUpsert)) *ModpackModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackModUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackModUpsertBulk) SetModpackID(v string) *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackModUpsertBulk) UpdateModpackID() *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateModpackID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *ModpackModUpsertBulk) SetModID(v string) *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModpackModUpsertBulk) UpdateModID() *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateModID() + }) +} + +// SetVersionConstraint sets the "version_constraint" field. +func (u *ModpackModUpsertBulk) SetVersionConstraint(v string) *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.SetVersionConstraint(v) + }) +} + +// UpdateVersionConstraint sets the "version_constraint" field to the value that was provided on create. +func (u *ModpackModUpsertBulk) UpdateVersionConstraint() *ModpackModUpsertBulk { + return u.Update(func(s *ModpackModUpsert) { + s.UpdateVersionConstraint() + }) +} + +// Exec executes the query. +func (u *ModpackModUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ModpackModCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackModCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackModUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpackmod_delete.go b/generated/ent/modpackmod_delete.go new file mode 100644 index 00000000..1cc44925 --- /dev/null +++ b/generated/ent/modpackmod_delete.go @@ -0,0 +1,87 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackModDelete is the builder for deleting a ModpackMod entity. +type ModpackModDelete struct { + config + hooks []Hook + mutation *ModpackModMutation +} + +// Where appends a list predicates to the ModpackModDelete builder. +func (mmd *ModpackModDelete) Where(ps ...predicate.ModpackMod) *ModpackModDelete { + mmd.mutation.Where(ps...) + return mmd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mmd *ModpackModDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, mmd.sqlExec, mmd.mutation, mmd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmd *ModpackModDelete) ExecX(ctx context.Context) int { + n, err := mmd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mmd *ModpackModDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modpackmod.Table, nil) + if ps := mmd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, mmd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + mmd.mutation.done = true + return affected, err +} + +// ModpackModDeleteOne is the builder for deleting a single ModpackMod entity. +type ModpackModDeleteOne struct { + mmd *ModpackModDelete +} + +// Where appends a list predicates to the ModpackModDelete builder. +func (mmdo *ModpackModDeleteOne) Where(ps ...predicate.ModpackMod) *ModpackModDeleteOne { + mmdo.mmd.mutation.Where(ps...) + return mmdo +} + +// Exec executes the deletion query. +func (mmdo *ModpackModDeleteOne) Exec(ctx context.Context) error { + n, err := mmdo.mmd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modpackmod.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmdo *ModpackModDeleteOne) ExecX(ctx context.Context) { + if err := mmdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpackmod_query.go b/generated/ent/modpackmod_query.go new file mode 100644 index 00000000..4f125c12 --- /dev/null +++ b/generated/ent/modpackmod_query.go @@ -0,0 +1,626 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackModQuery is the builder for querying ModpackMod entities. +type ModpackModQuery struct { + config + ctx *QueryContext + order []modpackmod.OrderOption + inters []Interceptor + predicates []predicate.ModpackMod + withModpack *ModpackQuery + withMod *ModQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ModpackModQuery builder. +func (mmq *ModpackModQuery) Where(ps ...predicate.ModpackMod) *ModpackModQuery { + mmq.predicates = append(mmq.predicates, ps...) + return mmq +} + +// Limit the number of records to be returned by this query. +func (mmq *ModpackModQuery) Limit(limit int) *ModpackModQuery { + mmq.ctx.Limit = &limit + return mmq +} + +// Offset to start from. +func (mmq *ModpackModQuery) Offset(offset int) *ModpackModQuery { + mmq.ctx.Offset = &offset + return mmq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mmq *ModpackModQuery) Unique(unique bool) *ModpackModQuery { + mmq.ctx.Unique = &unique + return mmq +} + +// Order specifies how the records should be ordered. +func (mmq *ModpackModQuery) Order(o ...modpackmod.OrderOption) *ModpackModQuery { + mmq.order = append(mmq.order, o...) + return mmq +} + +// QueryModpack chains the current query on the "modpack" edge. +func (mmq *ModpackModQuery) QueryModpack() *ModpackQuery { + query := (&ModpackClient{config: mmq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mmq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mmq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpackmod.Table, modpackmod.ModpackColumn, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modpackmod.ModpackTable, modpackmod.ModpackColumn), + ) + fromU = sqlgraph.SetNeighbors(mmq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMod chains the current query on the "mod" edge. +func (mmq *ModpackModQuery) QueryMod() *ModQuery { + query := (&ModClient{config: mmq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mmq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mmq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpackmod.Table, modpackmod.ModColumn, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modpackmod.ModTable, modpackmod.ModColumn), + ) + fromU = sqlgraph.SetNeighbors(mmq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ModpackMod entity from the query. +// Returns a *NotFoundError when no ModpackMod was found. +func (mmq *ModpackModQuery) First(ctx context.Context) (*ModpackMod, error) { + nodes, err := mmq.Limit(1).All(setContextOp(ctx, mmq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modpackmod.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mmq *ModpackModQuery) FirstX(ctx context.Context) *ModpackMod { + node, err := mmq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single ModpackMod entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ModpackMod entity is found. +// Returns a *NotFoundError when no ModpackMod entities are found. +func (mmq *ModpackModQuery) Only(ctx context.Context) (*ModpackMod, error) { + nodes, err := mmq.Limit(2).All(setContextOp(ctx, mmq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modpackmod.Label} + default: + return nil, &NotSingularError{modpackmod.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mmq *ModpackModQuery) OnlyX(ctx context.Context) *ModpackMod { + node, err := mmq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of ModpackMods. +func (mmq *ModpackModQuery) All(ctx context.Context) ([]*ModpackMod, error) { + ctx = setContextOp(ctx, mmq.ctx, ent.OpQueryAll) + if err := mmq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ModpackMod, *ModpackModQuery]() + return withInterceptors[[]*ModpackMod](ctx, mmq, qr, mmq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mmq *ModpackModQuery) AllX(ctx context.Context) []*ModpackMod { + nodes, err := mmq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (mmq *ModpackModQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mmq.ctx, ent.OpQueryCount) + if err := mmq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mmq, querierCount[*ModpackModQuery](), mmq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mmq *ModpackModQuery) CountX(ctx context.Context) int { + count, err := mmq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mmq *ModpackModQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mmq.ctx, ent.OpQueryExist) + switch _, err := mmq.First(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mmq *ModpackModQuery) ExistX(ctx context.Context) bool { + exist, err := mmq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModpackModQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mmq *ModpackModQuery) Clone() *ModpackModQuery { + if mmq == nil { + return nil + } + return &ModpackModQuery{ + config: mmq.config, + ctx: mmq.ctx.Clone(), + order: append([]modpackmod.OrderOption{}, mmq.order...), + inters: append([]Interceptor{}, mmq.inters...), + predicates: append([]predicate.ModpackMod{}, mmq.predicates...), + withModpack: mmq.withModpack.Clone(), + withMod: mmq.withMod.Clone(), + // clone intermediate query. + sql: mmq.sql.Clone(), + path: mmq.path, + modifiers: append([]func(*sql.Selector){}, mmq.modifiers...), + } +} + +// WithModpack tells the query-builder to eager-load the nodes that are connected to +// the "modpack" edge. The optional arguments are used to configure the query builder of the edge. +func (mmq *ModpackModQuery) WithModpack(opts ...func(*ModpackQuery)) *ModpackModQuery { + query := (&ModpackClient{config: mmq.config}).Query() + for _, opt := range opts { + opt(query) + } + mmq.withModpack = query + return mmq +} + +// WithMod tells the query-builder to eager-load the nodes that are connected to +// the "mod" edge. The optional arguments are used to configure the query builder of the edge. +func (mmq *ModpackModQuery) WithMod(opts ...func(*ModQuery)) *ModpackModQuery { + query := (&ModClient{config: mmq.config}).Query() + for _, opt := range opts { + opt(query) + } + mmq.withMod = query + return mmq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ModpackMod.Query(). +// GroupBy(modpackmod.FieldModpackID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mmq *ModpackModQuery) GroupBy(field string, fields ...string) *ModpackModGroupBy { + mmq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModpackModGroupBy{build: mmq} + grbuild.flds = &mmq.ctx.Fields + grbuild.label = modpackmod.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// } +// +// client.ModpackMod.Query(). +// Select(modpackmod.FieldModpackID). +// Scan(ctx, &v) +func (mmq *ModpackModQuery) Select(fields ...string) *ModpackModSelect { + mmq.ctx.Fields = append(mmq.ctx.Fields, fields...) + sbuild := &ModpackModSelect{ModpackModQuery: mmq} + sbuild.label = modpackmod.Label + sbuild.flds, sbuild.scan = &mmq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModpackModSelect configured with the given aggregations. +func (mmq *ModpackModQuery) Aggregate(fns ...AggregateFunc) *ModpackModSelect { + return mmq.Select().Aggregate(fns...) +} + +func (mmq *ModpackModQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mmq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mmq); err != nil { + return err + } + } + } + for _, f := range mmq.ctx.Fields { + if !modpackmod.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mmq.path != nil { + prev, err := mmq.path(ctx) + if err != nil { + return err + } + mmq.sql = prev + } + return nil +} + +func (mmq *ModpackModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ModpackMod, error) { + var ( + nodes = []*ModpackMod{} + _spec = mmq.querySpec() + loadedTypes = [2]bool{ + mmq.withModpack != nil, + mmq.withMod != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ModpackMod).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ModpackMod{config: mmq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mmq.modifiers) > 0 { + _spec.Modifiers = mmq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mmq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mmq.withModpack; query != nil { + if err := mmq.loadModpack(ctx, query, nodes, nil, + func(n *ModpackMod, e *Modpack) { n.Edges.Modpack = e }); err != nil { + return nil, err + } + } + if query := mmq.withMod; query != nil { + if err := mmq.loadMod(ctx, query, nodes, nil, + func(n *ModpackMod, e *Mod) { n.Edges.Mod = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mmq *ModpackModQuery) loadModpack(ctx context.Context, query *ModpackQuery, nodes []*ModpackMod, init func(*ModpackMod), assign func(*ModpackMod, *Modpack)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackMod) + for i := range nodes { + fk := nodes[i].ModpackID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(modpack.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "modpack_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (mmq *ModpackModQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*ModpackMod, init func(*ModpackMod), assign func(*ModpackMod, *Mod)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackMod) + for i := range nodes { + fk := nodes[i].ModID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(mod.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "mod_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (mmq *ModpackModQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mmq.querySpec() + if len(mmq.modifiers) > 0 { + _spec.Modifiers = mmq.modifiers + } + _spec.Unique = false + _spec.Node.Columns = nil + return sqlgraph.CountNodes(ctx, mmq.driver, _spec) +} + +func (mmq *ModpackModQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modpackmod.Table, modpackmod.Columns, nil) + _spec.From = mmq.sql + if unique := mmq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mmq.path != nil { + _spec.Unique = true + } + if fields := mmq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + for i := range fields { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + if mmq.withModpack != nil { + _spec.Node.AddColumnOnce(modpackmod.FieldModpackID) + } + if mmq.withMod != nil { + _spec.Node.AddColumnOnce(modpackmod.FieldModID) + } + } + if ps := mmq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mmq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mmq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mmq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mmq *ModpackModQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mmq.driver.Dialect()) + t1 := builder.Table(modpackmod.Table) + columns := mmq.ctx.Fields + if len(columns) == 0 { + columns = modpackmod.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mmq.sql != nil { + selector = mmq.sql + selector.Select(selector.Columns(columns...)...) + } + if mmq.ctx.Unique != nil && *mmq.ctx.Unique { + selector.Distinct() + } + for _, m := range mmq.modifiers { + m(selector) + } + for _, p := range mmq.predicates { + p(selector) + } + for _, p := range mmq.order { + p(selector) + } + if offset := mmq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mmq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mmq *ModpackModQuery) Modify(modifiers ...func(s *sql.Selector)) *ModpackModSelect { + mmq.modifiers = append(mmq.modifiers, modifiers...) + return mmq.Select() +} + +// ModpackModGroupBy is the group-by builder for ModpackMod entities. +type ModpackModGroupBy struct { + selector + build *ModpackModQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mmgb *ModpackModGroupBy) Aggregate(fns ...AggregateFunc) *ModpackModGroupBy { + mmgb.fns = append(mmgb.fns, fns...) + return mmgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mmgb *ModpackModGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mmgb.build.ctx, ent.OpQueryGroupBy) + if err := mmgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackModQuery, *ModpackModGroupBy](ctx, mmgb.build, mmgb, mmgb.build.inters, v) +} + +func (mmgb *ModpackModGroupBy) sqlScan(ctx context.Context, root *ModpackModQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mmgb.fns)) + for _, fn := range mmgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mmgb.flds)+len(mmgb.fns)) + for _, f := range *mmgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mmgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mmgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ModpackModSelect is the builder for selecting fields of ModpackMod entities. +type ModpackModSelect struct { + *ModpackModQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mms *ModpackModSelect) Aggregate(fns ...AggregateFunc) *ModpackModSelect { + mms.fns = append(mms.fns, fns...) + return mms +} + +// Scan applies the selector query and scans the result into the given value. +func (mms *ModpackModSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mms.ctx, ent.OpQuerySelect) + if err := mms.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackModQuery, *ModpackModSelect](ctx, mms.ModpackModQuery, mms, mms.inters, v) +} + +func (mms *ModpackModSelect) sqlScan(ctx context.Context, root *ModpackModQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(mms.fns)) + for _, fn := range mms.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*mms.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mms.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mms *ModpackModSelect) Modify(modifiers ...func(s *sql.Selector)) *ModpackModSelect { + mms.modifiers = append(mms.modifiers, modifiers...) + return mms +} diff --git a/generated/ent/modpackmod_update.go b/generated/ent/modpackmod_update.go new file mode 100644 index 00000000..ad769dd2 --- /dev/null +++ b/generated/ent/modpackmod_update.go @@ -0,0 +1,473 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackModUpdate is the builder for updating ModpackMod entities. +type ModpackModUpdate struct { + config + hooks []Hook + mutation *ModpackModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModpackModUpdate builder. +func (mmu *ModpackModUpdate) Where(ps ...predicate.ModpackMod) *ModpackModUpdate { + mmu.mutation.Where(ps...) + return mmu +} + +// SetModpackID sets the "modpack_id" field. +func (mmu *ModpackModUpdate) SetModpackID(s string) *ModpackModUpdate { + mmu.mutation.SetModpackID(s) + return mmu +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mmu *ModpackModUpdate) SetNillableModpackID(s *string) *ModpackModUpdate { + if s != nil { + mmu.SetModpackID(*s) + } + return mmu +} + +// SetModID sets the "mod_id" field. +func (mmu *ModpackModUpdate) SetModID(s string) *ModpackModUpdate { + mmu.mutation.SetModID(s) + return mmu +} + +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (mmu *ModpackModUpdate) SetNillableModID(s *string) *ModpackModUpdate { + if s != nil { + mmu.SetModID(*s) + } + return mmu +} + +// SetVersionConstraint sets the "version_constraint" field. +func (mmu *ModpackModUpdate) SetVersionConstraint(s string) *ModpackModUpdate { + mmu.mutation.SetVersionConstraint(s) + return mmu +} + +// SetNillableVersionConstraint sets the "version_constraint" field if the given value is not nil. +func (mmu *ModpackModUpdate) SetNillableVersionConstraint(s *string) *ModpackModUpdate { + if s != nil { + mmu.SetVersionConstraint(*s) + } + return mmu +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mmu *ModpackModUpdate) SetModpack(m *Modpack) *ModpackModUpdate { + return mmu.SetModpackID(m.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mmu *ModpackModUpdate) SetMod(m *Mod) *ModpackModUpdate { + return mmu.SetModID(m.ID) +} + +// Mutation returns the ModpackModMutation object of the builder. +func (mmu *ModpackModUpdate) Mutation() *ModpackModMutation { + return mmu.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mmu *ModpackModUpdate) ClearModpack() *ModpackModUpdate { + mmu.mutation.ClearModpack() + return mmu +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (mmu *ModpackModUpdate) ClearMod() *ModpackModUpdate { + mmu.mutation.ClearMod() + return mmu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mmu *ModpackModUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, mmu.sqlSave, mmu.mutation, mmu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mmu *ModpackModUpdate) SaveX(ctx context.Context) int { + affected, err := mmu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mmu *ModpackModUpdate) Exec(ctx context.Context) error { + _, err := mmu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmu *ModpackModUpdate) ExecX(ctx context.Context) { + if err := mmu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mmu *ModpackModUpdate) check() error { + if mmu.mutation.ModpackCleared() && len(mmu.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackMod.modpack"`) + } + if mmu.mutation.ModCleared() && len(mmu.mutation.ModIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackMod.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mmu *ModpackModUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackModUpdate { + mmu.modifiers = append(mmu.modifiers, modifiers...) + return mmu +} + +func (mmu *ModpackModUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mmu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modpackmod.Table, modpackmod.Columns, sqlgraph.NewFieldSpec(modpackmod.FieldModpackID, field.TypeString), sqlgraph.NewFieldSpec(modpackmod.FieldModID, field.TypeString)) + if ps := mmu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mmu.mutation.VersionConstraint(); ok { + _spec.SetField(modpackmod.FieldVersionConstraint, field.TypeString, value) + } + if mmu.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModpackTable, + Columns: []string{modpackmod.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mmu.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModpackTable, + Columns: []string{modpackmod.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mmu.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModTable, + Columns: []string{modpackmod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mmu.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModTable, + Columns: []string{modpackmod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mmu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, mmu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpackmod.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mmu.mutation.done = true + return n, nil +} + +// ModpackModUpdateOne is the builder for updating a single ModpackMod entity. +type ModpackModUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModpackModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetModpackID sets the "modpack_id" field. +func (mmuo *ModpackModUpdateOne) SetModpackID(s string) *ModpackModUpdateOne { + mmuo.mutation.SetModpackID(s) + return mmuo +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mmuo *ModpackModUpdateOne) SetNillableModpackID(s *string) *ModpackModUpdateOne { + if s != nil { + mmuo.SetModpackID(*s) + } + return mmuo +} + +// SetModID sets the "mod_id" field. +func (mmuo *ModpackModUpdateOne) SetModID(s string) *ModpackModUpdateOne { + mmuo.mutation.SetModID(s) + return mmuo +} + +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (mmuo *ModpackModUpdateOne) SetNillableModID(s *string) *ModpackModUpdateOne { + if s != nil { + mmuo.SetModID(*s) + } + return mmuo +} + +// SetVersionConstraint sets the "version_constraint" field. +func (mmuo *ModpackModUpdateOne) SetVersionConstraint(s string) *ModpackModUpdateOne { + mmuo.mutation.SetVersionConstraint(s) + return mmuo +} + +// SetNillableVersionConstraint sets the "version_constraint" field if the given value is not nil. +func (mmuo *ModpackModUpdateOne) SetNillableVersionConstraint(s *string) *ModpackModUpdateOne { + if s != nil { + mmuo.SetVersionConstraint(*s) + } + return mmuo +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mmuo *ModpackModUpdateOne) SetModpack(m *Modpack) *ModpackModUpdateOne { + return mmuo.SetModpackID(m.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mmuo *ModpackModUpdateOne) SetMod(m *Mod) *ModpackModUpdateOne { + return mmuo.SetModID(m.ID) +} + +// Mutation returns the ModpackModMutation object of the builder. +func (mmuo *ModpackModUpdateOne) Mutation() *ModpackModMutation { + return mmuo.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mmuo *ModpackModUpdateOne) ClearModpack() *ModpackModUpdateOne { + mmuo.mutation.ClearModpack() + return mmuo +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (mmuo *ModpackModUpdateOne) ClearMod() *ModpackModUpdateOne { + mmuo.mutation.ClearMod() + return mmuo +} + +// Where appends a list predicates to the ModpackModUpdate builder. +func (mmuo *ModpackModUpdateOne) Where(ps ...predicate.ModpackMod) *ModpackModUpdateOne { + mmuo.mutation.Where(ps...) + return mmuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mmuo *ModpackModUpdateOne) Select(field string, fields ...string) *ModpackModUpdateOne { + mmuo.fields = append([]string{field}, fields...) + return mmuo +} + +// Save executes the query and returns the updated ModpackMod entity. +func (mmuo *ModpackModUpdateOne) Save(ctx context.Context) (*ModpackMod, error) { + return withHooks(ctx, mmuo.sqlSave, mmuo.mutation, mmuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mmuo *ModpackModUpdateOne) SaveX(ctx context.Context) *ModpackMod { + node, err := mmuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mmuo *ModpackModUpdateOne) Exec(ctx context.Context) error { + _, err := mmuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mmuo *ModpackModUpdateOne) ExecX(ctx context.Context) { + if err := mmuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mmuo *ModpackModUpdateOne) check() error { + if mmuo.mutation.ModpackCleared() && len(mmuo.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackMod.modpack"`) + } + if mmuo.mutation.ModCleared() && len(mmuo.mutation.ModIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackMod.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mmuo *ModpackModUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackModUpdateOne { + mmuo.modifiers = append(mmuo.modifiers, modifiers...) + return mmuo +} + +func (mmuo *ModpackModUpdateOne) sqlSave(ctx context.Context) (_node *ModpackMod, err error) { + if err := mmuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modpackmod.Table, modpackmod.Columns, sqlgraph.NewFieldSpec(modpackmod.FieldModpackID, field.TypeString), sqlgraph.NewFieldSpec(modpackmod.FieldModID, field.TypeString)) + if id, ok := mmuo.mutation.ModpackID(); !ok { + return nil, &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing "ModpackMod.modpack_id" for update`)} + } else { + _spec.Node.CompositeID[0].Value = id + } + if id, ok := mmuo.mutation.ModID(); !ok { + return nil, &ValidationError{Name: "mod_id", err: errors.New(`ent: missing "ModpackMod.mod_id" for update`)} + } else { + _spec.Node.CompositeID[1].Value = id + } + if fields := mmuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, len(fields)) + for i, f := range fields { + if !modpackmod.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + _spec.Node.Columns[i] = f + } + } + if ps := mmuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mmuo.mutation.VersionConstraint(); ok { + _spec.SetField(modpackmod.FieldVersionConstraint, field.TypeString, value) + } + if mmuo.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModpackTable, + Columns: []string{modpackmod.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mmuo.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModpackTable, + Columns: []string{modpackmod.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mmuo.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModTable, + Columns: []string{modpackmod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mmuo.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpackmod.ModTable, + Columns: []string{modpackmod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mmuo.modifiers...) + _node = &ModpackMod{config: mmuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mmuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpackmod.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + mmuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/modpackrelease.go b/generated/ent/modpackrelease.go new file mode 100644 index 00000000..c75dde89 --- /dev/null +++ b/generated/ent/modpackrelease.go @@ -0,0 +1,188 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" +) + +// ModpackRelease is the model entity for the ModpackRelease schema. +type ModpackRelease struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // ModpackID holds the value of the "modpack_id" field. + ModpackID string `json:"modpack_id,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // Changelog holds the value of the "changelog" field. + Changelog string `json:"changelog,omitempty"` + // Lockfile holds the value of the "lockfile" field. + Lockfile string `json:"lockfile,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModpackReleaseQuery when eager-loading is set. + Edges ModpackReleaseEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModpackReleaseEdges holds the relations/edges for other nodes in the graph. +type ModpackReleaseEdges struct { + // Modpack holds the value of the modpack edge. + Modpack *Modpack `json:"modpack,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ModpackOrErr returns the Modpack value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackReleaseEdges) ModpackOrErr() (*Modpack, error) { + if e.Modpack != nil { + return e.Modpack, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: modpack.Label} + } + return nil, &NotLoadedError{edge: "modpack"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ModpackRelease) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modpackrelease.FieldID, modpackrelease.FieldModpackID, modpackrelease.FieldVersion, modpackrelease.FieldChangelog, modpackrelease.FieldLockfile: + values[i] = new(sql.NullString) + case modpackrelease.FieldCreatedAt, modpackrelease.FieldUpdatedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ModpackRelease fields. +func (mr *ModpackRelease) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case modpackrelease.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + mr.ID = value.String + } + case modpackrelease.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + mr.CreatedAt = value.Time + } + case modpackrelease.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + mr.UpdatedAt = value.Time + } + case modpackrelease.FieldModpackID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field modpack_id", values[i]) + } else if value.Valid { + mr.ModpackID = value.String + } + case modpackrelease.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + mr.Version = value.String + } + case modpackrelease.FieldChangelog: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field changelog", values[i]) + } else if value.Valid { + mr.Changelog = value.String + } + case modpackrelease.FieldLockfile: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field lockfile", values[i]) + } else if value.Valid { + mr.Lockfile = value.String + } + default: + mr.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ModpackRelease. +// This includes values selected through modifiers, order, etc. +func (mr *ModpackRelease) Value(name string) (ent.Value, error) { + return mr.selectValues.Get(name) +} + +// QueryModpack queries the "modpack" edge of the ModpackRelease entity. +func (mr *ModpackRelease) QueryModpack() *ModpackQuery { + return NewModpackReleaseClient(mr.config).QueryModpack(mr) +} + +// Update returns a builder for updating this ModpackRelease. +// Note that you need to call ModpackRelease.Unwrap() before calling this method if this ModpackRelease +// was returned from a transaction, and the transaction was committed or rolled back. +func (mr *ModpackRelease) Update() *ModpackReleaseUpdateOne { + return NewModpackReleaseClient(mr.config).UpdateOne(mr) +} + +// Unwrap unwraps the ModpackRelease entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (mr *ModpackRelease) Unwrap() *ModpackRelease { + _tx, ok := mr.config.driver.(*txDriver) + if !ok { + panic("ent: ModpackRelease is not a transactional entity") + } + mr.config.driver = _tx.drv + return mr +} + +// String implements the fmt.Stringer. +func (mr *ModpackRelease) String() string { + var builder strings.Builder + builder.WriteString("ModpackRelease(") + builder.WriteString(fmt.Sprintf("id=%v, ", mr.ID)) + builder.WriteString("created_at=") + builder.WriteString(mr.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(mr.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("modpack_id=") + builder.WriteString(mr.ModpackID) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(mr.Version) + builder.WriteString(", ") + builder.WriteString("changelog=") + builder.WriteString(mr.Changelog) + builder.WriteString(", ") + builder.WriteString("lockfile=") + builder.WriteString(mr.Lockfile) + builder.WriteByte(')') + return builder.String() +} + +// ModpackReleases is a parsable slice of ModpackRelease. +type ModpackReleases []*ModpackRelease diff --git a/generated/ent/modpackrelease/modpackrelease.go b/generated/ent/modpackrelease/modpackrelease.go new file mode 100644 index 00000000..b41caded --- /dev/null +++ b/generated/ent/modpackrelease/modpackrelease.go @@ -0,0 +1,124 @@ +// Code generated by ent, DO NOT EDIT. + +package modpackrelease + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modpackrelease type in the database. + Label = "modpack_release" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldModpackID holds the string denoting the modpack_id field in the database. + FieldModpackID = "modpack_id" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldChangelog holds the string denoting the changelog field in the database. + FieldChangelog = "changelog" + // FieldLockfile holds the string denoting the lockfile field in the database. + FieldLockfile = "lockfile" + // EdgeModpack holds the string denoting the modpack edge name in mutations. + EdgeModpack = "modpack" + // Table holds the table name of the modpackrelease in the database. + Table = "modpack_releases" + // ModpackTable is the table that holds the modpack relation/edge. + ModpackTable = "modpack_releases" + // ModpackInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpackInverseTable = "modpacks" + // ModpackColumn is the table column denoting the modpack relation/edge. + ModpackColumn = "modpack_id" +) + +// Columns holds all SQL columns for modpackrelease fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldModpackID, + FieldVersion, + FieldChangelog, + FieldLockfile, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the ModpackRelease queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByModpackID orders the results by the modpack_id field. +func ByModpackID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModpackID, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// ByChangelog orders the results by the changelog field. +func ByChangelog(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChangelog, opts...).ToFunc() +} + +// ByLockfile orders the results by the lockfile field. +func ByLockfile(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLockfile, opts...).ToFunc() +} + +// ByModpackField orders the results by modpack field. +func ByModpackField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackStep(), sql.OrderByField(field, opts...)) + } +} +func newModpackStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModpackTable, ModpackColumn), + ) +} diff --git a/generated/ent/modpackrelease/where.go b/generated/ent/modpackrelease/where.go new file mode 100644 index 00000000..19a24f82 --- /dev/null +++ b/generated/ent/modpackrelease/where.go @@ -0,0 +1,474 @@ +// Code generated by ent, DO NOT EDIT. + +package modpackrelease + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContainsFold(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// ModpackID applies equality check predicate on the "modpack_id" field. It's identical to ModpackIDEQ. +func ModpackID(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldModpackID, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldVersion, v)) +} + +// Changelog applies equality check predicate on the "changelog" field. It's identical to ChangelogEQ. +func Changelog(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldChangelog, v)) +} + +// Lockfile applies equality check predicate on the "lockfile" field. It's identical to LockfileEQ. +func Lockfile(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldLockfile, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// ModpackIDEQ applies the EQ predicate on the "modpack_id" field. +func ModpackIDEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldModpackID, v)) +} + +// ModpackIDNEQ applies the NEQ predicate on the "modpack_id" field. +func ModpackIDNEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldModpackID, v)) +} + +// ModpackIDIn applies the In predicate on the "modpack_id" field. +func ModpackIDIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldModpackID, vs...)) +} + +// ModpackIDNotIn applies the NotIn predicate on the "modpack_id" field. +func ModpackIDNotIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldModpackID, vs...)) +} + +// ModpackIDGT applies the GT predicate on the "modpack_id" field. +func ModpackIDGT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldModpackID, v)) +} + +// ModpackIDGTE applies the GTE predicate on the "modpack_id" field. +func ModpackIDGTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldModpackID, v)) +} + +// ModpackIDLT applies the LT predicate on the "modpack_id" field. +func ModpackIDLT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldModpackID, v)) +} + +// ModpackIDLTE applies the LTE predicate on the "modpack_id" field. +func ModpackIDLTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldModpackID, v)) +} + +// ModpackIDContains applies the Contains predicate on the "modpack_id" field. +func ModpackIDContains(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContains(FieldModpackID, v)) +} + +// ModpackIDHasPrefix applies the HasPrefix predicate on the "modpack_id" field. +func ModpackIDHasPrefix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasPrefix(FieldModpackID, v)) +} + +// ModpackIDHasSuffix applies the HasSuffix predicate on the "modpack_id" field. +func ModpackIDHasSuffix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasSuffix(FieldModpackID, v)) +} + +// ModpackIDEqualFold applies the EqualFold predicate on the "modpack_id" field. +func ModpackIDEqualFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEqualFold(FieldModpackID, v)) +} + +// ModpackIDContainsFold applies the ContainsFold predicate on the "modpack_id" field. +func ModpackIDContainsFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContainsFold(FieldModpackID, v)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContainsFold(FieldVersion, v)) +} + +// ChangelogEQ applies the EQ predicate on the "changelog" field. +func ChangelogEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldChangelog, v)) +} + +// ChangelogNEQ applies the NEQ predicate on the "changelog" field. +func ChangelogNEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldChangelog, v)) +} + +// ChangelogIn applies the In predicate on the "changelog" field. +func ChangelogIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldChangelog, vs...)) +} + +// ChangelogNotIn applies the NotIn predicate on the "changelog" field. +func ChangelogNotIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldChangelog, vs...)) +} + +// ChangelogGT applies the GT predicate on the "changelog" field. +func ChangelogGT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldChangelog, v)) +} + +// ChangelogGTE applies the GTE predicate on the "changelog" field. +func ChangelogGTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldChangelog, v)) +} + +// ChangelogLT applies the LT predicate on the "changelog" field. +func ChangelogLT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldChangelog, v)) +} + +// ChangelogLTE applies the LTE predicate on the "changelog" field. +func ChangelogLTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldChangelog, v)) +} + +// ChangelogContains applies the Contains predicate on the "changelog" field. +func ChangelogContains(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContains(FieldChangelog, v)) +} + +// ChangelogHasPrefix applies the HasPrefix predicate on the "changelog" field. +func ChangelogHasPrefix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasPrefix(FieldChangelog, v)) +} + +// ChangelogHasSuffix applies the HasSuffix predicate on the "changelog" field. +func ChangelogHasSuffix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasSuffix(FieldChangelog, v)) +} + +// ChangelogEqualFold applies the EqualFold predicate on the "changelog" field. +func ChangelogEqualFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEqualFold(FieldChangelog, v)) +} + +// ChangelogContainsFold applies the ContainsFold predicate on the "changelog" field. +func ChangelogContainsFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContainsFold(FieldChangelog, v)) +} + +// LockfileEQ applies the EQ predicate on the "lockfile" field. +func LockfileEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEQ(FieldLockfile, v)) +} + +// LockfileNEQ applies the NEQ predicate on the "lockfile" field. +func LockfileNEQ(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNEQ(FieldLockfile, v)) +} + +// LockfileIn applies the In predicate on the "lockfile" field. +func LockfileIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldIn(FieldLockfile, vs...)) +} + +// LockfileNotIn applies the NotIn predicate on the "lockfile" field. +func LockfileNotIn(vs ...string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldNotIn(FieldLockfile, vs...)) +} + +// LockfileGT applies the GT predicate on the "lockfile" field. +func LockfileGT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGT(FieldLockfile, v)) +} + +// LockfileGTE applies the GTE predicate on the "lockfile" field. +func LockfileGTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldGTE(FieldLockfile, v)) +} + +// LockfileLT applies the LT predicate on the "lockfile" field. +func LockfileLT(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLT(FieldLockfile, v)) +} + +// LockfileLTE applies the LTE predicate on the "lockfile" field. +func LockfileLTE(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldLTE(FieldLockfile, v)) +} + +// LockfileContains applies the Contains predicate on the "lockfile" field. +func LockfileContains(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContains(FieldLockfile, v)) +} + +// LockfileHasPrefix applies the HasPrefix predicate on the "lockfile" field. +func LockfileHasPrefix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasPrefix(FieldLockfile, v)) +} + +// LockfileHasSuffix applies the HasSuffix predicate on the "lockfile" field. +func LockfileHasSuffix(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldHasSuffix(FieldLockfile, v)) +} + +// LockfileEqualFold applies the EqualFold predicate on the "lockfile" field. +func LockfileEqualFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldEqualFold(FieldLockfile, v)) +} + +// LockfileContainsFold applies the ContainsFold predicate on the "lockfile" field. +func LockfileContainsFold(v string) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.FieldContainsFold(FieldLockfile, v)) +} + +// HasModpack applies the HasEdge predicate on the "modpack" edge. +func HasModpack() predicate.ModpackRelease { + return predicate.ModpackRelease(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModpackTable, ModpackColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackWith applies the HasEdge predicate on the "modpack" edge with a given conditions (other predicates). +func HasModpackWith(preds ...predicate.Modpack) predicate.ModpackRelease { + return predicate.ModpackRelease(func(s *sql.Selector) { + step := newModpackStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ModpackRelease) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ModpackRelease) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ModpackRelease) predicate.ModpackRelease { + return predicate.ModpackRelease(sql.NotPredicates(p)) +} diff --git a/generated/ent/modpackrelease_create.go b/generated/ent/modpackrelease_create.go new file mode 100644 index 00000000..f749f5af --- /dev/null +++ b/generated/ent/modpackrelease_create.go @@ -0,0 +1,785 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" +) + +// ModpackReleaseCreate is the builder for creating a ModpackRelease entity. +type ModpackReleaseCreate struct { + config + mutation *ModpackReleaseMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (mrc *ModpackReleaseCreate) SetCreatedAt(t time.Time) *ModpackReleaseCreate { + mrc.mutation.SetCreatedAt(t) + return mrc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (mrc *ModpackReleaseCreate) SetNillableCreatedAt(t *time.Time) *ModpackReleaseCreate { + if t != nil { + mrc.SetCreatedAt(*t) + } + return mrc +} + +// SetUpdatedAt sets the "updated_at" field. +func (mrc *ModpackReleaseCreate) SetUpdatedAt(t time.Time) *ModpackReleaseCreate { + mrc.mutation.SetUpdatedAt(t) + return mrc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (mrc *ModpackReleaseCreate) SetNillableUpdatedAt(t *time.Time) *ModpackReleaseCreate { + if t != nil { + mrc.SetUpdatedAt(*t) + } + return mrc +} + +// SetModpackID sets the "modpack_id" field. +func (mrc *ModpackReleaseCreate) SetModpackID(s string) *ModpackReleaseCreate { + mrc.mutation.SetModpackID(s) + return mrc +} + +// SetVersion sets the "version" field. +func (mrc *ModpackReleaseCreate) SetVersion(s string) *ModpackReleaseCreate { + mrc.mutation.SetVersion(s) + return mrc +} + +// SetChangelog sets the "changelog" field. +func (mrc *ModpackReleaseCreate) SetChangelog(s string) *ModpackReleaseCreate { + mrc.mutation.SetChangelog(s) + return mrc +} + +// SetLockfile sets the "lockfile" field. +func (mrc *ModpackReleaseCreate) SetLockfile(s string) *ModpackReleaseCreate { + mrc.mutation.SetLockfile(s) + return mrc +} + +// SetID sets the "id" field. +func (mrc *ModpackReleaseCreate) SetID(s string) *ModpackReleaseCreate { + mrc.mutation.SetID(s) + return mrc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (mrc *ModpackReleaseCreate) SetNillableID(s *string) *ModpackReleaseCreate { + if s != nil { + mrc.SetID(*s) + } + return mrc +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mrc *ModpackReleaseCreate) SetModpack(m *Modpack) *ModpackReleaseCreate { + return mrc.SetModpackID(m.ID) +} + +// Mutation returns the ModpackReleaseMutation object of the builder. +func (mrc *ModpackReleaseCreate) Mutation() *ModpackReleaseMutation { + return mrc.mutation +} + +// Save creates the ModpackRelease in the database. +func (mrc *ModpackReleaseCreate) Save(ctx context.Context) (*ModpackRelease, error) { + mrc.defaults() + return withHooks(ctx, mrc.sqlSave, mrc.mutation, mrc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mrc *ModpackReleaseCreate) SaveX(ctx context.Context) *ModpackRelease { + v, err := mrc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mrc *ModpackReleaseCreate) Exec(ctx context.Context) error { + _, err := mrc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mrc *ModpackReleaseCreate) ExecX(ctx context.Context) { + if err := mrc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mrc *ModpackReleaseCreate) defaults() { + if _, ok := mrc.mutation.CreatedAt(); !ok { + v := modpackrelease.DefaultCreatedAt() + mrc.mutation.SetCreatedAt(v) + } + if _, ok := mrc.mutation.UpdatedAt(); !ok { + v := modpackrelease.DefaultUpdatedAt() + mrc.mutation.SetUpdatedAt(v) + } + if _, ok := mrc.mutation.ID(); !ok { + v := modpackrelease.DefaultID() + mrc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mrc *ModpackReleaseCreate) check() error { + if _, ok := mrc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ModpackRelease.created_at"`)} + } + if _, ok := mrc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ModpackRelease.updated_at"`)} + } + if _, ok := mrc.mutation.ModpackID(); !ok { + return &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing required field "ModpackRelease.modpack_id"`)} + } + if _, ok := mrc.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`ent: missing required field "ModpackRelease.version"`)} + } + if _, ok := mrc.mutation.Changelog(); !ok { + return &ValidationError{Name: "changelog", err: errors.New(`ent: missing required field "ModpackRelease.changelog"`)} + } + if _, ok := mrc.mutation.Lockfile(); !ok { + return &ValidationError{Name: "lockfile", err: errors.New(`ent: missing required field "ModpackRelease.lockfile"`)} + } + if len(mrc.mutation.ModpackIDs()) == 0 { + return &ValidationError{Name: "modpack", err: errors.New(`ent: missing required edge "ModpackRelease.modpack"`)} + } + return nil +} + +func (mrc *ModpackReleaseCreate) sqlSave(ctx context.Context) (*ModpackRelease, error) { + if err := mrc.check(); err != nil { + return nil, err + } + _node, _spec := mrc.createSpec() + if err := sqlgraph.CreateNode(ctx, mrc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected ModpackRelease.ID type: %T", _spec.ID.Value) + } + } + mrc.mutation.id = &_node.ID + mrc.mutation.done = true + return _node, nil +} + +func (mrc *ModpackReleaseCreate) createSpec() (*ModpackRelease, *sqlgraph.CreateSpec) { + var ( + _node = &ModpackRelease{config: mrc.config} + _spec = sqlgraph.NewCreateSpec(modpackrelease.Table, sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString)) + ) + _spec.OnConflict = mrc.conflict + if id, ok := mrc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := mrc.mutation.CreatedAt(); ok { + _spec.SetField(modpackrelease.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := mrc.mutation.UpdatedAt(); ok { + _spec.SetField(modpackrelease.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := mrc.mutation.Version(); ok { + _spec.SetField(modpackrelease.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := mrc.mutation.Changelog(); ok { + _spec.SetField(modpackrelease.FieldChangelog, field.TypeString, value) + _node.Changelog = value + } + if value, ok := mrc.mutation.Lockfile(); ok { + _spec.SetField(modpackrelease.FieldLockfile, field.TypeString, value) + _node.Lockfile = value + } + if nodes := mrc.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpackrelease.ModpackTable, + Columns: []string{modpackrelease.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ModpackID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackRelease.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackReleaseUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mrc *ModpackReleaseCreate) OnConflict(opts ...sql.ConflictOption) *ModpackReleaseUpsertOne { + mrc.conflict = opts + return &ModpackReleaseUpsertOne{ + create: mrc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mrc *ModpackReleaseCreate) OnConflictColumns(columns ...string) *ModpackReleaseUpsertOne { + mrc.conflict = append(mrc.conflict, sql.ConflictColumns(columns...)) + return &ModpackReleaseUpsertOne{ + create: mrc, + } +} + +type ( + // ModpackReleaseUpsertOne is the builder for "upsert"-ing + // one ModpackRelease node. + ModpackReleaseUpsertOne struct { + create *ModpackReleaseCreate + } + + // ModpackReleaseUpsert is the "OnConflict" setter. + ModpackReleaseUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackReleaseUpsert) SetUpdatedAt(v time.Time) *ModpackReleaseUpsert { + u.Set(modpackrelease.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackReleaseUpsert) UpdateUpdatedAt() *ModpackReleaseUpsert { + u.SetExcluded(modpackrelease.FieldUpdatedAt) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackReleaseUpsert) SetModpackID(v string) *ModpackReleaseUpsert { + u.Set(modpackrelease.FieldModpackID, v) + return u +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackReleaseUpsert) UpdateModpackID() *ModpackReleaseUpsert { + u.SetExcluded(modpackrelease.FieldModpackID) + return u +} + +// SetVersion sets the "version" field. +func (u *ModpackReleaseUpsert) SetVersion(v string) *ModpackReleaseUpsert { + u.Set(modpackrelease.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *ModpackReleaseUpsert) UpdateVersion() *ModpackReleaseUpsert { + u.SetExcluded(modpackrelease.FieldVersion) + return u +} + +// SetChangelog sets the "changelog" field. +func (u *ModpackReleaseUpsert) SetChangelog(v string) *ModpackReleaseUpsert { + u.Set(modpackrelease.FieldChangelog, v) + return u +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *ModpackReleaseUpsert) UpdateChangelog() *ModpackReleaseUpsert { + u.SetExcluded(modpackrelease.FieldChangelog) + return u +} + +// SetLockfile sets the "lockfile" field. +func (u *ModpackReleaseUpsert) SetLockfile(v string) *ModpackReleaseUpsert { + u.Set(modpackrelease.FieldLockfile, v) + return u +} + +// UpdateLockfile sets the "lockfile" field to the value that was provided on create. +func (u *ModpackReleaseUpsert) UpdateLockfile() *ModpackReleaseUpsert { + u.SetExcluded(modpackrelease.FieldLockfile) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpackrelease.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackReleaseUpsertOne) UpdateNewValues() *ModpackReleaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(modpackrelease.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(modpackrelease.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackReleaseUpsertOne) Ignore() *ModpackReleaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackReleaseUpsertOne) DoNothing() *ModpackReleaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackReleaseCreate.OnConflict +// documentation for more info. +func (u *ModpackReleaseUpsertOne) Update(set func(*ModpackReleaseUpsert)) *ModpackReleaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackReleaseUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackReleaseUpsertOne) SetUpdatedAt(v time.Time) *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackReleaseUpsertOne) UpdateUpdatedAt() *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackReleaseUpsertOne) SetModpackID(v string) *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackReleaseUpsertOne) UpdateModpackID() *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateModpackID() + }) +} + +// SetVersion sets the "version" field. +func (u *ModpackReleaseUpsertOne) SetVersion(v string) *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *ModpackReleaseUpsertOne) UpdateVersion() *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateVersion() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *ModpackReleaseUpsertOne) SetChangelog(v string) *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *ModpackReleaseUpsertOne) UpdateChangelog() *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateChangelog() + }) +} + +// SetLockfile sets the "lockfile" field. +func (u *ModpackReleaseUpsertOne) SetLockfile(v string) *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetLockfile(v) + }) +} + +// UpdateLockfile sets the "lockfile" field to the value that was provided on create. +func (u *ModpackReleaseUpsertOne) UpdateLockfile() *ModpackReleaseUpsertOne { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateLockfile() + }) +} + +// Exec executes the query. +func (u *ModpackReleaseUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackReleaseCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackReleaseUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ModpackReleaseUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ModpackReleaseUpsertOne.ID is not supported by MySQL driver. Use ModpackReleaseUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ModpackReleaseUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ModpackReleaseCreateBulk is the builder for creating many ModpackRelease entities in bulk. +type ModpackReleaseCreateBulk struct { + config + err error + builders []*ModpackReleaseCreate + conflict []sql.ConflictOption +} + +// Save creates the ModpackRelease entities in the database. +func (mrcb *ModpackReleaseCreateBulk) Save(ctx context.Context) ([]*ModpackRelease, error) { + if mrcb.err != nil { + return nil, mrcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mrcb.builders)) + nodes := make([]*ModpackRelease, len(mrcb.builders)) + mutators := make([]Mutator, len(mrcb.builders)) + for i := range mrcb.builders { + func(i int, root context.Context) { + builder := mrcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ModpackReleaseMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mrcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = mrcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mrcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mrcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mrcb *ModpackReleaseCreateBulk) SaveX(ctx context.Context) []*ModpackRelease { + v, err := mrcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mrcb *ModpackReleaseCreateBulk) Exec(ctx context.Context) error { + _, err := mrcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mrcb *ModpackReleaseCreateBulk) ExecX(ctx context.Context) { + if err := mrcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackRelease.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackReleaseUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mrcb *ModpackReleaseCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModpackReleaseUpsertBulk { + mrcb.conflict = opts + return &ModpackReleaseUpsertBulk{ + create: mrcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mrcb *ModpackReleaseCreateBulk) OnConflictColumns(columns ...string) *ModpackReleaseUpsertBulk { + mrcb.conflict = append(mrcb.conflict, sql.ConflictColumns(columns...)) + return &ModpackReleaseUpsertBulk{ + create: mrcb, + } +} + +// ModpackReleaseUpsertBulk is the builder for "upsert"-ing +// a bulk of ModpackRelease nodes. +type ModpackReleaseUpsertBulk struct { + create *ModpackReleaseCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpackrelease.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackReleaseUpsertBulk) UpdateNewValues() *ModpackReleaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(modpackrelease.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(modpackrelease.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackRelease.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackReleaseUpsertBulk) Ignore() *ModpackReleaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackReleaseUpsertBulk) DoNothing() *ModpackReleaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackReleaseCreateBulk.OnConflict +// documentation for more info. +func (u *ModpackReleaseUpsertBulk) Update(set func(*ModpackReleaseUpsert)) *ModpackReleaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackReleaseUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModpackReleaseUpsertBulk) SetUpdatedAt(v time.Time) *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModpackReleaseUpsertBulk) UpdateUpdatedAt() *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackReleaseUpsertBulk) SetModpackID(v string) *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackReleaseUpsertBulk) UpdateModpackID() *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateModpackID() + }) +} + +// SetVersion sets the "version" field. +func (u *ModpackReleaseUpsertBulk) SetVersion(v string) *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *ModpackReleaseUpsertBulk) UpdateVersion() *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateVersion() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *ModpackReleaseUpsertBulk) SetChangelog(v string) *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *ModpackReleaseUpsertBulk) UpdateChangelog() *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateChangelog() + }) +} + +// SetLockfile sets the "lockfile" field. +func (u *ModpackReleaseUpsertBulk) SetLockfile(v string) *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.SetLockfile(v) + }) +} + +// UpdateLockfile sets the "lockfile" field to the value that was provided on create. +func (u *ModpackReleaseUpsertBulk) UpdateLockfile() *ModpackReleaseUpsertBulk { + return u.Update(func(s *ModpackReleaseUpsert) { + s.UpdateLockfile() + }) +} + +// Exec executes the query. +func (u *ModpackReleaseUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ModpackReleaseCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackReleaseCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackReleaseUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpackrelease_delete.go b/generated/ent/modpackrelease_delete.go new file mode 100644 index 00000000..a3d584f5 --- /dev/null +++ b/generated/ent/modpackrelease_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackReleaseDelete is the builder for deleting a ModpackRelease entity. +type ModpackReleaseDelete struct { + config + hooks []Hook + mutation *ModpackReleaseMutation +} + +// Where appends a list predicates to the ModpackReleaseDelete builder. +func (mrd *ModpackReleaseDelete) Where(ps ...predicate.ModpackRelease) *ModpackReleaseDelete { + mrd.mutation.Where(ps...) + return mrd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mrd *ModpackReleaseDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, mrd.sqlExec, mrd.mutation, mrd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (mrd *ModpackReleaseDelete) ExecX(ctx context.Context) int { + n, err := mrd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mrd *ModpackReleaseDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modpackrelease.Table, sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString)) + if ps := mrd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, mrd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + mrd.mutation.done = true + return affected, err +} + +// ModpackReleaseDeleteOne is the builder for deleting a single ModpackRelease entity. +type ModpackReleaseDeleteOne struct { + mrd *ModpackReleaseDelete +} + +// Where appends a list predicates to the ModpackReleaseDelete builder. +func (mrdo *ModpackReleaseDeleteOne) Where(ps ...predicate.ModpackRelease) *ModpackReleaseDeleteOne { + mrdo.mrd.mutation.Where(ps...) + return mrdo +} + +// Exec executes the deletion query. +func (mrdo *ModpackReleaseDeleteOne) Exec(ctx context.Context) error { + n, err := mrdo.mrd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modpackrelease.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mrdo *ModpackReleaseDeleteOne) ExecX(ctx context.Context) { + if err := mrdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpackrelease_query.go b/generated/ent/modpackrelease_query.go new file mode 100644 index 00000000..4622fb2a --- /dev/null +++ b/generated/ent/modpackrelease_query.go @@ -0,0 +1,629 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackReleaseQuery is the builder for querying ModpackRelease entities. +type ModpackReleaseQuery struct { + config + ctx *QueryContext + order []modpackrelease.OrderOption + inters []Interceptor + predicates []predicate.ModpackRelease + withModpack *ModpackQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ModpackReleaseQuery builder. +func (mrq *ModpackReleaseQuery) Where(ps ...predicate.ModpackRelease) *ModpackReleaseQuery { + mrq.predicates = append(mrq.predicates, ps...) + return mrq +} + +// Limit the number of records to be returned by this query. +func (mrq *ModpackReleaseQuery) Limit(limit int) *ModpackReleaseQuery { + mrq.ctx.Limit = &limit + return mrq +} + +// Offset to start from. +func (mrq *ModpackReleaseQuery) Offset(offset int) *ModpackReleaseQuery { + mrq.ctx.Offset = &offset + return mrq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mrq *ModpackReleaseQuery) Unique(unique bool) *ModpackReleaseQuery { + mrq.ctx.Unique = &unique + return mrq +} + +// Order specifies how the records should be ordered. +func (mrq *ModpackReleaseQuery) Order(o ...modpackrelease.OrderOption) *ModpackReleaseQuery { + mrq.order = append(mrq.order, o...) + return mrq +} + +// QueryModpack chains the current query on the "modpack" edge. +func (mrq *ModpackReleaseQuery) QueryModpack() *ModpackQuery { + query := (&ModpackClient{config: mrq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mrq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mrq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpackrelease.Table, modpackrelease.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpackrelease.ModpackTable, modpackrelease.ModpackColumn), + ) + fromU = sqlgraph.SetNeighbors(mrq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ModpackRelease entity from the query. +// Returns a *NotFoundError when no ModpackRelease was found. +func (mrq *ModpackReleaseQuery) First(ctx context.Context) (*ModpackRelease, error) { + nodes, err := mrq.Limit(1).All(setContextOp(ctx, mrq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modpackrelease.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) FirstX(ctx context.Context) *ModpackRelease { + node, err := mrq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ModpackRelease ID from the query. +// Returns a *NotFoundError when no ModpackRelease ID was found. +func (mrq *ModpackReleaseQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mrq.Limit(1).IDs(setContextOp(ctx, mrq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{modpackrelease.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) FirstIDX(ctx context.Context) string { + id, err := mrq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ModpackRelease entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ModpackRelease entity is found. +// Returns a *NotFoundError when no ModpackRelease entities are found. +func (mrq *ModpackReleaseQuery) Only(ctx context.Context) (*ModpackRelease, error) { + nodes, err := mrq.Limit(2).All(setContextOp(ctx, mrq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modpackrelease.Label} + default: + return nil, &NotSingularError{modpackrelease.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) OnlyX(ctx context.Context) *ModpackRelease { + node, err := mrq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ModpackRelease ID in the query. +// Returns a *NotSingularError when more than one ModpackRelease ID is found. +// Returns a *NotFoundError when no entities are found. +func (mrq *ModpackReleaseQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mrq.Limit(2).IDs(setContextOp(ctx, mrq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{modpackrelease.Label} + default: + err = &NotSingularError{modpackrelease.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) OnlyIDX(ctx context.Context) string { + id, err := mrq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ModpackReleases. +func (mrq *ModpackReleaseQuery) All(ctx context.Context) ([]*ModpackRelease, error) { + ctx = setContextOp(ctx, mrq.ctx, ent.OpQueryAll) + if err := mrq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ModpackRelease, *ModpackReleaseQuery]() + return withInterceptors[[]*ModpackRelease](ctx, mrq, qr, mrq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) AllX(ctx context.Context) []*ModpackRelease { + nodes, err := mrq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ModpackRelease IDs. +func (mrq *ModpackReleaseQuery) IDs(ctx context.Context) (ids []string, err error) { + if mrq.ctx.Unique == nil && mrq.path != nil { + mrq.Unique(true) + } + ctx = setContextOp(ctx, mrq.ctx, ent.OpQueryIDs) + if err = mrq.Select(modpackrelease.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) IDsX(ctx context.Context) []string { + ids, err := mrq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mrq *ModpackReleaseQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mrq.ctx, ent.OpQueryCount) + if err := mrq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mrq, querierCount[*ModpackReleaseQuery](), mrq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) CountX(ctx context.Context) int { + count, err := mrq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mrq *ModpackReleaseQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mrq.ctx, ent.OpQueryExist) + switch _, err := mrq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mrq *ModpackReleaseQuery) ExistX(ctx context.Context) bool { + exist, err := mrq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModpackReleaseQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mrq *ModpackReleaseQuery) Clone() *ModpackReleaseQuery { + if mrq == nil { + return nil + } + return &ModpackReleaseQuery{ + config: mrq.config, + ctx: mrq.ctx.Clone(), + order: append([]modpackrelease.OrderOption{}, mrq.order...), + inters: append([]Interceptor{}, mrq.inters...), + predicates: append([]predicate.ModpackRelease{}, mrq.predicates...), + withModpack: mrq.withModpack.Clone(), + // clone intermediate query. + sql: mrq.sql.Clone(), + path: mrq.path, + modifiers: append([]func(*sql.Selector){}, mrq.modifiers...), + } +} + +// WithModpack tells the query-builder to eager-load the nodes that are connected to +// the "modpack" edge. The optional arguments are used to configure the query builder of the edge. +func (mrq *ModpackReleaseQuery) WithModpack(opts ...func(*ModpackQuery)) *ModpackReleaseQuery { + query := (&ModpackClient{config: mrq.config}).Query() + for _, opt := range opts { + opt(query) + } + mrq.withModpack = query + return mrq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ModpackRelease.Query(). +// GroupBy(modpackrelease.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mrq *ModpackReleaseQuery) GroupBy(field string, fields ...string) *ModpackReleaseGroupBy { + mrq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModpackReleaseGroupBy{build: mrq} + grbuild.flds = &mrq.ctx.Fields + grbuild.label = modpackrelease.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.ModpackRelease.Query(). +// Select(modpackrelease.FieldCreatedAt). +// Scan(ctx, &v) +func (mrq *ModpackReleaseQuery) Select(fields ...string) *ModpackReleaseSelect { + mrq.ctx.Fields = append(mrq.ctx.Fields, fields...) + sbuild := &ModpackReleaseSelect{ModpackReleaseQuery: mrq} + sbuild.label = modpackrelease.Label + sbuild.flds, sbuild.scan = &mrq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModpackReleaseSelect configured with the given aggregations. +func (mrq *ModpackReleaseQuery) Aggregate(fns ...AggregateFunc) *ModpackReleaseSelect { + return mrq.Select().Aggregate(fns...) +} + +func (mrq *ModpackReleaseQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mrq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mrq); err != nil { + return err + } + } + } + for _, f := range mrq.ctx.Fields { + if !modpackrelease.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mrq.path != nil { + prev, err := mrq.path(ctx) + if err != nil { + return err + } + mrq.sql = prev + } + return nil +} + +func (mrq *ModpackReleaseQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ModpackRelease, error) { + var ( + nodes = []*ModpackRelease{} + _spec = mrq.querySpec() + loadedTypes = [1]bool{ + mrq.withModpack != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ModpackRelease).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ModpackRelease{config: mrq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mrq.modifiers) > 0 { + _spec.Modifiers = mrq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mrq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mrq.withModpack; query != nil { + if err := mrq.loadModpack(ctx, query, nodes, nil, + func(n *ModpackRelease, e *Modpack) { n.Edges.Modpack = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mrq *ModpackReleaseQuery) loadModpack(ctx context.Context, query *ModpackQuery, nodes []*ModpackRelease, init func(*ModpackRelease), assign func(*ModpackRelease, *Modpack)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackRelease) + for i := range nodes { + fk := nodes[i].ModpackID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(modpack.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "modpack_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (mrq *ModpackReleaseQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mrq.querySpec() + if len(mrq.modifiers) > 0 { + _spec.Modifiers = mrq.modifiers + } + _spec.Node.Columns = mrq.ctx.Fields + if len(mrq.ctx.Fields) > 0 { + _spec.Unique = mrq.ctx.Unique != nil && *mrq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, mrq.driver, _spec) +} + +func (mrq *ModpackReleaseQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modpackrelease.Table, modpackrelease.Columns, sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString)) + _spec.From = mrq.sql + if unique := mrq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mrq.path != nil { + _spec.Unique = true + } + if fields := mrq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpackrelease.FieldID) + for i := range fields { + if fields[i] != modpackrelease.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if mrq.withModpack != nil { + _spec.Node.AddColumnOnce(modpackrelease.FieldModpackID) + } + } + if ps := mrq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mrq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mrq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mrq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mrq *ModpackReleaseQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mrq.driver.Dialect()) + t1 := builder.Table(modpackrelease.Table) + columns := mrq.ctx.Fields + if len(columns) == 0 { + columns = modpackrelease.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mrq.sql != nil { + selector = mrq.sql + selector.Select(selector.Columns(columns...)...) + } + if mrq.ctx.Unique != nil && *mrq.ctx.Unique { + selector.Distinct() + } + for _, m := range mrq.modifiers { + m(selector) + } + for _, p := range mrq.predicates { + p(selector) + } + for _, p := range mrq.order { + p(selector) + } + if offset := mrq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mrq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mrq *ModpackReleaseQuery) Modify(modifiers ...func(s *sql.Selector)) *ModpackReleaseSelect { + mrq.modifiers = append(mrq.modifiers, modifiers...) + return mrq.Select() +} + +// ModpackReleaseGroupBy is the group-by builder for ModpackRelease entities. +type ModpackReleaseGroupBy struct { + selector + build *ModpackReleaseQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mrgb *ModpackReleaseGroupBy) Aggregate(fns ...AggregateFunc) *ModpackReleaseGroupBy { + mrgb.fns = append(mrgb.fns, fns...) + return mrgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mrgb *ModpackReleaseGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mrgb.build.ctx, ent.OpQueryGroupBy) + if err := mrgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackReleaseQuery, *ModpackReleaseGroupBy](ctx, mrgb.build, mrgb, mrgb.build.inters, v) +} + +func (mrgb *ModpackReleaseGroupBy) sqlScan(ctx context.Context, root *ModpackReleaseQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mrgb.fns)) + for _, fn := range mrgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mrgb.flds)+len(mrgb.fns)) + for _, f := range *mrgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mrgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mrgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ModpackReleaseSelect is the builder for selecting fields of ModpackRelease entities. +type ModpackReleaseSelect struct { + *ModpackReleaseQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mrs *ModpackReleaseSelect) Aggregate(fns ...AggregateFunc) *ModpackReleaseSelect { + mrs.fns = append(mrs.fns, fns...) + return mrs +} + +// Scan applies the selector query and scans the result into the given value. +func (mrs *ModpackReleaseSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mrs.ctx, ent.OpQuerySelect) + if err := mrs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackReleaseQuery, *ModpackReleaseSelect](ctx, mrs.ModpackReleaseQuery, mrs, mrs.inters, v) +} + +func (mrs *ModpackReleaseSelect) sqlScan(ctx context.Context, root *ModpackReleaseQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(mrs.fns)) + for _, fn := range mrs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*mrs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mrs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mrs *ModpackReleaseSelect) Modify(modifiers ...func(s *sql.Selector)) *ModpackReleaseSelect { + mrs.modifiers = append(mrs.modifiers, modifiers...) + return mrs +} diff --git a/generated/ent/modpackrelease_update.go b/generated/ent/modpackrelease_update.go new file mode 100644 index 00000000..1a0ca112 --- /dev/null +++ b/generated/ent/modpackrelease_update.go @@ -0,0 +1,461 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackReleaseUpdate is the builder for updating ModpackRelease entities. +type ModpackReleaseUpdate struct { + config + hooks []Hook + mutation *ModpackReleaseMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModpackReleaseUpdate builder. +func (mru *ModpackReleaseUpdate) Where(ps ...predicate.ModpackRelease) *ModpackReleaseUpdate { + mru.mutation.Where(ps...) + return mru +} + +// SetUpdatedAt sets the "updated_at" field. +func (mru *ModpackReleaseUpdate) SetUpdatedAt(t time.Time) *ModpackReleaseUpdate { + mru.mutation.SetUpdatedAt(t) + return mru +} + +// SetModpackID sets the "modpack_id" field. +func (mru *ModpackReleaseUpdate) SetModpackID(s string) *ModpackReleaseUpdate { + mru.mutation.SetModpackID(s) + return mru +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mru *ModpackReleaseUpdate) SetNillableModpackID(s *string) *ModpackReleaseUpdate { + if s != nil { + mru.SetModpackID(*s) + } + return mru +} + +// SetVersion sets the "version" field. +func (mru *ModpackReleaseUpdate) SetVersion(s string) *ModpackReleaseUpdate { + mru.mutation.SetVersion(s) + return mru +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (mru *ModpackReleaseUpdate) SetNillableVersion(s *string) *ModpackReleaseUpdate { + if s != nil { + mru.SetVersion(*s) + } + return mru +} + +// SetChangelog sets the "changelog" field. +func (mru *ModpackReleaseUpdate) SetChangelog(s string) *ModpackReleaseUpdate { + mru.mutation.SetChangelog(s) + return mru +} + +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (mru *ModpackReleaseUpdate) SetNillableChangelog(s *string) *ModpackReleaseUpdate { + if s != nil { + mru.SetChangelog(*s) + } + return mru +} + +// SetLockfile sets the "lockfile" field. +func (mru *ModpackReleaseUpdate) SetLockfile(s string) *ModpackReleaseUpdate { + mru.mutation.SetLockfile(s) + return mru +} + +// SetNillableLockfile sets the "lockfile" field if the given value is not nil. +func (mru *ModpackReleaseUpdate) SetNillableLockfile(s *string) *ModpackReleaseUpdate { + if s != nil { + mru.SetLockfile(*s) + } + return mru +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mru *ModpackReleaseUpdate) SetModpack(m *Modpack) *ModpackReleaseUpdate { + return mru.SetModpackID(m.ID) +} + +// Mutation returns the ModpackReleaseMutation object of the builder. +func (mru *ModpackReleaseUpdate) Mutation() *ModpackReleaseMutation { + return mru.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mru *ModpackReleaseUpdate) ClearModpack() *ModpackReleaseUpdate { + mru.mutation.ClearModpack() + return mru +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mru *ModpackReleaseUpdate) Save(ctx context.Context) (int, error) { + mru.defaults() + return withHooks(ctx, mru.sqlSave, mru.mutation, mru.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mru *ModpackReleaseUpdate) SaveX(ctx context.Context) int { + affected, err := mru.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mru *ModpackReleaseUpdate) Exec(ctx context.Context) error { + _, err := mru.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mru *ModpackReleaseUpdate) ExecX(ctx context.Context) { + if err := mru.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mru *ModpackReleaseUpdate) defaults() { + if _, ok := mru.mutation.UpdatedAt(); !ok { + v := modpackrelease.UpdateDefaultUpdatedAt() + mru.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mru *ModpackReleaseUpdate) check() error { + if mru.mutation.ModpackCleared() && len(mru.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackRelease.modpack"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mru *ModpackReleaseUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackReleaseUpdate { + mru.modifiers = append(mru.modifiers, modifiers...) + return mru +} + +func (mru *ModpackReleaseUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mru.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modpackrelease.Table, modpackrelease.Columns, sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString)) + if ps := mru.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mru.mutation.UpdatedAt(); ok { + _spec.SetField(modpackrelease.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := mru.mutation.Version(); ok { + _spec.SetField(modpackrelease.FieldVersion, field.TypeString, value) + } + if value, ok := mru.mutation.Changelog(); ok { + _spec.SetField(modpackrelease.FieldChangelog, field.TypeString, value) + } + if value, ok := mru.mutation.Lockfile(); ok { + _spec.SetField(modpackrelease.FieldLockfile, field.TypeString, value) + } + if mru.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpackrelease.ModpackTable, + Columns: []string{modpackrelease.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mru.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpackrelease.ModpackTable, + Columns: []string{modpackrelease.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mru.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, mru.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpackrelease.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mru.mutation.done = true + return n, nil +} + +// ModpackReleaseUpdateOne is the builder for updating a single ModpackRelease entity. +type ModpackReleaseUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModpackReleaseMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (mruo *ModpackReleaseUpdateOne) SetUpdatedAt(t time.Time) *ModpackReleaseUpdateOne { + mruo.mutation.SetUpdatedAt(t) + return mruo +} + +// SetModpackID sets the "modpack_id" field. +func (mruo *ModpackReleaseUpdateOne) SetModpackID(s string) *ModpackReleaseUpdateOne { + mruo.mutation.SetModpackID(s) + return mruo +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mruo *ModpackReleaseUpdateOne) SetNillableModpackID(s *string) *ModpackReleaseUpdateOne { + if s != nil { + mruo.SetModpackID(*s) + } + return mruo +} + +// SetVersion sets the "version" field. +func (mruo *ModpackReleaseUpdateOne) SetVersion(s string) *ModpackReleaseUpdateOne { + mruo.mutation.SetVersion(s) + return mruo +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (mruo *ModpackReleaseUpdateOne) SetNillableVersion(s *string) *ModpackReleaseUpdateOne { + if s != nil { + mruo.SetVersion(*s) + } + return mruo +} + +// SetChangelog sets the "changelog" field. +func (mruo *ModpackReleaseUpdateOne) SetChangelog(s string) *ModpackReleaseUpdateOne { + mruo.mutation.SetChangelog(s) + return mruo +} + +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (mruo *ModpackReleaseUpdateOne) SetNillableChangelog(s *string) *ModpackReleaseUpdateOne { + if s != nil { + mruo.SetChangelog(*s) + } + return mruo +} + +// SetLockfile sets the "lockfile" field. +func (mruo *ModpackReleaseUpdateOne) SetLockfile(s string) *ModpackReleaseUpdateOne { + mruo.mutation.SetLockfile(s) + return mruo +} + +// SetNillableLockfile sets the "lockfile" field if the given value is not nil. +func (mruo *ModpackReleaseUpdateOne) SetNillableLockfile(s *string) *ModpackReleaseUpdateOne { + if s != nil { + mruo.SetLockfile(*s) + } + return mruo +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mruo *ModpackReleaseUpdateOne) SetModpack(m *Modpack) *ModpackReleaseUpdateOne { + return mruo.SetModpackID(m.ID) +} + +// Mutation returns the ModpackReleaseMutation object of the builder. +func (mruo *ModpackReleaseUpdateOne) Mutation() *ModpackReleaseMutation { + return mruo.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mruo *ModpackReleaseUpdateOne) ClearModpack() *ModpackReleaseUpdateOne { + mruo.mutation.ClearModpack() + return mruo +} + +// Where appends a list predicates to the ModpackReleaseUpdate builder. +func (mruo *ModpackReleaseUpdateOne) Where(ps ...predicate.ModpackRelease) *ModpackReleaseUpdateOne { + mruo.mutation.Where(ps...) + return mruo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mruo *ModpackReleaseUpdateOne) Select(field string, fields ...string) *ModpackReleaseUpdateOne { + mruo.fields = append([]string{field}, fields...) + return mruo +} + +// Save executes the query and returns the updated ModpackRelease entity. +func (mruo *ModpackReleaseUpdateOne) Save(ctx context.Context) (*ModpackRelease, error) { + mruo.defaults() + return withHooks(ctx, mruo.sqlSave, mruo.mutation, mruo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mruo *ModpackReleaseUpdateOne) SaveX(ctx context.Context) *ModpackRelease { + node, err := mruo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mruo *ModpackReleaseUpdateOne) Exec(ctx context.Context) error { + _, err := mruo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mruo *ModpackReleaseUpdateOne) ExecX(ctx context.Context) { + if err := mruo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mruo *ModpackReleaseUpdateOne) defaults() { + if _, ok := mruo.mutation.UpdatedAt(); !ok { + v := modpackrelease.UpdateDefaultUpdatedAt() + mruo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mruo *ModpackReleaseUpdateOne) check() error { + if mruo.mutation.ModpackCleared() && len(mruo.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackRelease.modpack"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mruo *ModpackReleaseUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackReleaseUpdateOne { + mruo.modifiers = append(mruo.modifiers, modifiers...) + return mruo +} + +func (mruo *ModpackReleaseUpdateOne) sqlSave(ctx context.Context) (_node *ModpackRelease, err error) { + if err := mruo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modpackrelease.Table, modpackrelease.Columns, sqlgraph.NewFieldSpec(modpackrelease.FieldID, field.TypeString)) + id, ok := mruo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ModpackRelease.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := mruo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpackrelease.FieldID) + for _, f := range fields { + if !modpackrelease.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != modpackrelease.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := mruo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mruo.mutation.UpdatedAt(); ok { + _spec.SetField(modpackrelease.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := mruo.mutation.Version(); ok { + _spec.SetField(modpackrelease.FieldVersion, field.TypeString, value) + } + if value, ok := mruo.mutation.Changelog(); ok { + _spec.SetField(modpackrelease.FieldChangelog, field.TypeString, value) + } + if value, ok := mruo.mutation.Lockfile(); ok { + _spec.SetField(modpackrelease.FieldLockfile, field.TypeString, value) + } + if mruo.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpackrelease.ModpackTable, + Columns: []string{modpackrelease.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mruo.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpackrelease.ModpackTable, + Columns: []string{modpackrelease.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mruo.modifiers...) + _node = &ModpackRelease{config: mruo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mruo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpackrelease.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + mruo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/modpacktag.go b/generated/ent/modpacktag.go new file mode 100644 index 00000000..bb7cb7df --- /dev/null +++ b/generated/ent/modpacktag.go @@ -0,0 +1,151 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackTag is the model entity for the ModpackTag schema. +type ModpackTag struct { + config `json:"-"` + // ModpackID holds the value of the "modpack_id" field. + ModpackID string `json:"modpack_id,omitempty"` + // TagID holds the value of the "tag_id" field. + TagID string `json:"tag_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModpackTagQuery when eager-loading is set. + Edges ModpackTagEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModpackTagEdges holds the relations/edges for other nodes in the graph. +type ModpackTagEdges struct { + // Modpack holds the value of the modpack edge. + Modpack *Modpack `json:"modpack,omitempty"` + // Tag holds the value of the tag edge. + Tag *Tag `json:"tag,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ModpackOrErr returns the Modpack value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackTagEdges) ModpackOrErr() (*Modpack, error) { + if e.Modpack != nil { + return e.Modpack, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: modpack.Label} + } + return nil, &NotLoadedError{edge: "modpack"} +} + +// TagOrErr returns the Tag value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackTagEdges) TagOrErr() (*Tag, error) { + if e.Tag != nil { + return e.Tag, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: tag.Label} + } + return nil, &NotLoadedError{edge: "tag"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ModpackTag) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modpacktag.FieldModpackID, modpacktag.FieldTagID: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ModpackTag fields. +func (mt *ModpackTag) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case modpacktag.FieldModpackID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field modpack_id", values[i]) + } else if value.Valid { + mt.ModpackID = value.String + } + case modpacktag.FieldTagID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field tag_id", values[i]) + } else if value.Valid { + mt.TagID = value.String + } + default: + mt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ModpackTag. +// This includes values selected through modifiers, order, etc. +func (mt *ModpackTag) Value(name string) (ent.Value, error) { + return mt.selectValues.Get(name) +} + +// QueryModpack queries the "modpack" edge of the ModpackTag entity. +func (mt *ModpackTag) QueryModpack() *ModpackQuery { + return NewModpackTagClient(mt.config).QueryModpack(mt) +} + +// QueryTag queries the "tag" edge of the ModpackTag entity. +func (mt *ModpackTag) QueryTag() *TagQuery { + return NewModpackTagClient(mt.config).QueryTag(mt) +} + +// Update returns a builder for updating this ModpackTag. +// Note that you need to call ModpackTag.Unwrap() before calling this method if this ModpackTag +// was returned from a transaction, and the transaction was committed or rolled back. +func (mt *ModpackTag) Update() *ModpackTagUpdateOne { + return NewModpackTagClient(mt.config).UpdateOne(mt) +} + +// Unwrap unwraps the ModpackTag entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (mt *ModpackTag) Unwrap() *ModpackTag { + _tx, ok := mt.config.driver.(*txDriver) + if !ok { + panic("ent: ModpackTag is not a transactional entity") + } + mt.config.driver = _tx.drv + return mt +} + +// String implements the fmt.Stringer. +func (mt *ModpackTag) String() string { + var builder strings.Builder + builder.WriteString("ModpackTag(") + builder.WriteString("modpack_id=") + builder.WriteString(mt.ModpackID) + builder.WriteString(", ") + builder.WriteString("tag_id=") + builder.WriteString(mt.TagID) + builder.WriteByte(')') + return builder.String() +} + +// ModpackTags is a parsable slice of ModpackTag. +type ModpackTags []*ModpackTag diff --git a/generated/ent/modpacktag/modpacktag.go b/generated/ent/modpacktag/modpacktag.go new file mode 100644 index 00000000..ee1afcc1 --- /dev/null +++ b/generated/ent/modpacktag/modpacktag.go @@ -0,0 +1,98 @@ +// Code generated by ent, DO NOT EDIT. + +package modpacktag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modpacktag type in the database. + Label = "modpack_tag" + // FieldModpackID holds the string denoting the modpack_id field in the database. + FieldModpackID = "modpack_id" + // FieldTagID holds the string denoting the tag_id field in the database. + FieldTagID = "tag_id" + // EdgeModpack holds the string denoting the modpack edge name in mutations. + EdgeModpack = "modpack" + // EdgeTag holds the string denoting the tag edge name in mutations. + EdgeTag = "tag" + // ModpackFieldID holds the string denoting the ID field of the Modpack. + ModpackFieldID = "id" + // TagFieldID holds the string denoting the ID field of the Tag. + TagFieldID = "id" + // Table holds the table name of the modpacktag in the database. + Table = "modpack_tags" + // ModpackTable is the table that holds the modpack relation/edge. + ModpackTable = "modpack_tags" + // ModpackInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpackInverseTable = "modpacks" + // ModpackColumn is the table column denoting the modpack relation/edge. + ModpackColumn = "modpack_id" + // TagTable is the table that holds the tag relation/edge. + TagTable = "modpack_tags" + // TagInverseTable is the table name for the Tag entity. + // It exists in this package in order to avoid circular dependency with the "tag" package. + TagInverseTable = "tags" + // TagColumn is the table column denoting the tag relation/edge. + TagColumn = "tag_id" +) + +// Columns holds all SQL columns for modpacktag fields. +var Columns = []string{ + FieldModpackID, + FieldTagID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the ModpackTag queries. +type OrderOption func(*sql.Selector) + +// ByModpackID orders the results by the modpack_id field. +func ByModpackID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModpackID, opts...).ToFunc() +} + +// ByTagID orders the results by the tag_id field. +func ByTagID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTagID, opts...).ToFunc() +} + +// ByModpackField orders the results by modpack field. +func ByModpackField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackStep(), sql.OrderByField(field, opts...)) + } +} + +// ByTagField orders the results by tag field. +func ByTagField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTagStep(), sql.OrderByField(field, opts...)) + } +} +func newModpackStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, ModpackColumn), + sqlgraph.To(ModpackInverseTable, ModpackFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ModpackTable, ModpackColumn), + ) +} +func newTagStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, TagColumn), + sqlgraph.To(TagInverseTable, TagFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TagTable, TagColumn), + ) +} diff --git a/generated/ent/modpacktag/where.go b/generated/ent/modpacktag/where.go new file mode 100644 index 00000000..8b1bc336 --- /dev/null +++ b/generated/ent/modpacktag/where.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package modpacktag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackID applies equality check predicate on the "modpack_id" field. It's identical to ModpackIDEQ. +func ModpackID(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEQ(FieldModpackID, v)) +} + +// TagID applies equality check predicate on the "tag_id" field. It's identical to TagIDEQ. +func TagID(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEQ(FieldTagID, v)) +} + +// ModpackIDEQ applies the EQ predicate on the "modpack_id" field. +func ModpackIDEQ(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEQ(FieldModpackID, v)) +} + +// ModpackIDNEQ applies the NEQ predicate on the "modpack_id" field. +func ModpackIDNEQ(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldNEQ(FieldModpackID, v)) +} + +// ModpackIDIn applies the In predicate on the "modpack_id" field. +func ModpackIDIn(vs ...string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldIn(FieldModpackID, vs...)) +} + +// ModpackIDNotIn applies the NotIn predicate on the "modpack_id" field. +func ModpackIDNotIn(vs ...string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldNotIn(FieldModpackID, vs...)) +} + +// ModpackIDGT applies the GT predicate on the "modpack_id" field. +func ModpackIDGT(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldGT(FieldModpackID, v)) +} + +// ModpackIDGTE applies the GTE predicate on the "modpack_id" field. +func ModpackIDGTE(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldGTE(FieldModpackID, v)) +} + +// ModpackIDLT applies the LT predicate on the "modpack_id" field. +func ModpackIDLT(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldLT(FieldModpackID, v)) +} + +// ModpackIDLTE applies the LTE predicate on the "modpack_id" field. +func ModpackIDLTE(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldLTE(FieldModpackID, v)) +} + +// ModpackIDContains applies the Contains predicate on the "modpack_id" field. +func ModpackIDContains(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldContains(FieldModpackID, v)) +} + +// ModpackIDHasPrefix applies the HasPrefix predicate on the "modpack_id" field. +func ModpackIDHasPrefix(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldHasPrefix(FieldModpackID, v)) +} + +// ModpackIDHasSuffix applies the HasSuffix predicate on the "modpack_id" field. +func ModpackIDHasSuffix(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldHasSuffix(FieldModpackID, v)) +} + +// ModpackIDEqualFold applies the EqualFold predicate on the "modpack_id" field. +func ModpackIDEqualFold(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEqualFold(FieldModpackID, v)) +} + +// ModpackIDContainsFold applies the ContainsFold predicate on the "modpack_id" field. +func ModpackIDContainsFold(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldContainsFold(FieldModpackID, v)) +} + +// TagIDEQ applies the EQ predicate on the "tag_id" field. +func TagIDEQ(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEQ(FieldTagID, v)) +} + +// TagIDNEQ applies the NEQ predicate on the "tag_id" field. +func TagIDNEQ(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldNEQ(FieldTagID, v)) +} + +// TagIDIn applies the In predicate on the "tag_id" field. +func TagIDIn(vs ...string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldIn(FieldTagID, vs...)) +} + +// TagIDNotIn applies the NotIn predicate on the "tag_id" field. +func TagIDNotIn(vs ...string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldNotIn(FieldTagID, vs...)) +} + +// TagIDGT applies the GT predicate on the "tag_id" field. +func TagIDGT(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldGT(FieldTagID, v)) +} + +// TagIDGTE applies the GTE predicate on the "tag_id" field. +func TagIDGTE(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldGTE(FieldTagID, v)) +} + +// TagIDLT applies the LT predicate on the "tag_id" field. +func TagIDLT(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldLT(FieldTagID, v)) +} + +// TagIDLTE applies the LTE predicate on the "tag_id" field. +func TagIDLTE(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldLTE(FieldTagID, v)) +} + +// TagIDContains applies the Contains predicate on the "tag_id" field. +func TagIDContains(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldContains(FieldTagID, v)) +} + +// TagIDHasPrefix applies the HasPrefix predicate on the "tag_id" field. +func TagIDHasPrefix(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldHasPrefix(FieldTagID, v)) +} + +// TagIDHasSuffix applies the HasSuffix predicate on the "tag_id" field. +func TagIDHasSuffix(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldHasSuffix(FieldTagID, v)) +} + +// TagIDEqualFold applies the EqualFold predicate on the "tag_id" field. +func TagIDEqualFold(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldEqualFold(FieldTagID, v)) +} + +// TagIDContainsFold applies the ContainsFold predicate on the "tag_id" field. +func TagIDContainsFold(v string) predicate.ModpackTag { + return predicate.ModpackTag(sql.FieldContainsFold(FieldTagID, v)) +} + +// HasModpack applies the HasEdge predicate on the "modpack" edge. +func HasModpack() predicate.ModpackTag { + return predicate.ModpackTag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, ModpackColumn), + sqlgraph.Edge(sqlgraph.M2O, false, ModpackTable, ModpackColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackWith applies the HasEdge predicate on the "modpack" edge with a given conditions (other predicates). +func HasModpackWith(preds ...predicate.Modpack) predicate.ModpackTag { + return predicate.ModpackTag(func(s *sql.Selector) { + step := newModpackStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTag applies the HasEdge predicate on the "tag" edge. +func HasTag() predicate.ModpackTag { + return predicate.ModpackTag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, TagColumn), + sqlgraph.Edge(sqlgraph.M2O, false, TagTable, TagColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTagWith applies the HasEdge predicate on the "tag" edge with a given conditions (other predicates). +func HasTagWith(preds ...predicate.Tag) predicate.ModpackTag { + return predicate.ModpackTag(func(s *sql.Selector) { + step := newTagStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ModpackTag) predicate.ModpackTag { + return predicate.ModpackTag(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ModpackTag) predicate.ModpackTag { + return predicate.ModpackTag(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ModpackTag) predicate.ModpackTag { + return predicate.ModpackTag(sql.NotPredicates(p)) +} diff --git a/generated/ent/modpacktag_create.go b/generated/ent/modpacktag_create.go new file mode 100644 index 00000000..fd8b5063 --- /dev/null +++ b/generated/ent/modpacktag_create.go @@ -0,0 +1,524 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackTagCreate is the builder for creating a ModpackTag entity. +type ModpackTagCreate struct { + config + mutation *ModpackTagMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetModpackID sets the "modpack_id" field. +func (mtc *ModpackTagCreate) SetModpackID(s string) *ModpackTagCreate { + mtc.mutation.SetModpackID(s) + return mtc +} + +// SetTagID sets the "tag_id" field. +func (mtc *ModpackTagCreate) SetTagID(s string) *ModpackTagCreate { + mtc.mutation.SetTagID(s) + return mtc +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtc *ModpackTagCreate) SetModpack(m *Modpack) *ModpackTagCreate { + return mtc.SetModpackID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtc *ModpackTagCreate) SetTag(t *Tag) *ModpackTagCreate { + return mtc.SetTagID(t.ID) +} + +// Mutation returns the ModpackTagMutation object of the builder. +func (mtc *ModpackTagCreate) Mutation() *ModpackTagMutation { + return mtc.mutation +} + +// Save creates the ModpackTag in the database. +func (mtc *ModpackTagCreate) Save(ctx context.Context) (*ModpackTag, error) { + return withHooks(ctx, mtc.sqlSave, mtc.mutation, mtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mtc *ModpackTagCreate) SaveX(ctx context.Context) *ModpackTag { + v, err := mtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtc *ModpackTagCreate) Exec(ctx context.Context) error { + _, err := mtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtc *ModpackTagCreate) ExecX(ctx context.Context) { + if err := mtc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtc *ModpackTagCreate) check() error { + if _, ok := mtc.mutation.ModpackID(); !ok { + return &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing required field "ModpackTag.modpack_id"`)} + } + if _, ok := mtc.mutation.TagID(); !ok { + return &ValidationError{Name: "tag_id", err: errors.New(`ent: missing required field "ModpackTag.tag_id"`)} + } + if len(mtc.mutation.ModpackIDs()) == 0 { + return &ValidationError{Name: "modpack", err: errors.New(`ent: missing required edge "ModpackTag.modpack"`)} + } + if len(mtc.mutation.TagIDs()) == 0 { + return &ValidationError{Name: "tag", err: errors.New(`ent: missing required edge "ModpackTag.tag"`)} + } + return nil +} + +func (mtc *ModpackTagCreate) sqlSave(ctx context.Context) (*ModpackTag, error) { + if err := mtc.check(); err != nil { + return nil, err + } + _node, _spec := mtc.createSpec() + if err := sqlgraph.CreateNode(ctx, mtc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} + +func (mtc *ModpackTagCreate) createSpec() (*ModpackTag, *sqlgraph.CreateSpec) { + var ( + _node = &ModpackTag{config: mtc.config} + _spec = sqlgraph.NewCreateSpec(modpacktag.Table, nil) + ) + _spec.OnConflict = mtc.conflict + if nodes := mtc.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.ModpackTable, + Columns: []string{modpacktag.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ModpackID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := mtc.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.TagTable, + Columns: []string{modpacktag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.TagID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackTag.Create(). +// SetModpackID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackTagUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mtc *ModpackTagCreate) OnConflict(opts ...sql.ConflictOption) *ModpackTagUpsertOne { + mtc.conflict = opts + return &ModpackTagUpsertOne{ + create: mtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtc *ModpackTagCreate) OnConflictColumns(columns ...string) *ModpackTagUpsertOne { + mtc.conflict = append(mtc.conflict, sql.ConflictColumns(columns...)) + return &ModpackTagUpsertOne{ + create: mtc, + } +} + +type ( + // ModpackTagUpsertOne is the builder for "upsert"-ing + // one ModpackTag node. + ModpackTagUpsertOne struct { + create *ModpackTagCreate + } + + // ModpackTagUpsert is the "OnConflict" setter. + ModpackTagUpsert struct { + *sql.UpdateSet + } +) + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTagUpsert) SetModpackID(v string) *ModpackTagUpsert { + u.Set(modpacktag.FieldModpackID, v) + return u +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTagUpsert) UpdateModpackID() *ModpackTagUpsert { + u.SetExcluded(modpacktag.FieldModpackID) + return u +} + +// SetTagID sets the "tag_id" field. +func (u *ModpackTagUpsert) SetTagID(v string) *ModpackTagUpsert { + u.Set(modpacktag.FieldTagID, v) + return u +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModpackTagUpsert) UpdateTagID() *ModpackTagUpsert { + u.SetExcluded(modpacktag.FieldTagID) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModpackTagUpsertOne) UpdateNewValues() *ModpackTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackTagUpsertOne) Ignore() *ModpackTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackTagUpsertOne) DoNothing() *ModpackTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackTagCreate.OnConflict +// documentation for more info. +func (u *ModpackTagUpsertOne) Update(set func(*ModpackTagUpsert)) *ModpackTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTagUpsertOne) SetModpackID(v string) *ModpackTagUpsertOne { + return u.Update(func(s *ModpackTagUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTagUpsertOne) UpdateModpackID() *ModpackTagUpsertOne { + return u.Update(func(s *ModpackTagUpsert) { + s.UpdateModpackID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *ModpackTagUpsertOne) SetTagID(v string) *ModpackTagUpsertOne { + return u.Update(func(s *ModpackTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModpackTagUpsertOne) UpdateTagID() *ModpackTagUpsertOne { + return u.Update(func(s *ModpackTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *ModpackTagUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackTagCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackTagUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// ModpackTagCreateBulk is the builder for creating many ModpackTag entities in bulk. +type ModpackTagCreateBulk struct { + config + err error + builders []*ModpackTagCreate + conflict []sql.ConflictOption +} + +// Save creates the ModpackTag entities in the database. +func (mtcb *ModpackTagCreateBulk) Save(ctx context.Context) ([]*ModpackTag, error) { + if mtcb.err != nil { + return nil, mtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mtcb.builders)) + nodes := make([]*ModpackTag, len(mtcb.builders)) + mutators := make([]Mutator, len(mtcb.builders)) + for i := range mtcb.builders { + func(i int, root context.Context) { + builder := mtcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ModpackTagMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mtcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = mtcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mtcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mtcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mtcb *ModpackTagCreateBulk) SaveX(ctx context.Context) []*ModpackTag { + v, err := mtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtcb *ModpackTagCreateBulk) Exec(ctx context.Context) error { + _, err := mtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtcb *ModpackTagCreateBulk) ExecX(ctx context.Context) { + if err := mtcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackTag.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackTagUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mtcb *ModpackTagCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModpackTagUpsertBulk { + mtcb.conflict = opts + return &ModpackTagUpsertBulk{ + create: mtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtcb *ModpackTagCreateBulk) OnConflictColumns(columns ...string) *ModpackTagUpsertBulk { + mtcb.conflict = append(mtcb.conflict, sql.ConflictColumns(columns...)) + return &ModpackTagUpsertBulk{ + create: mtcb, + } +} + +// ModpackTagUpsertBulk is the builder for "upsert"-ing +// a bulk of ModpackTag nodes. +type ModpackTagUpsertBulk struct { + create *ModpackTagCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModpackTagUpsertBulk) UpdateNewValues() *ModpackTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackTagUpsertBulk) Ignore() *ModpackTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackTagUpsertBulk) DoNothing() *ModpackTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackTagCreateBulk.OnConflict +// documentation for more info. +func (u *ModpackTagUpsertBulk) Update(set func(*ModpackTagUpsert)) *ModpackTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTagUpsertBulk) SetModpackID(v string) *ModpackTagUpsertBulk { + return u.Update(func(s *ModpackTagUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTagUpsertBulk) UpdateModpackID() *ModpackTagUpsertBulk { + return u.Update(func(s *ModpackTagUpsert) { + s.UpdateModpackID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *ModpackTagUpsertBulk) SetTagID(v string) *ModpackTagUpsertBulk { + return u.Update(func(s *ModpackTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModpackTagUpsertBulk) UpdateTagID() *ModpackTagUpsertBulk { + return u.Update(func(s *ModpackTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *ModpackTagUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ModpackTagCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackTagCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackTagUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpacktag_delete.go b/generated/ent/modpacktag_delete.go new file mode 100644 index 00000000..95711196 --- /dev/null +++ b/generated/ent/modpacktag_delete.go @@ -0,0 +1,87 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackTagDelete is the builder for deleting a ModpackTag entity. +type ModpackTagDelete struct { + config + hooks []Hook + mutation *ModpackTagMutation +} + +// Where appends a list predicates to the ModpackTagDelete builder. +func (mtd *ModpackTagDelete) Where(ps ...predicate.ModpackTag) *ModpackTagDelete { + mtd.mutation.Where(ps...) + return mtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mtd *ModpackTagDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, mtd.sqlExec, mtd.mutation, mtd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtd *ModpackTagDelete) ExecX(ctx context.Context) int { + n, err := mtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mtd *ModpackTagDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modpacktag.Table, nil) + if ps := mtd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, mtd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + mtd.mutation.done = true + return affected, err +} + +// ModpackTagDeleteOne is the builder for deleting a single ModpackTag entity. +type ModpackTagDeleteOne struct { + mtd *ModpackTagDelete +} + +// Where appends a list predicates to the ModpackTagDelete builder. +func (mtdo *ModpackTagDeleteOne) Where(ps ...predicate.ModpackTag) *ModpackTagDeleteOne { + mtdo.mtd.mutation.Where(ps...) + return mtdo +} + +// Exec executes the deletion query. +func (mtdo *ModpackTagDeleteOne) Exec(ctx context.Context) error { + n, err := mtdo.mtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modpacktag.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtdo *ModpackTagDeleteOne) ExecX(ctx context.Context) { + if err := mtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpacktag_query.go b/generated/ent/modpacktag_query.go new file mode 100644 index 00000000..45a6abbf --- /dev/null +++ b/generated/ent/modpacktag_query.go @@ -0,0 +1,626 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackTagQuery is the builder for querying ModpackTag entities. +type ModpackTagQuery struct { + config + ctx *QueryContext + order []modpacktag.OrderOption + inters []Interceptor + predicates []predicate.ModpackTag + withModpack *ModpackQuery + withTag *TagQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ModpackTagQuery builder. +func (mtq *ModpackTagQuery) Where(ps ...predicate.ModpackTag) *ModpackTagQuery { + mtq.predicates = append(mtq.predicates, ps...) + return mtq +} + +// Limit the number of records to be returned by this query. +func (mtq *ModpackTagQuery) Limit(limit int) *ModpackTagQuery { + mtq.ctx.Limit = &limit + return mtq +} + +// Offset to start from. +func (mtq *ModpackTagQuery) Offset(offset int) *ModpackTagQuery { + mtq.ctx.Offset = &offset + return mtq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mtq *ModpackTagQuery) Unique(unique bool) *ModpackTagQuery { + mtq.ctx.Unique = &unique + return mtq +} + +// Order specifies how the records should be ordered. +func (mtq *ModpackTagQuery) Order(o ...modpacktag.OrderOption) *ModpackTagQuery { + mtq.order = append(mtq.order, o...) + return mtq +} + +// QueryModpack chains the current query on the "modpack" edge. +func (mtq *ModpackTagQuery) QueryModpack() *ModpackQuery { + query := (&ModpackClient{config: mtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpacktag.Table, modpacktag.ModpackColumn, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modpacktag.ModpackTable, modpacktag.ModpackColumn), + ) + fromU = sqlgraph.SetNeighbors(mtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTag chains the current query on the "tag" edge. +func (mtq *ModpackTagQuery) QueryTag() *TagQuery { + query := (&TagClient{config: mtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpacktag.Table, modpacktag.TagColumn, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modpacktag.TagTable, modpacktag.TagColumn), + ) + fromU = sqlgraph.SetNeighbors(mtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ModpackTag entity from the query. +// Returns a *NotFoundError when no ModpackTag was found. +func (mtq *ModpackTagQuery) First(ctx context.Context) (*ModpackTag, error) { + nodes, err := mtq.Limit(1).All(setContextOp(ctx, mtq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modpacktag.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mtq *ModpackTagQuery) FirstX(ctx context.Context) *ModpackTag { + node, err := mtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single ModpackTag entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ModpackTag entity is found. +// Returns a *NotFoundError when no ModpackTag entities are found. +func (mtq *ModpackTagQuery) Only(ctx context.Context) (*ModpackTag, error) { + nodes, err := mtq.Limit(2).All(setContextOp(ctx, mtq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modpacktag.Label} + default: + return nil, &NotSingularError{modpacktag.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mtq *ModpackTagQuery) OnlyX(ctx context.Context) *ModpackTag { + node, err := mtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of ModpackTags. +func (mtq *ModpackTagQuery) All(ctx context.Context) ([]*ModpackTag, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryAll) + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ModpackTag, *ModpackTagQuery]() + return withInterceptors[[]*ModpackTag](ctx, mtq, qr, mtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mtq *ModpackTagQuery) AllX(ctx context.Context) []*ModpackTag { + nodes, err := mtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (mtq *ModpackTagQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryCount) + if err := mtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mtq, querierCount[*ModpackTagQuery](), mtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mtq *ModpackTagQuery) CountX(ctx context.Context) int { + count, err := mtq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mtq *ModpackTagQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryExist) + switch _, err := mtq.First(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mtq *ModpackTagQuery) ExistX(ctx context.Context) bool { + exist, err := mtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModpackTagQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mtq *ModpackTagQuery) Clone() *ModpackTagQuery { + if mtq == nil { + return nil + } + return &ModpackTagQuery{ + config: mtq.config, + ctx: mtq.ctx.Clone(), + order: append([]modpacktag.OrderOption{}, mtq.order...), + inters: append([]Interceptor{}, mtq.inters...), + predicates: append([]predicate.ModpackTag{}, mtq.predicates...), + withModpack: mtq.withModpack.Clone(), + withTag: mtq.withTag.Clone(), + // clone intermediate query. + sql: mtq.sql.Clone(), + path: mtq.path, + modifiers: append([]func(*sql.Selector){}, mtq.modifiers...), + } +} + +// WithModpack tells the query-builder to eager-load the nodes that are connected to +// the "modpack" edge. The optional arguments are used to configure the query builder of the edge. +func (mtq *ModpackTagQuery) WithModpack(opts ...func(*ModpackQuery)) *ModpackTagQuery { + query := (&ModpackClient{config: mtq.config}).Query() + for _, opt := range opts { + opt(query) + } + mtq.withModpack = query + return mtq +} + +// WithTag tells the query-builder to eager-load the nodes that are connected to +// the "tag" edge. The optional arguments are used to configure the query builder of the edge. +func (mtq *ModpackTagQuery) WithTag(opts ...func(*TagQuery)) *ModpackTagQuery { + query := (&TagClient{config: mtq.config}).Query() + for _, opt := range opts { + opt(query) + } + mtq.withTag = query + return mtq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ModpackTag.Query(). +// GroupBy(modpacktag.FieldModpackID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mtq *ModpackTagQuery) GroupBy(field string, fields ...string) *ModpackTagGroupBy { + mtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModpackTagGroupBy{build: mtq} + grbuild.flds = &mtq.ctx.Fields + grbuild.label = modpacktag.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// } +// +// client.ModpackTag.Query(). +// Select(modpacktag.FieldModpackID). +// Scan(ctx, &v) +func (mtq *ModpackTagQuery) Select(fields ...string) *ModpackTagSelect { + mtq.ctx.Fields = append(mtq.ctx.Fields, fields...) + sbuild := &ModpackTagSelect{ModpackTagQuery: mtq} + sbuild.label = modpacktag.Label + sbuild.flds, sbuild.scan = &mtq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModpackTagSelect configured with the given aggregations. +func (mtq *ModpackTagQuery) Aggregate(fns ...AggregateFunc) *ModpackTagSelect { + return mtq.Select().Aggregate(fns...) +} + +func (mtq *ModpackTagQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mtq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mtq); err != nil { + return err + } + } + } + for _, f := range mtq.ctx.Fields { + if !modpacktag.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mtq.path != nil { + prev, err := mtq.path(ctx) + if err != nil { + return err + } + mtq.sql = prev + } + return nil +} + +func (mtq *ModpackTagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ModpackTag, error) { + var ( + nodes = []*ModpackTag{} + _spec = mtq.querySpec() + loadedTypes = [2]bool{ + mtq.withModpack != nil, + mtq.withTag != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ModpackTag).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ModpackTag{config: mtq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mtq.modifiers) > 0 { + _spec.Modifiers = mtq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mtq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mtq.withModpack; query != nil { + if err := mtq.loadModpack(ctx, query, nodes, nil, + func(n *ModpackTag, e *Modpack) { n.Edges.Modpack = e }); err != nil { + return nil, err + } + } + if query := mtq.withTag; query != nil { + if err := mtq.loadTag(ctx, query, nodes, nil, + func(n *ModpackTag, e *Tag) { n.Edges.Tag = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mtq *ModpackTagQuery) loadModpack(ctx context.Context, query *ModpackQuery, nodes []*ModpackTag, init func(*ModpackTag), assign func(*ModpackTag, *Modpack)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackTag) + for i := range nodes { + fk := nodes[i].ModpackID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(modpack.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "modpack_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (mtq *ModpackTagQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*ModpackTag, init func(*ModpackTag), assign func(*ModpackTag, *Tag)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackTag) + for i := range nodes { + fk := nodes[i].TagID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(tag.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "tag_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (mtq *ModpackTagQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mtq.querySpec() + if len(mtq.modifiers) > 0 { + _spec.Modifiers = mtq.modifiers + } + _spec.Unique = false + _spec.Node.Columns = nil + return sqlgraph.CountNodes(ctx, mtq.driver, _spec) +} + +func (mtq *ModpackTagQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modpacktag.Table, modpacktag.Columns, nil) + _spec.From = mtq.sql + if unique := mtq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mtq.path != nil { + _spec.Unique = true + } + if fields := mtq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + for i := range fields { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + if mtq.withModpack != nil { + _spec.Node.AddColumnOnce(modpacktag.FieldModpackID) + } + if mtq.withTag != nil { + _spec.Node.AddColumnOnce(modpacktag.FieldTagID) + } + } + if ps := mtq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mtq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mtq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mtq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mtq *ModpackTagQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mtq.driver.Dialect()) + t1 := builder.Table(modpacktag.Table) + columns := mtq.ctx.Fields + if len(columns) == 0 { + columns = modpacktag.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mtq.sql != nil { + selector = mtq.sql + selector.Select(selector.Columns(columns...)...) + } + if mtq.ctx.Unique != nil && *mtq.ctx.Unique { + selector.Distinct() + } + for _, m := range mtq.modifiers { + m(selector) + } + for _, p := range mtq.predicates { + p(selector) + } + for _, p := range mtq.order { + p(selector) + } + if offset := mtq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mtq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mtq *ModpackTagQuery) Modify(modifiers ...func(s *sql.Selector)) *ModpackTagSelect { + mtq.modifiers = append(mtq.modifiers, modifiers...) + return mtq.Select() +} + +// ModpackTagGroupBy is the group-by builder for ModpackTag entities. +type ModpackTagGroupBy struct { + selector + build *ModpackTagQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mtgb *ModpackTagGroupBy) Aggregate(fns ...AggregateFunc) *ModpackTagGroupBy { + mtgb.fns = append(mtgb.fns, fns...) + return mtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mtgb *ModpackTagGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mtgb.build.ctx, ent.OpQueryGroupBy) + if err := mtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackTagQuery, *ModpackTagGroupBy](ctx, mtgb.build, mtgb, mtgb.build.inters, v) +} + +func (mtgb *ModpackTagGroupBy) sqlScan(ctx context.Context, root *ModpackTagQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mtgb.fns)) + for _, fn := range mtgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mtgb.flds)+len(mtgb.fns)) + for _, f := range *mtgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mtgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mtgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ModpackTagSelect is the builder for selecting fields of ModpackTag entities. +type ModpackTagSelect struct { + *ModpackTagQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mts *ModpackTagSelect) Aggregate(fns ...AggregateFunc) *ModpackTagSelect { + mts.fns = append(mts.fns, fns...) + return mts +} + +// Scan applies the selector query and scans the result into the given value. +func (mts *ModpackTagSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mts.ctx, ent.OpQuerySelect) + if err := mts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackTagQuery, *ModpackTagSelect](ctx, mts.ModpackTagQuery, mts, mts.inters, v) +} + +func (mts *ModpackTagSelect) sqlScan(ctx context.Context, root *ModpackTagQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(mts.fns)) + for _, fn := range mts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*mts.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mts.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mts *ModpackTagSelect) Modify(modifiers ...func(s *sql.Selector)) *ModpackTagSelect { + mts.modifiers = append(mts.modifiers, modifiers...) + return mts +} diff --git a/generated/ent/modpacktag_update.go b/generated/ent/modpacktag_update.go new file mode 100644 index 00000000..46066be4 --- /dev/null +++ b/generated/ent/modpacktag_update.go @@ -0,0 +1,439 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModpackTagUpdate is the builder for updating ModpackTag entities. +type ModpackTagUpdate struct { + config + hooks []Hook + mutation *ModpackTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModpackTagUpdate builder. +func (mtu *ModpackTagUpdate) Where(ps ...predicate.ModpackTag) *ModpackTagUpdate { + mtu.mutation.Where(ps...) + return mtu +} + +// SetModpackID sets the "modpack_id" field. +func (mtu *ModpackTagUpdate) SetModpackID(s string) *ModpackTagUpdate { + mtu.mutation.SetModpackID(s) + return mtu +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mtu *ModpackTagUpdate) SetNillableModpackID(s *string) *ModpackTagUpdate { + if s != nil { + mtu.SetModpackID(*s) + } + return mtu +} + +// SetTagID sets the "tag_id" field. +func (mtu *ModpackTagUpdate) SetTagID(s string) *ModpackTagUpdate { + mtu.mutation.SetTagID(s) + return mtu +} + +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (mtu *ModpackTagUpdate) SetNillableTagID(s *string) *ModpackTagUpdate { + if s != nil { + mtu.SetTagID(*s) + } + return mtu +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtu *ModpackTagUpdate) SetModpack(m *Modpack) *ModpackTagUpdate { + return mtu.SetModpackID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtu *ModpackTagUpdate) SetTag(t *Tag) *ModpackTagUpdate { + return mtu.SetTagID(t.ID) +} + +// Mutation returns the ModpackTagMutation object of the builder. +func (mtu *ModpackTagUpdate) Mutation() *ModpackTagMutation { + return mtu.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mtu *ModpackTagUpdate) ClearModpack() *ModpackTagUpdate { + mtu.mutation.ClearModpack() + return mtu +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (mtu *ModpackTagUpdate) ClearTag() *ModpackTagUpdate { + mtu.mutation.ClearTag() + return mtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mtu *ModpackTagUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, mtu.sqlSave, mtu.mutation, mtu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mtu *ModpackTagUpdate) SaveX(ctx context.Context) int { + affected, err := mtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mtu *ModpackTagUpdate) Exec(ctx context.Context) error { + _, err := mtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtu *ModpackTagUpdate) ExecX(ctx context.Context) { + if err := mtu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtu *ModpackTagUpdate) check() error { + if mtu.mutation.ModpackCleared() && len(mtu.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTag.modpack"`) + } + if mtu.mutation.TagCleared() && len(mtu.mutation.TagIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtu *ModpackTagUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackTagUpdate { + mtu.modifiers = append(mtu.modifiers, modifiers...) + return mtu +} + +func (mtu *ModpackTagUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modpacktag.Table, modpacktag.Columns, sqlgraph.NewFieldSpec(modpacktag.FieldModpackID, field.TypeString), sqlgraph.NewFieldSpec(modpacktag.FieldTagID, field.TypeString)) + if ps := mtu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if mtu.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.ModpackTable, + Columns: []string{modpacktag.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtu.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.ModpackTable, + Columns: []string{modpacktag.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mtu.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.TagTable, + Columns: []string{modpacktag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtu.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.TagTable, + Columns: []string{modpacktag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mtu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, mtu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpacktag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mtu.mutation.done = true + return n, nil +} + +// ModpackTagUpdateOne is the builder for updating a single ModpackTag entity. +type ModpackTagUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModpackTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetModpackID sets the "modpack_id" field. +func (mtuo *ModpackTagUpdateOne) SetModpackID(s string) *ModpackTagUpdateOne { + mtuo.mutation.SetModpackID(s) + return mtuo +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mtuo *ModpackTagUpdateOne) SetNillableModpackID(s *string) *ModpackTagUpdateOne { + if s != nil { + mtuo.SetModpackID(*s) + } + return mtuo +} + +// SetTagID sets the "tag_id" field. +func (mtuo *ModpackTagUpdateOne) SetTagID(s string) *ModpackTagUpdateOne { + mtuo.mutation.SetTagID(s) + return mtuo +} + +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (mtuo *ModpackTagUpdateOne) SetNillableTagID(s *string) *ModpackTagUpdateOne { + if s != nil { + mtuo.SetTagID(*s) + } + return mtuo +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtuo *ModpackTagUpdateOne) SetModpack(m *Modpack) *ModpackTagUpdateOne { + return mtuo.SetModpackID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtuo *ModpackTagUpdateOne) SetTag(t *Tag) *ModpackTagUpdateOne { + return mtuo.SetTagID(t.ID) +} + +// Mutation returns the ModpackTagMutation object of the builder. +func (mtuo *ModpackTagUpdateOne) Mutation() *ModpackTagMutation { + return mtuo.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mtuo *ModpackTagUpdateOne) ClearModpack() *ModpackTagUpdateOne { + mtuo.mutation.ClearModpack() + return mtuo +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (mtuo *ModpackTagUpdateOne) ClearTag() *ModpackTagUpdateOne { + mtuo.mutation.ClearTag() + return mtuo +} + +// Where appends a list predicates to the ModpackTagUpdate builder. +func (mtuo *ModpackTagUpdateOne) Where(ps ...predicate.ModpackTag) *ModpackTagUpdateOne { + mtuo.mutation.Where(ps...) + return mtuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mtuo *ModpackTagUpdateOne) Select(field string, fields ...string) *ModpackTagUpdateOne { + mtuo.fields = append([]string{field}, fields...) + return mtuo +} + +// Save executes the query and returns the updated ModpackTag entity. +func (mtuo *ModpackTagUpdateOne) Save(ctx context.Context) (*ModpackTag, error) { + return withHooks(ctx, mtuo.sqlSave, mtuo.mutation, mtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mtuo *ModpackTagUpdateOne) SaveX(ctx context.Context) *ModpackTag { + node, err := mtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mtuo *ModpackTagUpdateOne) Exec(ctx context.Context) error { + _, err := mtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtuo *ModpackTagUpdateOne) ExecX(ctx context.Context) { + if err := mtuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtuo *ModpackTagUpdateOne) check() error { + if mtuo.mutation.ModpackCleared() && len(mtuo.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTag.modpack"`) + } + if mtuo.mutation.TagCleared() && len(mtuo.mutation.TagIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtuo *ModpackTagUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackTagUpdateOne { + mtuo.modifiers = append(mtuo.modifiers, modifiers...) + return mtuo +} + +func (mtuo *ModpackTagUpdateOne) sqlSave(ctx context.Context) (_node *ModpackTag, err error) { + if err := mtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modpacktag.Table, modpacktag.Columns, sqlgraph.NewFieldSpec(modpacktag.FieldModpackID, field.TypeString), sqlgraph.NewFieldSpec(modpacktag.FieldTagID, field.TypeString)) + if id, ok := mtuo.mutation.ModpackID(); !ok { + return nil, &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing "ModpackTag.modpack_id" for update`)} + } else { + _spec.Node.CompositeID[0].Value = id + } + if id, ok := mtuo.mutation.TagID(); !ok { + return nil, &ValidationError{Name: "tag_id", err: errors.New(`ent: missing "ModpackTag.tag_id" for update`)} + } else { + _spec.Node.CompositeID[1].Value = id + } + if fields := mtuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, len(fields)) + for i, f := range fields { + if !modpacktag.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + _spec.Node.Columns[i] = f + } + } + if ps := mtuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if mtuo.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.ModpackTable, + Columns: []string{modpacktag.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtuo.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.ModpackTable, + Columns: []string{modpacktag.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if mtuo.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.TagTable, + Columns: []string{modpacktag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtuo.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modpacktag.TagTable, + Columns: []string{modpacktag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mtuo.modifiers...) + _node = &ModpackTag{config: mtuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mtuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpacktag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + mtuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/modpacktarget.go b/generated/ent/modpacktarget.go new file mode 100644 index 00000000..fbdbbf63 --- /dev/null +++ b/generated/ent/modpacktarget.go @@ -0,0 +1,141 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" +) + +// ModpackTarget is the model entity for the ModpackTarget schema. +type ModpackTarget struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // ModpackID holds the value of the "modpack_id" field. + ModpackID string `json:"modpack_id,omitempty"` + // TargetName holds the value of the "target_name" field. + TargetName string `json:"target_name,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModpackTargetQuery when eager-loading is set. + Edges ModpackTargetEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModpackTargetEdges holds the relations/edges for other nodes in the graph. +type ModpackTargetEdges struct { + // Modpack holds the value of the modpack edge. + Modpack *Modpack `json:"modpack,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// ModpackOrErr returns the Modpack value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ModpackTargetEdges) ModpackOrErr() (*Modpack, error) { + if e.Modpack != nil { + return e.Modpack, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: modpack.Label} + } + return nil, &NotLoadedError{edge: "modpack"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ModpackTarget) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modpacktarget.FieldID, modpacktarget.FieldModpackID, modpacktarget.FieldTargetName: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ModpackTarget fields. +func (mt *ModpackTarget) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case modpacktarget.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + mt.ID = value.String + } + case modpacktarget.FieldModpackID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field modpack_id", values[i]) + } else if value.Valid { + mt.ModpackID = value.String + } + case modpacktarget.FieldTargetName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field target_name", values[i]) + } else if value.Valid { + mt.TargetName = value.String + } + default: + mt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ModpackTarget. +// This includes values selected through modifiers, order, etc. +func (mt *ModpackTarget) Value(name string) (ent.Value, error) { + return mt.selectValues.Get(name) +} + +// QueryModpack queries the "modpack" edge of the ModpackTarget entity. +func (mt *ModpackTarget) QueryModpack() *ModpackQuery { + return NewModpackTargetClient(mt.config).QueryModpack(mt) +} + +// Update returns a builder for updating this ModpackTarget. +// Note that you need to call ModpackTarget.Unwrap() before calling this method if this ModpackTarget +// was returned from a transaction, and the transaction was committed or rolled back. +func (mt *ModpackTarget) Update() *ModpackTargetUpdateOne { + return NewModpackTargetClient(mt.config).UpdateOne(mt) +} + +// Unwrap unwraps the ModpackTarget entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (mt *ModpackTarget) Unwrap() *ModpackTarget { + _tx, ok := mt.config.driver.(*txDriver) + if !ok { + panic("ent: ModpackTarget is not a transactional entity") + } + mt.config.driver = _tx.drv + return mt +} + +// String implements the fmt.Stringer. +func (mt *ModpackTarget) String() string { + var builder strings.Builder + builder.WriteString("ModpackTarget(") + builder.WriteString(fmt.Sprintf("id=%v, ", mt.ID)) + builder.WriteString("modpack_id=") + builder.WriteString(mt.ModpackID) + builder.WriteString(", ") + builder.WriteString("target_name=") + builder.WriteString(mt.TargetName) + builder.WriteByte(')') + return builder.String() +} + +// ModpackTargets is a parsable slice of ModpackTarget. +type ModpackTargets []*ModpackTarget diff --git a/generated/ent/modpacktarget/modpacktarget.go b/generated/ent/modpacktarget/modpacktarget.go new file mode 100644 index 00000000..5eaf52c9 --- /dev/null +++ b/generated/ent/modpacktarget/modpacktarget.go @@ -0,0 +1,84 @@ +// Code generated by ent, DO NOT EDIT. + +package modpacktarget + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modpacktarget type in the database. + Label = "modpack_target" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldModpackID holds the string denoting the modpack_id field in the database. + FieldModpackID = "modpack_id" + // FieldTargetName holds the string denoting the target_name field in the database. + FieldTargetName = "target_name" + // EdgeModpack holds the string denoting the modpack edge name in mutations. + EdgeModpack = "modpack" + // Table holds the table name of the modpacktarget in the database. + Table = "modpack_targets" + // ModpackTable is the table that holds the modpack relation/edge. + ModpackTable = "modpack_targets" + // ModpackInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpackInverseTable = "modpacks" + // ModpackColumn is the table column denoting the modpack relation/edge. + ModpackColumn = "modpack_id" +) + +// Columns holds all SQL columns for modpacktarget fields. +var Columns = []string{ + FieldID, + FieldModpackID, + FieldTargetName, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the ModpackTarget queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByModpackID orders the results by the modpack_id field. +func ByModpackID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModpackID, opts...).ToFunc() +} + +// ByTargetName orders the results by the target_name field. +func ByTargetName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTargetName, opts...).ToFunc() +} + +// ByModpackField orders the results by modpack field. +func ByModpackField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackStep(), sql.OrderByField(field, opts...)) + } +} +func newModpackStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModpackTable, ModpackColumn), + ) +} diff --git a/generated/ent/modpacktarget/where.go b/generated/ent/modpacktarget/where.go new file mode 100644 index 00000000..5cc2fe70 --- /dev/null +++ b/generated/ent/modpacktarget/where.go @@ -0,0 +1,242 @@ +// Code generated by ent, DO NOT EDIT. + +package modpacktarget + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldContainsFold(FieldID, id)) +} + +// ModpackID applies equality check predicate on the "modpack_id" field. It's identical to ModpackIDEQ. +func ModpackID(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldModpackID, v)) +} + +// TargetName applies equality check predicate on the "target_name" field. It's identical to TargetNameEQ. +func TargetName(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// ModpackIDEQ applies the EQ predicate on the "modpack_id" field. +func ModpackIDEQ(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldModpackID, v)) +} + +// ModpackIDNEQ applies the NEQ predicate on the "modpack_id" field. +func ModpackIDNEQ(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNEQ(FieldModpackID, v)) +} + +// ModpackIDIn applies the In predicate on the "modpack_id" field. +func ModpackIDIn(vs ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldIn(FieldModpackID, vs...)) +} + +// ModpackIDNotIn applies the NotIn predicate on the "modpack_id" field. +func ModpackIDNotIn(vs ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNotIn(FieldModpackID, vs...)) +} + +// ModpackIDGT applies the GT predicate on the "modpack_id" field. +func ModpackIDGT(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGT(FieldModpackID, v)) +} + +// ModpackIDGTE applies the GTE predicate on the "modpack_id" field. +func ModpackIDGTE(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGTE(FieldModpackID, v)) +} + +// ModpackIDLT applies the LT predicate on the "modpack_id" field. +func ModpackIDLT(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLT(FieldModpackID, v)) +} + +// ModpackIDLTE applies the LTE predicate on the "modpack_id" field. +func ModpackIDLTE(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLTE(FieldModpackID, v)) +} + +// ModpackIDContains applies the Contains predicate on the "modpack_id" field. +func ModpackIDContains(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldContains(FieldModpackID, v)) +} + +// ModpackIDHasPrefix applies the HasPrefix predicate on the "modpack_id" field. +func ModpackIDHasPrefix(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldHasPrefix(FieldModpackID, v)) +} + +// ModpackIDHasSuffix applies the HasSuffix predicate on the "modpack_id" field. +func ModpackIDHasSuffix(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldHasSuffix(FieldModpackID, v)) +} + +// ModpackIDEqualFold applies the EqualFold predicate on the "modpack_id" field. +func ModpackIDEqualFold(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEqualFold(FieldModpackID, v)) +} + +// ModpackIDContainsFold applies the ContainsFold predicate on the "modpack_id" field. +func ModpackIDContainsFold(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldContainsFold(FieldModpackID, v)) +} + +// TargetNameEQ applies the EQ predicate on the "target_name" field. +func TargetNameEQ(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// TargetNameNEQ applies the NEQ predicate on the "target_name" field. +func TargetNameNEQ(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNEQ(FieldTargetName, v)) +} + +// TargetNameIn applies the In predicate on the "target_name" field. +func TargetNameIn(vs ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldIn(FieldTargetName, vs...)) +} + +// TargetNameNotIn applies the NotIn predicate on the "target_name" field. +func TargetNameNotIn(vs ...string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldNotIn(FieldTargetName, vs...)) +} + +// TargetNameGT applies the GT predicate on the "target_name" field. +func TargetNameGT(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGT(FieldTargetName, v)) +} + +// TargetNameGTE applies the GTE predicate on the "target_name" field. +func TargetNameGTE(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldGTE(FieldTargetName, v)) +} + +// TargetNameLT applies the LT predicate on the "target_name" field. +func TargetNameLT(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLT(FieldTargetName, v)) +} + +// TargetNameLTE applies the LTE predicate on the "target_name" field. +func TargetNameLTE(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldLTE(FieldTargetName, v)) +} + +// TargetNameContains applies the Contains predicate on the "target_name" field. +func TargetNameContains(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldContains(FieldTargetName, v)) +} + +// TargetNameHasPrefix applies the HasPrefix predicate on the "target_name" field. +func TargetNameHasPrefix(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldHasPrefix(FieldTargetName, v)) +} + +// TargetNameHasSuffix applies the HasSuffix predicate on the "target_name" field. +func TargetNameHasSuffix(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldHasSuffix(FieldTargetName, v)) +} + +// TargetNameEqualFold applies the EqualFold predicate on the "target_name" field. +func TargetNameEqualFold(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldEqualFold(FieldTargetName, v)) +} + +// TargetNameContainsFold applies the ContainsFold predicate on the "target_name" field. +func TargetNameContainsFold(v string) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.FieldContainsFold(FieldTargetName, v)) +} + +// HasModpack applies the HasEdge predicate on the "modpack" edge. +func HasModpack() predicate.ModpackTarget { + return predicate.ModpackTarget(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModpackTable, ModpackColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackWith applies the HasEdge predicate on the "modpack" edge with a given conditions (other predicates). +func HasModpackWith(preds ...predicate.Modpack) predicate.ModpackTarget { + return predicate.ModpackTarget(func(s *sql.Selector) { + step := newModpackStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ModpackTarget) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ModpackTarget) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ModpackTarget) predicate.ModpackTarget { + return predicate.ModpackTarget(sql.NotPredicates(p)) +} diff --git a/generated/ent/modpacktarget_create.go b/generated/ent/modpacktarget_create.go new file mode 100644 index 00000000..2df7254e --- /dev/null +++ b/generated/ent/modpacktarget_create.go @@ -0,0 +1,582 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" +) + +// ModpackTargetCreate is the builder for creating a ModpackTarget entity. +type ModpackTargetCreate struct { + config + mutation *ModpackTargetMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetModpackID sets the "modpack_id" field. +func (mtc *ModpackTargetCreate) SetModpackID(s string) *ModpackTargetCreate { + mtc.mutation.SetModpackID(s) + return mtc +} + +// SetTargetName sets the "target_name" field. +func (mtc *ModpackTargetCreate) SetTargetName(s string) *ModpackTargetCreate { + mtc.mutation.SetTargetName(s) + return mtc +} + +// SetID sets the "id" field. +func (mtc *ModpackTargetCreate) SetID(s string) *ModpackTargetCreate { + mtc.mutation.SetID(s) + return mtc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (mtc *ModpackTargetCreate) SetNillableID(s *string) *ModpackTargetCreate { + if s != nil { + mtc.SetID(*s) + } + return mtc +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtc *ModpackTargetCreate) SetModpack(m *Modpack) *ModpackTargetCreate { + return mtc.SetModpackID(m.ID) +} + +// Mutation returns the ModpackTargetMutation object of the builder. +func (mtc *ModpackTargetCreate) Mutation() *ModpackTargetMutation { + return mtc.mutation +} + +// Save creates the ModpackTarget in the database. +func (mtc *ModpackTargetCreate) Save(ctx context.Context) (*ModpackTarget, error) { + mtc.defaults() + return withHooks(ctx, mtc.sqlSave, mtc.mutation, mtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mtc *ModpackTargetCreate) SaveX(ctx context.Context) *ModpackTarget { + v, err := mtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtc *ModpackTargetCreate) Exec(ctx context.Context) error { + _, err := mtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtc *ModpackTargetCreate) ExecX(ctx context.Context) { + if err := mtc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (mtc *ModpackTargetCreate) defaults() { + if _, ok := mtc.mutation.ID(); !ok { + v := modpacktarget.DefaultID() + mtc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtc *ModpackTargetCreate) check() error { + if _, ok := mtc.mutation.ModpackID(); !ok { + return &ValidationError{Name: "modpack_id", err: errors.New(`ent: missing required field "ModpackTarget.modpack_id"`)} + } + if _, ok := mtc.mutation.TargetName(); !ok { + return &ValidationError{Name: "target_name", err: errors.New(`ent: missing required field "ModpackTarget.target_name"`)} + } + if len(mtc.mutation.ModpackIDs()) == 0 { + return &ValidationError{Name: "modpack", err: errors.New(`ent: missing required edge "ModpackTarget.modpack"`)} + } + return nil +} + +func (mtc *ModpackTargetCreate) sqlSave(ctx context.Context) (*ModpackTarget, error) { + if err := mtc.check(); err != nil { + return nil, err + } + _node, _spec := mtc.createSpec() + if err := sqlgraph.CreateNode(ctx, mtc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected ModpackTarget.ID type: %T", _spec.ID.Value) + } + } + mtc.mutation.id = &_node.ID + mtc.mutation.done = true + return _node, nil +} + +func (mtc *ModpackTargetCreate) createSpec() (*ModpackTarget, *sqlgraph.CreateSpec) { + var ( + _node = &ModpackTarget{config: mtc.config} + _spec = sqlgraph.NewCreateSpec(modpacktarget.Table, sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString)) + ) + _spec.OnConflict = mtc.conflict + if id, ok := mtc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := mtc.mutation.TargetName(); ok { + _spec.SetField(modpacktarget.FieldTargetName, field.TypeString, value) + _node.TargetName = value + } + if nodes := mtc.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpacktarget.ModpackTable, + Columns: []string{modpacktarget.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ModpackID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackTarget.Create(). +// SetModpackID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackTargetUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mtc *ModpackTargetCreate) OnConflict(opts ...sql.ConflictOption) *ModpackTargetUpsertOne { + mtc.conflict = opts + return &ModpackTargetUpsertOne{ + create: mtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtc *ModpackTargetCreate) OnConflictColumns(columns ...string) *ModpackTargetUpsertOne { + mtc.conflict = append(mtc.conflict, sql.ConflictColumns(columns...)) + return &ModpackTargetUpsertOne{ + create: mtc, + } +} + +type ( + // ModpackTargetUpsertOne is the builder for "upsert"-ing + // one ModpackTarget node. + ModpackTargetUpsertOne struct { + create *ModpackTargetCreate + } + + // ModpackTargetUpsert is the "OnConflict" setter. + ModpackTargetUpsert struct { + *sql.UpdateSet + } +) + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTargetUpsert) SetModpackID(v string) *ModpackTargetUpsert { + u.Set(modpacktarget.FieldModpackID, v) + return u +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTargetUpsert) UpdateModpackID() *ModpackTargetUpsert { + u.SetExcluded(modpacktarget.FieldModpackID) + return u +} + +// SetTargetName sets the "target_name" field. +func (u *ModpackTargetUpsert) SetTargetName(v string) *ModpackTargetUpsert { + u.Set(modpacktarget.FieldTargetName, v) + return u +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *ModpackTargetUpsert) UpdateTargetName() *ModpackTargetUpsert { + u.SetExcluded(modpacktarget.FieldTargetName) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpacktarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackTargetUpsertOne) UpdateNewValues() *ModpackTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(modpacktarget.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackTargetUpsertOne) Ignore() *ModpackTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackTargetUpsertOne) DoNothing() *ModpackTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackTargetCreate.OnConflict +// documentation for more info. +func (u *ModpackTargetUpsertOne) Update(set func(*ModpackTargetUpsert)) *ModpackTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTargetUpsertOne) SetModpackID(v string) *ModpackTargetUpsertOne { + return u.Update(func(s *ModpackTargetUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTargetUpsertOne) UpdateModpackID() *ModpackTargetUpsertOne { + return u.Update(func(s *ModpackTargetUpsert) { + s.UpdateModpackID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *ModpackTargetUpsertOne) SetTargetName(v string) *ModpackTargetUpsertOne { + return u.Update(func(s *ModpackTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *ModpackTargetUpsertOne) UpdateTargetName() *ModpackTargetUpsertOne { + return u.Update(func(s *ModpackTargetUpsert) { + s.UpdateTargetName() + }) +} + +// Exec executes the query. +func (u *ModpackTargetUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackTargetCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackTargetUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *ModpackTargetUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: ModpackTargetUpsertOne.ID is not supported by MySQL driver. Use ModpackTargetUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *ModpackTargetUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ModpackTargetCreateBulk is the builder for creating many ModpackTarget entities in bulk. +type ModpackTargetCreateBulk struct { + config + err error + builders []*ModpackTargetCreate + conflict []sql.ConflictOption +} + +// Save creates the ModpackTarget entities in the database. +func (mtcb *ModpackTargetCreateBulk) Save(ctx context.Context) ([]*ModpackTarget, error) { + if mtcb.err != nil { + return nil, mtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mtcb.builders)) + nodes := make([]*ModpackTarget, len(mtcb.builders)) + mutators := make([]Mutator, len(mtcb.builders)) + for i := range mtcb.builders { + func(i int, root context.Context) { + builder := mtcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ModpackTargetMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mtcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = mtcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mtcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mtcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mtcb *ModpackTargetCreateBulk) SaveX(ctx context.Context) []*ModpackTarget { + v, err := mtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtcb *ModpackTargetCreateBulk) Exec(ctx context.Context) error { + _, err := mtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtcb *ModpackTargetCreateBulk) ExecX(ctx context.Context) { + if err := mtcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModpackTarget.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.ModpackTargetUpsert) { +// SetModpackID(v+v). +// }). +// Exec(ctx) +func (mtcb *ModpackTargetCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModpackTargetUpsertBulk { + mtcb.conflict = opts + return &ModpackTargetUpsertBulk{ + create: mtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtcb *ModpackTargetCreateBulk) OnConflictColumns(columns ...string) *ModpackTargetUpsertBulk { + mtcb.conflict = append(mtcb.conflict, sql.ConflictColumns(columns...)) + return &ModpackTargetUpsertBulk{ + create: mtcb, + } +} + +// ModpackTargetUpsertBulk is the builder for "upsert"-ing +// a bulk of ModpackTarget nodes. +type ModpackTargetUpsertBulk struct { + create *ModpackTargetCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(modpacktarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModpackTargetUpsertBulk) UpdateNewValues() *ModpackTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(modpacktarget.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.ModpackTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModpackTargetUpsertBulk) Ignore() *ModpackTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *ModpackTargetUpsertBulk) DoNothing() *ModpackTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModpackTargetCreateBulk.OnConflict +// documentation for more info. +func (u *ModpackTargetUpsertBulk) Update(set func(*ModpackTargetUpsert)) *ModpackTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModpackTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetModpackID sets the "modpack_id" field. +func (u *ModpackTargetUpsertBulk) SetModpackID(v string) *ModpackTargetUpsertBulk { + return u.Update(func(s *ModpackTargetUpsert) { + s.SetModpackID(v) + }) +} + +// UpdateModpackID sets the "modpack_id" field to the value that was provided on create. +func (u *ModpackTargetUpsertBulk) UpdateModpackID() *ModpackTargetUpsertBulk { + return u.Update(func(s *ModpackTargetUpsert) { + s.UpdateModpackID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *ModpackTargetUpsertBulk) SetTargetName(v string) *ModpackTargetUpsertBulk { + return u.Update(func(s *ModpackTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *ModpackTargetUpsertBulk) UpdateTargetName() *ModpackTargetUpsertBulk { + return u.Update(func(s *ModpackTargetUpsert) { + s.UpdateTargetName() + }) +} + +// Exec executes the query. +func (u *ModpackTargetUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ModpackTargetCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModpackTargetCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModpackTargetUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpacktarget_delete.go b/generated/ent/modpacktarget_delete.go new file mode 100644 index 00000000..b637f2d9 --- /dev/null +++ b/generated/ent/modpacktarget_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackTargetDelete is the builder for deleting a ModpackTarget entity. +type ModpackTargetDelete struct { + config + hooks []Hook + mutation *ModpackTargetMutation +} + +// Where appends a list predicates to the ModpackTargetDelete builder. +func (mtd *ModpackTargetDelete) Where(ps ...predicate.ModpackTarget) *ModpackTargetDelete { + mtd.mutation.Where(ps...) + return mtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mtd *ModpackTargetDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, mtd.sqlExec, mtd.mutation, mtd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtd *ModpackTargetDelete) ExecX(ctx context.Context) int { + n, err := mtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mtd *ModpackTargetDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modpacktarget.Table, sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString)) + if ps := mtd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, mtd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + mtd.mutation.done = true + return affected, err +} + +// ModpackTargetDeleteOne is the builder for deleting a single ModpackTarget entity. +type ModpackTargetDeleteOne struct { + mtd *ModpackTargetDelete +} + +// Where appends a list predicates to the ModpackTargetDelete builder. +func (mtdo *ModpackTargetDeleteOne) Where(ps ...predicate.ModpackTarget) *ModpackTargetDeleteOne { + mtdo.mtd.mutation.Where(ps...) + return mtdo +} + +// Exec executes the deletion query. +func (mtdo *ModpackTargetDeleteOne) Exec(ctx context.Context) error { + n, err := mtdo.mtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modpacktarget.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtdo *ModpackTargetDeleteOne) ExecX(ctx context.Context) { + if err := mtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modpacktarget_query.go b/generated/ent/modpacktarget_query.go new file mode 100644 index 00000000..76537ffb --- /dev/null +++ b/generated/ent/modpacktarget_query.go @@ -0,0 +1,629 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackTargetQuery is the builder for querying ModpackTarget entities. +type ModpackTargetQuery struct { + config + ctx *QueryContext + order []modpacktarget.OrderOption + inters []Interceptor + predicates []predicate.ModpackTarget + withModpack *ModpackQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ModpackTargetQuery builder. +func (mtq *ModpackTargetQuery) Where(ps ...predicate.ModpackTarget) *ModpackTargetQuery { + mtq.predicates = append(mtq.predicates, ps...) + return mtq +} + +// Limit the number of records to be returned by this query. +func (mtq *ModpackTargetQuery) Limit(limit int) *ModpackTargetQuery { + mtq.ctx.Limit = &limit + return mtq +} + +// Offset to start from. +func (mtq *ModpackTargetQuery) Offset(offset int) *ModpackTargetQuery { + mtq.ctx.Offset = &offset + return mtq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mtq *ModpackTargetQuery) Unique(unique bool) *ModpackTargetQuery { + mtq.ctx.Unique = &unique + return mtq +} + +// Order specifies how the records should be ordered. +func (mtq *ModpackTargetQuery) Order(o ...modpacktarget.OrderOption) *ModpackTargetQuery { + mtq.order = append(mtq.order, o...) + return mtq +} + +// QueryModpack chains the current query on the "modpack" edge. +func (mtq *ModpackTargetQuery) QueryModpack() *ModpackQuery { + query := (&ModpackClient{config: mtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := mtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(modpacktarget.Table, modpacktarget.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, modpacktarget.ModpackTable, modpacktarget.ModpackColumn), + ) + fromU = sqlgraph.SetNeighbors(mtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ModpackTarget entity from the query. +// Returns a *NotFoundError when no ModpackTarget was found. +func (mtq *ModpackTargetQuery) First(ctx context.Context) (*ModpackTarget, error) { + nodes, err := mtq.Limit(1).All(setContextOp(ctx, mtq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modpacktarget.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mtq *ModpackTargetQuery) FirstX(ctx context.Context) *ModpackTarget { + node, err := mtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ModpackTarget ID from the query. +// Returns a *NotFoundError when no ModpackTarget ID was found. +func (mtq *ModpackTargetQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mtq.Limit(1).IDs(setContextOp(ctx, mtq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{modpacktarget.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mtq *ModpackTargetQuery) FirstIDX(ctx context.Context) string { + id, err := mtq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ModpackTarget entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ModpackTarget entity is found. +// Returns a *NotFoundError when no ModpackTarget entities are found. +func (mtq *ModpackTargetQuery) Only(ctx context.Context) (*ModpackTarget, error) { + nodes, err := mtq.Limit(2).All(setContextOp(ctx, mtq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modpacktarget.Label} + default: + return nil, &NotSingularError{modpacktarget.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mtq *ModpackTargetQuery) OnlyX(ctx context.Context) *ModpackTarget { + node, err := mtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ModpackTarget ID in the query. +// Returns a *NotSingularError when more than one ModpackTarget ID is found. +// Returns a *NotFoundError when no entities are found. +func (mtq *ModpackTargetQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mtq.Limit(2).IDs(setContextOp(ctx, mtq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{modpacktarget.Label} + default: + err = &NotSingularError{modpacktarget.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mtq *ModpackTargetQuery) OnlyIDX(ctx context.Context) string { + id, err := mtq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ModpackTargets. +func (mtq *ModpackTargetQuery) All(ctx context.Context) ([]*ModpackTarget, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryAll) + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ModpackTarget, *ModpackTargetQuery]() + return withInterceptors[[]*ModpackTarget](ctx, mtq, qr, mtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mtq *ModpackTargetQuery) AllX(ctx context.Context) []*ModpackTarget { + nodes, err := mtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ModpackTarget IDs. +func (mtq *ModpackTargetQuery) IDs(ctx context.Context) (ids []string, err error) { + if mtq.ctx.Unique == nil && mtq.path != nil { + mtq.Unique(true) + } + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryIDs) + if err = mtq.Select(modpacktarget.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mtq *ModpackTargetQuery) IDsX(ctx context.Context) []string { + ids, err := mtq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mtq *ModpackTargetQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryCount) + if err := mtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mtq, querierCount[*ModpackTargetQuery](), mtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mtq *ModpackTargetQuery) CountX(ctx context.Context) int { + count, err := mtq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mtq *ModpackTargetQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mtq.ctx, ent.OpQueryExist) + switch _, err := mtq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mtq *ModpackTargetQuery) ExistX(ctx context.Context) bool { + exist, err := mtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModpackTargetQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mtq *ModpackTargetQuery) Clone() *ModpackTargetQuery { + if mtq == nil { + return nil + } + return &ModpackTargetQuery{ + config: mtq.config, + ctx: mtq.ctx.Clone(), + order: append([]modpacktarget.OrderOption{}, mtq.order...), + inters: append([]Interceptor{}, mtq.inters...), + predicates: append([]predicate.ModpackTarget{}, mtq.predicates...), + withModpack: mtq.withModpack.Clone(), + // clone intermediate query. + sql: mtq.sql.Clone(), + path: mtq.path, + modifiers: append([]func(*sql.Selector){}, mtq.modifiers...), + } +} + +// WithModpack tells the query-builder to eager-load the nodes that are connected to +// the "modpack" edge. The optional arguments are used to configure the query builder of the edge. +func (mtq *ModpackTargetQuery) WithModpack(opts ...func(*ModpackQuery)) *ModpackTargetQuery { + query := (&ModpackClient{config: mtq.config}).Query() + for _, opt := range opts { + opt(query) + } + mtq.withModpack = query + return mtq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ModpackTarget.Query(). +// GroupBy(modpacktarget.FieldModpackID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mtq *ModpackTargetQuery) GroupBy(field string, fields ...string) *ModpackTargetGroupBy { + mtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModpackTargetGroupBy{build: mtq} + grbuild.flds = &mtq.ctx.Fields + grbuild.label = modpacktarget.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ModpackID string `json:"modpack_id,omitempty"` +// } +// +// client.ModpackTarget.Query(). +// Select(modpacktarget.FieldModpackID). +// Scan(ctx, &v) +func (mtq *ModpackTargetQuery) Select(fields ...string) *ModpackTargetSelect { + mtq.ctx.Fields = append(mtq.ctx.Fields, fields...) + sbuild := &ModpackTargetSelect{ModpackTargetQuery: mtq} + sbuild.label = modpacktarget.Label + sbuild.flds, sbuild.scan = &mtq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModpackTargetSelect configured with the given aggregations. +func (mtq *ModpackTargetQuery) Aggregate(fns ...AggregateFunc) *ModpackTargetSelect { + return mtq.Select().Aggregate(fns...) +} + +func (mtq *ModpackTargetQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mtq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mtq); err != nil { + return err + } + } + } + for _, f := range mtq.ctx.Fields { + if !modpacktarget.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mtq.path != nil { + prev, err := mtq.path(ctx) + if err != nil { + return err + } + mtq.sql = prev + } + return nil +} + +func (mtq *ModpackTargetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ModpackTarget, error) { + var ( + nodes = []*ModpackTarget{} + _spec = mtq.querySpec() + loadedTypes = [1]bool{ + mtq.withModpack != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ModpackTarget).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ModpackTarget{config: mtq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(mtq.modifiers) > 0 { + _spec.Modifiers = mtq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mtq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := mtq.withModpack; query != nil { + if err := mtq.loadModpack(ctx, query, nodes, nil, + func(n *ModpackTarget, e *Modpack) { n.Edges.Modpack = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mtq *ModpackTargetQuery) loadModpack(ctx context.Context, query *ModpackQuery, nodes []*ModpackTarget, init func(*ModpackTarget), assign func(*ModpackTarget, *Modpack)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModpackTarget) + for i := range nodes { + fk := nodes[i].ModpackID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(modpack.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "modpack_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (mtq *ModpackTargetQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mtq.querySpec() + if len(mtq.modifiers) > 0 { + _spec.Modifiers = mtq.modifiers + } + _spec.Node.Columns = mtq.ctx.Fields + if len(mtq.ctx.Fields) > 0 { + _spec.Unique = mtq.ctx.Unique != nil && *mtq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, mtq.driver, _spec) +} + +func (mtq *ModpackTargetQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modpacktarget.Table, modpacktarget.Columns, sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString)) + _spec.From = mtq.sql + if unique := mtq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mtq.path != nil { + _spec.Unique = true + } + if fields := mtq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpacktarget.FieldID) + for i := range fields { + if fields[i] != modpacktarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if mtq.withModpack != nil { + _spec.Node.AddColumnOnce(modpacktarget.FieldModpackID) + } + } + if ps := mtq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mtq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mtq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mtq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mtq *ModpackTargetQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mtq.driver.Dialect()) + t1 := builder.Table(modpacktarget.Table) + columns := mtq.ctx.Fields + if len(columns) == 0 { + columns = modpacktarget.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mtq.sql != nil { + selector = mtq.sql + selector.Select(selector.Columns(columns...)...) + } + if mtq.ctx.Unique != nil && *mtq.ctx.Unique { + selector.Distinct() + } + for _, m := range mtq.modifiers { + m(selector) + } + for _, p := range mtq.predicates { + p(selector) + } + for _, p := range mtq.order { + p(selector) + } + if offset := mtq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mtq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mtq *ModpackTargetQuery) Modify(modifiers ...func(s *sql.Selector)) *ModpackTargetSelect { + mtq.modifiers = append(mtq.modifiers, modifiers...) + return mtq.Select() +} + +// ModpackTargetGroupBy is the group-by builder for ModpackTarget entities. +type ModpackTargetGroupBy struct { + selector + build *ModpackTargetQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mtgb *ModpackTargetGroupBy) Aggregate(fns ...AggregateFunc) *ModpackTargetGroupBy { + mtgb.fns = append(mtgb.fns, fns...) + return mtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mtgb *ModpackTargetGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mtgb.build.ctx, ent.OpQueryGroupBy) + if err := mtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackTargetQuery, *ModpackTargetGroupBy](ctx, mtgb.build, mtgb, mtgb.build.inters, v) +} + +func (mtgb *ModpackTargetGroupBy) sqlScan(ctx context.Context, root *ModpackTargetQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mtgb.fns)) + for _, fn := range mtgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mtgb.flds)+len(mtgb.fns)) + for _, f := range *mtgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mtgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mtgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ModpackTargetSelect is the builder for selecting fields of ModpackTarget entities. +type ModpackTargetSelect struct { + *ModpackTargetQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mts *ModpackTargetSelect) Aggregate(fns ...AggregateFunc) *ModpackTargetSelect { + mts.fns = append(mts.fns, fns...) + return mts +} + +// Scan applies the selector query and scans the result into the given value. +func (mts *ModpackTargetSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mts.ctx, ent.OpQuerySelect) + if err := mts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModpackTargetQuery, *ModpackTargetSelect](ctx, mts.ModpackTargetQuery, mts, mts.inters, v) +} + +func (mts *ModpackTargetSelect) sqlScan(ctx context.Context, root *ModpackTargetQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(mts.fns)) + for _, fn := range mts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*mts.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mts.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (mts *ModpackTargetSelect) Modify(modifiers ...func(s *sql.Selector)) *ModpackTargetSelect { + mts.modifiers = append(mts.modifiers, modifiers...) + return mts +} diff --git a/generated/ent/modpacktarget_update.go b/generated/ent/modpacktarget_update.go new file mode 100644 index 00000000..11dc0c7f --- /dev/null +++ b/generated/ent/modpacktarget_update.go @@ -0,0 +1,356 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModpackTargetUpdate is the builder for updating ModpackTarget entities. +type ModpackTargetUpdate struct { + config + hooks []Hook + mutation *ModpackTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModpackTargetUpdate builder. +func (mtu *ModpackTargetUpdate) Where(ps ...predicate.ModpackTarget) *ModpackTargetUpdate { + mtu.mutation.Where(ps...) + return mtu +} + +// SetModpackID sets the "modpack_id" field. +func (mtu *ModpackTargetUpdate) SetModpackID(s string) *ModpackTargetUpdate { + mtu.mutation.SetModpackID(s) + return mtu +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mtu *ModpackTargetUpdate) SetNillableModpackID(s *string) *ModpackTargetUpdate { + if s != nil { + mtu.SetModpackID(*s) + } + return mtu +} + +// SetTargetName sets the "target_name" field. +func (mtu *ModpackTargetUpdate) SetTargetName(s string) *ModpackTargetUpdate { + mtu.mutation.SetTargetName(s) + return mtu +} + +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (mtu *ModpackTargetUpdate) SetNillableTargetName(s *string) *ModpackTargetUpdate { + if s != nil { + mtu.SetTargetName(*s) + } + return mtu +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtu *ModpackTargetUpdate) SetModpack(m *Modpack) *ModpackTargetUpdate { + return mtu.SetModpackID(m.ID) +} + +// Mutation returns the ModpackTargetMutation object of the builder. +func (mtu *ModpackTargetUpdate) Mutation() *ModpackTargetMutation { + return mtu.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mtu *ModpackTargetUpdate) ClearModpack() *ModpackTargetUpdate { + mtu.mutation.ClearModpack() + return mtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mtu *ModpackTargetUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, mtu.sqlSave, mtu.mutation, mtu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mtu *ModpackTargetUpdate) SaveX(ctx context.Context) int { + affected, err := mtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mtu *ModpackTargetUpdate) Exec(ctx context.Context) error { + _, err := mtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtu *ModpackTargetUpdate) ExecX(ctx context.Context) { + if err := mtu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtu *ModpackTargetUpdate) check() error { + if mtu.mutation.ModpackCleared() && len(mtu.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTarget.modpack"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtu *ModpackTargetUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackTargetUpdate { + mtu.modifiers = append(mtu.modifiers, modifiers...) + return mtu +} + +func (mtu *ModpackTargetUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modpacktarget.Table, modpacktarget.Columns, sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString)) + if ps := mtu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mtu.mutation.TargetName(); ok { + _spec.SetField(modpacktarget.FieldTargetName, field.TypeString, value) + } + if mtu.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpacktarget.ModpackTable, + Columns: []string{modpacktarget.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtu.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpacktarget.ModpackTable, + Columns: []string{modpacktarget.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mtu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, mtu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpacktarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mtu.mutation.done = true + return n, nil +} + +// ModpackTargetUpdateOne is the builder for updating a single ModpackTarget entity. +type ModpackTargetUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModpackTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetModpackID sets the "modpack_id" field. +func (mtuo *ModpackTargetUpdateOne) SetModpackID(s string) *ModpackTargetUpdateOne { + mtuo.mutation.SetModpackID(s) + return mtuo +} + +// SetNillableModpackID sets the "modpack_id" field if the given value is not nil. +func (mtuo *ModpackTargetUpdateOne) SetNillableModpackID(s *string) *ModpackTargetUpdateOne { + if s != nil { + mtuo.SetModpackID(*s) + } + return mtuo +} + +// SetTargetName sets the "target_name" field. +func (mtuo *ModpackTargetUpdateOne) SetTargetName(s string) *ModpackTargetUpdateOne { + mtuo.mutation.SetTargetName(s) + return mtuo +} + +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (mtuo *ModpackTargetUpdateOne) SetNillableTargetName(s *string) *ModpackTargetUpdateOne { + if s != nil { + mtuo.SetTargetName(*s) + } + return mtuo +} + +// SetModpack sets the "modpack" edge to the Modpack entity. +func (mtuo *ModpackTargetUpdateOne) SetModpack(m *Modpack) *ModpackTargetUpdateOne { + return mtuo.SetModpackID(m.ID) +} + +// Mutation returns the ModpackTargetMutation object of the builder. +func (mtuo *ModpackTargetUpdateOne) Mutation() *ModpackTargetMutation { + return mtuo.mutation +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (mtuo *ModpackTargetUpdateOne) ClearModpack() *ModpackTargetUpdateOne { + mtuo.mutation.ClearModpack() + return mtuo +} + +// Where appends a list predicates to the ModpackTargetUpdate builder. +func (mtuo *ModpackTargetUpdateOne) Where(ps ...predicate.ModpackTarget) *ModpackTargetUpdateOne { + mtuo.mutation.Where(ps...) + return mtuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mtuo *ModpackTargetUpdateOne) Select(field string, fields ...string) *ModpackTargetUpdateOne { + mtuo.fields = append([]string{field}, fields...) + return mtuo +} + +// Save executes the query and returns the updated ModpackTarget entity. +func (mtuo *ModpackTargetUpdateOne) Save(ctx context.Context) (*ModpackTarget, error) { + return withHooks(ctx, mtuo.sqlSave, mtuo.mutation, mtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mtuo *ModpackTargetUpdateOne) SaveX(ctx context.Context) *ModpackTarget { + node, err := mtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mtuo *ModpackTargetUpdateOne) Exec(ctx context.Context) error { + _, err := mtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtuo *ModpackTargetUpdateOne) ExecX(ctx context.Context) { + if err := mtuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mtuo *ModpackTargetUpdateOne) check() error { + if mtuo.mutation.ModpackCleared() && len(mtuo.mutation.ModpackIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ModpackTarget.modpack"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtuo *ModpackTargetUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModpackTargetUpdateOne { + mtuo.modifiers = append(mtuo.modifiers, modifiers...) + return mtuo +} + +func (mtuo *ModpackTargetUpdateOne) sqlSave(ctx context.Context) (_node *ModpackTarget, err error) { + if err := mtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modpacktarget.Table, modpacktarget.Columns, sqlgraph.NewFieldSpec(modpacktarget.FieldID, field.TypeString)) + id, ok := mtuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ModpackTarget.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := mtuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, modpacktarget.FieldID) + for _, f := range fields { + if !modpacktarget.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != modpacktarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := mtuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mtuo.mutation.TargetName(); ok { + _spec.SetField(modpacktarget.FieldTargetName, field.TypeString, value) + } + if mtuo.mutation.ModpackCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpacktarget.ModpackTable, + Columns: []string{modpacktarget.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtuo.mutation.ModpackIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: modpacktarget.ModpackTable, + Columns: []string{modpacktarget.ModpackColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(mtuo.modifiers...) + _node = &ModpackTarget{config: mtuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mtuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{modpacktarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + mtuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/mutation.go b/generated/ent/mutation.go index b74b67dd..c50de16e 100644 --- a/generated/ent/mutation.go +++ b/generated/ent/mutation.go @@ -15,6 +15,11 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackmod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/satisfactoryversion" @@ -44,6 +49,11 @@ const ( TypeGuideTag = "GuideTag" TypeMod = "Mod" TypeModTag = "ModTag" + TypeModpack = "Modpack" + TypeModpackMod = "ModpackMod" + TypeModpackRelease = "ModpackRelease" + TypeModpackTag = "ModpackTag" + TypeModpackTarget = "ModpackTarget" TypeSatisfactoryVersion = "SatisfactoryVersion" TypeTag = "Tag" TypeUser = "User" @@ -1976,6 +1986,9 @@ type ModMutation struct { dependents map[string]struct{} removeddependents map[string]struct{} cleareddependents bool + modpacks map[string]struct{} + removedmodpacks map[string]struct{} + clearedmodpacks bool done bool oldValue func(context.Context) (*Mod, error) predicates []predicate.Mod @@ -3251,6 +3264,60 @@ func (m *ModMutation) ResetDependents() { m.removeddependents = nil } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by ids. +func (m *ModMutation) AddModpackIDs(ids ...string) { + if m.modpacks == nil { + m.modpacks = make(map[string]struct{}) + } + for i := range ids { + m.modpacks[ids[i]] = struct{}{} + } +} + +// ClearModpacks clears the "modpacks" edge to the Modpack entity. +func (m *ModMutation) ClearModpacks() { + m.clearedmodpacks = true +} + +// ModpacksCleared reports if the "modpacks" edge to the Modpack entity was cleared. +func (m *ModMutation) ModpacksCleared() bool { + return m.clearedmodpacks +} + +// RemoveModpackIDs removes the "modpacks" edge to the Modpack entity by IDs. +func (m *ModMutation) RemoveModpackIDs(ids ...string) { + if m.removedmodpacks == nil { + m.removedmodpacks = make(map[string]struct{}) + } + for i := range ids { + delete(m.modpacks, ids[i]) + m.removedmodpacks[ids[i]] = struct{}{} + } +} + +// RemovedModpacks returns the removed IDs of the "modpacks" edge to the Modpack entity. +func (m *ModMutation) RemovedModpacksIDs() (ids []string) { + for id := range m.removedmodpacks { + ids = append(ids, id) + } + return +} + +// ModpacksIDs returns the "modpacks" edge IDs in the mutation. +func (m *ModMutation) ModpacksIDs() (ids []string) { + for id := range m.modpacks { + ids = append(ids, id) + } + return +} + +// ResetModpacks resets all changes to the "modpacks" edge. +func (m *ModMutation) ResetModpacks() { + m.modpacks = nil + m.clearedmodpacks = false + m.removedmodpacks = nil +} + // Where appends a list predicates to the ModMutation builder. func (m *ModMutation) Where(ps ...predicate.Mod) { m.predicates = append(m.predicates, ps...) @@ -3831,7 +3898,7 @@ func (m *ModMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ModMutation) AddedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.versions != nil { edges = append(edges, mod.EdgeVersions) } @@ -3844,6 +3911,9 @@ func (m *ModMutation) AddedEdges() []string { if m.dependents != nil { edges = append(edges, mod.EdgeDependents) } + if m.modpacks != nil { + edges = append(edges, mod.EdgeModpacks) + } return edges } @@ -3875,13 +3945,19 @@ func (m *ModMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case mod.EdgeModpacks: + ids := make([]ent.Value, 0, len(m.modpacks)) + for id := range m.modpacks { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *ModMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.removedversions != nil { edges = append(edges, mod.EdgeVersions) } @@ -3894,6 +3970,9 @@ func (m *ModMutation) RemovedEdges() []string { if m.removeddependents != nil { edges = append(edges, mod.EdgeDependents) } + if m.removedmodpacks != nil { + edges = append(edges, mod.EdgeModpacks) + } return edges } @@ -3925,13 +4004,19 @@ func (m *ModMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case mod.EdgeModpacks: + ids := make([]ent.Value, 0, len(m.removedmodpacks)) + for id := range m.removedmodpacks { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ModMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 5) if m.clearedversions { edges = append(edges, mod.EdgeVersions) } @@ -3944,6 +4029,9 @@ func (m *ModMutation) ClearedEdges() []string { if m.cleareddependents { edges = append(edges, mod.EdgeDependents) } + if m.clearedmodpacks { + edges = append(edges, mod.EdgeModpacks) + } return edges } @@ -3959,6 +4047,8 @@ func (m *ModMutation) EdgeCleared(name string) bool { return m.clearedtags case mod.EdgeDependents: return m.cleareddependents + case mod.EdgeModpacks: + return m.clearedmodpacks } return false } @@ -3987,6 +4077,9 @@ func (m *ModMutation) ResetEdge(name string) error { case mod.EdgeDependents: m.ResetDependents() return nil + case mod.EdgeModpacks: + m.ResetModpacks() + return nil } return fmt.Errorf("unknown Mod edge %s", name) } @@ -4019,15 +4112,3575 @@ func newModTagMutation(c config, op Op, opts ...modtagOption) *ModTagMutation { typ: TypeModTag, clearedFields: make(map[string]struct{}), } - for _, opt := range opts { - opt(m) + for _, opt := range opts { + opt(m) + } + return m +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModTagMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModTagMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetModID sets the "mod_id" field. +func (m *ModTagMutation) SetModID(s string) { + m.mod = &s +} + +// ModID returns the value of the "mod_id" field in the mutation. +func (m *ModTagMutation) ModID() (r string, exists bool) { + v := m.mod + if v == nil { + return + } + return *v, true +} + +// ResetModID resets all changes to the "mod_id" field. +func (m *ModTagMutation) ResetModID() { + m.mod = nil +} + +// SetTagID sets the "tag_id" field. +func (m *ModTagMutation) SetTagID(s string) { + m.tag = &s +} + +// TagID returns the value of the "tag_id" field in the mutation. +func (m *ModTagMutation) TagID() (r string, exists bool) { + v := m.tag + if v == nil { + return + } + return *v, true +} + +// ResetTagID resets all changes to the "tag_id" field. +func (m *ModTagMutation) ResetTagID() { + m.tag = nil +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (m *ModTagMutation) ClearMod() { + m.clearedmod = true + m.clearedFields[modtag.FieldModID] = struct{}{} +} + +// ModCleared reports if the "mod" edge to the Mod entity was cleared. +func (m *ModTagMutation) ModCleared() bool { + return m.clearedmod +} + +// ModIDs returns the "mod" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModID instead. It exists only for internal usage by the builders. +func (m *ModTagMutation) ModIDs() (ids []string) { + if id := m.mod; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMod resets all changes to the "mod" edge. +func (m *ModTagMutation) ResetMod() { + m.mod = nil + m.clearedmod = false +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (m *ModTagMutation) ClearTag() { + m.clearedtag = true + m.clearedFields[modtag.FieldTagID] = struct{}{} +} + +// TagCleared reports if the "tag" edge to the Tag entity was cleared. +func (m *ModTagMutation) TagCleared() bool { + return m.clearedtag +} + +// TagIDs returns the "tag" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TagID instead. It exists only for internal usage by the builders. +func (m *ModTagMutation) TagIDs() (ids []string) { + if id := m.tag; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTag resets all changes to the "tag" edge. +func (m *ModTagMutation) ResetTag() { + m.tag = nil + m.clearedtag = false +} + +// Where appends a list predicates to the ModTagMutation builder. +func (m *ModTagMutation) Where(ps ...predicate.ModTag) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModTagMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModTagMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModTag, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModTagMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModTagMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ModTag). +func (m *ModTagMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ModTagMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.mod != nil { + fields = append(fields, modtag.FieldModID) + } + if m.tag != nil { + fields = append(fields, modtag.FieldTagID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ModTagMutation) Field(name string) (ent.Value, bool) { + switch name { + case modtag.FieldModID: + return m.ModID() + case modtag.FieldTagID: + return m.TagID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ModTagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema ModTag does not support getting old values") +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModTagMutation) SetField(name string, value ent.Value) error { + switch name { + case modtag.FieldModID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModID(v) + return nil + case modtag.FieldTagID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTagID(v) + return nil + } + return fmt.Errorf("unknown ModTag field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModTagMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModTagMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModTagMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ModTag numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModTagMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModTagMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ModTagMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModTag nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ModTagMutation) ResetField(name string) error { + switch name { + case modtag.FieldModID: + m.ResetModID() + return nil + case modtag.FieldTagID: + m.ResetTagID() + return nil + } + return fmt.Errorf("unknown ModTag field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModTagMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.mod != nil { + edges = append(edges, modtag.EdgeMod) + } + if m.tag != nil { + edges = append(edges, modtag.EdgeTag) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModTagMutation) AddedIDs(name string) []ent.Value { + switch name { + case modtag.EdgeMod: + if id := m.mod; id != nil { + return []ent.Value{*id} + } + case modtag.EdgeTag: + if id := m.tag; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ModTagMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModTagMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ModTagMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmod { + edges = append(edges, modtag.EdgeMod) + } + if m.clearedtag { + edges = append(edges, modtag.EdgeTag) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModTagMutation) EdgeCleared(name string) bool { + switch name { + case modtag.EdgeMod: + return m.clearedmod + case modtag.EdgeTag: + return m.clearedtag + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ModTagMutation) ClearEdge(name string) error { + switch name { + case modtag.EdgeMod: + m.ClearMod() + return nil + case modtag.EdgeTag: + m.ClearTag() + return nil + } + return fmt.Errorf("unknown ModTag unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ModTagMutation) ResetEdge(name string) error { + switch name { + case modtag.EdgeMod: + m.ResetMod() + return nil + case modtag.EdgeTag: + m.ResetTag() + return nil + } + return fmt.Errorf("unknown ModTag edge %s", name) +} + +// ModpackMutation represents an operation that mutates the Modpack nodes in the graph. +type ModpackMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + name *string + short_description *string + full_description *string + logo *string + logo_thumbhash *string + creator_id *string + views *uint + addviews *int + hotness *uint + addhotness *int + installs *uint + addinstalls *int + popularity *uint + addpopularity *int + hidden *bool + clearedFields map[string]struct{} + children map[string]struct{} + removedchildren map[string]struct{} + clearedchildren bool + parent *string + clearedparent bool + targets map[string]struct{} + removedtargets map[string]struct{} + clearedtargets bool + releases map[string]struct{} + removedreleases map[string]struct{} + clearedreleases bool + mods map[string]struct{} + removedmods map[string]struct{} + clearedmods bool + tags map[string]struct{} + removedtags map[string]struct{} + clearedtags bool + done bool + oldValue func(context.Context) (*Modpack, error) + predicates []predicate.Modpack +} + +var _ ent.Mutation = (*ModpackMutation)(nil) + +// modpackOption allows management of the mutation configuration using functional options. +type modpackOption func(*ModpackMutation) + +// newModpackMutation creates new mutation for the Modpack entity. +func newModpackMutation(c config, op Op, opts ...modpackOption) *ModpackMutation { + m := &ModpackMutation{ + config: c, + op: op, + typ: TypeModpack, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withModpackID sets the ID field of the mutation. +func withModpackID(id string) modpackOption { + return func(m *ModpackMutation) { + var ( + err error + once sync.Once + value *Modpack + ) + m.oldValue = func(ctx context.Context) (*Modpack, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Modpack.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withModpack sets the old Modpack of the mutation. +func withModpack(node *Modpack) modpackOption { + return func(m *ModpackMutation) { + m.oldValue = func(context.Context) (*Modpack, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModpackMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModpackMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Modpack entities. +func (m *ModpackMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ModpackMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ModpackMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Modpack.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ModpackMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ModpackMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ModpackMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ModpackMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ModpackMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ModpackMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetName sets the "name" field. +func (m *ModpackMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ModpackMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ModpackMutation) ResetName() { + m.name = nil +} + +// SetShortDescription sets the "short_description" field. +func (m *ModpackMutation) SetShortDescription(s string) { + m.short_description = &s +} + +// ShortDescription returns the value of the "short_description" field in the mutation. +func (m *ModpackMutation) ShortDescription() (r string, exists bool) { + v := m.short_description + if v == nil { + return + } + return *v, true +} + +// OldShortDescription returns the old "short_description" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldShortDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldShortDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldShortDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldShortDescription: %w", err) + } + return oldValue.ShortDescription, nil +} + +// ResetShortDescription resets all changes to the "short_description" field. +func (m *ModpackMutation) ResetShortDescription() { + m.short_description = nil +} + +// SetFullDescription sets the "full_description" field. +func (m *ModpackMutation) SetFullDescription(s string) { + m.full_description = &s +} + +// FullDescription returns the value of the "full_description" field in the mutation. +func (m *ModpackMutation) FullDescription() (r string, exists bool) { + v := m.full_description + if v == nil { + return + } + return *v, true +} + +// OldFullDescription returns the old "full_description" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldFullDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFullDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFullDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFullDescription: %w", err) + } + return oldValue.FullDescription, nil +} + +// ResetFullDescription resets all changes to the "full_description" field. +func (m *ModpackMutation) ResetFullDescription() { + m.full_description = nil +} + +// SetLogo sets the "logo" field. +func (m *ModpackMutation) SetLogo(s string) { + m.logo = &s +} + +// Logo returns the value of the "logo" field in the mutation. +func (m *ModpackMutation) Logo() (r string, exists bool) { + v := m.logo + if v == nil { + return + } + return *v, true +} + +// OldLogo returns the old "logo" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldLogo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLogo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLogo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLogo: %w", err) + } + return oldValue.Logo, nil +} + +// ClearLogo clears the value of the "logo" field. +func (m *ModpackMutation) ClearLogo() { + m.logo = nil + m.clearedFields[modpack.FieldLogo] = struct{}{} +} + +// LogoCleared returns if the "logo" field was cleared in this mutation. +func (m *ModpackMutation) LogoCleared() bool { + _, ok := m.clearedFields[modpack.FieldLogo] + return ok +} + +// ResetLogo resets all changes to the "logo" field. +func (m *ModpackMutation) ResetLogo() { + m.logo = nil + delete(m.clearedFields, modpack.FieldLogo) +} + +// SetLogoThumbhash sets the "logo_thumbhash" field. +func (m *ModpackMutation) SetLogoThumbhash(s string) { + m.logo_thumbhash = &s +} + +// LogoThumbhash returns the value of the "logo_thumbhash" field in the mutation. +func (m *ModpackMutation) LogoThumbhash() (r string, exists bool) { + v := m.logo_thumbhash + if v == nil { + return + } + return *v, true +} + +// OldLogoThumbhash returns the old "logo_thumbhash" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldLogoThumbhash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLogoThumbhash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLogoThumbhash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLogoThumbhash: %w", err) + } + return oldValue.LogoThumbhash, nil +} + +// ClearLogoThumbhash clears the value of the "logo_thumbhash" field. +func (m *ModpackMutation) ClearLogoThumbhash() { + m.logo_thumbhash = nil + m.clearedFields[modpack.FieldLogoThumbhash] = struct{}{} +} + +// LogoThumbhashCleared returns if the "logo_thumbhash" field was cleared in this mutation. +func (m *ModpackMutation) LogoThumbhashCleared() bool { + _, ok := m.clearedFields[modpack.FieldLogoThumbhash] + return ok +} + +// ResetLogoThumbhash resets all changes to the "logo_thumbhash" field. +func (m *ModpackMutation) ResetLogoThumbhash() { + m.logo_thumbhash = nil + delete(m.clearedFields, modpack.FieldLogoThumbhash) +} + +// SetCreatorID sets the "creator_id" field. +func (m *ModpackMutation) SetCreatorID(s string) { + m.creator_id = &s +} + +// CreatorID returns the value of the "creator_id" field in the mutation. +func (m *ModpackMutation) CreatorID() (r string, exists bool) { + v := m.creator_id + if v == nil { + return + } + return *v, true +} + +// OldCreatorID returns the old "creator_id" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldCreatorID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatorID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatorID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatorID: %w", err) + } + return oldValue.CreatorID, nil +} + +// ResetCreatorID resets all changes to the "creator_id" field. +func (m *ModpackMutation) ResetCreatorID() { + m.creator_id = nil +} + +// SetViews sets the "views" field. +func (m *ModpackMutation) SetViews(u uint) { + m.views = &u + m.addviews = nil +} + +// Views returns the value of the "views" field in the mutation. +func (m *ModpackMutation) Views() (r uint, exists bool) { + v := m.views + if v == nil { + return + } + return *v, true +} + +// OldViews returns the old "views" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldViews(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldViews is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldViews requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldViews: %w", err) + } + return oldValue.Views, nil +} + +// AddViews adds u to the "views" field. +func (m *ModpackMutation) AddViews(u int) { + if m.addviews != nil { + *m.addviews += u + } else { + m.addviews = &u + } +} + +// AddedViews returns the value that was added to the "views" field in this mutation. +func (m *ModpackMutation) AddedViews() (r int, exists bool) { + v := m.addviews + if v == nil { + return + } + return *v, true +} + +// ResetViews resets all changes to the "views" field. +func (m *ModpackMutation) ResetViews() { + m.views = nil + m.addviews = nil +} + +// SetHotness sets the "hotness" field. +func (m *ModpackMutation) SetHotness(u uint) { + m.hotness = &u + m.addhotness = nil +} + +// Hotness returns the value of the "hotness" field in the mutation. +func (m *ModpackMutation) Hotness() (r uint, exists bool) { + v := m.hotness + if v == nil { + return + } + return *v, true +} + +// OldHotness returns the old "hotness" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldHotness(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHotness is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHotness requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHotness: %w", err) + } + return oldValue.Hotness, nil +} + +// AddHotness adds u to the "hotness" field. +func (m *ModpackMutation) AddHotness(u int) { + if m.addhotness != nil { + *m.addhotness += u + } else { + m.addhotness = &u + } +} + +// AddedHotness returns the value that was added to the "hotness" field in this mutation. +func (m *ModpackMutation) AddedHotness() (r int, exists bool) { + v := m.addhotness + if v == nil { + return + } + return *v, true +} + +// ResetHotness resets all changes to the "hotness" field. +func (m *ModpackMutation) ResetHotness() { + m.hotness = nil + m.addhotness = nil +} + +// SetInstalls sets the "installs" field. +func (m *ModpackMutation) SetInstalls(u uint) { + m.installs = &u + m.addinstalls = nil +} + +// Installs returns the value of the "installs" field in the mutation. +func (m *ModpackMutation) Installs() (r uint, exists bool) { + v := m.installs + if v == nil { + return + } + return *v, true +} + +// OldInstalls returns the old "installs" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldInstalls(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInstalls is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInstalls requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInstalls: %w", err) + } + return oldValue.Installs, nil +} + +// AddInstalls adds u to the "installs" field. +func (m *ModpackMutation) AddInstalls(u int) { + if m.addinstalls != nil { + *m.addinstalls += u + } else { + m.addinstalls = &u + } +} + +// AddedInstalls returns the value that was added to the "installs" field in this mutation. +func (m *ModpackMutation) AddedInstalls() (r int, exists bool) { + v := m.addinstalls + if v == nil { + return + } + return *v, true +} + +// ResetInstalls resets all changes to the "installs" field. +func (m *ModpackMutation) ResetInstalls() { + m.installs = nil + m.addinstalls = nil +} + +// SetPopularity sets the "popularity" field. +func (m *ModpackMutation) SetPopularity(u uint) { + m.popularity = &u + m.addpopularity = nil +} + +// Popularity returns the value of the "popularity" field in the mutation. +func (m *ModpackMutation) Popularity() (r uint, exists bool) { + v := m.popularity + if v == nil { + return + } + return *v, true +} + +// OldPopularity returns the old "popularity" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldPopularity(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPopularity is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPopularity requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPopularity: %w", err) + } + return oldValue.Popularity, nil +} + +// AddPopularity adds u to the "popularity" field. +func (m *ModpackMutation) AddPopularity(u int) { + if m.addpopularity != nil { + *m.addpopularity += u + } else { + m.addpopularity = &u + } +} + +// AddedPopularity returns the value that was added to the "popularity" field in this mutation. +func (m *ModpackMutation) AddedPopularity() (r int, exists bool) { + v := m.addpopularity + if v == nil { + return + } + return *v, true +} + +// ResetPopularity resets all changes to the "popularity" field. +func (m *ModpackMutation) ResetPopularity() { + m.popularity = nil + m.addpopularity = nil +} + +// SetHidden sets the "hidden" field. +func (m *ModpackMutation) SetHidden(b bool) { + m.hidden = &b +} + +// Hidden returns the value of the "hidden" field in the mutation. +func (m *ModpackMutation) Hidden() (r bool, exists bool) { + v := m.hidden + if v == nil { + return + } + return *v, true +} + +// OldHidden returns the old "hidden" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldHidden(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHidden is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHidden requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHidden: %w", err) + } + return oldValue.Hidden, nil +} + +// ResetHidden resets all changes to the "hidden" field. +func (m *ModpackMutation) ResetHidden() { + m.hidden = nil +} + +// SetParentID sets the "parent_id" field. +func (m *ModpackMutation) SetParentID(s string) { + m.parent = &s +} + +// ParentID returns the value of the "parent_id" field in the mutation. +func (m *ModpackMutation) ParentID() (r string, exists bool) { + v := m.parent + if v == nil { + return + } + return *v, true +} + +// OldParentID returns the old "parent_id" field's value of the Modpack entity. +// If the Modpack object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackMutation) OldParentID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentID: %w", err) + } + return oldValue.ParentID, nil +} + +// ClearParentID clears the value of the "parent_id" field. +func (m *ModpackMutation) ClearParentID() { + m.parent = nil + m.clearedFields[modpack.FieldParentID] = struct{}{} +} + +// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. +func (m *ModpackMutation) ParentIDCleared() bool { + _, ok := m.clearedFields[modpack.FieldParentID] + return ok +} + +// ResetParentID resets all changes to the "parent_id" field. +func (m *ModpackMutation) ResetParentID() { + m.parent = nil + delete(m.clearedFields, modpack.FieldParentID) +} + +// AddChildIDs adds the "children" edge to the Modpack entity by ids. +func (m *ModpackMutation) AddChildIDs(ids ...string) { + if m.children == nil { + m.children = make(map[string]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } +} + +// ClearChildren clears the "children" edge to the Modpack entity. +func (m *ModpackMutation) ClearChildren() { + m.clearedchildren = true +} + +// ChildrenCleared reports if the "children" edge to the Modpack entity was cleared. +func (m *ModpackMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Modpack entity by IDs. +func (m *ModpackMutation) RemoveChildIDs(ids ...string) { + if m.removedchildren == nil { + m.removedchildren = make(map[string]struct{}) + } + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} + } +} + +// RemovedChildren returns the removed IDs of the "children" edge to the Modpack entity. +func (m *ModpackMutation) RemovedChildrenIDs() (ids []string) { + for id := range m.removedchildren { + ids = append(ids, id) + } + return +} + +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *ModpackMutation) ChildrenIDs() (ids []string) { + for id := range m.children { + ids = append(ids, id) + } + return +} + +// ResetChildren resets all changes to the "children" edge. +func (m *ModpackMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil +} + +// ClearParent clears the "parent" edge to the Modpack entity. +func (m *ModpackMutation) ClearParent() { + m.clearedparent = true + m.clearedFields[modpack.FieldParentID] = struct{}{} +} + +// ParentCleared reports if the "parent" edge to the Modpack entity was cleared. +func (m *ModpackMutation) ParentCleared() bool { + return m.ParentIDCleared() || m.clearedparent +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ModpackMutation) ParentIDs() (ids []string) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetParent resets all changes to the "parent" edge. +func (m *ModpackMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddTargetIDs adds the "targets" edge to the ModpackTarget entity by ids. +func (m *ModpackMutation) AddTargetIDs(ids ...string) { + if m.targets == nil { + m.targets = make(map[string]struct{}) + } + for i := range ids { + m.targets[ids[i]] = struct{}{} + } +} + +// ClearTargets clears the "targets" edge to the ModpackTarget entity. +func (m *ModpackMutation) ClearTargets() { + m.clearedtargets = true +} + +// TargetsCleared reports if the "targets" edge to the ModpackTarget entity was cleared. +func (m *ModpackMutation) TargetsCleared() bool { + return m.clearedtargets +} + +// RemoveTargetIDs removes the "targets" edge to the ModpackTarget entity by IDs. +func (m *ModpackMutation) RemoveTargetIDs(ids ...string) { + if m.removedtargets == nil { + m.removedtargets = make(map[string]struct{}) + } + for i := range ids { + delete(m.targets, ids[i]) + m.removedtargets[ids[i]] = struct{}{} + } +} + +// RemovedTargets returns the removed IDs of the "targets" edge to the ModpackTarget entity. +func (m *ModpackMutation) RemovedTargetsIDs() (ids []string) { + for id := range m.removedtargets { + ids = append(ids, id) + } + return +} + +// TargetsIDs returns the "targets" edge IDs in the mutation. +func (m *ModpackMutation) TargetsIDs() (ids []string) { + for id := range m.targets { + ids = append(ids, id) + } + return +} + +// ResetTargets resets all changes to the "targets" edge. +func (m *ModpackMutation) ResetTargets() { + m.targets = nil + m.clearedtargets = false + m.removedtargets = nil +} + +// AddReleaseIDs adds the "releases" edge to the ModpackRelease entity by ids. +func (m *ModpackMutation) AddReleaseIDs(ids ...string) { + if m.releases == nil { + m.releases = make(map[string]struct{}) + } + for i := range ids { + m.releases[ids[i]] = struct{}{} + } +} + +// ClearReleases clears the "releases" edge to the ModpackRelease entity. +func (m *ModpackMutation) ClearReleases() { + m.clearedreleases = true +} + +// ReleasesCleared reports if the "releases" edge to the ModpackRelease entity was cleared. +func (m *ModpackMutation) ReleasesCleared() bool { + return m.clearedreleases +} + +// RemoveReleaseIDs removes the "releases" edge to the ModpackRelease entity by IDs. +func (m *ModpackMutation) RemoveReleaseIDs(ids ...string) { + if m.removedreleases == nil { + m.removedreleases = make(map[string]struct{}) + } + for i := range ids { + delete(m.releases, ids[i]) + m.removedreleases[ids[i]] = struct{}{} + } +} + +// RemovedReleases returns the removed IDs of the "releases" edge to the ModpackRelease entity. +func (m *ModpackMutation) RemovedReleasesIDs() (ids []string) { + for id := range m.removedreleases { + ids = append(ids, id) + } + return +} + +// ReleasesIDs returns the "releases" edge IDs in the mutation. +func (m *ModpackMutation) ReleasesIDs() (ids []string) { + for id := range m.releases { + ids = append(ids, id) + } + return +} + +// ResetReleases resets all changes to the "releases" edge. +func (m *ModpackMutation) ResetReleases() { + m.releases = nil + m.clearedreleases = false + m.removedreleases = nil +} + +// AddModIDs adds the "mods" edge to the Mod entity by ids. +func (m *ModpackMutation) AddModIDs(ids ...string) { + if m.mods == nil { + m.mods = make(map[string]struct{}) + } + for i := range ids { + m.mods[ids[i]] = struct{}{} + } +} + +// ClearMods clears the "mods" edge to the Mod entity. +func (m *ModpackMutation) ClearMods() { + m.clearedmods = true +} + +// ModsCleared reports if the "mods" edge to the Mod entity was cleared. +func (m *ModpackMutation) ModsCleared() bool { + return m.clearedmods +} + +// RemoveModIDs removes the "mods" edge to the Mod entity by IDs. +func (m *ModpackMutation) RemoveModIDs(ids ...string) { + if m.removedmods == nil { + m.removedmods = make(map[string]struct{}) + } + for i := range ids { + delete(m.mods, ids[i]) + m.removedmods[ids[i]] = struct{}{} + } +} + +// RemovedMods returns the removed IDs of the "mods" edge to the Mod entity. +func (m *ModpackMutation) RemovedModsIDs() (ids []string) { + for id := range m.removedmods { + ids = append(ids, id) + } + return +} + +// ModsIDs returns the "mods" edge IDs in the mutation. +func (m *ModpackMutation) ModsIDs() (ids []string) { + for id := range m.mods { + ids = append(ids, id) + } + return +} + +// ResetMods resets all changes to the "mods" edge. +func (m *ModpackMutation) ResetMods() { + m.mods = nil + m.clearedmods = false + m.removedmods = nil +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *ModpackMutation) AddTagIDs(ids ...string) { + if m.tags == nil { + m.tags = make(map[string]struct{}) + } + for i := range ids { + m.tags[ids[i]] = struct{}{} + } +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *ModpackMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *ModpackMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *ModpackMutation) RemoveTagIDs(ids ...string) { + if m.removedtags == nil { + m.removedtags = make(map[string]struct{}) + } + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} + } +} + +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *ModpackMutation) RemovedTagsIDs() (ids []string) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *ModpackMutation) TagsIDs() (ids []string) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *ModpackMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// Where appends a list predicates to the ModpackMutation builder. +func (m *ModpackMutation) Where(ps ...predicate.Modpack) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModpackMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModpackMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Modpack, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModpackMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModpackMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Modpack). +func (m *ModpackMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ModpackMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.created_at != nil { + fields = append(fields, modpack.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, modpack.FieldUpdatedAt) + } + if m.name != nil { + fields = append(fields, modpack.FieldName) + } + if m.short_description != nil { + fields = append(fields, modpack.FieldShortDescription) + } + if m.full_description != nil { + fields = append(fields, modpack.FieldFullDescription) + } + if m.logo != nil { + fields = append(fields, modpack.FieldLogo) + } + if m.logo_thumbhash != nil { + fields = append(fields, modpack.FieldLogoThumbhash) + } + if m.creator_id != nil { + fields = append(fields, modpack.FieldCreatorID) + } + if m.views != nil { + fields = append(fields, modpack.FieldViews) + } + if m.hotness != nil { + fields = append(fields, modpack.FieldHotness) + } + if m.installs != nil { + fields = append(fields, modpack.FieldInstalls) + } + if m.popularity != nil { + fields = append(fields, modpack.FieldPopularity) + } + if m.hidden != nil { + fields = append(fields, modpack.FieldHidden) + } + if m.parent != nil { + fields = append(fields, modpack.FieldParentID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ModpackMutation) Field(name string) (ent.Value, bool) { + switch name { + case modpack.FieldCreatedAt: + return m.CreatedAt() + case modpack.FieldUpdatedAt: + return m.UpdatedAt() + case modpack.FieldName: + return m.Name() + case modpack.FieldShortDescription: + return m.ShortDescription() + case modpack.FieldFullDescription: + return m.FullDescription() + case modpack.FieldLogo: + return m.Logo() + case modpack.FieldLogoThumbhash: + return m.LogoThumbhash() + case modpack.FieldCreatorID: + return m.CreatorID() + case modpack.FieldViews: + return m.Views() + case modpack.FieldHotness: + return m.Hotness() + case modpack.FieldInstalls: + return m.Installs() + case modpack.FieldPopularity: + return m.Popularity() + case modpack.FieldHidden: + return m.Hidden() + case modpack.FieldParentID: + return m.ParentID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ModpackMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case modpack.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case modpack.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case modpack.FieldName: + return m.OldName(ctx) + case modpack.FieldShortDescription: + return m.OldShortDescription(ctx) + case modpack.FieldFullDescription: + return m.OldFullDescription(ctx) + case modpack.FieldLogo: + return m.OldLogo(ctx) + case modpack.FieldLogoThumbhash: + return m.OldLogoThumbhash(ctx) + case modpack.FieldCreatorID: + return m.OldCreatorID(ctx) + case modpack.FieldViews: + return m.OldViews(ctx) + case modpack.FieldHotness: + return m.OldHotness(ctx) + case modpack.FieldInstalls: + return m.OldInstalls(ctx) + case modpack.FieldPopularity: + return m.OldPopularity(ctx) + case modpack.FieldHidden: + return m.OldHidden(ctx) + case modpack.FieldParentID: + return m.OldParentID(ctx) + } + return nil, fmt.Errorf("unknown Modpack field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackMutation) SetField(name string, value ent.Value) error { + switch name { + case modpack.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case modpack.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case modpack.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case modpack.FieldShortDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetShortDescription(v) + return nil + case modpack.FieldFullDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFullDescription(v) + return nil + case modpack.FieldLogo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLogo(v) + return nil + case modpack.FieldLogoThumbhash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLogoThumbhash(v) + return nil + case modpack.FieldCreatorID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatorID(v) + return nil + case modpack.FieldViews: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetViews(v) + return nil + case modpack.FieldHotness: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHotness(v) + return nil + case modpack.FieldInstalls: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInstalls(v) + return nil + case modpack.FieldPopularity: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPopularity(v) + return nil + case modpack.FieldHidden: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHidden(v) + return nil + case modpack.FieldParentID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentID(v) + return nil + } + return fmt.Errorf("unknown Modpack field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModpackMutation) AddedFields() []string { + var fields []string + if m.addviews != nil { + fields = append(fields, modpack.FieldViews) + } + if m.addhotness != nil { + fields = append(fields, modpack.FieldHotness) + } + if m.addinstalls != nil { + fields = append(fields, modpack.FieldInstalls) + } + if m.addpopularity != nil { + fields = append(fields, modpack.FieldPopularity) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModpackMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case modpack.FieldViews: + return m.AddedViews() + case modpack.FieldHotness: + return m.AddedHotness() + case modpack.FieldInstalls: + return m.AddedInstalls() + case modpack.FieldPopularity: + return m.AddedPopularity() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackMutation) AddField(name string, value ent.Value) error { + switch name { + case modpack.FieldViews: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddViews(v) + return nil + case modpack.FieldHotness: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHotness(v) + return nil + case modpack.FieldInstalls: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddInstalls(v) + return nil + case modpack.FieldPopularity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPopularity(v) + return nil + } + return fmt.Errorf("unknown Modpack numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModpackMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(modpack.FieldLogo) { + fields = append(fields, modpack.FieldLogo) + } + if m.FieldCleared(modpack.FieldLogoThumbhash) { + fields = append(fields, modpack.FieldLogoThumbhash) + } + if m.FieldCleared(modpack.FieldParentID) { + fields = append(fields, modpack.FieldParentID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModpackMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ModpackMutation) ClearField(name string) error { + switch name { + case modpack.FieldLogo: + m.ClearLogo() + return nil + case modpack.FieldLogoThumbhash: + m.ClearLogoThumbhash() + return nil + case modpack.FieldParentID: + m.ClearParentID() + return nil + } + return fmt.Errorf("unknown Modpack nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ModpackMutation) ResetField(name string) error { + switch name { + case modpack.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case modpack.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case modpack.FieldName: + m.ResetName() + return nil + case modpack.FieldShortDescription: + m.ResetShortDescription() + return nil + case modpack.FieldFullDescription: + m.ResetFullDescription() + return nil + case modpack.FieldLogo: + m.ResetLogo() + return nil + case modpack.FieldLogoThumbhash: + m.ResetLogoThumbhash() + return nil + case modpack.FieldCreatorID: + m.ResetCreatorID() + return nil + case modpack.FieldViews: + m.ResetViews() + return nil + case modpack.FieldHotness: + m.ResetHotness() + return nil + case modpack.FieldInstalls: + m.ResetInstalls() + return nil + case modpack.FieldPopularity: + m.ResetPopularity() + return nil + case modpack.FieldHidden: + m.ResetHidden() + return nil + case modpack.FieldParentID: + m.ResetParentID() + return nil + } + return fmt.Errorf("unknown Modpack field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModpackMutation) AddedEdges() []string { + edges := make([]string, 0, 6) + if m.children != nil { + edges = append(edges, modpack.EdgeChildren) + } + if m.parent != nil { + edges = append(edges, modpack.EdgeParent) + } + if m.targets != nil { + edges = append(edges, modpack.EdgeTargets) + } + if m.releases != nil { + edges = append(edges, modpack.EdgeReleases) + } + if m.mods != nil { + edges = append(edges, modpack.EdgeMods) + } + if m.tags != nil { + edges = append(edges, modpack.EdgeTags) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModpackMutation) AddedIDs(name string) []ent.Value { + switch name { + case modpack.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case modpack.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case modpack.EdgeTargets: + ids := make([]ent.Value, 0, len(m.targets)) + for id := range m.targets { + ids = append(ids, id) + } + return ids + case modpack.EdgeReleases: + ids := make([]ent.Value, 0, len(m.releases)) + for id := range m.releases { + ids = append(ids, id) + } + return ids + case modpack.EdgeMods: + ids := make([]ent.Value, 0, len(m.mods)) + for id := range m.mods { + ids = append(ids, id) + } + return ids + case modpack.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ModpackMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) + if m.removedchildren != nil { + edges = append(edges, modpack.EdgeChildren) + } + if m.removedtargets != nil { + edges = append(edges, modpack.EdgeTargets) + } + if m.removedreleases != nil { + edges = append(edges, modpack.EdgeReleases) + } + if m.removedmods != nil { + edges = append(edges, modpack.EdgeMods) + } + if m.removedtags != nil { + edges = append(edges, modpack.EdgeTags) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModpackMutation) RemovedIDs(name string) []ent.Value { + switch name { + case modpack.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case modpack.EdgeTargets: + ids := make([]ent.Value, 0, len(m.removedtargets)) + for id := range m.removedtargets { + ids = append(ids, id) + } + return ids + case modpack.EdgeReleases: + ids := make([]ent.Value, 0, len(m.removedreleases)) + for id := range m.removedreleases { + ids = append(ids, id) + } + return ids + case modpack.EdgeMods: + ids := make([]ent.Value, 0, len(m.removedmods)) + for id := range m.removedmods { + ids = append(ids, id) + } + return ids + case modpack.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ModpackMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) + if m.clearedchildren { + edges = append(edges, modpack.EdgeChildren) + } + if m.clearedparent { + edges = append(edges, modpack.EdgeParent) + } + if m.clearedtargets { + edges = append(edges, modpack.EdgeTargets) + } + if m.clearedreleases { + edges = append(edges, modpack.EdgeReleases) + } + if m.clearedmods { + edges = append(edges, modpack.EdgeMods) + } + if m.clearedtags { + edges = append(edges, modpack.EdgeTags) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModpackMutation) EdgeCleared(name string) bool { + switch name { + case modpack.EdgeChildren: + return m.clearedchildren + case modpack.EdgeParent: + return m.clearedparent + case modpack.EdgeTargets: + return m.clearedtargets + case modpack.EdgeReleases: + return m.clearedreleases + case modpack.EdgeMods: + return m.clearedmods + case modpack.EdgeTags: + return m.clearedtags + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ModpackMutation) ClearEdge(name string) error { + switch name { + case modpack.EdgeParent: + m.ClearParent() + return nil + } + return fmt.Errorf("unknown Modpack unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ModpackMutation) ResetEdge(name string) error { + switch name { + case modpack.EdgeChildren: + m.ResetChildren() + return nil + case modpack.EdgeParent: + m.ResetParent() + return nil + case modpack.EdgeTargets: + m.ResetTargets() + return nil + case modpack.EdgeReleases: + m.ResetReleases() + return nil + case modpack.EdgeMods: + m.ResetMods() + return nil + case modpack.EdgeTags: + m.ResetTags() + return nil + } + return fmt.Errorf("unknown Modpack edge %s", name) +} + +// ModpackModMutation represents an operation that mutates the ModpackMod nodes in the graph. +type ModpackModMutation struct { + config + op Op + typ string + version_constraint *string + clearedFields map[string]struct{} + modpack *string + clearedmodpack bool + mod *string + clearedmod bool + done bool + oldValue func(context.Context) (*ModpackMod, error) + predicates []predicate.ModpackMod +} + +var _ ent.Mutation = (*ModpackModMutation)(nil) + +// modpackmodOption allows management of the mutation configuration using functional options. +type modpackmodOption func(*ModpackModMutation) + +// newModpackModMutation creates new mutation for the ModpackMod entity. +func newModpackModMutation(c config, op Op, opts ...modpackmodOption) *ModpackModMutation { + m := &ModpackModMutation{ + config: c, + op: op, + typ: TypeModpackMod, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModpackModMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModpackModMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetModpackID sets the "modpack_id" field. +func (m *ModpackModMutation) SetModpackID(s string) { + m.modpack = &s +} + +// ModpackID returns the value of the "modpack_id" field in the mutation. +func (m *ModpackModMutation) ModpackID() (r string, exists bool) { + v := m.modpack + if v == nil { + return + } + return *v, true +} + +// ResetModpackID resets all changes to the "modpack_id" field. +func (m *ModpackModMutation) ResetModpackID() { + m.modpack = nil +} + +// SetModID sets the "mod_id" field. +func (m *ModpackModMutation) SetModID(s string) { + m.mod = &s +} + +// ModID returns the value of the "mod_id" field in the mutation. +func (m *ModpackModMutation) ModID() (r string, exists bool) { + v := m.mod + if v == nil { + return + } + return *v, true +} + +// ResetModID resets all changes to the "mod_id" field. +func (m *ModpackModMutation) ResetModID() { + m.mod = nil +} + +// SetVersionConstraint sets the "version_constraint" field. +func (m *ModpackModMutation) SetVersionConstraint(s string) { + m.version_constraint = &s +} + +// VersionConstraint returns the value of the "version_constraint" field in the mutation. +func (m *ModpackModMutation) VersionConstraint() (r string, exists bool) { + v := m.version_constraint + if v == nil { + return + } + return *v, true +} + +// ResetVersionConstraint resets all changes to the "version_constraint" field. +func (m *ModpackModMutation) ResetVersionConstraint() { + m.version_constraint = nil +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (m *ModpackModMutation) ClearModpack() { + m.clearedmodpack = true + m.clearedFields[modpackmod.FieldModpackID] = struct{}{} +} + +// ModpackCleared reports if the "modpack" edge to the Modpack entity was cleared. +func (m *ModpackModMutation) ModpackCleared() bool { + return m.clearedmodpack +} + +// ModpackIDs returns the "modpack" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModpackID instead. It exists only for internal usage by the builders. +func (m *ModpackModMutation) ModpackIDs() (ids []string) { + if id := m.modpack; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetModpack resets all changes to the "modpack" edge. +func (m *ModpackModMutation) ResetModpack() { + m.modpack = nil + m.clearedmodpack = false +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (m *ModpackModMutation) ClearMod() { + m.clearedmod = true + m.clearedFields[modpackmod.FieldModID] = struct{}{} +} + +// ModCleared reports if the "mod" edge to the Mod entity was cleared. +func (m *ModpackModMutation) ModCleared() bool { + return m.clearedmod +} + +// ModIDs returns the "mod" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModID instead. It exists only for internal usage by the builders. +func (m *ModpackModMutation) ModIDs() (ids []string) { + if id := m.mod; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMod resets all changes to the "mod" edge. +func (m *ModpackModMutation) ResetMod() { + m.mod = nil + m.clearedmod = false +} + +// Where appends a list predicates to the ModpackModMutation builder. +func (m *ModpackModMutation) Where(ps ...predicate.ModpackMod) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModpackModMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModpackModMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModpackMod, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModpackModMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModpackModMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ModpackMod). +func (m *ModpackModMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ModpackModMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.modpack != nil { + fields = append(fields, modpackmod.FieldModpackID) + } + if m.mod != nil { + fields = append(fields, modpackmod.FieldModID) + } + if m.version_constraint != nil { + fields = append(fields, modpackmod.FieldVersionConstraint) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ModpackModMutation) Field(name string) (ent.Value, bool) { + switch name { + case modpackmod.FieldModpackID: + return m.ModpackID() + case modpackmod.FieldModID: + return m.ModID() + case modpackmod.FieldVersionConstraint: + return m.VersionConstraint() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ModpackModMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema ModpackMod does not support getting old values") +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackModMutation) SetField(name string, value ent.Value) error { + switch name { + case modpackmod.FieldModpackID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModpackID(v) + return nil + case modpackmod.FieldModID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModID(v) + return nil + case modpackmod.FieldVersionConstraint: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionConstraint(v) + return nil + } + return fmt.Errorf("unknown ModpackMod field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModpackModMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModpackModMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackModMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ModpackMod numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModpackModMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModpackModMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ModpackModMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModpackMod nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ModpackModMutation) ResetField(name string) error { + switch name { + case modpackmod.FieldModpackID: + m.ResetModpackID() + return nil + case modpackmod.FieldModID: + m.ResetModID() + return nil + case modpackmod.FieldVersionConstraint: + m.ResetVersionConstraint() + return nil + } + return fmt.Errorf("unknown ModpackMod field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModpackModMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.modpack != nil { + edges = append(edges, modpackmod.EdgeModpack) + } + if m.mod != nil { + edges = append(edges, modpackmod.EdgeMod) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModpackModMutation) AddedIDs(name string) []ent.Value { + switch name { + case modpackmod.EdgeModpack: + if id := m.modpack; id != nil { + return []ent.Value{*id} + } + case modpackmod.EdgeMod: + if id := m.mod; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ModpackModMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModpackModMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ModpackModMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmodpack { + edges = append(edges, modpackmod.EdgeModpack) + } + if m.clearedmod { + edges = append(edges, modpackmod.EdgeMod) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModpackModMutation) EdgeCleared(name string) bool { + switch name { + case modpackmod.EdgeModpack: + return m.clearedmodpack + case modpackmod.EdgeMod: + return m.clearedmod + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ModpackModMutation) ClearEdge(name string) error { + switch name { + case modpackmod.EdgeModpack: + m.ClearModpack() + return nil + case modpackmod.EdgeMod: + m.ClearMod() + return nil + } + return fmt.Errorf("unknown ModpackMod unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ModpackModMutation) ResetEdge(name string) error { + switch name { + case modpackmod.EdgeModpack: + m.ResetModpack() + return nil + case modpackmod.EdgeMod: + m.ResetMod() + return nil + } + return fmt.Errorf("unknown ModpackMod edge %s", name) +} + +// ModpackReleaseMutation represents an operation that mutates the ModpackRelease nodes in the graph. +type ModpackReleaseMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + version *string + changelog *string + lockfile *string + clearedFields map[string]struct{} + modpack *string + clearedmodpack bool + done bool + oldValue func(context.Context) (*ModpackRelease, error) + predicates []predicate.ModpackRelease +} + +var _ ent.Mutation = (*ModpackReleaseMutation)(nil) + +// modpackreleaseOption allows management of the mutation configuration using functional options. +type modpackreleaseOption func(*ModpackReleaseMutation) + +// newModpackReleaseMutation creates new mutation for the ModpackRelease entity. +func newModpackReleaseMutation(c config, op Op, opts ...modpackreleaseOption) *ModpackReleaseMutation { + m := &ModpackReleaseMutation{ + config: c, + op: op, + typ: TypeModpackRelease, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withModpackReleaseID sets the ID field of the mutation. +func withModpackReleaseID(id string) modpackreleaseOption { + return func(m *ModpackReleaseMutation) { + var ( + err error + once sync.Once + value *ModpackRelease + ) + m.oldValue = func(ctx context.Context) (*ModpackRelease, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ModpackRelease.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withModpackRelease sets the old ModpackRelease of the mutation. +func withModpackRelease(node *ModpackRelease) modpackreleaseOption { + return func(m *ModpackReleaseMutation) { + m.oldValue = func(context.Context) (*ModpackRelease, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModpackReleaseMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModpackReleaseMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ModpackRelease entities. +func (m *ModpackReleaseMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ModpackReleaseMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ModpackReleaseMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ModpackRelease.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *ModpackReleaseMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ModpackReleaseMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ModpackReleaseMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ModpackReleaseMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ModpackReleaseMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ModpackReleaseMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetModpackID sets the "modpack_id" field. +func (m *ModpackReleaseMutation) SetModpackID(s string) { + m.modpack = &s +} + +// ModpackID returns the value of the "modpack_id" field in the mutation. +func (m *ModpackReleaseMutation) ModpackID() (r string, exists bool) { + v := m.modpack + if v == nil { + return + } + return *v, true +} + +// OldModpackID returns the old "modpack_id" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldModpackID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModpackID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModpackID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModpackID: %w", err) + } + return oldValue.ModpackID, nil +} + +// ResetModpackID resets all changes to the "modpack_id" field. +func (m *ModpackReleaseMutation) ResetModpackID() { + m.modpack = nil +} + +// SetVersion sets the "version" field. +func (m *ModpackReleaseMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *ModpackReleaseMutation) Version() (r string, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil +} + +// ResetVersion resets all changes to the "version" field. +func (m *ModpackReleaseMutation) ResetVersion() { + m.version = nil +} + +// SetChangelog sets the "changelog" field. +func (m *ModpackReleaseMutation) SetChangelog(s string) { + m.changelog = &s +} + +// Changelog returns the value of the "changelog" field in the mutation. +func (m *ModpackReleaseMutation) Changelog() (r string, exists bool) { + v := m.changelog + if v == nil { + return + } + return *v, true +} + +// OldChangelog returns the old "changelog" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldChangelog(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChangelog is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChangelog requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChangelog: %w", err) + } + return oldValue.Changelog, nil +} + +// ResetChangelog resets all changes to the "changelog" field. +func (m *ModpackReleaseMutation) ResetChangelog() { + m.changelog = nil +} + +// SetLockfile sets the "lockfile" field. +func (m *ModpackReleaseMutation) SetLockfile(s string) { + m.lockfile = &s +} + +// Lockfile returns the value of the "lockfile" field in the mutation. +func (m *ModpackReleaseMutation) Lockfile() (r string, exists bool) { + v := m.lockfile + if v == nil { + return + } + return *v, true +} + +// OldLockfile returns the old "lockfile" field's value of the ModpackRelease entity. +// If the ModpackRelease object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackReleaseMutation) OldLockfile(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLockfile is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLockfile requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLockfile: %w", err) + } + return oldValue.Lockfile, nil +} + +// ResetLockfile resets all changes to the "lockfile" field. +func (m *ModpackReleaseMutation) ResetLockfile() { + m.lockfile = nil +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (m *ModpackReleaseMutation) ClearModpack() { + m.clearedmodpack = true + m.clearedFields[modpackrelease.FieldModpackID] = struct{}{} +} + +// ModpackCleared reports if the "modpack" edge to the Modpack entity was cleared. +func (m *ModpackReleaseMutation) ModpackCleared() bool { + return m.clearedmodpack +} + +// ModpackIDs returns the "modpack" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModpackID instead. It exists only for internal usage by the builders. +func (m *ModpackReleaseMutation) ModpackIDs() (ids []string) { + if id := m.modpack; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetModpack resets all changes to the "modpack" edge. +func (m *ModpackReleaseMutation) ResetModpack() { + m.modpack = nil + m.clearedmodpack = false +} + +// Where appends a list predicates to the ModpackReleaseMutation builder. +func (m *ModpackReleaseMutation) Where(ps ...predicate.ModpackRelease) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModpackReleaseMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModpackReleaseMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModpackRelease, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModpackReleaseMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModpackReleaseMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ModpackRelease). +func (m *ModpackReleaseMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ModpackReleaseMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.created_at != nil { + fields = append(fields, modpackrelease.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, modpackrelease.FieldUpdatedAt) + } + if m.modpack != nil { + fields = append(fields, modpackrelease.FieldModpackID) + } + if m.version != nil { + fields = append(fields, modpackrelease.FieldVersion) + } + if m.changelog != nil { + fields = append(fields, modpackrelease.FieldChangelog) + } + if m.lockfile != nil { + fields = append(fields, modpackrelease.FieldLockfile) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ModpackReleaseMutation) Field(name string) (ent.Value, bool) { + switch name { + case modpackrelease.FieldCreatedAt: + return m.CreatedAt() + case modpackrelease.FieldUpdatedAt: + return m.UpdatedAt() + case modpackrelease.FieldModpackID: + return m.ModpackID() + case modpackrelease.FieldVersion: + return m.Version() + case modpackrelease.FieldChangelog: + return m.Changelog() + case modpackrelease.FieldLockfile: + return m.Lockfile() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ModpackReleaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case modpackrelease.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case modpackrelease.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case modpackrelease.FieldModpackID: + return m.OldModpackID(ctx) + case modpackrelease.FieldVersion: + return m.OldVersion(ctx) + case modpackrelease.FieldChangelog: + return m.OldChangelog(ctx) + case modpackrelease.FieldLockfile: + return m.OldLockfile(ctx) + } + return nil, fmt.Errorf("unknown ModpackRelease field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackReleaseMutation) SetField(name string, value ent.Value) error { + switch name { + case modpackrelease.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case modpackrelease.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case modpackrelease.FieldModpackID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModpackID(v) + return nil + case modpackrelease.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case modpackrelease.FieldChangelog: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChangelog(v) + return nil + case modpackrelease.FieldLockfile: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLockfile(v) + return nil + } + return fmt.Errorf("unknown ModpackRelease field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModpackReleaseMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModpackReleaseMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackReleaseMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ModpackRelease numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModpackReleaseMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModpackReleaseMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ModpackReleaseMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModpackRelease nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ModpackReleaseMutation) ResetField(name string) error { + switch name { + case modpackrelease.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case modpackrelease.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case modpackrelease.FieldModpackID: + m.ResetModpackID() + return nil + case modpackrelease.FieldVersion: + m.ResetVersion() + return nil + case modpackrelease.FieldChangelog: + m.ResetChangelog() + return nil + case modpackrelease.FieldLockfile: + m.ResetLockfile() + return nil + } + return fmt.Errorf("unknown ModpackRelease field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModpackReleaseMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.modpack != nil { + edges = append(edges, modpackrelease.EdgeModpack) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModpackReleaseMutation) AddedIDs(name string) []ent.Value { + switch name { + case modpackrelease.EdgeModpack: + if id := m.modpack; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ModpackReleaseMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModpackReleaseMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ModpackReleaseMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedmodpack { + edges = append(edges, modpackrelease.EdgeModpack) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModpackReleaseMutation) EdgeCleared(name string) bool { + switch name { + case modpackrelease.EdgeModpack: + return m.clearedmodpack + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ModpackReleaseMutation) ClearEdge(name string) error { + switch name { + case modpackrelease.EdgeModpack: + m.ClearModpack() + return nil + } + return fmt.Errorf("unknown ModpackRelease unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ModpackReleaseMutation) ResetEdge(name string) error { + switch name { + case modpackrelease.EdgeModpack: + m.ResetModpack() + return nil + } + return fmt.Errorf("unknown ModpackRelease edge %s", name) +} + +// ModpackTagMutation represents an operation that mutates the ModpackTag nodes in the graph. +type ModpackTagMutation struct { + config + op Op + typ string + clearedFields map[string]struct{} + modpack *string + clearedmodpack bool + tag *string + clearedtag bool + done bool + oldValue func(context.Context) (*ModpackTag, error) + predicates []predicate.ModpackTag +} + +var _ ent.Mutation = (*ModpackTagMutation)(nil) + +// modpacktagOption allows management of the mutation configuration using functional options. +type modpacktagOption func(*ModpackTagMutation) + +// newModpackTagMutation creates new mutation for the ModpackTag entity. +func newModpackTagMutation(c config, op Op, opts ...modpacktagOption) *ModpackTagMutation { + m := &ModpackTagMutation{ + config: c, + op: op, + typ: TypeModpackTag, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModpackTagMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModpackTagMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetModpackID sets the "modpack_id" field. +func (m *ModpackTagMutation) SetModpackID(s string) { + m.modpack = &s +} + +// ModpackID returns the value of the "modpack_id" field in the mutation. +func (m *ModpackTagMutation) ModpackID() (r string, exists bool) { + v := m.modpack + if v == nil { + return + } + return *v, true +} + +// ResetModpackID resets all changes to the "modpack_id" field. +func (m *ModpackTagMutation) ResetModpackID() { + m.modpack = nil +} + +// SetTagID sets the "tag_id" field. +func (m *ModpackTagMutation) SetTagID(s string) { + m.tag = &s +} + +// TagID returns the value of the "tag_id" field in the mutation. +func (m *ModpackTagMutation) TagID() (r string, exists bool) { + v := m.tag + if v == nil { + return + } + return *v, true +} + +// ResetTagID resets all changes to the "tag_id" field. +func (m *ModpackTagMutation) ResetTagID() { + m.tag = nil +} + +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (m *ModpackTagMutation) ClearModpack() { + m.clearedmodpack = true + m.clearedFields[modpacktag.FieldModpackID] = struct{}{} +} + +// ModpackCleared reports if the "modpack" edge to the Modpack entity was cleared. +func (m *ModpackTagMutation) ModpackCleared() bool { + return m.clearedmodpack +} + +// ModpackIDs returns the "modpack" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModpackID instead. It exists only for internal usage by the builders. +func (m *ModpackTagMutation) ModpackIDs() (ids []string) { + if id := m.modpack; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetModpack resets all changes to the "modpack" edge. +func (m *ModpackTagMutation) ResetModpack() { + m.modpack = nil + m.clearedmodpack = false +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (m *ModpackTagMutation) ClearTag() { + m.clearedtag = true + m.clearedFields[modpacktag.FieldTagID] = struct{}{} +} + +// TagCleared reports if the "tag" edge to the Tag entity was cleared. +func (m *ModpackTagMutation) TagCleared() bool { + return m.clearedtag +} + +// TagIDs returns the "tag" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TagID instead. It exists only for internal usage by the builders. +func (m *ModpackTagMutation) TagIDs() (ids []string) { + if id := m.tag; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTag resets all changes to the "tag" edge. +func (m *ModpackTagMutation) ResetTag() { + m.tag = nil + m.clearedtag = false +} + +// Where appends a list predicates to the ModpackTagMutation builder. +func (m *ModpackTagMutation) Where(ps ...predicate.ModpackTag) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModpackTagMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModpackTagMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModpackTag, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModpackTagMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModpackTagMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ModpackTag). +func (m *ModpackTagMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ModpackTagMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.modpack != nil { + fields = append(fields, modpacktag.FieldModpackID) + } + if m.tag != nil { + fields = append(fields, modpacktag.FieldTagID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ModpackTagMutation) Field(name string) (ent.Value, bool) { + switch name { + case modpacktag.FieldModpackID: + return m.ModpackID() + case modpacktag.FieldTagID: + return m.TagID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ModpackTagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema ModpackTag does not support getting old values") +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackTagMutation) SetField(name string, value ent.Value) error { + switch name { + case modpacktag.FieldModpackID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModpackID(v) + return nil + case modpacktag.FieldTagID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTagID(v) + return nil + } + return fmt.Errorf("unknown ModpackTag field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModpackTagMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModpackTagMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModpackTagMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ModpackTag numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModpackTagMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModpackTagMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ModpackTagMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModpackTag nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ModpackTagMutation) ResetField(name string) error { + switch name { + case modpacktag.FieldModpackID: + m.ResetModpackID() + return nil + case modpacktag.FieldTagID: + m.ResetTagID() + return nil + } + return fmt.Errorf("unknown ModpackTag field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModpackTagMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.modpack != nil { + edges = append(edges, modpacktag.EdgeModpack) + } + if m.tag != nil { + edges = append(edges, modpacktag.EdgeTag) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModpackTagMutation) AddedIDs(name string) []ent.Value { + switch name { + case modpacktag.EdgeModpack: + if id := m.modpack; id != nil { + return []ent.Value{*id} + } + case modpacktag.EdgeTag: + if id := m.tag; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ModpackTagMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModpackTagMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ModpackTagMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmodpack { + edges = append(edges, modpacktag.EdgeModpack) + } + if m.clearedtag { + edges = append(edges, modpacktag.EdgeTag) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModpackTagMutation) EdgeCleared(name string) bool { + switch name { + case modpacktag.EdgeModpack: + return m.clearedmodpack + case modpacktag.EdgeTag: + return m.clearedtag + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ModpackTagMutation) ClearEdge(name string) error { + switch name { + case modpacktag.EdgeModpack: + m.ClearModpack() + return nil + case modpacktag.EdgeTag: + m.ClearTag() + return nil + } + return fmt.Errorf("unknown ModpackTag unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ModpackTagMutation) ResetEdge(name string) error { + switch name { + case modpacktag.EdgeModpack: + m.ResetModpack() + return nil + case modpacktag.EdgeTag: + m.ResetTag() + return nil + } + return fmt.Errorf("unknown ModpackTag edge %s", name) +} + +// ModpackTargetMutation represents an operation that mutates the ModpackTarget nodes in the graph. +type ModpackTargetMutation struct { + config + op Op + typ string + id *string + target_name *string + clearedFields map[string]struct{} + modpack *string + clearedmodpack bool + done bool + oldValue func(context.Context) (*ModpackTarget, error) + predicates []predicate.ModpackTarget +} + +var _ ent.Mutation = (*ModpackTargetMutation)(nil) + +// modpacktargetOption allows management of the mutation configuration using functional options. +type modpacktargetOption func(*ModpackTargetMutation) + +// newModpackTargetMutation creates new mutation for the ModpackTarget entity. +func newModpackTargetMutation(c config, op Op, opts ...modpacktargetOption) *ModpackTargetMutation { + m := &ModpackTargetMutation{ + config: c, + op: op, + typ: TypeModpackTarget, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withModpackTargetID sets the ID field of the mutation. +func withModpackTargetID(id string) modpacktargetOption { + return func(m *ModpackTargetMutation) { + var ( + err error + once sync.Once + value *ModpackTarget + ) + m.oldValue = func(ctx context.Context) (*ModpackTarget, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ModpackTarget.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withModpackTarget sets the old ModpackTarget of the mutation. +func withModpackTarget(node *ModpackTarget) modpacktargetOption { + return func(m *ModpackTargetMutation) { + m.oldValue = func(context.Context) (*ModpackTarget, error) { + return node, nil + } + m.id = &node.ID } - return m } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ModTagMutation) Client() *Client { +func (m ModpackTargetMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -4035,7 +7688,7 @@ func (m ModTagMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ModTagMutation) Tx() (*Tx, error) { +func (m ModpackTargetMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -4044,107 +7697,148 @@ func (m ModTagMutation) Tx() (*Tx, error) { return tx, nil } -// SetModID sets the "mod_id" field. -func (m *ModTagMutation) SetModID(s string) { - m.mod = &s +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ModpackTarget entities. +func (m *ModpackTargetMutation) SetID(id string) { + m.id = &id } -// ModID returns the value of the "mod_id" field in the mutation. -func (m *ModTagMutation) ModID() (r string, exists bool) { - v := m.mod - if v == nil { +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ModpackTargetMutation) ID() (id string, exists bool) { + if m.id == nil { return } - return *v, true + return *m.id, true } -// ResetModID resets all changes to the "mod_id" field. -func (m *ModTagMutation) ResetModID() { - m.mod = nil +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ModpackTargetMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ModpackTarget.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// SetTagID sets the "tag_id" field. -func (m *ModTagMutation) SetTagID(s string) { - m.tag = &s +// SetModpackID sets the "modpack_id" field. +func (m *ModpackTargetMutation) SetModpackID(s string) { + m.modpack = &s } -// TagID returns the value of the "tag_id" field in the mutation. -func (m *ModTagMutation) TagID() (r string, exists bool) { - v := m.tag +// ModpackID returns the value of the "modpack_id" field in the mutation. +func (m *ModpackTargetMutation) ModpackID() (r string, exists bool) { + v := m.modpack if v == nil { return } return *v, true } -// ResetTagID resets all changes to the "tag_id" field. -func (m *ModTagMutation) ResetTagID() { - m.tag = nil +// OldModpackID returns the old "modpack_id" field's value of the ModpackTarget entity. +// If the ModpackTarget object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackTargetMutation) OldModpackID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModpackID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModpackID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModpackID: %w", err) + } + return oldValue.ModpackID, nil } -// ClearMod clears the "mod" edge to the Mod entity. -func (m *ModTagMutation) ClearMod() { - m.clearedmod = true - m.clearedFields[modtag.FieldModID] = struct{}{} +// ResetModpackID resets all changes to the "modpack_id" field. +func (m *ModpackTargetMutation) ResetModpackID() { + m.modpack = nil } -// ModCleared reports if the "mod" edge to the Mod entity was cleared. -func (m *ModTagMutation) ModCleared() bool { - return m.clearedmod +// SetTargetName sets the "target_name" field. +func (m *ModpackTargetMutation) SetTargetName(s string) { + m.target_name = &s } -// ModIDs returns the "mod" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModID instead. It exists only for internal usage by the builders. -func (m *ModTagMutation) ModIDs() (ids []string) { - if id := m.mod; id != nil { - ids = append(ids, *id) +// TargetName returns the value of the "target_name" field in the mutation. +func (m *ModpackTargetMutation) TargetName() (r string, exists bool) { + v := m.target_name + if v == nil { + return } - return + return *v, true } -// ResetMod resets all changes to the "mod" edge. -func (m *ModTagMutation) ResetMod() { - m.mod = nil - m.clearedmod = false +// OldTargetName returns the old "target_name" field's value of the ModpackTarget entity. +// If the ModpackTarget object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModpackTargetMutation) OldTargetName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTargetName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTargetName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTargetName: %w", err) + } + return oldValue.TargetName, nil } -// ClearTag clears the "tag" edge to the Tag entity. -func (m *ModTagMutation) ClearTag() { - m.clearedtag = true - m.clearedFields[modtag.FieldTagID] = struct{}{} +// ResetTargetName resets all changes to the "target_name" field. +func (m *ModpackTargetMutation) ResetTargetName() { + m.target_name = nil } -// TagCleared reports if the "tag" edge to the Tag entity was cleared. -func (m *ModTagMutation) TagCleared() bool { - return m.clearedtag +// ClearModpack clears the "modpack" edge to the Modpack entity. +func (m *ModpackTargetMutation) ClearModpack() { + m.clearedmodpack = true + m.clearedFields[modpacktarget.FieldModpackID] = struct{}{} } -// TagIDs returns the "tag" edge IDs in the mutation. +// ModpackCleared reports if the "modpack" edge to the Modpack entity was cleared. +func (m *ModpackTargetMutation) ModpackCleared() bool { + return m.clearedmodpack +} + +// ModpackIDs returns the "modpack" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TagID instead. It exists only for internal usage by the builders. -func (m *ModTagMutation) TagIDs() (ids []string) { - if id := m.tag; id != nil { +// ModpackID instead. It exists only for internal usage by the builders. +func (m *ModpackTargetMutation) ModpackIDs() (ids []string) { + if id := m.modpack; id != nil { ids = append(ids, *id) } return } -// ResetTag resets all changes to the "tag" edge. -func (m *ModTagMutation) ResetTag() { - m.tag = nil - m.clearedtag = false +// ResetModpack resets all changes to the "modpack" edge. +func (m *ModpackTargetMutation) ResetModpack() { + m.modpack = nil + m.clearedmodpack = false } -// Where appends a list predicates to the ModTagMutation builder. -func (m *ModTagMutation) Where(ps ...predicate.ModTag) { +// Where appends a list predicates to the ModpackTargetMutation builder. +func (m *ModpackTargetMutation) Where(ps ...predicate.ModpackTarget) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ModTagMutation builder. Using this method, +// WhereP appends storage-level predicates to the ModpackTargetMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ModTagMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ModTag, len(ps)) +func (m *ModpackTargetMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModpackTarget, len(ps)) for i := range ps { p[i] = ps[i] } @@ -4152,30 +7846,30 @@ func (m *ModTagMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ModTagMutation) Op() Op { +func (m *ModpackTargetMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ModTagMutation) SetOp(op Op) { +func (m *ModpackTargetMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ModTag). -func (m *ModTagMutation) Type() string { +// Type returns the node type of this mutation (ModpackTarget). +func (m *ModpackTargetMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ModTagMutation) Fields() []string { +func (m *ModpackTargetMutation) Fields() []string { fields := make([]string, 0, 2) - if m.mod != nil { - fields = append(fields, modtag.FieldModID) + if m.modpack != nil { + fields = append(fields, modpacktarget.FieldModpackID) } - if m.tag != nil { - fields = append(fields, modtag.FieldTagID) + if m.target_name != nil { + fields = append(fields, modpacktarget.FieldTargetName) } return fields } @@ -4183,12 +7877,12 @@ func (m *ModTagMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ModTagMutation) Field(name string) (ent.Value, bool) { +func (m *ModpackTargetMutation) Field(name string) (ent.Value, bool) { switch name { - case modtag.FieldModID: - return m.ModID() - case modtag.FieldTagID: - return m.TagID() + case modpacktarget.FieldModpackID: + return m.ModpackID() + case modpacktarget.FieldTargetName: + return m.TargetName() } return nil, false } @@ -4196,110 +7890,109 @@ func (m *ModTagMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ModTagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - return nil, errors.New("edge schema ModTag does not support getting old values") +func (m *ModpackTargetMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case modpacktarget.FieldModpackID: + return m.OldModpackID(ctx) + case modpacktarget.FieldTargetName: + return m.OldTargetName(ctx) + } + return nil, fmt.Errorf("unknown ModpackTarget field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModTagMutation) SetField(name string, value ent.Value) error { +func (m *ModpackTargetMutation) SetField(name string, value ent.Value) error { switch name { - case modtag.FieldModID: + case modpacktarget.FieldModpackID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModID(v) + m.SetModpackID(v) return nil - case modtag.FieldTagID: + case modpacktarget.FieldTargetName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTagID(v) + m.SetTargetName(v) return nil } - return fmt.Errorf("unknown ModTag field %s", name) + return fmt.Errorf("unknown ModpackTarget field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ModTagMutation) AddedFields() []string { +func (m *ModpackTargetMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ModTagMutation) AddedField(name string) (ent.Value, bool) { +func (m *ModpackTargetMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModTagMutation) AddField(name string, value ent.Value) error { +func (m *ModpackTargetMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown ModTag numeric field %s", name) + return fmt.Errorf("unknown ModpackTarget numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ModTagMutation) ClearedFields() []string { +func (m *ModpackTargetMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ModTagMutation) FieldCleared(name string) bool { +func (m *ModpackTargetMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ModTagMutation) ClearField(name string) error { - return fmt.Errorf("unknown ModTag nullable field %s", name) +func (m *ModpackTargetMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModpackTarget nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ModTagMutation) ResetField(name string) error { +func (m *ModpackTargetMutation) ResetField(name string) error { switch name { - case modtag.FieldModID: - m.ResetModID() + case modpacktarget.FieldModpackID: + m.ResetModpackID() return nil - case modtag.FieldTagID: - m.ResetTagID() + case modpacktarget.FieldTargetName: + m.ResetTargetName() return nil } - return fmt.Errorf("unknown ModTag field %s", name) + return fmt.Errorf("unknown ModpackTarget field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ModTagMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.mod != nil { - edges = append(edges, modtag.EdgeMod) - } - if m.tag != nil { - edges = append(edges, modtag.EdgeTag) +func (m *ModpackTargetMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.modpack != nil { + edges = append(edges, modpacktarget.EdgeModpack) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ModTagMutation) AddedIDs(name string) []ent.Value { +func (m *ModpackTargetMutation) AddedIDs(name string) []ent.Value { switch name { - case modtag.EdgeMod: - if id := m.mod; id != nil { - return []ent.Value{*id} - } - case modtag.EdgeTag: - if id := m.tag; id != nil { + case modpacktarget.EdgeModpack: + if id := m.modpack; id != nil { return []ent.Value{*id} } } @@ -4307,67 +8000,56 @@ func (m *ModTagMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ModTagMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *ModpackTargetMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ModTagMutation) RemovedIDs(name string) []ent.Value { +func (m *ModpackTargetMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ModTagMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedmod { - edges = append(edges, modtag.EdgeMod) - } - if m.clearedtag { - edges = append(edges, modtag.EdgeTag) +func (m *ModpackTargetMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedmodpack { + edges = append(edges, modpacktarget.EdgeModpack) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ModTagMutation) EdgeCleared(name string) bool { +func (m *ModpackTargetMutation) EdgeCleared(name string) bool { switch name { - case modtag.EdgeMod: - return m.clearedmod - case modtag.EdgeTag: - return m.clearedtag + case modpacktarget.EdgeModpack: + return m.clearedmodpack } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ModTagMutation) ClearEdge(name string) error { +func (m *ModpackTargetMutation) ClearEdge(name string) error { switch name { - case modtag.EdgeMod: - m.ClearMod() - return nil - case modtag.EdgeTag: - m.ClearTag() + case modpacktarget.EdgeModpack: + m.ClearModpack() return nil } - return fmt.Errorf("unknown ModTag unique edge %s", name) + return fmt.Errorf("unknown ModpackTarget unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ModTagMutation) ResetEdge(name string) error { +func (m *ModpackTargetMutation) ResetEdge(name string) error { switch name { - case modtag.EdgeMod: - m.ResetMod() - return nil - case modtag.EdgeTag: - m.ResetTag() + case modpacktarget.EdgeModpack: + m.ResetModpack() return nil } - return fmt.Errorf("unknown ModTag edge %s", name) + return fmt.Errorf("unknown ModpackTarget edge %s", name) } // SatisfactoryVersionMutation represents an operation that mutates the SatisfactoryVersion nodes in the graph. @@ -4795,24 +8477,27 @@ func (m *SatisfactoryVersionMutation) ResetEdge(name string) error { // TagMutation represents an operation that mutates the Tag nodes in the graph. type TagMutation struct { config - op Op - typ string - id *string - created_at *time.Time - updated_at *time.Time - deleted_at *time.Time - name *string - description *string - clearedFields map[string]struct{} - mods map[string]struct{} - removedmods map[string]struct{} - clearedmods bool - guides map[string]struct{} - removedguides map[string]struct{} - clearedguides bool - done bool - oldValue func(context.Context) (*Tag, error) - predicates []predicate.Tag + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + description *string + clearedFields map[string]struct{} + mods map[string]struct{} + removedmods map[string]struct{} + clearedmods bool + guides map[string]struct{} + removedguides map[string]struct{} + clearedguides bool + modpacks map[string]struct{} + removedmodpacks map[string]struct{} + clearedmodpacks bool + done bool + oldValue func(context.Context) (*Tag, error) + predicates []predicate.Tag } var _ ent.Mutation = (*TagMutation)(nil) @@ -5233,6 +8918,60 @@ func (m *TagMutation) ResetGuides() { m.removedguides = nil } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by ids. +func (m *TagMutation) AddModpackIDs(ids ...string) { + if m.modpacks == nil { + m.modpacks = make(map[string]struct{}) + } + for i := range ids { + m.modpacks[ids[i]] = struct{}{} + } +} + +// ClearModpacks clears the "modpacks" edge to the Modpack entity. +func (m *TagMutation) ClearModpacks() { + m.clearedmodpacks = true +} + +// ModpacksCleared reports if the "modpacks" edge to the Modpack entity was cleared. +func (m *TagMutation) ModpacksCleared() bool { + return m.clearedmodpacks +} + +// RemoveModpackIDs removes the "modpacks" edge to the Modpack entity by IDs. +func (m *TagMutation) RemoveModpackIDs(ids ...string) { + if m.removedmodpacks == nil { + m.removedmodpacks = make(map[string]struct{}) + } + for i := range ids { + delete(m.modpacks, ids[i]) + m.removedmodpacks[ids[i]] = struct{}{} + } +} + +// RemovedModpacks returns the removed IDs of the "modpacks" edge to the Modpack entity. +func (m *TagMutation) RemovedModpacksIDs() (ids []string) { + for id := range m.removedmodpacks { + ids = append(ids, id) + } + return +} + +// ModpacksIDs returns the "modpacks" edge IDs in the mutation. +func (m *TagMutation) ModpacksIDs() (ids []string) { + for id := range m.modpacks { + ids = append(ids, id) + } + return +} + +// ResetModpacks resets all changes to the "modpacks" edge. +func (m *TagMutation) ResetModpacks() { + m.modpacks = nil + m.clearedmodpacks = false + m.removedmodpacks = nil +} + // Where appends a list predicates to the TagMutation builder. func (m *TagMutation) Where(ps ...predicate.Tag) { m.predicates = append(m.predicates, ps...) @@ -5449,13 +9188,16 @@ func (m *TagMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TagMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.mods != nil { edges = append(edges, tag.EdgeMods) } if m.guides != nil { edges = append(edges, tag.EdgeGuides) } + if m.modpacks != nil { + edges = append(edges, tag.EdgeModpacks) + } return edges } @@ -5475,19 +9217,28 @@ func (m *TagMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case tag.EdgeModpacks: + ids := make([]ent.Value, 0, len(m.modpacks)) + for id := range m.modpacks { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *TagMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.removedmods != nil { edges = append(edges, tag.EdgeMods) } if m.removedguides != nil { edges = append(edges, tag.EdgeGuides) } + if m.removedmodpacks != nil { + edges = append(edges, tag.EdgeModpacks) + } return edges } @@ -5507,19 +9258,28 @@ func (m *TagMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case tag.EdgeModpacks: + ids := make([]ent.Value, 0, len(m.removedmodpacks)) + for id := range m.removedmodpacks { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TagMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearedmods { edges = append(edges, tag.EdgeMods) } if m.clearedguides { edges = append(edges, tag.EdgeGuides) } + if m.clearedmodpacks { + edges = append(edges, tag.EdgeModpacks) + } return edges } @@ -5531,6 +9291,8 @@ func (m *TagMutation) EdgeCleared(name string) bool { return m.clearedmods case tag.EdgeGuides: return m.clearedguides + case tag.EdgeModpacks: + return m.clearedmodpacks } return false } @@ -5553,6 +9315,9 @@ func (m *TagMutation) ResetEdge(name string) error { case tag.EdgeGuides: m.ResetGuides() return nil + case tag.EdgeModpacks: + m.ResetModpacks() + return nil } return fmt.Errorf("unknown Tag edge %s", name) } diff --git a/generated/ent/predicate/predicate.go b/generated/ent/predicate/predicate.go index 4992ae4e..60b8d217 100644 --- a/generated/ent/predicate/predicate.go +++ b/generated/ent/predicate/predicate.go @@ -21,6 +21,21 @@ type Mod func(*sql.Selector) // ModTag is the predicate function for modtag builders. type ModTag func(*sql.Selector) +// Modpack is the predicate function for modpack builders. +type Modpack func(*sql.Selector) + +// ModpackMod is the predicate function for modpackmod builders. +type ModpackMod func(*sql.Selector) + +// ModpackRelease is the predicate function for modpackrelease builders. +type ModpackRelease func(*sql.Selector) + +// ModpackTag is the predicate function for modpacktag builders. +type ModpackTag func(*sql.Selector) + +// ModpackTarget is the predicate function for modpacktarget builders. +type ModpackTarget func(*sql.Selector) + // SatisfactoryVersion is the predicate function for satisfactoryversion builders. type SatisfactoryVersion func(*sql.Selector) diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go index 2d6baa8d..5ffc1f5b 100644 --- a/generated/ent/runtime/runtime.go +++ b/generated/ent/runtime/runtime.go @@ -9,6 +9,9 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/announcement" "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktarget" "github.com/satisfactorymodding/smr-api/generated/ent/satisfactoryversion" "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/generated/ent/user" @@ -159,6 +162,81 @@ func init() { modDescID := modMixinFields0[0].Descriptor() // mod.DefaultID holds the default value on creation for the id field. mod.DefaultID = modDescID.Default.(func() string) + modpackMixin := schema.Modpack{}.Mixin() + modpackMixinFields0 := modpackMixin[0].Fields() + _ = modpackMixinFields0 + modpackMixinFields1 := modpackMixin[1].Fields() + _ = modpackMixinFields1 + modpackFields := schema.Modpack{}.Fields() + _ = modpackFields + // modpackDescCreatedAt is the schema descriptor for created_at field. + modpackDescCreatedAt := modpackMixinFields1[0].Descriptor() + // modpack.DefaultCreatedAt holds the default value on creation for the created_at field. + modpack.DefaultCreatedAt = modpackDescCreatedAt.Default.(func() time.Time) + // modpackDescUpdatedAt is the schema descriptor for updated_at field. + modpackDescUpdatedAt := modpackMixinFields1[1].Descriptor() + // modpack.DefaultUpdatedAt holds the default value on creation for the updated_at field. + modpack.DefaultUpdatedAt = modpackDescUpdatedAt.Default.(func() time.Time) + // modpack.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + modpack.UpdateDefaultUpdatedAt = modpackDescUpdatedAt.UpdateDefault.(func() time.Time) + // modpackDescShortDescription is the schema descriptor for short_description field. + modpackDescShortDescription := modpackFields[1].Descriptor() + // modpack.ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + modpack.ShortDescriptionValidator = modpackDescShortDescription.Validators[0].(func(string) error) + // modpackDescViews is the schema descriptor for views field. + modpackDescViews := modpackFields[6].Descriptor() + // modpack.DefaultViews holds the default value on creation for the views field. + modpack.DefaultViews = modpackDescViews.Default.(uint) + // modpackDescHotness is the schema descriptor for hotness field. + modpackDescHotness := modpackFields[7].Descriptor() + // modpack.DefaultHotness holds the default value on creation for the hotness field. + modpack.DefaultHotness = modpackDescHotness.Default.(uint) + // modpackDescInstalls is the schema descriptor for installs field. + modpackDescInstalls := modpackFields[8].Descriptor() + // modpack.DefaultInstalls holds the default value on creation for the installs field. + modpack.DefaultInstalls = modpackDescInstalls.Default.(uint) + // modpackDescPopularity is the schema descriptor for popularity field. + modpackDescPopularity := modpackFields[9].Descriptor() + // modpack.DefaultPopularity holds the default value on creation for the popularity field. + modpack.DefaultPopularity = modpackDescPopularity.Default.(uint) + // modpackDescHidden is the schema descriptor for hidden field. + modpackDescHidden := modpackFields[10].Descriptor() + // modpack.DefaultHidden holds the default value on creation for the hidden field. + modpack.DefaultHidden = modpackDescHidden.Default.(bool) + // modpackDescID is the schema descriptor for id field. + modpackDescID := modpackMixinFields0[0].Descriptor() + // modpack.DefaultID holds the default value on creation for the id field. + modpack.DefaultID = modpackDescID.Default.(func() string) + modpackreleaseMixin := schema.ModpackRelease{}.Mixin() + modpackreleaseMixinFields0 := modpackreleaseMixin[0].Fields() + _ = modpackreleaseMixinFields0 + modpackreleaseMixinFields1 := modpackreleaseMixin[1].Fields() + _ = modpackreleaseMixinFields1 + modpackreleaseFields := schema.ModpackRelease{}.Fields() + _ = modpackreleaseFields + // modpackreleaseDescCreatedAt is the schema descriptor for created_at field. + modpackreleaseDescCreatedAt := modpackreleaseMixinFields1[0].Descriptor() + // modpackrelease.DefaultCreatedAt holds the default value on creation for the created_at field. + modpackrelease.DefaultCreatedAt = modpackreleaseDescCreatedAt.Default.(func() time.Time) + // modpackreleaseDescUpdatedAt is the schema descriptor for updated_at field. + modpackreleaseDescUpdatedAt := modpackreleaseMixinFields1[1].Descriptor() + // modpackrelease.DefaultUpdatedAt holds the default value on creation for the updated_at field. + modpackrelease.DefaultUpdatedAt = modpackreleaseDescUpdatedAt.Default.(func() time.Time) + // modpackrelease.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + modpackrelease.UpdateDefaultUpdatedAt = modpackreleaseDescUpdatedAt.UpdateDefault.(func() time.Time) + // modpackreleaseDescID is the schema descriptor for id field. + modpackreleaseDescID := modpackreleaseMixinFields0[0].Descriptor() + // modpackrelease.DefaultID holds the default value on creation for the id field. + modpackrelease.DefaultID = modpackreleaseDescID.Default.(func() string) + modpacktargetMixin := schema.ModpackTarget{}.Mixin() + modpacktargetMixinFields0 := modpacktargetMixin[0].Fields() + _ = modpacktargetMixinFields0 + modpacktargetFields := schema.ModpackTarget{}.Fields() + _ = modpacktargetFields + // modpacktargetDescID is the schema descriptor for id field. + modpacktargetDescID := modpacktargetMixinFields0[0].Descriptor() + // modpacktarget.DefaultID holds the default value on creation for the id field. + modpacktarget.DefaultID = modpacktargetDescID.Default.(func() string) satisfactoryversionMixin := schema.SatisfactoryVersion{}.Mixin() satisfactoryversionMixinFields0 := satisfactoryversionMixin[0].Fields() _ = satisfactoryversionMixinFields0 diff --git a/generated/ent/tag.go b/generated/ent/tag.go index 5c0c9f73..9751bbbc 100644 --- a/generated/ent/tag.go +++ b/generated/ent/tag.go @@ -39,13 +39,17 @@ type TagEdges struct { Mods []*Mod `json:"mods,omitempty"` // Guides holds the value of the guides edge. Guides []*Guide `json:"guides,omitempty"` + // Modpacks holds the value of the modpacks edge. + Modpacks []*Modpack `json:"modpacks,omitempty"` // ModTags holds the value of the mod_tags edge. ModTags []*ModTag `json:"mod_tags,omitempty"` // GuideTags holds the value of the guide_tags edge. GuideTags []*GuideTag `json:"guide_tags,omitempty"` + // ModpackTags holds the value of the modpack_tags edge. + ModpackTags []*ModpackTag `json:"modpack_tags,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [6]bool } // ModsOrErr returns the Mods value or an error if the edge @@ -66,10 +70,19 @@ func (e TagEdges) GuidesOrErr() ([]*Guide, error) { return nil, &NotLoadedError{edge: "guides"} } +// ModpacksOrErr returns the Modpacks value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) ModpacksOrErr() ([]*Modpack, error) { + if e.loadedTypes[2] { + return e.Modpacks, nil + } + return nil, &NotLoadedError{edge: "modpacks"} +} + // ModTagsOrErr returns the ModTags value or an error if the edge // was not loaded in eager-loading. func (e TagEdges) ModTagsOrErr() ([]*ModTag, error) { - if e.loadedTypes[2] { + if e.loadedTypes[3] { return e.ModTags, nil } return nil, &NotLoadedError{edge: "mod_tags"} @@ -78,12 +91,21 @@ func (e TagEdges) ModTagsOrErr() ([]*ModTag, error) { // GuideTagsOrErr returns the GuideTags value or an error if the edge // was not loaded in eager-loading. func (e TagEdges) GuideTagsOrErr() ([]*GuideTag, error) { - if e.loadedTypes[3] { + if e.loadedTypes[4] { return e.GuideTags, nil } return nil, &NotLoadedError{edge: "guide_tags"} } +// ModpackTagsOrErr returns the ModpackTags value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) ModpackTagsOrErr() ([]*ModpackTag, error) { + if e.loadedTypes[5] { + return e.ModpackTags, nil + } + return nil, &NotLoadedError{edge: "modpack_tags"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Tag) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -167,6 +189,11 @@ func (t *Tag) QueryGuides() *GuideQuery { return NewTagClient(t.config).QueryGuides(t) } +// QueryModpacks queries the "modpacks" edge of the Tag entity. +func (t *Tag) QueryModpacks() *ModpackQuery { + return NewTagClient(t.config).QueryModpacks(t) +} + // QueryModTags queries the "mod_tags" edge of the Tag entity. func (t *Tag) QueryModTags() *ModTagQuery { return NewTagClient(t.config).QueryModTags(t) @@ -177,6 +204,11 @@ func (t *Tag) QueryGuideTags() *GuideTagQuery { return NewTagClient(t.config).QueryGuideTags(t) } +// QueryModpackTags queries the "modpack_tags" edge of the Tag entity. +func (t *Tag) QueryModpackTags() *ModpackTagQuery { + return NewTagClient(t.config).QueryModpackTags(t) +} + // Update returns a builder for updating this Tag. // Note that you need to call Tag.Unwrap() before calling this method if this Tag // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/generated/ent/tag/tag.go b/generated/ent/tag/tag.go index f2b1d4e0..dcf9c65c 100644 --- a/generated/ent/tag/tag.go +++ b/generated/ent/tag/tag.go @@ -29,10 +29,14 @@ const ( EdgeMods = "mods" // EdgeGuides holds the string denoting the guides edge name in mutations. EdgeGuides = "guides" + // EdgeModpacks holds the string denoting the modpacks edge name in mutations. + EdgeModpacks = "modpacks" // EdgeModTags holds the string denoting the mod_tags edge name in mutations. EdgeModTags = "mod_tags" // EdgeGuideTags holds the string denoting the guide_tags edge name in mutations. EdgeGuideTags = "guide_tags" + // EdgeModpackTags holds the string denoting the modpack_tags edge name in mutations. + EdgeModpackTags = "modpack_tags" // Table holds the table name of the tag in the database. Table = "tags" // ModsTable is the table that holds the mods relation/edge. The primary key declared below. @@ -45,6 +49,11 @@ const ( // GuidesInverseTable is the table name for the Guide entity. // It exists in this package in order to avoid circular dependency with the "guide" package. GuidesInverseTable = "guides" + // ModpacksTable is the table that holds the modpacks relation/edge. The primary key declared below. + ModpacksTable = "modpack_tags" + // ModpacksInverseTable is the table name for the Modpack entity. + // It exists in this package in order to avoid circular dependency with the "modpack" package. + ModpacksInverseTable = "modpacks" // ModTagsTable is the table that holds the mod_tags relation/edge. ModTagsTable = "mod_tags" // ModTagsInverseTable is the table name for the ModTag entity. @@ -59,6 +68,13 @@ const ( GuideTagsInverseTable = "guide_tags" // GuideTagsColumn is the table column denoting the guide_tags relation/edge. GuideTagsColumn = "tag_id" + // ModpackTagsTable is the table that holds the modpack_tags relation/edge. + ModpackTagsTable = "modpack_tags" + // ModpackTagsInverseTable is the table name for the ModpackTag entity. + // It exists in this package in order to avoid circular dependency with the "modpacktag" package. + ModpackTagsInverseTable = "modpack_tags" + // ModpackTagsColumn is the table column denoting the modpack_tags relation/edge. + ModpackTagsColumn = "tag_id" ) // Columns holds all SQL columns for tag fields. @@ -78,6 +94,9 @@ var ( // GuidesPrimaryKey and GuidesColumn2 are the table columns denoting the // primary key for the guides relation (M2M). GuidesPrimaryKey = []string{"guide_id", "tag_id"} + // ModpacksPrimaryKey and ModpacksColumn2 are the table columns denoting the + // primary key for the modpacks relation (M2M). + ModpacksPrimaryKey = []string{"modpack_id", "tag_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -173,6 +192,20 @@ func ByGuides(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByModpacksCount orders the results by modpacks count. +func ByModpacksCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpacksStep(), opts...) + } +} + +// ByModpacks orders the results by modpacks terms. +func ByModpacks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpacksStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByModTagsCount orders the results by mod_tags count. func ByModTagsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -200,6 +233,20 @@ func ByGuideTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newGuideTagsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByModpackTagsCount orders the results by modpack_tags count. +func ByModpackTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModpackTagsStep(), opts...) + } +} + +// ByModpackTags orders the results by modpack_tags terms. +func ByModpackTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModpackTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newModsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -214,6 +261,13 @@ func newGuidesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, GuidesTable, GuidesPrimaryKey...), ) } +func newModpacksStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpacksInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ModpacksTable, ModpacksPrimaryKey...), + ) +} func newModTagsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -228,3 +282,10 @@ func newGuideTagsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, GuideTagsTable, GuideTagsColumn), ) } +func newModpackTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModpackTagsInverseTable, ModpackTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackTagsTable, ModpackTagsColumn), + ) +} diff --git a/generated/ent/tag/where.go b/generated/ent/tag/where.go index 59573549..d87d2692 100644 --- a/generated/ent/tag/where.go +++ b/generated/ent/tag/where.go @@ -406,6 +406,29 @@ func HasGuidesWith(preds ...predicate.Guide) predicate.Tag { }) } +// HasModpacks applies the HasEdge predicate on the "modpacks" edge. +func HasModpacks() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ModpacksTable, ModpacksPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpacksWith applies the HasEdge predicate on the "modpacks" edge with a given conditions (other predicates). +func HasModpacksWith(preds ...predicate.Modpack) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newModpacksStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasModTags applies the HasEdge predicate on the "mod_tags" edge. func HasModTags() predicate.Tag { return predicate.Tag(func(s *sql.Selector) { @@ -452,6 +475,29 @@ func HasGuideTagsWith(preds ...predicate.GuideTag) predicate.Tag { }) } +// HasModpackTags applies the HasEdge predicate on the "modpack_tags" edge. +func HasModpackTags() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModpackTagsTable, ModpackTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModpackTagsWith applies the HasEdge predicate on the "modpack_tags" edge with a given conditions (other predicates). +func HasModpackTagsWith(preds ...predicate.ModpackTag) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newModpackTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Tag) predicate.Tag { return predicate.Tag(sql.AndPredicates(predicates...)) diff --git a/generated/ent/tag_create.go b/generated/ent/tag_create.go index ee022fbd..42a5d1fa 100644 --- a/generated/ent/tag_create.go +++ b/generated/ent/tag_create.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" "github.com/satisfactorymodding/smr-api/generated/ent/tag" ) @@ -131,6 +132,21 @@ func (tc *TagCreate) AddGuides(g ...*Guide) *TagCreate { return tc.AddGuideIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (tc *TagCreate) AddModpackIDs(ids ...string) *TagCreate { + tc.mutation.AddModpackIDs(ids...) + return tc +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (tc *TagCreate) AddModpacks(m ...*Modpack) *TagCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tc.AddModpackIDs(ids...) +} + // Mutation returns the TagMutation object of the builder. func (tc *TagCreate) Mutation() *TagMutation { return tc.mutation @@ -301,6 +317,22 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/generated/ent/tag_query.go b/generated/ent/tag_query.go index 7eb12bd6..76be60f2 100644 --- a/generated/ent/tag_query.go +++ b/generated/ent/tag_query.go @@ -15,6 +15,8 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpacktag" "github.com/satisfactorymodding/smr-api/generated/ent/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/tag" @@ -23,15 +25,17 @@ import ( // TagQuery is the builder for querying Tag entities. type TagQuery struct { config - ctx *QueryContext - order []tag.OrderOption - inters []Interceptor - predicates []predicate.Tag - withMods *ModQuery - withGuides *GuideQuery - withModTags *ModTagQuery - withGuideTags *GuideTagQuery - modifiers []func(*sql.Selector) + ctx *QueryContext + order []tag.OrderOption + inters []Interceptor + predicates []predicate.Tag + withMods *ModQuery + withGuides *GuideQuery + withModpacks *ModpackQuery + withModTags *ModTagQuery + withGuideTags *GuideTagQuery + withModpackTags *ModpackTagQuery + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -112,6 +116,28 @@ func (tq *TagQuery) QueryGuides() *GuideQuery { return query } +// QueryModpacks chains the current query on the "modpacks" edge. +func (tq *TagQuery) QueryModpacks() *ModpackQuery { + query := (&ModpackClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, selector), + sqlgraph.To(modpack.Table, modpack.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.ModpacksTable, tag.ModpacksPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryModTags chains the current query on the "mod_tags" edge. func (tq *TagQuery) QueryModTags() *ModTagQuery { query := (&ModTagClient{config: tq.config}).Query() @@ -156,6 +182,28 @@ func (tq *TagQuery) QueryGuideTags() *GuideTagQuery { return query } +// QueryModpackTags chains the current query on the "modpack_tags" edge. +func (tq *TagQuery) QueryModpackTags() *ModpackTagQuery { + query := (&ModpackTagClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, selector), + sqlgraph.To(modpacktag.Table, modpacktag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.ModpackTagsTable, tag.ModpackTagsColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Tag entity from the query. // Returns a *NotFoundError when no Tag was found. func (tq *TagQuery) First(ctx context.Context) (*Tag, error) { @@ -343,15 +391,17 @@ func (tq *TagQuery) Clone() *TagQuery { return nil } return &TagQuery{ - config: tq.config, - ctx: tq.ctx.Clone(), - order: append([]tag.OrderOption{}, tq.order...), - inters: append([]Interceptor{}, tq.inters...), - predicates: append([]predicate.Tag{}, tq.predicates...), - withMods: tq.withMods.Clone(), - withGuides: tq.withGuides.Clone(), - withModTags: tq.withModTags.Clone(), - withGuideTags: tq.withGuideTags.Clone(), + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]tag.OrderOption{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Tag{}, tq.predicates...), + withMods: tq.withMods.Clone(), + withGuides: tq.withGuides.Clone(), + withModpacks: tq.withModpacks.Clone(), + withModTags: tq.withModTags.Clone(), + withGuideTags: tq.withGuideTags.Clone(), + withModpackTags: tq.withModpackTags.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, @@ -381,6 +431,17 @@ func (tq *TagQuery) WithGuides(opts ...func(*GuideQuery)) *TagQuery { return tq } +// WithModpacks tells the query-builder to eager-load the nodes that are connected to +// the "modpacks" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithModpacks(opts ...func(*ModpackQuery)) *TagQuery { + query := (&ModpackClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withModpacks = query + return tq +} + // WithModTags tells the query-builder to eager-load the nodes that are connected to // the "mod_tags" edge. The optional arguments are used to configure the query builder of the edge. func (tq *TagQuery) WithModTags(opts ...func(*ModTagQuery)) *TagQuery { @@ -403,6 +464,17 @@ func (tq *TagQuery) WithGuideTags(opts ...func(*GuideTagQuery)) *TagQuery { return tq } +// WithModpackTags tells the query-builder to eager-load the nodes that are connected to +// the "modpack_tags" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithModpackTags(opts ...func(*ModpackTagQuery)) *TagQuery { + query := (&ModpackTagClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withModpackTags = query + return tq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -481,11 +553,13 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err var ( nodes = []*Tag{} _spec = tq.querySpec() - loadedTypes = [4]bool{ + loadedTypes = [6]bool{ tq.withMods != nil, tq.withGuides != nil, + tq.withModpacks != nil, tq.withModTags != nil, tq.withGuideTags != nil, + tq.withModpackTags != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -523,6 +597,13 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err return nil, err } } + if query := tq.withModpacks; query != nil { + if err := tq.loadModpacks(ctx, query, nodes, + func(n *Tag) { n.Edges.Modpacks = []*Modpack{} }, + func(n *Tag, e *Modpack) { n.Edges.Modpacks = append(n.Edges.Modpacks, e) }); err != nil { + return nil, err + } + } if query := tq.withModTags; query != nil { if err := tq.loadModTags(ctx, query, nodes, func(n *Tag) { n.Edges.ModTags = []*ModTag{} }, @@ -537,6 +618,13 @@ func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err return nil, err } } + if query := tq.withModpackTags; query != nil { + if err := tq.loadModpackTags(ctx, query, nodes, + func(n *Tag) { n.Edges.ModpackTags = []*ModpackTag{} }, + func(n *Tag, e *ModpackTag) { n.Edges.ModpackTags = append(n.Edges.ModpackTags, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -662,6 +750,67 @@ func (tq *TagQuery) loadGuides(ctx context.Context, query *GuideQuery, nodes []* } return nil } +func (tq *TagQuery) loadModpacks(ctx context.Context, query *ModpackQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Modpack)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Tag) + nids := make(map[string]map[*Tag]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(tag.ModpacksTable) + s.Join(joinT).On(s.C(modpack.FieldID), joinT.C(tag.ModpacksPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(tag.ModpacksPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(tag.ModpacksPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullString)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullString).String + inValue := values[1].(*sql.NullString).String + if nids[inValue] == nil { + nids[inValue] = map[*Tag]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Modpack](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "modpacks" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (tq *TagQuery) loadModTags(ctx context.Context, query *ModTagQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *ModTag)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[string]*Tag) @@ -722,6 +871,36 @@ func (tq *TagQuery) loadGuideTags(ctx context.Context, query *GuideTagQuery, nod } return nil } +func (tq *TagQuery) loadModpackTags(ctx context.Context, query *ModpackTagQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *ModpackTag)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Tag) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(modpacktag.FieldTagID) + } + query.Where(predicate.ModpackTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(tag.ModpackTagsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.TagID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "tag_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} func (tq *TagQuery) sqlCount(ctx context.Context) (int, error) { _spec := tq.querySpec() diff --git a/generated/ent/tag_update.go b/generated/ent/tag_update.go index 23df70d5..922c3694 100644 --- a/generated/ent/tag_update.go +++ b/generated/ent/tag_update.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/tag" ) @@ -121,6 +122,21 @@ func (tu *TagUpdate) AddGuides(g ...*Guide) *TagUpdate { return tu.AddGuideIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (tu *TagUpdate) AddModpackIDs(ids ...string) *TagUpdate { + tu.mutation.AddModpackIDs(ids...) + return tu +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (tu *TagUpdate) AddModpacks(m ...*Modpack) *TagUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tu.AddModpackIDs(ids...) +} + // Mutation returns the TagMutation object of the builder. func (tu *TagUpdate) Mutation() *TagMutation { return tu.mutation @@ -168,6 +184,27 @@ func (tu *TagUpdate) RemoveGuides(g ...*Guide) *TagUpdate { return tu.RemoveGuideIDs(ids...) } +// ClearModpacks clears all "modpacks" edges to the Modpack entity. +func (tu *TagUpdate) ClearModpacks() *TagUpdate { + tu.mutation.ClearModpacks() + return tu +} + +// RemoveModpackIDs removes the "modpacks" edge to Modpack entities by IDs. +func (tu *TagUpdate) RemoveModpackIDs(ids ...string) *TagUpdate { + tu.mutation.RemoveModpackIDs(ids...) + return tu +} + +// RemoveModpacks removes "modpacks" edges to Modpack entities. +func (tu *TagUpdate) RemoveModpacks(m ...*Modpack) *TagUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tu.RemoveModpackIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TagUpdate) Save(ctx context.Context) (int, error) { if err := tu.defaults(); err != nil { @@ -351,6 +388,51 @@ func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedModpacksIDs(); len(nodes) > 0 && !tu.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(tu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -463,6 +545,21 @@ func (tuo *TagUpdateOne) AddGuides(g ...*Guide) *TagUpdateOne { return tuo.AddGuideIDs(ids...) } +// AddModpackIDs adds the "modpacks" edge to the Modpack entity by IDs. +func (tuo *TagUpdateOne) AddModpackIDs(ids ...string) *TagUpdateOne { + tuo.mutation.AddModpackIDs(ids...) + return tuo +} + +// AddModpacks adds the "modpacks" edges to the Modpack entity. +func (tuo *TagUpdateOne) AddModpacks(m ...*Modpack) *TagUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tuo.AddModpackIDs(ids...) +} + // Mutation returns the TagMutation object of the builder. func (tuo *TagUpdateOne) Mutation() *TagMutation { return tuo.mutation @@ -510,6 +607,27 @@ func (tuo *TagUpdateOne) RemoveGuides(g ...*Guide) *TagUpdateOne { return tuo.RemoveGuideIDs(ids...) } +// ClearModpacks clears all "modpacks" edges to the Modpack entity. +func (tuo *TagUpdateOne) ClearModpacks() *TagUpdateOne { + tuo.mutation.ClearModpacks() + return tuo +} + +// RemoveModpackIDs removes the "modpacks" edge to Modpack entities by IDs. +func (tuo *TagUpdateOne) RemoveModpackIDs(ids ...string) *TagUpdateOne { + tuo.mutation.RemoveModpackIDs(ids...) + return tuo +} + +// RemoveModpacks removes "modpacks" edges to Modpack entities. +func (tuo *TagUpdateOne) RemoveModpacks(m ...*Modpack) *TagUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tuo.RemoveModpackIDs(ids...) +} + // Where appends a list predicates to the TagUpdate builder. func (tuo *TagUpdateOne) Where(ps ...predicate.Tag) *TagUpdateOne { tuo.mutation.Where(ps...) @@ -723,6 +841,51 @@ func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedModpacksIDs(); len(nodes) > 0 && !tuo.mutation.ModpacksCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.ModpacksIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModpacksTable, + Columns: tag.ModpacksPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(modpack.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(tuo.modifiers...) _node = &Tag{config: tuo.config} _spec.Assign = _node.assignValues diff --git a/generated/ent/tx.go b/generated/ent/tx.go index 4bf737e2..9ee6f16b 100644 --- a/generated/ent/tx.go +++ b/generated/ent/tx.go @@ -24,6 +24,16 @@ type Tx struct { Mod *ModClient // ModTag is the client for interacting with the ModTag builders. ModTag *ModTagClient + // Modpack is the client for interacting with the Modpack builders. + Modpack *ModpackClient + // ModpackMod is the client for interacting with the ModpackMod builders. + ModpackMod *ModpackModClient + // ModpackRelease is the client for interacting with the ModpackRelease builders. + ModpackRelease *ModpackReleaseClient + // ModpackTag is the client for interacting with the ModpackTag builders. + ModpackTag *ModpackTagClient + // ModpackTarget is the client for interacting with the ModpackTarget builders. + ModpackTarget *ModpackTargetClient // SatisfactoryVersion is the client for interacting with the SatisfactoryVersion builders. SatisfactoryVersion *SatisfactoryVersionClient // Tag is the client for interacting with the Tag builders. @@ -180,6 +190,11 @@ func (tx *Tx) init() { tx.GuideTag = NewGuideTagClient(tx.config) tx.Mod = NewModClient(tx.config) tx.ModTag = NewModTagClient(tx.config) + tx.Modpack = NewModpackClient(tx.config) + tx.ModpackMod = NewModpackModClient(tx.config) + tx.ModpackRelease = NewModpackReleaseClient(tx.config) + tx.ModpackTag = NewModpackTagClient(tx.config) + tx.ModpackTarget = NewModpackTargetClient(tx.config) tx.SatisfactoryVersion = NewSatisfactoryVersionClient(tx.config) tx.Tag = NewTagClient(tx.config) tx.User = NewUserClient(tx.config) diff --git a/generated/generated.go b/generated/generated.go index 34d11a07..a724e91e 100644 --- a/generated/generated.go +++ b/generated/generated.go @@ -38,6 +38,7 @@ type Config struct { type ResolverRoot interface { GetGuides() GetGuidesResolver + GetModpacks() GetModpacksResolver GetMods() GetModsResolver GetMyMods() GetMyModsResolver GetMyVersions() GetMyVersionsResolver @@ -45,6 +46,7 @@ type ResolverRoot interface { GetVersions() GetVersionsResolver Guide() GuideResolver Mod() ModResolver + Modpack() ModpackResolver Mutation() MutationResolver Query() QueryResolver SMLVersion() SMLVersionResolver @@ -63,6 +65,7 @@ type DirectiveRoot struct { CanEditGuide func(ctx context.Context, obj any, next graphql.Resolver, field string) (res any, err error) CanEditMod func(ctx context.Context, obj any, next graphql.Resolver, field string) (res any, err error) CanEditModCompatibility func(ctx context.Context, obj any, next graphql.Resolver, field *string) (res any, err error) + CanEditModpack func(ctx context.Context, obj any, next graphql.Resolver, field string) (res any, err error) CanEditSatisfactoryVersions func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) CanEditUser func(ctx context.Context, obj any, next graphql.Resolver, field string, object bool) (res any, err error) CanEditUsers func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) @@ -99,6 +102,11 @@ type ComplexityRoot struct { Guides func(childComplexity int) int } + GetModpacks struct { + Count func(childComplexity int) int + Modpacks func(childComplexity int) int + } + GetMods struct { Count func(childComplexity int) int Mods func(childComplexity int) int @@ -183,12 +191,52 @@ type ComplexityRoot struct { Versions func(childComplexity int) int } + Modpack struct { + Children func(childComplexity int) int + CreatedAt func(childComplexity int) int + Creator func(childComplexity int) int + CreatorID func(childComplexity int) int + FullDescription func(childComplexity int) int + Hidden func(childComplexity int) int + Hotness func(childComplexity int) int + ID func(childComplexity int) int + Installs func(childComplexity int) int + Logo func(childComplexity int) int + LogoThumbhash func(childComplexity int) int + Mods func(childComplexity int) int + Name func(childComplexity int) int + Parent func(childComplexity int) int + ParentID func(childComplexity int) int + Popularity func(childComplexity int) int + Releases func(childComplexity int) int + ShortDescription func(childComplexity int) int + Tags func(childComplexity int) int + Targets func(childComplexity int) int + UpdatedAt func(childComplexity int) int + Views func(childComplexity int) int + } + + ModpackModEntry struct { + ModID func(childComplexity int) int + VersionConstraint func(childComplexity int) int + } + + ModpackRelease struct { + Changelog func(childComplexity int) int + CreatedAt func(childComplexity int) int + ID func(childComplexity int) int + Lockfile func(childComplexity int) int + Version func(childComplexity int) int + } + Mutation struct { ApproveMod func(childComplexity int, modID string) int ApproveVersion func(childComplexity int, versionID string) int CreateAnnouncement func(childComplexity int, announcement NewAnnouncement) int CreateGuide func(childComplexity int, guide NewGuide) int CreateMod func(childComplexity int, mod NewMod) int + CreateModpack func(childComplexity int, modpack NewModpack) int + CreateModpackRelease func(childComplexity int, modpackID string, release NewModpackRelease) int CreateMultipleTags func(childComplexity int, tagNames []*NewTag) int CreateSatisfactoryVersion func(childComplexity int, input NewSatisfactoryVersion) int CreateTag func(childComplexity int, tagName string, description string) int @@ -196,6 +244,8 @@ type ComplexityRoot struct { DeleteAnnouncement func(childComplexity int, announcementID string) int DeleteGuide func(childComplexity int, guideID string) int DeleteMod func(childComplexity int, modID string) int + DeleteModpack func(childComplexity int, modpackID string) int + DeleteModpackRelease func(childComplexity int, modpackID string, version string) int DeleteSatisfactoryVersion func(childComplexity int, id string) int DeleteTag func(childComplexity int, tagID string) int DeleteVersion func(childComplexity int, versionID string) int @@ -207,10 +257,12 @@ type ComplexityRoot struct { OAuthFacebook func(childComplexity int, code string, state string) int OAuthGithub func(childComplexity int, code string, state string) int OAuthGoogle func(childComplexity int, code string, state string) int + ResolveModpack func(childComplexity int, modpackID string, targets []string) int UpdateAnnouncement func(childComplexity int, announcementID string, announcement UpdateAnnouncement) int UpdateGuide func(childComplexity int, guideID string, guide UpdateGuide) int UpdateMod func(childComplexity int, modID string, mod UpdateMod) int UpdateModCompatibility func(childComplexity int, modID string, compatibility CompatibilityInfoInput) int + UpdateModpack func(childComplexity int, modpackID string, modpack UpdateModpack) int UpdateMultipleModCompatibilities func(childComplexity int, modIDs []string, compatibility CompatibilityInfoInput) int UpdateSatisfactoryVersion func(childComplexity int, id string, input UpdateSatisfactoryVersion) int UpdateTag func(childComplexity int, tagID string, newName string, description string) int @@ -237,6 +289,9 @@ type ComplexityRoot struct { GetModAssetList func(childComplexity int, modReference string) int GetModByIDOrReference func(childComplexity int, modIDOrReference string) int GetModByReference func(childComplexity int, modReference string) int + GetModpack func(childComplexity int, modpackID string) int + GetModpackRelease func(childComplexity int, modpackID string, version string) int + GetModpacks func(childComplexity int, filter *ModpackFilter) int GetMods func(childComplexity int, filter map[string]interface{}) int GetMyMods func(childComplexity int, filter map[string]interface{}) int GetMyUnapprovedMods func(childComplexity int, filter map[string]interface{}) int @@ -386,6 +441,10 @@ type GetGuidesResolver interface { Guides(ctx context.Context, obj *GetGuides) ([]*Guide, error) Count(ctx context.Context, obj *GetGuides) (int, error) } +type GetModpacksResolver interface { + Modpacks(ctx context.Context, obj *GetModpacks) ([]*Modpack, error) + Count(ctx context.Context, obj *GetModpacks) (int, error) +} type GetModsResolver interface { Mods(ctx context.Context, obj *GetMods) ([]*Mod, error) Count(ctx context.Context, obj *GetMods) (int, error) @@ -415,6 +474,9 @@ type ModResolver interface { Versions(ctx context.Context, obj *Mod, filter map[string]interface{}) ([]*Version, error) LatestVersions(ctx context.Context, obj *Mod) (*LatestVersions, error) } +type ModpackResolver interface { + Children(ctx context.Context, obj *Modpack) ([]*Modpack, error) +} type MutationResolver interface { DiscourseSso(ctx context.Context, sso string, sig string) (*string, error) CreateAnnouncement(ctx context.Context, announcement NewAnnouncement) (*Announcement, error) @@ -430,6 +492,12 @@ type MutationResolver interface { DeleteMod(ctx context.Context, modID string) (bool, error) ApproveMod(ctx context.Context, modID string) (bool, error) DenyMod(ctx context.Context, modID string) (bool, error) + CreateModpack(ctx context.Context, modpack NewModpack) (*Modpack, error) + UpdateModpack(ctx context.Context, modpackID string, modpack UpdateModpack) (*Modpack, error) + DeleteModpack(ctx context.Context, modpackID string) (bool, error) + CreateModpackRelease(ctx context.Context, modpackID string, release NewModpackRelease) (*ModpackRelease, error) + DeleteModpackRelease(ctx context.Context, modpackID string, version string) (bool, error) + ResolveModpack(ctx context.Context, modpackID string, targets []string) (*string, error) CreateSatisfactoryVersion(ctx context.Context, input NewSatisfactoryVersion) (*SatisfactoryVersion, error) UpdateSatisfactoryVersion(ctx context.Context, id string, input UpdateSatisfactoryVersion) (*SatisfactoryVersion, error) DeleteSatisfactoryVersion(ctx context.Context, id string) (bool, error) @@ -466,6 +534,9 @@ type QueryResolver interface { GetMyUnapprovedMods(ctx context.Context, filter map[string]interface{}) (*GetMyMods, error) ResolveModVersions(ctx context.Context, filter []*ModVersionConstraint) ([]*ModVersion, error) GetModAssetList(ctx context.Context, modReference string) ([]string, error) + GetModpack(ctx context.Context, modpackID string) (*Modpack, error) + GetModpacks(ctx context.Context, filter *ModpackFilter) (*GetModpacks, error) + GetModpackRelease(ctx context.Context, modpackID string, version string) (*ModpackRelease, error) GetSatisfactoryVersions(ctx context.Context) ([]*SatisfactoryVersion, error) GetSatisfactoryVersion(ctx context.Context, id string) (*SatisfactoryVersion, error) GetSMLVersion(ctx context.Context, smlVersionID string) (*SMLVersion, error) @@ -615,6 +686,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.GetGuides.Guides(childComplexity), true + case "GetModpacks.count": + if e.complexity.GetModpacks.Count == nil { + break + } + + return e.complexity.GetModpacks.Count(childComplexity), true + + case "GetModpacks.modpacks": + if e.complexity.GetModpacks.Modpacks == nil { + break + } + + return e.complexity.GetModpacks.Modpacks(childComplexity), true + case "GetMods.count": if e.complexity.GetMods.Count == nil { break @@ -1003,6 +1088,209 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.ModVersion.Versions(childComplexity), true + case "Modpack.children": + if e.complexity.Modpack.Children == nil { + break + } + + return e.complexity.Modpack.Children(childComplexity), true + + case "Modpack.created_at": + if e.complexity.Modpack.CreatedAt == nil { + break + } + + return e.complexity.Modpack.CreatedAt(childComplexity), true + + case "Modpack.creator": + if e.complexity.Modpack.Creator == nil { + break + } + + return e.complexity.Modpack.Creator(childComplexity), true + + case "Modpack.creator_id": + if e.complexity.Modpack.CreatorID == nil { + break + } + + return e.complexity.Modpack.CreatorID(childComplexity), true + + case "Modpack.full_description": + if e.complexity.Modpack.FullDescription == nil { + break + } + + return e.complexity.Modpack.FullDescription(childComplexity), true + + case "Modpack.hidden": + if e.complexity.Modpack.Hidden == nil { + break + } + + return e.complexity.Modpack.Hidden(childComplexity), true + + case "Modpack.hotness": + if e.complexity.Modpack.Hotness == nil { + break + } + + return e.complexity.Modpack.Hotness(childComplexity), true + + case "Modpack.id": + if e.complexity.Modpack.ID == nil { + break + } + + return e.complexity.Modpack.ID(childComplexity), true + + case "Modpack.installs": + if e.complexity.Modpack.Installs == nil { + break + } + + return e.complexity.Modpack.Installs(childComplexity), true + + case "Modpack.logo": + if e.complexity.Modpack.Logo == nil { + break + } + + return e.complexity.Modpack.Logo(childComplexity), true + + case "Modpack.logo_thumbhash": + if e.complexity.Modpack.LogoThumbhash == nil { + break + } + + return e.complexity.Modpack.LogoThumbhash(childComplexity), true + + case "Modpack.mods": + if e.complexity.Modpack.Mods == nil { + break + } + + return e.complexity.Modpack.Mods(childComplexity), true + + case "Modpack.name": + if e.complexity.Modpack.Name == nil { + break + } + + return e.complexity.Modpack.Name(childComplexity), true + + case "Modpack.parent": + if e.complexity.Modpack.Parent == nil { + break + } + + return e.complexity.Modpack.Parent(childComplexity), true + + case "Modpack.parent_id": + if e.complexity.Modpack.ParentID == nil { + break + } + + return e.complexity.Modpack.ParentID(childComplexity), true + + case "Modpack.popularity": + if e.complexity.Modpack.Popularity == nil { + break + } + + return e.complexity.Modpack.Popularity(childComplexity), true + + case "Modpack.releases": + if e.complexity.Modpack.Releases == nil { + break + } + + return e.complexity.Modpack.Releases(childComplexity), true + + case "Modpack.short_description": + if e.complexity.Modpack.ShortDescription == nil { + break + } + + return e.complexity.Modpack.ShortDescription(childComplexity), true + + case "Modpack.tags": + if e.complexity.Modpack.Tags == nil { + break + } + + return e.complexity.Modpack.Tags(childComplexity), true + + case "Modpack.targets": + if e.complexity.Modpack.Targets == nil { + break + } + + return e.complexity.Modpack.Targets(childComplexity), true + + case "Modpack.updated_at": + if e.complexity.Modpack.UpdatedAt == nil { + break + } + + return e.complexity.Modpack.UpdatedAt(childComplexity), true + + case "Modpack.views": + if e.complexity.Modpack.Views == nil { + break + } + + return e.complexity.Modpack.Views(childComplexity), true + + case "ModpackModEntry.mod_id": + if e.complexity.ModpackModEntry.ModID == nil { + break + } + + return e.complexity.ModpackModEntry.ModID(childComplexity), true + + case "ModpackModEntry.version_constraint": + if e.complexity.ModpackModEntry.VersionConstraint == nil { + break + } + + return e.complexity.ModpackModEntry.VersionConstraint(childComplexity), true + + case "ModpackRelease.changelog": + if e.complexity.ModpackRelease.Changelog == nil { + break + } + + return e.complexity.ModpackRelease.Changelog(childComplexity), true + + case "ModpackRelease.created_at": + if e.complexity.ModpackRelease.CreatedAt == nil { + break + } + + return e.complexity.ModpackRelease.CreatedAt(childComplexity), true + + case "ModpackRelease.id": + if e.complexity.ModpackRelease.ID == nil { + break + } + + return e.complexity.ModpackRelease.ID(childComplexity), true + + case "ModpackRelease.lockfile": + if e.complexity.ModpackRelease.Lockfile == nil { + break + } + + return e.complexity.ModpackRelease.Lockfile(childComplexity), true + + case "ModpackRelease.version": + if e.complexity.ModpackRelease.Version == nil { + break + } + + return e.complexity.ModpackRelease.Version(childComplexity), true + case "Mutation.approveMod": if e.complexity.Mutation.ApproveMod == nil { break @@ -1063,6 +1351,30 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.CreateMod(childComplexity, args["mod"].(NewMod)), true + case "Mutation.createModpack": + if e.complexity.Mutation.CreateModpack == nil { + break + } + + args, err := ec.field_Mutation_createModpack_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateModpack(childComplexity, args["modpack"].(NewModpack)), true + + case "Mutation.createModpackRelease": + if e.complexity.Mutation.CreateModpackRelease == nil { + break + } + + args, err := ec.field_Mutation_createModpackRelease_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateModpackRelease(childComplexity, args["modpackID"].(string), args["release"].(NewModpackRelease)), true + case "Mutation.createMultipleTags": if e.complexity.Mutation.CreateMultipleTags == nil { break @@ -1147,6 +1459,30 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.DeleteMod(childComplexity, args["modId"].(string)), true + case "Mutation.deleteModpack": + if e.complexity.Mutation.DeleteModpack == nil { + break + } + + args, err := ec.field_Mutation_deleteModpack_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteModpack(childComplexity, args["modpackID"].(string)), true + + case "Mutation.deleteModpackRelease": + if e.complexity.Mutation.DeleteModpackRelease == nil { + break + } + + args, err := ec.field_Mutation_deleteModpackRelease_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteModpackRelease(childComplexity, args["modpackID"].(string), args["version"].(string)), true + case "Mutation.deleteSatisfactoryVersion": if e.complexity.Mutation.DeleteSatisfactoryVersion == nil { break @@ -1274,6 +1610,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.OAuthGoogle(childComplexity, args["code"].(string), args["state"].(string)), true + case "Mutation.resolveModpack": + if e.complexity.Mutation.ResolveModpack == nil { + break + } + + args, err := ec.field_Mutation_resolveModpack_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.ResolveModpack(childComplexity, args["modpackID"].(string), args["targets"].([]string)), true + case "Mutation.updateAnnouncement": if e.complexity.Mutation.UpdateAnnouncement == nil { break @@ -1322,6 +1670,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.UpdateModCompatibility(childComplexity, args["modId"].(string), args["compatibility"].(CompatibilityInfoInput)), true + case "Mutation.updateModpack": + if e.complexity.Mutation.UpdateModpack == nil { + break + } + + args, err := ec.field_Mutation_updateModpack_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateModpack(childComplexity, args["modpackID"].(string), args["modpack"].(UpdateModpack)), true + case "Mutation.updateMultipleModCompatibilities": if e.complexity.Mutation.UpdateMultipleModCompatibilities == nil { break @@ -1537,6 +1897,42 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Query.GetModByReference(childComplexity, args["modReference"].(string)), true + case "Query.getModpack": + if e.complexity.Query.GetModpack == nil { + break + } + + args, err := ec.field_Query_getModpack_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModpack(childComplexity, args["modpackID"].(string)), true + + case "Query.getModpackRelease": + if e.complexity.Query.GetModpackRelease == nil { + break + } + + args, err := ec.field_Query_getModpackRelease_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModpackRelease(childComplexity, args["modpackID"].(string), args["version"].(string)), true + + case "Query.getModpacks": + if e.complexity.Query.GetModpacks == nil { + break + } + + args, err := ec.field_Query_getModpacks_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModpacks(childComplexity, args["filter"].(*ModpackFilter)), true + case "Query.getMods": if e.complexity.Query.GetMods == nil { break @@ -2382,9 +2778,13 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputGuideFilter, ec.unmarshalInputModFilter, ec.unmarshalInputModVersionConstraint, + ec.unmarshalInputModpackFilter, + ec.unmarshalInputModpackModInput, ec.unmarshalInputNewAnnouncement, ec.unmarshalInputNewGuide, ec.unmarshalInputNewMod, + ec.unmarshalInputNewModpack, + ec.unmarshalInputNewModpackRelease, ec.unmarshalInputNewSatisfactoryVersion, ec.unmarshalInputNewTag, ec.unmarshalInputNewVersion, @@ -2393,6 +2793,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputUpdateAnnouncement, ec.unmarshalInputUpdateGuide, ec.unmarshalInputUpdateMod, + ec.unmarshalInputUpdateModpack, ec.unmarshalInputUpdateSatisfactoryVersion, ec.unmarshalInputUpdateUser, ec.unmarshalInputUpdateUserMod, @@ -2600,6 +3001,7 @@ directive @canEditVersion(field: String!) on FIELD_DEFINITION directive @canEditUser(field: String!, object: Boolean!) on FIELD_DEFINITION directive @canEditGuide(field: String!) on FIELD_DEFINITION directive @canEditModCompatibility(field: String) on FIELD_DEFINITION +directive @canEditModpack(field: String!) on FIELD_DEFINITION directive @canApproveMods on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @canApproveVersions on FIELD_DEFINITION | INPUT_FIELD_DEFINITION @@ -2820,29 +3222,155 @@ extend type Mutation { approveMod(modId: ModID!): Boolean! @canApproveMods @isLoggedIn denyMod(modId: ModID!): Boolean! @canApproveMods @isLoggedIn }`, BuiltIn: false}, - {Name: "../schemas/satisfactory_version.graphql", Input: `### Types + {Name: "../schemas/modpack.graphql", Input: `### Types -scalar SatisfactoryVersionID +scalar ModpackID -type SatisfactoryVersion { - id: SatisfactoryVersionID! - version: Int! - engine_version: String! +enum ModpackFields { + created_at + updated_at + name + views + installs + hotness + popularity + search } -### Inputs +type Modpack { + id: ModpackID! + name: String! + short_description: String! + full_description: String! + logo: String + logo_thumbhash: String + creator_id: UserID! + creator: User! + views: Int! + installs: Int! + hotness: Int! + popularity: Int! + updated_at: Date! + created_at: Date! + hidden: Boolean! + parent_id: ModpackID -input NewSatisfactoryVersion { - version: Int! - engine_version: String! + parent: Modpack + children: [Modpack!]! + tags: [Tag!]! + targets: [String!]! + mods: [ModpackModEntry!]! + releases: [ModpackRelease!]! } -input UpdateSatisfactoryVersion { - version: Int - engine_version: String +type ModpackModEntry { + mod_id: ModID! + version_constraint: String! } -### Queries +type ModpackRelease { + id: String! + version: String! + created_at: Date! + lockfile: String! + changelog: String! +} + +type GetModpacks { + modpacks: [Modpack!]! + count: Int! +} + +### Inputs + +input ModpackFilter { + limit: Int + offset: Int + order_by: ModpackFields + order: Order + search: String + ids: [ModpackID!] + hidden: Boolean + tagIDs: [TagID!] +} + +input NewModpack { + name: String! + short_description: String! + full_description: String + logo: Upload + hidden: Boolean + tagIDs: [TagID!] + targets: [String!]! + mods: [ModpackModInput!]! + parent_id: ModpackID +} + +input ModpackModInput { + mod_id: String! + version_constraint: String! +} + +input UpdateModpack { + name: String + short_description: String + full_description: String + logo: Upload + hidden: Boolean + tagIDs: [TagID!] + targets: [String!] + mods: [ModpackModInput!] +} + +input NewModpackRelease { + version: String! + changelog: String! +} + +### Queries + +extend type Query { + getModpack(modpackID: ModpackID!): Modpack + getModpacks(filter: ModpackFilter): GetModpacks! + + getModpackRelease(modpackID: ModpackID!, version: String!): ModpackRelease +} + +### Mutations + +extend type Mutation { + createModpack(modpack: NewModpack!): Modpack @isLoggedIn + updateModpack(modpackID: ModpackID!, modpack: UpdateModpack!): Modpack! @canEditModpack(field: "modpackID") @isLoggedIn + deleteModpack(modpackID: ModpackID!): Boolean! @canEditModpack(field: "modpackID") @isLoggedIn + + createModpackRelease(modpackID: ModpackID!, release: NewModpackRelease!): ModpackRelease! @canEditModpack(field: "modpackID") @isLoggedIn + deleteModpackRelease(modpackID: ModpackID!, version: String!): Boolean! @canEditModpack(field: "modpackID") @isLoggedIn + resolveModpack(modpackID: ModpackID!, targets: [String!]!): String @canEditModpack(field: "modpackID") @isLoggedIn +} +`, BuiltIn: false}, + {Name: "../schemas/satisfactory_version.graphql", Input: `### Types + +scalar SatisfactoryVersionID + +type SatisfactoryVersion { + id: SatisfactoryVersionID! + version: Int! + engine_version: String! +} + +### Inputs + +input NewSatisfactoryVersion { + version: Int! + engine_version: String! +} + +input UpdateSatisfactoryVersion { + version: Int + engine_version: String +} + +### Queries extend type Query { getSatisfactoryVersions: [SatisfactoryVersion!]! @@ -3268,6 +3796,34 @@ func (ec *executionContext) dir_canEditMod_argsField( return zeroVal, nil } +func (ec *executionContext) dir_canEditModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.dir_canEditModpack_argsField(ctx, rawArgs) + if err != nil { + return nil, err + } + args["field"] = arg0 + return args, nil +} +func (ec *executionContext) dir_canEditModpack_argsField( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["field"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + if tmp, ok := rawArgs["field"]; ok { + return ec.unmarshalNString2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + func (ec *executionContext) dir_canEditUser_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -3543,6 +4099,85 @@ func (ec *executionContext) field_Mutation_createMod_argsMod( return zeroVal, nil } +func (ec *executionContext) field_Mutation_createModpackRelease_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_createModpackRelease_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + arg1, err := ec.field_Mutation_createModpackRelease_argsRelease(ctx, rawArgs) + if err != nil { + return nil, err + } + args["release"] = arg1 + return args, nil +} +func (ec *executionContext) field_Mutation_createModpackRelease_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_createModpackRelease_argsRelease( + ctx context.Context, + rawArgs map[string]any, +) (NewModpackRelease, error) { + if _, ok := rawArgs["release"]; !ok { + var zeroVal NewModpackRelease + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("release")) + if tmp, ok := rawArgs["release"]; ok { + return ec.unmarshalNNewModpackRelease2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewModpackRelease(ctx, tmp) + } + + var zeroVal NewModpackRelease + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_createModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_createModpack_argsModpack(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpack"] = arg0 + return args, nil +} +func (ec *executionContext) field_Mutation_createModpack_argsModpack( + ctx context.Context, + rawArgs map[string]any, +) (NewModpack, error) { + if _, ok := rawArgs["modpack"]; !ok { + var zeroVal NewModpack + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpack")) + if tmp, ok := rawArgs["modpack"]; ok { + return ec.unmarshalNNewModpack2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewModpack(ctx, tmp) + } + + var zeroVal NewModpack + return zeroVal, nil +} + func (ec *executionContext) field_Mutation_createMultipleTags_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -3762,6 +4397,85 @@ func (ec *executionContext) field_Mutation_deleteMod_argsModID( return zeroVal, nil } +func (ec *executionContext) field_Mutation_deleteModpackRelease_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_deleteModpackRelease_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + arg1, err := ec.field_Mutation_deleteModpackRelease_argsVersion(ctx, rawArgs) + if err != nil { + return nil, err + } + args["version"] = arg1 + return args, nil +} +func (ec *executionContext) field_Mutation_deleteModpackRelease_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_deleteModpackRelease_argsVersion( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["version"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + if tmp, ok := rawArgs["version"]; ok { + return ec.unmarshalNString2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_deleteModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_deleteModpack_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + return args, nil +} +func (ec *executionContext) field_Mutation_deleteModpack_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + func (ec *executionContext) field_Mutation_deleteSatisfactoryVersion_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4180,6 +4894,57 @@ func (ec *executionContext) field_Mutation_oAuthGoogle_argsState( return zeroVal, nil } +func (ec *executionContext) field_Mutation_resolveModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_resolveModpack_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + arg1, err := ec.field_Mutation_resolveModpack_argsTargets(ctx, rawArgs) + if err != nil { + return nil, err + } + args["targets"] = arg1 + return args, nil +} +func (ec *executionContext) field_Mutation_resolveModpack_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_resolveModpack_argsTargets( + ctx context.Context, + rawArgs map[string]any, +) ([]string, error) { + if _, ok := rawArgs["targets"]; !ok { + var zeroVal []string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) + if tmp, ok := rawArgs["targets"]; ok { + return ec.unmarshalNString2ᚕstringᚄ(ctx, tmp) + } + + var zeroVal []string + return zeroVal, nil +} + func (ec *executionContext) field_Mutation_updateAnnouncement_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4384,33 +5149,84 @@ func (ec *executionContext) field_Mutation_updateMod_argsMod( return zeroVal, nil } -func (ec *executionContext) field_Mutation_updateMultipleModCompatibilities_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Mutation_updateModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := ec.field_Mutation_updateMultipleModCompatibilities_argsModIDs(ctx, rawArgs) + arg0, err := ec.field_Mutation_updateModpack_argsModpackID(ctx, rawArgs) if err != nil { return nil, err } - args["modIDs"] = arg0 - arg1, err := ec.field_Mutation_updateMultipleModCompatibilities_argsCompatibility(ctx, rawArgs) + args["modpackID"] = arg0 + arg1, err := ec.field_Mutation_updateModpack_argsModpack(ctx, rawArgs) if err != nil { return nil, err } - args["compatibility"] = arg1 + args["modpack"] = arg1 return args, nil } -func (ec *executionContext) field_Mutation_updateMultipleModCompatibilities_argsModIDs( +func (ec *executionContext) field_Mutation_updateModpack_argsModpackID( ctx context.Context, rawArgs map[string]any, -) ([]string, error) { - if _, ok := rawArgs["modIDs"]; !ok { - var zeroVal []string +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string return zeroVal, nil } - ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modIDs")) - if tmp, ok := rawArgs["modIDs"]; ok { - return ec.unmarshalNModID2ᚕstringᚄ(ctx, tmp) + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_updateModpack_argsModpack( + ctx context.Context, + rawArgs map[string]any, +) (UpdateModpack, error) { + if _, ok := rawArgs["modpack"]; !ok { + var zeroVal UpdateModpack + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpack")) + if tmp, ok := rawArgs["modpack"]; ok { + return ec.unmarshalNUpdateModpack2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateModpack(ctx, tmp) + } + + var zeroVal UpdateModpack + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_updateMultipleModCompatibilities_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_updateMultipleModCompatibilities_argsModIDs(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modIDs"] = arg0 + arg1, err := ec.field_Mutation_updateMultipleModCompatibilities_argsCompatibility(ctx, rawArgs) + if err != nil { + return nil, err + } + args["compatibility"] = arg1 + return args, nil +} +func (ec *executionContext) field_Mutation_updateMultipleModCompatibilities_argsModIDs( + ctx context.Context, + rawArgs map[string]any, +) ([]string, error) { + if _, ok := rawArgs["modIDs"]; !ok { + var zeroVal []string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modIDs")) + if tmp, ok := rawArgs["modIDs"]; ok { + return ec.unmarshalNModID2ᚕstringᚄ(ctx, tmp) } var zeroVal []string @@ -5062,6 +5878,113 @@ func (ec *executionContext) field_Query_getMod_argsModID( return zeroVal, nil } +func (ec *executionContext) field_Query_getModpackRelease_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Query_getModpackRelease_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + arg1, err := ec.field_Query_getModpackRelease_argsVersion(ctx, rawArgs) + if err != nil { + return nil, err + } + args["version"] = arg1 + return args, nil +} +func (ec *executionContext) field_Query_getModpackRelease_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Query_getModpackRelease_argsVersion( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["version"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + if tmp, ok := rawArgs["version"]; ok { + return ec.unmarshalNString2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Query_getModpack_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Query_getModpack_argsModpackID(ctx, rawArgs) + if err != nil { + return nil, err + } + args["modpackID"] = arg0 + return args, nil +} +func (ec *executionContext) field_Query_getModpack_argsModpackID( + ctx context.Context, + rawArgs map[string]any, +) (string, error) { + if _, ok := rawArgs["modpackID"]; !ok { + var zeroVal string + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("modpackID")) + if tmp, ok := rawArgs["modpackID"]; ok { + return ec.unmarshalNModpackID2string(ctx, tmp) + } + + var zeroVal string + return zeroVal, nil +} + +func (ec *executionContext) field_Query_getModpacks_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Query_getModpacks_argsFilter(ctx, rawArgs) + if err != nil { + return nil, err + } + args["filter"] = arg0 + return args, nil +} +func (ec *executionContext) field_Query_getModpacks_argsFilter( + ctx context.Context, + rawArgs map[string]any, +) (*ModpackFilter, error) { + if _, ok := rawArgs["filter"]; !ok { + var zeroVal *ModpackFilter + return zeroVal, nil + } + + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + if tmp, ok := rawArgs["filter"]; ok { + return ec.unmarshalOModpackFilter2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackFilter(ctx, tmp) + } + + var zeroVal *ModpackFilter + return zeroVal, nil +} + func (ec *executionContext) field_Query_getMods_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -6240,6 +7163,140 @@ func (ec *executionContext) fieldContext_GetGuides_count(_ context.Context, fiel return fc, nil } +func (ec *executionContext) _GetModpacks_modpacks(ctx context.Context, field graphql.CollectedField, obj *GetModpacks) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetModpacks_modpacks(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetModpacks().Modpacks(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*Modpack) + fc.Result = res + return ec.marshalNModpack2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetModpacks_modpacks(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetModpacks", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Modpack_id(ctx, field) + case "name": + return ec.fieldContext_Modpack_name(ctx, field) + case "short_description": + return ec.fieldContext_Modpack_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Modpack_full_description(ctx, field) + case "logo": + return ec.fieldContext_Modpack_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) + case "creator_id": + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) + case "views": + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) + case "hotness": + return ec.fieldContext_Modpack_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Modpack_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Modpack_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Modpack_created_at(ctx, field) + case "hidden": + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) + case "tags": + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _GetModpacks_count(ctx context.Context, field graphql.CollectedField, obj *GetModpacks) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetModpacks_count(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetModpacks().Count(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetModpacks_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetModpacks", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _GetMods_mods(ctx context.Context, field graphql.CollectedField, obj *GetMods) (ret graphql.Marshaler) { fc, err := ec.fieldContext_GetMods_mods(ctx, field) if err != nil { @@ -9145,8 +10202,8 @@ func (ec *executionContext) fieldContext_ModVersion_versions(_ context.Context, return fc, nil } -func (ec *executionContext) _Mutation_discourseSSO(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_discourseSSO(ctx, field) +func (ec *executionContext) _Modpack_id(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_id(ctx, field) if err != nil { return graphql.Null } @@ -9158,69 +10215,39 @@ func (ec *executionContext) _Mutation_discourseSSO(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DiscourseSso(rctx, fc.Args["sso"].(string), fc.Args["sig"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNModpackID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_discourseSSO(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ModpackID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_discourseSSO_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createAnnouncement(ctx, field) +func (ec *executionContext) _Modpack_name(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_name(ctx, field) if err != nil { return graphql.Null } @@ -9232,84 +10259,39 @@ func (ec *executionContext) _Mutation_createAnnouncement(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateAnnouncement(rctx, fc.Args["announcement"].(NewAnnouncement)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditAnnouncements == nil { - var zeroVal *Announcement - return zeroVal, errors.New("directive canEditAnnouncements is not implemented") - } - return ec.directives.CanEditAnnouncements(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Announcement - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Announcement); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Announcement`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Announcement) + res := resTmp.(string) fc.Result = res - return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Announcement_id(ctx, field) - case "message": - return ec.fieldContext_Announcement_message(ctx, field) - case "importance": - return ec.fieldContext_Announcement_importance(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateAnnouncement(ctx, field) +func (ec *executionContext) _Modpack_short_description(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_short_description(ctx, field) if err != nil { return graphql.Null } @@ -9321,37 +10303,8 @@ func (ec *executionContext) _Mutation_updateAnnouncement(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateAnnouncement(rctx, fc.Args["announcementId"].(string), fc.Args["announcement"].(UpdateAnnouncement)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditAnnouncements == nil { - var zeroVal *Announcement - return zeroVal, errors.New("directive canEditAnnouncements is not implemented") - } - return ec.directives.CanEditAnnouncements(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Announcement - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Announcement); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Announcement`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.ShortDescription, nil }) if err != nil { ec.Error(ctx, err) @@ -9363,45 +10316,26 @@ func (ec *executionContext) _Mutation_updateAnnouncement(ctx context.Context, fi } return graphql.Null } - res := resTmp.(*Announcement) + res := resTmp.(string) fc.Result = res - return ec.marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_short_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Announcement_id(ctx, field) - case "message": - return ec.fieldContext_Announcement_message(ctx, field) - case "importance": - return ec.fieldContext_Announcement_importance(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteAnnouncement(ctx, field) +func (ec *executionContext) _Modpack_full_description(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_full_description(ctx, field) if err != nil { return graphql.Null } @@ -9413,37 +10347,8 @@ func (ec *executionContext) _Mutation_deleteAnnouncement(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteAnnouncement(rctx, fc.Args["announcementId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditAnnouncements == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditAnnouncements is not implemented") - } - return ec.directives.CanEditAnnouncements(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.FullDescription, nil }) if err != nil { ec.Error(ctx, err) @@ -9455,37 +10360,26 @@ func (ec *executionContext) _Mutation_deleteAnnouncement(ctx context.Context, fi } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_full_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateModCompatibility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateModCompatibility(ctx, field) +func (ec *executionContext) _Modpack_logo(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_logo(ctx, field) if err != nil { return graphql.Null } @@ -9497,84 +10391,77 @@ func (ec *executionContext) _Mutation_updateModCompatibility(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateModCompatibility(rctx, fc.Args["modId"].(string), fc.Args["compatibility"].(CompatibilityInfoInput)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalOString2ᚖstring(ctx, "modId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditModCompatibility == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditModCompatibility is not implemented") - } - return ec.directives.CanEditModCompatibility(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Logo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateModCompatibility(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_logo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _Modpack_logo_thumbhash(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_logo_thumbhash(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateModCompatibility_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.LogoThumbhash, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Modpack_logo_thumbhash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Modpack", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Mutation_updateMultipleModCompatibilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateMultipleModCompatibilities(ctx, field) +func (ec *executionContext) _Modpack_creator_id(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_creator_id(ctx, field) if err != nil { return graphql.Null } @@ -9586,37 +10473,8 @@ func (ec *executionContext) _Mutation_updateMultipleModCompatibilities(ctx conte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateMultipleModCompatibilities(rctx, fc.Args["modIDs"].([]string), fc.Args["compatibility"].(CompatibilityInfoInput)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditModCompatibility == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditModCompatibility is not implemented") - } - return ec.directives.CanEditModCompatibility(ctx, nil, directive0, nil) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.CreatorID, nil }) if err != nil { ec.Error(ctx, err) @@ -9628,37 +10486,26 @@ func (ec *executionContext) _Mutation_updateMultipleModCompatibilities(ctx conte } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateMultipleModCompatibilities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_creator_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type UserID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateMultipleModCompatibilities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createGuide(ctx, field) +func (ec *executionContext) _Modpack_creator(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_creator(ctx, field) if err != nil { return graphql.Null } @@ -9670,91 +10517,67 @@ func (ec *executionContext) _Mutation_createGuide(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateGuide(rctx, fc.Args["guide"].(NewGuide)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Guide - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Guide); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Guide`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Creator, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Guide) + res := resTmp.(*User) fc.Result = res - return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Guide_id(ctx, field) - case "name": - return ec.fieldContext_Guide_name(ctx, field) - case "short_description": - return ec.fieldContext_Guide_short_description(ctx, field) - case "guide": - return ec.fieldContext_Guide_guide(ctx, field) - case "views": - return ec.fieldContext_Guide_views(ctx, field) - case "user_id": - return ec.fieldContext_Guide_user_id(ctx, field) - case "updated_at": - return ec.fieldContext_Guide_updated_at(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) case "created_at": - return ec.fieldContext_Guide_created_at(ctx, field) - case "tags": - return ec.fieldContext_Guide_tags(ctx, field) - case "user": - return ec.fieldContext_Guide_user(ctx, field) + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateGuide(ctx, field) +func (ec *executionContext) _Modpack_views(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_views(ctx, field) if err != nil { return graphql.Null } @@ -9766,42 +10589,8 @@ func (ec *executionContext) _Mutation_updateGuide(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateGuide(rctx, fc.Args["guideId"].(string), fc.Args["guide"].(UpdateGuide)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "guideId") - if err != nil { - var zeroVal *Guide - return zeroVal, err - } - if ec.directives.CanEditGuide == nil { - var zeroVal *Guide - return zeroVal, errors.New("directive canEditGuide is not implemented") - } - return ec.directives.CanEditGuide(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Guide - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Guide); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Guide`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Views, nil }) if err != nil { ec.Error(ctx, err) @@ -9813,59 +10602,26 @@ func (ec *executionContext) _Mutation_updateGuide(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(*Guide) + res := resTmp.(int) fc.Result = res - return ec.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_views(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Guide_id(ctx, field) - case "name": - return ec.fieldContext_Guide_name(ctx, field) - case "short_description": - return ec.fieldContext_Guide_short_description(ctx, field) - case "guide": - return ec.fieldContext_Guide_guide(ctx, field) - case "views": - return ec.fieldContext_Guide_views(ctx, field) - case "user_id": - return ec.fieldContext_Guide_user_id(ctx, field) - case "updated_at": - return ec.fieldContext_Guide_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Guide_created_at(ctx, field) - case "tags": - return ec.fieldContext_Guide_tags(ctx, field) - case "user": - return ec.fieldContext_Guide_user(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteGuide(ctx, field) +func (ec *executionContext) _Modpack_installs(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_installs(ctx, field) if err != nil { return graphql.Null } @@ -9877,42 +10633,8 @@ func (ec *executionContext) _Mutation_deleteGuide(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteGuide(rctx, fc.Args["guideId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "guideId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditGuide == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditGuide is not implemented") - } - return ec.directives.CanEditGuide(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Installs, nil }) if err != nil { ec.Error(ctx, err) @@ -9924,37 +10646,26 @@ func (ec *executionContext) _Mutation_deleteGuide(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_installs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createMod(ctx, field) +func (ec *executionContext) _Modpack_hotness(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_hotness(ctx, field) if err != nil { return graphql.Null } @@ -9966,123 +10677,39 @@ func (ec *executionContext) _Mutation_createMod(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateMod(rctx, fc.Args["mod"].(NewMod)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Mod - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Mod); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Mod`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Hotness, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(int) fc.Result = res - return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_hotness(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateMod(ctx, field) +func (ec *executionContext) _Modpack_popularity(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_popularity(ctx, field) if err != nil { return graphql.Null } @@ -10094,42 +10721,8 @@ func (ec *executionContext) _Mutation_updateMod(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateMod(rctx, fc.Args["modId"].(string), fc.Args["mod"].(UpdateMod)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "modId") - if err != nil { - var zeroVal *Mod - return zeroVal, err - } - if ec.directives.CanEditMod == nil { - var zeroVal *Mod - return zeroVal, errors.New("directive canEditMod is not implemented") - } - return ec.directives.CanEditMod(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Mod - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Mod); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Mod`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Popularity, nil }) if err != nil { ec.Error(ctx, err) @@ -10141,91 +10734,26 @@ func (ec *executionContext) _Mutation_updateMod(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(int) fc.Result = res - return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_popularity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteMod(ctx, field) +func (ec *executionContext) _Modpack_updated_at(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_updated_at(ctx, field) if err != nil { return graphql.Null } @@ -10237,42 +10765,8 @@ func (ec *executionContext) _Mutation_deleteMod(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteMod(rctx, fc.Args["modId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "modId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditMod == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditMod is not implemented") - } - return ec.directives.CanEditMod(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.UpdatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -10284,37 +10778,26 @@ func (ec *executionContext) _Mutation_deleteMod(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_approveMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_approveMod(ctx, field) +func (ec *executionContext) _Modpack_created_at(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_created_at(ctx, field) if err != nil { return graphql.Null } @@ -10326,37 +10809,8 @@ func (ec *executionContext) _Mutation_approveMod(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ApproveMod(rctx, fc.Args["modId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveMods == nil { - var zeroVal bool - return zeroVal, errors.New("directive canApproveMods is not implemented") - } - return ec.directives.CanApproveMods(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -10368,37 +10822,26 @@ func (ec *executionContext) _Mutation_approveMod(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_approveMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_denyMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_denyMod(ctx, field) +func (ec *executionContext) _Modpack_hidden(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_hidden(ctx, field) if err != nil { return graphql.Null } @@ -10410,37 +10853,8 @@ func (ec *executionContext) _Mutation_denyMod(ctx context.Context, field graphql } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DenyMod(rctx, fc.Args["modId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveMods == nil { - var zeroVal bool - return zeroVal, errors.New("directive canApproveMods is not implemented") - } - return ec.directives.CanApproveMods(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Hidden, nil }) if err != nil { ec.Error(ctx, err) @@ -10457,32 +10871,62 @@ func (ec *executionContext) _Mutation_denyMod(ctx context.Context, field graphql return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_denyMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_hidden(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _Modpack_parent_id(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_parent_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_denyMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.ParentID, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOModpackID2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Modpack_parent_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Modpack", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ModpackID does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Mutation_createSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createSatisfactoryVersion(ctx, field) +func (ec *executionContext) _Modpack_parent(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_parent(ctx, field) if err != nil { return graphql.Null } @@ -10494,87 +10938,82 @@ func (ec *executionContext) _Mutation_createSatisfactoryVersion(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateSatisfactoryVersion(rctx, fc.Args["input"].(NewSatisfactoryVersion)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *SatisfactoryVersion - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditSatisfactoryVersions == nil { - var zeroVal *SatisfactoryVersion - return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") - } - return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*SatisfactoryVersion); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SatisfactoryVersion`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Parent, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*SatisfactoryVersion) + res := resTmp.(*Modpack) fc.Result = res - return ec.marshalNSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) + return ec.marshalOModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_parent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_SatisfactoryVersion_id(ctx, field) - case "version": - return ec.fieldContext_SatisfactoryVersion_version(ctx, field) - case "engine_version": - return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + return ec.fieldContext_Modpack_id(ctx, field) + case "name": + return ec.fieldContext_Modpack_name(ctx, field) + case "short_description": + return ec.fieldContext_Modpack_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Modpack_full_description(ctx, field) + case "logo": + return ec.fieldContext_Modpack_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) + case "creator_id": + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) + case "views": + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) + case "hotness": + return ec.fieldContext_Modpack_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Modpack_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Modpack_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Modpack_created_at(ctx, field) + case "hidden": + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) + case "tags": + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateSatisfactoryVersion(ctx, field) +func (ec *executionContext) _Modpack_children(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_children(ctx, field) if err != nil { return graphql.Null } @@ -10586,37 +11025,8 @@ func (ec *executionContext) _Mutation_updateSatisfactoryVersion(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateSatisfactoryVersion(rctx, fc.Args["id"].(string), fc.Args["input"].(UpdateSatisfactoryVersion)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *SatisfactoryVersion - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditSatisfactoryVersions == nil { - var zeroVal *SatisfactoryVersion - return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") - } - return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*SatisfactoryVersion); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SatisfactoryVersion`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Modpack().Children(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -10628,45 +11038,72 @@ func (ec *executionContext) _Mutation_updateSatisfactoryVersion(ctx context.Cont } return graphql.Null } - res := resTmp.(*SatisfactoryVersion) + res := resTmp.([]*Modpack) fc.Result = res - return ec.marshalNSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) + return ec.marshalNModpack2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_children(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_SatisfactoryVersion_id(ctx, field) - case "version": - return ec.fieldContext_SatisfactoryVersion_version(ctx, field) - case "engine_version": - return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + return ec.fieldContext_Modpack_id(ctx, field) + case "name": + return ec.fieldContext_Modpack_name(ctx, field) + case "short_description": + return ec.fieldContext_Modpack_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Modpack_full_description(ctx, field) + case "logo": + return ec.fieldContext_Modpack_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) + case "creator_id": + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) + case "views": + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) + case "hotness": + return ec.fieldContext_Modpack_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Modpack_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Modpack_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Modpack_created_at(ctx, field) + case "hidden": + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) + case "tags": + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteSatisfactoryVersion(ctx, field) +func (ec *executionContext) _Modpack_tags(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_tags(ctx, field) if err != nil { return graphql.Null } @@ -10678,37 +11115,8 @@ func (ec *executionContext) _Mutation_deleteSatisfactoryVersion(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteSatisfactoryVersion(rctx, fc.Args["id"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.CanEditSatisfactoryVersions == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") - } - return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Tags, nil }) if err != nil { ec.Error(ctx, err) @@ -10720,37 +11128,34 @@ func (ec *executionContext) _Mutation_deleteSatisfactoryVersion(ctx context.Cont } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*Tag) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_tags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createTag(ctx, field) +func (ec *executionContext) _Modpack_targets(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_targets(ctx, field) if err != nil { return graphql.Null } @@ -10762,84 +11167,39 @@ func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string), fc.Args["description"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanManageTags == nil { - var zeroVal *Tag - return zeroVal, errors.New("directive canManageTags is not implemented") - } - return ec.directives.CanManageTags(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Tag - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Tag); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Targets, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Tag) + res := resTmp.([]string) fc.Result = res - return ec.marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_targets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "description": - return ec.fieldContext_Tag_description(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createMultipleTags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createMultipleTags(ctx, field) +func (ec *executionContext) _Modpack_mods(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_mods(ctx, field) if err != nil { return graphql.Null } @@ -10851,37 +11211,8 @@ func (ec *executionContext) _Mutation_createMultipleTags(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateMultipleTags(rctx, fc.Args["tagNames"].([]*NewTag)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanManageTags == nil { - var zeroVal []*Tag - return zeroVal, errors.New("directive canManageTags is not implemented") - } - return ec.directives.CanManageTags(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal []*Tag - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*Tag); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Mods, nil }) if err != nil { ec.Error(ctx, err) @@ -10893,45 +11224,32 @@ func (ec *executionContext) _Mutation_createMultipleTags(ctx context.Context, fi } return graphql.Null } - res := resTmp.([]*Tag) + res := resTmp.([]*ModpackModEntry) fc.Result = res - return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) + return ec.marshalNModpackModEntry2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModEntryᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createMultipleTags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_mods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "description": - return ec.fieldContext_Tag_description(ctx, field) + case "mod_id": + return ec.fieldContext_ModpackModEntry_mod_id(ctx, field) + case "version_constraint": + return ec.fieldContext_ModpackModEntry_version_constraint(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ModpackModEntry", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createMultipleTags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateTag(ctx, field) +func (ec *executionContext) _Modpack_releases(ctx context.Context, field graphql.CollectedField, obj *Modpack) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Modpack_releases(ctx, field) if err != nil { return graphql.Null } @@ -10943,37 +11261,8 @@ func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["tagID"].(string), fc.Args["NewName"].(string), fc.Args["description"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanManageTags == nil { - var zeroVal *Tag - return zeroVal, errors.New("directive canManageTags is not implemented") - } - return ec.directives.CanManageTags(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *Tag - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*Tag); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Releases, nil }) if err != nil { ec.Error(ctx, err) @@ -10985,45 +11274,38 @@ func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*Tag) + res := resTmp.([]*ModpackRelease) fc.Result = res - return ec.marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) + return ec.marshalNModpackRelease2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackReleaseᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Modpack_releases(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Modpack", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "description": - return ec.fieldContext_Tag_description(ctx, field) + return ec.fieldContext_ModpackRelease_id(ctx, field) + case "version": + return ec.fieldContext_ModpackRelease_version(ctx, field) + case "created_at": + return ec.fieldContext_ModpackRelease_created_at(ctx, field) + case "lockfile": + return ec.fieldContext_ModpackRelease_lockfile(ctx, field) + case "changelog": + return ec.fieldContext_ModpackRelease_changelog(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ModpackRelease", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteTag(ctx, field) +func (ec *executionContext) _ModpackModEntry_mod_id(ctx context.Context, field graphql.CollectedField, obj *ModpackModEntry) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackModEntry_mod_id(ctx, field) if err != nil { return graphql.Null } @@ -11035,37 +11317,8 @@ func (ec *executionContext) _Mutation_deleteTag(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteTag(rctx, fc.Args["tagID"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanManageTags == nil { - var zeroVal bool - return zeroVal, errors.New("directive canManageTags is not implemented") - } - return ec.directives.CanManageTags(ctx, nil, directive0) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.ModID, nil }) if err != nil { ec.Error(ctx, err) @@ -11077,37 +11330,26 @@ func (ec *executionContext) _Mutation_deleteTag(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackModEntry_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackModEntry", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type ModID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) +func (ec *executionContext) _ModpackModEntry_version_constraint(ctx context.Context, field graphql.CollectedField, obj *ModpackModEntry) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackModEntry_version_constraint(ctx, field) if err != nil { return graphql.Null } @@ -11119,47 +11361,8 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["userId"].(string), fc.Args["input"].(UpdateUser)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "userId") - if err != nil { - var zeroVal *User - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, false) - if err != nil { - var zeroVal *User - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *User - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, nil, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *User - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*User); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.User`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.VersionConstraint, nil }) if err != nil { ec.Error(ctx, err) @@ -11171,65 +11374,26 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*User) + res := resTmp.(string) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackModEntry_version_constraint(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackModEntry", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "avatar": - return ec.fieldContext_User_avatar(ctx, field) - case "avatar_thumbhash": - return ec.fieldContext_User_avatar_thumbhash(ctx, field) - case "created_at": - return ec.fieldContext_User_created_at(ctx, field) - case "github_id": - return ec.fieldContext_User_github_id(ctx, field) - case "google_id": - return ec.fieldContext_User_google_id(ctx, field) - case "facebook_id": - return ec.fieldContext_User_facebook_id(ctx, field) - case "roles": - return ec.fieldContext_User_roles(ctx, field) - case "groups": - return ec.fieldContext_User_groups(ctx, field) - case "mods": - return ec.fieldContext_User_mods(ctx, field) - case "guides": - return ec.fieldContext_User_guides(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_logout(ctx, field) +func (ec *executionContext) _ModpackRelease_id(ctx context.Context, field graphql.CollectedField, obj *ModpackRelease) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackRelease_id(ctx, field) if err != nil { return graphql.Null } @@ -11241,30 +11405,8 @@ func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().Logout(rctx) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal bool - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(bool); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -11276,26 +11418,26 @@ func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackRelease_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackRelease", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Mutation_oAuthGithub(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_oAuthGithub(ctx, field) +func (ec *executionContext) _ModpackRelease_version(ctx context.Context, field graphql.CollectedField, obj *ModpackRelease) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackRelease_version(ctx, field) if err != nil { return graphql.Null } @@ -11307,73 +11449,39 @@ func (ec *executionContext) _Mutation_oAuthGithub(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().OAuthGithub(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsNotLoggedIn == nil { - var zeroVal *UserSession - return zeroVal, errors.New("directive isNotLoggedIn is not implemented") - } - return ec.directives.IsNotLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*UserSession); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Version, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*UserSession) + res := resTmp.(string) fc.Result = res - return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_oAuthGithub(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackRelease_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackRelease", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "token": - return ec.fieldContext_UserSession_token(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_oAuthGithub_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_oAuthGoogle(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_oAuthGoogle(ctx, field) +func (ec *executionContext) _ModpackRelease_created_at(ctx context.Context, field graphql.CollectedField, obj *ModpackRelease) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackRelease_created_at(ctx, field) if err != nil { return graphql.Null } @@ -11385,73 +11493,39 @@ func (ec *executionContext) _Mutation_oAuthGoogle(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().OAuthGoogle(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsNotLoggedIn == nil { - var zeroVal *UserSession - return zeroVal, errors.New("directive isNotLoggedIn is not implemented") - } - return ec.directives.IsNotLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*UserSession); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*UserSession) + res := resTmp.(string) fc.Result = res - return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_oAuthGoogle(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackRelease_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackRelease", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "token": - return ec.fieldContext_UserSession_token(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) + return nil, errors.New("field of type Date does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_oAuthGoogle_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_oAuthFacebook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_oAuthFacebook(ctx, field) +func (ec *executionContext) _ModpackRelease_lockfile(ctx context.Context, field graphql.CollectedField, obj *ModpackRelease) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackRelease_lockfile(ctx, field) if err != nil { return graphql.Null } @@ -11463,73 +11537,39 @@ func (ec *executionContext) _Mutation_oAuthFacebook(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().OAuthFacebook(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - if ec.directives.IsNotLoggedIn == nil { - var zeroVal *UserSession - return zeroVal, errors.New("directive isNotLoggedIn is not implemented") - } - return ec.directives.IsNotLoggedIn(ctx, nil, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*UserSession); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Lockfile, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*UserSession) + res := resTmp.(string) fc.Result = res - return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_oAuthFacebook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackRelease_lockfile(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackRelease", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "token": - return ec.fieldContext_UserSession_token(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_oAuthFacebook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createVersion(ctx, field) +func (ec *executionContext) _ModpackRelease_changelog(ctx context.Context, field graphql.CollectedField, obj *ModpackRelease) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModpackRelease_changelog(ctx, field) if err != nil { return graphql.Null } @@ -11541,42 +11581,8 @@ func (ec *executionContext) _Mutation_createVersion(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateVersion(rctx, fc.Args["modId"].(string)) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "modId") - if err != nil { - var zeroVal string - return zeroVal, err - } - if ec.directives.CanEditMod == nil { - var zeroVal string - return zeroVal, errors.New("directive canEditMod is not implemented") - } - return ec.directives.CanEditMod(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, nil, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Changelog, nil }) if err != nil { ec.Error(ctx, err) @@ -11590,35 +11596,24 @@ func (ec *executionContext) _Mutation_createVersion(ctx context.Context, field g } res := resTmp.(string) fc.Result = res - return ec.marshalNVersionID2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModpackRelease_changelog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ModpackRelease", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_uploadVersionPart(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_uploadVersionPart(ctx, field) +func (ec *executionContext) _Mutation_discourseSSO(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_discourseSSO(ctx, field) if err != nil { return graphql.Null } @@ -11632,64 +11627,49 @@ func (ec *executionContext) _Mutation_uploadVersionPart(ctx context.Context, fie resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UploadVersionPart(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string), fc.Args["part"].(int), fc.Args["file"].(graphql.Upload)) + return ec.resolvers.Mutation().DiscourseSso(rctx, fc.Args["sso"].(string), fc.Args["sig"].(string)) } directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "modId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditMod == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditMod is not implemented") - } - return ec.directives.CanEditMod(ctx, nil, directive0, field) - } - directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal bool + var zeroVal *string return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return ec.directives.IsLoggedIn(ctx, nil, directive1) + return ec.directives.IsLoggedIn(ctx, nil, directive0) } - tmp, err := directive2(rctx) + tmp, err := directive1(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.(bool); ok { + if data, ok := tmp.(*string); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_uploadVersionPart(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_discourseSSO(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } defer func() { @@ -11699,15 +11679,15 @@ func (ec *executionContext) fieldContext_Mutation_uploadVersionPart(ctx context. } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_uploadVersionPart_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_discourseSSO_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_finalizeCreateVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_finalizeCreateVersion(ctx, field) +func (ec *executionContext) _Mutation_createAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createAnnouncement(ctx, field) if err != nil { return graphql.Null } @@ -11721,24 +11701,19 @@ func (ec *executionContext) _Mutation_finalizeCreateVersion(ctx context.Context, resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FinalizeCreateVersion(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string), fc.Args["version"].(NewVersion)) + return ec.resolvers.Mutation().CreateAnnouncement(rctx, fc.Args["announcement"].(NewAnnouncement)) } directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "modId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditMod == nil { - var zeroVal bool - return zeroVal, errors.New("directive canEditMod is not implemented") + if ec.directives.CanEditAnnouncements == nil { + var zeroVal *Announcement + return zeroVal, errors.New("directive canEditAnnouncements is not implemented") } - return ec.directives.CanEditMod(ctx, nil, directive0, field) + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal bool + var zeroVal *Announcement return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive1) @@ -11751,34 +11726,39 @@ func (ec *executionContext) _Mutation_finalizeCreateVersion(ctx context.Context, if tmp == nil { return nil, nil } - if data, ok := tmp.(bool); ok { + if data, ok := tmp.(*Announcement); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Announcement`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*Announcement) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_finalizeCreateVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Announcement_id(ctx, field) + case "message": + return ec.fieldContext_Announcement_message(ctx, field) + case "importance": + return ec.fieldContext_Announcement_importance(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) }, } defer func() { @@ -11788,15 +11768,15 @@ func (ec *executionContext) fieldContext_Mutation_finalizeCreateVersion(ctx cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_finalizeCreateVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateVersion(ctx, field) +func (ec *executionContext) _Mutation_updateAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateAnnouncement(ctx, field) if err != nil { return graphql.Null } @@ -11810,24 +11790,19 @@ func (ec *executionContext) _Mutation_updateVersion(ctx context.Context, field g resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateVersion(rctx, fc.Args["versionId"].(string), fc.Args["version"].(UpdateVersion)) + return ec.resolvers.Mutation().UpdateAnnouncement(rctx, fc.Args["announcementId"].(string), fc.Args["announcement"].(UpdateAnnouncement)) } directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "versionId") - if err != nil { - var zeroVal *Version - return zeroVal, err - } - if ec.directives.CanEditVersion == nil { - var zeroVal *Version - return zeroVal, errors.New("directive canEditVersion is not implemented") + if ec.directives.CanEditAnnouncements == nil { + var zeroVal *Announcement + return zeroVal, errors.New("directive canEditAnnouncements is not implemented") } - return ec.directives.CanEditVersion(ctx, nil, directive0, field) + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *Version + var zeroVal *Announcement return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive1) @@ -11840,10 +11815,10 @@ func (ec *executionContext) _Mutation_updateVersion(ctx context.Context, field g if tmp == nil { return nil, nil } - if data, ok := tmp.(*Version); ok { + if data, ok := tmp.(*Announcement); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Version`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Announcement`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -11855,12 +11830,12 @@ func (ec *executionContext) _Mutation_updateVersion(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*Version) + res := resTmp.(*Announcement) fc.Result = res - return ec.marshalNVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) + return ec.marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -11869,47 +11844,13 @@ func (ec *executionContext) fieldContext_Mutation_updateVersion(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Version_id(ctx, field) - case "mod_id": - return ec.fieldContext_Version_mod_id(ctx, field) - case "version": - return ec.fieldContext_Version_version(ctx, field) - case "sml_version": - return ec.fieldContext_Version_sml_version(ctx, field) - case "game_version": - return ec.fieldContext_Version_game_version(ctx, field) - case "required_on_remote": - return ec.fieldContext_Version_required_on_remote(ctx, field) - case "changelog": - return ec.fieldContext_Version_changelog(ctx, field) - case "downloads": - return ec.fieldContext_Version_downloads(ctx, field) - case "stability": - return ec.fieldContext_Version_stability(ctx, field) - case "approved": - return ec.fieldContext_Version_approved(ctx, field) - case "updated_at": - return ec.fieldContext_Version_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Version_created_at(ctx, field) - case "link": - return ec.fieldContext_Version_link(ctx, field) - case "targets": - return ec.fieldContext_Version_targets(ctx, field) - case "metadata": - return ec.fieldContext_Version_metadata(ctx, field) - case "size": - return ec.fieldContext_Version_size(ctx, field) - case "hash": - return ec.fieldContext_Version_hash(ctx, field) - case "mod": - return ec.fieldContext_Version_mod(ctx, field) - case "dependencies": - return ec.fieldContext_Version_dependencies(ctx, field) - case "virustotal_results": - return ec.fieldContext_Version_virustotal_results(ctx, field) + return ec.fieldContext_Announcement_id(ctx, field) + case "message": + return ec.fieldContext_Announcement_message(ctx, field) + case "importance": + return ec.fieldContext_Announcement_importance(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) }, } defer func() { @@ -11919,15 +11860,15 @@ func (ec *executionContext) fieldContext_Mutation_updateVersion(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteVersion(ctx, field) +func (ec *executionContext) _Mutation_deleteAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteAnnouncement(ctx, field) if err != nil { return graphql.Null } @@ -11941,20 +11882,15 @@ func (ec *executionContext) _Mutation_deleteVersion(ctx context.Context, field g resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteVersion(rctx, fc.Args["versionId"].(string)) + return ec.resolvers.Mutation().DeleteAnnouncement(rctx, fc.Args["announcementId"].(string)) } directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "versionId") - if err != nil { - var zeroVal bool - return zeroVal, err - } - if ec.directives.CanEditVersion == nil { + if ec.directives.CanEditAnnouncements == nil { var zeroVal bool - return zeroVal, errors.New("directive canEditVersion is not implemented") + return zeroVal, errors.New("directive canEditAnnouncements is not implemented") } - return ec.directives.CanEditVersion(ctx, nil, directive0, field) + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { @@ -11991,7 +11927,7 @@ func (ec *executionContext) _Mutation_deleteVersion(ctx context.Context, field g return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -12008,15 +11944,15 @@ func (ec *executionContext) fieldContext_Mutation_deleteVersion(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_approveVersion(ctx, field) +func (ec *executionContext) _Mutation_updateModCompatibility(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateModCompatibility(ctx, field) if err != nil { return graphql.Null } @@ -12030,15 +11966,20 @@ func (ec *executionContext) _Mutation_approveVersion(ctx context.Context, field resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ApproveVersion(rctx, fc.Args["versionId"].(string)) + return ec.resolvers.Mutation().UpdateModCompatibility(rctx, fc.Args["modId"].(string), fc.Args["compatibility"].(CompatibilityInfoInput)) } directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveVersions == nil { + field, err := ec.unmarshalOString2ᚖstring(ctx, "modId") + if err != nil { var zeroVal bool - return zeroVal, errors.New("directive canApproveVersions is not implemented") + return zeroVal, err } - return ec.directives.CanApproveVersions(ctx, nil, directive0) + if ec.directives.CanEditModCompatibility == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditModCompatibility is not implemented") + } + return ec.directives.CanEditModCompatibility(ctx, nil, directive0, field) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { @@ -12075,7 +12016,7 @@ func (ec *executionContext) _Mutation_approveVersion(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_approveVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateModCompatibility(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -12092,15 +12033,15 @@ func (ec *executionContext) fieldContext_Mutation_approveVersion(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateModCompatibility_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_denyVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_denyVersion(ctx, field) +func (ec *executionContext) _Mutation_updateMultipleModCompatibilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateMultipleModCompatibilities(ctx, field) if err != nil { return graphql.Null } @@ -12114,15 +12055,15 @@ func (ec *executionContext) _Mutation_denyVersion(ctx context.Context, field gra resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DenyVersion(rctx, fc.Args["versionId"].(string)) + return ec.resolvers.Mutation().UpdateMultipleModCompatibilities(rctx, fc.Args["modIDs"].([]string), fc.Args["compatibility"].(CompatibilityInfoInput)) } directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveVersions == nil { + if ec.directives.CanEditModCompatibility == nil { var zeroVal bool - return zeroVal, errors.New("directive canApproveVersions is not implemented") + return zeroVal, errors.New("directive canEditModCompatibility is not implemented") } - return ec.directives.CanApproveVersions(ctx, nil, directive0) + return ec.directives.CanEditModCompatibility(ctx, nil, directive0, nil) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { @@ -12159,7 +12100,7 @@ func (ec *executionContext) _Mutation_denyVersion(ctx context.Context, field gra return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_denyVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateMultipleModCompatibilities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -12176,15 +12117,15 @@ func (ec *executionContext) fieldContext_Mutation_denyVersion(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_denyVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateMultipleModCompatibilities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _OAuthOptions_github(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_OAuthOptions_github(ctx, field) +func (ec *executionContext) _Mutation_createGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createGuide(ctx, field) if err != nil { return graphql.Null } @@ -12196,39 +12137,91 @@ func (ec *executionContext) _OAuthOptions_github(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Github, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateGuide(rctx, fc.Args["guide"].(NewGuide)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Guide + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Guide); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Guide`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Guide) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_github(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "OAuthOptions", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Guide_id(ctx, field) + case "name": + return ec.fieldContext_Guide_name(ctx, field) + case "short_description": + return ec.fieldContext_Guide_short_description(ctx, field) + case "guide": + return ec.fieldContext_Guide_guide(ctx, field) + case "views": + return ec.fieldContext_Guide_views(ctx, field) + case "user_id": + return ec.fieldContext_Guide_user_id(ctx, field) + case "updated_at": + return ec.fieldContext_Guide_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Guide_created_at(ctx, field) + case "tags": + return ec.fieldContext_Guide_tags(ctx, field) + case "user": + return ec.fieldContext_Guide_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _OAuthOptions_google(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_OAuthOptions_google(ctx, field) +func (ec *executionContext) _Mutation_updateGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateGuide(ctx, field) if err != nil { return graphql.Null } @@ -12240,8 +12233,42 @@ func (ec *executionContext) _OAuthOptions_google(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Google, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateGuide(rctx, fc.Args["guideId"].(string), fc.Args["guide"].(UpdateGuide)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "guideId") + if err != nil { + var zeroVal *Guide + return zeroVal, err + } + if ec.directives.CanEditGuide == nil { + var zeroVal *Guide + return zeroVal, errors.New("directive canEditGuide is not implemented") + } + return ec.directives.CanEditGuide(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Guide + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Guide); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Guide`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -12253,26 +12280,59 @@ func (ec *executionContext) _OAuthOptions_google(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Guide) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_google(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "OAuthOptions", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Guide_id(ctx, field) + case "name": + return ec.fieldContext_Guide_name(ctx, field) + case "short_description": + return ec.fieldContext_Guide_short_description(ctx, field) + case "guide": + return ec.fieldContext_Guide_guide(ctx, field) + case "views": + return ec.fieldContext_Guide_views(ctx, field) + case "user_id": + return ec.fieldContext_Guide_user_id(ctx, field) + case "updated_at": + return ec.fieldContext_Guide_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Guide_created_at(ctx, field) + case "tags": + return ec.fieldContext_Guide_tags(ctx, field) + case "user": + return ec.fieldContext_Guide_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _OAuthOptions_facebook(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_OAuthOptions_facebook(ctx, field) +func (ec *executionContext) _Mutation_deleteGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteGuide(ctx, field) if err != nil { return graphql.Null } @@ -12284,8 +12344,42 @@ func (ec *executionContext) _OAuthOptions_facebook(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Facebook, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteGuide(rctx, fc.Args["guideId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "guideId") + if err != nil { + var zeroVal bool + return zeroVal, err + } + if ec.directives.CanEditGuide == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditGuide is not implemented") + } + return ec.directives.CanEditGuide(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -12297,26 +12391,37 @@ func (ec *executionContext) _OAuthOptions_facebook(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_facebook(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "OAuthOptions", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } - return fc, nil -} - -func (ec *executionContext) _Query_getOAuthOptions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getOAuthOptions(ctx, field) + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createMod(ctx, field) if err != nil { return graphql.Null } @@ -12328,40 +12433,105 @@ func (ec *executionContext) _Query_getOAuthOptions(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetOAuthOptions(rctx, fc.Args["callback_url"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateMod(rctx, fc.Args["mod"].(NewMod)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Mod + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Mod); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Mod`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*OAuthOptions) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalNOAuthOptions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOAuthOptions(ctx, field.Selections, res) + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getOAuthOptions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "github": - return ec.fieldContext_OAuthOptions_github(ctx, field) - case "google": - return ec.fieldContext_OAuthOptions_google(ctx, field) - case "facebook": - return ec.fieldContext_OAuthOptions_facebook(ctx, field) + case "id": + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type OAuthOptions", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } defer func() { @@ -12371,15 +12541,15 @@ func (ec *executionContext) fieldContext_Query_getOAuthOptions(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getOAuthOptions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getAnnouncement(ctx, field) +func (ec *executionContext) _Mutation_updateMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateMod(ctx, field) if err != nil { return graphql.Null } @@ -12391,37 +12561,120 @@ func (ec *executionContext) _Query_getAnnouncement(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetAnnouncement(rctx, fc.Args["announcementId"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateMod(rctx, fc.Args["modId"].(string), fc.Args["mod"].(UpdateMod)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + var zeroVal *Mod + return zeroVal, err + } + if ec.directives.CanEditMod == nil { + var zeroVal *Mod + return zeroVal, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Mod + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Mod); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Mod`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Announcement) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) + return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Announcement_id(ctx, field) - case "message": - return ec.fieldContext_Announcement_message(ctx, field) - case "importance": - return ec.fieldContext_Announcement_importance(ctx, field) + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } defer func() { @@ -12431,15 +12684,15 @@ func (ec *executionContext) fieldContext_Query_getAnnouncement(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getAnnouncements(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getAnnouncements(ctx, field) +func (ec *executionContext) _Mutation_deleteMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteMod(ctx, field) if err != nil { return graphql.Null } @@ -12451,60 +12704,42 @@ func (ec *executionContext) _Query_getAnnouncements(ctx context.Context, field g } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetAnnouncements(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteMod(rctx, fc.Args["modId"].(string)) } - return graphql.Null - } - res := resTmp.([]*Announcement) - fc.Result = res - return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) -} -func (ec *executionContext) fieldContext_Query_getAnnouncements(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Announcement_id(ctx, field) - case "message": - return ec.fieldContext_Announcement_message(ctx, field) - case "importance": - return ec.fieldContext_Announcement_importance(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + var zeroVal bool + return zeroVal, err } - return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) - }, - } - return fc, nil -} + if ec.directives.CanEditMod == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } -func (ec *executionContext) _Query_getAnnouncementsByImportance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getAnnouncementsByImportance(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetAnnouncementsByImportance(rctx, fc.Args["importance"].(AnnouncementImportance)) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -12516,27 +12751,19 @@ func (ec *executionContext) _Query_getAnnouncementsByImportance(ctx context.Cont } return graphql.Null } - res := resTmp.([]*Announcement) + res := resTmp.(bool) fc.Result = res - return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getAnnouncementsByImportance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Announcement_id(ctx, field) - case "message": - return ec.fieldContext_Announcement_message(ctx, field) - case "importance": - return ec.fieldContext_Announcement_importance(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -12546,15 +12773,15 @@ func (ec *executionContext) fieldContext_Query_getAnnouncementsByImportance(ctx } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getAnnouncementsByImportance_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getGuide(ctx, field) +func (ec *executionContext) _Mutation_approveMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_approveMod(ctx, field) if err != nil { return graphql.Null } @@ -12566,51 +12793,61 @@ func (ec *executionContext) _Query_getGuide(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetGuide(rctx, fc.Args["guideId"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ApproveMod(rctx, fc.Args["modId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveMods == nil { + var zeroVal bool + return zeroVal, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Guide) + res := resTmp.(bool) fc.Result = res - return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Guide_id(ctx, field) - case "name": - return ec.fieldContext_Guide_name(ctx, field) - case "short_description": - return ec.fieldContext_Guide_short_description(ctx, field) - case "guide": - return ec.fieldContext_Guide_guide(ctx, field) - case "views": - return ec.fieldContext_Guide_views(ctx, field) - case "user_id": - return ec.fieldContext_Guide_user_id(ctx, field) - case "updated_at": - return ec.fieldContext_Guide_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Guide_created_at(ctx, field) - case "tags": - return ec.fieldContext_Guide_tags(ctx, field) - case "user": - return ec.fieldContext_Guide_user(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -12620,15 +12857,15 @@ func (ec *executionContext) fieldContext_Query_getGuide(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getGuides(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getGuides(ctx, field) +func (ec *executionContext) _Mutation_denyMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_denyMod(ctx, field) if err != nil { return graphql.Null } @@ -12640,8 +12877,37 @@ func (ec *executionContext) _Query_getGuides(ctx context.Context, field graphql. } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetGuides(rctx, fc.Args["filter"].(map[string]interface{})) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DenyMod(rctx, fc.Args["modId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveMods == nil { + var zeroVal bool + return zeroVal, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -12653,25 +12919,19 @@ func (ec *executionContext) _Query_getGuides(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(*GetGuides) + res := resTmp.(bool) fc.Result = res - return ec.marshalNGetGuides2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getGuides(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_denyMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "guides": - return ec.fieldContext_GetGuides_guides(ctx, field) - case "count": - return ec.fieldContext_GetGuides_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetGuides", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -12681,15 +12941,15 @@ func (ec *executionContext) fieldContext_Query_getGuides(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getGuides_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_denyMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMod(ctx, field) +func (ec *executionContext) _Mutation_createModpack(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createModpack(ctx, field) if err != nil { return graphql.Null } @@ -12701,8 +12961,30 @@ func (ec *executionContext) _Query_getMod(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMod(rctx, fc.Args["modId"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateModpack(rctx, fc.Args["modpack"].(NewModpack)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Modpack + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Modpack); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Modpack`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -12711,73 +12993,65 @@ func (ec *executionContext) _Query_getMod(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(*Modpack) fc.Result = res - return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalOModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createModpack(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Mod_id(ctx, field) + return ec.fieldContext_Modpack_id(ctx, field) case "name": - return ec.fieldContext_Mod_name(ctx, field) + return ec.fieldContext_Modpack_name(ctx, field) case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) + return ec.fieldContext_Modpack_short_description(ctx, field) case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) + return ec.fieldContext_Modpack_full_description(ctx, field) case "logo": - return ec.fieldContext_Mod_logo(ctx, field) + return ec.fieldContext_Modpack_logo(ctx, field) case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) + return ec.fieldContext_Modpack_hotness(ctx, field) case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) + return ec.fieldContext_Modpack_popularity(ctx, field) case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) + return ec.fieldContext_Modpack_updated_at(ctx, field) case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) + return ec.fieldContext_Modpack_created_at(ctx, field) case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) }, } defer func() { @@ -12787,15 +13061,15 @@ func (ec *executionContext) fieldContext_Query_getMod(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createModpack_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getModByReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getModByReference(ctx, field) +func (ec *executionContext) _Mutation_updateModpack(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateModpack(ctx, field) if err != nil { return graphql.Null } @@ -12807,83 +13081,112 @@ func (ec *executionContext) _Query_getModByReference(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetModByReference(rctx, fc.Args["modReference"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateModpack(rctx, fc.Args["modpackID"].(string), fc.Args["modpack"].(UpdateModpack)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modpackID") + if err != nil { + var zeroVal *Modpack + return zeroVal, err + } + if ec.directives.CanEditModpack == nil { + var zeroVal *Modpack + return zeroVal, errors.New("directive canEditModpack is not implemented") + } + return ec.directives.CanEditModpack(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Modpack + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Modpack); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Modpack`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(*Modpack) fc.Result = res - return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalNModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getModByReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateModpack(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Mod_id(ctx, field) + return ec.fieldContext_Modpack_id(ctx, field) case "name": - return ec.fieldContext_Mod_name(ctx, field) + return ec.fieldContext_Modpack_name(ctx, field) case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) + return ec.fieldContext_Modpack_short_description(ctx, field) case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) + return ec.fieldContext_Modpack_full_description(ctx, field) case "logo": - return ec.fieldContext_Mod_logo(ctx, field) + return ec.fieldContext_Modpack_logo(ctx, field) case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) + return ec.fieldContext_Modpack_hotness(ctx, field) case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) + return ec.fieldContext_Modpack_popularity(ctx, field) case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) + return ec.fieldContext_Modpack_updated_at(ctx, field) case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) + return ec.fieldContext_Modpack_created_at(ctx, field) case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) }, } defer func() { @@ -12893,15 +13196,15 @@ func (ec *executionContext) fieldContext_Query_getModByReference(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getModByReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateModpack_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getModByIdOrReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getModByIdOrReference(ctx, field) +func (ec *executionContext) _Mutation_deleteModpack(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteModpack(ctx, field) if err != nil { return graphql.Null } @@ -12913,83 +13216,66 @@ func (ec *executionContext) _Query_getModByIdOrReference(ctx context.Context, fi } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetModByIDOrReference(rctx, fc.Args["modIdOrReference"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteModpack(rctx, fc.Args["modpackID"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modpackID") + if err != nil { + var zeroVal bool + return zeroVal, err + } + if ec.directives.CanEditModpack == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditModpack is not implemented") + } + return ec.directives.CanEditModpack(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(bool) fc.Result = res - return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getModByIdOrReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteModpack(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -12999,15 +13285,15 @@ func (ec *executionContext) fieldContext_Query_getModByIdOrReference(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getModByIdOrReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteModpack_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMods(ctx, field) +func (ec *executionContext) _Mutation_createModpackRelease(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createModpackRelease(ctx, field) if err != nil { return graphql.Null } @@ -13019,8 +13305,42 @@ func (ec *executionContext) _Query_getMods(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMods(rctx, fc.Args["filter"].(map[string]interface{})) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateModpackRelease(rctx, fc.Args["modpackID"].(string), fc.Args["release"].(NewModpackRelease)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modpackID") + if err != nil { + var zeroVal *ModpackRelease + return zeroVal, err + } + if ec.directives.CanEditModpack == nil { + var zeroVal *ModpackRelease + return zeroVal, errors.New("directive canEditModpack is not implemented") + } + return ec.directives.CanEditModpack(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *ModpackRelease + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*ModpackRelease); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.ModpackRelease`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13032,25 +13352,31 @@ func (ec *executionContext) _Query_getMods(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(*GetMods) + res := resTmp.(*ModpackRelease) fc.Result = res - return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) + return ec.marshalNModpackRelease2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createModpackRelease(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "mods": - return ec.fieldContext_GetMods_mods(ctx, field) - case "count": - return ec.fieldContext_GetMods_count(ctx, field) + case "id": + return ec.fieldContext_ModpackRelease_id(ctx, field) + case "version": + return ec.fieldContext_ModpackRelease_version(ctx, field) + case "created_at": + return ec.fieldContext_ModpackRelease_created_at(ctx, field) + case "lockfile": + return ec.fieldContext_ModpackRelease_lockfile(ctx, field) + case "changelog": + return ec.fieldContext_ModpackRelease_changelog(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type GetMods", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ModpackRelease", field.Name) }, } defer func() { @@ -13060,15 +13386,15 @@ func (ec *executionContext) fieldContext_Query_getMods(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createModpackRelease_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getUnapprovedMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getUnapprovedMods(ctx, field) +func (ec *executionContext) _Mutation_deleteModpackRelease(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteModpackRelease(ctx, field) if err != nil { return graphql.Null } @@ -13082,19 +13408,24 @@ func (ec *executionContext) _Query_getUnapprovedMods(ctx context.Context, field resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetUnapprovedMods(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().DeleteModpackRelease(rctx, fc.Args["modpackID"].(string), fc.Args["version"].(string)) } directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveMods == nil { - var zeroVal *GetMods - return zeroVal, errors.New("directive canApproveMods is not implemented") + field, err := ec.unmarshalNString2string(ctx, "modpackID") + if err != nil { + var zeroVal bool + return zeroVal, err } - return ec.directives.CanApproveMods(ctx, nil, directive0) + if ec.directives.CanEditModpack == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditModpack is not implemented") + } + return ec.directives.CanEditModpack(ctx, nil, directive0, field) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetMods + var zeroVal bool return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive1) @@ -13107,10 +13438,10 @@ func (ec *executionContext) _Query_getUnapprovedMods(ctx context.Context, field if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetMods); ok { + if data, ok := tmp.(bool); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMods`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13122,25 +13453,19 @@ func (ec *executionContext) _Query_getUnapprovedMods(ctx context.Context, field } return graphql.Null } - res := resTmp.(*GetMods) + res := resTmp.(bool) fc.Result = res - return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getUnapprovedMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteModpackRelease(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "mods": - return ec.fieldContext_GetMods_mods(ctx, field) - case "count": - return ec.fieldContext_GetMods_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetMods", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -13150,15 +13475,15 @@ func (ec *executionContext) fieldContext_Query_getUnapprovedMods(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getUnapprovedMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteModpackRelease_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMyMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMyMods(ctx, field) +func (ec *executionContext) _Mutation_resolveModpack(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_resolveModpack(ctx, field) if err != nil { return graphql.Null } @@ -13172,58 +13497,61 @@ func (ec *executionContext) _Query_getMyMods(ctx context.Context, field graphql. resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMyMods(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().ResolveModpack(rctx, fc.Args["modpackID"].(string), fc.Args["targets"].([]string)) } directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modpackID") + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.directives.CanEditModpack == nil { + var zeroVal *string + return zeroVal, errors.New("directive canEditModpack is not implemented") + } + return ec.directives.CanEditModpack(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetMyMods + var zeroVal *string return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return ec.directives.IsLoggedIn(ctx, nil, directive0) + return ec.directives.IsLoggedIn(ctx, nil, directive1) } - tmp, err := directive1(rctx) + tmp, err := directive2(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetMyMods); ok { + if data, ok := tmp.(*string); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyMods`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*GetMyMods) + res := resTmp.(*string) fc.Result = res - return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMyMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_resolveModpack(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "mods": - return ec.fieldContext_GetMyMods_mods(ctx, field) - case "count": - return ec.fieldContext_GetMyMods_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetMyMods", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } defer func() { @@ -13233,15 +13561,15 @@ func (ec *executionContext) fieldContext_Query_getMyMods(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMyMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_resolveModpack_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMyUnapprovedMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMyUnapprovedMods(ctx, field) +func (ec *executionContext) _Mutation_createSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createSatisfactoryVersion(ctx, field) if err != nil { return graphql.Null } @@ -13255,28 +13583,35 @@ func (ec *executionContext) _Query_getMyUnapprovedMods(ctx context.Context, fiel resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMyUnapprovedMods(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().CreateSatisfactoryVersion(rctx, fc.Args["input"].(NewSatisfactoryVersion)) } directive1 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetMyMods + var zeroVal *SatisfactoryVersion return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive0) } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.CanEditSatisfactoryVersions == nil { + var zeroVal *SatisfactoryVersion + return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") + } + return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) + } - tmp, err := directive1(rctx) + tmp, err := directive2(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetMyMods); ok { + if data, ok := tmp.(*SatisfactoryVersion); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyMods`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SatisfactoryVersion`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13288,25 +13623,27 @@ func (ec *executionContext) _Query_getMyUnapprovedMods(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(*GetMyMods) + res := resTmp.(*SatisfactoryVersion) fc.Result = res - return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) + return ec.marshalNSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMyUnapprovedMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "mods": - return ec.fieldContext_GetMyMods_mods(ctx, field) - case "count": - return ec.fieldContext_GetMyMods_count(ctx, field) + case "id": + return ec.fieldContext_SatisfactoryVersion_id(ctx, field) + case "version": + return ec.fieldContext_SatisfactoryVersion_version(ctx, field) + case "engine_version": + return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type GetMyMods", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) }, } defer func() { @@ -13316,15 +13653,15 @@ func (ec *executionContext) fieldContext_Query_getMyUnapprovedMods(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMyUnapprovedMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_resolveModVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_resolveModVersions(ctx, field) +func (ec *executionContext) _Mutation_updateSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateSatisfactoryVersion(ctx, field) if err != nil { return graphql.Null } @@ -13336,8 +13673,37 @@ func (ec *executionContext) _Query_resolveModVersions(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ResolveModVersions(rctx, fc.Args["filter"].([]*ModVersionConstraint)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateSatisfactoryVersion(rctx, fc.Args["id"].(string), fc.Args["input"].(UpdateSatisfactoryVersion)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *SatisfactoryVersion + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.CanEditSatisfactoryVersions == nil { + var zeroVal *SatisfactoryVersion + return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") + } + return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*SatisfactoryVersion); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SatisfactoryVersion`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13349,27 +13715,27 @@ func (ec *executionContext) _Query_resolveModVersions(ctx context.Context, field } return graphql.Null } - res := resTmp.([]*ModVersion) + res := resTmp.(*SatisfactoryVersion) fc.Result = res - return ec.marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionᚄ(ctx, field.Selections, res) + return ec.marshalNSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_resolveModVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_ModVersion_id(ctx, field) - case "mod_reference": - return ec.fieldContext_ModVersion_mod_reference(ctx, field) - case "versions": - return ec.fieldContext_ModVersion_versions(ctx, field) + return ec.fieldContext_SatisfactoryVersion_id(ctx, field) + case "version": + return ec.fieldContext_SatisfactoryVersion_version(ctx, field) + case "engine_version": + return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ModVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) }, } defer func() { @@ -13379,15 +13745,15 @@ func (ec *executionContext) fieldContext_Query_resolveModVersions(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_resolveModVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getModAssetList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getModAssetList(ctx, field) +func (ec *executionContext) _Mutation_deleteSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteSatisfactoryVersion(ctx, field) if err != nil { return graphql.Null } @@ -13399,8 +13765,37 @@ func (ec *executionContext) _Query_getModAssetList(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetModAssetList(rctx, fc.Args["modReference"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteSatisfactoryVersion(rctx, fc.Args["id"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.CanEditSatisfactoryVersions == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditSatisfactoryVersions is not implemented") + } + return ec.directives.CanEditSatisfactoryVersions(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13412,19 +13807,19 @@ func (ec *executionContext) _Query_getModAssetList(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getModAssetList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -13434,15 +13829,15 @@ func (ec *executionContext) fieldContext_Query_getModAssetList(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getModAssetList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getSatisfactoryVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getSatisfactoryVersions(ctx, field) +func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTag(ctx, field) if err != nil { return graphql.Null } @@ -13454,47 +13849,84 @@ func (ec *executionContext) _Query_getSatisfactoryVersions(ctx context.Context, } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetSatisfactoryVersions(rctx) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string), fc.Args["description"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanManageTags == nil { + var zeroVal *Tag + return zeroVal, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Tag + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Tag); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*SatisfactoryVersion) + res := resTmp.(*Tag) fc.Result = res - return ec.marshalNSatisfactoryVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersionᚄ(ctx, field.Selections, res) + return ec.marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getSatisfactoryVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_SatisfactoryVersion_id(ctx, field) - case "version": - return ec.fieldContext_SatisfactoryVersion_version(ctx, field) - case "engine_version": - return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Query_getSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getSatisfactoryVersion(ctx, field) +func (ec *executionContext) _Mutation_createMultipleTags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createMultipleTags(ctx, field) if err != nil { return graphql.Null } @@ -13506,37 +13938,69 @@ func (ec *executionContext) _Query_getSatisfactoryVersion(ctx context.Context, f } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetSatisfactoryVersion(rctx, fc.Args["id"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateMultipleTags(rctx, fc.Args["tagNames"].([]*NewTag)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanManageTags == nil { + var zeroVal []*Tag + return zeroVal, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal []*Tag + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*Tag); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*SatisfactoryVersion) + res := resTmp.([]*Tag) fc.Result = res - return ec.marshalOSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createMultipleTags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_SatisfactoryVersion_id(ctx, field) - case "version": - return ec.fieldContext_SatisfactoryVersion_version(ctx, field) - case "engine_version": - return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } defer func() { @@ -13546,15 +14010,15 @@ func (ec *executionContext) fieldContext_Query_getSatisfactoryVersion(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createMultipleTags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getSMLVersion(ctx, field) +func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateTag(ctx, field) if err != nil { return graphql.Null } @@ -13566,55 +14030,69 @@ func (ec *executionContext) _Query_getSMLVersion(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetSMLVersion(rctx, fc.Args["smlVersionID"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["tagID"].(string), fc.Args["NewName"].(string), fc.Args["description"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanManageTags == nil { + var zeroVal *Tag + return zeroVal, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *Tag + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*Tag); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Tag`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*SMLVersion) + res := resTmp.(*Tag) fc.Result = res - return ec.marshalOSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx, field.Selections, res) + return ec.marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getSMLVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_SMLVersion_id(ctx, field) - case "version": - return ec.fieldContext_SMLVersion_version(ctx, field) - case "satisfactory_version": - return ec.fieldContext_SMLVersion_satisfactory_version(ctx, field) - case "stability": - return ec.fieldContext_SMLVersion_stability(ctx, field) - case "link": - return ec.fieldContext_SMLVersion_link(ctx, field) - case "targets": - return ec.fieldContext_SMLVersion_targets(ctx, field) - case "changelog": - return ec.fieldContext_SMLVersion_changelog(ctx, field) - case "date": - return ec.fieldContext_SMLVersion_date(ctx, field) - case "bootstrap_version": - return ec.fieldContext_SMLVersion_bootstrap_version(ctx, field) - case "engine_version": - return ec.fieldContext_SMLVersion_engine_version(ctx, field) - case "updated_at": - return ec.fieldContext_SMLVersion_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_SMLVersion_created_at(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SMLVersion", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } defer func() { @@ -13624,15 +14102,15 @@ func (ec *executionContext) fieldContext_Query_getSMLVersion(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getSMLVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getSMLVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getSMLVersions(ctx, field) +func (ec *executionContext) _Mutation_deleteTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteTag(ctx, field) if err != nil { return graphql.Null } @@ -13644,8 +14122,37 @@ func (ec *executionContext) _Query_getSMLVersions(ctx context.Context, field gra } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetSMLVersions(rctx, fc.Args["filter"].(map[string]interface{})) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteTag(rctx, fc.Args["tagID"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanManageTags == nil { + var zeroVal bool + return zeroVal, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13657,25 +14164,19 @@ func (ec *executionContext) _Query_getSMLVersions(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(*GetSMLVersions) + res := resTmp.(bool) fc.Result = res - return ec.marshalNGetSMLVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getSMLVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "sml_versions": - return ec.fieldContext_GetSMLVersions_sml_versions(ctx, field) - case "count": - return ec.fieldContext_GetSMLVersions_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetSMLVersions", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -13685,15 +14186,15 @@ func (ec *executionContext) fieldContext_Query_getSMLVersions(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getSMLVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getTag(ctx, field) +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) if err != nil { return graphql.Null } @@ -13705,68 +14206,47 @@ func (ec *executionContext) _Query_getTag(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetTag(rctx, fc.Args["tagID"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Tag) - fc.Result = res - return ec.marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) -} + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["userId"].(string), fc.Args["input"].(UpdateUser)) + } -func (ec *executionContext) fieldContext_Query_getTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "description": - return ec.fieldContext_Tag_description(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "userId") + if err != nil { + var zeroVal *User + return zeroVal, err } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + object, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *User + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *User + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, nil, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *User + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} -func (ec *executionContext) _Query_getTags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getTags(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetTags(rctx, fc.Args["filter"].(*TagFilter)) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.User`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13778,27 +14258,47 @@ func (ec *executionContext) _Query_getTags(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]*Tag) + res := resTmp.(*User) fc.Result = res - return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getTags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "description": - return ec.fieldContext_Tag_description(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) + case "created_at": + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { @@ -13808,15 +14308,15 @@ func (ec *executionContext) fieldContext_Query_getTags(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getTags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMe(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMe(ctx, field) +func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_logout(ctx, field) if err != nil { return graphql.Null } @@ -13830,12 +14330,12 @@ func (ec *executionContext) _Query_getMe(ctx context.Context, field graphql.Coll resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMe(rctx) + return ec.resolvers.Mutation().Logout(rctx) } directive1 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *User + var zeroVal bool return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive0) @@ -13848,66 +14348,41 @@ func (ec *executionContext) _Query_getMe(ctx context.Context, field graphql.Coll if tmp == nil { return nil, nil } - if data, ok := tmp.(*User); ok { + if data, ok := tmp.(bool); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.User`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*User) + res := resTmp.(bool) fc.Result = res - return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMe(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "avatar": - return ec.fieldContext_User_avatar(ctx, field) - case "avatar_thumbhash": - return ec.fieldContext_User_avatar_thumbhash(ctx, field) - case "created_at": - return ec.fieldContext_User_created_at(ctx, field) - case "github_id": - return ec.fieldContext_User_github_id(ctx, field) - case "google_id": - return ec.fieldContext_User_google_id(ctx, field) - case "facebook_id": - return ec.fieldContext_User_facebook_id(ctx, field) - case "roles": - return ec.fieldContext_User_roles(ctx, field) - case "groups": - return ec.fieldContext_User_groups(ctx, field) - case "mods": - return ec.fieldContext_User_mods(ctx, field) - case "guides": - return ec.fieldContext_User_guides(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getUser(ctx, field) +func (ec *executionContext) _Mutation_oAuthGithub(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_oAuthGithub(ctx, field) if err != nil { return graphql.Null } @@ -13919,8 +14394,30 @@ func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetUser(rctx, fc.Args["userId"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().OAuthGithub(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsNotLoggedIn == nil { + var zeroVal *UserSession + return zeroVal, errors.New("directive isNotLoggedIn is not implemented") + } + return ec.directives.IsNotLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*UserSession); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -13929,47 +14426,23 @@ func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(*User) + res := resTmp.(*UserSession) fc.Result = res - return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_oAuthGithub(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "avatar": - return ec.fieldContext_User_avatar(ctx, field) - case "avatar_thumbhash": - return ec.fieldContext_User_avatar_thumbhash(ctx, field) - case "created_at": - return ec.fieldContext_User_created_at(ctx, field) - case "github_id": - return ec.fieldContext_User_github_id(ctx, field) - case "google_id": - return ec.fieldContext_User_google_id(ctx, field) - case "facebook_id": - return ec.fieldContext_User_facebook_id(ctx, field) - case "roles": - return ec.fieldContext_User_roles(ctx, field) - case "groups": - return ec.fieldContext_User_groups(ctx, field) - case "mods": - return ec.fieldContext_User_mods(ctx, field) - case "guides": - return ec.fieldContext_User_guides(ctx, field) + case "token": + return ec.fieldContext_UserSession_token(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) }, } defer func() { @@ -13979,15 +14452,15 @@ func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_oAuthGithub_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getUsers(ctx, field) +func (ec *executionContext) _Mutation_oAuthGoogle(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_oAuthGoogle(ctx, field) if err != nil { return graphql.Null } @@ -13999,91 +14472,30 @@ func (ec *executionContext) _Query_getUsers(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetUsers(rctx, fc.Args["userIds"].([]string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().OAuthGoogle(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) } - return graphql.Null - } - res := resTmp.([]*User) - fc.Result = res - return ec.marshalNUser2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) -} -func (ec *executionContext) fieldContext_Query_getUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "avatar": - return ec.fieldContext_User_avatar(ctx, field) - case "avatar_thumbhash": - return ec.fieldContext_User_avatar_thumbhash(ctx, field) - case "created_at": - return ec.fieldContext_User_created_at(ctx, field) - case "github_id": - return ec.fieldContext_User_github_id(ctx, field) - case "google_id": - return ec.fieldContext_User_google_id(ctx, field) - case "facebook_id": - return ec.fieldContext_User_facebook_id(ctx, field) - case "roles": - return ec.fieldContext_User_roles(ctx, field) - case "groups": - return ec.fieldContext_User_groups(ctx, field) - case "mods": - return ec.fieldContext_User_mods(ctx, field) - case "guides": - return ec.fieldContext_User_guides(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsNotLoggedIn == nil { + var zeroVal *UserSession + return zeroVal, errors.New("directive isNotLoggedIn is not implemented") } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + return ec.directives.IsNotLoggedIn(ctx, nil, directive0) } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} -func (ec *executionContext) _Query_getVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getVersion(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetVersion(rctx, fc.Args["versionId"].(string)) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*UserSession); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14092,61 +14504,23 @@ func (ec *executionContext) _Query_getVersion(ctx context.Context, field graphql if resTmp == nil { return graphql.Null } - res := resTmp.(*Version) + res := resTmp.(*UserSession) fc.Result = res - return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_oAuthGoogle(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Version_id(ctx, field) - case "mod_id": - return ec.fieldContext_Version_mod_id(ctx, field) - case "version": - return ec.fieldContext_Version_version(ctx, field) - case "sml_version": - return ec.fieldContext_Version_sml_version(ctx, field) - case "game_version": - return ec.fieldContext_Version_game_version(ctx, field) - case "required_on_remote": - return ec.fieldContext_Version_required_on_remote(ctx, field) - case "changelog": - return ec.fieldContext_Version_changelog(ctx, field) - case "downloads": - return ec.fieldContext_Version_downloads(ctx, field) - case "stability": - return ec.fieldContext_Version_stability(ctx, field) - case "approved": - return ec.fieldContext_Version_approved(ctx, field) - case "updated_at": - return ec.fieldContext_Version_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Version_created_at(ctx, field) - case "link": - return ec.fieldContext_Version_link(ctx, field) - case "targets": - return ec.fieldContext_Version_targets(ctx, field) - case "metadata": - return ec.fieldContext_Version_metadata(ctx, field) - case "size": - return ec.fieldContext_Version_size(ctx, field) - case "hash": - return ec.fieldContext_Version_hash(ctx, field) - case "mod": - return ec.fieldContext_Version_mod(ctx, field) - case "dependencies": - return ec.fieldContext_Version_dependencies(ctx, field) - case "virustotal_results": - return ec.fieldContext_Version_virustotal_results(ctx, field) + case "token": + return ec.fieldContext_UserSession_token(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) }, } defer func() { @@ -14156,15 +14530,15 @@ func (ec *executionContext) fieldContext_Query_getVersion(ctx context.Context, f } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_oAuthGoogle_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getVersions(ctx, field) +func (ec *executionContext) _Mutation_oAuthFacebook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_oAuthFacebook(ctx, field) if err != nil { return graphql.Null } @@ -14176,38 +14550,55 @@ func (ec *executionContext) _Query_getVersions(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetVersions(rctx, fc.Args["filter"].(map[string]interface{})) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().OAuthFacebook(rctx, fc.Args["code"].(string), fc.Args["state"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsNotLoggedIn == nil { + var zeroVal *UserSession + return zeroVal, errors.New("directive isNotLoggedIn is not implemented") + } + return ec.directives.IsNotLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*UserSession); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserSession`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*GetVersions) + res := resTmp.(*UserSession) fc.Result = res - return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_oAuthFacebook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "versions": - return ec.fieldContext_GetVersions_versions(ctx, field) - case "count": - return ec.fieldContext_GetVersions_count(ctx, field) + case "token": + return ec.fieldContext_UserSession_token(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type GetVersions", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserSession", field.Name) }, } defer func() { @@ -14217,15 +14608,15 @@ func (ec *executionContext) fieldContext_Query_getVersions(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_oAuthFacebook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getUnapprovedVersions(ctx, field) +func (ec *executionContext) _Mutation_createVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createVersion(ctx, field) if err != nil { return graphql.Null } @@ -14239,19 +14630,24 @@ func (ec *executionContext) _Query_getUnapprovedVersions(ctx context.Context, fi resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetUnapprovedVersions(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().CreateVersion(rctx, fc.Args["modId"].(string)) } directive1 := func(ctx context.Context) (any, error) { - if ec.directives.CanApproveVersions == nil { - var zeroVal *GetVersions - return zeroVal, errors.New("directive canApproveVersions is not implemented") + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + var zeroVal string + return zeroVal, err } - return ec.directives.CanApproveVersions(ctx, nil, directive0) + if ec.directives.CanEditMod == nil { + var zeroVal string + return zeroVal, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetVersions + var zeroVal string return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive1) @@ -14264,10 +14660,10 @@ func (ec *executionContext) _Query_getUnapprovedVersions(ctx context.Context, fi if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetVersions); ok { + if data, ok := tmp.(string); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetVersions`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14279,25 +14675,19 @@ func (ec *executionContext) _Query_getUnapprovedVersions(ctx context.Context, fi } return graphql.Null } - res := resTmp.(*GetVersions) + res := resTmp.(string) fc.Result = res - return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) + return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "versions": - return ec.fieldContext_GetVersions_versions(ctx, field) - case "count": - return ec.fieldContext_GetVersions_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetVersions", field.Name) + return nil, errors.New("field of type VersionID does not have child fields") }, } defer func() { @@ -14307,15 +14697,15 @@ func (ec *executionContext) fieldContext_Query_getUnapprovedVersions(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getUnapprovedVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_checkVersionUploadState(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_checkVersionUploadState(ctx, field) +func (ec *executionContext) _Mutation_uploadVersionPart(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_uploadVersionPart(ctx, field) if err != nil { return graphql.Null } @@ -14329,24 +14719,24 @@ func (ec *executionContext) _Query_checkVersionUploadState(ctx context.Context, resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CheckVersionUploadState(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string)) + return ec.resolvers.Mutation().UploadVersionPart(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string), fc.Args["part"].(int), fc.Args["file"].(graphql.Upload)) } directive1 := func(ctx context.Context) (any, error) { field, err := ec.unmarshalNString2string(ctx, "modId") if err != nil { - var zeroVal *CreateVersionResponse + var zeroVal bool return zeroVal, err } if ec.directives.CanEditMod == nil { - var zeroVal *CreateVersionResponse + var zeroVal bool return zeroVal, errors.New("directive canEditMod is not implemented") } return ec.directives.CanEditMod(ctx, nil, directive0, field) } directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *CreateVersionResponse + var zeroVal bool return zeroVal, errors.New("directive isLoggedIn is not implemented") } return ec.directives.IsLoggedIn(ctx, nil, directive1) @@ -14359,37 +14749,34 @@ func (ec *executionContext) _Query_checkVersionUploadState(ctx context.Context, if tmp == nil { return nil, nil } - if data, ok := tmp.(*CreateVersionResponse); ok { + if data, ok := tmp.(bool); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.CreateVersionResponse`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*CreateVersionResponse) + res := resTmp.(bool) fc.Result = res - return ec.marshalOCreateVersionResponse2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCreateVersionResponse(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_checkVersionUploadState(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_uploadVersionPart(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "auto_approved": - return ec.fieldContext_CreateVersionResponse_auto_approved(ctx, field) - case "version": - return ec.fieldContext_CreateVersionResponse_version(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CreateVersionResponse", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -14399,15 +14786,15 @@ func (ec *executionContext) fieldContext_Query_checkVersionUploadState(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_checkVersionUploadState_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_uploadVersionPart_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMyVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMyVersions(ctx, field) +func (ec *executionContext) _Mutation_finalizeCreateVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_finalizeCreateVersion(ctx, field) if err != nil { return graphql.Null } @@ -14421,28 +14808,40 @@ func (ec *executionContext) _Query_getMyVersions(ctx context.Context, field grap resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMyVersions(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().FinalizeCreateVersion(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string), fc.Args["version"].(NewVersion)) } directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + var zeroVal bool + return zeroVal, err + } + if ec.directives.CanEditMod == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetMyVersions + var zeroVal bool return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return ec.directives.IsLoggedIn(ctx, nil, directive0) + return ec.directives.IsLoggedIn(ctx, nil, directive1) } - tmp, err := directive1(rctx) + tmp, err := directive2(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetMyVersions); ok { + if data, ok := tmp.(bool); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyVersions`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14454,25 +14853,19 @@ func (ec *executionContext) _Query_getMyVersions(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*GetMyVersions) + res := resTmp.(bool) fc.Result = res - return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMyVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_finalizeCreateVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "versions": - return ec.fieldContext_GetMyVersions_versions(ctx, field) - case "count": - return ec.fieldContext_GetMyVersions_count(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type GetMyVersions", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -14482,15 +14875,15 @@ func (ec *executionContext) fieldContext_Query_getMyVersions(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMyVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_finalizeCreateVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_getMyUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_getMyUnapprovedVersions(ctx, field) +func (ec *executionContext) _Mutation_updateVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateVersion(ctx, field) if err != nil { return graphql.Null } @@ -14504,28 +14897,40 @@ func (ec *executionContext) _Query_getMyUnapprovedVersions(ctx context.Context, resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetMyUnapprovedVersions(rctx, fc.Args["filter"].(map[string]interface{})) + return ec.resolvers.Mutation().UpdateVersion(rctx, fc.Args["versionId"].(string), fc.Args["version"].(UpdateVersion)) } directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "versionId") + if err != nil { + var zeroVal *Version + return zeroVal, err + } + if ec.directives.CanEditVersion == nil { + var zeroVal *Version + return zeroVal, errors.New("directive canEditVersion is not implemented") + } + return ec.directives.CanEditVersion(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal *GetMyVersions + var zeroVal *Version return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return ec.directives.IsLoggedIn(ctx, nil, directive0) + return ec.directives.IsLoggedIn(ctx, nil, directive1) } - tmp, err := directive1(rctx) + tmp, err := directive2(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.(*GetMyVersions); ok { + if data, ok := tmp.(*Version); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyVersions`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.Version`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14537,25 +14942,61 @@ func (ec *executionContext) _Query_getMyUnapprovedVersions(ctx context.Context, } return graphql.Null } - res := resTmp.(*GetMyVersions) + res := resTmp.(*Version) fc.Result = res - return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) + return ec.marshalNVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMyUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "versions": - return ec.fieldContext_GetMyVersions_versions(ctx, field) - case "count": - return ec.fieldContext_GetMyVersions_count(ctx, field) + case "id": + return ec.fieldContext_Version_id(ctx, field) + case "mod_id": + return ec.fieldContext_Version_mod_id(ctx, field) + case "version": + return ec.fieldContext_Version_version(ctx, field) + case "sml_version": + return ec.fieldContext_Version_sml_version(ctx, field) + case "game_version": + return ec.fieldContext_Version_game_version(ctx, field) + case "required_on_remote": + return ec.fieldContext_Version_required_on_remote(ctx, field) + case "changelog": + return ec.fieldContext_Version_changelog(ctx, field) + case "downloads": + return ec.fieldContext_Version_downloads(ctx, field) + case "stability": + return ec.fieldContext_Version_stability(ctx, field) + case "approved": + return ec.fieldContext_Version_approved(ctx, field) + case "updated_at": + return ec.fieldContext_Version_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Version_created_at(ctx, field) + case "link": + return ec.fieldContext_Version_link(ctx, field) + case "targets": + return ec.fieldContext_Version_targets(ctx, field) + case "metadata": + return ec.fieldContext_Version_metadata(ctx, field) + case "size": + return ec.fieldContext_Version_size(ctx, field) + case "hash": + return ec.fieldContext_Version_hash(ctx, field) + case "mod": + return ec.fieldContext_Version_mod(ctx, field) + case "dependencies": + return ec.fieldContext_Version_dependencies(ctx, field) + case "virustotal_results": + return ec.fieldContext_Version_virustotal_results(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type GetMyVersions", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) }, } defer func() { @@ -14565,15 +15006,15 @@ func (ec *executionContext) fieldContext_Query_getMyUnapprovedVersions(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_getMyUnapprovedVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Mutation_deleteVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteVersion(ctx, field) if err != nil { return graphql.Null } @@ -14585,53 +15026,66 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteVersion(rctx, fc.Args["versionId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "versionId") + if err != nil { + var zeroVal bool + return zeroVal, err + } + if ec.directives.CanEditVersion == nil { + var zeroVal bool + return zeroVal, errors.New("directive canEditVersion is not implemented") + } + return ec.directives.CanEditVersion(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Mutation", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { @@ -14641,15 +15095,15 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _Mutation_approveVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_approveVersion(ctx, field) if err != nil { return graphql.Null } @@ -14661,63 +15115,37 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ApproveVersion(rctx, fc.Args["versionId"].(string)) + } -func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveVersions == nil { + var zeroVal bool + return zeroVal, errors.New("directive canApproveVersions is not implemented") } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } -func (ec *executionContext) _SMLVersion_id(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14729,26 +15157,37 @@ func (ec *executionContext) _SMLVersion_id(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type SMLVersionID does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_approveVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SMLVersion_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_version(ctx, field) +func (ec *executionContext) _Mutation_denyVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_denyVersion(ctx, field) if err != nil { return graphql.Null } @@ -14760,8 +15199,37 @@ func (ec *executionContext) _SMLVersion_version(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Version, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DenyVersion(rctx, fc.Args["versionId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveVersions == nil { + var zeroVal bool + return zeroVal, errors.New("directive canApproveVersions is not implemented") + } + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal bool + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -14773,26 +15241,37 @@ func (ec *executionContext) _SMLVersion_version(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_denyVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_denyVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SMLVersion_satisfactory_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_satisfactory_version(ctx, field) +func (ec *executionContext) _OAuthOptions_github(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuthOptions_github(ctx, field) if err != nil { return graphql.Null } @@ -14805,7 +15284,7 @@ func (ec *executionContext) _SMLVersion_satisfactory_version(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.SatisfactoryVersion, nil + return obj.Github, nil }) if err != nil { ec.Error(ctx, err) @@ -14817,26 +15296,26 @@ func (ec *executionContext) _SMLVersion_satisfactory_version(ctx context.Context } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_satisfactory_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_OAuthOptions_github(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "OAuthOptions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SMLVersion_stability(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_stability(ctx, field) +func (ec *executionContext) _OAuthOptions_google(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuthOptions_google(ctx, field) if err != nil { return graphql.Null } @@ -14849,7 +15328,7 @@ func (ec *executionContext) _SMLVersion_stability(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Stability, nil + return obj.Google, nil }) if err != nil { ec.Error(ctx, err) @@ -14861,26 +15340,26 @@ func (ec *executionContext) _SMLVersion_stability(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(VersionStabilities) + res := resTmp.(string) fc.Result = res - return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_stability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_OAuthOptions_google(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "OAuthOptions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionStabilities does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _SMLVersion_link(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_link(ctx, field) +func (ec *executionContext) _OAuthOptions_facebook(ctx context.Context, field graphql.CollectedField, obj *OAuthOptions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OAuthOptions_facebook(ctx, field) if err != nil { return graphql.Null } @@ -14893,7 +15372,7 @@ func (ec *executionContext) _SMLVersion_link(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.SMLVersion().Link(rctx, obj) + return obj.Facebook, nil }) if err != nil { ec.Error(ctx, err) @@ -14910,12 +15389,12 @@ func (ec *executionContext) _SMLVersion_link(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_OAuthOptions_facebook(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "OAuthOptions", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -14923,8 +15402,8 @@ func (ec *executionContext) fieldContext_SMLVersion_link(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _SMLVersion_targets(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_targets(ctx, field) +func (ec *executionContext) _Query_getOAuthOptions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getOAuthOptions(ctx, field) if err != nil { return graphql.Null } @@ -14937,7 +15416,7 @@ func (ec *executionContext) _SMLVersion_targets(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Targets, nil + return ec.resolvers.Query().GetOAuthOptions(rctx, fc.Args["callback_url"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -14949,34 +15428,45 @@ func (ec *executionContext) _SMLVersion_targets(ctx context.Context, field graph } return graphql.Null } - res := resTmp.([]*SMLVersionTarget) + res := resTmp.(*OAuthOptions) fc.Result = res - return ec.marshalNSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx, field.Selections, res) + return ec.marshalNOAuthOptions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOAuthOptions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_targets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getOAuthOptions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "VersionID": - return ec.fieldContext_SMLVersionTarget_VersionID(ctx, field) - case "targetName": - return ec.fieldContext_SMLVersionTarget_targetName(ctx, field) - case "link": - return ec.fieldContext_SMLVersionTarget_link(ctx, field) + case "github": + return ec.fieldContext_OAuthOptions_github(ctx, field) + case "google": + return ec.fieldContext_OAuthOptions_google(ctx, field) + case "facebook": + return ec.fieldContext_OAuthOptions_facebook(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SMLVersionTarget", field.Name) + return nil, fmt.Errorf("no field named %q was found under type OAuthOptions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getOAuthOptions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SMLVersion_changelog(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_changelog(ctx, field) +func (ec *executionContext) _Query_getAnnouncement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getAnnouncement(ctx, field) if err != nil { return graphql.Null } @@ -14989,82 +15479,54 @@ func (ec *executionContext) _SMLVersion_changelog(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Changelog, nil + return ec.resolvers.Query().GetAnnouncement(rctx, fc.Args["announcementId"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Announcement) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_changelog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getAnnouncement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Announcement_id(ctx, field) + case "message": + return ec.fieldContext_Announcement_message(ctx, field) + case "importance": + return ec.fieldContext_Announcement_importance(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) }, } - return fc, nil -} - -func (ec *executionContext) _SMLVersion_date(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_date(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Date, nil - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getAnnouncement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SMLVersion_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SMLVersion", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") - }, + return fc, err } return fc, nil } -func (ec *executionContext) _SMLVersion_bootstrap_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_bootstrap_version(ctx, field) +func (ec *executionContext) _Query_getAnnouncements(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getAnnouncements(ctx, field) if err != nil { return graphql.Null } @@ -15077,35 +15539,46 @@ func (ec *executionContext) _SMLVersion_bootstrap_version(ctx context.Context, f }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.SMLVersion().BootstrapVersion(rctx, obj) + return ec.resolvers.Query().GetAnnouncements(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*Announcement) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_bootstrap_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getAnnouncements(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Announcement_id(ctx, field) + case "message": + return ec.fieldContext_Announcement_message(ctx, field) + case "importance": + return ec.fieldContext_Announcement_importance(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) }, } return fc, nil } -func (ec *executionContext) _SMLVersion_engine_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_engine_version(ctx, field) +func (ec *executionContext) _Query_getAnnouncementsByImportance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getAnnouncementsByImportance(ctx, field) if err != nil { return graphql.Null } @@ -15118,7 +15591,7 @@ func (ec *executionContext) _SMLVersion_engine_version(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.SMLVersion().EngineVersion(rctx, obj) + return ec.resolvers.Query().GetAnnouncementsByImportance(rctx, fc.Args["importance"].(AnnouncementImportance)) }) if err != nil { ec.Error(ctx, err) @@ -15130,70 +15603,45 @@ func (ec *executionContext) _SMLVersion_engine_version(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*Announcement) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_engine_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getAnnouncementsByImportance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Announcement_id(ctx, field) + case "message": + return ec.fieldContext_Announcement_message(ctx, field) + case "importance": + return ec.fieldContext_Announcement_importance(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Announcement", field.Name) }, } - return fc, nil -} - -func (ec *executionContext) _SMLVersion_updated_at(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_updated_at(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, nil - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getAnnouncementsByImportance_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SMLVersion_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SMLVersion", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") - }, + return fc, err } return fc, nil } -func (ec *executionContext) _SMLVersion_created_at(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersion_created_at(ctx, field) +func (ec *executionContext) _Query_getGuide(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getGuide(ctx, field) if err != nil { return graphql.Null } @@ -15206,38 +15654,68 @@ func (ec *executionContext) _SMLVersion_created_at(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return ec.resolvers.Query().GetGuide(rctx, fc.Args["guideId"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Guide) fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) + return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getGuide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Guide_id(ctx, field) + case "name": + return ec.fieldContext_Guide_name(ctx, field) + case "short_description": + return ec.fieldContext_Guide_short_description(ctx, field) + case "guide": + return ec.fieldContext_Guide_guide(ctx, field) + case "views": + return ec.fieldContext_Guide_views(ctx, field) + case "user_id": + return ec.fieldContext_Guide_user_id(ctx, field) + case "updated_at": + return ec.fieldContext_Guide_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Guide_created_at(ctx, field) + case "tags": + return ec.fieldContext_Guide_tags(ctx, field) + case "user": + return ec.fieldContext_Guide_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getGuide_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SMLVersionTarget_VersionID(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersionTarget_VersionID(ctx, field) +func (ec *executionContext) _Query_getGuides(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getGuides(ctx, field) if err != nil { return graphql.Null } @@ -15250,7 +15728,7 @@ func (ec *executionContext) _SMLVersionTarget_VersionID(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.VersionID, nil + return ec.resolvers.Query().GetGuides(rctx, fc.Args["filter"].(map[string]interface{})) }) if err != nil { ec.Error(ctx, err) @@ -15262,26 +15740,43 @@ func (ec *executionContext) _SMLVersionTarget_VersionID(ctx context.Context, fie } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetGuides) fc.Result = res - return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) + return ec.marshalNGetGuides2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_VersionID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getGuides(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersionTarget", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type SMLVersionID does not have child fields") + switch field.Name { + case "guides": + return ec.fieldContext_GetGuides_guides(ctx, field) + case "count": + return ec.fieldContext_GetGuides_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetGuides", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getGuides_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SMLVersionTarget_targetName(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersionTarget_targetName(ctx, field) +func (ec *executionContext) _Query_getMod(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMod(ctx, field) if err != nil { return graphql.Null } @@ -15294,38 +15789,100 @@ func (ec *executionContext) _SMLVersionTarget_targetName(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.TargetName, nil + return ec.resolvers.Query().GetMod(rctx, fc.Args["modId"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(TargetName) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_targetName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersionTarget", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TargetName does not have child fields") - }, - } - return fc, nil -} + switch field.Name { + case "id": + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} -func (ec *executionContext) _SMLVersionTarget_link(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SMLVersionTarget_link(ctx, field) +func (ec *executionContext) _Query_getModByReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModByReference(ctx, field) if err != nil { return graphql.Null } @@ -15338,38 +15895,100 @@ func (ec *executionContext) _SMLVersionTarget_link(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.SMLVersionTarget().Link(rctx, obj) + return ec.resolvers.Query().GetModByReference(rctx, fc.Args["modReference"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModByReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SMLVersionTarget", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModByReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SatisfactoryVersion_id(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SatisfactoryVersion_id(ctx, field) +func (ec *executionContext) _Query_getModByIdOrReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModByIdOrReference(ctx, field) if err != nil { return graphql.Null } @@ -15382,38 +16001,100 @@ func (ec *executionContext) _SatisfactoryVersion_id(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Query().GetModByIDOrReference(rctx, fc.Args["modIdOrReference"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalNSatisfactoryVersionID2string(ctx, field.Selections, res) + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SatisfactoryVersion_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModByIdOrReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SatisfactoryVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type SatisfactoryVersionID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModByIdOrReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SatisfactoryVersion_version(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SatisfactoryVersion_version(ctx, field) +func (ec *executionContext) _Query_getMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMods(ctx, field) if err != nil { return graphql.Null } @@ -15426,7 +16107,7 @@ func (ec *executionContext) _SatisfactoryVersion_version(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Version, nil + return ec.resolvers.Query().GetMods(rctx, fc.Args["filter"].(map[string]interface{})) }) if err != nil { ec.Error(ctx, err) @@ -15438,26 +16119,43 @@ func (ec *executionContext) _SatisfactoryVersion_version(ctx context.Context, fi } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*GetMods) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SatisfactoryVersion_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SatisfactoryVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "mods": + return ec.fieldContext_GetMods_mods(ctx, field) + case "count": + return ec.fieldContext_GetMods_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetMods", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SatisfactoryVersion_engine_version(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) +func (ec *executionContext) _Query_getUnapprovedMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getUnapprovedMods(ctx, field) if err != nil { return graphql.Null } @@ -15469,8 +16167,37 @@ func (ec *executionContext) _SatisfactoryVersion_engine_version(ctx context.Cont } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.EngineVersion, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetUnapprovedMods(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveMods == nil { + var zeroVal *GetMods + return zeroVal, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetMods + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetMods); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMods`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15482,26 +16209,43 @@ func (ec *executionContext) _SatisfactoryVersion_engine_version(ctx context.Cont } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetMods) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SatisfactoryVersion_engine_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getUnapprovedMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SatisfactoryVersion", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "mods": + return ec.fieldContext_GetMods_mods(ctx, field) + case "count": + return ec.fieldContext_GetMods_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetMods", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getUnapprovedMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_id(ctx, field) +func (ec *executionContext) _Query_getMyMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMyMods(ctx, field) if err != nil { return graphql.Null } @@ -15513,8 +16257,30 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMyMods(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetMyMods + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetMyMods); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyMods`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15526,26 +16292,43 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetMyMods) fc.Result = res - return ec.marshalNTagID2string(ctx, field.Selections, res) + return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMyMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagID does not have child fields") + switch field.Name { + case "mods": + return ec.fieldContext_GetMyMods_mods(ctx, field) + case "count": + return ec.fieldContext_GetMyMods_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetMyMods", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMyMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_name(ctx, field) +func (ec *executionContext) _Query_getMyUnapprovedMods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMyUnapprovedMods(ctx, field) if err != nil { return graphql.Null } @@ -15557,8 +16340,30 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMyUnapprovedMods(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetMyMods + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetMyMods); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyMods`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -15570,26 +16375,43 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetMyMods) fc.Result = res - return ec.marshalNTagName2string(ctx, field.Selections, res) + return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMyUnapprovedMods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagName does not have child fields") + switch field.Name { + case "mods": + return ec.fieldContext_GetMyMods_mods(ctx, field) + case "count": + return ec.fieldContext_GetMyMods_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetMyMods", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMyUnapprovedMods_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_description(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_description(ctx, field) +func (ec *executionContext) _Query_resolveModVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_resolveModVersions(ctx, field) if err != nil { return graphql.Null } @@ -15602,7 +16424,7 @@ func (ec *executionContext) _Tag_description(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.resolvers.Query().ResolveModVersions(rctx, fc.Args["filter"].([]*ModVersionConstraint)) }) if err != nil { ec.Error(ctx, err) @@ -15614,26 +16436,45 @@ func (ec *executionContext) _Tag_description(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ModVersion) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_resolveModVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_ModVersion_id(ctx, field) + case "mod_reference": + return ec.fieldContext_ModVersion_mod_reference(ctx, field) + case "versions": + return ec.fieldContext_ModVersion_versions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ModVersion", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_resolveModVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _Query_getModAssetList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModAssetList(ctx, field) if err != nil { return graphql.Null } @@ -15646,7 +16487,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Query().GetModAssetList(rctx, fc.Args["modReference"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -15658,26 +16499,37 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]string) fc.Result = res - return ec.marshalNUserID2string(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModAssetList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type UserID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModAssetList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_email(ctx, field) +func (ec *executionContext) _Query_getModpack(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModpack(ctx, field) if err != nil { return graphql.Null } @@ -15689,47 +16541,8 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Email, nil - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal *string - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal *string - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *string - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetModpack(rctx, fc.Args["modpackID"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -15738,26 +16551,83 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*Modpack) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModpack(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Modpack_id(ctx, field) + case "name": + return ec.fieldContext_Modpack_name(ctx, field) + case "short_description": + return ec.fieldContext_Modpack_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Modpack_full_description(ctx, field) + case "logo": + return ec.fieldContext_Modpack_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Modpack_logo_thumbhash(ctx, field) + case "creator_id": + return ec.fieldContext_Modpack_creator_id(ctx, field) + case "creator": + return ec.fieldContext_Modpack_creator(ctx, field) + case "views": + return ec.fieldContext_Modpack_views(ctx, field) + case "installs": + return ec.fieldContext_Modpack_installs(ctx, field) + case "hotness": + return ec.fieldContext_Modpack_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Modpack_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Modpack_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Modpack_created_at(ctx, field) + case "hidden": + return ec.fieldContext_Modpack_hidden(ctx, field) + case "parent_id": + return ec.fieldContext_Modpack_parent_id(ctx, field) + case "parent": + return ec.fieldContext_Modpack_parent(ctx, field) + case "children": + return ec.fieldContext_Modpack_children(ctx, field) + case "tags": + return ec.fieldContext_Modpack_tags(ctx, field) + case "targets": + return ec.fieldContext_Modpack_targets(ctx, field) + case "mods": + return ec.fieldContext_Modpack_mods(ctx, field) + case "releases": + return ec.fieldContext_Modpack_releases(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Modpack", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModpack_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_username(ctx, field) +func (ec *executionContext) _Query_getModpacks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModpacks(ctx, field) if err != nil { return graphql.Null } @@ -15770,7 +16640,7 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Username, nil + return ec.resolvers.Query().GetModpacks(rctx, fc.Args["filter"].(*ModpackFilter)) }) if err != nil { ec.Error(ctx, err) @@ -15782,26 +16652,43 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetModpacks) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNGetModpacks2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetModpacks(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_username(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModpacks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "modpacks": + return ec.fieldContext_GetModpacks_modpacks(ctx, field) + case "count": + return ec.fieldContext_GetModpacks_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetModpacks", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModpacks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_avatar(ctx, field) +func (ec *executionContext) _Query_getModpackRelease(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getModpackRelease(ctx, field) if err != nil { return graphql.Null } @@ -15814,7 +16701,7 @@ func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Avatar, nil + return ec.resolvers.Query().GetModpackRelease(rctx, fc.Args["modpackID"].(string), fc.Args["version"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -15823,26 +16710,49 @@ func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*ModpackRelease) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOModpackRelease2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_avatar(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getModpackRelease(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_ModpackRelease_id(ctx, field) + case "version": + return ec.fieldContext_ModpackRelease_version(ctx, field) + case "created_at": + return ec.fieldContext_ModpackRelease_created_at(ctx, field) + case "lockfile": + return ec.fieldContext_ModpackRelease_lockfile(ctx, field) + case "changelog": + return ec.fieldContext_ModpackRelease_changelog(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ModpackRelease", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getModpackRelease_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_avatar_thumbhash(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_avatar_thumbhash(ctx, field) +func (ec *executionContext) _Query_getSatisfactoryVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getSatisfactoryVersions(ctx, field) if err != nil { return graphql.Null } @@ -15855,35 +16765,46 @@ func (ec *executionContext) _User_avatar_thumbhash(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.AvatarThumbhash, nil + return ec.resolvers.Query().GetSatisfactoryVersions(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*SatisfactoryVersion) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNSatisfactoryVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_avatar_thumbhash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getSatisfactoryVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_SatisfactoryVersion_id(ctx, field) + case "version": + return ec.fieldContext_SatisfactoryVersion_version(ctx, field) + case "engine_version": + return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_created_at(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_created_at(ctx, field) +func (ec *executionContext) _Query_getSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getSatisfactoryVersion(ctx, field) if err != nil { return graphql.Null } @@ -15896,38 +16817,54 @@ func (ec *executionContext) _User_created_at(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return ec.resolvers.Query().GetSatisfactoryVersion(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*SatisfactoryVersion) fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) + return ec.marshalOSatisfactoryVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSatisfactoryVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getSatisfactoryVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_SatisfactoryVersion_id(ctx, field) + case "version": + return ec.fieldContext_SatisfactoryVersion_version(ctx, field) + case "engine_version": + return ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SatisfactoryVersion", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getSatisfactoryVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_github_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_github_id(ctx, field) +func (ec *executionContext) _Query_getSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getSMLVersion(ctx, field) if err != nil { return graphql.Null } @@ -15939,47 +16876,8 @@ func (ec *executionContext) _User_github_id(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.GithubID, nil - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal *string - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal *string - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *string - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetSMLVersion(rctx, fc.Args["smlVersionID"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -15988,26 +16886,63 @@ func (ec *executionContext) _User_github_id(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*SMLVersion) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_github_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getSMLVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_SMLVersion_id(ctx, field) + case "version": + return ec.fieldContext_SMLVersion_version(ctx, field) + case "satisfactory_version": + return ec.fieldContext_SMLVersion_satisfactory_version(ctx, field) + case "stability": + return ec.fieldContext_SMLVersion_stability(ctx, field) + case "link": + return ec.fieldContext_SMLVersion_link(ctx, field) + case "targets": + return ec.fieldContext_SMLVersion_targets(ctx, field) + case "changelog": + return ec.fieldContext_SMLVersion_changelog(ctx, field) + case "date": + return ec.fieldContext_SMLVersion_date(ctx, field) + case "bootstrap_version": + return ec.fieldContext_SMLVersion_bootstrap_version(ctx, field) + case "engine_version": + return ec.fieldContext_SMLVersion_engine_version(ctx, field) + case "updated_at": + return ec.fieldContext_SMLVersion_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_SMLVersion_created_at(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SMLVersion", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getSMLVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_google_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_google_id(ctx, field) +func (ec *executionContext) _Query_getSMLVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getSMLVersions(ctx, field) if err != nil { return graphql.Null } @@ -16019,75 +16954,56 @@ func (ec *executionContext) _User_google_id(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.GoogleID, nil - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal *string - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal *string - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *string - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetSMLVersions(rctx, fc.Args["filter"].(map[string]interface{})) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*GetSMLVersions) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNGetSMLVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_google_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getSMLVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "sml_versions": + return ec.fieldContext_GetSMLVersions_sml_versions(ctx, field) + case "count": + return ec.fieldContext_GetSMLVersions_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetSMLVersions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getSMLVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_facebook_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_facebook_id(ctx, field) +func (ec *executionContext) _Query_getTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getTag(ctx, field) if err != nil { return graphql.Null } @@ -16099,47 +17015,8 @@ func (ec *executionContext) _User_facebook_id(ctx context.Context, field graphql } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.FacebookID, nil - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal *string - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal *string - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *string - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *string - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetTag(rctx, fc.Args["tagID"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -16148,26 +17025,45 @@ func (ec *executionContext) _User_facebook_id(ctx context.Context, field graphql if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*Tag) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_facebook_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_roles(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_roles(ctx, field) +func (ec *executionContext) _Query_getTags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getTags(ctx, field) if err != nil { return graphql.Null } @@ -16179,47 +17075,8 @@ func (ec *executionContext) _User_roles(ctx context.Context, field graphql.Colle } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - directive0 := func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Roles(rctx, obj) - } - - directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal *UserRoles - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal *UserRoles - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal *UserRoles - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { - if ec.directives.IsLoggedIn == nil { - var zeroVal *UserRoles - return zeroVal, errors.New("directive isLoggedIn is not implemented") - } - return ec.directives.IsLoggedIn(ctx, obj, directive1) - } - - tmp, err := directive2(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*UserRoles); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserRoles`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetTags(rctx, fc.Args["filter"].(*TagFilter)) }) if err != nil { ec.Error(ctx, err) @@ -16231,44 +17088,45 @@ func (ec *executionContext) _User_roles(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(*UserRoles) + res := resTmp.([]*Tag) fc.Result = res - return ec.marshalNUserRoles2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx, field.Selections, res) + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_roles(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getTags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "approveMods": - return ec.fieldContext_UserRoles_approveMods(ctx, field) - case "approveVersions": - return ec.fieldContext_UserRoles_approveVersions(ctx, field) - case "deleteContent": - return ec.fieldContext_UserRoles_deleteContent(ctx, field) - case "editContent": - return ec.fieldContext_UserRoles_editContent(ctx, field) - case "editUsers": - return ec.fieldContext_UserRoles_editUsers(ctx, field) - case "editSatisfactoryVersions": - return ec.fieldContext_UserRoles_editSatisfactoryVersions(ctx, field) - case "editBootstrapVersions": - return ec.fieldContext_UserRoles_editBootstrapVersions(ctx, field) - case "editAnyModCompatibility": - return ec.fieldContext_UserRoles_editAnyModCompatibility(ctx, field) + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "description": + return ec.fieldContext_Tag_description(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserRoles", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getTags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_groups(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_groups(ctx, field) +func (ec *executionContext) _Query_getMe(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMe(ctx, field) if err != nil { return graphql.Null } @@ -16282,82 +17140,84 @@ func (ec *executionContext) _User_groups(ctx context.Context, field graphql.Coll resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { directive0 := func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Groups(rctx, obj) + return ec.resolvers.Query().GetMe(rctx) } directive1 := func(ctx context.Context) (any, error) { - field, err := ec.unmarshalNString2string(ctx, "ID") - if err != nil { - var zeroVal []*Group - return zeroVal, err - } - object, err := ec.unmarshalNBoolean2bool(ctx, true) - if err != nil { - var zeroVal []*Group - return zeroVal, err - } - if ec.directives.CanEditUser == nil { - var zeroVal []*Group - return zeroVal, errors.New("directive canEditUser is not implemented") - } - return ec.directives.CanEditUser(ctx, obj, directive0, field, object) - } - directive2 := func(ctx context.Context) (any, error) { if ec.directives.IsLoggedIn == nil { - var zeroVal []*Group + var zeroVal *User return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return ec.directives.IsLoggedIn(ctx, obj, directive1) + return ec.directives.IsLoggedIn(ctx, nil, directive0) } - tmp, err := directive2(rctx) + tmp, err := directive1(rctx) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } if tmp == nil { return nil, nil } - if data, ok := tmp.([]*Group); ok { + if data, ok := tmp.(*User); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/satisfactorymodding/smr-api/generated.Group`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.User`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*Group) + res := resTmp.(*User) fc.Result = res - return ec.marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_groups(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMe(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Group_id(ctx, field) - case "name": - return ec.fieldContext_Group_name(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) + case "created_at": + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_mods(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_mods(ctx, field) +func (ec *executionContext) _Query_getUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getUser(ctx, field) if err != nil { return graphql.Null } @@ -16370,50 +17230,74 @@ func (ec *executionContext) _User_mods(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Mods(rctx, obj) + return ec.resolvers.Query().GetUser(rctx, fc.Args["userId"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*UserMod) + res := resTmp.(*User) fc.Result = res - return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_mods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "user_id": - return ec.fieldContext_UserMod_user_id(ctx, field) - case "mod_id": - return ec.fieldContext_UserMod_mod_id(ctx, field) - case "role": - return ec.fieldContext_UserMod_role(ctx, field) - case "user": - return ec.fieldContext_UserMod_user(ctx, field) - case "mod": - return ec.fieldContext_UserMod_mod(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) + case "created_at": + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserMod", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _User_guides(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_guides(ctx, field) +func (ec *executionContext) _Query_getUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getUsers(ctx, field) if err != nil { return graphql.Null } @@ -16426,7 +17310,7 @@ func (ec *executionContext) _User_guides(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Guides(rctx, obj) + return ec.resolvers.Query().GetUsers(rctx, fc.Args["userIds"].([]string)) }) if err != nil { ec.Error(ctx, err) @@ -16438,48 +17322,65 @@ func (ec *executionContext) _User_guides(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*Guide) + res := resTmp.([]*User) fc.Result = res - return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) + return ec.marshalNUser2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_guides(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Guide_id(ctx, field) - case "name": - return ec.fieldContext_Guide_name(ctx, field) - case "short_description": - return ec.fieldContext_Guide_short_description(ctx, field) - case "guide": - return ec.fieldContext_Guide_guide(ctx, field) - case "views": - return ec.fieldContext_Guide_views(ctx, field) - case "user_id": - return ec.fieldContext_Guide_user_id(ctx, field) - case "updated_at": - return ec.fieldContext_Guide_updated_at(ctx, field) + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) case "created_at": - return ec.fieldContext_Guide_created_at(ctx, field) - case "tags": - return ec.fieldContext_Guide_tags(ctx, field) - case "user": - return ec.fieldContext_Guide_user(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserMod_user_id(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserMod_user_id(ctx, field) +func (ec *executionContext) _Query_getVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getVersion(ctx, field) if err != nil { return graphql.Null } @@ -16492,38 +17393,88 @@ func (ec *executionContext) _UserMod_user_id(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.UserID, nil + return ec.resolvers.Query().GetVersion(rctx, fc.Args["versionId"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Version) fc.Result = res - return ec.marshalNUserID2string(ctx, field.Selections, res) + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_user_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserMod", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type UserID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Version_id(ctx, field) + case "mod_id": + return ec.fieldContext_Version_mod_id(ctx, field) + case "version": + return ec.fieldContext_Version_version(ctx, field) + case "sml_version": + return ec.fieldContext_Version_sml_version(ctx, field) + case "game_version": + return ec.fieldContext_Version_game_version(ctx, field) + case "required_on_remote": + return ec.fieldContext_Version_required_on_remote(ctx, field) + case "changelog": + return ec.fieldContext_Version_changelog(ctx, field) + case "downloads": + return ec.fieldContext_Version_downloads(ctx, field) + case "stability": + return ec.fieldContext_Version_stability(ctx, field) + case "approved": + return ec.fieldContext_Version_approved(ctx, field) + case "updated_at": + return ec.fieldContext_Version_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Version_created_at(ctx, field) + case "link": + return ec.fieldContext_Version_link(ctx, field) + case "targets": + return ec.fieldContext_Version_targets(ctx, field) + case "metadata": + return ec.fieldContext_Version_metadata(ctx, field) + case "size": + return ec.fieldContext_Version_size(ctx, field) + case "hash": + return ec.fieldContext_Version_hash(ctx, field) + case "mod": + return ec.fieldContext_Version_mod(ctx, field) + case "dependencies": + return ec.fieldContext_Version_dependencies(ctx, field) + case "virustotal_results": + return ec.fieldContext_Version_virustotal_results(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserMod_mod_id(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserMod_mod_id(ctx, field) +func (ec *executionContext) _Query_getVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getVersions(ctx, field) if err != nil { return graphql.Null } @@ -16536,7 +17487,7 @@ func (ec *executionContext) _UserMod_mod_id(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ModID, nil + return ec.resolvers.Query().GetVersions(rctx, fc.Args["filter"].(map[string]interface{})) }) if err != nil { ec.Error(ctx, err) @@ -16548,26 +17499,43 @@ func (ec *executionContext) _UserMod_mod_id(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetVersions) fc.Result = res - return ec.marshalNModID2string(ctx, field.Selections, res) + return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserMod", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ModID does not have child fields") + switch field.Name { + case "versions": + return ec.fieldContext_GetVersions_versions(ctx, field) + case "count": + return ec.fieldContext_GetVersions_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetVersions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserMod_role(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserMod_role(ctx, field) +func (ec *executionContext) _Query_getUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getUnapprovedVersions(ctx, field) if err != nil { return graphql.Null } @@ -16579,8 +17547,37 @@ func (ec *executionContext) _UserMod_role(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Role, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetUnapprovedVersions(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.CanApproveVersions == nil { + var zeroVal *GetVersions + return zeroVal, errors.New("directive canApproveVersions is not implemented") + } + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetVersions + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetVersions); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetVersions`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16592,26 +17589,43 @@ func (ec *executionContext) _UserMod_role(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*GetVersions) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_role(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserMod", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "versions": + return ec.fieldContext_GetVersions_versions(ctx, field) + case "count": + return ec.fieldContext_GetVersions_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetVersions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getUnapprovedVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserMod_user(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserMod_user(ctx, field) +func (ec *executionContext) _Query_checkVersionUploadState(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_checkVersionUploadState(ctx, field) if err != nil { return graphql.Null } @@ -16623,67 +17637,87 @@ func (ec *executionContext) _UserMod_user(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.UserMod().User(rctx, obj) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().CheckVersionUploadState(rctx, fc.Args["modId"].(string), fc.Args["versionId"].(string)) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + var zeroVal *CreateVersionResponse + return zeroVal, err + } + if ec.directives.CanEditMod == nil { + var zeroVal *CreateVersionResponse + return zeroVal, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *CreateVersionResponse + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*CreateVersionResponse); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.CreateVersionResponse`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*User) + res := resTmp.(*CreateVersionResponse) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) + return ec.marshalOCreateVersionResponse2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCreateVersionResponse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_checkVersionUploadState(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserMod", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "avatar": - return ec.fieldContext_User_avatar(ctx, field) - case "avatar_thumbhash": - return ec.fieldContext_User_avatar_thumbhash(ctx, field) - case "created_at": - return ec.fieldContext_User_created_at(ctx, field) - case "github_id": - return ec.fieldContext_User_github_id(ctx, field) - case "google_id": - return ec.fieldContext_User_google_id(ctx, field) - case "facebook_id": - return ec.fieldContext_User_facebook_id(ctx, field) - case "roles": - return ec.fieldContext_User_roles(ctx, field) - case "groups": - return ec.fieldContext_User_groups(ctx, field) - case "mods": - return ec.fieldContext_User_mods(ctx, field) - case "guides": - return ec.fieldContext_User_guides(ctx, field) + case "auto_approved": + return ec.fieldContext_CreateVersionResponse_auto_approved(ctx, field) + case "version": + return ec.fieldContext_CreateVersionResponse_version(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CreateVersionResponse", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_checkVersionUploadState_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserMod_mod(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserMod_mod(ctx, field) +func (ec *executionContext) _Query_getMyVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMyVersions(ctx, field) if err != nil { return graphql.Null } @@ -16695,8 +17729,30 @@ func (ec *executionContext) _UserMod_mod(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.UserMod().Mod(rctx, obj) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMyVersions(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetMyVersions + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetMyVersions); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyVersions`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16708,80 +17764,43 @@ func (ec *executionContext) _UserMod_mod(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(*GetMyVersions) fc.Result = res - return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMyVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserMod", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) + return ec.fieldContext_GetMyVersions_versions(ctx, field) + case "count": + return ec.fieldContext_GetMyVersions_count(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, fmt.Errorf("no field named %q was found under type GetMyVersions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMyVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserRoles_approveMods(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_approveMods(ctx, field) +func (ec *executionContext) _Query_getMyUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getMyUnapprovedVersions(ctx, field) if err != nil { return graphql.Null } @@ -16793,8 +17812,30 @@ func (ec *executionContext) _UserRoles_approveMods(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ApproveMods, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMyUnapprovedVersions(rctx, fc.Args["filter"].(map[string]interface{})) + } + + directive1 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *GetMyVersions + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, nil, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*GetMyVersions); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.GetMyVersions`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -16806,26 +17847,43 @@ func (ec *executionContext) _UserRoles_approveMods(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*GetMyVersions) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_approveMods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_getMyUnapprovedVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "versions": + return ec.fieldContext_GetMyVersions_versions(ctx, field) + case "count": + return ec.fieldContext_GetMyVersions_count(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetMyVersions", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getMyUnapprovedVersions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserRoles_approveVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_approveVersions(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -16838,82 +17896,70 @@ func (ec *executionContext) _UserRoles_approveVersions(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ApproveVersions, nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_approveVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _UserRoles_deleteContent(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_deleteContent(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeleteContent, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_UserRoles_deleteContent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UserRoles", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } return fc, nil } -func (ec *executionContext) _UserRoles_editContent(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_editContent(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -16926,38 +17972,49 @@ func (ec *executionContext) _UserRoles_editContent(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EditContent, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editContent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _UserRoles_editUsers(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_editUsers(ctx, field) +func (ec *executionContext) _SMLVersion_id(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_id(ctx, field) if err != nil { return graphql.Null } @@ -16970,7 +18027,7 @@ func (ec *executionContext) _UserRoles_editUsers(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EditUsers, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -16982,26 +18039,26 @@ func (ec *executionContext) _UserRoles_editUsers(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editUsers(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type SMLVersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserRoles_editSatisfactoryVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_editSatisfactoryVersions(ctx, field) +func (ec *executionContext) _SMLVersion_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_version(ctx, field) if err != nil { return graphql.Null } @@ -17014,7 +18071,7 @@ func (ec *executionContext) _UserRoles_editSatisfactoryVersions(ctx context.Cont }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EditSatisfactoryVersions, nil + return obj.Version, nil }) if err != nil { ec.Error(ctx, err) @@ -17026,26 +18083,26 @@ func (ec *executionContext) _UserRoles_editSatisfactoryVersions(ctx context.Cont } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editSatisfactoryVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserRoles_editBootstrapVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_editBootstrapVersions(ctx, field) +func (ec *executionContext) _SMLVersion_satisfactory_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_satisfactory_version(ctx, field) if err != nil { return graphql.Null } @@ -17058,7 +18115,7 @@ func (ec *executionContext) _UserRoles_editBootstrapVersions(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EditBootstrapVersions, nil + return obj.SatisfactoryVersion, nil }) if err != nil { ec.Error(ctx, err) @@ -17070,26 +18127,26 @@ func (ec *executionContext) _UserRoles_editBootstrapVersions(ctx context.Context } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editBootstrapVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_satisfactory_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserRoles_editAnyModCompatibility(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserRoles_editAnyModCompatibility(ctx, field) +func (ec *executionContext) _SMLVersion_stability(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_stability(ctx, field) if err != nil { return graphql.Null } @@ -17102,7 +18159,7 @@ func (ec *executionContext) _UserRoles_editAnyModCompatibility(ctx context.Conte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EditAnyModCompatibility, nil + return obj.Stability, nil }) if err != nil { ec.Error(ctx, err) @@ -17114,26 +18171,26 @@ func (ec *executionContext) _UserRoles_editAnyModCompatibility(ctx context.Conte } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(VersionStabilities) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editAnyModCompatibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_stability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserRoles", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type VersionStabilities does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserSession_token(ctx context.Context, field graphql.CollectedField, obj *UserSession) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserSession_token(ctx, field) +func (ec *executionContext) _SMLVersion_link(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_link(ctx, field) if err != nil { return graphql.Null } @@ -17146,7 +18203,7 @@ func (ec *executionContext) _UserSession_token(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Token, nil + return ec.resolvers.SMLVersion().Link(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -17163,12 +18220,12 @@ func (ec *executionContext) _UserSession_token(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserSession_token(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserSession", + Object: "SMLVersion", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -17176,8 +18233,8 @@ func (ec *executionContext) fieldContext_UserSession_token(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Version_id(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_id(ctx, field) +func (ec *executionContext) _SMLVersion_targets(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_targets(ctx, field) if err != nil { return graphql.Null } @@ -17190,7 +18247,7 @@ func (ec *executionContext) _Version_id(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Targets, nil }) if err != nil { ec.Error(ctx, err) @@ -17202,26 +18259,34 @@ func (ec *executionContext) _Version_id(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*SMLVersionTarget) fc.Result = res - return ec.marshalNVersionID2string(ctx, field.Selections, res) + return ec.marshalNSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_targets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionID does not have child fields") + switch field.Name { + case "VersionID": + return ec.fieldContext_SMLVersionTarget_VersionID(ctx, field) + case "targetName": + return ec.fieldContext_SMLVersionTarget_targetName(ctx, field) + case "link": + return ec.fieldContext_SMLVersionTarget_link(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SMLVersionTarget", field.Name) }, } return fc, nil } -func (ec *executionContext) _Version_mod_id(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_mod_id(ctx, field) +func (ec *executionContext) _SMLVersion_changelog(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_changelog(ctx, field) if err != nil { return graphql.Null } @@ -17234,7 +18299,7 @@ func (ec *executionContext) _Version_mod_id(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ModID, nil + return obj.Changelog, nil }) if err != nil { ec.Error(ctx, err) @@ -17248,24 +18313,24 @@ func (ec *executionContext) _Version_mod_id(ctx context.Context, field graphql.C } res := resTmp.(string) fc.Result = res - return ec.marshalNModID2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_changelog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ModID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_version(ctx, field) +func (ec *executionContext) _SMLVersion_date(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_date(ctx, field) if err != nil { return graphql.Null } @@ -17278,7 +18343,7 @@ func (ec *executionContext) _Version_version(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Version, nil + return obj.Date, nil }) if err != nil { ec.Error(ctx, err) @@ -17292,24 +18357,24 @@ func (ec *executionContext) _Version_version(ctx context.Context, field graphql. } res := resTmp.(string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_sml_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_sml_version(ctx, field) +func (ec *executionContext) _SMLVersion_bootstrap_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_bootstrap_version(ctx, field) if err != nil { return graphql.Null } @@ -17322,26 +18387,23 @@ func (ec *executionContext) _Version_sml_version(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().SmlVersion(rctx, obj) + return ec.resolvers.SMLVersion().BootstrapVersion(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_sml_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_bootstrap_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: true, IsResolver: true, @@ -17352,8 +18414,8 @@ func (ec *executionContext) fieldContext_Version_sml_version(_ context.Context, return fc, nil } -func (ec *executionContext) _Version_game_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_game_version(ctx, field) +func (ec *executionContext) _SMLVersion_engine_version(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_engine_version(ctx, field) if err != nil { return graphql.Null } @@ -17366,7 +18428,7 @@ func (ec *executionContext) _Version_game_version(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.GameVersion, nil + return ec.resolvers.SMLVersion().EngineVersion(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -17383,12 +18445,12 @@ func (ec *executionContext) _Version_game_version(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_game_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_engine_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -17396,8 +18458,8 @@ func (ec *executionContext) fieldContext_Version_game_version(_ context.Context, return fc, nil } -func (ec *executionContext) _Version_required_on_remote(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_required_on_remote(ctx, field) +func (ec *executionContext) _SMLVersion_updated_at(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_updated_at(ctx, field) if err != nil { return graphql.Null } @@ -17410,7 +18472,7 @@ func (ec *executionContext) _Version_required_on_remote(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.RequiredOnRemote, nil + return obj.UpdatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -17422,26 +18484,26 @@ func (ec *executionContext) _Version_required_on_remote(ctx context.Context, fie } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_required_on_remote(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_changelog(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_changelog(ctx, field) +func (ec *executionContext) _SMLVersion_created_at(ctx context.Context, field graphql.CollectedField, obj *SMLVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersion_created_at(ctx, field) if err != nil { return graphql.Null } @@ -17454,7 +18516,7 @@ func (ec *executionContext) _Version_changelog(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Changelog, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -17468,24 +18530,24 @@ func (ec *executionContext) _Version_changelog(ctx context.Context, field graphq } res := resTmp.(string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_changelog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersion_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_downloads(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_downloads(ctx, field) +func (ec *executionContext) _SMLVersionTarget_VersionID(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersionTarget_VersionID(ctx, field) if err != nil { return graphql.Null } @@ -17498,7 +18560,7 @@ func (ec *executionContext) _Version_downloads(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Downloads, nil + return obj.VersionID, nil }) if err != nil { ec.Error(ctx, err) @@ -17510,26 +18572,26 @@ func (ec *executionContext) _Version_downloads(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersionTarget_VersionID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersionTarget", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type SMLVersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_stability(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_stability(ctx, field) +func (ec *executionContext) _SMLVersionTarget_targetName(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersionTarget_targetName(ctx, field) if err != nil { return graphql.Null } @@ -17542,7 +18604,7 @@ func (ec *executionContext) _Version_stability(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Stability, nil + return obj.TargetName, nil }) if err != nil { ec.Error(ctx, err) @@ -17554,26 +18616,26 @@ func (ec *executionContext) _Version_stability(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(VersionStabilities) + res := resTmp.(TargetName) fc.Result = res - return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) + return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_stability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersionTarget_targetName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersionTarget", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionStabilities does not have child fields") + return nil, errors.New("field of type TargetName does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_approved(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_approved(ctx, field) +func (ec *executionContext) _SMLVersionTarget_link(ctx context.Context, field graphql.CollectedField, obj *SMLVersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SMLVersionTarget_link(ctx, field) if err != nil { return graphql.Null } @@ -17586,7 +18648,7 @@ func (ec *executionContext) _Version_approved(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Approved, nil + return ec.resolvers.SMLVersionTarget().Link(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -17598,26 +18660,26 @@ func (ec *executionContext) _Version_approved(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_approved(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SMLVersionTarget_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SMLVersionTarget", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_updated_at(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_updated_at(ctx, field) +func (ec *executionContext) _SatisfactoryVersion_id(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SatisfactoryVersion_id(ctx, field) if err != nil { return graphql.Null } @@ -17630,7 +18692,7 @@ func (ec *executionContext) _Version_updated_at(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -17644,24 +18706,24 @@ func (ec *executionContext) _Version_updated_at(ctx context.Context, field graph } res := resTmp.(string) fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) + return ec.marshalNSatisfactoryVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SatisfactoryVersion_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SatisfactoryVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + return nil, errors.New("field of type SatisfactoryVersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_created_at(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_created_at(ctx, field) +func (ec *executionContext) _SatisfactoryVersion_version(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SatisfactoryVersion_version(ctx, field) if err != nil { return graphql.Null } @@ -17674,7 +18736,7 @@ func (ec *executionContext) _Version_created_at(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Version, nil }) if err != nil { ec.Error(ctx, err) @@ -17686,26 +18748,26 @@ func (ec *executionContext) _Version_created_at(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SatisfactoryVersion_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SatisfactoryVersion", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_link(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_link(ctx, field) +func (ec *executionContext) _SatisfactoryVersion_engine_version(ctx context.Context, field graphql.CollectedField, obj *SatisfactoryVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SatisfactoryVersion_engine_version(ctx, field) if err != nil { return graphql.Null } @@ -17718,7 +18780,7 @@ func (ec *executionContext) _Version_link(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().Link(rctx, obj) + return obj.EngineVersion, nil }) if err != nil { ec.Error(ctx, err) @@ -17735,12 +18797,12 @@ func (ec *executionContext) _Version_link(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SatisfactoryVersion_engine_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "SatisfactoryVersion", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -17748,8 +18810,8 @@ func (ec *executionContext) fieldContext_Version_link(_ context.Context, field g return fc, nil } -func (ec *executionContext) _Version_targets(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_targets(ctx, field) +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_id(ctx, field) if err != nil { return graphql.Null } @@ -17762,7 +18824,7 @@ func (ec *executionContext) _Version_targets(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Targets, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -17774,38 +18836,26 @@ func (ec *executionContext) _Version_targets(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]*VersionTarget) + res := resTmp.(string) fc.Result = res - return ec.marshalNVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx, field.Selections, res) + return ec.marshalNTagID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_targets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "VersionID": - return ec.fieldContext_VersionTarget_VersionID(ctx, field) - case "targetName": - return ec.fieldContext_VersionTarget_targetName(ctx, field) - case "link": - return ec.fieldContext_VersionTarget_link(ctx, field) - case "size": - return ec.fieldContext_VersionTarget_size(ctx, field) - case "hash": - return ec.fieldContext_VersionTarget_hash(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type VersionTarget", field.Name) + return nil, errors.New("field of type TagID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_metadata(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_metadata(ctx, field) +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_name(ctx, field) if err != nil { return graphql.Null } @@ -17818,35 +18868,38 @@ func (ec *executionContext) _Version_metadata(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Metadata, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNTagName2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type TagName does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_size(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_size(ctx, field) +func (ec *executionContext) _Tag_description(ctx context.Context, field graphql.CollectedField, obj *Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_description(ctx, field) if err != nil { return graphql.Null } @@ -17859,35 +18912,38 @@ func (ec *executionContext) _Version_size(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().Size(rctx, obj) + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*int) + res := resTmp.(string) fc.Result = res - return ec.marshalOInt2ᚖint(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "Tag", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_hash(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_hash(ctx, field) +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { return graphql.Null } @@ -17900,35 +18956,38 @@ func (ec *executionContext) _Version_hash(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().Hash(rctx, obj) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type UserID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Version_mod(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_mod(ctx, field) +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) if err != nil { return graphql.Null } @@ -17940,213 +18999,75 @@ func (ec *executionContext) _Version_mod(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().Mod(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Email, nil } - return graphql.Null - } - res := resTmp.(*Mod) - fc.Result = res - return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) -} -func (ec *executionContext) fieldContext_Version_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Version", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal *string + return zeroVal, err } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Version_dependencies(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_dependencies(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().Dependencies(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *string + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) } - return graphql.Null - } - res := resTmp.([]*VersionDependency) - fc.Result = res - return ec.marshalNVersionDependency2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependencyᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Version_dependencies(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Version", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "version_id": - return ec.fieldContext_VersionDependency_version_id(ctx, field) - case "mod_id": - return ec.fieldContext_VersionDependency_mod_id(ctx, field) - case "condition": - return ec.fieldContext_VersionDependency_condition(ctx, field) - case "optional": - return ec.fieldContext_VersionDependency_optional(ctx, field) - case "mod_reference": - return ec.fieldContext_VersionDependency_mod_reference(ctx, field) - case "mod": - return ec.fieldContext_VersionDependency_mod(ctx, field) - case "version": - return ec.fieldContext_VersionDependency_version(ctx, field) + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *string + return zeroVal, errors.New("directive isLoggedIn is not implemented") } - return nil, fmt.Errorf("no field named %q was found under type VersionDependency", field.Name) - }, - } - return fc, nil -} + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } -func (ec *executionContext) _Version_virustotal_results(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Version_virustotal_results(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Version().VirustotalResults(rctx, obj) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*VirustotalResult) + res := resTmp.(*string) fc.Result = res - return ec.marshalNVirustotalResult2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVirustotalResultᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_virustotal_results(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Version", + Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_VirustotalResult_id(ctx, field) - case "hash": - return ec.fieldContext_VirustotalResult_hash(ctx, field) - case "safe": - return ec.fieldContext_VirustotalResult_safe(ctx, field) - case "file_name": - return ec.fieldContext_VirustotalResult_file_name(ctx, field) - case "version_id": - return ec.fieldContext_VirustotalResult_version_id(ctx, field) - case "created_at": - return ec.fieldContext_VirustotalResult_created_at(ctx, field) - case "updated_at": - return ec.fieldContext_VirustotalResult_updated_at(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type VirustotalResult", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionDependency_version_id(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_version_id(ctx, field) +func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_username(ctx, field) if err != nil { return graphql.Null } @@ -18159,7 +19080,7 @@ func (ec *executionContext) _VersionDependency_version_id(ctx context.Context, f }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.VersionID, nil + return obj.Username, nil }) if err != nil { ec.Error(ctx, err) @@ -18173,24 +19094,24 @@ func (ec *executionContext) _VersionDependency_version_id(ctx context.Context, f } res := resTmp.(string) fc.Result = res - return ec.marshalNVersionID2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_username(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionDependency_mod_id(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_mod_id(ctx, field) +func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_avatar(ctx, field) if err != nil { return graphql.Null } @@ -18203,38 +19124,35 @@ func (ec *executionContext) _VersionDependency_mod_id(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ModID, nil + return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNModID2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_avatar(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ModID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionDependency_condition(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_condition(ctx, field) +func (ec *executionContext) _User_avatar_thumbhash(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_avatar_thumbhash(ctx, field) if err != nil { return graphql.Null } @@ -18247,26 +19165,23 @@ func (ec *executionContext) _VersionDependency_condition(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Condition, nil + return obj.AvatarThumbhash, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_condition(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_avatar_thumbhash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, @@ -18277,8 +19192,8 @@ func (ec *executionContext) fieldContext_VersionDependency_condition(_ context.C return fc, nil } -func (ec *executionContext) _VersionDependency_optional(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_optional(ctx, field) +func (ec *executionContext) _User_created_at(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_created_at(ctx, field) if err != nil { return graphql.Null } @@ -18291,7 +19206,7 @@ func (ec *executionContext) _VersionDependency_optional(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Optional, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -18303,26 +19218,26 @@ func (ec *executionContext) _VersionDependency_optional(ctx context.Context, fie } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_optional(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionDependency_mod_reference(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_mod_reference(ctx, field) +func (ec *executionContext) _User_github_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_github_id(ctx, field) if err != nil { return graphql.Null } @@ -18334,27 +19249,63 @@ func (ec *executionContext) _VersionDependency_mod_reference(ctx context.Context } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.ModReference, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.GithubID, nil + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal *string + return zeroVal, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *string + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *string + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_mod_reference(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_github_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, @@ -18365,8 +19316,8 @@ func (ec *executionContext) fieldContext_VersionDependency_mod_reference(_ conte return fc, nil } -func (ec *executionContext) _VersionDependency_mod(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_mod(ctx, field) +func (ec *executionContext) _User_google_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_google_id(ctx, field) if err != nil { return graphql.Null } @@ -18378,8 +19329,47 @@ func (ec *executionContext) _VersionDependency_mod(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.VersionDependency().Mod(rctx, obj) + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.GoogleID, nil + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal *string + return zeroVal, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *string + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *string + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18388,80 +19378,26 @@ func (ec *executionContext) _VersionDependency_mod(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*Mod) + res := resTmp.(*string) fc.Result = res - return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_google_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Mod_id(ctx, field) - case "name": - return ec.fieldContext_Mod_name(ctx, field) - case "short_description": - return ec.fieldContext_Mod_short_description(ctx, field) - case "full_description": - return ec.fieldContext_Mod_full_description(ctx, field) - case "logo": - return ec.fieldContext_Mod_logo(ctx, field) - case "logo_thumbhash": - return ec.fieldContext_Mod_logo_thumbhash(ctx, field) - case "source_url": - return ec.fieldContext_Mod_source_url(ctx, field) - case "creator_id": - return ec.fieldContext_Mod_creator_id(ctx, field) - case "approved": - return ec.fieldContext_Mod_approved(ctx, field) - case "views": - return ec.fieldContext_Mod_views(ctx, field) - case "downloads": - return ec.fieldContext_Mod_downloads(ctx, field) - case "hotness": - return ec.fieldContext_Mod_hotness(ctx, field) - case "popularity": - return ec.fieldContext_Mod_popularity(ctx, field) - case "updated_at": - return ec.fieldContext_Mod_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Mod_created_at(ctx, field) - case "last_version_date": - return ec.fieldContext_Mod_last_version_date(ctx, field) - case "mod_reference": - return ec.fieldContext_Mod_mod_reference(ctx, field) - case "hidden": - return ec.fieldContext_Mod_hidden(ctx, field) - case "tags": - return ec.fieldContext_Mod_tags(ctx, field) - case "compatibility": - return ec.fieldContext_Mod_compatibility(ctx, field) - case "toggle_network_use": - return ec.fieldContext_Mod_toggle_network_use(ctx, field) - case "toggle_explicit_content": - return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) - case "authors": - return ec.fieldContext_Mod_authors(ctx, field) - case "version": - return ec.fieldContext_Mod_version(ctx, field) - case "versions": - return ec.fieldContext_Mod_versions(ctx, field) - case "latestVersions": - return ec.fieldContext_Mod_latestVersions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionDependency_version(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionDependency_version(ctx, field) +func (ec *executionContext) _User_facebook_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_facebook_id(ctx, field) if err != nil { return graphql.Null } @@ -18473,8 +19409,47 @@ func (ec *executionContext) _VersionDependency_version(ctx context.Context, fiel } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.Version, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.FacebookID, nil + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal *string + return zeroVal, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *string + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *string + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*string); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18483,68 +19458,26 @@ func (ec *executionContext) _VersionDependency_version(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*Version) + res := resTmp.(*string) fc.Result = res - return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_facebook_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionDependency", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Version_id(ctx, field) - case "mod_id": - return ec.fieldContext_Version_mod_id(ctx, field) - case "version": - return ec.fieldContext_Version_version(ctx, field) - case "sml_version": - return ec.fieldContext_Version_sml_version(ctx, field) - case "game_version": - return ec.fieldContext_Version_game_version(ctx, field) - case "required_on_remote": - return ec.fieldContext_Version_required_on_remote(ctx, field) - case "changelog": - return ec.fieldContext_Version_changelog(ctx, field) - case "downloads": - return ec.fieldContext_Version_downloads(ctx, field) - case "stability": - return ec.fieldContext_Version_stability(ctx, field) - case "approved": - return ec.fieldContext_Version_approved(ctx, field) - case "updated_at": - return ec.fieldContext_Version_updated_at(ctx, field) - case "created_at": - return ec.fieldContext_Version_created_at(ctx, field) - case "link": - return ec.fieldContext_Version_link(ctx, field) - case "targets": - return ec.fieldContext_Version_targets(ctx, field) - case "metadata": - return ec.fieldContext_Version_metadata(ctx, field) - case "size": - return ec.fieldContext_Version_size(ctx, field) - case "hash": - return ec.fieldContext_Version_hash(ctx, field) - case "mod": - return ec.fieldContext_Version_mod(ctx, field) - case "dependencies": - return ec.fieldContext_Version_dependencies(ctx, field) - case "virustotal_results": - return ec.fieldContext_Version_virustotal_results(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VersionTarget_VersionID(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionTarget_VersionID(ctx, field) +func (ec *executionContext) _User_roles(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_roles(ctx, field) if err != nil { return graphql.Null } @@ -18556,8 +19489,47 @@ func (ec *executionContext) _VersionTarget_VersionID(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.VersionID, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Roles(rctx, obj) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal *UserRoles + return zeroVal, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *UserRoles + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal *UserRoles + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal *UserRoles + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*UserRoles); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.UserRoles`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18569,26 +19541,44 @@ func (ec *executionContext) _VersionTarget_VersionID(ctx context.Context, field } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*UserRoles) fc.Result = res - return ec.marshalNVersionID2string(ctx, field.Selections, res) + return ec.marshalNUserRoles2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_VersionID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_roles(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionTarget", + Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VersionID does not have child fields") + switch field.Name { + case "approveMods": + return ec.fieldContext_UserRoles_approveMods(ctx, field) + case "approveVersions": + return ec.fieldContext_UserRoles_approveVersions(ctx, field) + case "deleteContent": + return ec.fieldContext_UserRoles_deleteContent(ctx, field) + case "editContent": + return ec.fieldContext_UserRoles_editContent(ctx, field) + case "editUsers": + return ec.fieldContext_UserRoles_editUsers(ctx, field) + case "editSatisfactoryVersions": + return ec.fieldContext_UserRoles_editSatisfactoryVersions(ctx, field) + case "editBootstrapVersions": + return ec.fieldContext_UserRoles_editBootstrapVersions(ctx, field) + case "editAnyModCompatibility": + return ec.fieldContext_UserRoles_editAnyModCompatibility(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserRoles", field.Name) }, } return fc, nil } -func (ec *executionContext) _VersionTarget_targetName(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionTarget_targetName(ctx, field) +func (ec *executionContext) _User_groups(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_groups(ctx, field) if err != nil { return graphql.Null } @@ -18600,8 +19590,47 @@ func (ec *executionContext) _VersionTarget_targetName(ctx context.Context, field } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { - ctx = rctx // use context from middleware stack in children - return obj.TargetName, nil + directive0 := func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Groups(rctx, obj) + } + + directive1 := func(ctx context.Context) (any, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + var zeroVal []*Group + return zeroVal, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []*Group + return zeroVal, err + } + if ec.directives.CanEditUser == nil { + var zeroVal []*Group + return zeroVal, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (any, error) { + if ec.directives.IsLoggedIn == nil { + var zeroVal []*Group + return zeroVal, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*Group); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/satisfactorymodding/smr-api/generated.Group`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -18613,26 +19642,32 @@ func (ec *executionContext) _VersionTarget_targetName(ctx context.Context, field } return graphql.Null } - res := resTmp.(TargetName) + res := resTmp.([]*Group) fc.Result = res - return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) + return ec.marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_targetName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_groups(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionTarget", + Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TargetName does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) }, } return fc, nil } -func (ec *executionContext) _VersionTarget_link(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionTarget_link(ctx, field) +func (ec *executionContext) _User_mods(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_mods(ctx, field) if err != nil { return graphql.Null } @@ -18645,7 +19680,7 @@ func (ec *executionContext) _VersionTarget_link(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.VersionTarget().Link(rctx, obj) + return ec.resolvers.User().Mods(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -18657,26 +19692,38 @@ func (ec *executionContext) _VersionTarget_link(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*UserMod) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_mods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionTarget", + Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "user_id": + return ec.fieldContext_UserMod_user_id(ctx, field) + case "mod_id": + return ec.fieldContext_UserMod_mod_id(ctx, field) + case "role": + return ec.fieldContext_UserMod_role(ctx, field) + case "user": + return ec.fieldContext_UserMod_user(ctx, field) + case "mod": + return ec.fieldContext_UserMod_mod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserMod", field.Name) }, } return fc, nil } -func (ec *executionContext) _VersionTarget_size(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionTarget_size(ctx, field) +func (ec *executionContext) _User_guides(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_guides(ctx, field) if err != nil { return graphql.Null } @@ -18689,35 +19736,60 @@ func (ec *executionContext) _VersionTarget_size(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Size, nil + return ec.resolvers.User().Guides(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*int) + res := resTmp.([]*Guide) fc.Result = res - return ec.marshalOInt2ᚖint(ctx, field.Selections, res) + return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_guides(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionTarget", + Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Guide_id(ctx, field) + case "name": + return ec.fieldContext_Guide_name(ctx, field) + case "short_description": + return ec.fieldContext_Guide_short_description(ctx, field) + case "guide": + return ec.fieldContext_Guide_guide(ctx, field) + case "views": + return ec.fieldContext_Guide_views(ctx, field) + case "user_id": + return ec.fieldContext_Guide_user_id(ctx, field) + case "updated_at": + return ec.fieldContext_Guide_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Guide_created_at(ctx, field) + case "tags": + return ec.fieldContext_Guide_tags(ctx, field) + case "user": + return ec.fieldContext_Guide_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Guide", field.Name) }, } return fc, nil } -func (ec *executionContext) _VersionTarget_hash(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionTarget_hash(ctx, field) +func (ec *executionContext) _UserMod_user_id(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserMod_user_id(ctx, field) if err != nil { return graphql.Null } @@ -18730,35 +19802,38 @@ func (ec *executionContext) _VersionTarget_hash(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Hash, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserMod_user_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VersionTarget", + Object: "UserMod", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type UserID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_id(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_id(ctx, field) +func (ec *executionContext) _UserMod_mod_id(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserMod_mod_id(ctx, field) if err != nil { return graphql.Null } @@ -18771,35 +19846,38 @@ func (ec *executionContext) _VirustotalResult_id(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.ModID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - return graphql.Null + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOVirustotalID2ᚖstring(ctx, field.Selections, res) + return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserMod_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserMod", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VirustotalID does not have child fields") + return nil, errors.New("field of type ModID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_hash(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_hash(ctx, field) +func (ec *executionContext) _UserMod_role(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserMod_role(ctx, field) if err != nil { return graphql.Null } @@ -18812,7 +19890,7 @@ func (ec *executionContext) _VirustotalResult_hash(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Hash, nil + return obj.Role, nil }) if err != nil { ec.Error(ctx, err) @@ -18826,24 +19904,24 @@ func (ec *executionContext) _VirustotalResult_hash(ctx context.Context, field gr } res := resTmp.(string) fc.Result = res - return ec.marshalNVirustotalHash2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserMod_role(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserMod", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type VirustotalHash does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_safe(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_safe(ctx, field) +func (ec *executionContext) _UserMod_user(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserMod_user(ctx, field) if err != nil { return graphql.Null } @@ -18856,7 +19934,7 @@ func (ec *executionContext) _VirustotalResult_safe(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Safe, nil + return ec.resolvers.UserMod().User(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -18868,26 +19946,54 @@ func (ec *executionContext) _VirustotalResult_safe(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*User) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_safe(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserMod_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserMod", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "avatar": + return ec.fieldContext_User_avatar(ctx, field) + case "avatar_thumbhash": + return ec.fieldContext_User_avatar_thumbhash(ctx, field) + case "created_at": + return ec.fieldContext_User_created_at(ctx, field) + case "github_id": + return ec.fieldContext_User_github_id(ctx, field) + case "google_id": + return ec.fieldContext_User_google_id(ctx, field) + case "facebook_id": + return ec.fieldContext_User_facebook_id(ctx, field) + case "roles": + return ec.fieldContext_User_roles(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "mods": + return ec.fieldContext_User_mods(ctx, field) + case "guides": + return ec.fieldContext_User_guides(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_file_name(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_file_name(ctx, field) +func (ec *executionContext) _UserMod_mod(ctx context.Context, field graphql.CollectedField, obj *UserMod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserMod_mod(ctx, field) if err != nil { return graphql.Null } @@ -18900,7 +20006,7 @@ func (ec *executionContext) _VirustotalResult_file_name(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.FileName, nil + return ec.resolvers.UserMod().Mod(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -18912,26 +20018,80 @@ func (ec *executionContext) _VirustotalResult_file_name(ctx context.Context, fie } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_file_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserMod_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserMod", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Mod_id(ctx, field) + case "name": + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_version_id(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_version_id(ctx, field) +func (ec *executionContext) _UserRoles_approveMods(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_approveMods(ctx, field) if err != nil { return graphql.Null } @@ -18944,7 +20104,7 @@ func (ec *executionContext) _VirustotalResult_version_id(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.VersionID, nil + return obj.ApproveMods, nil }) if err != nil { ec.Error(ctx, err) @@ -18956,26 +20116,26 @@ func (ec *executionContext) _VirustotalResult_version_id(ctx context.Context, fi } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_approveMods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_created_at(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_created_at(ctx, field) +func (ec *executionContext) _UserRoles_approveVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_approveVersions(ctx, field) if err != nil { return graphql.Null } @@ -18988,7 +20148,7 @@ func (ec *executionContext) _VirustotalResult_created_at(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.ApproveVersions, nil }) if err != nil { ec.Error(ctx, err) @@ -19000,26 +20160,26 @@ func (ec *executionContext) _VirustotalResult_created_at(ctx context.Context, fi } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNDate2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_approveVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _VirustotalResult_updated_at(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VirustotalResult_updated_at(ctx, field) +func (ec *executionContext) _UserRoles_deleteContent(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_deleteContent(ctx, field) if err != nil { return graphql.Null } @@ -19032,35 +20192,38 @@ func (ec *executionContext) _VirustotalResult_updated_at(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, nil + return obj.DeleteContent, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalODate2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VirustotalResult_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_deleteContent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "VirustotalResult", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Date does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _UserRoles_editContent(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editContent(ctx, field) if err != nil { return graphql.Null } @@ -19073,7 +20236,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.EditContent, nil }) if err != nil { ec.Error(ctx, err) @@ -19085,26 +20248,26 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editContent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) +func (ec *executionContext) _UserRoles_editUsers(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editUsers(ctx, field) if err != nil { return graphql.Null } @@ -19117,35 +20280,38 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.EditUsers, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editUsers(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "UserRoles", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _UserRoles_editSatisfactoryVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editSatisfactoryVersions(ctx, field) if err != nil { return graphql.Null } @@ -19158,7 +20324,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil + return obj.EditSatisfactoryVersions, nil }) if err != nil { ec.Error(ctx, err) @@ -19175,9 +20341,9 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editSatisfactoryVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, @@ -19188,8 +20354,8 @@ func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Cont return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _UserRoles_editBootstrapVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editBootstrapVersions(ctx, field) if err != nil { return graphql.Null } @@ -19202,7 +20368,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.EditBootstrapVersions, nil }) if err != nil { ec.Error(ctx, err) @@ -19214,26 +20380,26 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editBootstrapVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _UserRoles_editAnyModCompatibility(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editAnyModCompatibility(ctx, field) if err != nil { return graphql.Null } @@ -19246,7 +20412,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.EditAnyModCompatibility, nil }) if err != nil { ec.Error(ctx, err) @@ -19258,51 +20424,26 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editAnyModCompatibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "UserRoles", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - case "isDeprecated": - return ec.fieldContext___InputValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___InputValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _UserSession_token(ctx context.Context, field graphql.CollectedField, obj *UserSession) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserSession_token(ctx, field) if err != nil { return graphql.Null } @@ -19315,7 +20456,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Token, nil }) if err != nil { ec.Error(ctx, err) @@ -19332,9 +20473,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserSession_token(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "UserSession", Field: field, IsMethod: false, IsResolver: false, @@ -19345,8 +20486,8 @@ func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, fie return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _Version_id(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_id(ctx, field) if err != nil { return graphql.Null } @@ -19359,35 +20500,38 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type VersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _Version_mod_id(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_mod_id(ctx, field) if err != nil { return graphql.Null } @@ -19400,7 +20544,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.ModID, nil }) if err != nil { ec.Error(ctx, err) @@ -19412,26 +20556,26 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type ModID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _Version_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_version(ctx, field) if err != nil { return graphql.Null } @@ -19444,25 +20588,28 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Version, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -19471,8 +20618,8 @@ func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _Version_sml_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_sml_version(ctx, field) if err != nil { return graphql.Null } @@ -19485,7 +20632,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Version().SmlVersion(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -19502,12 +20649,12 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_sml_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -19515,8 +20662,8 @@ func (ec *executionContext) fieldContext___Field_name(_ context.Context, field g return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _Version_game_version(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_game_version(ctx, field) if err != nil { return graphql.Null } @@ -19529,25 +20676,28 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.GameVersion, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_game_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -19556,8 +20706,8 @@ func (ec *executionContext) fieldContext___Field_description(_ context.Context, return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _Version_required_on_remote(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_required_on_remote(ctx, field) if err != nil { return graphql.Null } @@ -19570,7 +20720,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.RequiredOnRemote, nil }) if err != nil { ec.Error(ctx, err) @@ -19582,51 +20732,26 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_required_on_remote(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - case "isDeprecated": - return ec.fieldContext___InputValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___InputValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _Version_changelog(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_changelog(ctx, field) if err != nil { return graphql.Null } @@ -19639,7 +20764,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Changelog, nil }) if err != nil { ec.Error(ctx, err) @@ -19651,50 +20776,26 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_changelog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _Version_downloads(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_downloads(ctx, field) if err != nil { return graphql.Null } @@ -19707,7 +20808,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Downloads, nil }) if err != nil { ec.Error(ctx, err) @@ -19719,26 +20820,26 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _Version_stability(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_stability(ctx, field) if err != nil { return graphql.Null } @@ -19751,35 +20852,38 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Stability, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - return graphql.Null + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } - res := resTmp.(*string) + res := resTmp.(VersionStabilities) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_stability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type VersionStabilities does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _Version_approved(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_approved(ctx, field) if err != nil { return graphql.Null } @@ -19792,7 +20896,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Approved, nil }) if err != nil { ec.Error(ctx, err) @@ -19804,26 +20908,26 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_approved(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) +func (ec *executionContext) _Version_updated_at(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_updated_at(ctx, field) if err != nil { return graphql.Null } @@ -19836,35 +20940,38 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.UpdatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) +func (ec *executionContext) _Version_created_at(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_created_at(ctx, field) if err != nil { return graphql.Null } @@ -19877,7 +20984,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -19889,50 +20996,26 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) +func (ec *executionContext) _Version_link(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_link(ctx, field) if err != nil { return graphql.Null } @@ -19945,26 +21028,29 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return ec.resolvers.Version().Link(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, @@ -19972,8 +21058,8 @@ func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Con return fc, nil } -func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_isDeprecated(ctx, field) +func (ec *executionContext) _Version_targets(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_targets(ctx, field) if err != nil { return graphql.Null } @@ -19986,7 +21072,7 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Targets, nil }) if err != nil { ec.Error(ctx, err) @@ -19998,26 +21084,38 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*VersionTarget) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_targets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "VersionID": + return ec.fieldContext_VersionTarget_VersionID(ctx, field) + case "targetName": + return ec.fieldContext_VersionTarget_targetName(ctx, field) + case "link": + return ec.fieldContext_VersionTarget_link(ctx, field) + case "size": + return ec.fieldContext_VersionTarget_size(ctx, field) + case "hash": + return ec.fieldContext_VersionTarget_hash(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VersionTarget", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_deprecationReason(ctx, field) +func (ec *executionContext) _Version_metadata(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_metadata(ctx, field) if err != nil { return graphql.Null } @@ -20030,7 +21128,7 @@ func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Metadata, nil }) if err != nil { ec.Error(ctx, err) @@ -20044,11 +21142,11 @@ func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "Version", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -20057,8 +21155,8 @@ func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ contex return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) +func (ec *executionContext) _Version_size(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_size(ctx, field) if err != nil { return graphql.Null } @@ -20071,7 +21169,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.resolvers.Version().Size(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -20080,26 +21178,26 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "Version", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +func (ec *executionContext) _Version_hash(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_hash(ctx, field) if err != nil { return graphql.Null } @@ -20112,62 +21210,35 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return ec.resolvers.Version().Hash(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*string) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "Version", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) +func (ec *executionContext) _Version_mod(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_mod(ctx, field) if err != nil { return graphql.Null } @@ -20180,7 +21251,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return ec.resolvers.Version().Mod(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -20192,50 +21263,80 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "Version", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "id": + return ec.fieldContext_Mod_id(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) +func (ec *executionContext) _Version_dependencies(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_dependencies(ctx, field) if err != nil { return graphql.Null } @@ -20248,59 +21349,54 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return ec.resolvers.Version().Dependencies(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*VersionDependency) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNVersionDependency2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependencyᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_dependencies(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "Version", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "version_id": + return ec.fieldContext_VersionDependency_version_id(ctx, field) + case "mod_id": + return ec.fieldContext_VersionDependency_mod_id(ctx, field) + case "condition": + return ec.fieldContext_VersionDependency_condition(ctx, field) + case "optional": + return ec.fieldContext_VersionDependency_optional(ctx, field) + case "mod_reference": + return ec.fieldContext_VersionDependency_mod_reference(ctx, field) + case "mod": + return ec.fieldContext_VersionDependency_mod(ctx, field) + case "version": + return ec.fieldContext_VersionDependency_version(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type VersionDependency", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) +func (ec *executionContext) _Version_virustotal_results(ctx context.Context, field graphql.CollectedField, obj *Version) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Version_virustotal_results(ctx, field) if err != nil { return graphql.Null } @@ -20313,59 +21409,54 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return ec.resolvers.Version().VirustotalResults(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*VirustotalResult) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNVirustotalResult2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVirustotalResultᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Version_virustotal_results(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "Version", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "id": + return ec.fieldContext_VirustotalResult_id(ctx, field) + case "hash": + return ec.fieldContext_VirustotalResult_hash(ctx, field) + case "safe": + return ec.fieldContext_VirustotalResult_safe(ctx, field) + case "file_name": + return ec.fieldContext_VirustotalResult_file_name(ctx, field) + case "version_id": + return ec.fieldContext_VirustotalResult_version_id(ctx, field) + case "created_at": + return ec.fieldContext_VirustotalResult_created_at(ctx, field) + case "updated_at": + return ec.fieldContext_VirustotalResult_updated_at(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type VirustotalResult", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) _VersionDependency_version_id(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_version_id(ctx, field) if err != nil { return graphql.Null } @@ -20378,7 +21469,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.VersionID, nil }) if err != nil { ec.Error(ctx, err) @@ -20390,38 +21481,26 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, errors.New("field of type VersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) _VersionDependency_mod_id(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_mod_id(ctx, field) if err != nil { return graphql.Null } @@ -20434,7 +21513,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.ModID, nil }) if err != nil { ec.Error(ctx, err) @@ -20448,24 +21527,24 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } res := resTmp.(string) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") + return nil, errors.New("field of type ModID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) _VersionDependency_condition(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_condition(ctx, field) if err != nil { return graphql.Null } @@ -20478,25 +21557,28 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Condition, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_condition(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -20505,8 +21587,8 @@ func (ec *executionContext) fieldContext___Type_name(_ context.Context, field gr return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) _VersionDependency_optional(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_optional(ctx, field) if err != nil { return graphql.Null } @@ -20519,36 +21601,39 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Optional, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_optional(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) - if err != nil { +func (ec *executionContext) _VersionDependency_mod_reference(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_mod_reference(ctx, field) + if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) @@ -20560,25 +21645,28 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil + return obj.ModReference, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_mod_reference(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -20587,8 +21675,8 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) _VersionDependency_mod(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_mod(ctx, field) if err != nil { return graphql.Null } @@ -20601,7 +21689,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return ec.resolvers.VersionDependency().Mod(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -20610,51 +21698,80 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.(*Mod) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_mod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "id": + return ec.fieldContext_Mod_id(ctx, field) case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) + return ec.fieldContext_Mod_name(ctx, field) + case "short_description": + return ec.fieldContext_Mod_short_description(ctx, field) + case "full_description": + return ec.fieldContext_Mod_full_description(ctx, field) + case "logo": + return ec.fieldContext_Mod_logo(ctx, field) + case "logo_thumbhash": + return ec.fieldContext_Mod_logo_thumbhash(ctx, field) + case "source_url": + return ec.fieldContext_Mod_source_url(ctx, field) + case "creator_id": + return ec.fieldContext_Mod_creator_id(ctx, field) + case "approved": + return ec.fieldContext_Mod_approved(ctx, field) + case "views": + return ec.fieldContext_Mod_views(ctx, field) + case "downloads": + return ec.fieldContext_Mod_downloads(ctx, field) + case "hotness": + return ec.fieldContext_Mod_hotness(ctx, field) + case "popularity": + return ec.fieldContext_Mod_popularity(ctx, field) + case "updated_at": + return ec.fieldContext_Mod_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Mod_created_at(ctx, field) + case "last_version_date": + return ec.fieldContext_Mod_last_version_date(ctx, field) + case "mod_reference": + return ec.fieldContext_Mod_mod_reference(ctx, field) + case "hidden": + return ec.fieldContext_Mod_hidden(ctx, field) + case "tags": + return ec.fieldContext_Mod_tags(ctx, field) + case "compatibility": + return ec.fieldContext_Mod_compatibility(ctx, field) + case "toggle_network_use": + return ec.fieldContext_Mod_toggle_network_use(ctx, field) + case "toggle_explicit_content": + return ec.fieldContext_Mod_toggle_explicit_content(ctx, field) + case "authors": + return ec.fieldContext_Mod_authors(ctx, field) + case "version": + return ec.fieldContext_Mod_version(ctx, field) + case "versions": + return ec.fieldContext_Mod_versions(ctx, field) + case "latestVersions": + return ec.fieldContext_Mod_latestVersions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Mod", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) _VersionDependency_version(ctx context.Context, field graphql.CollectedField, obj *VersionDependency) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionDependency_version(ctx, field) if err != nil { return graphql.Null } @@ -20667,7 +21784,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.Version, nil }) if err != nil { ec.Error(ctx, err) @@ -20676,50 +21793,68 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*Version) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionDependency_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionDependency", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "id": + return ec.fieldContext_Version_id(ctx, field) + case "mod_id": + return ec.fieldContext_Version_mod_id(ctx, field) + case "version": + return ec.fieldContext_Version_version(ctx, field) + case "sml_version": + return ec.fieldContext_Version_sml_version(ctx, field) + case "game_version": + return ec.fieldContext_Version_game_version(ctx, field) + case "required_on_remote": + return ec.fieldContext_Version_required_on_remote(ctx, field) + case "changelog": + return ec.fieldContext_Version_changelog(ctx, field) + case "downloads": + return ec.fieldContext_Version_downloads(ctx, field) + case "stability": + return ec.fieldContext_Version_stability(ctx, field) + case "approved": + return ec.fieldContext_Version_approved(ctx, field) + case "updated_at": + return ec.fieldContext_Version_updated_at(ctx, field) + case "created_at": + return ec.fieldContext_Version_created_at(ctx, field) + case "link": + return ec.fieldContext_Version_link(ctx, field) + case "targets": + return ec.fieldContext_Version_targets(ctx, field) + case "metadata": + return ec.fieldContext_Version_metadata(ctx, field) + case "size": + return ec.fieldContext_Version_size(ctx, field) + case "hash": + return ec.fieldContext_Version_hash(ctx, field) + case "mod": + return ec.fieldContext_Version_mod(ctx, field) + case "dependencies": + return ec.fieldContext_Version_dependencies(ctx, field) + case "virustotal_results": + return ec.fieldContext_Version_virustotal_results(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) _VersionTarget_VersionID(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionTarget_VersionID(ctx, field) if err != nil { return graphql.Null } @@ -20732,59 +21867,38 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.VersionID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionTarget_VersionID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionTarget", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type VersionID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) _VersionTarget_targetName(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionTarget_targetName(ctx, field) if err != nil { return graphql.Null } @@ -20797,56 +21911,82 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.TargetName, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(TargetName) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionTarget_targetName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionTarget", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, errors.New("field of type TargetName does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _VersionTarget_link(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionTarget_link(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.VersionTarget().Link(rctx, obj) + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionTarget_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionTarget", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } return fc, nil } -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) _VersionTarget_size(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionTarget_size(ctx, field) if err != nil { return graphql.Null } @@ -20859,7 +21999,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Size, nil }) if err != nil { ec.Error(ctx, err) @@ -20868,40 +22008,26 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*int) fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionTarget_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionTarget", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - case "isDeprecated": - return ec.fieldContext___InputValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___InputValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) +func (ec *executionContext) _VersionTarget_hash(ctx context.Context, field graphql.CollectedField, obj *VersionTarget) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionTarget_hash(ctx, field) if err != nil { return graphql.Null } @@ -20914,7 +22040,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Hash, nil }) if err != nil { ec.Error(ctx, err) @@ -20923,50 +22049,26 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionTarget_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VersionTarget", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_isOneOf(ctx, field) +func (ec *executionContext) _VirustotalResult_id(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_id(ctx, field) if err != nil { return graphql.Null } @@ -20979,7 +22081,7 @@ func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsOneOf(), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -20988,107 +22090,2315 @@ func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalOBoolean2bool(ctx, field.Selections, res) + return ec.marshalOVirustotalID2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VirustotalResult_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "VirustotalResult", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type VirustotalID does not have child fields") }, } return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputCompatibilityInfoInput(ctx context.Context, obj any) (CompatibilityInfoInput, error) { - var it CompatibilityInfoInput - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v +func (ec *executionContext) _VirustotalResult_hash(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_hash(ctx, field) + if err != nil { + return graphql.Null } - - fieldsInOrder := [...]string{"EA", "EXP"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } - switch k { - case "EA": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EA")) - data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) - if err != nil { - return it, err - } - it.Ea = data - case "EXP": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EXP")) - data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) - if err != nil { - return it, err - } - it.Exp = data + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hash, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - - return it, nil + res := resTmp.(string) + fc.Result = res + return ec.marshalNVirustotalHash2string(ctx, field.Selections, res) } -func (ec *executionContext) unmarshalInputCompatibilityInput(ctx context.Context, obj any) (CompatibilityInput, error) { - var it CompatibilityInput - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"state", "note"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "state": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) - data, err := ec.unmarshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx, v) - if err != nil { - return it, err - } - it.State = data - case "note": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("note")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Note = data - } +func (ec *executionContext) fieldContext_VirustotalResult_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type VirustotalHash does not have child fields") + }, } - - return it, nil + return fc, nil } -func (ec *executionContext) unmarshalInputGuideFilter(ctx context.Context, obj any) (map[string]any, error) { - it := make(map[string]any, len(obj.(map[string]any))) - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v +func (ec *executionContext) _VirustotalResult_safe(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_safe(ctx, field) + if err != nil { + return graphql.Null } - - fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids", "tagIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Safe, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VirustotalResult_safe(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VirustotalResult_file_name(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_file_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.FileName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VirustotalResult_file_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VirustotalResult_version_id(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_version_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.VersionID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VirustotalResult_version_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VirustotalResult_created_at(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_created_at(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNDate2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VirustotalResult_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Date does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VirustotalResult_updated_at(ctx context.Context, field graphql.CollectedField, obj *VirustotalResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VirustotalResult_updated_at(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.UpdatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalODate2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VirustotalResult_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VirustotalResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Date does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsRepeatable, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "isDeprecated": + return ec.fieldContext___InputValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___InputValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "isDeprecated": + return ec.fieldContext___InputValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___InputValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "isDeprecated": + return ec.fieldContext___InputValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___InputValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_isOneOf(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsOneOf(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalOBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputCompatibilityInfoInput(ctx context.Context, obj any) (CompatibilityInfoInput, error) { + var it CompatibilityInfoInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"EA", "EXP"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "EA": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EA")) + data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) + if err != nil { + return it, err + } + it.Ea = data + case "EXP": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EXP")) + data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) + if err != nil { + return it, err + } + it.Exp = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCompatibilityInput(ctx context.Context, obj any) (CompatibilityInput, error) { + var it CompatibilityInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"state", "note"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "state": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + data, err := ec.unmarshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx, v) + if err != nil { + return it, err + } + it.State = data + case "note": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("note")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Note = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputGuideFilter(ctx context.Context, obj any) (map[string]any, error) { + it := make(map[string]any, len(obj.(map[string]any))) + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids", "tagIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { continue } switch k { @@ -21244,20 +24554,130 @@ func (ec *executionContext) unmarshalInputModVersionConstraint(ctx context.Conte continue } switch k { - case "modIdOrReference": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIdOrReference")) + case "modIdOrReference": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIdOrReference")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.ModIDOrReference = data + case "version": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Version = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputModpackFilter(ctx context.Context, obj any) (ModpackFilter, error) { + var it ModpackFilter + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids", "hidden", "tagIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "limit": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Limit = data + case "offset": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Offset = data + case "order_by": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("order_by")) + data, err := ec.unmarshalOModpackFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackFields(ctx, v) + if err != nil { + return it, err + } + it.OrderBy = data + case "order": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("order")) + data, err := ec.unmarshalOOrder2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOrder(ctx, v) + if err != nil { + return it, err + } + it.Order = data + case "search": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("search")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Search = data + case "ids": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) + data, err := ec.unmarshalOModpackID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Ids = data + case "hidden": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hidden")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Hidden = data + case "tagIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) + data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TagIDs = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputModpackModInput(ctx context.Context, obj any) (ModpackModInput, error) { + var it ModpackModInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"mod_id", "version_constraint"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "mod_id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod_id")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.ModIDOrReference = data - case "version": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + it.ModID = data + case "version_constraint": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version_constraint")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.Version = data + it.VersionConstraint = data } } @@ -21436,6 +24856,123 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj any) ( return it, nil } +func (ec *executionContext) unmarshalInputNewModpack(ctx context.Context, obj any) (NewModpack, error) { + var it NewModpack + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "full_description", "logo", "hidden", "tagIDs", "targets", "mods", "parent_id"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "short_description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.ShortDescription = data + case "full_description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("full_description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FullDescription = data + case "logo": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logo")) + data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) + if err != nil { + return it, err + } + it.Logo = data + case "hidden": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hidden")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Hidden = data + case "tagIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) + data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TagIDs = data + case "targets": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) + data, err := ec.unmarshalNString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Targets = data + case "mods": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mods")) + data, err := ec.unmarshalNModpackModInput2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Mods = data + case "parent_id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parent_id")) + data, err := ec.unmarshalOModpackID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParentID = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputNewModpackRelease(ctx context.Context, obj any) (NewModpackRelease, error) { + var it NewModpackRelease + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"version", "changelog"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "version": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Version = data + case "changelog": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Changelog = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputNewSatisfactoryVersion(ctx context.Context, obj any) (NewSatisfactoryVersion, error) { var it NewSatisfactoryVersion asMap := map[string]any{} @@ -21841,6 +25378,82 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj any return it, nil } +func (ec *executionContext) unmarshalInputUpdateModpack(ctx context.Context, obj any) (UpdateModpack, error) { + var it UpdateModpack + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "full_description", "logo", "hidden", "tagIDs", "targets", "mods"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "short_description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ShortDescription = data + case "full_description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("full_description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FullDescription = data + case "logo": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logo")) + data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) + if err != nil { + return it, err + } + it.Logo = data + case "hidden": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hidden")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Hidden = data + case "tagIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) + data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TagIDs = data + case "targets": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Targets = data + case "mods": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mods")) + data, err := ec.unmarshalOModpackModInput2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Mods = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputUpdateSatisfactoryVersion(ctx context.Context, obj any) (UpdateSatisfactoryVersion, error) { var it UpdateSatisfactoryVersion asMap := map[string]any{} @@ -22063,47 +25676,173 @@ func (ec *executionContext) unmarshalInputVersionFilter(ctx context.Context, obj if err != nil { return it, err } - it["ids"] = data + it["ids"] = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var announcementImplementors = []string{"Announcement"} + +func (ec *executionContext) _Announcement(ctx context.Context, sel ast.SelectionSet, obj *Announcement) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, announcementImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Announcement") + case "id": + out.Values[i] = ec._Announcement_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "message": + out.Values[i] = ec._Announcement_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "importance": + out.Values[i] = ec._Announcement_importance(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var compatibilityImplementors = []string{"Compatibility"} + +func (ec *executionContext) _Compatibility(ctx context.Context, sel ast.SelectionSet, obj *Compatibility) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, compatibilityImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Compatibility") + case "state": + out.Values[i] = ec._Compatibility_state(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "note": + out.Values[i] = ec._Compatibility_note(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** + atomic.AddInt32(&ec.deferred, int32(len(deferred))) -// endregion ************************** interface.gotpl *************************** + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } -// region **************************** object.gotpl **************************** + return out +} -var announcementImplementors = []string{"Announcement"} +var compatibilityInfoImplementors = []string{"CompatibilityInfo"} -func (ec *executionContext) _Announcement(ctx context.Context, sel ast.SelectionSet, obj *Announcement) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, announcementImplementors) +func (ec *executionContext) _CompatibilityInfo(ctx context.Context, sel ast.SelectionSet, obj *CompatibilityInfo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, compatibilityInfoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Announcement") - case "id": - out.Values[i] = ec._Announcement_id(ctx, field, obj) + out.Values[i] = graphql.MarshalString("CompatibilityInfo") + case "EA": + out.Values[i] = ec._CompatibilityInfo_EA(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "message": - out.Values[i] = ec._Announcement_message(ctx, field, obj) + case "EXP": + out.Values[i] = ec._CompatibilityInfo_EXP(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "importance": - out.Values[i] = ec._Announcement_importance(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var createVersionResponseImplementors = []string{"CreateVersionResponse"} + +func (ec *executionContext) _CreateVersionResponse(ctx context.Context, sel ast.SelectionSet, obj *CreateVersionResponse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, createVersionResponseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CreateVersionResponse") + case "auto_approved": + out.Values[i] = ec._CreateVersionResponse_auto_approved(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } + case "version": + out.Values[i] = ec._CreateVersionResponse_version(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22127,24 +25866,195 @@ func (ec *executionContext) _Announcement(ctx context.Context, sel ast.Selection return out } -var compatibilityImplementors = []string{"Compatibility"} +var getGuidesImplementors = []string{"GetGuides"} -func (ec *executionContext) _Compatibility(ctx context.Context, sel ast.SelectionSet, obj *Compatibility) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, compatibilityImplementors) +func (ec *executionContext) _GetGuides(ctx context.Context, sel ast.SelectionSet, obj *GetGuides) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getGuidesImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("GetGuides") + case "guides": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetGuides_guides(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "count": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetGuides_count(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var getModpacksImplementors = []string{"GetModpacks"} + +func (ec *executionContext) _GetModpacks(ctx context.Context, sel ast.SelectionSet, obj *GetModpacks) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getModpacksImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("GetModpacks") + case "modpacks": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetModpacks_modpacks(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "count": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetModpacks_count(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Compatibility") - case "state": - out.Values[i] = ec._Compatibility_state(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue } - case "note": - out.Values[i] = ec._Compatibility_note(ctx, field, obj) + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22168,27 +26078,89 @@ func (ec *executionContext) _Compatibility(ctx context.Context, sel ast.Selectio return out } -var compatibilityInfoImplementors = []string{"CompatibilityInfo"} +var getModsImplementors = []string{"GetMods"} -func (ec *executionContext) _CompatibilityInfo(ctx context.Context, sel ast.SelectionSet, obj *CompatibilityInfo) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, compatibilityInfoImplementors) +func (ec *executionContext) _GetMods(ctx context.Context, sel ast.SelectionSet, obj *GetMods) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getModsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("CompatibilityInfo") - case "EA": - out.Values[i] = ec._CompatibilityInfo_EA(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ + out.Values[i] = graphql.MarshalString("GetMods") + case "mods": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetMods_mods(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res } - case "EXP": - out.Values[i] = ec._CompatibilityInfo_EXP(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "count": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetMods_count(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22212,24 +26184,89 @@ func (ec *executionContext) _CompatibilityInfo(ctx context.Context, sel ast.Sele return out } -var createVersionResponseImplementors = []string{"CreateVersionResponse"} +var getMyModsImplementors = []string{"GetMyMods"} -func (ec *executionContext) _CreateVersionResponse(ctx context.Context, sel ast.SelectionSet, obj *CreateVersionResponse) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, createVersionResponseImplementors) +func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet, obj *GetMyMods) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getMyModsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("CreateVersionResponse") - case "auto_approved": - out.Values[i] = ec._CreateVersionResponse_auto_approved(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ + out.Values[i] = graphql.MarshalString("GetMyMods") + case "mods": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetMyMods_mods(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res } - case "version": - out.Values[i] = ec._CreateVersionResponse_version(ctx, field, obj) + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "count": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._GetMyMods_count(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22253,18 +26290,18 @@ func (ec *executionContext) _CreateVersionResponse(ctx context.Context, sel ast. return out } -var getGuidesImplementors = []string{"GetGuides"} +var getMyVersionsImplementors = []string{"GetMyVersions"} -func (ec *executionContext) _GetGuides(ctx context.Context, sel ast.SelectionSet, obj *GetGuides) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getGuidesImplementors) +func (ec *executionContext) _GetMyVersions(ctx context.Context, sel ast.SelectionSet, obj *GetMyVersions) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getMyVersionsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("GetGuides") - case "guides": + out.Values[i] = graphql.MarshalString("GetMyVersions") + case "versions": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22273,7 +26310,7 @@ func (ec *executionContext) _GetGuides(ctx context.Context, sel ast.SelectionSet ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetGuides_guides(ctx, field, obj) + res = ec._GetMyVersions_versions(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22309,7 +26346,7 @@ func (ec *executionContext) _GetGuides(ctx context.Context, sel ast.SelectionSet ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetGuides_count(ctx, field, obj) + res = ec._GetMyVersions_count(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22359,18 +26396,18 @@ func (ec *executionContext) _GetGuides(ctx context.Context, sel ast.SelectionSet return out } -var getModsImplementors = []string{"GetMods"} +var getSMLVersionsImplementors = []string{"GetSMLVersions"} -func (ec *executionContext) _GetMods(ctx context.Context, sel ast.SelectionSet, obj *GetMods) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getModsImplementors) +func (ec *executionContext) _GetSMLVersions(ctx context.Context, sel ast.SelectionSet, obj *GetSMLVersions) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getSMLVersionsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("GetMods") - case "mods": + out.Values[i] = graphql.MarshalString("GetSMLVersions") + case "sml_versions": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22379,7 +26416,7 @@ func (ec *executionContext) _GetMods(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetMods_mods(ctx, field, obj) + res = ec._GetSMLVersions_sml_versions(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22415,7 +26452,7 @@ func (ec *executionContext) _GetMods(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetMods_count(ctx, field, obj) + res = ec._GetSMLVersions_count(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22465,18 +26502,18 @@ func (ec *executionContext) _GetMods(ctx context.Context, sel ast.SelectionSet, return out } -var getMyModsImplementors = []string{"GetMyMods"} +var getVersionsImplementors = []string{"GetVersions"} -func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet, obj *GetMyMods) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getMyModsImplementors) +func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionSet, obj *GetVersions) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getVersionsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("GetMyMods") - case "mods": + out.Values[i] = graphql.MarshalString("GetVersions") + case "versions": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22485,7 +26522,7 @@ func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetMyMods_mods(ctx, field, obj) + res = ec._GetVersions_versions(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22521,7 +26558,7 @@ func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetMyMods_count(ctx, field, obj) + res = ec._GetVersions_count(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22542,12 +26579,56 @@ func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet return innerFunc(ctx, dfs) }) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) +var groupImplementors = []string{"Group"} + +func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *Group) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Group") + case "id": + out.Values[i] = ec._Group_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._Group_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22571,18 +26652,63 @@ func (ec *executionContext) _GetMyMods(ctx context.Context, sel ast.SelectionSet return out } -var getMyVersionsImplementors = []string{"GetMyVersions"} +var guideImplementors = []string{"Guide"} -func (ec *executionContext) _GetMyVersions(ctx context.Context, sel ast.SelectionSet, obj *GetMyVersions) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getMyVersionsImplementors) +func (ec *executionContext) _Guide(ctx context.Context, sel ast.SelectionSet, obj *Guide) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, guideImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("GetMyVersions") - case "versions": + out.Values[i] = graphql.MarshalString("Guide") + case "id": + out.Values[i] = ec._Guide_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Guide_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "short_description": + out.Values[i] = ec._Guide_short_description(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "guide": + out.Values[i] = ec._Guide_guide(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "views": + out.Values[i] = ec._Guide_views(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "user_id": + out.Values[i] = ec._Guide_user_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updated_at": + out.Values[i] = ec._Guide_updated_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "created_at": + out.Values[i] = ec._Guide_created_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "tags": + out.Values[i] = ec._Guide_tags(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22591,7 +26717,7 @@ func (ec *executionContext) _GetMyVersions(ctx context.Context, sel ast.Selectio ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetMyVersions_versions(ctx, field, obj) + res = ec._Guide_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22618,42 +26744,46 @@ func (ec *executionContext) _GetMyVersions(ctx context.Context, sel ast.Selectio } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "count": - field := field + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._GetMyVersions_count(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } + atomic.AddInt32(&ec.deferred, int32(len(deferred))) - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + return out +} - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) +var latestVersionsImplementors = []string{"LatestVersions"} + +func (ec *executionContext) _LatestVersions(ctx context.Context, sel ast.SelectionSet, obj *LatestVersions) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, latestVersionsImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LatestVersions") + case "alpha": + out.Values[i] = ec._LatestVersions_alpha(ctx, field, obj) + case "beta": + out.Values[i] = ec._LatestVersions_beta(ctx, field, obj) + case "release": + out.Values[i] = ec._LatestVersions_release(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -22677,18 +26807,107 @@ func (ec *executionContext) _GetMyVersions(ctx context.Context, sel ast.Selectio return out } -var getSMLVersionsImplementors = []string{"GetSMLVersions"} +var modImplementors = []string{"Mod"} -func (ec *executionContext) _GetSMLVersions(ctx context.Context, sel ast.SelectionSet, obj *GetSMLVersions) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getSMLVersionsImplementors) +func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj *Mod) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, modImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("GetSMLVersions") - case "sml_versions": + out.Values[i] = graphql.MarshalString("Mod") + case "id": + out.Values[i] = ec._Mod_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Mod_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "short_description": + out.Values[i] = ec._Mod_short_description(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "full_description": + out.Values[i] = ec._Mod_full_description(ctx, field, obj) + case "logo": + out.Values[i] = ec._Mod_logo(ctx, field, obj) + case "logo_thumbhash": + out.Values[i] = ec._Mod_logo_thumbhash(ctx, field, obj) + case "source_url": + out.Values[i] = ec._Mod_source_url(ctx, field, obj) + case "creator_id": + out.Values[i] = ec._Mod_creator_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "approved": + out.Values[i] = ec._Mod_approved(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "views": + out.Values[i] = ec._Mod_views(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "downloads": + out.Values[i] = ec._Mod_downloads(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "hotness": + out.Values[i] = ec._Mod_hotness(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "popularity": + out.Values[i] = ec._Mod_popularity(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updated_at": + out.Values[i] = ec._Mod_updated_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "created_at": + out.Values[i] = ec._Mod_created_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "last_version_date": + out.Values[i] = ec._Mod_last_version_date(ctx, field, obj) + case "mod_reference": + out.Values[i] = ec._Mod_mod_reference(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "hidden": + out.Values[i] = ec._Mod_hidden(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "tags": + out.Values[i] = ec._Mod_tags(ctx, field, obj) + case "compatibility": + out.Values[i] = ec._Mod_compatibility(ctx, field, obj) + case "toggle_network_use": + out.Values[i] = ec._Mod_toggle_network_use(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "toggle_explicit_content": + out.Values[i] = ec._Mod_toggle_explicit_content(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "authors": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22697,7 +26916,7 @@ func (ec *executionContext) _GetSMLVersions(ctx context.Context, sel ast.Selecti ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetSMLVersions_sml_versions(ctx, field, obj) + res = ec._Mod_authors(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22724,19 +26943,16 @@ func (ec *executionContext) _GetSMLVersions(ctx context.Context, sel ast.Selecti } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "count": + case "version": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetSMLVersions_count(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Mod_version(ctx, field, obj) return res } @@ -22760,40 +26976,6 @@ func (ec *executionContext) _GetSMLVersions(ctx context.Context, sel ast.Selecti } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var getVersionsImplementors = []string{"GetVersions"} - -func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionSet, obj *GetVersions) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, getVersionsImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("GetVersions") case "versions": field := field @@ -22803,7 +26985,7 @@ func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionS ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetVersions_versions(ctx, field, obj) + res = ec._Mod_versions(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22830,7 +27012,7 @@ func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionS } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "count": + case "latestVersions": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22839,7 +27021,7 @@ func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionS ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._GetVersions_count(ctx, field, obj) + res = ec._Mod_latestVersions(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22889,182 +27071,32 @@ func (ec *executionContext) _GetVersions(ctx context.Context, sel ast.SelectionS return out } -var groupImplementors = []string{"Group"} +var modVersionImplementors = []string{"ModVersion"} -func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *Group) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) +func (ec *executionContext) _ModVersion(ctx context.Context, sel ast.SelectionSet, obj *ModVersion) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, modVersionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Group") + out.Values[i] = graphql.MarshalString("ModVersion") case "id": - out.Values[i] = ec._Group_id(ctx, field, obj) + out.Values[i] = ec._ModVersion_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "name": - out.Values[i] = ec._Group_name(ctx, field, obj) + case "mod_reference": + out.Values[i] = ec._ModVersion_mod_reference(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var guideImplementors = []string{"Guide"} - -func (ec *executionContext) _Guide(ctx context.Context, sel ast.SelectionSet, obj *Guide) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, guideImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Guide") - case "id": - out.Values[i] = ec._Guide_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "name": - out.Values[i] = ec._Guide_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "short_description": - out.Values[i] = ec._Guide_short_description(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "guide": - out.Values[i] = ec._Guide_guide(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "views": - out.Values[i] = ec._Guide_views(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "user_id": - out.Values[i] = ec._Guide_user_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "updated_at": - out.Values[i] = ec._Guide_updated_at(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "created_at": - out.Values[i] = ec._Guide_created_at(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "tags": - out.Values[i] = ec._Guide_tags(ctx, field, obj) + case "versions": + out.Values[i] = ec._ModVersion_versions(ctx, field, obj) if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "user": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Guide_user(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var latestVersionsImplementors = []string{"LatestVersions"} - -func (ec *executionContext) _LatestVersions(ctx context.Context, sel ast.SelectionSet, obj *LatestVersions) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, latestVersionsImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("LatestVersions") - case "alpha": - out.Values[i] = ec._LatestVersions_alpha(ctx, field, obj) - case "beta": - out.Values[i] = ec._LatestVersions_beta(ctx, field, obj) - case "release": - out.Values[i] = ec._LatestVersions_release(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -23088,107 +27120,91 @@ func (ec *executionContext) _LatestVersions(ctx context.Context, sel ast.Selecti return out } -var modImplementors = []string{"Mod"} +var modpackImplementors = []string{"Modpack"} -func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj *Mod) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, modImplementors) +func (ec *executionContext) _Modpack(ctx context.Context, sel ast.SelectionSet, obj *Modpack) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, modpackImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Mod") + out.Values[i] = graphql.MarshalString("Modpack") case "id": - out.Values[i] = ec._Mod_id(ctx, field, obj) + out.Values[i] = ec._Modpack_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._Mod_name(ctx, field, obj) + out.Values[i] = ec._Modpack_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "short_description": - out.Values[i] = ec._Mod_short_description(ctx, field, obj) + out.Values[i] = ec._Modpack_short_description(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "full_description": - out.Values[i] = ec._Mod_full_description(ctx, field, obj) + out.Values[i] = ec._Modpack_full_description(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "logo": - out.Values[i] = ec._Mod_logo(ctx, field, obj) + out.Values[i] = ec._Modpack_logo(ctx, field, obj) case "logo_thumbhash": - out.Values[i] = ec._Mod_logo_thumbhash(ctx, field, obj) - case "source_url": - out.Values[i] = ec._Mod_source_url(ctx, field, obj) + out.Values[i] = ec._Modpack_logo_thumbhash(ctx, field, obj) case "creator_id": - out.Values[i] = ec._Mod_creator_id(ctx, field, obj) + out.Values[i] = ec._Modpack_creator_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "approved": - out.Values[i] = ec._Mod_approved(ctx, field, obj) + case "creator": + out.Values[i] = ec._Modpack_creator(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "views": - out.Values[i] = ec._Mod_views(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "downloads": - out.Values[i] = ec._Mod_downloads(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "hotness": - out.Values[i] = ec._Mod_hotness(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "popularity": - out.Values[i] = ec._Mod_popularity(ctx, field, obj) + out.Values[i] = ec._Modpack_views(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "updated_at": - out.Values[i] = ec._Mod_updated_at(ctx, field, obj) + case "installs": + out.Values[i] = ec._Modpack_installs(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "created_at": - out.Values[i] = ec._Mod_created_at(ctx, field, obj) + case "hotness": + out.Values[i] = ec._Modpack_hotness(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "last_version_date": - out.Values[i] = ec._Mod_last_version_date(ctx, field, obj) - case "mod_reference": - out.Values[i] = ec._Mod_mod_reference(ctx, field, obj) + case "popularity": + out.Values[i] = ec._Modpack_popularity(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "hidden": - out.Values[i] = ec._Mod_hidden(ctx, field, obj) + case "updated_at": + out.Values[i] = ec._Modpack_updated_at(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "tags": - out.Values[i] = ec._Mod_tags(ctx, field, obj) - case "compatibility": - out.Values[i] = ec._Mod_compatibility(ctx, field, obj) - case "toggle_network_use": - out.Values[i] = ec._Mod_toggle_network_use(ctx, field, obj) + case "created_at": + out.Values[i] = ec._Modpack_created_at(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "toggle_explicit_content": - out.Values[i] = ec._Mod_toggle_explicit_content(ctx, field, obj) + case "hidden": + out.Values[i] = ec._Modpack_hidden(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "authors": + case "parent_id": + out.Values[i] = ec._Modpack_parent_id(ctx, field, obj) + case "parent": + out.Values[i] = ec._Modpack_parent(ctx, field, obj) + case "children": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -23197,7 +27213,7 @@ func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Mod_authors(ctx, field, obj) + res = ec._Modpack_children(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -23224,111 +27240,70 @@ func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "version": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Mod_version(ctx, field, obj) - return res + case "tags": + out.Values[i] = ec._Modpack_tags(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + case "targets": + out.Values[i] = ec._Modpack_targets(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "versions": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Mod_versions(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res + case "mods": + out.Values[i] = ec._Modpack_mods(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "releases": + out.Values[i] = ec._Modpack_releases(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) + atomic.AddInt32(&ec.deferred, int32(len(deferred))) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "latestVersions": - field := field + return out +} - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Mod_latestVersions(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } +var modpackModEntryImplementors = []string{"ModpackModEntry"} - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) +func (ec *executionContext) _ModpackModEntry(ctx context.Context, sel ast.SelectionSet, obj *ModpackModEntry) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, modpackModEntryImplementors) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ModpackModEntry") + case "mod_id": + out.Values[i] = ec._ModpackModEntry_mod_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "version_constraint": + out.Values[i] = ec._ModpackModEntry_version_constraint(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -23352,29 +27327,39 @@ func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj return out } -var modVersionImplementors = []string{"ModVersion"} +var modpackReleaseImplementors = []string{"ModpackRelease"} -func (ec *executionContext) _ModVersion(ctx context.Context, sel ast.SelectionSet, obj *ModVersion) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, modVersionImplementors) +func (ec *executionContext) _ModpackRelease(ctx context.Context, sel ast.SelectionSet, obj *ModpackRelease) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, modpackReleaseImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("ModVersion") + out.Values[i] = graphql.MarshalString("ModpackRelease") case "id": - out.Values[i] = ec._ModVersion_id(ctx, field, obj) + out.Values[i] = ec._ModpackRelease_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "mod_reference": - out.Values[i] = ec._ModVersion_mod_reference(ctx, field, obj) + case "version": + out.Values[i] = ec._ModpackRelease_version(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "versions": - out.Values[i] = ec._ModVersion_versions(ctx, field, obj) + case "created_at": + out.Values[i] = ec._ModpackRelease_created_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "lockfile": + out.Values[i] = ec._ModpackRelease_lockfile(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "changelog": + out.Values[i] = ec._ModpackRelease_changelog(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -23506,6 +27491,42 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "createModpack": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createModpack(ctx, field) + }) + case "updateModpack": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateModpack(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteModpack": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteModpack(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createModpackRelease": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createModpackRelease(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteModpackRelease": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteModpackRelease(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resolveModpack": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_resolveModpack(ctx, field) + }) case "createSatisfactoryVersion": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createSatisfactoryVersion(ctx, field) @@ -24032,6 +28053,66 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "getModpack": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_getModpack(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "getModpacks": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_getModpacks(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "getModpackRelease": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_getModpackRelease(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "getSatisfactoryVersions": field := field @@ -26068,35 +30149,333 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o default: panic("unknown field " + strconv.Quote(field.Name)) } - } - out.Dispatch(ctx) - if out.Invalids > 0 { + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx context.Context, sel ast.SelectionSet, v Announcement) graphql.Marshaler { + return ec._Announcement(ctx, sel, &v) +} + +func (ec *executionContext) marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx context.Context, sel ast.SelectionSet, v []*Announcement) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx context.Context, sel ast.SelectionSet, v *Announcement) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Announcement(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNAnnouncementID2string(ctx context.Context, v any) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNAnnouncementID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, v any) (AnnouncementImportance, error) { + var res AnnouncementImportance + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, sel ast.SelectionSet, v AnnouncementImportance) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + _ = sel + res := graphql.MarshalBoolean(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx context.Context, sel ast.SelectionSet, v *Compatibility) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Compatibility(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNCompatibilityInfoInput2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx context.Context, v any) (CompatibilityInfoInput, error) { + res, err := ec.unmarshalInputCompatibilityInfoInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx context.Context, v any) (*CompatibilityInput, error) { + res, err := ec.unmarshalInputCompatibilityInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx context.Context, v any) (CompatibilityState, error) { + var res CompatibilityState + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx context.Context, sel ast.SelectionSet, v CompatibilityState) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNDate2string(ctx context.Context, v any) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNDate2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNGetGuides2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx context.Context, sel ast.SelectionSet, v GetGuides) graphql.Marshaler { + return ec._GetGuides(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetGuides2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx context.Context, sel ast.SelectionSet, v *GetGuides) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetGuides(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetModpacks2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetModpacks(ctx context.Context, sel ast.SelectionSet, v GetModpacks) graphql.Marshaler { + return ec._GetModpacks(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetModpacks2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetModpacks(ctx context.Context, sel ast.SelectionSet, v *GetModpacks) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetModpacks(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetMods2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx context.Context, sel ast.SelectionSet, v GetMods) graphql.Marshaler { + return ec._GetMods(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx context.Context, sel ast.SelectionSet, v *GetMods) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetMods(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetMyMods2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx context.Context, sel ast.SelectionSet, v GetMyMods) graphql.Marshaler { + return ec._GetMyMods(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx context.Context, sel ast.SelectionSet, v *GetMyMods) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetMyMods(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetMyVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx context.Context, sel ast.SelectionSet, v GetMyVersions) graphql.Marshaler { + return ec._GetMyVersions(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx context.Context, sel ast.SelectionSet, v *GetMyVersions) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetMyVersions(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetSMLVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx context.Context, sel ast.SelectionSet, v GetSMLVersions) graphql.Marshaler { + return ec._GetSMLVersions(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetSMLVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx context.Context, sel ast.SelectionSet, v *GetSMLVersions) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._GetSMLVersions(ctx, sel, v) +} + +func (ec *executionContext) marshalNGetVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx context.Context, sel ast.SelectionSet, v GetVersions) graphql.Marshaler { + return ec._GetVersions(ctx, sel, &v) +} + +func (ec *executionContext) marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx context.Context, sel ast.SelectionSet, v *GetVersions) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } return graphql.Null } + return ec._GetVersions(ctx, sel, v) +} - atomic.AddInt32(&ec.deferred, int32(len(deferred))) +func (ec *executionContext) marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx context.Context, sel ast.SelectionSet, v []*Group) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNGroup2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroup(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) } + wg.Wait() - return out -} + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } -// endregion **************************** object.gotpl **************************** + return ret +} -// region ***************************** type.gotpl ***************************** +func (ec *executionContext) marshalNGroup2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroup(ctx context.Context, sel ast.SelectionSet, v *Group) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Group(ctx, sel, v) +} -func (ec *executionContext) marshalNAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx context.Context, sel ast.SelectionSet, v Announcement) graphql.Marshaler { - return ec._Announcement(ctx, sel, &v) +func (ec *executionContext) marshalNGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx context.Context, sel ast.SelectionSet, v Guide) graphql.Marshaler { + return ec._Guide(ctx, sel, &v) } -func (ec *executionContext) marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx context.Context, sel ast.SelectionSet, v []*Announcement) graphql.Marshaler { +func (ec *executionContext) marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx context.Context, sel ast.SelectionSet, v []*Guide) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -26120,7 +30499,7 @@ func (ec *executionContext) marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfacto if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, sel, v[i]) + ret[i] = ec.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, sel, v[i]) } if isLen1 { f(i) @@ -26140,22 +30519,22 @@ func (ec *executionContext) marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfacto return ret } -func (ec *executionContext) marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx context.Context, sel ast.SelectionSet, v *Announcement) graphql.Marshaler { +func (ec *executionContext) marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx context.Context, sel ast.SelectionSet, v *Guide) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Announcement(ctx, sel, v) + return ec._Guide(ctx, sel, v) } -func (ec *executionContext) unmarshalNAnnouncementID2string(ctx context.Context, v any) (string, error) { +func (ec *executionContext) unmarshalNGuideID2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNAnnouncementID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { +func (ec *executionContext) marshalNGuideID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = sel res := graphql.MarshalString(v) if res == graphql.Null { @@ -26166,24 +30545,14 @@ func (ec *executionContext) marshalNAnnouncementID2string(ctx context.Context, s return res } -func (ec *executionContext) unmarshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, v any) (AnnouncementImportance, error) { - var res AnnouncementImportance - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, sel ast.SelectionSet, v AnnouncementImportance) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (int, error) { + res, err := graphql.UnmarshalInt(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { _ = sel - res := graphql.MarshalBoolean(v) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -26192,137 +30561,141 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx context.Context, sel ast.SelectionSet, v *Compatibility) graphql.Marshaler { +func (ec *executionContext) marshalNLatestVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx context.Context, sel ast.SelectionSet, v LatestVersions) graphql.Marshaler { + return ec._LatestVersions(ctx, sel, &v) +} + +func (ec *executionContext) marshalNLatestVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx context.Context, sel ast.SelectionSet, v *LatestVersions) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Compatibility(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNCompatibilityInfoInput2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx context.Context, v any) (CompatibilityInfoInput, error) { - res, err := ec.unmarshalInputCompatibilityInfoInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx context.Context, v any) (*CompatibilityInput, error) { - res, err := ec.unmarshalInputCompatibilityInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx context.Context, v any) (CompatibilityState, error) { - var res CompatibilityState - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx context.Context, sel ast.SelectionSet, v CompatibilityState) graphql.Marshaler { - return v + return ec._LatestVersions(ctx, sel, v) } -func (ec *executionContext) unmarshalNDate2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) +func (ec *executionContext) marshalNMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx context.Context, sel ast.SelectionSet, v Mod) graphql.Marshaler { + return ec._Mod(ctx, sel, &v) } -func (ec *executionContext) marshalNDate2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } +func (ec *executionContext) marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx context.Context, sel ast.SelectionSet, v []*Mod) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - return res -} + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) marshalNGetGuides2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx context.Context, sel ast.SelectionSet, v GetGuides) graphql.Marshaler { - return ec._GetGuides(ctx, sel, &v) -} + } + wg.Wait() -func (ec *executionContext) marshalNGetGuides2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx context.Context, sel ast.SelectionSet, v *GetGuides) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") + for _, e := range ret { + if e == graphql.Null { + return graphql.Null } - return graphql.Null } - return ec._GetGuides(ctx, sel, v) -} -func (ec *executionContext) marshalNGetMods2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx context.Context, sel ast.SelectionSet, v GetMods) graphql.Marshaler { - return ec._GetMods(ctx, sel, &v) + return ret } -func (ec *executionContext) marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx context.Context, sel ast.SelectionSet, v *GetMods) graphql.Marshaler { +func (ec *executionContext) marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx context.Context, sel ast.SelectionSet, v *Mod) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._GetMods(ctx, sel, v) + return ec._Mod(ctx, sel, v) } -func (ec *executionContext) marshalNGetMyMods2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx context.Context, sel ast.SelectionSet, v GetMyMods) graphql.Marshaler { - return ec._GetMyMods(ctx, sel, &v) +func (ec *executionContext) unmarshalNModID2string(ctx context.Context, v any) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx context.Context, sel ast.SelectionSet, v *GetMyMods) graphql.Marshaler { - if v == nil { +func (ec *executionContext) marshalNModID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel + res := graphql.MarshalString(v) + if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } - return graphql.Null } - return ec._GetMyMods(ctx, sel, v) -} - -func (ec *executionContext) marshalNGetMyVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx context.Context, sel ast.SelectionSet, v GetMyVersions) graphql.Marshaler { - return ec._GetMyVersions(ctx, sel, &v) + return res } -func (ec *executionContext) marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx context.Context, sel ast.SelectionSet, v *GetMyVersions) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") +func (ec *executionContext) unmarshalNModID2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) { + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNModID2string(ctx, vSlice[i]) + if err != nil { + return nil, err } - return graphql.Null } - return ec._GetMyVersions(ctx, sel, v) + return res, nil } -func (ec *executionContext) marshalNGetSMLVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx context.Context, sel ast.SelectionSet, v GetSMLVersions) graphql.Marshaler { - return ec._GetSMLVersions(ctx, sel, &v) -} +func (ec *executionContext) marshalNModID2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNModID2string(ctx, sel, v[i]) + } -func (ec *executionContext) marshalNGetSMLVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx context.Context, sel ast.SelectionSet, v *GetSMLVersions) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") + for _, e := range ret { + if e == graphql.Null { + return graphql.Null } - return graphql.Null } - return ec._GetSMLVersions(ctx, sel, v) + + return ret } -func (ec *executionContext) marshalNGetVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx context.Context, sel ast.SelectionSet, v GetVersions) graphql.Marshaler { - return ec._GetVersions(ctx, sel, &v) +func (ec *executionContext) unmarshalNModReference2string(ctx context.Context, v any) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx context.Context, sel ast.SelectionSet, v *GetVersions) graphql.Marshaler { - if v == nil { +func (ec *executionContext) marshalNModReference2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel + res := graphql.MarshalString(v) + if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } - return graphql.Null } - return ec._GetVersions(ctx, sel, v) + return res } -func (ec *executionContext) marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx context.Context, sel ast.SelectionSet, v []*Group) graphql.Marshaler { +func (ec *executionContext) marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionᚄ(ctx context.Context, sel ast.SelectionSet, v []*ModVersion) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -26346,7 +30719,7 @@ func (ec *executionContext) marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddi if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNGroup2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroup(ctx, sel, v[i]) + ret[i] = ec.marshalNModVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersion(ctx, sel, v[i]) } if isLen1 { f(i) @@ -26366,21 +30739,41 @@ func (ec *executionContext) marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddi return ret } -func (ec *executionContext) marshalNGroup2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroup(ctx context.Context, sel ast.SelectionSet, v *Group) graphql.Marshaler { +func (ec *executionContext) marshalNModVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersion(ctx context.Context, sel ast.SelectionSet, v *ModVersion) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Group(ctx, sel, v) + return ec._ModVersion(ctx, sel, v) } -func (ec *executionContext) marshalNGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx context.Context, sel ast.SelectionSet, v Guide) graphql.Marshaler { - return ec._Guide(ctx, sel, &v) +func (ec *executionContext) unmarshalNModVersionConstraint2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraintᚄ(ctx context.Context, v any) ([]*ModVersionConstraint, error) { + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ModVersionConstraint, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNModVersionConstraint2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraint(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } -func (ec *executionContext) marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx context.Context, sel ast.SelectionSet, v []*Guide) graphql.Marshaler { +func (ec *executionContext) unmarshalNModVersionConstraint2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraint(ctx context.Context, v any) (*ModVersionConstraint, error) { + res, err := ec.unmarshalInputModVersionConstraint(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNModpack2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx context.Context, sel ast.SelectionSet, v Modpack) graphql.Marshaler { + return ec._Modpack(ctx, sel, &v) +} + +func (ec *executionContext) marshalNModpack2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackᚄ(ctx context.Context, sel ast.SelectionSet, v []*Modpack) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -26404,7 +30797,7 @@ func (ec *executionContext) marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddi if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, sel, v[i]) + ret[i] = ec.marshalNModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx, sel, v[i]) } if isLen1 { f(i) @@ -26424,22 +30817,22 @@ func (ec *executionContext) marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddi return ret } -func (ec *executionContext) marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx context.Context, sel ast.SelectionSet, v *Guide) graphql.Marshaler { +func (ec *executionContext) marshalNModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx context.Context, sel ast.SelectionSet, v *Modpack) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Guide(ctx, sel, v) + return ec._Modpack(ctx, sel, v) } -func (ec *executionContext) unmarshalNGuideID2string(ctx context.Context, v any) (string, error) { +func (ec *executionContext) unmarshalNModpackID2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNGuideID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { +func (ec *executionContext) marshalNModpackID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = sel res := graphql.MarshalString(v) if res == graphql.Null { @@ -26450,41 +30843,7 @@ func (ec *executionContext) marshalNGuideID2string(ctx context.Context, sel ast. return res } -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - _ = sel - res := graphql.MarshalInt(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalNLatestVersions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx context.Context, sel ast.SelectionSet, v LatestVersions) graphql.Marshaler { - return ec._LatestVersions(ctx, sel, &v) -} - -func (ec *executionContext) marshalNLatestVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx context.Context, sel ast.SelectionSet, v *LatestVersions) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._LatestVersions(ctx, sel, v) -} - -func (ec *executionContext) marshalNMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx context.Context, sel ast.SelectionSet, v Mod) graphql.Marshaler { - return ec._Mod(ctx, sel, &v) -} - -func (ec *executionContext) marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx context.Context, sel ast.SelectionSet, v []*Mod) graphql.Marshaler { +func (ec *executionContext) marshalNModpackModEntry2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModEntryᚄ(ctx context.Context, sel ast.SelectionSet, v []*ModpackModEntry) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -26508,7 +30867,7 @@ func (ec *executionContext) marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymodding if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, sel, v[i]) + ret[i] = ec.marshalNModpackModEntry2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModEntry(ctx, sel, v[i]) } if isLen1 { f(i) @@ -26528,40 +30887,24 @@ func (ec *executionContext) marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymodding return ret } -func (ec *executionContext) marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx context.Context, sel ast.SelectionSet, v *Mod) graphql.Marshaler { +func (ec *executionContext) marshalNModpackModEntry2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModEntry(ctx context.Context, sel ast.SelectionSet, v *ModpackModEntry) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Mod(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNModID2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNModID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res + return ec._ModpackModEntry(ctx, sel, v) } -func (ec *executionContext) unmarshalNModID2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) { +func (ec *executionContext) unmarshalNModpackModInput2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInputᚄ(ctx context.Context, v any) ([]*ModpackModInput, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error - res := make([]string, len(vSlice)) + res := make([]*ModpackModInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNModID2string(ctx, vSlice[i]) + res[i], err = ec.unmarshalNModpackModInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -26569,38 +30912,16 @@ func (ec *executionContext) unmarshalNModID2ᚕstringᚄ(ctx context.Context, v return res, nil } -func (ec *executionContext) marshalNModID2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNModID2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNModReference2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) +func (ec *executionContext) unmarshalNModpackModInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInput(ctx context.Context, v any) (*ModpackModInput, error) { + res, err := ec.unmarshalInputModpackModInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNModReference2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res +func (ec *executionContext) marshalNModpackRelease2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx context.Context, sel ast.SelectionSet, v ModpackRelease) graphql.Marshaler { + return ec._ModpackRelease(ctx, sel, &v) } -func (ec *executionContext) marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionᚄ(ctx context.Context, sel ast.SelectionSet, v []*ModVersion) graphql.Marshaler { +func (ec *executionContext) marshalNModpackRelease2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackReleaseᚄ(ctx context.Context, sel ast.SelectionSet, v []*ModpackRelease) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -26624,7 +30945,7 @@ func (ec *executionContext) marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactory if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNModVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersion(ctx, sel, v[i]) + ret[i] = ec.marshalNModpackRelease2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx, sel, v[i]) } if isLen1 { f(i) @@ -26644,34 +30965,14 @@ func (ec *executionContext) marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactory return ret } -func (ec *executionContext) marshalNModVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersion(ctx context.Context, sel ast.SelectionSet, v *ModVersion) graphql.Marshaler { +func (ec *executionContext) marshalNModpackRelease2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx context.Context, sel ast.SelectionSet, v *ModpackRelease) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._ModVersion(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNModVersionConstraint2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraintᚄ(ctx context.Context, v any) ([]*ModVersionConstraint, error) { - var vSlice []any - vSlice = graphql.CoerceList(v) - var err error - res := make([]*ModVersionConstraint, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNModVersionConstraint2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraint(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalNModVersionConstraint2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraint(ctx context.Context, v any) (*ModVersionConstraint, error) { - res, err := ec.unmarshalInputModVersionConstraint(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + return ec._ModpackRelease(ctx, sel, v) } func (ec *executionContext) unmarshalNNewAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewAnnouncement(ctx context.Context, v any) (NewAnnouncement, error) { @@ -26689,6 +30990,16 @@ func (ec *executionContext) unmarshalNNewMod2githubᚗcomᚋsatisfactorymodding return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNNewModpack2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewModpack(ctx context.Context, v any) (NewModpack, error) { + res, err := ec.unmarshalInputNewModpack(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewModpackRelease2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewModpackRelease(ctx context.Context, v any) (NewModpackRelease, error) { + res, err := ec.unmarshalInputNewModpackRelease(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNNewSatisfactoryVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSatisfactoryVersion(ctx context.Context, v any) (NewSatisfactoryVersion, error) { res, err := ec.unmarshalInputNewSatisfactoryVersion(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -27076,6 +31387,11 @@ func (ec *executionContext) unmarshalNUpdateMod2githubᚗcomᚋsatisfactorymoddi return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNUpdateModpack2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateModpack(ctx context.Context, v any) (UpdateModpack, error) { + res, err := ec.unmarshalInputUpdateModpack(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNUpdateSatisfactoryVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSatisfactoryVersion(ctx context.Context, v any) (UpdateSatisfactoryVersion, error) { res, err := ec.unmarshalInputUpdateSatisfactoryVersion(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -27968,6 +32284,116 @@ func (ec *executionContext) marshalOModReference2ᚖstring(ctx context.Context, return res } +func (ec *executionContext) marshalOModpack2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpack(ctx context.Context, sel ast.SelectionSet, v *Modpack) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Modpack(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOModpackFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackFields(ctx context.Context, v any) (*ModpackFields, error) { + if v == nil { + return nil, nil + } + var res = new(ModpackFields) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOModpackFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackFields(ctx context.Context, sel ast.SelectionSet, v *ModpackFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOModpackFilter2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackFilter(ctx context.Context, v any) (*ModpackFilter, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputModpackFilter(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOModpackID2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNModpackID2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOModpackID2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNModpackID2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOModpackID2ᚖstring(ctx context.Context, v any) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOModpackID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + _ = sel + _ = ctx + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) unmarshalOModpackModInput2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInputᚄ(ctx context.Context, v any) ([]*ModpackModInput, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ModpackModInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNModpackModInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackModInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOModpackRelease2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModpackRelease(ctx context.Context, sel ast.SelectionSet, v *ModpackRelease) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ModpackRelease(ctx, sel, v) +} + func (ec *executionContext) unmarshalOOrder2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOrder(ctx context.Context, v any) (*Order, error) { if v == nil { return nil, nil diff --git a/generated/models_gen.go b/generated/models_gen.go index 7656cdf0..6c811054 100644 --- a/generated/models_gen.go +++ b/generated/models_gen.go @@ -47,6 +47,11 @@ type GetGuides struct { Count int `json:"count"` } +type GetModpacks struct { + Modpacks []*Modpack `json:"modpacks"` + Count int `json:"count"` +} + type GetMods struct { Mods []*Mod `json:"mods"` Count int `json:"count"` @@ -136,6 +141,60 @@ type ModVersionConstraint struct { Version string `json:"version"` } +type Modpack struct { + ID string `json:"id"` + Name string `json:"name"` + ShortDescription string `json:"short_description"` + FullDescription string `json:"full_description"` + Logo *string `json:"logo,omitempty"` + LogoThumbhash *string `json:"logo_thumbhash,omitempty"` + CreatorID string `json:"creator_id"` + Creator *User `json:"creator"` + Views int `json:"views"` + Installs int `json:"installs"` + Hotness int `json:"hotness"` + Popularity int `json:"popularity"` + UpdatedAt string `json:"updated_at"` + CreatedAt string `json:"created_at"` + Hidden bool `json:"hidden"` + ParentID *string `json:"parent_id,omitempty"` + Parent *Modpack `json:"parent,omitempty"` + Children []*Modpack `json:"children"` + Tags []*Tag `json:"tags"` + Targets []string `json:"targets"` + Mods []*ModpackModEntry `json:"mods"` + Releases []*ModpackRelease `json:"releases"` +} + +type ModpackFilter struct { + Limit *int `json:"limit,omitempty"` + Offset *int `json:"offset,omitempty"` + OrderBy *ModpackFields `json:"order_by,omitempty"` + Order *Order `json:"order,omitempty"` + Search *string `json:"search,omitempty"` + Ids []string `json:"ids,omitempty"` + Hidden *bool `json:"hidden,omitempty"` + TagIDs []string `json:"tagIDs,omitempty"` +} + +type ModpackModEntry struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` +} + +type ModpackModInput struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` +} + +type ModpackRelease struct { + ID string `json:"id"` + Version string `json:"version"` + CreatedAt string `json:"created_at"` + Lockfile string `json:"lockfile"` + Changelog string `json:"changelog"` +} + type Mutation struct { } @@ -151,6 +210,23 @@ type NewGuide struct { TagIDs []string `json:"tagIDs,omitempty"` } +type NewModpack struct { + Name string `json:"name"` + ShortDescription string `json:"short_description"` + FullDescription *string `json:"full_description,omitempty"` + Logo *graphql.Upload `json:"logo,omitempty"` + Hidden *bool `json:"hidden,omitempty"` + TagIDs []string `json:"tagIDs,omitempty"` + Targets []string `json:"targets"` + Mods []*ModpackModInput `json:"mods"` + ParentID *string `json:"parent_id,omitempty"` +} + +type NewModpackRelease struct { + Version string `json:"version"` + Changelog string `json:"changelog"` +} + type NewSatisfactoryVersion struct { Version int `json:"version"` EngineVersion string `json:"engine_version"` @@ -228,6 +304,17 @@ type UpdateGuide struct { TagIDs []string `json:"tagIDs,omitempty"` } +type UpdateModpack struct { + Name *string `json:"name,omitempty"` + ShortDescription *string `json:"short_description,omitempty"` + FullDescription *string `json:"full_description,omitempty"` + Logo *graphql.Upload `json:"logo,omitempty"` + Hidden *bool `json:"hidden,omitempty"` + TagIDs []string `json:"tagIDs,omitempty"` + Targets []string `json:"targets,omitempty"` + Mods []*ModpackModInput `json:"mods,omitempty"` +} + type UpdateSatisfactoryVersion struct { Version *int `json:"version,omitempty"` EngineVersion *string `json:"engine_version,omitempty"` @@ -583,6 +670,73 @@ func (e ModFields) MarshalJSON() ([]byte, error) { return buf.Bytes(), nil } +type ModpackFields string + +const ( + ModpackFieldsCreatedAt ModpackFields = "created_at" + ModpackFieldsUpdatedAt ModpackFields = "updated_at" + ModpackFieldsName ModpackFields = "name" + ModpackFieldsViews ModpackFields = "views" + ModpackFieldsInstalls ModpackFields = "installs" + ModpackFieldsHotness ModpackFields = "hotness" + ModpackFieldsPopularity ModpackFields = "popularity" + ModpackFieldsSearch ModpackFields = "search" +) + +var AllModpackFields = []ModpackFields{ + ModpackFieldsCreatedAt, + ModpackFieldsUpdatedAt, + ModpackFieldsName, + ModpackFieldsViews, + ModpackFieldsInstalls, + ModpackFieldsHotness, + ModpackFieldsPopularity, + ModpackFieldsSearch, +} + +func (e ModpackFields) IsValid() bool { + switch e { + case ModpackFieldsCreatedAt, ModpackFieldsUpdatedAt, ModpackFieldsName, ModpackFieldsViews, ModpackFieldsInstalls, ModpackFieldsHotness, ModpackFieldsPopularity, ModpackFieldsSearch: + return true + } + return false +} + +func (e ModpackFields) String() string { + return string(e) +} + +func (e *ModpackFields) UnmarshalGQL(v any) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ModpackFields(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ModpackFields", str) + } + return nil +} + +func (e ModpackFields) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +func (e *ModpackFields) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e ModpackFields) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type Order string const ( diff --git a/go.mod b/go.mod index 590a743e..76a5518d 100755 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( github.com/ravilushqa/otelgqlgen v0.18.0 github.com/russross/blackfriday/v2 v2.1.0 github.com/samber/slog-multi v1.4.0 + github.com/satisfactorymodding/ficsit-resolver v0.0.6 github.com/spf13/viper v1.20.1 github.com/swaggo/echo-swagger v1.4.1 github.com/swaggo/swag v1.16.4 @@ -159,12 +160,14 @@ require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/mircearoata/pubgrub-go v0.3.3 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/mitchellh/hashstructure v1.1.0 // indirect github.com/nexus-rpc/sdk-go v0.4.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/pterm/pterm v0.12.81 // indirect + github.com/puzpuzpuz/xsync/v3 v3.0.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/robfig/cron v1.2.0 // indirect github.com/sagikazarmark/locafero v0.9.0 // indirect diff --git a/go.sum b/go.sum index 9cab2517..99645f9c 100644 --- a/go.sum +++ b/go.sum @@ -394,6 +394,8 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= +github.com/mircearoata/pubgrub-go v0.3.3 h1:XGwL8Xh5GX+mbnvWItbM/lVJxAq3NZtfUtbJ/hUf2ig= +github.com/mircearoata/pubgrub-go v0.3.3/go.mod h1:9oWL9ZXdjFYvnGl95qiM1dTciFNx1MN8fUnG3SUwDi8= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0= @@ -454,6 +456,8 @@ github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5b github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s= github.com/pterm/pterm v0.12.81 h1:ju+j5I2++FO1jBKMmscgh5h5DPFDFMB7epEjSoKehKA= github.com/pterm/pterm v0.12.81/go.mod h1:TyuyrPjnxfwP+ccJdBTeWHtd/e0ybQHkOS/TakajZCw= +github.com/puzpuzpuz/xsync/v3 v3.0.2 h1:3yESHrRFYr6xzkz61LLkvNiPFXxJEAABanTQpKbAaew= +github.com/puzpuzpuz/xsync/v3 v3.0.2/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/ravilushqa/otelgqlgen v0.18.0 h1:nkIiKeho8rZYIk7mmMixyA8xA+1f5iSgTlZc6WBKlgQ= github.com/ravilushqa/otelgqlgen v0.18.0/go.mod h1:ebH89mbrQz6UOe/05zSS6d4oYsFgcP6692OkbkH8A9g= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -471,6 +475,8 @@ github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI= github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0= github.com/samber/slog-multi v1.4.0 h1:pwlPMIE7PrbTHQyKWDU+RIoxP1+HKTNOujk3/kdkbdg= github.com/samber/slog-multi v1.4.0/go.mod h1:FsQ4Uv2L+E/8TZt+/BVgYZ1LoDWCbfCU21wVIoMMrO8= +github.com/satisfactorymodding/ficsit-resolver v0.0.6 h1:4iCIHOg3z+AvwSVeWtu+k9aysLOL9+FIszCbiKOG2oo= +github.com/satisfactorymodding/ficsit-resolver v0.0.6/go.mod h1:ckKMmMvDoYbbkEbWXEsMes608uvv6EKphXPhHX8LKSc= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw= github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= diff --git a/gql/directive.go b/gql/directive.go index c3954c7c..f19cfa6f 100644 --- a/gql/directive.go +++ b/gql/directive.go @@ -27,6 +27,7 @@ func MakeDirective() generated.DirectiveRoot { CanManageTags: canManageTags, CanEditModCompatibility: canEditModCompatibility, CanEditSatisfactoryVersions: canEditSatisfactoryVersions, + CanEditModpack: canEditModpack, } } @@ -248,3 +249,25 @@ func canManageTags(ctx context.Context, _ interface{}, next graphql.Resolver) (i return nil, errors.New("user not authorized to perform this action") } + +func canEditModpack(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + g, err := db.From(ctx).Modpack.Get(ctx, getArgument(ctx, field).(string)) + if err != nil { + return nil, err + } + + if g.CreatorID == user.ID { + return next(ctx) + } + + if db.UserHas(ctx, auth.RoleEditAnyContent, user) { + return next(ctx) + } + + return nil, errors.New("user not authorized to perform this action") +} diff --git a/gql/resolver.go b/gql/resolver.go index cf74e482..f2150689 100755 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -74,6 +74,14 @@ func (r *Resolver) VersionDependency() generated.VersionDependencyResolver { return &versionDependencyResolver{r} } +func (r *Resolver) GetModpacks() generated.GetModpacksResolver { + return &getModpacksResolver{r} +} + +func (r *Resolver) Modpack() generated.ModpackResolver { + return &modpackResolver{r} +} + type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } diff --git a/gql/resolver_modpacks.go b/gql/resolver_modpacks.go new file mode 100644 index 00000000..d2e0ff7b --- /dev/null +++ b/gql/resolver_modpacks.go @@ -0,0 +1,543 @@ +package gql + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "log/slog" + "maps" + "math" + "slices" + "time" + + "github.com/99designs/gqlgen/graphql" + "github.com/Vilsol/slox" + "github.com/go-playground/validator/v10" + resolver "github.com/satisfactorymodding/ficsit-resolver" + + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/models" + "github.com/satisfactorymodding/smr-api/redis" + "github.com/satisfactorymodding/smr-api/storage" + "github.com/satisfactorymodding/smr-api/util" + "github.com/satisfactorymodding/smr-api/util/converter" +) + +func (r *queryResolver) GetModpack(ctx context.Context, modpackID string) (*generated.Modpack, error) { + dbModpack, err := db.From(ctx).Modpack.Query(). + Where(modpack.ID(modpackID)). + WithTags(). + WithTargets(). + WithReleases(). + WithMods(). + WithParent(). + WithChildren(). + First(ctx) + if err != nil { + return nil, err + } + + if dbModpack == nil { + return nil, nil + } + + if redis.CanIncrement(RealIP(ctx), "view", "modpack:"+modpackID, time.Hour*4) { + if err := dbModpack.Update().AddViews(1).Exec(ctx); err != nil { + return nil, err + } + } + + return (*conv.ModpackImpl)(nil).Convert(dbModpack), nil +} + +func (r *queryResolver) GetModpacks(_ context.Context, _ *generated.ModpackFilter) (*generated.GetModpacks, error) { + return &generated.GetModpacks{}, nil +} + +func (r *mutationResolver) CreateModpack(ctx context.Context, newModpack generated.NewModpack) (*generated.Modpack, error) { + val := ctx.Value(util.ContextValidator{}).(*validator.Validate) + if err := val.Struct(&newModpack); err != nil { + return nil, fmt.Errorf("validation failed: %w", err) + } + + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + if newModpack.ParentID != nil { + parent, err := db.From(ctx).Modpack.Query(). + Where(modpack.ID(*newModpack.ParentID)). + First(ctx) + if err != nil { + return nil, err + } + + if parent.ParentID != "" { + return nil, fmt.Errorf("cannot create a remix of a remix") + } + } + + var resultModpack *ent.Modpack + + if err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + dbModpack := tx.Modpack.Create(). + SetName(newModpack.Name). + SetShortDescription(newModpack.ShortDescription). + SetCreatorID(user.ID) + + SetINNF(newModpack.FullDescription, dbModpack.SetFullDescription) + SetINNF(newModpack.Hidden, dbModpack.SetHidden) + SetINNF(newModpack.ParentID, dbModpack.SetParentID) + + // Add tags + if len(newModpack.TagIDs) > 0 { + dbModpack = dbModpack.AddTagIDs(newModpack.TagIDs...) + } + + resultModpack, err = dbModpack.Save(ctx) + + // Create targets + for _, target := range newModpack.Targets { + targets, err := tx.ModpackTarget.Create(). + SetModpackID(resultModpack.ID). + SetTargetName(target).Save(ctx) + if err != nil { + return err + } + + dbModpack = dbModpack.AddTargets(targets) + } + + // Create modpack mod relationships + for _, modInput := range newModpack.Mods { + if err := tx.ModpackMod.Create(). + SetModpackID(resultModpack.ID). + SetModID(modInput.ModID). + SetVersionConstraint(modInput.VersionConstraint). + Exec(ctx); err != nil { + return err + } + } + + return err + }, nil); err != nil { + return nil, err + } + + // Handle logo upload + if newModpack.Logo != nil { + file, err := io.ReadAll(newModpack.Logo.File) + if err != nil { + return nil, fmt.Errorf("failed to read logo file: %w", err) + } + + logoData, thumbHash, err := converter.ConvertAnyImageToWebp(ctx, file) + if err != nil { + return nil, fmt.Errorf("failed to convert logo file: %w", err) + } + + logoKey, err := storage.UploadModpackLogo(ctx, resultModpack.ID, bytes.NewReader(logoData)) + if err == nil { + resultModpack, err = resultModpack.Update(). + SetLogo(storage.GenerateDownloadLink(ctx, logoKey)). + SetLogoThumbhash(thumbHash). + Save(ctx) + if err != nil { + return nil, err + } + } + } + + // Get the modpack again with all relationships + resultModpack, err = db.From(ctx).Modpack.Query(). + WithTags(). + WithTargets(). + WithModpackMods(). + WithParent(). + Where(modpack.ID(resultModpack.ID)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackImpl)(nil).Convert(resultModpack), nil +} + +func (r *mutationResolver) UpdateModpack(ctx context.Context, modpackID string, updatedModpack generated.UpdateModpack) (*generated.Modpack, error) { + val := ctx.Value(util.ContextValidator{}).(*validator.Validate) + if err := val.Struct(&updatedModpack); err != nil { + return nil, fmt.Errorf("validation failed: %w", err) + } + + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + dbModpack, err := db.From(ctx).Modpack.Query(). + Where(modpack.ID(modpackID), modpack.CreatorID(user.ID)). + First(ctx) + if err != nil { + return nil, err + } + + update := dbModpack.Update() + SetINNF(updatedModpack.Name, update.SetName) + SetINNF(updatedModpack.ShortDescription, update.SetShortDescription) + SetINNF(updatedModpack.FullDescription, update.SetFullDescription) + SetINNF(updatedModpack.Hidden, update.SetHidden) + + resultModpack, err := update.Save(ctx) + if err != nil { + return nil, err + } + + if updatedModpack.Logo != nil { + file, err := io.ReadAll(updatedModpack.Logo.File) + if err != nil { + return nil, fmt.Errorf("failed to read logo file: %w", err) + } + + logoData, thumbHash, err := converter.ConvertAnyImageToWebp(ctx, file) + if err != nil { + return nil, fmt.Errorf("failed to convert logo file: %w", err) + } + + logoKey, err := storage.UploadModpackLogo(ctx, resultModpack.ID, bytes.NewReader(logoData)) + if err == nil { + resultModpack, err = resultModpack.Update(). + SetLogo(storage.GenerateDownloadLink(ctx, logoKey)). + SetLogoThumbhash(thumbHash). + Save(ctx) + if err != nil { + return nil, err + } + } + } + + if updatedModpack.TagIDs != nil { + if err := resultModpack.Update().ClearTags().AddTagIDs(updatedModpack.TagIDs...).Exec(ctx); err != nil { + return nil, err + } + } + + resultModpack, err = db.From(ctx).Modpack.Query(). + WithTags(). + WithTargets(). + WithMods(). + Where(modpack.ID(resultModpack.ID)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackImpl)(nil).Convert(resultModpack), nil +} + +func (r *mutationResolver) DeleteModpack(ctx context.Context, modpackID string) (bool, error) { + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return false, err + } + + dbModpack, err := db.From(ctx).Modpack.Query(). + Where(modpack.ID(modpackID), modpack.CreatorID(user.ID)). + First(ctx) + if err != nil { + return false, err + } + + if err := db.From(ctx).Modpack.DeleteOne(dbModpack).Exec(ctx); err != nil { + return false, err + } + + return true, nil +} + +func (r *queryResolver) GetModpackRelease(ctx context.Context, modpackID string, version string) (*generated.ModpackRelease, error) { + dbRelease, err := db.From(ctx).ModpackRelease.Query(). + Where(modpackrelease.HasModpackWith(modpack.ID(modpackID)), modpackrelease.Version(version)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackReleaseImpl)(nil).Convert(dbRelease), nil +} + +func (r *mutationResolver) CreateModpackRelease(ctx context.Context, modpackID string, release generated.NewModpackRelease) (*generated.ModpackRelease, error) { + val := ctx.Value(util.ContextValidator{}).(*validator.Validate) + if err := val.Struct(&release); err != nil { + return nil, fmt.Errorf("validation failed: %w", err) + } + + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + dbModpack, err := db.From(ctx).Modpack.Query(). + WithTargets(). + Where(modpack.ID(modpackID), modpack.CreatorID(user.ID)). + First(ctx) + if err != nil { + return nil, err + } + + targetNames := make([]resolver.TargetName, len(dbModpack.Edges.Targets)) + for i, target := range dbModpack.Edges.Targets { + targetNames[i] = resolver.TargetName(target.TargetName) + } + + lockfile, err := resolveModpackToLockfile(ctx, modpackID, targetNames) + if err != nil { + return nil, err + } + + dbRelease := db.From(ctx).ModpackRelease.Create(). + SetModpackID(dbModpack.ID). + SetVersion(release.Version). + SetChangelog(release.Changelog). + SetLockfile(lockfile) + + resultRelease, err := dbRelease.Save(ctx) + if err != nil { + return nil, err + } + + resultRelease, err = db.From(ctx).ModpackRelease.Query(). + Where(modpackrelease.ID(resultRelease.ID)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackReleaseImpl)(nil).Convert(resultRelease), nil +} + +func (r *mutationResolver) DeleteModpackRelease(ctx context.Context, modpackID string, version string) (bool, error) { + user, _, err := db.UserFromGQLContext(ctx) + if err != nil { + return false, err + } + + dbRelease, err := db.From(ctx).ModpackRelease.Query(). + Where( + modpackrelease.HasModpackWith(modpack.ID(modpackID), modpack.CreatorID(user.ID)), + modpackrelease.Version(version), + ). + First(ctx) + if err != nil { + return false, err + } + + if err := db.From(ctx).ModpackRelease.DeleteOne(dbRelease).Exec(ctx); err != nil { + return false, err + } + + return true, nil +} + +func (r *mutationResolver) ResolveModpack(ctx context.Context, modpackID string, targets []string) (*string, error) { + targetNames := make([]resolver.TargetName, len(targets)) + for i, target := range targets { + targetNames[i] = resolver.TargetName(target) + } + + lockfile, err := resolveModpackToLockfile(ctx, modpackID, targetNames) + if err != nil { + return nil, err + } + + return &lockfile, nil +} + +// GetModpacks resolver type +type getModpacksResolver struct{ *Resolver } + +func (r *getModpacksResolver) Modpacks(ctx context.Context, _ *generated.GetModpacks) ([]*generated.Modpack, error) { + resolverContext := graphql.GetFieldContext(ctx) + modpackFilter, err := models.ProcessModpackFilter(resolverContext.Parent.Args["filter"].(*generated.ModpackFilter)) + if err != nil { + return nil, err + } + + query := db.From(ctx).Modpack.Query().WithTags() + query = db.ConvertModpackFilter(query, modpackFilter, false) + + result, err := query.All(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackImpl)(nil).ConvertSlice(result), nil +} + +func (r *getModpacksResolver) Count(ctx context.Context, _ *generated.GetModpacks) (int, error) { + resolverContext := graphql.GetFieldContext(ctx) + modpackFilter, err := models.ProcessModpackFilter(resolverContext.Parent.Args["filter"].(*generated.ModpackFilter)) + if err != nil { + return 0, err + } + + query := db.From(ctx).Modpack.Query().WithTags() + query = db.ConvertModpackFilter(query, modpackFilter, true) + + result, err := query.Count(ctx) + if err != nil { + return 0, err + } + + return result, nil +} + +// GetModpacks resolver type +type modpackResolver struct{ *Resolver } + +func (r *modpackResolver) Children(ctx context.Context, m *generated.Modpack) ([]*generated.Modpack, error) { + packs, err := db.From(ctx).Modpack.Query(). + WithTags(). + WithTargets(). + WithMods(). + Where(modpack.ParentID(m.ID)). + All(ctx) + if err != nil { + return nil, err + } + + return (*conv.ModpackImpl)(nil).ConvertSlice(packs), nil +} + +type lockfileResolver struct { + Context context.Context +} + +func (l lockfileResolver) ModVersionsWithDependencies(_ context.Context, modID string) ([]resolver.ModVersion, error) { + //nolint:contextcheck + slox.Info(l.Context, "resolver looking up mod", slog.String("id", modID)) + + //nolint:contextcheck + all, err := db.From(l.Context).Version.Query(). + WithVersionDependencies(). + WithTargets(). + Where(version.HasModWith(mod.Or(mod.ID(modID), mod.ModReference(modID)))). + All(l.Context) //nolint:contextcheck + if err != nil { + return nil, fmt.Errorf("failed to query versions: %w", err) + } + + result := make([]resolver.ModVersion, len(all)) + for i, v := range all { + dependencies := make([]resolver.Dependency, len(v.Edges.VersionDependencies)) + for j, d := range v.Edges.VersionDependencies { + dependencies[j] = resolver.Dependency{ + ModID: d.ModID, + Condition: d.Condition, + Optional: d.Optional, + } + } + + targets := make([]resolver.Target, len(v.Edges.Targets)) + for j, t := range v.Edges.Targets { + targets[j] = resolver.Target{ + TargetName: resolver.TargetName(t.TargetName), + Link: "/v1/version/" + t.VersionID + "/" + t.TargetName + "/download", + Hash: t.Hash, + Size: t.Size, + } + } + + result[i] = resolver.ModVersion{ + Version: v.Version, + GameVersion: v.GameVersion, + Dependencies: dependencies, + Targets: targets, + RequiredOnRemote: v.RequiredOnRemote, + } + } + + return result, nil +} + +func (l lockfileResolver) GetModName(_ context.Context, modReference string) (*resolver.ModName, error) { + //nolint:contextcheck + slox.Info(l.Context, "resolver looking up mod name", slog.String("reference", modReference)) + + //nolint:contextcheck + m, err := db.From(l.Context).Mod.Query(). + Where(mod.ModReference(modReference)). + Select(mod.FieldID, mod.FieldModReference, mod.FieldName). + First(l.Context) //nolint:contextcheck + if err != nil { + return nil, err + } + + return &resolver.ModName{ + ID: m.ID, + ModReference: m.ModReference, + Name: m.Name, + }, nil +} + +func resolveModpackToLockfile(ctx context.Context, modpackID string, targets []resolver.TargetName) (string, error) { + pack, err := db.From(ctx).Modpack.Query(). + WithModpackMods(). + WithParent(func(query *ent.ModpackQuery) { + query.WithModpackMods() + }). + Where(modpack.ID(modpackID)). + Only(ctx) + if err != nil { + return "", err + } + + constraints := make(map[string]string) + if pack.ParentID != "" { + for _, m := range pack.Edges.Parent.Edges.ModpackMods { + constraints[m.ModID] = m.VersionConstraint + } + } + + for _, m := range pack.Edges.ModpackMods { + constraints[m.ModID] = m.VersionConstraint + } + + modReferences, err := db.From(ctx).Mod.Query(). + Where(mod.IDIn(slices.Collect(maps.Keys(constraints))...)). + Select(mod.FieldID, mod.FieldModReference). + All(ctx) + if err != nil { + return "", err + } + + referenceConstraints := make(map[string]string, len(constraints)) + for _, reference := range modReferences { + referenceConstraints[reference.ModReference] = constraints[reference.ID] + } + + dependencyResolver := resolver.NewDependencyResolver(lockfileResolver{ + Context: ctx, + }) + + lockfile, err := dependencyResolver.ResolveModDependencies(referenceConstraints, nil, math.MaxInt, targets) + if err != nil { + return "", fmt.Errorf("failed to resolve dependencies: %w", err) + } + + b, err := json.Marshal(lockfile) + if err != nil { + return "", fmt.Errorf("failed to marshal lockfile: %w", err) + } + + return string(b), nil +} diff --git a/gqlgen.yml b/gqlgen.yml index 545b7c22..360c81bb 100755 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -176,3 +176,15 @@ models: fields: mod: resolver: true + + GetModpacks: + fields: + modpacks: + resolver: true + count: + resolver: true + + Modpack: + fields: + children: + resolver: true diff --git a/migrations/sql/20250623121418_add_modpacks.down.sql b/migrations/sql/20250623121418_add_modpacks.down.sql new file mode 100644 index 00000000..64f63fb6 --- /dev/null +++ b/migrations/sql/20250623121418_add_modpacks.down.sql @@ -0,0 +1,14 @@ +-- reverse: create index "modpacktarget_modpack_id_target_name" to table: "modpack_targets" +DROP INDEX "modpacktarget_modpack_id_target_name"; +-- reverse: create "modpack_targets" table +DROP TABLE "modpack_targets"; +-- reverse: create "modpack_tags" table +DROP TABLE "modpack_tags"; +-- reverse: create index "modpackrelease_modpack_id_version" to table: "modpack_releases" +DROP INDEX "modpackrelease_modpack_id_version"; +-- reverse: create "modpack_releases" table +DROP TABLE "modpack_releases"; +-- reverse: create "modpack_mods" table +DROP TABLE "modpack_mods"; +-- reverse: create "modpacks" table +DROP TABLE "modpacks"; diff --git a/migrations/sql/20250623121418_add_modpacks.up.sql b/migrations/sql/20250623121418_add_modpacks.up.sql new file mode 100644 index 00000000..d39bc8dd --- /dev/null +++ b/migrations/sql/20250623121418_add_modpacks.up.sql @@ -0,0 +1,66 @@ +-- create "modpacks" table +CREATE TABLE "modpacks" +( + "id" character varying NOT NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "name" character varying NOT NULL, + "short_description" character varying NOT NULL, + "full_description" character varying NOT NULL, + "logo" character varying NULL, + "logo_thumbhash" character varying NULL, + "creator_id" character varying NOT NULL, + "views" bigint NOT NULL DEFAULT 0, + "hotness" bigint NOT NULL DEFAULT 0, + "installs" bigint NOT NULL DEFAULT 0, + "popularity" bigint NOT NULL DEFAULT 0, + "hidden" boolean NOT NULL DEFAULT false, + "parent_id" character varying NULL, + PRIMARY KEY ("id"), + CONSTRAINT "modpacks_modpacks_children" FOREIGN KEY ("parent_id") REFERENCES "modpacks" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT +); +-- create "modpack_mods" table +CREATE TABLE "modpack_mods" +( + "version_constraint" character varying NOT NULL, + "modpack_id" character varying NOT NULL, + "mod_id" character varying NOT NULL, + PRIMARY KEY ("modpack_id", "mod_id"), + CONSTRAINT "modpack_mods_modpacks_modpack" FOREIGN KEY ("modpack_id") REFERENCES "modpacks" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, + CONSTRAINT "modpack_mods_mods_mod" FOREIGN KEY ("mod_id") REFERENCES "mods" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create "modpack_releases" table +CREATE TABLE "modpack_releases" +( + "id" character varying NOT NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "version" character varying NOT NULL, + "changelog" character varying NOT NULL, + "lockfile" character varying NOT NULL, + "modpack_id" character varying NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "modpack_releases_modpacks_releases" FOREIGN KEY ("modpack_id") REFERENCES "modpacks" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create index "modpackrelease_modpack_id_version" to table: "modpack_releases" +CREATE UNIQUE INDEX "modpackrelease_modpack_id_version" ON "modpack_releases" ("modpack_id", "version"); +-- create "modpack_tags" table +CREATE TABLE "modpack_tags" +( + "modpack_id" character varying NOT NULL, + "tag_id" character varying NOT NULL, + PRIMARY KEY ("modpack_id", "tag_id"), + CONSTRAINT "modpack_tags_modpacks_modpack" FOREIGN KEY ("modpack_id") REFERENCES "modpacks" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, + CONSTRAINT "modpack_tags_tags_tag" FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create "modpack_targets" table +CREATE TABLE "modpack_targets" +( + "id" character varying NOT NULL, + "target_name" character varying NOT NULL, + "modpack_id" character varying NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "modpack_targets_modpacks_targets" FOREIGN KEY ("modpack_id") REFERENCES "modpacks" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create index "modpacktarget_modpack_id_target_name" to table: "modpack_targets" +CREATE UNIQUE INDEX "modpacktarget_modpack_id_target_name" ON "modpack_targets" ("modpack_id", "target_name"); diff --git a/migrations/sql/atlas.sum b/migrations/sql/atlas.sum index e9b312c3..67c64e7d 100644 --- a/migrations/sql/atlas.sum +++ b/migrations/sql/atlas.sum @@ -1,4 +1,4 @@ -h1:NVXwUmNMPEOBFBSqgQGuw/OMarJOpSsxkE/8o1qQH3k= +h1:CelcBqJE9oBnByHVAYrd1F8Bi7Ug3sTSbsHKJwcrsTE= 000001_create_initial_tables.down.sql h1:QcXXwE8ir3PM3vZjQfBihY55WiuLYjN8pbbk/L6U+bs= 000001_create_initial_tables.up.sql h1:EfAqETefs7TW9BDVS4ukiB7wUFs+HQzVdc3qHhdAFd4= 000002_create_user_group_table.down.sql h1:uJjRbQ3H7yvPGNXLD5iSPmderEoWhCNGdsqN8yqBIRY= @@ -79,3 +79,5 @@ h1:NVXwUmNMPEOBFBSqgQGuw/OMarJOpSsxkE/8o1qQH3k= 20241003161005_create_virustotal_results_table.up.sql h1:mXMWj998hZ59bbkZYIbbyxU9foptzWuXHnlS2UuY4bY= 20241008092121_nullable_mod_logo.down.sql h1:vKZrz/FqaaQctvzrTR0EvQcyQ6ENWgTbcud7q2/NvnY= 20241008092121_nullable_mod_logo.up.sql h1:7ePponYitScS4NnMP+hRoEAKnvPPpbCHXMxilYzfmD8= +20250623121418_add_modpacks.down.sql h1:s4R0G3LDW8Xx/9kTHRNjmOdBJJNr2ckGjiVESDSmObQ= +20250623121418_add_modpacks.up.sql h1:hEmGQve6Hkef5Wue/98E835JI7C/RaRN/Hl8rmYCJ1c= diff --git a/models/filters.go b/models/filters.go index 2c2886d5..956a3a1d 100644 --- a/models/filters.go +++ b/models/filters.go @@ -221,6 +221,57 @@ func ProcessGuideFilter(filter map[string]interface{}) (*GuideFilter, error) { return base, nil } +type ModpackFilter struct { + Limit *int `json:"limit" validate:"omitempty,min=1,max=100"` + Offset *int `json:"offset" validate:"omitempty,min=0"` + OrderBy *generated.ModpackFields `json:"order_by"` + Order *generated.Order `json:"order"` + Search *string `json:"search" validate:"omitempty,min=3"` + IDs []string `json:"ids" validate:"omitempty,max=100"` + TagIDs []string `json:"tagIDs" validate:"omitempty,max=100"` + Hidden *bool `json:"hidden"` +} + +func (f ModpackFilter) Hash() (string, error) { + hash, err := hashstructure.Hash(f, hashstructure.FormatV2, nil) + if err != nil { + return "", fmt.Errorf("failed to hash ModpackFilter: %w", err) + } + return strconv.FormatUint(hash, 10), nil +} + +func DefaultModpackFilter() *ModpackFilter { + limit := 10 + offset := 0 + order := generated.OrderDesc + orderBy := generated.ModpackFieldsCreatedAt + return &ModpackFilter{ + Limit: &limit, + Offset: &offset, + IDs: nil, + Order: &order, + OrderBy: &orderBy, + } +} + +func ProcessModpackFilter(filter *generated.ModpackFilter) (*ModpackFilter, error) { + base := DefaultModpackFilter() + + if filter == nil { + return base, nil + } + + if err := ApplyChanges(filter, base); err != nil { + return nil, err + } + + if err := dataValidator.Struct(base); err != nil { + return nil, fmt.Errorf("failed to validate ModpackFilter: %w", err) + } + + return base, nil +} + func ProcessSMLVersionFilter(filter map[string]interface{}) (*VersionFilter, error) { base := DefaultVersionFilter() diff --git a/nodes/modpack.go b/nodes/modpack.go new file mode 100644 index 00000000..ea43ab7d --- /dev/null +++ b/nodes/modpack.go @@ -0,0 +1,146 @@ +package nodes + +import ( + "log/slog" + "time" + + "github.com/Vilsol/slox" + "github.com/labstack/echo/v4" + + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/modpack" + "github.com/satisfactorymodding/smr-api/generated/ent/modpackrelease" + "github.com/satisfactorymodding/smr-api/models" + "github.com/satisfactorymodding/smr-api/redis" + "github.com/satisfactorymodding/smr-api/util" +) + +// @Summary Retrieve a list of Modpacks +// @Tags Modpacks +// @Description Retrieve a list of modpacks +// @Accept json +// @Produce json +// @Param limit query int false "How many modpacks to return" +// @Param offset query int false "Offset for list of modpacks to return" +// @Param order_by query string false "Order by field" Enums(created_at, updated_at, name, views, installs, hotness, popularity, search) +// @Param order query string false "Order of results" Enums(asc, desc) +// @Param search query string false "Search string" +// @Param hidden query bool false "Include hidden modpacks" +// @Success 200 {object} GenericResponse{data=[]generated.Modpack} +// @Router /modpacks [get] +func getModpacks(c echo.Context) (interface{}, *ErrorResponse) { + limit := util.GetIntRange(c, "limit", 1, 100, 25) + offset := util.GetIntRange(c, "offset", 0, 9999999, 0) + orderBy := util.OneOf(c, "order_by", []string{"created_at", "updated_at", "name", "views", "installs", "hotness", "popularity", "search"}, "created_at") + order := util.OneOf(c, "order", []string{"asc", "desc"}, "desc") + search := c.QueryParam("search") + hiddenParam := c.QueryParam("hidden") + + modpackFilter := models.DefaultModpackFilter() + modpackFilter.Limit = &limit + modpackFilter.Offset = &offset + + orderByGen := generated.ModpackFields(orderBy) + modpackFilter.OrderBy = &orderByGen + + orderGen := generated.Order(order) + modpackFilter.Order = &orderGen + + if search != "" { + modpackFilter.Search = &search + } + + if hiddenParam != "" { + hidden := hiddenParam == "true" + modpackFilter.Hidden = &hidden + } + + query := db.From(c.Request().Context()).Modpack.Query(). + WithTags(). + WithTargets(). + WithModpackMods() + + query = db.ConvertModpackFilter(query, modpackFilter, false) + + result, err := query.All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed to get modpacks", slog.Any("error", err)) + return nil, GenericUserError(err) + } + + return (*conv.ModpackImpl)(nil).ConvertSlice(result), nil +} + +// @Summary Retrieve a single Modpack +// @Tags Modpacks +// @Description Retrieve a single modpack by ID +// @Accept json +// @Produce json +// @Param modpackId path string true "Modpack ID" +// @Success 200 {object} GenericResponse{data=generated.Modpack} +// @Failure 404 {object} GenericResponse{error=ErrorResponse} +// @Router /modpacks/{modpackId} [get] +func getModpack(c echo.Context) (interface{}, *ErrorResponse) { + modpackID := c.Param("modpackId") + + dbModpack, err := db.From(c.Request().Context()).Modpack.Query(). + Where(modpack.ID(modpackID)). + WithTags(). + WithTargets(). + WithReleases(). + WithModpackMods(). + WithParent(). + WithChildren(). + First(c.Request().Context()) + if err != nil { + if ent.IsNotFound(err) { + return nil, &ErrorModpackNotFound + } + slox.Error(c.Request().Context(), "failed to get modpack", slog.Any("error", err)) + return nil, GenericUserError(err) + } + + if dbModpack == nil { + return nil, &ErrorModpackNotFound + } + + // Increment view count with rate limiting + if redis.CanIncrement(c.RealIP(), "view", "modpack:"+modpackID, time.Hour*4) { + if err := dbModpack.Update().AddViews(1).Exec(c.Request().Context()); err != nil { + slox.Error(c.Request().Context(), "failed to increment modpack views", slog.Any("error", err)) + } + } + + return (*conv.ModpackImpl)(nil).Convert(dbModpack), nil +} + +// @Summary Retrieve a Modpack Release +// @Tags Modpacks +// @Description Retrieve a specific release of a modpack +// @Accept json +// @Produce json +// @Param modpackId path string true "Modpack ID" +// @Param version path string true "Release Version" +// @Success 200 {object} GenericResponse{data=generated.ModpackRelease} +// @Failure 404 {object} GenericResponse{error=ErrorResponse} +// @Router /modpacks/{modpackId}/releases/{version} [get] +func getModpackRelease(c echo.Context) (interface{}, *ErrorResponse) { + modpackID := c.Param("modpackId") + version := c.Param("version") + + dbRelease, err := db.From(c.Request().Context()).ModpackRelease.Query(). + Where(modpackrelease.HasModpackWith(modpack.ID(modpackID)), modpackrelease.Version(version)). + First(c.Request().Context()) + if err != nil { + if ent.IsNotFound(err) { + return nil, &ErrorModpackReleaseNotFound + } + slox.Error(c.Request().Context(), "failed to get modpack release", slog.Any("error", err)) + return nil, GenericUserError(err) + } + + return (*conv.ModpackReleaseImpl)(nil).Convert(dbRelease), nil +} diff --git a/nodes/node_types.go b/nodes/node_types.go index c1a8a5f5..cf311ab9 100755 --- a/nodes/node_types.go +++ b/nodes/node_types.go @@ -23,6 +23,9 @@ var ( ErrorFailedModUpload = ErrorResponse{Code: 201, Message: "failed to upload mod", Status: 500} ErrorVersionNotFound = ErrorResponse{Code: 300, Message: "version not found", Status: 404} + + ErrorModpackNotFound = ErrorResponse{Code: 400, Message: "modpack not found", Status: 404} + ErrorModpackReleaseNotFound = ErrorResponse{Code: 401, Message: "modpack release not found", Status: 404} ) func GenericUserError(err error) *ErrorResponse { diff --git a/nodes/routes.go b/nodes/routes.go index 691baccf..907cd16c 100755 --- a/nodes/routes.go +++ b/nodes/routes.go @@ -56,3 +56,12 @@ func RegisterVersionRoutes(router *echo.Group) { router.GET("/:versionId/:target/download", downloadModTarget) router.HEAD("/:versionId/:target/download", downloadModTarget) } + +func RegisterModpackRoutes(router *echo.Group) { + router.GET("/:modpackId", dataWrapper(getModpack)) + router.GET("/:modpackId/releases/:version", dataWrapper(getModpackRelease)) +} + +func RegisterModpacksRoutes(router *echo.Group) { + router.GET("", dataWrapper(getModpacks)) +} diff --git a/schemas/directives.graphql b/schemas/directives.graphql index 6f0bf0e8..ee3feb3a 100755 --- a/schemas/directives.graphql +++ b/schemas/directives.graphql @@ -6,6 +6,7 @@ directive @canEditVersion(field: String!) on FIELD_DEFINITION directive @canEditUser(field: String!, object: Boolean!) on FIELD_DEFINITION directive @canEditGuide(field: String!) on FIELD_DEFINITION directive @canEditModCompatibility(field: String) on FIELD_DEFINITION +directive @canEditModpack(field: String!) on FIELD_DEFINITION directive @canApproveMods on FIELD_DEFINITION | INPUT_FIELD_DEFINITION directive @canApproveVersions on FIELD_DEFINITION | INPUT_FIELD_DEFINITION diff --git a/schemas/modpack.graphql b/schemas/modpack.graphql new file mode 100755 index 00000000..66aef640 --- /dev/null +++ b/schemas/modpack.graphql @@ -0,0 +1,125 @@ +### Types + +scalar ModpackID + +enum ModpackFields { + created_at + updated_at + name + views + installs + hotness + popularity + search +} + +type Modpack { + id: ModpackID! + name: String! + short_description: String! + full_description: String! + logo: String + logo_thumbhash: String + creator_id: UserID! + creator: User! + views: Int! + installs: Int! + hotness: Int! + popularity: Int! + updated_at: Date! + created_at: Date! + hidden: Boolean! + parent_id: ModpackID + + parent: Modpack + children: [Modpack!]! + tags: [Tag!]! + targets: [String!]! + mods: [ModpackModEntry!]! + releases: [ModpackRelease!]! +} + +type ModpackModEntry { + mod_id: ModID! + version_constraint: String! +} + +type ModpackRelease { + id: String! + version: String! + created_at: Date! + lockfile: String! + changelog: String! +} + +type GetModpacks { + modpacks: [Modpack!]! + count: Int! +} + +### Inputs + +input ModpackFilter { + limit: Int + offset: Int + order_by: ModpackFields + order: Order + search: String + ids: [ModpackID!] + hidden: Boolean + tagIDs: [TagID!] +} + +input NewModpack { + name: String! + short_description: String! + full_description: String + logo: Upload + hidden: Boolean + tagIDs: [TagID!] + targets: [String!]! + mods: [ModpackModInput!]! + parent_id: ModpackID +} + +input ModpackModInput { + mod_id: String! + version_constraint: String! +} + +input UpdateModpack { + name: String + short_description: String + full_description: String + logo: Upload + hidden: Boolean + tagIDs: [TagID!] + targets: [String!] + mods: [ModpackModInput!] +} + +input NewModpackRelease { + version: String! + changelog: String! +} + +### Queries + +extend type Query { + getModpack(modpackID: ModpackID!): Modpack + getModpacks(filter: ModpackFilter): GetModpacks! + + getModpackRelease(modpackID: ModpackID!, version: String!): ModpackRelease +} + +### Mutations + +extend type Mutation { + createModpack(modpack: NewModpack!): Modpack @isLoggedIn + updateModpack(modpackID: ModpackID!, modpack: UpdateModpack!): Modpack! @canEditModpack(field: "modpackID") @isLoggedIn + deleteModpack(modpackID: ModpackID!): Boolean! @canEditModpack(field: "modpackID") @isLoggedIn + + createModpackRelease(modpackID: ModpackID!, release: NewModpackRelease!): ModpackRelease! @canEditModpack(field: "modpackID") @isLoggedIn + deleteModpackRelease(modpackID: ModpackID!, version: String!): Boolean! @canEditModpack(field: "modpackID") @isLoggedIn + resolveModpack(modpackID: ModpackID!, targets: [String!]!): String @canEditModpack(field: "modpackID") @isLoggedIn +} diff --git a/storage/storage.go b/storage/storage.go index 71794f26..40b3fc3d 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -174,6 +174,18 @@ func UploadModLogo(ctx context.Context, modID string, data io.ReadSeeker) (strin return key, nil } +func UploadModpackLogo(ctx context.Context, modID string, data io.ReadSeeker) (string, error) { + key := fmt.Sprintf("/images/modpacks/%s/logo.webp", modID) + + key, err := Client(ctx).Put(ctx, key, data) + if err != nil { + slox.Error(ctx, "failed to upload modpack logo", slog.Any("err", err)) + return "", fmt.Errorf("failed to upload modpack logo: %w", err) + } + + return key, nil +} + func UploadUserAvatar(ctx context.Context, userID string, data io.ReadSeeker) (string, error) { key := fmt.Sprintf("/images/users/%s/avatar.webp", userID) diff --git a/tests/modpack_db_test.go b/tests/modpack_db_test.go new file mode 100644 index 00000000..af3d6dd7 --- /dev/null +++ b/tests/modpack_db_test.go @@ -0,0 +1,480 @@ +package tests + +import ( + "strconv" + "testing" + + "github.com/MarvinJWendt/testza" + + "github.com/satisfactorymodding/smr-api/config" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated" +) + +func init() { + config.SetConfigDir("../") + db.EnableDebug() +} + +func TestModpackDB(t *testing.T) { + ctx, _, stop := setup() + defer stop() + + _, userID, err := makeUser(ctx) + testza.AssertNoError(t, err) + + testza.AssertNoError(t, db.From(ctx).Mod.Create(). + SetName("Fluffy Unicorns"). + SetModReference("FluffyUnicorns"). + SetShortDescription("A"). + SetFullDescription("B"). + SetLogo("C"). + SetCreatorID(userID). + Exec(ctx)) + + testza.AssertNoError(t, db.From(ctx).Mod.Create(). + SetName("Death Skulls"). + SetModReference("DeathSkulls"). + SetShortDescription("A"). + SetFullDescription("B"). + SetLogo("C"). + SetCreatorID(userID). + Exec(ctx)) + + testza.AssertNoError(t, db.From(ctx).Modpack.Create(). + SetName("Mega Pack"). + SetShortDescription("A"). + SetFullDescription("B"). + SetLogo("C"). + SetCreatorID(userID). + Exec(ctx)) +} + +func TestModpacks(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + token, userID, err := makeUser(ctx) + testza.AssertNoError(t, err) + + // Second user for testing permissions + _, _, err = makeUser(ctx) + testza.AssertNoError(t, err) + + tags := seedTags(ctx, t, token, client) + mods := seedMods(ctx, t, token, client, tags[0]) + + // Run twice to detect any cache issues + for i := range 2 { + t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { + var objID string + var releaseID string + + t.Run("Create", func(t *testing.T) { + createRequest := authRequest(`mutation ($name: String!, $shortDescription: String!, $fullDescription: String!, $tags: [TagID!], $targets: [String!]!, $mods: [ModpackModInput!]!) { + createModpack(modpack: { + name: $name, + short_description: $shortDescription, + full_description: $fullDescription, + tagIDs: $tags, + targets: $targets, + mods: $mods + }) { + id + name + short_description + full_description + creator_id + hidden + tags { + id + name + } + targets + mods { + mod_id + version_constraint + } + } + }`, token) + createRequest.Var("name", "Test Modpack "+strconv.Itoa(i)) + createRequest.Var("shortDescription", "A test modpack for testing purposes") + createRequest.Var("fullDescription", "This is a comprehensive test modpack that includes multiple mods for testing the modpack functionality.") + createRequest.Var("tags", tags) + createRequest.Var("targets", []string{"Windows", "LinuxServer"}) + createRequest.Var("mods", []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: mods[0], VersionConstraint: ">=1.0.0"}, + {ModID: mods[1], VersionConstraint: "^2.0.0"}, + }) + + var createResponse struct { + CreateModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateModpack.ID) + testza.AssertEqual(t, "Test Modpack "+strconv.Itoa(i), createResponse.CreateModpack.Name) + testza.AssertEqual(t, "A test modpack for testing purposes", createResponse.CreateModpack.ShortDescription) + testza.AssertEqual(t, userID, createResponse.CreateModpack.CreatorID) + testza.AssertFalse(t, createResponse.CreateModpack.Hidden) + testza.AssertEqual(t, 2, len(createResponse.CreateModpack.Tags)) + testza.AssertEqual(t, 2, len(createResponse.CreateModpack.Targets)) + testza.AssertEqual(t, 2, len(createResponse.CreateModpack.Mods)) + + objID = createResponse.CreateModpack.ID + }) + + t.Run("Query One", func(t *testing.T) { + queryRequest := authRequest(`query ($id: ModpackID!) { + getModpack(modpackID: $id) { + id + name + short_description + full_description + logo + creator_id + views + installs + hotness + popularity + hidden + tags { + id + name + } + targets + mods { + mod_id + version_constraint + } + releases { + id + version + } + parent { + id + name + } + children { + id + name + } + } + }`, token) + queryRequest.Var("id", objID) + + var queryResponse struct { + GetModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + testza.AssertEqual(t, objID, queryResponse.GetModpack.ID) + testza.AssertEqual(t, "Test Modpack "+strconv.Itoa(i), queryResponse.GetModpack.Name) + testza.AssertEqual(t, "A test modpack for testing purposes", queryResponse.GetModpack.ShortDescription) + testza.AssertEqual(t, userID, queryResponse.GetModpack.CreatorID) + testza.AssertFalse(t, queryResponse.GetModpack.Hidden) + }) + + t.Run("Update", func(t *testing.T) { + updateRequest := authRequest(`mutation ($id: ModpackID!, $name: String, $shortDescription: String, $fullDescription: String, $hidden: Boolean, $tags: [TagID!]) { + updateModpack(modpackID: $id, modpack: { + name: $name, + short_description: $shortDescription, + full_description: $fullDescription, + hidden: $hidden, + tagIDs: $tags + }) { + id + name + short_description + full_description + hidden + tags { + id + name + } + } + }`, token) + updateRequest.Var("id", objID) + updateRequest.Var("name", "Updated Modpack "+strconv.Itoa(i)) + updateRequest.Var("shortDescription", "Updated description") + updateRequest.Var("fullDescription", "Updated full description with more details.") + updateRequest.Var("hidden", false) + updateRequest.Var("tags", []string{tags[0]}) // Only first tag + + var updateResponse struct { + UpdateModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, updateRequest, &updateResponse)) + testza.AssertEqual(t, objID, updateResponse.UpdateModpack.ID) + testza.AssertEqual(t, "Updated Modpack "+strconv.Itoa(i), updateResponse.UpdateModpack.Name) + testza.AssertEqual(t, "Updated description", updateResponse.UpdateModpack.ShortDescription) + testza.AssertFalse(t, updateResponse.UpdateModpack.Hidden) + testza.AssertEqual(t, 1, len(updateResponse.UpdateModpack.Tags)) + }) + + t.Run("Create Release", func(t *testing.T) { + createReleaseRequest := authRequest(`mutation ($modpackID: ModpackID!, $version: String!, $changelog: String!) { + createModpackRelease(modpackID: $modpackID, release: { + version: $version, + changelog: $changelog + }) { + id + version + changelog + lockfile + } + }`, token) + createReleaseRequest.Var("modpackID", objID) + createReleaseRequest.Var("version", "1.0."+strconv.Itoa(i)) + createReleaseRequest.Var("changelog", "Initial release for testing") + + var createReleaseResponse struct { + CreateModpackRelease generated.ModpackRelease + } + testza.AssertNoError(t, client.Run(ctx, createReleaseRequest, &createReleaseResponse)) + testza.AssertNotEqual(t, "", createReleaseResponse.CreateModpackRelease.ID) + testza.AssertEqual(t, "1.0."+strconv.Itoa(i), createReleaseResponse.CreateModpackRelease.Version) + testza.AssertEqual(t, "Initial release for testing", createReleaseResponse.CreateModpackRelease.Changelog) + testza.AssertNotEqual(t, "", createReleaseResponse.CreateModpackRelease.Lockfile) + + releaseID = createReleaseResponse.CreateModpackRelease.ID + }) + + t.Run("Query Release", func(t *testing.T) { + queryReleaseRequest := authRequest(`query ($modpackID: ModpackID!, $version: String!) { + getModpackRelease(modpackID: $modpackID, version: $version) { + id + version + changelog + lockfile + } + }`, token) + queryReleaseRequest.Var("modpackID", objID) + queryReleaseRequest.Var("version", "1.0."+strconv.Itoa(i)) + + var queryReleaseResponse struct { + GetModpackRelease generated.ModpackRelease + } + testza.AssertNoError(t, client.Run(ctx, queryReleaseRequest, &queryReleaseResponse)) + testza.AssertEqual(t, releaseID, queryReleaseResponse.GetModpackRelease.ID) + testza.AssertEqual(t, "1.0."+strconv.Itoa(i), queryReleaseResponse.GetModpackRelease.Version) + testza.AssertEqual(t, "Initial release for testing", queryReleaseResponse.GetModpackRelease.Changelog) + }) + + t.Run("Resolve Modpack", func(t *testing.T) { + resolveRequest := authRequest(`mutation ($modpackID: ModpackID!, $targets: [String!]!) { + resolveModpack(modpackID: $modpackID, targets: $targets) + }`, token) + resolveRequest.Var("modpackID", objID) + resolveRequest.Var("targets", []string{"Windows"}) + + var resolveResponse struct { + ResolveModpack *string + } + testza.AssertNoError(t, client.Run(ctx, resolveRequest, &resolveResponse)) + testza.AssertNotNil(t, resolveResponse.ResolveModpack) + testza.AssertNotEqual(t, "", *resolveResponse.ResolveModpack) + }) + + if i == 0 { + t.Run("Delete Release", func(t *testing.T) { + deleteReleaseRequest := authRequest(`mutation ($modpackID: ModpackID!, $version: String!) { + deleteModpackRelease(modpackID: $modpackID, version: $version) + }`, token) + deleteReleaseRequest.Var("modpackID", objID) + deleteReleaseRequest.Var("version", "1.0.0") + + var deleteReleaseResponse struct { + DeleteModpackRelease bool + } + testza.AssertNoError(t, client.Run(ctx, deleteReleaseRequest, &deleteReleaseResponse)) + testza.AssertTrue(t, deleteReleaseResponse.DeleteModpackRelease) + }) + + t.Run("Delete", func(t *testing.T) { + deleteRequest := authRequest(`mutation ($id: ModpackID!) { + deleteModpack(modpackID: $id) + }`, token) + deleteRequest.Var("id", objID) + + var deleteResponse struct { + DeleteModpack bool + } + testza.AssertNoError(t, client.Run(ctx, deleteRequest, &deleteResponse)) + testza.AssertTrue(t, deleteResponse.DeleteModpack) + }) + } + }) + } + + t.Run("Query Many", func(t *testing.T) { + queryRequest := authRequest(`query { + getModpacks(filter: {order: asc, order_by: created_at}) { + count + modpacks { + id + name + short_description + full_description + creator_id + hidden + tags { + id + name + } + } + } + }`, token) + + var queryResponse struct { + GetModpacks generated.GetModpacks + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + testza.AssertEqual(t, 1, queryResponse.GetModpacks.Count) // Only one left after deletion + testza.AssertEqual(t, 1, len(queryResponse.GetModpacks.Modpacks)) + testza.AssertEqual(t, "Updated Modpack 1", queryResponse.GetModpacks.Modpacks[0].Name) + }) +} + +func TestModpackRemix(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + token, _, err := makeUser(ctx) + testza.AssertNoError(t, err) + + tags := seedTags(ctx, t, token, client) + mods := seedMods(ctx, t, token, client, tags[0]) + + // Create parent modpack + createParentRequest := authRequest(`mutation ($name: String!, $shortDescription: String!, $fullDescription: String!, $tags: [TagID!], $targets: [String!]!, $mods: [ModpackModInput!]!) { + createModpack(modpack: { + name: $name, + short_description: $shortDescription, + full_description: $fullDescription, + tagIDs: $tags, + targets: $targets, + mods: $mods + }) { + id + name + } + }`, token) + createParentRequest.Var("name", "Parent Modpack") + createParentRequest.Var("shortDescription", "Original modpack") + createParentRequest.Var("fullDescription", "This is the original modpack.") + createParentRequest.Var("tags", tags) + createParentRequest.Var("targets", []string{"Windows"}) + createParentRequest.Var("mods", []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: mods[0], VersionConstraint: ">=1.0.0"}, + }) + + var createParentResponse struct { + CreateModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, createParentRequest, &createParentResponse)) + parentID := createParentResponse.CreateModpack.ID + + // Create child modpack (remix) + createChildRequest := authRequest(`mutation ($name: String!, $shortDescription: String!, $fullDescription: String!, $parentID: ModpackID!, $tags: [TagID!], $targets: [String!]!, $mods: [ModpackModInput!]!) { + createModpack(modpack: { + name: $name, + short_description: $shortDescription, + full_description: $fullDescription, + parent_id: $parentID, + tagIDs: $tags, + targets: $targets, + mods: $mods + }) { + id + name + parent { + id + name + } + } + }`, token) + createChildRequest.Var("name", "Child Modpack") + createChildRequest.Var("shortDescription", "Remix of original") + createChildRequest.Var("fullDescription", "This is a remix of the original modpack.") + createChildRequest.Var("parentID", parentID) + createChildRequest.Var("tags", tags) + createChildRequest.Var("targets", []string{"Windows"}) + createChildRequest.Var("mods", []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: mods[1], VersionConstraint: "^2.0.0"}, + }) + + var createChildResponse struct { + CreateModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, createChildRequest, &createChildResponse)) + + testza.AssertNotEqual(t, "", createChildResponse.CreateModpack.ID) + testza.AssertEqual(t, "Child Modpack", createChildResponse.CreateModpack.Name) + testza.AssertNotNil(t, createChildResponse.CreateModpack.Parent) + testza.AssertEqual(t, parentID, createChildResponse.CreateModpack.Parent.ID) + testza.AssertEqual(t, "Parent Modpack", createChildResponse.CreateModpack.Parent.Name) + + // Try to create a remix of a remix (should fail) + createGrandchildRequest := authRequest(`mutation ($name: String!, $shortDescription: String!, $fullDescription: String!, $parentID: ModpackID!, $tags: [TagID!], $targets: [String!]!, $mods: [ModpackModInput!]!) { + createModpack(modpack: { + name: $name, + short_description: $shortDescription, + full_description: $fullDescription, + parent_id: $parentID, + tagIDs: $tags, + targets: $targets, + mods: $mods + }) { + id + } + }`, token) + createGrandchildRequest.Var("name", "Grandchild Modpack") + createGrandchildRequest.Var("shortDescription", "Remix of remix") + createGrandchildRequest.Var("fullDescription", "This should fail.") + createGrandchildRequest.Var("parentID", createChildResponse.CreateModpack.ID) + createGrandchildRequest.Var("tags", tags) + createGrandchildRequest.Var("targets", []string{"Windows"}) + createGrandchildRequest.Var("mods", []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: mods[0], VersionConstraint: ">=1.0.0"}, + }) + + var createGrandchildResponse struct { + CreateModpack generated.Modpack + } + err = client.Run(ctx, createGrandchildRequest, &createGrandchildResponse) + testza.AssertNotNil(t, err) + testza.AssertContains(t, err.Error(), "cannot create a remix of a remix") + + // Query parent to see children + queryParentRequest := authRequest(`query ($id: ModpackID!) { + getModpack(modpackID: $id) { + id + name + children { + id + name + } + } + }`, token) + queryParentRequest.Var("id", parentID) + + var queryParentResponse struct { + GetModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, queryParentRequest, &queryParentResponse)) + testza.AssertEqual(t, parentID, queryParentResponse.GetModpack.ID) + testza.AssertEqual(t, 1, len(queryParentResponse.GetModpack.Children)) + testza.AssertEqual(t, "Child Modpack", queryParentResponse.GetModpack.Children[0].Name) +} diff --git a/tests/modpack_rest_test.go b/tests/modpack_rest_test.go new file mode 100644 index 00000000..6ac9c8a4 --- /dev/null +++ b/tests/modpack_rest_test.go @@ -0,0 +1,347 @@ +package tests + +import ( + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "testing" + + "github.com/MarvinJWendt/testza" + "github.com/labstack/echo/v4" + + "github.com/satisfactorymodding/smr-api/config" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/nodes" +) + +func init() { + config.SetConfigDir("../") + db.EnableDebug() +} + +func setupEcho() *echo.Echo { + e := echo.New() + v1 := e.Group("/v1") + nodes.RegisterModpackRoutes(v1.Group("/modpack")) + nodes.RegisterModpacksRoutes(v1.Group("/modpacks")) + return e +} + +func TestModpacksRESTEndpoints(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + e := setupEcho() + + token, _, err := makeUser(ctx) + testza.AssertNoError(t, err) + + tags := seedTags(ctx, t, token, client) + mods := seedMods(ctx, t, token, client, tags[0]) + modpacks := seedModpacks(ctx, t, token, client, tags, mods) + + t.Run("GET /v1/modpacks - List modpacks", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + testza.AssertNil(t, response.Error) + + modpacksData, ok := response.Data.([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 2, len(modpacksData)) + }) + + t.Run("GET /v1/modpacks - List modpacks with hidden=true", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?hidden=true", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + + modpacksData, ok := response.Data.([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 3, len(modpacksData)) + }) + + t.Run("GET /v1/modpacks - List modpacks with search", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?search=Ultimate", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + + modpacksData, ok := response.Data.([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 1, len(modpacksData)) + }) + + t.Run("GET /v1/modpacks - List modpacks with pagination", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?limit=1&offset=0&hidden=true", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + + modpacksData, ok := response.Data.([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 1, len(modpacksData)) + }) + + t.Run("GET /v1/modpacks - List modpacks with ordering", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?order_by=name&order=asc&hidden=true", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + + modpacksData, ok := response.Data.([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 3, len(modpacksData)) + + firstModpack := modpacksData[0].(map[string]interface{}) + testza.AssertEqual(t, "Advanced Engineering", firstModpack["name"]) + }) + + t.Run("GET /v1/modpack/:id - Get existing modpack", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s", modpacks[0]), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + testza.AssertNil(t, response.Error) + + modpackData, ok := response.Data.(map[string]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, "Ultimate Factory Pack", modpackData["name"]) + testza.AssertEqual(t, modpacks[0], modpackData["id"]) + + tags, ok := modpackData["tags"].([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertTrue(t, len(tags) > 0) + + targets, ok := modpackData["targets"].([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 3, len(targets)) + + mods, ok := modpackData["mods"].([]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, 3, len(mods)) + }) + + t.Run("GET /v1/modpack/:id - Get non-existent modpack", func(t *testing.T) { + nonExistentID := "non-existent-id" + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s", nonExistentID), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusNotFound, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertFalse(t, response.Success) + testza.AssertNil(t, response.Data) + + errorData, ok := response.Error.(map[string]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, "modpack not found", errorData["message"]) + testza.AssertEqual(t, float64(400), errorData["code"]) + }) + + t.Run("GET /v1/modpack/:id/releases/:version - Get existing release", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s/releases/1.0.0", modpacks[0]), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + testza.AssertNil(t, response.Error) + + releaseData, ok := response.Data.(map[string]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, "1.0.0", releaseData["version"]) + testza.AssertNotNil(t, releaseData["lockfile"]) + }) + + t.Run("GET /v1/modpack/:id/releases/:version - Get non-existent release", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s/releases/999.0.0", modpacks[0]), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusNotFound, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertFalse(t, response.Success) + testza.AssertNil(t, response.Data) + + errorData, ok := response.Error.(map[string]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, "modpack release not found", errorData["message"]) + testza.AssertEqual(t, float64(401), errorData["code"]) + }) + + t.Run("GET /v1/modpack/:id/releases/:version - Release for non-existent modpack", func(t *testing.T) { + nonExistentID := "non-existent-modpack" + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s/releases/1.0.0", nonExistentID), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusNotFound, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertFalse(t, response.Success) + testza.AssertNil(t, response.Data) + + errorData, ok := response.Error.(map[string]interface{}) + testza.AssertTrue(t, ok) + testza.AssertEqual(t, "modpack release not found", errorData["message"]) + }) +} + +func TestModpackRESTValidation(t *testing.T) { + ctx, _, stop := setup() + defer stop() + + e := setupEcho() + + t.Run("GET /v1/modpacks - Invalid query parameters", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?limit=1000", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + req = httptest.NewRequest(http.MethodGet, "/v1/modpacks?order_by=invalid_field", nil) + req = req.WithContext(ctx) + rec = httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + req = httptest.NewRequest(http.MethodGet, "/v1/modpacks?order=invalid_order", nil) + req = req.WithContext(ctx) + rec = httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + }) +} + +func TestModpackRESTEdgeCases(t *testing.T) { + ctx, _, stop := setup() + defer stop() + + e := setupEcho() + + t.Run("GET /v1/modpacks - Empty search string", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?search=", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + + var response nodes.GenericResponse + err := json.Unmarshal(rec.Body.Bytes(), &response) + testza.AssertNoError(t, err) + + testza.AssertTrue(t, response.Success) + }) + + t.Run("GET /v1/modpacks - Zero limit", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/v1/modpacks?limit=0", nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusOK, rec.Code) + }) + + t.Run("GET /v1/modpack/:id/releases/:version - Empty version", func(t *testing.T) { + modpackID := "test-modpack-id" + req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/v1/modpack/%s/releases/", modpackID), nil) + req = req.WithContext(ctx) + rec := httptest.NewRecorder() + + e.ServeHTTP(rec, req) + + testza.AssertEqual(t, http.StatusNotFound, rec.Code) + }) +} diff --git a/tests/utils_test.go b/tests/utils_test.go index eeef4432..2666e01b 100644 --- a/tests/utils_test.go +++ b/tests/utils_test.go @@ -5,8 +5,10 @@ import ( "testing" "github.com/MarvinJWendt/testza" + "github.com/Masterminds/semver/v3" "github.com/machinebox/graphql" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/util" ) @@ -41,12 +43,125 @@ func seedTags(ctx context.Context, t *testing.T, token string, client *graphql.C return ids } +type testModpack struct { + Name string `json:"name"` + ShortDescription string `json:"short_description"` + FullDescription string `json:"full_description"` + TagIDs []string `json:"tagIDs"` + Targets []string `json:"targets"` + Mods []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + } `json:"mods"` + ParentID *string `json:"parent_id,omitempty"` + Hidden *bool `json:"hidden,omitempty"` +} + +func seedModpacks(ctx context.Context, t *testing.T, token string, client *graphql.Client, tagIDs []string, modIDs []string) []string { + modpacks := []testModpack{ + { + Name: "Ultimate Factory Pack", + ShortDescription: "The ultimate collection of factory enhancement mods", + FullDescription: "This modpack includes the best mods for optimizing and enhancing your factory operations, from automation to resource management.", + TagIDs: tagIDs, + Targets: []string{"Windows", "WindowsServer", "LinuxServer"}, + Mods: []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: modIDs[0], VersionConstraint: ">=1.0.0"}, + {ModID: modIDs[1], VersionConstraint: "^2.0.0"}, + {ModID: modIDs[2], VersionConstraint: "~1.0.0"}, + }, + }, + { + Name: "Beginner's Starter Pack", + ShortDescription: "Perfect for new players getting started", + FullDescription: "A carefully curated selection of beginner-friendly mods that enhance the game experience without overwhelming new players.", + TagIDs: []string{tagIDs[0]}, + Targets: []string{"Windows"}, + Mods: []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: modIDs[1], VersionConstraint: ">=2.0.0"}, + {ModID: modIDs[0], VersionConstraint: "^1.0.0"}, + }, + }, + { + Name: "Advanced Engineering", + ShortDescription: "For experienced players seeking complex challenges", + FullDescription: "Advanced mods that add complexity and new engineering challenges for experienced players.", + TagIDs: []string{tagIDs[1]}, + Targets: []string{"Windows", "WindowsServer", "LinuxServer"}, + Mods: []struct { + ModID string `json:"mod_id"` + VersionConstraint string `json:"version_constraint"` + }{ + {ModID: modIDs[1], VersionConstraint: ">=3.0.0"}, + {ModID: modIDs[2], VersionConstraint: "^1.0.0"}, + {ModID: modIDs[3], VersionConstraint: "~1.0.0"}, + }, + Hidden: func() *bool { b := true; return &b }(), + }, + } + + ids := make([]string, len(modpacks)) + for i, pack := range modpacks { + // Create the modpack itself + createRequest := authRequest(`mutation ($modpack: NewModpack!) { + createModpack(modpack: $modpack) { + id + } + }`, token) + createRequest.Var("modpack", pack) + + var createResponse struct { + CreateModpack generated.Modpack + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateModpack.ID) + + ids[i] = createResponse.CreateModpack.ID + + // Create a release for each modpack + releaseRequest := authRequest(`mutation ($modpackID: ModpackID!, $release: NewModpackRelease!) { + createModpackRelease(modpackID: $modpackID, release: $release) { + id + } + }`, token) + releaseRequest.Var("modpackID", createResponse.CreateModpack.ID) + releaseRequest.Var("release", struct { + Version string `json:"version"` + Changelog string `json:"changelog"` + }{ + Version: "1.0.0", + Changelog: "Hello World", + }) + + var releaseaResponse struct { + CreateModpackRelease generated.ModpackRelease + } + testza.AssertNoError(t, client.Run(ctx, releaseRequest, &releaseaResponse)) + testza.AssertNotEqual(t, "", releaseaResponse.CreateModpackRelease.ID) + } + + return ids +} + +type testVersion struct { + Version *semver.Version `json:"version"` + Dependencies map[string]string +} + type testMod struct { Name string `json:"name"` ShortDescription string `json:"short_description"` FullDescription string `json:"full_description"` ModReference string `json:"mod_reference"` TagIDs []string `json:"tagIDs"` + + versions []testVersion } func seedMods(ctx context.Context, t *testing.T, token string, client *graphql.Client, tagID string) []string { @@ -55,21 +170,71 @@ func seedMods(ctx context.Context, t *testing.T, token string, client *graphql.C Name: "Advanced Robotics", ShortDescription: "Enhances robot efficiency and adds new automation features.", ModReference: "advanced_robotics", + versions: []testVersion{ + { + Version: semver.New(1, 0, 0, "", ""), + Dependencies: map[string]string{ + "mega_factory": ">0.0.0", + }, + }, + { + Version: semver.New(2, 0, 0, "", ""), + Dependencies: map[string]string{ + "mega_factory": ">0.0.0", + }, + }, + { + Version: semver.New(3, 0, 0, "", ""), + Dependencies: map[string]string{ + "mega_factory": ">0.0.0", + }, + }, + }, }, { Name: "Eco-Friendly Power", ShortDescription: "Introduces sustainable energy sources and eco-friendly power management.", ModReference: "eco_friendly_power", + versions: []testVersion{ + { + Version: semver.New(1, 0, 0, "", ""), + Dependencies: map[string]string{ + "quantum_transport": ">0.0.0", + }, + }, + { + Version: semver.New(2, 0, 0, "", ""), + Dependencies: map[string]string{ + "quantum_transport": ">0.0.0", + }, + }, + { + Version: semver.New(3, 0, 0, "", ""), + Dependencies: map[string]string{ + "quantum_transport": ">0.0.0", + }, + }, + }, }, { Name: "Quantum Transport", ShortDescription: "Allows instantaneous item transport using quantum entanglement.", ModReference: "quantum_transport", + versions: []testVersion{ + { + Version: semver.New(1, 0, 0, "", ""), + }, + }, }, { Name: "Mega Factory", ShortDescription: "Expands factory building limits and adds new large-scale production tools.", ModReference: "mega_factory", + versions: []testVersion{ + { + Version: semver.New(1, 0, 0, "", ""), + }, + }, }, { Name: "Resource Overhaul", @@ -128,6 +293,23 @@ func seedMods(ctx context.Context, t *testing.T, token string, client *graphql.C testza.AssertNotEqual(t, "", createResponse.CreateMod.ID) ids[i] = createResponse.CreateMod.ID + + for _, version := range mod.versions { + v := db.From(ctx).Version.Create(). + SetVersion(version.Version.String()). + SetVersionMajor(int(version.Version.Major())). + SetVersionMinor(int(version.Version.Minor())). + SetVersionPatch(int(version.Version.Patch())). + SetGameVersion(">=0"). + SetModReference(mod.ModReference). + SetModID(createResponse.CreateMod.ID). + SetApproved(true). + SaveX(ctx) + + for _, s := range []string{"Windows", "WindowsServer", "LinuxServer"} { + db.From(ctx).VersionTarget.Create().SetVersion(v).SetTargetName(s).SaveX(ctx) + } + } } return ids From 1fd5ceda39cd25ccaa56d006468f53a9c0432bc9 Mon Sep 17 00:00:00 2001 From: Vilsol Date: Wed, 25 Jun 2025 02:41:24 +0300 Subject: [PATCH 2/2] chore: schema files don't have coverage --- codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codecov.yml b/codecov.yml index a31e7c19..bb37385f 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,3 +6,4 @@ coverage: ignore: - "generated" + - "db/schema"