From 41077e3c3487733ec3a50e7bb1762f7dc71a83f9 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Sat, 21 Oct 2023 03:00:41 +0300 Subject: [PATCH 01/19] refactor: yes --- .github/workflows/build.yml | 8 +- .github/workflows/release.yml | 2 +- .golangci.yml | 2 - Dockerfile | 2 +- README.md | 2 +- api.go | 65 +- config/config.go | 53 +- config/logging.go | 42 + db/postgres/otel/plugin.go | 2 +- db/postgres/postgres.go | 35 +- db/statistics.go | 7 +- go.mod | 224 +- go.sum | 1860 +++-------------- gql/directive.go | 26 +- gql/resolver_announcements.go | 5 +- gql/resolver_bootstrap_versions.go | 15 +- gql/resolver_guides.go | 11 +- gql/resolver_mods.go | 27 +- gql/resolver_oauth.go | 3 +- gql/resolver_sml_versions.go | 13 +- gql/resolver_users.go | 9 +- gql/resolver_versions.go | 24 +- gql/versions.go | 18 +- integrations/discord.go | 9 +- migrations/code.go | 11 +- .../code/20200426221900_test_new_migration.go | 4 +- migrations/code/20200501224200_parse_paks.go | 4 +- .../20200524203800_after_reference_fix.go | 4 +- .../20200621195500_after_id_length_fix.go | 4 +- ...20200622003600_after_validation_disable.go | 4 +- .../code/20200629093800_copy_to_new_bucket.go | 4 +- .../20200707150700_after_sml_version_fix.go | 4 +- .../code/20200829171600_after_db_dirty.go | 4 +- .../20200829225100_after_broken_datajson.go | 4 +- .../code/20200830011200_after_gorm_hotfix.go | 4 +- .../code/20201014162200_after_bp_fix.go | 4 +- .../code/20201016202600_after_body_enable.go | 4 +- .../20201019203800_after_remove_filter.go | 4 +- migrations/migrations.go | 7 +- models/filters.go | 22 +- nodes/user.go | 4 +- oauth/facebook.go | 9 +- oauth/github.go | 15 +- oauth/google.go | 9 +- .../consumer_copy_object_from_old_bucket.go | 4 +- .../consumer_copy_object_to_old_bucket.go | 26 - .../consumer_scan_mod_on_virus_total.go | 19 +- ...onsumer_update_db_from_mod_version_file.go | 4 +- ...er_update_db_from_mod_version_json_file.go | 4 +- redis/jobs/consumers/utils.go | 12 +- redis/jobs/jobs.go | 22 +- redis/jobs/tasks/tasks.go | 1 - redis/redis.go | 16 +- shell.nix | 7 +- storage/b2.go | 246 --- storage/s3.go | 31 +- storage/storage.go | 103 +- storage/wasabi.go | 124 -- tests/utils.go | 9 +- util/converter/converter_linux.go | 15 +- util/converter/converter_windows.go | 16 +- util/flags.go | 9 +- util/logging.go | 4 +- util/random.go | 2 +- validation/decoderv2.go | 150 -- validation/paks.go | 266 --- validation/paks_test.go | 69 - validation/validation.go | 29 +- validation/virustotal.go | 23 +- 69 files changed, 870 insertions(+), 2934 deletions(-) create mode 100644 config/logging.go mode change 100755 => 100644 go.sum delete mode 100644 redis/jobs/consumers/consumer_copy_object_to_old_bucket.go delete mode 100644 storage/b2.go delete mode 100644 storage/wasabi.go delete mode 100644 validation/decoderv2.go delete mode 100644 validation/paks.go delete mode 100644 validation/paks_test.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 332f1398..aa4a63b9 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -53,7 +53,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.49.0 + version: v1.54.2 skip-pkg-cache: true skip-build-cache: true args: --timeout 5m @@ -65,7 +65,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc5a0eff..0bfd054a 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/.golangci.yml b/.golangci.yml index 37211ece..08345800 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,8 +4,6 @@ linters-settings: - .Errorf( - errors.New( - errors.Unwrap( - - .Wrap( - - .Wrapf( - .WithMessage( - .WithMessagef( - .WithStack( diff --git a/Dockerfile b/Dockerfile index 83c9552d..b66353e2 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine3.18 AS builder +FROM golang:1.21-alpine3.18 AS builder RUN apk add --no-cache git build-base libpng-dev protoc RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 diff --git a/README.md b/README.md index 220b9da0..8028db17 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SMR API   [](https://codecov.io/gh/satisfactorymodding/smr-api)  +# SMR API [](https://github.com/satisfactorymodding/smr-api/actions/workflows/build.yml)  [](https://codecov.io/gh/satisfactorymodding/smr-api)  The Satisfactory Mod Repository backend API diff --git a/api.go b/api.go index ed58933e..05758919 100644 --- a/api.go +++ b/api.go @@ -3,6 +3,7 @@ package smr import ( "context" "fmt" + "log/slog" "os" "os/signal" "runtime" @@ -14,12 +15,11 @@ import ( "github.com/99designs/gqlgen/graphql/handler/lru" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" + "github.com/Vilsol/slox" "github.com/felixge/fgprof" "github.com/labstack/echo-contrib/pprof" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" echoSwagger "github.com/swaggo/echo-swagger" "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" @@ -59,7 +59,10 @@ type CustomValidator struct { } func (cv *CustomValidator) Validate(i interface{}) error { - return errors.Wrap(cv.validator.Struct(i), "validation error") + if err := cv.validator.Struct(i); err != nil { + return fmt.Errorf("validation error: %w", err) + } + return nil } func Initialize(baseCtx context.Context) context.Context { @@ -79,7 +82,7 @@ func Initialize(baseCtx context.Context) context.Context { auth.InitializeAuth() jobs.InitializeJobs(ctx) validation.InitializeVirusTotal() - util.PrintFeatureFlags() + util.PrintFeatureFlags(ctx) return ctx } @@ -99,7 +102,7 @@ func Setup(ctx context.Context) { debugServer.HideBanner = true debugServer.HidePort = true address := ":6060" - log.Info().Str("address", address).Msg("starting profiler") + slog.Info("starting profiler", slog.String("address", address)) debugServer.Logger.Fatal(debugServer.Start(address)) }() } @@ -120,8 +123,7 @@ func Setup(ctx context.Context) { v1.Use(func(handlerFunc echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { - newLogger := log.Ctx(ctx.Request().Context()).With().Str("facade", "REST").Logger() - newCtx := newLogger.WithContext(context.Background()) + newCtx := slox.With(ctx.Request().Context(), slog.String("facade", "REST")) ctx.SetRequest(ctx.Request().WithContext(newCtx)) return handlerFunc(ctx) } @@ -139,8 +141,7 @@ func Setup(ctx context.Context) { v2.Use(func(handlerFunc echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { - newLogger := log.Ctx(ctx.Request().Context()).With().Str("facade", "GQL").Logger() - newCtx := newLogger.WithContext(context.Background()) + newCtx := slox.With(ctx.Request().Context(), slog.String("facade", "GQL")) newCtx = context.WithValue(newCtx, util.ContextHeader{}, ctx.Request().Header) newCtx = context.WithValue(newCtx, util.ContextRequest{}, ctx.Request()) newCtx = context.WithValue(newCtx, util.ContextResponse{}, ctx.Response().Writer) @@ -250,22 +251,23 @@ func Setup(ctx context.Context) { bytesIn = "0" } - log.Info(). - Str("time_rfc3339", time.Now().Format(time.RFC3339)). - Str("remote_ip", c.RealIP()). - Str("host", req.Host). - Str("uri", req.RequestURI). - Str("method", req.Method). - Str("path", p). - Str("referer", req.Referer()). - Str("user_agent", req.UserAgent()). - Int("status", res.Status). - Int64("latency", stop.Sub(start).Nanoseconds()/1000). - Str("latency_human", stop.Sub(start).String()). - Str("bytes_in", bytesIn). - Int64("bytes_out", res.Size). - Str("trace_id", spanContext.TraceID().String()). - Msg("Handled request") + slog.Info( + "Handled request", + slog.String("time_rfc3339", time.Now().Format(time.RFC3339)), + slog.String("remote_ip", c.RealIP()), + slog.String("host", req.Host), + slog.String("uri", req.RequestURI), + slog.String("method", req.Method), + slog.String("path", p), + slog.String("referer", req.Referer()), + slog.String("user_agent", req.UserAgent()), + slog.Int("status", res.Status), + slog.Int64("latency", stop.Sub(start).Nanoseconds()/1000), + slog.String("latency_human", stop.Sub(start).String()), + slog.String("bytes_in", bytesIn), + slog.Int64("bytes_out", res.Size), + slog.String("trace_id", spanContext.TraceID().String()), + ) return nil } @@ -282,7 +284,7 @@ func Setup(ctx context.Context) { func Serve() { address := fmt.Sprintf(":%d", viper.GetInt("port")) - log.Info().Str("address", address).Msg("starting server") + slog.Info("starting server", slog.String("address", address)) e.HidePort = true e.Logger.Error(e.Start(address)) @@ -292,7 +294,8 @@ func installExportPipeline(ctx context.Context) func() { client := otlptracehttp.NewClient() exporter, err := otlptrace.New(ctx, client) if err != nil { - log.Fatal().Err(err).Msg("creating OTLP trace exporter") + slog.Error("creating OTLP trace exporter", slog.Any("err", err)) + os.Exit(1) } tracerProvider := sdktrace.NewTracerProvider( @@ -304,7 +307,8 @@ func installExportPipeline(ctx context.Context) func() { return func() { if err := tracerProvider.Shutdown(ctx); err != nil { - log.Fatal().Err(err).Msg("stopping tracer provider") + slog.Error("stopping tracer provider", slog.Any("err", err)) + os.Exit(1) } } } @@ -329,5 +333,8 @@ func Start() { } func Stop() error { - return errors.Wrap(e.Close(), "failed to stop http server") + if err := e.Close(); err != nil { + return fmt.Errorf("failed to stop http server: %w", err) + } + return nil } diff --git a/config/config.go b/config/config.go index 1fd6ea3d..9cc2fd79 100644 --- a/config/config.go +++ b/config/config.go @@ -2,17 +2,25 @@ package config import ( "context" - "io" + "fmt" + "log/slog" "os" "time" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" + "github.com/Vilsol/slox" + "github.com/lmittmann/tint" "github.com/spf13/viper" ) var configDir = "." +const ( + ansiReset = "\033[0m" + ansiBold = "\033[1m" + ansiWhite = "\033[38m" + ansiBrightMagenta = "\033[95m" +) + func SetConfigDir(newConfigDir string) { configDir = newConfigDir } @@ -27,29 +35,44 @@ func InitializeConfig(baseCtx context.Context) context.Context { err := viper.ReadInConfig() //nolint:ifshort - var out io.Writer = os.Stdout if !viper.GetBool("production") { - out = zerolog.ConsoleWriter{ - Out: os.Stdout, - TimeFormat: time.RFC3339, - } + slog.SetDefault(slog.New( + StackRewriter{ + Upstream: tint.NewHandler(os.Stderr, &tint.Options{ + Level: slog.LevelDebug, + AddSource: true, + TimeFormat: time.RFC3339Nano, + ReplaceAttr: func(groups []string, attr slog.Attr) slog.Attr { + if attr.Key == slog.LevelKey { + level := attr.Value.Any().(slog.Level) + if level == slog.LevelDebug { + attr.Value = slog.StringValue(ansiBrightMagenta + "DBG" + ansiReset) + } + } else if attr.Key == slog.MessageKey { + attr.Value = slog.StringValue(ansiBold + ansiWhite + fmt.Sprint(attr.Value.Any()) + ansiReset) + } + return attr + }, + }).WithAttrs([]slog.Attr{slog.String("service", "api")}), + }, + )) + } else { + slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{ + AddSource: true, + }))) } - log.Logger = zerolog.New(out).With().Str("service", "api").Timestamp().Logger() - if baseCtx == nil { baseCtx = context.Background() } - ctx := log.Logger.WithContext(baseCtx) - if err != nil { - log.Warn().Err(err).Msg("config initialized using defaults and environment only!") + slog.Warn("config initialized using defaults and environment only!", slog.Any("err", err)) } - log.Info().Msg("Config initialized") + slox.Info(baseCtx, "Config initialized") - return ctx + return baseCtx } func initializeDefaults() { diff --git a/config/logging.go b/config/logging.go new file mode 100644 index 00000000..ef78f134 --- /dev/null +++ b/config/logging.go @@ -0,0 +1,42 @@ +package config + +import ( + "context" + "log/slog" + "runtime" + "strings" +) + +var _ slog.Handler = (*StackRewriter)(nil) + +type StackRewriter struct { + Upstream slog.Handler +} + +func (t StackRewriter) Enabled(ctx context.Context, level slog.Level) bool { + return t.Upstream.Enabled(ctx, level) +} + +func (t StackRewriter) Handle(ctx context.Context, record slog.Record) error { + if record.PC != 0 { + fs := runtime.CallersFrames([]uintptr{record.PC}) + f, _ := fs.Next() + if strings.HasPrefix(f.Function, "github.com/Vilsol/slox") { + // skip one more + var pcs [1]uintptr + runtime.Callers(5, pcs[:]) + record.PC = pcs[0] + } + } + + //nolint + return t.Upstream.Handle(ctx, record) +} + +func (t StackRewriter) WithAttrs(attrs []slog.Attr) slog.Handler { + return t.Upstream.WithAttrs(attrs) +} + +func (t StackRewriter) WithGroup(name string) slog.Handler { + return t.Upstream.WithGroup(name) +} diff --git a/db/postgres/otel/plugin.go b/db/postgres/otel/plugin.go index 4769d2e8..f4a0dd5b 100644 --- a/db/postgres/otel/plugin.go +++ b/db/postgres/otel/plugin.go @@ -48,7 +48,7 @@ func NewPlugin(opts ...Option) *Plugin { cfg: cfg, tracer: cfg.tracerProvider.Tracer( defaultTracerName, - oteltrace.WithInstrumentationVersion(contrib.SemVersion()), + oteltrace.WithInstrumentationVersion(contrib.Version()), ), } } diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go index 35f023ad..2f8b2727 100644 --- a/db/postgres/postgres.go +++ b/db/postgres/postgres.go @@ -3,11 +3,11 @@ package postgres import ( "context" "fmt" + "log/slog" "time" + "github.com/Vilsol/slox" "github.com/patrickmn/go-cache" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "gorm.io/driver/postgres" "gorm.io/gorm" @@ -37,15 +37,15 @@ func (l *GormLogger) LogMode(mode logger.LogLevel) logger.Interface { } func (*GormLogger) Info(ctx context.Context, msg string, data ...interface{}) { - log.Info().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + slox.Info(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) } func (*GormLogger) Warn(ctx context.Context, msg string, data ...interface{}) { - log.Warn().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + slox.Warn(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) } func (*GormLogger) Error(ctx context.Context, msg string, data ...interface{}) { - log.Error().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + slox.Error(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) } func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { @@ -54,25 +54,30 @@ func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (stri sql, rows := fc() - var logEv *zerolog.Event + level := slog.LevelInfo + attrs := make([]slog.Attr, 0) + toLog := false switch { case err != nil: - logEv = log.Err(err) + level = slog.LevelError + attrs = append(attrs, slog.Any("err", err)) + toLog = true case since > l.SlowThreshold && l.SlowThreshold != 0: - logEv = log.Warn() + level = slog.LevelWarn + toLog = true case l.Debug: - logEv = log.Info() + level = slog.LevelInfo + toLog = true } - if logEv != nil { + if toLog { if len(sql) > 256 { sql = sql[:256] } - logEv.Str("file", utils.FileWithLineNum()). - Float64("elapsed", elapsed). - Int64("rows", rows). - Msg(sql) + attrs = append(attrs, slog.Float64("elapsed", elapsed)) + attrs = append(attrs, slog.Int64("rows", rows)) + slox.LogAttrs(ctx, level, sql, attrs...) } } @@ -112,7 +117,7 @@ func InitializePostgres(ctx context.Context) { // TODO Create search indexes - log.Info().Msg("Postgres initialized") + slox.Info(ctx, "Postgres initialized") } func Save(ctx context.Context, object interface{}) { diff --git a/db/statistics.go b/db/statistics.go index f772341e..105d79d0 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -2,10 +2,11 @@ package db import ( "context" + "log/slog" "regexp" "time" - "github.com/rs/zerolog/log" + "github.com/Vilsol/slox" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/redis" @@ -18,7 +19,7 @@ func RunAsyncStatisticLoop(ctx context.Context) { for { start := time.Now() keys := redis.GetAllKeys() - log.Info().Msgf("Fetched: %d keys in %s", len(keys), time.Since(start).String()) + slox.Info(ctx, "statistics fetched", slog.Int("keys", len(keys)), slog.Duration("took", time.Since(start))) resultMap := make(map[string]map[string]map[string]uint) for _, key := range keys { if matches := keyRegex.FindStringSubmatch(key); matches != nil { @@ -102,7 +103,7 @@ func RunAsyncStatisticLoop(ctx context.Context) { updateTx.Commit() } - log.Info().Msgf("Statistics Updated! Took %s", time.Since(start).String()) + slox.Info(ctx, "statistics updated", slog.Duration("took", time.Since(start))) time.Sleep(time.Minute) } }() diff --git a/go.mod b/go.mod index 43a278e6..b3fbd322 100755 --- a/go.mod +++ b/go.mod @@ -1,171 +1,173 @@ module github.com/satisfactorymodding/smr-api -go 1.19 +go 1.21 require ( - github.com/99designs/gqlgen v0.17.16 - github.com/MarvinJWendt/testza v0.4.3 - github.com/Masterminds/semver/v3 v3.1.1 - github.com/Vilsol/ue4pak v0.1.5 - github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee + github.com/99designs/gqlgen v0.17.39 + github.com/MarvinJWendt/testza v0.5.2 + github.com/Masterminds/semver/v3 v3.2.1 + github.com/Vilsol/slox v0.0.1 + github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f github.com/avast/retry-go/v3 v3.1.1 - github.com/aws/aws-sdk-go v1.44.12 - github.com/btcsuite/btcutil v1.0.2 + github.com/aws/aws-sdk-go v1.46.1 + github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cespare/xxhash v1.1.0 github.com/chai2010/webp v1.1.1 - github.com/dgraph-io/ristretto v0.1.0 + github.com/dgraph-io/ristretto v0.1.1 github.com/felixge/fgprof v0.9.3 github.com/finnbear/moderation v0.11.4 github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis/v8 v8.11.5 - github.com/golang-migrate/migrate/v4 v4.15.2 + github.com/golang-migrate/migrate/v4 v4.16.2 github.com/lab259/go-migration v1.3.1 - github.com/labstack/echo-contrib v0.13.0 - github.com/labstack/echo/v4 v4.7.2 + github.com/labstack/echo-contrib v0.15.0 + github.com/labstack/echo/v4 v4.11.2 + github.com/lmittmann/tint v1.0.2 github.com/machinebox/graphql v0.2.2 - github.com/microcosm-cc/bluemonday v1.0.18 + github.com/microcosm-cc/bluemonday v1.0.26 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/mitchellh/mapstructure v1.5.0 github.com/o1egl/paseto v1.0.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.26.1 github.com/russross/blackfriday v1.6.0 github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591 - github.com/spf13/viper v1.11.0 - github.com/swaggo/echo-swagger v1.3.2 - github.com/swaggo/swag v1.8.1 - github.com/vektah/gqlparser/v2 v2.5.0 - github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.8 - github.com/vmihailenco/taskq/v3 v3.2.8 + github.com/spf13/viper v1.17.0 + github.com/swaggo/echo-swagger v1.4.1 + github.com/swaggo/swag v1.16.2 + github.com/vektah/gqlparser/v2 v2.5.10 + github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9 + github.com/vmihailenco/taskq/v3 v3.2.9 github.com/xeipuuv/gojsonschema v1.2.0 - go.opentelemetry.io/contrib v1.7.0 - go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.32.0 - go.opentelemetry.io/otel v1.7.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0 - go.opentelemetry.io/otel/sdk v1.7.0 - go.opentelemetry.io/otel/trace v1.7.0 - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa - golang.org/x/net v0.0.0-20220728030405-41545e8bf201 - golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c + go.opentelemetry.io/contrib v1.20.0 + go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 + go.opentelemetry.io/otel v1.19.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 + go.opentelemetry.io/otel/sdk v1.19.0 + go.opentelemetry.io/otel/trace v1.19.0 + golang.org/x/crypto v0.14.0 + golang.org/x/net v0.17.0 + golang.org/x/oauth2 v0.13.0 + golang.org/x/sync v0.4.0 + google.golang.org/grpc v1.59.0 + google.golang.org/protobuf v1.31.0 gopkg.in/go-playground/validator.v9 v9.31.0 - gorm.io/driver/postgres v1.3.5 - gorm.io/gorm v1.23.5 + gorm.io/driver/postgres v1.5.3 + gorm.io/gorm v1.25.5 ) require ( - cloud.google.com/go/compute v1.5.0 // indirect + atomicgo.dev/assert v0.0.2 // indirect + atomicgo.dev/cursor v0.2.0 // indirect + atomicgo.dev/keyboard v0.2.9 // indirect + atomicgo.dev/schedule v0.1.0 // indirect + cloud.google.com/go/compute v1.23.1 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb // indirect + github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29 // indirect github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect - github.com/atomicgo/cursor v0.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect - github.com/bsm/redislock v0.7.1 // indirect + github.com/bsm/redislock v0.7.2 // indirect github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containerd/console v1.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/dustin/go-humanize v1.0.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.6 // indirect - github.com/go-openapi/spec v0.20.4 // indirect - github.com/go-openapi/swag v0.19.15 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-openapi/jsonpointer v0.20.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/spec v0.20.9 // indirect + github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-redis/redis_rate/v9 v9.1.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/golang/glog v1.0.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/gookit/color v1.5.0 // indirect + github.com/golang/glog v1.1.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.12.0 // indirect - github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.11.0 // indirect - github.com/jackc/pgx/v4 v4.16.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/pgx/v5 v5.4.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.4 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/klauspost/cpuid/v2 v2.1.0 // indirect - github.com/labstack/gommon v0.3.1 // indirect - github.com/leodido/go-urn v1.2.1 // indirect - github.com/lib/pq v1.10.2 // indirect - github.com/magiconair/properties v1.8.6 // indirect + github.com/klauspost/compress v1.17.1 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/labstack/gommon v0.4.0 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/lithammer/fuzzysearch v1.1.8 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/matryer/is v1.4.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/pelletier/go-toml v1.9.4 // indirect - github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect - github.com/pterm/pterm v0.12.40 // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/matryer/is v1.4.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pterm/pterm v0.12.69 // indirect + github.com/rivo/uniseg v0.4.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sergi/go-diff v1.2.0 // indirect + github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9 // indirect - github.com/spate/glimage v0.0.0-20200505055513-fbdcc60a65e5 // indirect - github.com/spf13/afero v1.8.2 // indirect - github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/sosodev/duration v1.2.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.10.0 // indirect + github.com/spf13/cast v1.5.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/subosito/gotenv v1.2.0 // indirect - github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/swaggo/files/v2 v2.0.0 // indirect github.com/thedevsaddam/gojsonq/v2 v2.5.2 // indirect - github.com/urfave/cli/v2 v2.8.1 // indirect + github.com/urfave/cli/v2 v2.25.7 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.1 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/x448/float16 v0.8.4 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect - go.opentelemetry.io/proto/otlp v0.16.0 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/exp v0.0.0-20210220032938-85be41e4509f // indirect - golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect - golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect - golang.org/x/tools v0.1.10 // indirect - golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect - google.golang.org/grpc v1.48.0 // indirect - google.golang.org/protobuf v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.19.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/mod v0.13.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.14.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/ini.v1 v1.66.4 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum old mode 100755 new mode 100644 index 7828d761..b0d0d079 --- a/go.sum +++ b/go.sum @@ -1,5 +1,11 @@ -bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= -bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= +atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg= +atomicgo.dev/assert v0.0.2/go.mod h1:ut4NcI3QDdJtlmAxQULOmA13Gz6e2DWbSAS8RUOmNYQ= +atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw= +atomicgo.dev/cursor v0.2.0/go.mod h1:Lr4ZJB3U7DfPPOkbH7/6TOtJ4vFGHlgj1nc+n900IpU= +atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8= +atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ= +atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs= +atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -19,37 +25,22 @@ cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHOb cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0 h1:b1zWmYuuHz7gO9kDcM/EpHGr06UgsYNRpNJzI2kFiLM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.23.1 h1:V97tBoDaZHb6leicZ1G6DLK2BAaZLJ/7+9BB/En3hR0= +cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/spanner v1.28.0/go.mod h1:7m6mtQZn/hMbMfx62ct5EWrGND4DNqkXyrmBPRS+OJo= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= @@ -58,35 +49,12 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= -github.com/99designs/gqlgen v0.17.16 h1:tTIw/cQ/uvf3iXIb2I6YSkdaDkmHmH2W2eZkVe0IVLA= -github.com/99designs/gqlgen v0.17.16/go.mod h1:dnJdUkgfh8iw8CEx2hhTdgTQO/GvVWKLcm/kult5gwI= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg= -github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= -github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-storage-blob-go v0.14.0/go.mod h1:SMqIBi+SuiQH32bvyjngEewEeXoPfKMgWlBDaYf6fck= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest v10.8.1+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= -github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= -github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= -github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/adal v0.9.16/go.mod h1:tGMin8I49Yij6AQ+rvV+Xa/zwxYQB5hmsd6DkfAx2+A= -github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +github.com/99designs/gqlgen v0.17.39 h1:wPTAyc2fqVjAWT5DsJ21k/lLudgnXzURwbsjVNegFpU= +github.com/99designs/gqlgen v0.17.39/go.mod h1:b62q1USk82GYIVjC60h02YguAZLqYZtvWml8KkhJps4= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= @@ -95,548 +63,187 @@ github.com/MarvinJWendt/testza v0.2.8/go.mod h1:nwIcjmr0Zz+Rcwfh3/4UhBp7ePKVhuBE github.com/MarvinJWendt/testza v0.2.10/go.mod h1:pd+VWsoGUiFtq+hRKSU1Bktnn+DMCSrDrXDpX2bG66k= github.com/MarvinJWendt/testza v0.2.12/go.mod h1:JOIegYyV7rX+7VZ9r77L/eH6CfJHHzXjB69adAhzZkI= github.com/MarvinJWendt/testza v0.3.0/go.mod h1:eFcL4I0idjtIx8P9C6KkAuLgATNKpX4/2oUqKc6bF2c= -github.com/MarvinJWendt/testza v0.4.3 h1:u2XaM4IqGp9dsdUmML8/Z791fu4yjQYzOiufOtJwTII= -github.com/MarvinJWendt/testza v0.4.3/go.mod h1:CpXaOfceNEYnLDtNIyTrPPcCpDJYqzZnu2aiA2Wp33U= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= -github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.4.17-0.20210324224401-5516f17a5958/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= -github.com/Microsoft/hcsshim v0.8.7-0.20190325164909-8abdbb8205e4/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= -github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= -github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8= -github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg= -github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00= -github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600= -github.com/Microsoft/hcsshim v0.8.20/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= -github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= -github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg= -github.com/Microsoft/hcsshim v0.9.2/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= -github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= -github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= +github.com/MarvinJWendt/testza v0.4.2/go.mod h1:mSdhXiKH8sg/gQehJ63bINcCKp7RtYewEjXsvsVUPbE= +github.com/MarvinJWendt/testza v0.5.2 h1:53KDo64C1z/h/d/stCYCPY69bt/OSwjq5KpFNwi+zB4= +github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc4n3EjyIYvEY= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= -github.com/Vilsol/ue4pak v0.1.5 h1:XE17rYgieBh67vpB2lZI6ARv3KxMzAelWh/RDA9O7Ms= -github.com/Vilsol/ue4pak v0.1.5/go.mod h1:e/4WiPI80PbsP2+IOWYoqwiZT+lKAcoEr0wmVY3ROLQ= -github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee h1:JDhi0dS8y9QLMJZA7ezLyXHxYaMlyzX6MDkq0SSc304= -github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= +github.com/Vilsol/slox v0.0.1 h1:X5iskI+WLDxW5FNxYV9izEEWliFzRUNxcItHWetwnOk= +github.com/Vilsol/slox v0.0.1/go.mod h1:1mhhQdJHAzUVobE9RE0k7vxaSn17C0b4WSMPjHCizJo= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f h1:49xl3zKS625gxmIRCfmwkXcTzB4cr4FcayRw/RcxhZs= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb h1:6Z/wqhPFZ7y5ksCEV/V5MXOazLaeu/EW97CU5rz8NWk= github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb/go.mod h1:UzH9IX1MMqOcwhoNOIjmTQeAxrFgzs50j4golQtXXxU= +github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29 h1:1DcvRPZOdbQRg5nAHt2jrc5QbV0AGuhDdfQI6gXjiFE= +github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29/go.mod h1:UzH9IX1MMqOcwhoNOIjmTQeAxrFgzs50j4golQtXXxU= github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 h1:52m0LGchQBBVqJRyYYufQuIbVqRawmubW3OFGqK1ekw= github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs= -github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= -github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0= -github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/arrow/go/arrow v0.0.0-20210818145353-234c94e4ce64/go.mod h1:2qMFB56yOP3KzkB3PbYZ4AlUFg3a88F67TIx5lB/WwY= -github.com/apache/arrow/go/arrow v0.0.0-20211013220434-5962184e7a30/go.mod h1:Q7yQnSMnLvcXlZ8RV+jwz/6y1rQTqbX6C82SndT52Zs= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/atomicgo/cursor v0.0.1 h1:xdogsqa6YYlLfM+GyClC/Lchf7aiMerFiZQn7soTOoU= github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk= github.com/avast/retry-go/v3 v3.1.1 h1:49Scxf4v8PmiQ/nY0aY3p0hDueqSmc7++cBbtiDGu2g= github.com/avast/retry-go/v3 v3.1.1/go.mod h1:6cXRK369RpzFL3UQGqIUp9Q7GDrams+KsYWrfNA1/nQ= -github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.42.7/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= -github.com/aws/aws-sdk-go v1.44.12 h1:5f7ESFKQv5WHX8m37H2T8G+tc/rggy7sfdZ8ioqXFY8= -github.com/aws/aws-sdk-go v1.44.12/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go-v2 v1.8.0/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0= -github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= -github.com/aws/aws-sdk-go-v2/config v1.6.0/go.mod h1:TNtBVmka80lRPk5+S9ZqVfFszOQAGJJ9KbT3EM3CHNU= -github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= -github.com/aws/aws-sdk-go-v2/credentials v1.3.2/go.mod h1:PACKuTJdt6AlXvEq8rFI4eDmoqDFC5DpVKQbWysaDgM= -github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.4.0/go.mod h1:Mj/U8OpDbcVcoctrYwA2bak8k/HFPdcLzI/vaiXMwuM= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.4.0/go.mod h1:eHwXu2+uE/T6gpnYWwBwqoeqRf9IXyCcolyOWDRAErQ= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.4/go.mod h1:Ex7XQmbFmgFHrjUX6TN3mApKW5Hglyga+F7wZHTtYhA= -github.com/aws/aws-sdk-go-v2/internal/ini v1.2.0/go.mod h1:Q5jATQc+f1MfZp3PDMhn6ry18hGvE0i8yvbXoKbnZaE= -github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.2.2/go.mod h1:EASdTcM1lGhUe1/p4gkojHwlGJkeoRjjr1sRCzup3Is= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.3.0/go.mod h1:v8ygadNyATSm6elwJ/4gzJwcFhri9RqS8skgHKiwXPU= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.2/go.mod h1:NXmNI41bdEsJMrD0v9rUvbGCB5GwdBEpKvUvIY3vTFg= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.5.2/go.mod h1:QuL2Ym8BkrLmN4lUofXYq6000/i5jPjosCNK//t6gak= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.7.2/go.mod h1:np7TMuJNT83O0oDOSF8i4dF3dvGqA6hPYYo6YYkzgRA= -github.com/aws/aws-sdk-go-v2/service/s3 v1.12.0/go.mod h1:6J++A5xpo7QDsIeSqPK4UHqMSyPOCopa+zKtqAMhqVQ= -github.com/aws/aws-sdk-go-v2/service/s3 v1.16.1/go.mod h1:CQe/KvWV1AqRc65KqeJjrLzr5X2ijnFTTVzJW0VBRCI= -github.com/aws/aws-sdk-go-v2/service/sso v1.3.2/go.mod h1:J21I6kF+d/6XHVk7kp/cx9YVD2TMD2TbLwtRGVcinXo= -github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= -github.com/aws/aws-sdk-go-v2/service/sts v1.6.1/go.mod h1:hLZ/AnkIKHLuPGjEiyghNEdvJ2PP0MgOxcmv9EBJ4xs= -github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= -github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= +github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= +github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= -github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= -github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/bsm/ginkgo v1.16.4 h1:pkHpo2VJRvI0NGlxCYi8qovww76L7+g82MgM+UBvH4A= -github.com/bsm/ginkgo v1.16.4/go.mod h1:RabIZLzOCPghgHJKUqHZpqrQETA5AnF4aCSIYy5C1bk= -github.com/bsm/gomega v1.13.0 h1:fzOh8E2Wu/x407rP+v3mEb9yGJaMVguiJBtmFkuOmlc= -github.com/bsm/gomega v1.13.0/go.mod h1:JifAceMQ4crZIWYUKrlGcmbN3bqHogVTADMD2ATsbwk= -github.com/bsm/redislock v0.7.1 h1:nBMm91MRuGOOSlHZNEF0+HpiaH1i8QpSALrF/q7b/Es= -github.com/bsm/redislock v0.7.1/go.mod h1:TSF3xUotaocycoHjVAp535/bET+ZmvrtcyNrXc0Whm8= +github.com/bsm/redislock v0.7.2 h1:jggqOio8JyX9FJBKIfjF3fTxAu/v7zC5mAID9LveqG4= +github.com/bsm/redislock v0.7.2/go.mod h1:kS2g0Yvlymc9Dz8V3iVYAtLAaSVruYbAFdYBDrmC5WU= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= -github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 h1:IHZ1Le1ejzkmS7Si7dIzJvYDWe+BIoNmqMnfWHBZSVw= github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3/go.mod h1:M5XHQLu90v2JNm/bW2tdsYar+5vhV0gEcBcmDBNAN1Y= -github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/webp v1.1.1 h1:jTRmEccAJ4MGrhFOrPMpNGIJ/eybIgwKpcACsrTEapk= github.com/chai2010/webp v1.1.1/go.mod h1:0XVwvZWdjjdxpUEIf7b9g9VkHFnInUSYujwqTLEuldU= -github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= -github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= -github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg= -github.com/cilium/ebpf v0.0.0-20200702112145-1c8d4c9ef775/go.mod h1:7cR51M8ViRLIdUjrmSXlK9pkrsDlLHbO8jiB8X8JnOc= -github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= -github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= -github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= -github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/cockroachdb/cockroach-go/v2 v2.1.1/go.mod h1:7NtUnP6eK+l6k483WSYNrq3Kb23bWV10IRV1TyeSpwM= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= -github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= -github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU= -github.com/containerd/aufs v1.0.0/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU= -github.com/containerd/btrfs v0.0.0-20201111183144-404b9149801e/go.mod h1:jg2QkJcsabfHugurUvvPhS3E08Oxiuh5W/g1ybB4e0E= -github.com/containerd/btrfs v0.0.0-20210316141732-918d888fb676/go.mod h1:zMcX3qkXTAi9GI50+0HOeuV8LU2ryCE/V2vG/ZBiTss= -github.com/containerd/btrfs v1.0.0/go.mod h1:zMcX3qkXTAi9GI50+0HOeuV8LU2ryCE/V2vG/ZBiTss= -github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601/go.mod h1:X9rLEHIqSf/wfK8NsPqxJmeZgW4pcfzdXITDrUSJ6uI= -github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= -github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM= -github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo= -github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo= -github.com/containerd/cgroups v0.0.0-20210114181951-8a68de567b68/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= -github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU= -github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8= -github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= -github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= -github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE= -github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw= -github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= +github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/containerd/containerd v1.2.10/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.4.0-beta.2.0.20200729163537-40b22ef07410/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.4.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.4.9/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.5.0-beta.1/go.mod h1:5HfvG1V2FsKesEGQ17k5/T7V960Tmcumvqn8Mc+pCYQ= -github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo/uBBoBORwEx6ardVcmKU= -github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI= -github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoTJseu1FGOKuoA4nNb2s= -github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= -github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= -github.com/containerd/containerd v1.5.8/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc5qtSuYx1YUb/s= -github.com/containerd/containerd v1.6.1 h1:oa2uY0/0G+JX4X7hpGCYvkp9FjUancz56kSNnb1sG3o= -github.com/containerd/containerd v1.6.1/go.mod h1:1nJz5xCZPusx6jJU8Frfct988y0NpumIq9ODB0kLtoE= -github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo= -github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y= -github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= -github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM= -github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rxcMX7HX1Dmibvk= -github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= -github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= -github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= -github.com/containerd/fifo v0.0.0-20201026212402-0724c46b320c/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= -github.com/containerd/fifo v0.0.0-20210316144830-115abcc95a1d/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= -github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= -github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU= -github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk= -github.com/containerd/go-cni v1.1.0/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= -github.com/containerd/go-cni v1.1.3/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= -github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= -github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= -github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g= -github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok= -github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok= -github.com/containerd/imgcrypt v1.0.1/go.mod h1:mdd8cEPW7TPgNG4FpuP3sGBiQ7Yi/zak9TYCG3juvb0= -github.com/containerd/imgcrypt v1.0.4-0.20210301171431-0ae5c75f59ba/go.mod h1:6TNsg0ctmizkrOgXRNQjAPFWpMYRWuiB6dSF4Pfa5SA= -github.com/containerd/imgcrypt v1.1.1-0.20210312161619-7ed62a527887/go.mod h1:5AZJNI6sLHJljKuI9IHnw1pWqo/F0nGDOuR9zgTs7ow= -github.com/containerd/imgcrypt v1.1.1/go.mod h1:xpLnwiQmEUJPvQoAapeb2SNCxz7Xr6PJrXQb0Dpc4ms= -github.com/containerd/imgcrypt v1.1.3/go.mod h1:/TPA1GIDXMzbj01yd8pIbQiLdQxed5ue1wb8bP7PQu4= -github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c= -github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= -github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY= -github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= -github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= -github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= -github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= -github.com/containerd/ttrpc v1.0.1/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= -github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= -github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ= -github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= -github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk= -github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= -github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= -github.com/containerd/zfs v0.0.0-20200918131355-0a33824f23a2/go.mod h1:8IgZOBdv8fAgXddBT4dBXJPtxyRsejFIpXoklgxgEjw= -github.com/containerd/zfs v0.0.0-20210301145711-11e8f1707f62/go.mod h1:A9zfAbMlQwE+/is6hi0Xw8ktpL+6glmqZYtevJgaB8Y= -github.com/containerd/zfs v0.0.0-20210315114300-dde8f0fda960/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= -github.com/containerd/zfs v0.0.0-20210324211415-d5c4544f0433/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= -github.com/containerd/zfs v1.0.0/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= -github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= -github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= -github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= -github.com/containernetworking/cni v1.0.1/go.mod h1:AKuhXbN5EzmD4yTNtfSsX3tPcmtrBI6QcRV0NiNt15Y= -github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM= -github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8= -github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE= -github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc= -github.com/containers/ocicrypt v1.1.0/go.mod h1:b8AOe0YR67uU8OqfVNcznfFpAzu3rdgUV4GP9qXPfu4= -github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY= -github.com/containers/ocicrypt v1.1.2/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= -github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= -github.com/coreos/go-iptables v0.6.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= -github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= -github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= -github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= -github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= -github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= -github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= -github.com/dhui/dktest v0.3.10 h1:0frpeeoM9pHouHjhLeZDuDTJ0PqjDTrycaHaMmkJAo8= -github.com/dhui/dktest v0.3.10/go.mod h1:h5Enh0nG3Qbo9WjNFRrwmKUaePEBhXMOygbz3Ww7Sz0= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= -github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v20.10.13+incompatible h1:5s7uxnKZG+b8hYWlPYUi6x1Sjpq2MSt96d15eLZeHyw= -github.com/docker/docker v20.10.13+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= +github.com/dhui/dktest v0.3.16 h1:i6gq2YQEtcrjKbeJpBkWjE8MmLZPYllcjOFbTZuPDnw= +github.com/dhui/dktest v0.3.16/go.mod h1:gYaA3LRmM8Z4vJl2MA0THIigJoZrwOansEOsp+kqxp0= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= +github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= -github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= -github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/finnbear/moderation v0.11.4 h1:bqGeFj+sScc3nIFxT3SZDXOqio3+AQ/UtZ+qyVgqiHs= github.com/finnbear/moderation v0.11.4/go.mod h1:IFowm0Qv42lFZkoHzVLYxTGN4CDI0mJRgYk+8BewbVE= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0uQR+pM/VdlL83bw= -github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= -github.com/gabriel-vasile/mimetype v1.3.1/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8= -github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8= -github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= -github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= -github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= -github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= -github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= -github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= -github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= +github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8= +github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-redis/redis/v8 v8.1.0/go.mod h1:isLoQT/NFSP7V67lyvM9GmdvLdyZ7pEhsXvvyQtnQTo= github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-redis/redis_rate/v9 v9.1.2 h1:H0l5VzoAtOE6ydd38j8MCq3ABlGLnvvbA1xDSVVCHgQ= github.com/go-redis/redis_rate/v9 v9.1.2/go.mod h1:oam2de2apSgRG8aJzwJddXbNu91Iyz1m8IKJE2vpvlQ= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= -github.com/gocql/gocql v0.0.0-20210515062232-b7ef815b4556/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= -github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= -github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= -github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU= -github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-migrate/migrate/v4 v4.15.2 h1:vU+M05vs6jWHKDdmE1Ecwj0BznygFc4QsdRe2E/L7kc= -github.com/golang-migrate/migrate/v4 v4.15.2/go.mod h1:f2toGLkYqD3JH+Todi4aZ2ZdbeUNx4sIwiOK96rE9Lw= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang-migrate/migrate/v4 v4.16.2 h1:8coYbMKUyInrFk1lfGfRovTLAW7PhWp8qQDT2iKfuoA= +github.com/golang-migrate/migrate/v4 v4.16.2/go.mod h1:pfcJX4nPHaVdc5nmdCikFBWtm+UBpiZjRNNsyBbp0/o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -644,9 +251,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -662,17 +266,12 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/flatbuffers v2.0.0+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -681,23 +280,14 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0= -github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -708,603 +298,224 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= -github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ= -github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw= github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= +github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= -github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= -github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= -github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QGdLI4y34qQGjGWO0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/intel/goresctrl v0.2.0/go.mod h1:+CZdzouYFn5EsxgqAQTEzMfwKwuc0fVdMrT9FCCAVRQ= github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac h1:w5wltlINIIqRTqQ64dASrCo0fM7k9nosPbKCZnkL0W0= github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac/go.mod h1:gyMTRVO+ZkEy7wQDyD++okPsBN2q127EpuShhHMWG54= -github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= -github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= -github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= -github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= -github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= -github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= -github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk= -github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= -github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= -github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= -github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= -github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.12.0 h1:/RvQ24k3TnNdfBSW0ou9EOi5jx2cX7zfE8n2nLKuiP0= -github.com/jackc/pgconn v1.12.0/go.mod h1:ZkhRC59Llhrq3oSfrikvwQ5NaxYExr6twkdkMLaKono= -github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= -github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= -github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= -github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= -github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.0.7/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.0 h1:brH0pCGBDkBW07HWlN/oSBXrmo3WB0UvZd1pIuDcL8Y= -github.com/jackc/pgproto3/v2 v2.3.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= -github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= -github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= -github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= -github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0= -github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= -github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= -github.com/jackc/pgtype v1.6.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= -github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.11.0 h1:u4uiGPz/1hryuXzyaBhSk6dnIyyG2683olG2OV+UUgs= -github.com/jackc/pgtype v1.11.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= -github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= -github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= -github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA= -github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= -github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= -github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA= -github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.16.0 h1:4k1tROTJctHotannFYzu77dY3bgtMRymQP7tXQjqpPk= -github.com/jackc/pgx/v4 v4.16.0/go.mod h1:N0A9sFdWzkw/Jy1lwoiB64F2+ugFZi987zRxcPez/wI= -github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY= +github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033 h1:R0efOJW2JdoZ7ValaK6iFhWHrlZFeRvV4alZbHg5hnQ= github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033/go.mod h1:JHpPOBFu/UpmWT79z9fw5lQn7Oem6lnkS3jN4ZQdfLQ= -github.com/jeffh/go.bdd v0.0.0-20120717032931-88f798ee0c74/go.mod h1:qNa9FlAfO0U/qNkzYBMH1JKYRMzC+sP9IcyV4U18l98= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= -github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= -github.com/jmoiron/sqlx v1.3.1/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= -github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g= +github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= -github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0= -github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= github.com/lab259/go-migration v1.3.1 h1:9ymcS7IywHzcl/6xePMhht9fLUgPeZFUNbrj0f3z2mU= github.com/lab259/go-migration v1.3.1/go.mod h1:9SB2RbONCWrBN7VXFLt/qOU6ar/uJNnaIGnHDkYK+lE= github.com/lab259/rlog/v2 v2.1.0/go.mod h1:Rfy8HYLxXb0s/1F98p8fRtrCiIwxA8q5HqsQmXLvKfM= -github.com/labstack/echo-contrib v0.13.0 h1:bzSG0SpuZZd7BmJLvsWtPfU23W0Enh3K0tok3aENVKA= -github.com/labstack/echo-contrib v0.13.0/go.mod h1:IF9+MJu22ADOZEHD+bAV67XMIO3vNXUy7Naz/ABPHEs= -github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI= -github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= -github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= -github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU= +github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4= +github.com/labstack/echo/v4 v4.11.2 h1:T+cTLQxWCDfqDEoydYm5kCobjmHwOwcv4OJAPHilmdE= +github.com/labstack/echo/v4 v4.11.2/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws= +github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= -github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= -github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4= +github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4= +github.com/lmittmann/tint v1.0.2 h1:9XZ+JvEzjvd3VNVugYqo3j+dl0NRju8k9FquAusJExM= +github.com/lmittmann/tint v1.0.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo= github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= -github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= -github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= -github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= -github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= +github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= +github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= -github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= -github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= -github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY= -github.com/microcosm-cc/bluemonday v1.0.18 h1:6HcxvXDAi3ARt3slx6nTesbvorIc3QeTzBNRvWktHBo= -github.com/microcosm-cc/bluemonday v1.0.18/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= +github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= -github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= -github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= -github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= -github.com/moby/sys/signal v0.6.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg= -github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ= -github.com/moby/sys/symlink v0.2.0/go.mod h1:7uZVF2dqJjG/NsClqul95CqKOBRQyYSNnJ6BMgR/gFs= -github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= -github.com/moby/term v0.0.0-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A= -github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= -github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= -github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mutecomm/go-sqlcipher/v4 v4.4.0/go.mod h1:PyN04SaWalavxRGH9E8ZftG6Ju7rsPrGmQRjrEaVpiY= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA= -github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= -github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/o1egl/paseto v1.0.0 h1:bwpvPu2au176w4IBlhbyUv/S5VPptERIA99Oap5qUd0= github.com/o1egl/paseto v1.0.0/go.mod h1:5HxsZPmw/3RI2pAwGo1HhOOwSdvBpcuVzO7uDkm+CLU= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= -github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= -github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0= -github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= -github.com/opencontainers/runc v1.1.0/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc= -github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= -github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqiriPsEqVhc+svHE= -github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= -github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= -github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= -github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= -github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= -github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4/v4 v4.1.8/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.0-20190522114515-bc1a522cf7b1/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI= github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg= github.com/pterm/pterm v0.12.30/go.mod h1:MOqLIyMOgmTDz9yorcYbcw+HsgoZo3BQfg2wtl3HEFE= github.com/pterm/pterm v0.12.31/go.mod h1:32ZAWZVXD7ZfG0s8qqHXePte42kdz8ECtRyEejaWgXU= github.com/pterm/pterm v0.12.33/go.mod h1:x+h2uL+n7CP/rel9+bImHD5lF3nM9vJj80k9ybiiTTE= github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5bUw8T8= -github.com/pterm/pterm v0.12.40 h1:LvQE43RYegVH+y5sCDcqjlbsRu0DlAecEn9FDfs9ePs= github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s= -github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/pterm/pterm v0.12.69 h1:fBCKnB8dSLAl8FlYRQAWYGp2WTI/Xm/tKJ21Hyo9USw= +github.com/pterm/pterm v0.12.69/go.mod h1:wl06ko9MHnqxz4oDV++IORDpjCzw6+mfrvf0MPj6fdk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= -github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= -github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= -github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= +github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= +github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591 h1:dCWBD4Xchp/XFIR/x6D2l74DtQHvIpHsmpPRHgH9oUo= github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591/go.mod h1:IXC7KN2FEuTEISdePm37qcFyXInAh6pfW35yDjbdfOM= github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9 h1:i3LYMwQ0zkh/BJ47vIZN+jBYqV4/f6DFoAsW8rwV490= github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9/go.mod h1:/NQ8ciRuH+vxYhrFlnX70gvXBugMYQbBygCRocFgSZ4= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/snowflakedb/gosnowflake v1.6.3/go.mod h1:6hLajn6yxuJ4xUHZegMekpq9rnQbGJ7TMwXjgTmA6lg= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= +github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us= +github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spate/glimage v0.0.0-20200505055513-fbdcc60a65e5 h1:i6p4jluRhb5P857lqMZDdpt/KuJxS9CnJU1Nqv8ts5k= -github.com/spate/glimage v0.0.0-20200505055513-fbdcc60a65e5/go.mod h1:F9YvJg9MlSd+PomE+6peEdsa/VdHFv4DYPXTwtfnHh8= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= -github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= +github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= -github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= -github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= +github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1312,237 +523,115 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/swaggo/echo-swagger v1.3.2 h1:D+3BNl8JMC6pKhA+egjh4LGI0jNesqlt77WahTHfTXQ= -github.com/swaggo/echo-swagger v1.3.2/go.mod h1:Sjj0O7Puf939HXhxhfZdR49MIrtcg3mLgdg3/qVcbyw= -github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 h1:+iNTcqQJy0OZ5jk6a5NLib47eqXK8uYcPX+O4+cBpEM= -github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= -github.com/swaggo/swag v1.8.1 h1:JuARzFX1Z1njbCGz+ZytBR15TFJwF2Q7fu8puJHhQYI= -github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= +github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= +github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= +github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= +github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04= +github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/thedevsaddam/gojsonq/v2 v2.5.2 h1:CoMVaYyKFsVj6TjU6APqAhAvC07hTI6IQen8PHzHYY0= github.com/thedevsaddam/gojsonq/v2 v2.5.2/go.mod h1:bv6Xa7kWy82uT0LnXPE2SzGqTj33TAEeR560MdJkiXs= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= -github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4= -github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/vektah/gqlparser/v2 v2.5.0 h1:GwEwy7AJsqPWrey0bHnn+3JLaHLZVT66wY/+O+Tf9SU= -github.com/vektah/gqlparser/v2 v2.5.0/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= -github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= -github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= -github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= -github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= -github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= +github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= +github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.8 h1:keHd+7LCPUPyQMb+DsO/OiZJuMoBEsOiBdONm+1nmPI= -github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.8/go.mod h1:svFuw6AcsvxQdwFiZF0BYk2XSfgXy1tSWE6L6sOJVeo= -github.com/vmihailenco/taskq/v3 v3.2.8 h1:Smrz4Fhqi+29fALjcjlETACVbzlra/MbmFY9YKfvjQI= -github.com/vmihailenco/taskq/v3 v3.2.8/go.mod h1:IFuypxi7Y0h+PcactlQOPf92Ssxg0FWxQZ8ptxYW/Zk= -github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= -github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9 h1:HPsSGLvvTXQRENUWUPTJOiwjQhimBHgJrCzp+cKzma0= +github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9/go.mod h1:SWuxQvsmwULAWKswSuEhJpR/ajBJKe1fSKecqUmAp5w= +github.com/vmihailenco/taskq/v3 v3.2.9 h1:QE1O8IJlh4xvSB9MJsnEBzNzmJc61y320xAyBeQZ/40= +github.com/vmihailenco/taskq/v3 v3.2.9/go.mod h1:ZoRbkYMZWEUKtKvYlLGKiaRQKUjdvwWAIs/WiW1Nwtg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= -github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= -github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= -go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= -go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= -go.etcd.io/etcd/pkg/v3 v3.5.0/go.mod h1:UzJGatBQ1lXChBkQF0AuAtkRQMYnHubxAEYIrC3MSsE= -go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= -go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4= -go.mongodb.org/mongo-driver v1.7.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= -go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc= -go.opentelemetry.io/contrib v1.7.0 h1:7jCRAqrnHPV9k9Km1RUTXvKJnvGL8UL3GklcCY0lAnk= -go.opentelemetry.io/contrib v1.7.0/go.mod h1:FlyPNX9s4U6MCsWEc5YAK4KzKNHFDsjrDUZijJiXvy8= -go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.32.0 h1:bkyJgifVcPo1w8HYf1K0ExtgdmNgxyVa02o/yFDrSAA= -go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.32.0/go.mod h1:rmdIBqEgyXERsERn9CjVXXPL9qAinIsID+X9AhBnzOQ= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0/go.mod h1:oVGt1LRbBOBq1A5BQLlUg9UaU/54aiHw8cgjV3aWZ/E= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0/go.mod h1:vEhqr0m4eTc+DWxfsXoXue2GBgV2uUwVznkGIHW/e5w= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= -go.opentelemetry.io/contrib/propagators/b3 v1.7.0 h1:oRAenUhj+GFttfIp3gj7HYVzBhPOHgq/dWPDSmLCXSY= -go.opentelemetry.io/contrib/propagators/b3 v1.7.0/go.mod h1:gXx7AhL4xXCF42gpm9dQvdohoDa2qeyEx4eIIxqK+h4= -go.opentelemetry.io/otel v0.11.0/go.mod h1:G8UCk+KooF2HLkgo8RHX9epABH/aRGYET7gQOqBVdB0= -go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= -go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= -go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= -go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= -go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= -go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 h1:7Yxsak1q4XrJ5y7XBnNwqWx9amMZvoidCctv62XOQ6Y= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0/go.mod h1:M1hVZHNxcbkAlcvrOMlpQ4YOO3Awf+4N2dxkZL3xm04= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0/go.mod h1:hO1KLR7jcKaDDKDkvI9dP/FIhpmna5lkqPUQdEjFAM8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 h1:cMDtmgJ5FpRvqx9x2Aq+Mm0O6K/zcUkH73SFz20TuBw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0/go.mod h1:ceUgdyfNv4h4gLxHR0WNfDiiVmZFodZhZSbOLhpxqXE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0/go.mod h1:keUU7UfnwWTWpJ+FWnyqmogPa82nuU5VUANFq49hlMY= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.3.0/go.mod h1:QNX1aly8ehqqX1LEa6YniTU7VY9I6R3X/oPxhGdTceE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0 h1:pLP0MH4MAqeTEV0g/4flxw9O8Is48uAIauAnjznbW50= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0/go.mod h1:aFXT9Ng2seM9eizF+LfKiyPBGy8xIZKwhusC1gIu3hA= -go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= -go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= -go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= -go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs= -go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0= -go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= -go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= -go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= -go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= -go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= -go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= -go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= -go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= -go.opentelemetry.io/proto/otlp v0.16.0 h1:WHzDWdXUvbc5bG2ObdrGfaNpQz7ft7QN9HHmJlbiB1E= -go.opentelemetry.io/proto/otlp v0.16.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.opentelemetry.io/contrib v1.20.0 h1:oXUiIQLlkbi9uZB/bt5B1WRLsrTKqb7bPpAQ+6htn2w= +go.opentelemetry.io/contrib v1.20.0/go.mod h1:gIzjwWFoGazJmtCaDgViqOSJPde2mCWzv60o0bWPcZs= +go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 h1:JJCIHAxGCB5HM3NxeIwFjHc087Xwk96TG9kaZU6TAec= +go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0/go.mod h1:Px9kH7SJ+NhsgWRtD/eMcs15Tyt4uL3rM7X54qv6pfA= +go.opentelemetry.io/contrib/propagators/b3 v1.20.0 h1:Yty9Vs4F3D6/liF1o6FNt0PvN85h/BJJ6DQKJ3nrcM0= +go.opentelemetry.io/contrib/propagators/b3 v1.20.0/go.mod h1:On4VgbkqYL18kbJlWsa18+cMNe6rYpBnPi1ARI/BrsU= +go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= +go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= +go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= +go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= +go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= +go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= +go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181025213731-e84da0312774/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200908183739-ae8ad444f925/go.mod h1:1phAWC201xIgDyaFpmDeZkgf70Q4Pd/CNqfRtVPtxNw= -golang.org/x/exp v0.0.0-20210220032938-85be41e4509f h1:GrkO5AtFUU9U/1f5ctbIBXtBGeSJbWwIYfIsTcFMaX4= golang.org/x/exp v0.0.0-20210220032938-85be41e4509f/go.mod h1:I6l2HNBLBZEcrOoCpyKLdY2lHoRZ8lI4x60KMCQDft4= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1554,7 +643,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= @@ -1568,38 +656,24 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190225153610-fe579d43d832/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1614,41 +688,21 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220728030405-41545e8bf201 h1:bvOltf3SADAfG05iRml8lAB3qjoEX5RCyN4K6G5v3N0= -golang.org/x/net v0.0.0-20220728030405-41545e8bf201/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1657,80 +711,45 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= +golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190812073006-9eafafc0a87e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1740,143 +759,79 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220317061510-51cd9980dadf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1884,7 +839,6 @@ golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1898,49 +852,28 @@ golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjs golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= -google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1960,38 +893,20 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190522204451-c2c4e71fbf69/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= @@ -2000,7 +915,6 @@ google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200117163144-32f20d992d24/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -2009,70 +923,31 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79/go.mod h1:yiaVoXHpRzHGyxV3o4DktVWY4mSUErTKaeEOq6C3t3U= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220111164026-67b88f271998/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= +google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k= +google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= @@ -2082,27 +957,11 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -2115,45 +974,27 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= -gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -2163,18 +1004,10 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg= -gorm.io/driver/postgres v1.3.5 h1:oVLmefGqBTlgeEVG6LKnH6krOlo4TZ3Q/jIK21KUMlw= -gorm.io/driver/postgres v1.3.5/go.mod h1:EGCWefLFQSVFrHGy4J8EtiHCWX5Q8t0yz2Jt9aKkGzU= -gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= -gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= -gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM= -gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= -gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= +gorm.io/driver/postgres v1.5.3 h1:qKGY5CPHOuj47K/VxbCXJfFvIUeqMSXXadqdCY+MbBU= +gorm.io/driver/postgres v1.5.3/go.mod h1:F+LtvlFhZT7UBiA81mC9W6Su3D4WUhSboc/36QZU0gk= +gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= +gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -2182,85 +1015,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo= -k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ= -k8s.io/api v0.20.6/go.mod h1:X9e8Qag6JV/bL5G6bU8sdVRltWKmdHsFUGS3eVndqE8= -k8s.io/api v0.22.5/go.mod h1:mEhXyLaSD1qTOf40rRiKXkc+2iCem09rWLlFwhCEiAs= -k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= -k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= -k8s.io/apimachinery v0.20.6/go.mod h1:ejZXtW1Ra6V1O5H8xPBGz+T3+4gfkTCeExAHKU57MAc= -k8s.io/apimachinery v0.22.1/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= -k8s.io/apimachinery v0.22.5/go.mod h1:xziclGKwuuJ2RM5/rSFQSYAj0zdbci3DH8kj+WvyN0U= -k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= -k8s.io/apiserver v0.20.4/go.mod h1:Mc80thBKOyy7tbvFtB4kJv1kbdD0eIH8k8vianJcbFM= -k8s.io/apiserver v0.20.6/go.mod h1:QIJXNt6i6JB+0YQRNcS0hdRHJlMhflFmsBDeSgT1r8Q= -k8s.io/apiserver v0.22.5/go.mod h1:s2WbtgZAkTKt679sYtSudEQrTGWUSQAPe6MupLnlmaQ= -k8s.io/client-go v0.20.1/go.mod h1:/zcHdt1TeWSd5HoUe6elJmHSQ6uLLgp4bIJHVEuy+/Y= -k8s.io/client-go v0.20.4/go.mod h1:LiMv25ND1gLUdBeYxBIwKpkSC5IsozMMmOOeSJboP+k= -k8s.io/client-go v0.20.6/go.mod h1:nNQMnOvEUEsOzRRFIIkdmYOjAZrC8bgq0ExboWSU1I0= -k8s.io/client-go v0.22.5/go.mod h1:cs6yf/61q2T1SdQL5Rdcjg9J1ElXSwbjSrW2vFImM4Y= -k8s.io/code-generator v0.19.7/go.mod h1:lwEq3YnLYb/7uVXLorOJfxg+cUu2oihFhHZ0n9NIla0= -k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk= -k8s.io/component-base v0.20.4/go.mod h1:t4p9EdiagbVCJKrQ1RsA5/V4rFQNDfRlevJajlGwgjI= -k8s.io/component-base v0.20.6/go.mod h1:6f1MPBAeI+mvuts3sIdtpjljHWBQ2cIy38oBIWMYnrM= -k8s.io/component-base v0.22.5/go.mod h1:VK3I+TjuF9eaa+Ln67dKxhGar5ynVbwnGrUiNF4MqCI= -k8s.io/cri-api v0.17.3/go.mod h1:X1sbHmuXhwaHs9xxYffLqJogVsnI+f6cPRcgPel7ywM= -k8s.io/cri-api v0.20.1/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= -k8s.io/cri-api v0.20.4/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= -k8s.io/cri-api v0.20.6/go.mod h1:ew44AjNXwyn1s0U4xCKGodU7J1HzBeZ1MpGrpa5r8Yc= -k8s.io/cri-api v0.23.1/go.mod h1:REJE3PSU0h/LOV1APBrupxrEJqnoxZC8KWzkBUHwrK4= -k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= -k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= -k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -modernc.org/b v1.0.0/go.mod h1:uZWcZfRj1BpYzfN9JTerzlNUnnPsV9O2ZA8JsRcubNg= -modernc.org/cc/v3 v3.32.4/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= -modernc.org/ccgo/v3 v3.9.2/go.mod h1:gnJpy6NIVqkETT+L5zPsQFj7L2kkhfPMzOghRNv/CFo= -modernc.org/db v1.0.0/go.mod h1:kYD/cO29L/29RM0hXYl4i3+Q5VojL31kTUVpVJDw0s8= -modernc.org/file v1.0.0/go.mod h1:uqEokAEn1u6e+J45e54dsEA/pw4o7zLrA2GwyntZzjw= -modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= -modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= -modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/internal v1.0.0/go.mod h1:VUD/+JAkhCpvkUitlEOnhpVxCgsBI90oTzSCRcqQVSM= -modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= -modernc.org/libc v1.9.5/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= -modernc.org/lldb v1.0.0/go.mod h1:jcRvJGWfCGodDZz8BPwiKMJxGJngQ/5DrRapkQnLob8= -modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= -modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= -modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/ql v1.0.0/go.mod h1:xGVyrLIatPcO2C1JvI/Co8c0sr6y91HKFNy4pt9JXEY= -modernc.org/sortutil v1.1.0/go.mod h1:ZyL98OQHJgH9IEfN71VsamvJgrtRX9Dj2gX+vH86L1k= -modernc.org/sqlite v1.10.6/go.mod h1:Z9FEjUtZP4qFEg6/SiADg9XCER7aYy9a/j7Pg9P7CPs= -modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= -modernc.org/tcl v1.5.2/go.mod h1:pmJYOLgpiys3oI4AeAafkcUfE+TKKilminxNyU/+Zlo= -modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= -modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= -modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= -sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/gql/directive.go b/gql/directive.go index 72657eee..4eb404a7 100644 --- a/gql/directive.go +++ b/gql/directive.go @@ -37,7 +37,7 @@ type Directive struct { generated.DirectiveRoot } -func canEditMod(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (interface{}, error) { +func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) dbMod := postgres.GetModByID(ctx, getArgument(ctx, field).(string)) @@ -57,7 +57,7 @@ func canEditMod(ctx context.Context, obj interface{}, next graphql.Resolver, fie return nil, errors.New("user not authorized to perform this action") } -func canEditModCompatibility(ctx context.Context, obj interface{}, next graphql.Resolver, field *string) (interface{}, error) { +func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Resolver, field *string) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleEditAnyModCompatibility) || user.Has(ctx, auth.RoleEditAnyContent) { @@ -81,7 +81,7 @@ func canEditModCompatibility(ctx context.Context, obj interface{}, next graphql. return nil, errors.New("user not authorized to perform this action") } -func canEditVersion(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (interface{}, error) { +func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) dbVersion := postgres.GetVersion(ctx, getArgument(ctx, field).(string)) @@ -128,7 +128,7 @@ func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, fi return nil, errors.New("user not authorized to perform this action") } -func canEditGuide(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (interface{}, error) { +func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) dbGuide := postgres.GetGuideByID(ctx, getArgument(ctx, field).(string)) @@ -148,7 +148,7 @@ func canEditGuide(ctx context.Context, obj interface{}, next graphql.Resolver, f return nil, errors.New("user not authorized to perform this action") } -func isLoggedIn(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func isLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { header := ctx.Value(util.ContextHeader{}).(http.Header) authorization := header.Get("Authorization") @@ -171,7 +171,7 @@ func isLoggedIn(ctx context.Context, obj interface{}, next graphql.Resolver) (in return next(userCtx) } -func isNotLoggedIn(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func isNotLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { header := ctx.Value(util.ContextHeader{}).(http.Header) authorization := header.Get("Authorization") @@ -190,7 +190,7 @@ func getArgument(ctx context.Context, key string) interface{} { return graphql.GetFieldContext(ctx).Args[key] } -func canApproveMods(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canApproveMods(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleApproveMods) { @@ -200,7 +200,7 @@ func canApproveMods(ctx context.Context, obj interface{}, next graphql.Resolver) return nil, errors.New("user not authorized to perform this action") } -func canApproveVersions(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canApproveVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleApproveVersions) { @@ -210,7 +210,7 @@ func canApproveVersions(ctx context.Context, obj interface{}, next graphql.Resol return nil, errors.New("user not authorized to perform this action") } -func canEditUsers(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canEditUsers(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleEditUsers) { @@ -220,7 +220,7 @@ func canEditUsers(ctx context.Context, obj interface{}, next graphql.Resolver) ( return nil, errors.New("user not authorized to perform this action") } -func canEditSMLVersions(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canEditSMLVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleEditSMLVersions) { @@ -230,7 +230,7 @@ func canEditSMLVersions(ctx context.Context, obj interface{}, next graphql.Resol return nil, errors.New("user not authorized to perform this action") } -func canEditBootstrapVersions(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canEditBootstrapVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleEditBootstrapVersions) { @@ -240,7 +240,7 @@ func canEditBootstrapVersions(ctx context.Context, obj interface{}, next graphql return nil, errors.New("user not authorized to perform this action") } -func canEditAnnouncements(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canEditAnnouncements(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleEditAnnouncements) { @@ -250,7 +250,7 @@ func canEditAnnouncements(ctx context.Context, obj interface{}, next graphql.Res return nil, errors.New("user not authorized to perform this action") } -func canManageTags(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { +func canManageTags(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { user := ctx.Value(postgres.UserKey{}).(*postgres.User) if user.Has(ctx, auth.RoleManageTags) { diff --git a/gql/resolver_announcements.go b/gql/resolver_announcements.go index 47b9d163..7e5e0b54 100644 --- a/gql/resolver_announcements.go +++ b/gql/resolver_announcements.go @@ -2,6 +2,7 @@ package gql import ( "context" + "fmt" "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" @@ -17,7 +18,7 @@ func (r *mutationResolver) CreateAnnouncement(ctx context.Context, announcement val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&announcement); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } dbAnnouncement := &postgres.Announcement{ @@ -53,7 +54,7 @@ func (r *mutationResolver) UpdateAnnouncement(ctx context.Context, announcementI val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&announcement); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } dbAnnouncement := postgres.GetAnnouncementByID(newCtx, announcementID) diff --git a/gql/resolver_bootstrap_versions.go b/gql/resolver_bootstrap_versions.go index 5a1ecfc8..e011e072 100644 --- a/gql/resolver_bootstrap_versions.go +++ b/gql/resolver_bootstrap_versions.go @@ -2,6 +2,7 @@ package gql import ( "context" + "fmt" "time" "github.com/99designs/gqlgen/graphql" @@ -20,12 +21,12 @@ func (r *mutationResolver) CreateBootstrapVersion(ctx context.Context, bootstrap val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&bootstrapVersion); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } date, err := time.Parse(time.RFC3339Nano, bootstrapVersion.Date) if err != nil { - return nil, errors.Wrap(err, "failed to parse date") + return nil, fmt.Errorf("failed to parse date: %w", err) } dbBootstrapVersion := &postgres.BootstrapVersion{ @@ -39,7 +40,7 @@ func (r *mutationResolver) CreateBootstrapVersion(ctx context.Context, bootstrap resultBootstrapVersion, err := postgres.CreateBootstrapVersion(newCtx, dbBootstrapVersion) if err != nil { - return nil, errors.Wrap(err, "failed to create bootstrap version") + return nil, fmt.Errorf("failed to create bootstrap version: %w", err) } return DBBootstrapVersionToGenerated(resultBootstrapVersion), nil @@ -51,7 +52,7 @@ func (r *mutationResolver) UpdateBootstrapVersion(ctx context.Context, bootstrap val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&bootstrapVersion); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } dbBootstrapVersion := postgres.GetBootstrapVersionByID(newCtx, bootstrapVersionID) @@ -94,7 +95,7 @@ func (r *queryResolver) GetBootstrapVersion(ctx context.Context, bootstrapVersio return DBBootstrapVersionToGenerated(postgres.GetBootstrapVersionByID(newCtx, bootstrapVersionID)), nil } -func (r *queryResolver) GetBootstrapVersions(ctx context.Context, filter map[string]interface{}) (*generated.GetBootstrapVersions, error) { +func (r *queryResolver) GetBootstrapVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetBootstrapVersions, error) { wrapper, _ := WrapQueryTrace(ctx, "getBootstrapVersions") defer wrapper.end() return &generated.GetBootstrapVersions{}, nil @@ -102,7 +103,7 @@ func (r *queryResolver) GetBootstrapVersions(ctx context.Context, filter map[str type getBootstrapVersionsResolver struct{ *Resolver } -func (r *getBootstrapVersionsResolver) BootstrapVersions(ctx context.Context, obj *generated.GetBootstrapVersions) ([]*generated.BootstrapVersion, error) { +func (r *getBootstrapVersionsResolver) BootstrapVersions(ctx context.Context, _ *generated.GetBootstrapVersions) ([]*generated.BootstrapVersion, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetBootstrapVersions.bootstrapVersions") defer wrapper.end() @@ -132,7 +133,7 @@ func (r *getBootstrapVersionsResolver) BootstrapVersions(ctx context.Context, ob return converted, nil } -func (r *getBootstrapVersionsResolver) Count(ctx context.Context, obj *generated.GetBootstrapVersions) (int, error) { +func (r *getBootstrapVersionsResolver) Count(ctx context.Context, _ *generated.GetBootstrapVersions) (int, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetBootstrapVersions.count") defer wrapper.end() diff --git a/gql/resolver_guides.go b/gql/resolver_guides.go index 33d5252e..481ab6e2 100644 --- a/gql/resolver_guides.go +++ b/gql/resolver_guides.go @@ -2,6 +2,7 @@ package gql import ( "context" + "fmt" "time" "github.com/99designs/gqlgen/graphql" @@ -21,7 +22,7 @@ func (r *mutationResolver) CreateGuide(ctx context.Context, guide generated.NewG val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&guide); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } dbGuide := &postgres.Guide{ @@ -55,7 +56,7 @@ func (r *mutationResolver) UpdateGuide(ctx context.Context, guideID string, guid val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&guide); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } err := postgres.ResetGuideTags(newCtx, guideID, guide.TagIDs) @@ -108,7 +109,7 @@ func (r *queryResolver) GetGuide(ctx context.Context, guideID string) (*generate return DBGuideToGenerated(guide), nil } -func (r *queryResolver) GetGuides(ctx context.Context, filter map[string]interface{}) (*generated.GetGuides, error) { +func (r *queryResolver) GetGuides(ctx context.Context, _ map[string]interface{}) (*generated.GetGuides, error) { wrapper, _ := WrapQueryTrace(ctx, "getGuides") defer wrapper.end() return &generated.GetGuides{}, nil @@ -116,7 +117,7 @@ func (r *queryResolver) GetGuides(ctx context.Context, filter map[string]interfa type getGuidesResolver struct{ *Resolver } -func (r *getGuidesResolver) Guides(ctx context.Context, obj *generated.GetGuides) ([]*generated.Guide, error) { +func (r *getGuidesResolver) Guides(ctx context.Context, _ *generated.GetGuides) ([]*generated.Guide, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetGuides.guides") defer wrapper.end() @@ -146,7 +147,7 @@ func (r *getGuidesResolver) Guides(ctx context.Context, obj *generated.GetGuides return converted, nil } -func (r *getGuidesResolver) Count(ctx context.Context, obj *generated.GetGuides) (int, error) { +func (r *getGuidesResolver) Count(ctx context.Context, _ *generated.GetGuides) (int, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetGuides.count") defer wrapper.end() diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index f9010537..fc73f1f9 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -3,6 +3,7 @@ package gql import ( "bytes" "context" + "fmt" "io" "strings" "time" @@ -38,7 +39,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&mod); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } if DisallowedModReferences[strings.ToLower(mod.ModReference)] { @@ -69,13 +70,13 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) if mod.Logo != nil { file, err := io.ReadAll(mod.Logo.File) if err != nil { - return nil, errors.Wrap(err, "failed to read logo file") + return nil, fmt.Errorf("failed to read logo file: %w", err) } logoData, err = converter.ConvertAnyImageToWebp(ctx, file) if err != nil { - return nil, errors.Wrap(err, "failed to convert logo file") + return nil, fmt.Errorf("failed to convert logo file: %w", err) } } else { dbMod.Logo = "" @@ -110,7 +111,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&mod); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } if mod.TagIDs != nil { @@ -141,7 +142,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene if mod.Logo != nil { file, err := io.ReadAll(mod.Logo.File) if err != nil { - return nil, errors.Wrap(err, "failed to read logo file") + return nil, fmt.Errorf("failed to read logo file: %w", err) } logoData, err := converter.ConvertAnyImageToWebp(ctx, file) @@ -305,25 +306,25 @@ func (r *queryResolver) GetModByReference(ctx context.Context, modReference stri return DBModToGenerated(mod), nil } -func (r *queryResolver) GetMods(ctx context.Context, filter map[string]interface{}) (*generated.GetMods, error) { +func (r *queryResolver) GetMods(ctx context.Context, _ map[string]interface{}) (*generated.GetMods, error) { wrapper, _ := WrapQueryTrace(ctx, "getMods") defer wrapper.end() return &generated.GetMods{}, nil } -func (r *queryResolver) GetUnapprovedMods(ctx context.Context, filter map[string]interface{}) (*generated.GetMods, error) { +func (r *queryResolver) GetUnapprovedMods(ctx context.Context, _ map[string]interface{}) (*generated.GetMods, error) { wrapper, _ := WrapQueryTrace(ctx, "getUnapprovedMods") defer wrapper.end() return &generated.GetMods{}, nil } -func (r *queryResolver) GetMyMods(ctx context.Context, filter map[string]interface{}) (*generated.GetMyMods, error) { +func (r *queryResolver) GetMyMods(ctx context.Context, _ map[string]interface{}) (*generated.GetMyMods, error) { wrapper, _ := WrapQueryTrace(ctx, "getMyMods") defer wrapper.end() return &generated.GetMyMods{}, nil } -func (r *queryResolver) GetMyUnapprovedMods(ctx context.Context, filter map[string]interface{}) (*generated.GetMyMods, error) { +func (r *queryResolver) GetMyUnapprovedMods(ctx context.Context, _ map[string]interface{}) (*generated.GetMyMods, error) { wrapper, _ := WrapQueryTrace(ctx, "getMyUnapprovedMods") defer wrapper.end() return &generated.GetMyMods{}, nil @@ -331,7 +332,7 @@ func (r *queryResolver) GetMyUnapprovedMods(ctx context.Context, filter map[stri type getModsResolver struct{ *Resolver } -func (r *getModsResolver) Mods(ctx context.Context, obj *generated.GetMods) ([]*generated.Mod, error) { +func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*generated.Mod, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetMods.mods") defer wrapper.end() @@ -361,7 +362,7 @@ func (r *getModsResolver) Mods(ctx context.Context, obj *generated.GetMods) ([]* return converted, nil } -func (r *getModsResolver) Count(ctx context.Context, obj *generated.GetMods) (int, error) { +func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetMods.count") defer wrapper.end() @@ -382,7 +383,7 @@ func (r *getModsResolver) Count(ctx context.Context, obj *generated.GetMods) (in type getMyModsResolver struct{ *Resolver } -func (r *getMyModsResolver) Mods(ctx context.Context, obj *generated.GetMyMods) ([]*generated.Mod, error) { +func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([]*generated.Mod, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetMyMods.mods") defer wrapper.end() @@ -418,7 +419,7 @@ func (r *getMyModsResolver) Mods(ctx context.Context, obj *generated.GetMyMods) return converted, nil } -func (r *getMyModsResolver) Count(ctx context.Context, obj *generated.GetMyMods) (int, error) { +func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) (int, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetMyMods.count") defer wrapper.end() diff --git a/gql/resolver_oauth.go b/gql/resolver_oauth.go index b8189f0b..9aab4eef 100644 --- a/gql/resolver_oauth.go +++ b/gql/resolver_oauth.go @@ -3,6 +3,7 @@ package gql import ( "bytes" "context" + "fmt" "net/http" "net/url" @@ -21,7 +22,7 @@ func (r *queryResolver) GetOAuthOptions(ctx context.Context, callbackURL string) unescapedURL, err := url.PathUnescape(callbackURL) if err != nil { - return nil, errors.Wrap(err, "unable to unescape callback url") + return nil, fmt.Errorf("unable to unescape callback url: %w", err) } authOptions := oauth.GetOAuthOptions(unescapedURL) diff --git a/gql/resolver_sml_versions.go b/gql/resolver_sml_versions.go index a5859f55..72e0d14a 100644 --- a/gql/resolver_sml_versions.go +++ b/gql/resolver_sml_versions.go @@ -2,6 +2,7 @@ package gql import ( "context" + "fmt" "time" "github.com/99designs/gqlgen/graphql" @@ -20,12 +21,12 @@ func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion gene val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&smlVersion); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } date, err := time.Parse(time.RFC3339Nano, smlVersion.Date) if err != nil { - return nil, errors.Wrap(err, "failed to parse date") + return nil, fmt.Errorf("failed to parse date: %w", err) } dbSMLVersion := &postgres.SMLVersion{ @@ -62,7 +63,7 @@ func (r *mutationResolver) UpdateSMLVersion(ctx context.Context, smlVersionID st val := ctx.Value(util.ContextValidator{}).(*validator.Validate) if err := val.Struct(&smlVersion); err != nil { - return nil, errors.Wrap(err, "validation failed") + return nil, fmt.Errorf("validation failed: %w", err) } dbSMLTargets := postgres.GetSMLVersionTargets(newCtx, smlVersionID) @@ -137,7 +138,7 @@ func (r *queryResolver) GetSMLVersion(ctx context.Context, smlVersionID string) return DBSMLVersionToGenerated(postgres.GetSMLVersionByID(newCtx, smlVersionID)), nil } -func (r *queryResolver) GetSMLVersions(ctx context.Context, filter map[string]interface{}) (*generated.GetSMLVersions, error) { +func (r *queryResolver) GetSMLVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetSMLVersions, error) { wrapper, _ := WrapQueryTrace(ctx, "getSMLVersions") defer wrapper.end() return &generated.GetSMLVersions{}, nil @@ -145,7 +146,7 @@ func (r *queryResolver) GetSMLVersions(ctx context.Context, filter map[string]in type getSMLVersionsResolver struct{ *Resolver } -func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, obj *generated.GetSMLVersions) ([]*generated.SMLVersion, error) { +func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, _ *generated.GetSMLVersions) ([]*generated.SMLVersion, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetSMLVersions.smlVersions") defer wrapper.end() @@ -175,7 +176,7 @@ func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, obj *generated return converted, nil } -func (r *getSMLVersionsResolver) Count(ctx context.Context, obj *generated.GetSMLVersions) (int, error) { +func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLVersions) (int, error) { wrapper, newCtx := WrapQueryTrace(ctx, "GetSMLVersions.count") defer wrapper.end() diff --git a/gql/resolver_users.go b/gql/resolver_users.go index 6342880d..ef28edf7 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -7,6 +7,7 @@ import ( "crypto/sha256" "encoding/base64" "encoding/hex" + "fmt" "io" "net/http" "net/url" @@ -36,7 +37,7 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, userID string, input if input.Avatar != nil { file, err := io.ReadAll(input.Avatar.File) if err != nil { - return nil, errors.Wrap(err, "failed to read avatar file") + return nil, fmt.Errorf("failed to read avatar file: %w", err) } avatarData, err := converter.ConvertAnyImageToWebp(ctx, file) @@ -153,7 +154,7 @@ func (r *userResolver) Guides(ctx context.Context, obj *generated.User) ([]*gene return converted, nil } -func (r *userResolver) Groups(ctx context.Context, obj *generated.User) ([]*generated.Group, error) { +func (r *userResolver) Groups(ctx context.Context, _ *generated.User) ([]*generated.Group, error) { wrapper, newCtx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() @@ -172,7 +173,7 @@ func (r *userResolver) Groups(ctx context.Context, obj *generated.User) ([]*gene return converted, nil } -func (r *userResolver) Roles(ctx context.Context, obj *generated.User) (*generated.UserRoles, error) { +func (r *userResolver) Roles(ctx context.Context, _ *generated.User) (*generated.UserRoles, error) { wrapper, newCtx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() @@ -261,7 +262,7 @@ func (r *mutationResolver) DiscourseSso(ctx context.Context, sso string, sig str nonceString, err := base64.StdEncoding.DecodeString(sso) if err != nil { - return nil, errors.Wrap(err, "failed to decode sso") + return nil, fmt.Errorf("failed to decode sso: %w", err) } user := ctx.Value(postgres.UserKey{}).(*postgres.User) diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index 4d2d216e..c460e50f 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -3,14 +3,16 @@ package gql import ( "bytes" "context" + "fmt" "io" + "log/slog" "runtime/debug" "time" "github.com/99designs/gqlgen/graphql" + "github.com/Vilsol/slox" "github.com/dgraph-io/ristretto" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/dataloader" "github.com/satisfactorymodding/smr-api/db/postgres" @@ -72,7 +74,7 @@ func (r *mutationResolver) UploadVersionPart(ctx context.Context, modID string, // TODO Optimize fileData, err := io.ReadAll(file.File) if err != nil { - return false, errors.Wrap(err, "failed to read file") + return false, fmt.Errorf("failed to read file: %w", err) } success, _ := storage.UploadMultipartMod(ctx, mod.ID, mod.Name, versionID, int64(part), bytes.NewReader(fileData)) @@ -98,33 +100,35 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri return false, errors.New("you must update your mod reference on the site to match your mod_reference in your data.json") } - log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finalization gql call") + newCtx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) + + slox.Info(newCtx, "finalization gql call") go func(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) { defer func() { if r := recover(); r != nil { - log.Error().Interface("recover", r).Str("stack", string(debug.Stack())).Msgf("recovered from version finalization") + slox.Error(ctx, "recovered from version finalization", slog.Any("recover", r), slog.String("stack", string(debug.Stack()))) if err := redis.StoreVersionUploadState(versionID, nil, errors.New("internal error, please try again, if it fails again, please report on discord")); err != nil { - log.Error().Err(err).Msg("failed to store version upload state") + slox.Error(ctx, "failed to store version upload state", slog.Any("err", err)) } } }() - log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("calling FinalizeVersionUploadAsync") + slox.Info(ctx, "calling FinalizeVersionUploadAsync") data, err := FinalizeVersionUploadAsync(ctx, mod, versionID, version) if err2 := redis.StoreVersionUploadState(versionID, data, err); err2 != nil { - log.Err(err2).Msg("error storing redis state") + slox.Error(ctx, "error storing redis state", slog.Any("err", err)) return } - log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finished FinalizeVersionUploadAsync") + slox.Info(ctx, "finished FinalizeVersionUploadAsync") if err != nil { - log.Err(err).Msgf("error completing version upload [%s]", versionID) + slox.Error(ctx, "error completing version upload", slog.Any("err", err)) } else { - log.Info().Msgf("completed version upload: %s", versionID) + slox.Info(ctx, "completed version upload") } }(util.ReWrapCtx(ctx), mod, versionID, version) diff --git a/gql/versions.go b/gql/versions.go index de9a28b1..14ec5ba7 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -3,11 +3,13 @@ package gql import ( "context" "encoding/json" + "fmt" "io" + "log/slog" "time" + "github.com/Vilsol/slox" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" @@ -19,9 +21,9 @@ import ( ) func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) (*generated.CreateVersionResponse, error) { - l := log.With().Str("mod_id", mod.ID).Str("version_id", versionID).Logger() + ctx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) - l.Info().Msg("Creating multipart upload") + slox.Info(ctx, "Creating multipart upload") success, _ := storage.CompleteUploadMultipartMod(ctx, mod.ID, mod.Name, versionID) if !success { @@ -39,13 +41,13 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI fileData, err := io.ReadAll(modFile) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) - return nil, errors.Wrap(err, "failed reading mod file") + return nil, fmt.Errorf("failed reading mod file: %w", err) } modInfo, err := validation.ExtractModInfo(ctx, fileData, true, true, mod.ModReference) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) - return nil, errors.Wrap(err, "failed extracting mod info") + return nil, fmt.Errorf("failed extracting mod info: %w", err) } if modInfo.ModReference != mod.ModReference { @@ -122,7 +124,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI jsonData, err := json.Marshal(modInfo.Metadata) if err != nil { - log.Err(err).Msgf("[%s] failed serializing", dbVersion.ID) + slox.Error(ctx, "failed serializing", slog.Any("err", err), slog.String("version_id", dbVersion.ID)) } else { metadata := string(jsonData) dbVersion.Metadata = &metadata @@ -145,7 +147,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI separateSuccess := true for _, target := range targets { - log.Info().Str("target", target.TargetName).Str("mod", mod.Name).Str("version", dbVersion.Version).Msg("separating mod") + slox.Info(ctx, "separating mod", slog.String("target", target.TargetName), slog.String("mod", mod.Name), slog.String("version", dbVersion.Version)) success, key, hash, size := storage.SeparateModTarget(ctx, fileData, mod.ID, mod.Name, dbVersion.Version, target.TargetName) if !success { @@ -199,7 +201,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI go integrations.NewVersion(util.ReWrapCtx(ctx), dbVersion) } else { - l.Info().Msg("Submitting version job for virus scan") + slox.Info(ctx, "Submitting version job for virus scan") jobs.SubmitJobScanModOnVirusTotalTask(ctx, mod.ID, dbVersion.ID, true) } diff --git a/integrations/discord.go b/integrations/discord.go index 81347f6d..4bc435b7 100644 --- a/integrations/discord.go +++ b/integrations/discord.go @@ -6,12 +6,13 @@ import ( "encoding/json" "html" "io" + "log/slog" "net/http" "runtime/debug" "strings" + "github.com/Vilsol/slox" "github.com/microcosm-cc/bluemonday" - "github.com/rs/zerolog/log" "github.com/russross/blackfriday" "github.com/spf13/viper" @@ -59,7 +60,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { payloadJSON, err := json.Marshal(payload) if err != nil { - log.Err(err).Msg("error marshaling discord webhook") + slox.Error(ctx, "error marshaling discord webhook", slog.Any("err", err)) return } @@ -78,7 +79,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { } func NewVersion(ctx context.Context, version *postgres.Version) { - log.Info().Str("stack", string(debug.Stack())).Msg("new version discord webhook") + slox.Info(ctx, "new version discord webhook", slog.String("stack", string(debug.Stack()))) if version == nil { return @@ -143,7 +144,7 @@ func NewVersion(ctx context.Context, version *postgres.Version) { payloadJSON, err := json.Marshal(payload) if err != nil { - log.Err(err).Msg("error marshaling discord webhook") + slox.Error(ctx, "error marshaling discord webhook", slog.Any("err", err)) return } diff --git a/migrations/code.go b/migrations/code.go index cbb9c98a..fc5e13ff 100644 --- a/migrations/code.go +++ b/migrations/code.go @@ -2,12 +2,11 @@ package migrations import ( "context" + "log/slog" "os" "strings" "github.com/lab259/go-migration" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" postgres2 "github.com/satisfactorymodding/smr-api/db/postgres" @@ -15,14 +14,12 @@ import ( _ "github.com/satisfactorymodding/smr-api/migrations/code" ) -type codeMigrationLogger struct { - log *zerolog.Logger -} +type codeMigrationLogger struct{} func (c codeMigrationLogger) Write(p []byte) (int, error) { message := strings.TrimRight(string(p), "\n") if len(message) > 0 { - log.Info().Msg(message) + slog.Info(message) } return len(p), nil } @@ -31,7 +28,7 @@ func codeMigrations(ctx context.Context) { source := migration.DefaultCodeSource() // TODO Custom reporter, this one's very ugly - reporter := migration.NewDefaultReporterWithParams(codeMigrationLogger{log: &log.Logger}, os.Exit) + reporter := migration.NewDefaultReporterWithParams(codeMigrationLogger{}, os.Exit) db, _ := postgres2.DBCtx(ctx).DB() manager := migration.NewDefaultManager(migration.NewPostgreSQLTarget(db), source) diff --git a/migrations/code/20200426221900_test_new_migration.go b/migrations/code/20200426221900_test_new_migration.go index 936920e3..488054c0 100644 --- a/migrations/code/20200426221900_test_new_migration.go +++ b/migrations/code/20200426221900_test_new_migration.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20200501224200_parse_paks.go b/migrations/code/20200501224200_parse_paks.go index 936920e3..488054c0 100644 --- a/migrations/code/20200501224200_parse_paks.go +++ b/migrations/code/20200501224200_parse_paks.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20200524203800_after_reference_fix.go b/migrations/code/20200524203800_after_reference_fix.go index f9dbec10..311c6ff2 100644 --- a/migrations/code/20200524203800_after_reference_fix.go +++ b/migrations/code/20200524203800_after_reference_fix.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, false, nil, nil) + utils.ReindexAllModFiles(context.TODO(), false, nil, nil) return nil }, ) diff --git a/migrations/code/20200621195500_after_id_length_fix.go b/migrations/code/20200621195500_after_id_length_fix.go index f9dbec10..311c6ff2 100644 --- a/migrations/code/20200621195500_after_id_length_fix.go +++ b/migrations/code/20200621195500_after_id_length_fix.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, false, nil, nil) + utils.ReindexAllModFiles(context.TODO(), false, nil, nil) return nil }, ) diff --git a/migrations/code/20200622003600_after_validation_disable.go b/migrations/code/20200622003600_after_validation_disable.go index 936920e3..488054c0 100644 --- a/migrations/code/20200622003600_after_validation_disable.go +++ b/migrations/code/20200622003600_after_validation_disable.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20200629093800_copy_to_new_bucket.go b/migrations/code/20200629093800_copy_to_new_bucket.go index 9e6aac69..e16ce85b 100644 --- a/migrations/code/20200629093800_copy_to_new_bucket.go +++ b/migrations/code/20200629093800_copy_to_new_bucket.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/redis/jobs" "github.com/satisfactorymodding/smr-api/storage" @@ -14,8 +13,7 @@ func init() { migration.NewCodeMigration( func(executionContext interface{}) error { storage.ScheduleCopyAllObjectsFromOldBucket(func(key string) { - ctx := log.Logger.WithContext(context.TODO()) - jobs.SubmitJobCopyObjectFromOldBucketTask(ctx, key) + jobs.SubmitJobCopyObjectFromOldBucketTask(context.TODO(), key) }) return nil }, diff --git a/migrations/code/20200707150700_after_sml_version_fix.go b/migrations/code/20200707150700_after_sml_version_fix.go index 3b8e25ba..9326e632 100644 --- a/migrations/code/20200707150700_after_sml_version_fix.go +++ b/migrations/code/20200707150700_after_sml_version_fix.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/migrations/utils" @@ -13,8 +12,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, false, nil, func(version postgres.Version) bool { + utils.ReindexAllModFiles(context.TODO(), false, nil, func(version postgres.Version) bool { return version.SMLVersion == "" }) return nil diff --git a/migrations/code/20200829171600_after_db_dirty.go b/migrations/code/20200829171600_after_db_dirty.go index 936920e3..488054c0 100644 --- a/migrations/code/20200829171600_after_db_dirty.go +++ b/migrations/code/20200829171600_after_db_dirty.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20200829225100_after_broken_datajson.go b/migrations/code/20200829225100_after_broken_datajson.go index 9dde4680..9da63802 100644 --- a/migrations/code/20200829225100_after_broken_datajson.go +++ b/migrations/code/20200829225100_after_broken_datajson.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/migrations/utils" @@ -13,8 +12,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, func(version postgres.Version) bool { + utils.ReindexAllModFiles(context.TODO(), true, nil, func(version postgres.Version) bool { return version.Hash == nil || *version.Hash == "" }) return nil diff --git a/migrations/code/20200830011200_after_gorm_hotfix.go b/migrations/code/20200830011200_after_gorm_hotfix.go index 936920e3..488054c0 100644 --- a/migrations/code/20200830011200_after_gorm_hotfix.go +++ b/migrations/code/20200830011200_after_gorm_hotfix.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20201014162200_after_bp_fix.go b/migrations/code/20201014162200_after_bp_fix.go index 936920e3..488054c0 100644 --- a/migrations/code/20201014162200_after_bp_fix.go +++ b/migrations/code/20201014162200_after_bp_fix.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20201016202600_after_body_enable.go b/migrations/code/20201016202600_after_body_enable.go index 936920e3..488054c0 100644 --- a/migrations/code/20201016202600_after_body_enable.go +++ b/migrations/code/20201016202600_after_body_enable.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/code/20201019203800_after_remove_filter.go b/migrations/code/20201019203800_after_remove_filter.go index 936920e3..488054c0 100644 --- a/migrations/code/20201019203800_after_remove_filter.go +++ b/migrations/code/20201019203800_after_remove_filter.go @@ -4,7 +4,6 @@ import ( "context" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/migrations/utils" ) @@ -12,8 +11,7 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, nil) + utils.ReindexAllModFiles(context.TODO(), true, nil, nil) return nil }, ) diff --git a/migrations/migrations.go b/migrations/migrations.go index 3999c69f..68b6b49e 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -3,11 +3,12 @@ package migrations import ( "context" "errors" + "fmt" "strings" + "github.com/Vilsol/slox" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/postgres" - "github.com/rs/zerolog/log" postgres2 "github.com/satisfactorymodding/smr-api/db/postgres" @@ -18,7 +19,7 @@ import ( func RunMigrations(ctx context.Context) { databaseMigrations(ctx) codeMigrations(ctx) - log.Info().Msg("Migrations Complete") + slox.Info(ctx, "Migrations Complete") } var migrationDir = "./migrations" @@ -55,7 +56,7 @@ type SimpleLogger struct { } func (l SimpleLogger) Printf(format string, v ...interface{}) { - log.Ctx(l.ctx).Info().Msgf(strings.TrimRight(format, "\n"), v...) + slox.Info(l.ctx, fmt.Sprintf(strings.TrimRight(format, "\n"), v...)) } func (l SimpleLogger) Verbose() bool { diff --git a/models/filters.go b/models/filters.go index c7fd5d61..856044e3 100644 --- a/models/filters.go +++ b/models/filters.go @@ -1,13 +1,13 @@ package models import ( + "fmt" "reflect" "strconv" "github.com/99designs/gqlgen/graphql" "github.com/mitchellh/hashstructure/v2" "github.com/mitchellh/mapstructure" - "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" "github.com/satisfactorymodding/smr-api/generated" @@ -72,7 +72,7 @@ func (f *VersionFilter) AddField(name string) { func (f *VersionFilter) Hash() (string, error) { hash, err := hashstructure.Hash(f, hashstructure.FormatV2, nil) if err != nil { - return "", errors.Wrap(err, "failed to hash VersionFilter") + return "", fmt.Errorf("failed to hash VersionFilter: %w", err) } return strconv.FormatUint(hash, 10), nil } @@ -89,7 +89,7 @@ func ProcessVersionFilter(filter map[string]interface{}) (*VersionFilter, error) } if err := dataValidator.Struct(base); err != nil { - return nil, errors.Wrap(err, "failed to validate VersionFilter") + return nil, fmt.Errorf("failed to validate VersionFilter: %w", err) } return base, nil @@ -150,7 +150,7 @@ func (f *ModFilter) AddField(name string) { func (f *ModFilter) Hash() (string, error) { hash, err := hashstructure.Hash(f, hashstructure.FormatV2, nil) if err != nil { - return "", errors.Wrap(err, "failed to hash ModFilter") + return "", fmt.Errorf("failed to hash ModFilter: %w", err) } return strconv.FormatUint(hash, 10), nil } @@ -167,7 +167,7 @@ func ProcessModFilter(filter map[string]interface{}) (*ModFilter, error) { } if err := dataValidator.Struct(base); err != nil { - return nil, errors.Wrap(err, "failed to validate ModFilter") + return nil, fmt.Errorf("failed to validate ModFilter: %w", err) } return base, nil @@ -186,7 +186,7 @@ type GuideFilter struct { func (f GuideFilter) Hash() (string, error) { hash, err := hashstructure.Hash(f, hashstructure.FormatV2, nil) if err != nil { - return "", errors.Wrap(err, "failed to hash GuideFilter") + return "", fmt.Errorf("failed to hash GuideFilter: %w", err) } return strconv.FormatUint(hash, 10), nil } @@ -217,7 +217,7 @@ func ProcessGuideFilter(filter map[string]interface{}) (*GuideFilter, error) { } if err := dataValidator.Struct(base); err != nil { - return nil, errors.Wrap(err, "failed to validate GuideFilter") + return nil, fmt.Errorf("failed to validate GuideFilter: %w", err) } return base, nil @@ -258,7 +258,7 @@ func ProcessSMLVersionFilter(filter map[string]interface{}) (*SMLVersionFilter, } if err := dataValidator.Struct(base); err != nil { - return nil, errors.Wrap(err, "failed to validate SMLVersionFilter") + return nil, fmt.Errorf("failed to validate SMLVersionFilter: %w", err) } return base, nil @@ -282,10 +282,10 @@ func ApplyChanges(changes interface{}, to interface{}) error { }, }) if err != nil { - return errors.Wrap(err, "failed to create decoder") + return fmt.Errorf("failed to create decoder: %w", err) } - return errors.Wrap(dec.Decode(changes), "failed to decode changes") + return fmt.Errorf("failed to decode changes: %w", dec.Decode(changes)) } type BootstrapVersionFilter struct { @@ -323,7 +323,7 @@ func ProcessBootstrapVersionFilter(filter map[string]interface{}) (*BootstrapVer } if err := dataValidator.Struct(base); err != nil { - return nil, errors.Wrap(err, "failed to validate BootstrapVersionFilter") + return nil, fmt.Errorf("failed to validate BootstrapVersionFilter: %w", err) } return base, nil diff --git a/nodes/user.go b/nodes/user.go index a03ba675..a029ee49 100644 --- a/nodes/user.go +++ b/nodes/user.go @@ -31,7 +31,7 @@ func userFromContext(c echo.Context) *postgres.User { // @Produce json // @Success 200 // @Router /user/me [get] -func getMe(user *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { +func getMe(user *postgres.User, _ echo.Context) (interface{}, *ErrorResponse) { return UserToPrivateUser(user), nil } @@ -42,7 +42,7 @@ func getMe(user *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { // @Produce json // @Success 200 // @Router /user/me/logout [get] -func getLogout(user *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { +func getLogout(_ *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { postgres.LogoutSession(c.Request().Context(), c.Request().Header.Get("Authorization")) return nil, nil } diff --git a/oauth/facebook.go b/oauth/facebook.go index 3aa9fb35..8e4a41a3 100644 --- a/oauth/facebook.go +++ b/oauth/facebook.go @@ -2,6 +2,7 @@ package oauth import ( "encoding/json" + "fmt" "io" "github.com/pkg/errors" @@ -20,26 +21,26 @@ func FacebookCallback(code string, state string) (*UserData, error) { token, err := facebookAuth.Exchange(ctx, code, urlParam) if err != nil { - return nil, errors.Wrap(err, "failed to exchange code") + return nil, fmt.Errorf("failed to exchange code: %w", err) } client := facebookAuth.Client(ctx, token) resp, err := client.Get("https://graph.facebook.com/v5.0/me?fields=email,short_name,id,picture{url}") if err != nil { - return nil, errors.Wrap(err, "failed to get user data") + return nil, fmt.Errorf("failed to get user data: %w", err) } bytes, err := io.ReadAll(resp.Body) if err != nil { - return nil, errors.Wrap(err, "failed to read response body") + return nil, fmt.Errorf("failed to read response body: %w", err) } var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) if err != nil { - return nil, errors.Wrap(err, "failed to unmarshal user data") + return nil, fmt.Errorf("failed to unmarshal user data: %w", err) } return &UserData{ diff --git a/oauth/github.go b/oauth/github.go index 7e479e90..e9c9bfc3 100644 --- a/oauth/github.go +++ b/oauth/github.go @@ -2,6 +2,7 @@ package oauth import ( "encoding/json" + "fmt" "io" "strconv" @@ -18,45 +19,45 @@ func GithubCallback(code string, state string) (*UserData, error) { token, err := githubAuth.Exchange(ctx, code) if err != nil { - return nil, errors.Wrap(err, "failed to exchange code") + return nil, fmt.Errorf("failed to exchange code: %w", err) } client := githubAuth.Client(ctx, token) resp, err := client.Get("https://api.github.com/user") if err != nil { - return nil, errors.Wrap(err, "failed to get user data") + return nil, fmt.Errorf("failed to get user data: %w", err) } bytes, err := io.ReadAll(resp.Body) if err != nil { - return nil, errors.Wrap(err, "failed to read user data") + return nil, fmt.Errorf("failed to read user data: %w", err) } var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) if err != nil { - return nil, errors.Wrap(err, "failed to unmarshal user data") + return nil, fmt.Errorf("failed to unmarshal user data: %w", err) } resp, err = client.Get("https://api.github.com/user/emails") if err != nil { - return nil, errors.Wrap(err, "failed to get user emails") + return nil, fmt.Errorf("failed to get user emails: %w", err) } bytes, err = io.ReadAll(resp.Body) if err != nil { - return nil, errors.Wrap(err, "failed to read user emails") + return nil, fmt.Errorf("failed to read user emails: %w", err) } var userEmailsData []map[string]interface{} err = json.Unmarshal(bytes, &userEmailsData) if err != nil { - return nil, errors.Wrap(err, "failed to unmarshal user emails") + return nil, fmt.Errorf("failed to unmarshal user emails: %w", err) } if len(userEmailsData) == 0 { diff --git a/oauth/google.go b/oauth/google.go index beab7e23..e7c4b8b3 100644 --- a/oauth/google.go +++ b/oauth/google.go @@ -2,6 +2,7 @@ package oauth import ( "encoding/json" + "fmt" "io" "github.com/pkg/errors" @@ -19,26 +20,26 @@ func GoogleCallback(code string, state string) (*UserData, error) { token, err := googleAuth.Exchange(ctx, code, oauth2.SetAuthURLParam("redirect_uri", viper.GetString("frontend.url"))) if err != nil { - return nil, errors.Wrap(err, "failed to exchange code") + return nil, fmt.Errorf("failed to exchange code: %w", err) } client := googleAuth.Client(ctx, token) resp, err := client.Get("https://www.googleapis.com/oauth2/v2/userinfo") if err != nil { - return nil, errors.Wrap(err, "failed to get user info") + return nil, fmt.Errorf("failed to get user info: %w", err) } bytes, err := io.ReadAll(resp.Body) if err != nil { - return nil, errors.Wrap(err, "failed to read user info") + return nil, fmt.Errorf("failed to read user info: %w", err) } var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) if err != nil { - return nil, errors.Wrap(err, "failed to unmarshal user info") + return nil, fmt.Errorf("failed to unmarshal user info: %w", err) } return &UserData{ diff --git a/redis/jobs/consumers/consumer_copy_object_from_old_bucket.go b/redis/jobs/consumers/consumer_copy_object_from_old_bucket.go index e86cbb50..4ac994af 100644 --- a/redis/jobs/consumers/consumer_copy_object_from_old_bucket.go +++ b/redis/jobs/consumers/consumer_copy_object_from_old_bucket.go @@ -2,8 +2,8 @@ package consumers import ( "encoding/json" + "fmt" - "github.com/pkg/errors" "github.com/vmihailenco/taskq/v3" "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" @@ -20,7 +20,7 @@ func init() { func CopyObjectFromOldBucketConsumer(payload []byte) error { var task tasks.CopyObjectFromOldBucketData if err := json.Unmarshal(payload, &task); err != nil { - return errors.Wrap(err, "failed to unmarshal task") + return fmt.Errorf("failed to unmarshal task: %w", err) } return storage.CopyObjectFromOldBucket(task.Key) } diff --git a/redis/jobs/consumers/consumer_copy_object_to_old_bucket.go b/redis/jobs/consumers/consumer_copy_object_to_old_bucket.go deleted file mode 100644 index 49b1fdb2..00000000 --- a/redis/jobs/consumers/consumer_copy_object_to_old_bucket.go +++ /dev/null @@ -1,26 +0,0 @@ -package consumers - -import ( - "encoding/json" - - "github.com/pkg/errors" - "github.com/vmihailenco/taskq/v3" - - "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" - "github.com/satisfactorymodding/smr-api/storage" -) - -func init() { - tasks.CopyObjectToOldBucketTask = taskq.RegisterTask(&taskq.TaskOptions{ - Name: "consumer_copy_object_to_old_bucket", - Handler: CopyObjectToOldBucketConsumer, - }) -} - -func CopyObjectToOldBucketConsumer(payload []byte) error { - var task tasks.CopyObjectToOldBucketData - if err := json.Unmarshal(payload, &task); err != nil { - return errors.Wrap(err, "failed to unmarshal task") - } - return storage.CopyObjectToOldBucket(task.Key) -} diff --git a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go index c906f8c5..28759521 100644 --- a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go +++ b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go @@ -5,13 +5,14 @@ import ( "bytes" "context" "encoding/json" + "fmt" "io" + "log/slog" "net/http" "path" "time" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" + "github.com/Vilsol/slox" "github.com/vmihailenco/taskq/v3" "github.com/satisfactorymodding/smr-api/db/postgres" @@ -32,10 +33,10 @@ func init() { func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { var task tasks.ScanModOnVirusTotalData if err := json.Unmarshal(payload, &task); err != nil { - return errors.Wrap(err, "failed to unmarshal task data") + return fmt.Errorf("failed to unmarshal task data: %w", err) } - log.Info().Msgf("starting virus scan of mod %s version %s", task.ModID, task.VersionID) + slox.Info(ctx, "starting virus scan of mod", slog.String("mod", task.ModID), slog.String("version", task.VersionID)) version := postgres.GetVersion(ctx, task.VersionID) // Version got deleted? @@ -50,12 +51,12 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { fileData, err := io.ReadAll(response.Body) if err != nil { - return errors.Wrap(err, "failed to read mod file") + return fmt.Errorf("failed to read mod file: %w", err) } archive, err := zip.NewReader(bytes.NewReader(fileData), int64(len(fileData))) if err != nil { - return errors.Wrap(err, "failed to unzip mod file") + return fmt.Errorf("failed to unzip mod file: %w", err) } toScan := make([]io.Reader, 0) @@ -64,7 +65,7 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { if path.Ext(file.Name) == ".dll" || path.Ext(file.Name) == ".so" { open, err := file.Open() if err != nil { - return errors.Wrap(err, "failed to open mod file") + return fmt.Errorf("failed to open mod file: %w", err) } toScan = append(toScan, open) @@ -78,12 +79,12 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { } if !success { - log.Warn().Msgf("mod %s version %s failed to pass virus scan", task.ModID, task.VersionID) + slox.Warn(ctx, "mod failed to pass virus scan", slog.String("mod", task.ModID), slog.String("version", task.VersionID)) return nil } if task.ApproveAfter { - log.Info().Msgf("approving mod %s version %s after successful virus scan", task.ModID, task.VersionID) + slox.Info(ctx, "approving mod after successful virus scan", slog.String("mod", task.ModID), slog.String("version", task.VersionID)) version.Approved = true postgres.Save(ctx, &version) diff --git a/redis/jobs/consumers/consumer_update_db_from_mod_version_file.go b/redis/jobs/consumers/consumer_update_db_from_mod_version_file.go index b6670cb6..ea2f23c8 100644 --- a/redis/jobs/consumers/consumer_update_db_from_mod_version_file.go +++ b/redis/jobs/consumers/consumer_update_db_from_mod_version_file.go @@ -3,8 +3,8 @@ package consumers import ( "context" "encoding/json" + "fmt" - "github.com/pkg/errors" "github.com/vmihailenco/taskq/v3" "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" @@ -20,7 +20,7 @@ func init() { func UpdateDBFromModVersionFileConsumer(ctx context.Context, payload []byte) error { var task tasks.UpdateDBFromModVersionFileData if err := json.Unmarshal(payload, &task); err != nil { - return errors.Wrap(err, "failed to unmarshal task") + return fmt.Errorf("failed to unmarshal task: %w", err) } return UpdateModDataFromStorage(ctx, task.ModID, task.VersionID, true) } diff --git a/redis/jobs/consumers/consumer_update_db_from_mod_version_json_file.go b/redis/jobs/consumers/consumer_update_db_from_mod_version_json_file.go index d392d831..b238eeaf 100644 --- a/redis/jobs/consumers/consumer_update_db_from_mod_version_json_file.go +++ b/redis/jobs/consumers/consumer_update_db_from_mod_version_json_file.go @@ -3,8 +3,8 @@ package consumers import ( "context" "encoding/json" + "fmt" - "github.com/pkg/errors" "github.com/vmihailenco/taskq/v3" "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" @@ -20,7 +20,7 @@ func init() { func UpdateDBFromModVersionJSONFileConsumer(ctx context.Context, payload []byte) error { var task tasks.UpdateDBFromModVersionFileData if err := json.Unmarshal(payload, &task); err != nil { - return errors.Wrap(err, "failed to unmarshal task") + return fmt.Errorf("failed to unmarshal task: %w", err) } return UpdateModDataFromStorage(ctx, task.ModID, task.VersionID, false) } diff --git a/redis/jobs/consumers/utils.go b/redis/jobs/consumers/utils.go index 9a8ebab2..6cb77c7b 100644 --- a/redis/jobs/consumers/utils.go +++ b/redis/jobs/consumers/utils.go @@ -3,11 +3,13 @@ package consumers import ( "context" "encoding/json" + "fmt" "io" + "log/slog" "net/http" + "github.com/Vilsol/slox" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/storage" @@ -16,7 +18,7 @@ import ( func UpdateModDataFromStorage(ctx context.Context, modID string, versionID string, metadata bool) error { // perform task - log.Info().Msgf("[%s] Updating DB for mod %s version with metadata: %v", versionID, modID, metadata) + slox.Info(ctx, "Updating DB for mod version with metadata", slog.String("mod", modID), slog.String("version", versionID), slog.Bool("metadata", metadata)) version := postgres.GetVersion(ctx, versionID) link := storage.GenerateDownloadLink(version.Key) @@ -25,7 +27,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin fileData, err := io.ReadAll(response.Body) if err != nil { - return errors.Wrap(err, "failed to read response body") + return fmt.Errorf("failed to read response body: %w", err) } mod := postgres.GetModByID(ctx, modID) @@ -36,7 +38,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin info, err := validation.ExtractModInfo(ctx, fileData, metadata, false, mod.ModReference) if err != nil { - log.Warn().Err(err).Msgf("[%s] Failed updating mod, likely outdated", versionID) + slox.Warn(ctx, "failed updating mod, likely outdated", slog.Any("err", err), slog.String("version", versionID)) // Outdated version return nil } @@ -66,7 +68,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin if metadata { jsonData, err := json.Marshal(info.Metadata) if err != nil { - log.Err(err).Msgf("[%s] failed serializing", versionID) + slox.Error(ctx, "failed serializing", slog.Any("err", err), slog.String("version", versionID)) } else { metadata := string(jsonData) version.Metadata = &metadata diff --git a/redis/jobs/jobs.go b/redis/jobs/jobs.go index 0ce35aa2..82cda3ff 100644 --- a/redis/jobs/jobs.go +++ b/redis/jobs/jobs.go @@ -4,10 +4,11 @@ import ( "context" "encoding/json" "fmt" + "log/slog" "time" + "github.com/Vilsol/slox" "github.com/go-redis/redis/v8" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "github.com/vmihailenco/taskq/extra/taskqotel/v3" "github.com/vmihailenco/taskq/v3" @@ -54,7 +55,7 @@ func SubmitJobUpdateDBFromModVersionFileTask(ctx context.Context, modID string, err := queue.Add(tasks.UpdateDBFromModVersionFileTask.WithArgs(ctx, task)) if err != nil { - log.Err(err).Msg("error adding task") + slox.Error(ctx, "error adding task", slog.Any("err", err)) } } @@ -66,7 +67,7 @@ func SubmitJobUpdateDBFromModVersionJSONFileTask(ctx context.Context, modID stri err := queue.Add(tasks.UpdateDBFromModVersionJSONFileTask.WithArgs(ctx, task)) if err != nil { - log.Err(err).Msg("error adding task") + slox.Error(ctx, "error adding task", slog.Any("err", err)) } } @@ -77,18 +78,7 @@ func SubmitJobCopyObjectFromOldBucketTask(ctx context.Context, key string) { err := queue.Add(tasks.CopyObjectFromOldBucketTask.WithArgs(ctx, task)) if err != nil { - log.Err(err).Msg("error adding task") - } -} - -func SubmitJobCopyObjectToOldBucketTask(ctx context.Context, key string) { - task, _ := json.Marshal(tasks.CopyObjectToOldBucketData{ - Key: key, - }) - - err := queue.Add(tasks.CopyObjectToOldBucketTask.WithArgs(ctx, task)) - if err != nil { - log.Err(err).Msg("error adding task") + slox.Error(ctx, "error adding task", slog.Any("err", err)) } } @@ -101,6 +91,6 @@ func SubmitJobScanModOnVirusTotalTask(ctx context.Context, modID string, version err := queue.Add(tasks.ScanModOnVirusTotalTask.WithArgs(ctx, task)) if err != nil { - log.Err(err).Msg("error adding task") + slox.Error(ctx, "error adding task", slog.Any("err", err)) } } diff --git a/redis/jobs/tasks/tasks.go b/redis/jobs/tasks/tasks.go index 77b199cf..0ef9605f 100755 --- a/redis/jobs/tasks/tasks.go +++ b/redis/jobs/tasks/tasks.go @@ -6,7 +6,6 @@ var ( UpdateDBFromModVersionFileTask *taskq.Task UpdateDBFromModVersionJSONFileTask *taskq.Task CopyObjectFromOldBucketTask *taskq.Task - CopyObjectToOldBucketTask *taskq.Task ScanModOnVirusTotalTask *taskq.Task ) diff --git a/redis/redis.go b/redis/redis.go index 51411c85..33b7bcf1 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -12,10 +12,10 @@ import ( "strconv" "time" + "github.com/Vilsol/slox" "github.com/cespare/xxhash" "github.com/go-redis/redis" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "github.com/satisfactorymodding/smr-api/generated" @@ -40,7 +40,7 @@ func InitializeRedis(ctx context.Context) { panic(ping.Err()) } - log.Info().Msg("Redis initialized") + slox.Info(ctx, "Redis initialized") } func CanIncrement(ip string, action string, object string, expiration time.Duration) bool { @@ -56,7 +56,7 @@ func StoreNonce(nonce string, redirectURI string) { func GetNonce(nonce string) (string, error) { result, err := client.Get("nonce:" + nonce).Result() - return result, errors.Wrap(err, "failed to get nonce") + return result, fmt.Errorf("failed to get nonce: %w", err) } func GetAllKeys() []string { @@ -108,11 +108,15 @@ func StoreVersionUploadState(versionID string, data *generated.CreateVersionResp marshaled, e := json.Marshal(state) if e != nil { - return errors.Wrap(err, "failed to marshal version upload state") + return fmt.Errorf("failed to marshal version upload state: %w", err) } redisKey := "version:upload:state:" + versionID - return errors.Wrap(client.Set(redisKey, string(marshaled), time.Minute*10).Err(), "failed to store version upload state") + if err := client.Set(redisKey, string(marshaled), time.Minute*10).Err(); err != nil { + return fmt.Errorf("failed to store version upload state: %w", err) + } + + return nil } func GetVersionUploadState(versionID string) (*generated.CreateVersionResponse, error) { @@ -127,7 +131,7 @@ func GetVersionUploadState(versionID string) (*generated.CreateVersionResponse, if errors.Is(get.Err(), redis.Nil) { return nil, nil } - return nil, errors.Wrap(get.Err(), "failed to get version upload state") + return nil, fmt.Errorf("failed to get version upload state: %w", get.Err()) } data := &StoredVersionUploadState{} diff --git a/shell.nix b/shell.nix index 216a4f80..90d31232 100644 --- a/shell.nix +++ b/shell.nix @@ -1,11 +1,16 @@ { pkgs ? import <nixpkgs> {} }: +let + unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { }; +in pkgs.mkShell { nativeBuildInputs = with pkgs.buildPackages; [ libwebp - go + libpng + unstable.go_1_21 protobuf protoc-gen-go-grpc minio-client + unstable.golangci-lint ]; } diff --git a/storage/b2.go b/storage/b2.go deleted file mode 100644 index 3c0b79e2..00000000 --- a/storage/b2.go +++ /dev/null @@ -1,246 +0,0 @@ -package storage - -import ( - "context" - "fmt" - "io" - "strconv" - "strings" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/s3" - "github.com/aws/aws-sdk-go/service/s3/s3manager" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - - "github.com/satisfactorymodding/smr-api/redis" -) - -type B2 struct { - BaseURL string - S3Client *s3.S3 - S3Session *session.Session - Config Config -} - -func initializeB2(ctx context.Context, config Config) *B2 { - s3Config := &aws.Config{ - Credentials: credentials.NewStaticCredentials(config.Key, config.Secret, ""), - Endpoint: aws.String("https://s3." + config.Region + ".backblazeb2.com"), - Region: aws.String(config.Region), - S3ForcePathStyle: aws.Bool(true), - } - - newSession, err := session.NewSession(s3Config) - if err != nil { - log.Err(err).Msg("failed to create S3 session") - return nil - } - - s3Client := s3.New(newSession) - - return &B2{ - BaseURL: config.BaseURL, - S3Client: s3Client, - S3Session: newSession, - Config: config, - } -} - -func (b2o *B2) Get(key string) (io.ReadCloser, error) { - cleanedKey := strings.TrimPrefix(key, "/") - - object, err := b2o.S3Client.GetObject(&s3.GetObjectInput{ - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - }) - if err != nil { - return nil, errors.Wrap(err, "failed to get object") - } - - return object.Body, nil -} - -func (b2o *B2) Put(ctx context.Context, key string, body io.ReadSeeker) (string, error) { - cleanedKey := strings.TrimPrefix(key, "/") - uploader := s3manager.NewUploader(b2o.S3Session) - - _, err := uploader.UploadWithContext(ctx, &s3manager.UploadInput{ - Body: body, - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - }) - if err != nil { - return cleanedKey, errors.Wrap(err, "failed to upload file") - } - - return key, nil -} - -func (b2o *B2) SignGet(key string) (string, error) { - // Public Bucket - cleanedKey := strings.TrimPrefix(key, "/") - return fmt.Sprintf("%s/file/%s/%s", b2o.BaseURL, b2o.Config.Bucket, cleanedKey), nil -} - -func (b2o *B2) SignPut(key string) (string, error) { - // Unsupported at the moment - return "", errors.New("Unsupported") -} - -func (b2o *B2) StartMultipartUpload(key string) error { - cleanedKey := strings.TrimPrefix(key, "/") - upload, err := b2o.S3Client.CreateMultipartUpload(&s3.CreateMultipartUploadInput{ - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - }) - if err != nil { - return errors.Wrap(err, "failed to create multipart upload") - } - - redis.StoreMultipartUploadID(cleanedKey, *upload.UploadId) - - return nil -} - -func (b2o *B2) UploadPart(key string, part int64, data io.ReadSeeker) error { - cleanedKey := strings.TrimPrefix(key, "/") - id := redis.GetMultipartUploadID(cleanedKey) - - response, err := b2o.S3Client.UploadPart(&s3.UploadPartInput{ - Body: data, - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - PartNumber: aws.Int64(part), - UploadId: aws.String(id), - }) - if err != nil { - return errors.Wrap(err, "failed to upload part") - } - - redis.StoreMultipartCompletedPart(cleanedKey, *response.ETag, int(part)) - - return nil -} - -func (b2o *B2) CompleteMultipartUpload(key string) error { - cleanedKey := strings.TrimPrefix(key, "/") - id := redis.GetMultipartUploadID(cleanedKey) - parts := redis.GetAndClearMultipartCompletedParts(cleanedKey) - completedParts := make([]*s3.CompletedPart, len(parts)) - - for part, etag := range parts { - partInt, _ := strconv.ParseInt(part, 10, 64) - completedParts[partInt-1] = &s3.CompletedPart{ETag: aws.String(etag), PartNumber: &partInt} - } - - _, err := b2o.S3Client.CompleteMultipartUpload(&s3.CompleteMultipartUploadInput{ - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - MultipartUpload: &s3.CompletedMultipartUpload{Parts: completedParts}, - UploadId: aws.String(id), - }) - - return errors.Wrap(err, "failed to complete multipart upload") -} - -func (b2o *B2) Rename(from string, to string) error { - cleanedKey := strings.TrimPrefix(to, "/") - - _, err := b2o.S3Client.CopyObject(&s3.CopyObjectInput{ - Bucket: aws.String(b2o.Config.Bucket), - CopySource: aws.String(b2o.Config.Bucket + from), - Key: aws.String(cleanedKey), - }) - - return errors.Wrap(err, "failed to copy object") -} - -func (b2o *B2) Delete(key string) error { - cleanedKey := strings.TrimPrefix(key, "/") - - for i := 0; i < 10; i++ { - versions, err := b2o.S3Client.ListObjectVersions(&s3.ListObjectVersionsInput{ - Bucket: aws.String(b2o.Config.Bucket), - KeyMarker: aws.String(cleanedKey), - Prefix: aws.String(cleanedKey), - }) - if err != nil { - return errors.Wrap(err, "failed to list object versions") - } - - objects := make([]*s3.ObjectIdentifier, len(versions.Versions)+len(versions.DeleteMarkers)) - - for i, version := range versions.Versions { - objects[i] = &s3.ObjectIdentifier{ - Key: version.Key, - VersionId: version.VersionId, - } - } - - for i, marker := range versions.DeleteMarkers { - objects[i+len(versions.Versions)] = &s3.ObjectIdentifier{ - Key: marker.Key, - VersionId: marker.VersionId, - } - } - - if len(objects) == 0 { - return nil - } - - _, err = b2o.S3Client.DeleteObjects(&s3.DeleteObjectsInput{ - Bucket: aws.String(b2o.Config.Bucket), - Delete: &s3.Delete{ - Objects: objects, - }, - }) - - if err != nil { - return errors.Wrap(err, "failed to delete objects") - } - } - - return nil -} - -func (b2o *B2) Meta(key string) (*ObjectMeta, error) { - cleanedKey := strings.TrimPrefix(key, "/") - - data, err := b2o.S3Client.HeadObject(&s3.HeadObjectInput{ - Bucket: aws.String(b2o.Config.Bucket), - Key: aws.String(cleanedKey), - }) - if err != nil { - return nil, errors.Wrap(err, "failed to get object meta") - } - - return &ObjectMeta{ - ContentLength: data.ContentLength, - ContentType: data.ContentType, - }, nil -} - -func (b2o *B2) List(prefix string) ([]Object, error) { - out := make([]Object, 0) - - err := b2o.S3Client.ListObjectsPages(&s3.ListObjectsInput{ - Bucket: aws.String(b2o.Config.Bucket), - Prefix: aws.String(prefix), - }, func(output *s3.ListObjectsOutput, b bool) bool { - for _, obj := range output.Contents { - out = append(out, Object{ - Key: obj.Key, - LastModified: obj.LastModified, - }) - } - return true - }) - if err != nil { - return nil, errors.Wrap(err, "failed to list objects") - } - - return out, nil -} diff --git a/storage/s3.go b/storage/s3.go index f2335f4e..92eec1a2 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -4,16 +4,17 @@ import ( "context" "fmt" "io" + "log/slog" "strconv" "strings" + "github.com/Vilsol/slox" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "github.com/satisfactorymodding/smr-api/redis" @@ -36,7 +37,7 @@ func initializeS3(ctx context.Context, config Config) *S3 { newSession, err := session.NewSession(s3Config) if err != nil { - log.Err(err).Msg("failed to create S3 session") + slox.Error(ctx, "failed to create S3 session", slog.Any("err", err)) return nil } @@ -58,7 +59,7 @@ func (s3o *S3) Get(key string) (io.ReadCloser, error) { Key: aws.String(cleanedKey), }) if err != nil { - return nil, errors.Wrap(err, "failed to get object") + return nil, fmt.Errorf("failed to get object: %w", err) } return object.Body, nil @@ -75,7 +76,7 @@ func (s3o *S3) Put(ctx context.Context, key string, body io.ReadSeeker) (string, Key: aws.String(cleanedKey), }) if err != nil { - return cleanedKey, errors.Wrap(err, "failed to upload file") + return cleanedKey, fmt.Errorf("failed to upload file: %w", err) } return key, nil @@ -87,7 +88,7 @@ func (s3o *S3) SignGet(key string) (string, error) { return fmt.Sprintf(viper.GetString("storage.keypath"), s3o.BaseURL, viper.GetString("storage.bucket"), cleanedKey), nil } -func (s3o *S3) SignPut(key string) (string, error) { +func (s3o *S3) SignPut(_ string) (string, error) { // Unsupported at the moment return "", errors.New("Unsupported") } @@ -99,7 +100,7 @@ func (s3o *S3) StartMultipartUpload(key string) error { Key: aws.String(cleanedKey), }) if err != nil { - return errors.Wrap(err, "failed to create multipart upload") + return fmt.Errorf("failed to create multipart upload: %w", err) } redis.StoreMultipartUploadID(cleanedKey, *upload.UploadId) @@ -119,7 +120,7 @@ func (s3o *S3) UploadPart(key string, part int64, data io.ReadSeeker) error { UploadId: aws.String(id), }) if err != nil { - return errors.Wrap(err, "failed to upload part") + return fmt.Errorf("failed to upload part: %w", err) } redis.StoreMultipartCompletedPart(cleanedKey, *response.ETag, int(part)) @@ -145,7 +146,7 @@ func (s3o *S3) CompleteMultipartUpload(key string) error { UploadId: aws.String(id), }) - return errors.Wrap(err, "failed to complete multipart upload") + return fmt.Errorf("failed to complete multipart upload: %w", err) } func (s3o *S3) Rename(from string, to string) error { @@ -157,7 +158,7 @@ func (s3o *S3) Rename(from string, to string) error { Key: aws.String(cleanedKey), }) - return errors.Wrap(err, "failed to copy object") + return fmt.Errorf("failed to copy object: %w", err) } func (s3o *S3) Delete(key string) error { @@ -177,13 +178,13 @@ func (s3o *S3) Delete(key string) error { }) if err != nil { - return errors.Wrap(err, "failed to delete objects") + return fmt.Errorf("failed to delete objects: %w", err) } return nil } - return errors.Wrap(err, "failed to list object versions") + return fmt.Errorf("failed to list object versions: %w", err) } objects := make([]*s3.ObjectIdentifier, len(versions.Versions)+len(versions.DeleteMarkers)) @@ -209,7 +210,7 @@ func (s3o *S3) Delete(key string) error { }) if err != nil { - return errors.Wrap(err, "failed to delete objects") + return fmt.Errorf("failed to delete objects: %w", err) } return nil @@ -223,7 +224,7 @@ func (s3o *S3) Delete(key string) error { }) if err != nil { - return errors.Wrap(err, "failed to delete objects") + return fmt.Errorf("failed to delete objects: %w", err) } } @@ -238,7 +239,7 @@ func (s3o *S3) Meta(key string) (*ObjectMeta, error) { Key: aws.String(cleanedKey), }) if err != nil { - return nil, errors.Wrap(err, "failed to get object meta") + return nil, fmt.Errorf("failed to get object meta: %w", err) } return &ObjectMeta{ @@ -263,7 +264,7 @@ func (s3o *S3) List(prefix string) ([]Object, error) { return true }) if err != nil { - return nil, errors.Wrap(err, "failed to list objects") + return nil, fmt.Errorf("failed to list objects: %w", err) } return out, nil diff --git a/storage/storage.go b/storage/storage.go index 9c2ec55c..9863c6f7 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -8,13 +8,14 @@ import ( "encoding/hex" "fmt" "io" + "log/slog" "sort" "strings" "time" + "github.com/Vilsol/slox" "github.com/avast/retry-go/v3" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" ) @@ -71,16 +72,11 @@ func InitializeStorage(ctx context.Context) { panic("Failed to initialize storage!") } - log.Info().Msgf("Storage initialized: %s", baseConfig.Type) + slox.Info(ctx, "storage initialized", slog.String("type", baseConfig.Type)) } func configToStorage(ctx context.Context, config Config) Storage { - switch config.Type { - case "wasabi": - return initializeWasabi(ctx, config) - case "b2": - return initializeB2(ctx, config) - case "s3": + if config.Type == "s3" { return initializeS3(ctx, config) } @@ -98,7 +94,7 @@ func StartUploadMultipartMod(ctx context.Context, modID string, name string, ver key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := StartMultipartUpload(key); err != nil { - log.Err(err).Msg("failed to upload mod") + slox.Error(ctx, "failed to upload mod", slog.Any("err", err)) return false, "" } @@ -116,7 +112,7 @@ func UploadMultipartMod(ctx context.Context, modID string, name string, versionI key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := UploadPart(key, part, data); err != nil { - log.Err(err).Msg("failed to upload mod") + slox.Error(ctx, "failed to upload mod", slog.Any("err", err)) return false, "" } @@ -134,7 +130,7 @@ func CompleteUploadMultipartMod(ctx context.Context, modID string, name string, key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := CompleteMultipartUpload(key); err != nil { - log.Err(err).Msg("failed to upload mod") + slox.Error(ctx, "failed to upload mod", slog.Any("err", err)) return false, "" } @@ -150,7 +146,7 @@ func UploadModLogo(ctx context.Context, modID string, data io.ReadSeeker) (bool, key, err := storage.Put(ctx, key, data) if err != nil { - log.Err(err).Msg("failed to upload mod logo") + slox.Error(ctx, "failed to upload mod logo", slog.Any("err", err)) return false, "" } @@ -168,16 +164,16 @@ func UploadUserAvatar(ctx context.Context, userID string, data io.ReadSeeker) (b func() error { var err error key, err = storage.Put(ctx, key, data) - return errors.Wrap(err, "failed to upload user avatar") + return fmt.Errorf("failed to upload user avatar: %w", err) }, retry.Attempts(3), retry.LastErrorOnly(true), retry.OnRetry(func(n uint, err error) { - log.Err(err).Msgf("failed to upload user avatar, retrying [%d]", n) + slox.Error(ctx, "failed to upload user avatar, retrying", slog.Any("err", err), slog.Any("n", n)) }), ) if err != nil { - log.Err(err).Msg("failed to upload user avatar") + slox.Error(ctx, "failed to upload user avatar", slog.Any("err", err)) return false, "" } @@ -202,7 +198,11 @@ func StartMultipartUpload(key string) error { return errors.New("storage not initialized") } - return errors.Wrap(storage.StartMultipartUpload(key), "failed to start multipart upload") + if err := storage.StartMultipartUpload(key); err != nil { + return fmt.Errorf("failed to start multipart upload: %w", err) + } + + return nil } func UploadPart(key string, part int64, data io.ReadSeeker) error { @@ -210,7 +210,11 @@ func UploadPart(key string, part int64, data io.ReadSeeker) error { return errors.New("storage not initialized") } - return errors.Wrap(storage.UploadPart(key, part, data), "failed to upload part") + if err := storage.UploadPart(key, part, data); err != nil { + return fmt.Errorf("failed to upload part: %w", err) + } + + return nil } func CompleteMultipartUpload(key string) error { @@ -218,20 +222,19 @@ func CompleteMultipartUpload(key string) error { return errors.New("storage not initialized") } - return errors.Wrap(storage.CompleteMultipartUpload(key), "failed to complete multipart upload") -} + if err := storage.CompleteMultipartUpload(key); err != nil { + return fmt.Errorf("failed to complete multipart upload: %w", err) + } -func CopyObjectFromOldBucket(key string) error { - // Ignored return nil } -func CopyObjectToOldBucket(key string) error { +func CopyObjectFromOldBucket(_ string) error { // Ignored return nil } -func ScheduleCopyAllObjectsFromOldBucket(scheduler func(string)) { +func ScheduleCopyAllObjectsFromOldBucket(_ func(string)) { // Ignored } @@ -241,7 +244,7 @@ func Get(key string) (io.ReadCloser, error) { } get, err := storage.Get(key) - return get, errors.Wrap(err, "failed to get object") + return get, fmt.Errorf("failed to get object: %w", err) } func GetMod(modID string, name string, versionID string) (io.ReadCloser, error) { @@ -263,16 +266,16 @@ func RenameVersion(ctx context.Context, modID string, name string, versionID str from := fmt.Sprintf("/mods/%s/%s.smod", modID, EncodeName(cleanName)+"-"+versionID) to := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+version) - log.Info().Msgf("Renaming file from %s to %s", from, to) + slox.Info(ctx, "renaming file", slog.String("from", from), slog.String("to", to)) if err := storage.Rename(from, to); err != nil { - log.Err(err).Msg("failed to rename version") + slox.Error(ctx, "failed to rename version", slog.Any("err", err)) return false, "" } fromUnescaped := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+versionID) if err := storage.Delete(fromUnescaped); err != nil { - log.Err(err).Msg("failed to delete version") + slox.Error(ctx, "failed to delete version", slog.Any("err", err)) return false, "" } @@ -288,9 +291,9 @@ func DeleteMod(ctx context.Context, modID string, name string, versionID string) key := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+versionID) - log.Info().Str("key", key).Msg("deleting version") + slox.Info(ctx, "deleting version", slog.String("key", key)) if err := storage.Delete(key); err != nil { - log.Err(err).Msg("failed to delete version") + slox.Error(ctx, "failed to delete version", slog.Any("err", err)) return false } @@ -305,33 +308,15 @@ func DeleteModTarget(ctx context.Context, modID string, name string, versionID s cleanName := cleanModName(name) key := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+target+"-"+versionID) - log.Info().Str("key", key).Msg("deleting mod target") + slox.Info(ctx, "deleting mod target", slog.String("key", key)) if err := storage.Delete(key); err != nil { - log.Err(err).Msg("failed to delete version target") + slox.Error(ctx, "failed to delete version target", slog.Any("err", err)) return false } return true } -func ModVersionMeta(ctx context.Context, modID string, name string, versionID string) *ObjectMeta { - if storage == nil { - return nil - } - - cleanName := cleanModName(name) - - key := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+versionID) - - meta, err := storage.Meta(key) - if err != nil { - log.Err(err).Msg("failed to delete version") - return nil - } - - return meta -} - func cleanModName(name string) string { cleanName := strings.ReplaceAll(name, " ", "_") cleanName = strings.ReplaceAll(cleanName, "\\", "_") @@ -397,7 +382,7 @@ func SeparateModTarget(ctx context.Context, body []byte, modID, name, modVersion err = copyModFileToArchZip(file, zipWriter, trimmedName) if err != nil { - log.Err(err).Msg("failed to add file to " + target + " archive") + slox.Error(ctx, "failed to add file to archive", slog.Any("err", err), slog.String("target", target)) return false, "", "", 0 } } @@ -409,7 +394,7 @@ func SeparateModTarget(ctx context.Context, body []byte, modID, name, modVersion _, err = storage.Put(ctx, key, bytes.NewReader(buf.Bytes())) if err != nil { - log.Err(err).Msg("failed to save " + target + " archive") + slox.Error(ctx, "failed to save archive", slog.Any("err", err), slog.String("target", target)) return false, "", "", 0 } @@ -426,12 +411,12 @@ func copyModFileToArchZip(file *zip.File, zipWriter *zip.Writer, newName string) zipFile, err := zipWriter.CreateHeader(&fileHeader) if err != nil { - return errors.Wrap(err, "failed to create file") + return fmt.Errorf("failed to create file: %w", err) } rawFile, err := file.Open() if err != nil { - return errors.Wrap(err, "failed to open file") + return fmt.Errorf("failed to open file: %w", err) } defer rawFile.Close() @@ -439,22 +424,22 @@ func copyModFileToArchZip(file *zip.File, zipWriter *zip.Writer, newName string) _, err = buf.ReadFrom(rawFile) if err != nil { - return errors.Wrap(err, "failed to read file") + return fmt.Errorf("failed to read file: %w", err) } _, err = zipFile.Write(buf.Bytes()) if err != nil { - return errors.Wrap(err, "failed to write file") + return fmt.Errorf("failed to write file: %w", err) } return nil } -func DeleteOldModAssets(modReference string, before time.Time) { +func DeleteOldModAssets(ctx context.Context, modReference string, before time.Time) { list, err := storage.List(fmt.Sprintf("assets/mods/%s", modReference)) if err != nil { - log.Err(err).Msg("failed to list assets") + slox.Error(ctx, "failed to list assets", slog.Any("err", err)) return } @@ -465,7 +450,7 @@ func DeleteOldModAssets(modReference string, before time.Time) { if object.LastModified == nil || object.LastModified.Before(before) { if err := storage.Delete(*object.Key); err != nil { - log.Err(err).Str("key", *object.Key).Msg("failed deleting old asset") + slox.Error(ctx, "failed deleting old asset", slog.Any("err", err), slog.String("key", *object.Key)) return } } @@ -481,7 +466,7 @@ func UploadModAsset(ctx context.Context, modReference string, path string, data _, err := storage.Put(ctx, key, bytes.NewReader(data)) if err != nil { - log.Err(err).Str("path", path).Msg("failed to upload mod asset") + slox.Error(ctx, "failed to upload mod asset", slog.Any("err", err), slog.String("path", path)) } } diff --git a/storage/wasabi.go b/storage/wasabi.go deleted file mode 100644 index c35b864e..00000000 --- a/storage/wasabi.go +++ /dev/null @@ -1,124 +0,0 @@ -package storage - -import ( - "context" - "io" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/s3" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" -) - -type Wasabi struct { - S3Client *s3.S3 - Bucket *string -} - -func initializeWasabi(ctx context.Context, config Config) *Wasabi { - bucket := aws.String(config.Bucket) - - s3Config := &aws.Config{ - Credentials: credentials.NewStaticCredentials(config.Key, config.Secret, ""), - Endpoint: aws.String(config.Endpoint), - Region: aws.String(config.Region), - S3ForcePathStyle: aws.Bool(true), - } - - newSession, err := session.NewSession(s3Config) - if err != nil { - log.Err(err).Msg("failed to create session") - return nil - } - - s3Client := s3.New(newSession) - - return &Wasabi{ - Bucket: bucket, - S3Client: s3Client, - } -} - -func (wasabi *Wasabi) Get(key string) (io.ReadCloser, error) { - obj, err := wasabi.S3Client.GetObject(&s3.GetObjectInput{ - Bucket: wasabi.Bucket, - Key: aws.String(key), - }) - if err != nil { - return nil, errors.Wrap(err, "failed to get object") - } - - return obj.Body, nil -} - -func (wasabi *Wasabi) Put(ctx context.Context, key string, body io.ReadSeeker) (string, error) { - _, err := wasabi.S3Client.PutObject(&s3.PutObjectInput{ - Body: body, - Bucket: wasabi.Bucket, - Key: aws.String(key), - }) - if err != nil { - return key, errors.Wrap(err, "failed to put object") - } - - return key, nil -} - -func (wasabi *Wasabi) SignGet(key string) (string, error) { - req, _ := wasabi.S3Client.GetObjectRequest(&s3.GetObjectInput{ - Bucket: wasabi.Bucket, - Key: aws.String(key), - }) - - urlStr, err := req.Presign(15 * time.Minute) - if err != nil { - return "", errors.Wrap(err, "failed to sign url") - } - - return urlStr, nil -} - -func (wasabi *Wasabi) SignPut(key string) (string, error) { - req, _ := wasabi.S3Client.PutObjectRequest(&s3.PutObjectInput{ - Bucket: wasabi.Bucket, - Key: aws.String(key), - }) - - urlStr, err := req.Presign(15 * time.Minute) - if err != nil { - return "", errors.Wrap(err, "failed to sign url") - } - - return urlStr, nil -} - -func (wasabi *Wasabi) StartMultipartUpload(key string) error { - return errors.New("Unsupported") -} - -func (wasabi *Wasabi) UploadPart(key string, part int64, data io.ReadSeeker) error { - return errors.New("Unsupported") -} - -func (wasabi *Wasabi) CompleteMultipartUpload(key string) error { - return errors.New("Unsupported") -} - -func (wasabi *Wasabi) Rename(from string, to string) error { - return errors.New("Unsupported") -} - -func (wasabi *Wasabi) Delete(key string) error { - return errors.New("Unsupported") -} - -func (wasabi *Wasabi) Meta(key string) (*ObjectMeta, error) { - return nil, errors.New("Unsupported") -} - -func (wasabi *Wasabi) List(key string) ([]Object, error) { - return nil, errors.New("Unsupported") -} diff --git a/tests/utils.go b/tests/utils.go index 6e87a950..15086cd3 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -2,10 +2,11 @@ package tests import ( "context" + "log/slog" "sync" + "github.com/Vilsol/slox" "github.com/machinebox/graphql" - "github.com/rs/zerolog/log" "github.com/satisfactorymodding/smr-api" "github.com/satisfactorymodding/smr-api/auth" @@ -73,7 +74,7 @@ func makeUser(ctx context.Context) (string, string, error) { return "", "", err } - log.Info().Str("id", user.ID).Msg("created fake test_user") + slox.Info(ctx, "created fake test_user", slog.String("id", user.ID)) userGroup := postgres.UserGroup{ UserID: user.ID, @@ -85,7 +86,7 @@ func makeUser(ctx context.Context) (string, string, error) { return "", "", err } - log.Info().Msg("created user admin group") + slox.Info(ctx, "created user admin group") session := postgres.UserSession{ SMRModel: postgres.SMRModel{ @@ -100,7 +101,7 @@ func makeUser(ctx context.Context) (string, string, error) { return "", "", err } - log.Info().Str("token", session.Token).Msg("created fake user session") + slox.Info(ctx, "created fake user session", slog.String("token", session.Token)) return session.Token, user.ID, nil } diff --git a/util/converter/converter_linux.go b/util/converter/converter_linux.go index c4b48c89..6322a7e5 100644 --- a/util/converter/converter_linux.go +++ b/util/converter/converter_linux.go @@ -3,11 +3,12 @@ package converter import ( "bytes" "context" + "fmt" "image" + "log/slog" + "github.com/Vilsol/slox" "github.com/chai2010/webp" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" giftowebp "github.com/sizeofint/gif-to-webp" // GIF Support @@ -24,8 +25,8 @@ func ConvertAnyImageToWebp(ctx context.Context, imageAsBytes []byte) ([]byte, er imageData, imageType, err := image.Decode(bytes.NewReader(imageAsBytes)) if err != nil { message := "error converting image to webp" - log.Err(err).Msg(message) - return nil, errors.Wrap(err, message) + slox.Error(ctx, message, slog.Any("err", err)) + return nil, fmt.Errorf("%s: %w", message, err) } result := bytes.NewBuffer(make([]byte, 0)) @@ -34,15 +35,15 @@ func ConvertAnyImageToWebp(ctx context.Context, imageAsBytes []byte) ([]byte, er webpBin, err := converter.Convert(imageAsBytes) if err != nil { message := "error converting image to webp" - log.Err(err).Msg(message) - return nil, errors.Wrap(err, message) + slox.Error(ctx, message, slog.Any("err", err)) + return nil, fmt.Errorf("%s: %w", message, err) } return webpBin, nil } if err := webp.Encode(result, imageData, nil); err != nil { - return nil, errors.Wrap(err, "error converting image to webp") + return nil, fmt.Errorf("error converting image to webp: %w", err) } return result.Bytes(), nil diff --git a/util/converter/converter_windows.go b/util/converter/converter_windows.go index 9ab1eb71..725e9e08 100755 --- a/util/converter/converter_windows.go +++ b/util/converter/converter_windows.go @@ -3,12 +3,12 @@ package converter import ( "bytes" "context" + "fmt" "image" + "log/slog" + "github.com/Vilsol/slox" "github.com/chai2010/webp" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - // GIF Support _ "image/gif" // JPEG Support @@ -21,20 +21,20 @@ func ConvertAnyImageToWebp(ctx context.Context, imageAsBytes []byte) ([]byte, er imageData, imageType, err := image.Decode(bytes.NewReader(imageAsBytes)) if err != nil { message := "error converting image to webp" - log.Err(err).Msg(message) - return nil, errors.Wrap(err, message) + slox.Error(ctx, message, slog.Any("err", err)) + return nil, fmt.Errorf("%s: %w", message, err) } result := bytes.NewBuffer(make([]byte, 0)) if imageType == "gif" { message := "converting gif to webp not supported on windows" - log.Err(err).Msg(message) - return nil, errors.Wrap(err, message) + slox.Error(ctx, message, slog.Any("err", err)) + return nil, fmt.Errorf("%s: %w", message, err) } if err := webp.Encode(result, imageData, nil); err != nil { - return nil, errors.Wrap(err, "error converting image to webp") + return nil, fmt.Errorf("error converting image to webp: %w", err) } return result.Bytes(), nil diff --git a/util/flags.go b/util/flags.go index 7d6edea7..7cb2e094 100644 --- a/util/flags.go +++ b/util/flags.go @@ -1,7 +1,10 @@ package util import ( - "github.com/rs/zerolog/log" + "context" + "log/slog" + + "github.com/Vilsol/slox" "github.com/spf13/viper" ) @@ -15,8 +18,8 @@ func FlagEnabled(flag FeatureFlag) bool { return viper.GetBool("feature_flags." + string(flag)) } -func PrintFeatureFlags() { +func PrintFeatureFlags(ctx context.Context) { for _, flag := range []FeatureFlag{FeatureFlagAllowMultiTargetUpload} { - log.Info().Str("flag", string(flag)).Bool("enabled", FlagEnabled(flag)).Msg("flag") + slox.Info(ctx, "flag", slog.String("flag", string(flag)), slog.Bool("enabled", FlagEnabled(flag))) } } diff --git a/util/logging.go b/util/logging.go index 658081fb..2360c4c8 100644 --- a/util/logging.go +++ b/util/logging.go @@ -3,10 +3,10 @@ package util import ( "context" - "github.com/rs/zerolog" + "github.com/Vilsol/slox" ) // ReWrapCtx re-wraps the old logger but with a new context func ReWrapCtx(ctx context.Context) context.Context { - return zerolog.Ctx(ctx).WithContext(context.Background()) + return slox.Into(context.Background(), slox.From(ctx)) } diff --git a/util/random.go b/util/random.go index f04696b6..3ef66175 100644 --- a/util/random.go +++ b/util/random.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/btcsuite/btcutil/base58" + "github.com/btcsuite/btcd/btcutil/base58" ) var seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) diff --git a/validation/decoderv2.go b/validation/decoderv2.go deleted file mode 100644 index b9d5fb0d..00000000 --- a/validation/decoderv2.go +++ /dev/null @@ -1,150 +0,0 @@ -package validation - -import ( - "context" - "strings" - - "github.com/Vilsol/ue4pak/parser" - "github.com/rs/zerolog/log" -) - -func DecodeProperty(ctx context.Context, cleanName string, property *parser.FPropertyTag) interface{} { - // Ignore on purpose - if cleanName == "VertexData" { - return nil - } - - switch strings.Trim(property.PropertyType, "\x00") { - case "ArrayProperty": - return DecodeArrayProperty(ctx, property) - case "IntProperty": - return property.Tag - case "Int8Property": - return property.Tag - case "UInt64Property": - return property.Tag - case "FloatProperty": - return property.Tag - case "BoolProperty": - return property.TagData - case "TextProperty": - return trim(property.Tag.(*parser.FText).SourceString) - case "ObjectProperty": - return FPackageIndexToString(property.Tag) - case "EnumProperty": - return trim(property.Tag.(string)) - case "StrProperty": - return trim(property.Tag.(string)) - case "NameProperty": - return trim(property.Tag.(string)) - case "StructProperty": - return DecodeStructProperty(ctx, property) - case "SoftObjectProperty": - // TODO Might need second - return property.Tag.(*parser.FSoftObjectPath).AssetPathName - case "ByteProperty": - if str, ok := property.Tag.(string); ok { - return trim(str) - } else if b, ok := property.Tag.(byte); ok { - return b - } else { - log.Error().Msgf("Unknown ByteProperty type: %#v", property) - } - default: - log.Error().Msgf("Unknown property type [%s]: %s", cleanName, property.PropertyType) - } - - return nil -} - -func DecodePropertyFields(ctx context.Context, properties []*parser.FPropertyTag) map[string]interface{} { - result := make(map[string]interface{}) - - for _, property := range properties { - cleanName := strings.Trim(property.Name, "\x00") - result[cleanName] = DecodeProperty(ctx, cleanName, property) - } - - return result -} - -func DecodeArrayProperty(ctx context.Context, property *parser.FPropertyTag) []interface{} { - arrayData := property.Tag.([]interface{}) - - if len(arrayData) == 0 { - return make([]interface{}, 0) - } - - results := make([]interface{}, len(arrayData)) - - switch strings.Trim(property.TagData.(string), "\x00") { - case "StructProperty": - for i, data := range arrayData { - properties := data.(*parser.ArrayStructProperty).Properties - switch properties.(type) { - case *parser.StructType: - break - default: - results[i] = DecodePropertyFields(ctx, properties.([]*parser.FPropertyTag)) - } - } - case "SoftObjectProperty": - for i, data := range arrayData { - // TODO Might need second - results[i] = trim(data.(*parser.FSoftObjectPath).AssetPathName) - } - case "ObjectProperty": - for i, data := range arrayData { - results[i] = FPackageIndexToStringSpecial(data) - } - case "StrProperty": - fallthrough - case "EnumProperty": - fallthrough - case "NameProperty": - for i, data := range arrayData { - results[i] = trim(data.(string)) - } - case "IntProperty": - fallthrough - case "FloatProperty": - copy(results, arrayData) - default: - log.Error().Msgf("Unknown array property data type [%s]: %s", property.Name, property.TagData.(string)) - } - - return results -} - -func DecodeStructProperty(ctx context.Context, property *parser.FPropertyTag) interface{} { - if arr, ok := property.Tag.([]*parser.FPropertyTag); ok { - return DecodePropertyFields(ctx, arr) - } - - return property.Tag.(*parser.StructType).Value -} - -func FPackageIndexToStringSpecial(index interface{}) string { - fPackage := index.(*parser.FPackageIndex) - result := "" - - if fImport, ok := fPackage.Reference.(*parser.FObjectImport); ok { - result = trim(fImport.ObjectName) - } else if fExport, ok := fPackage.Reference.(*parser.FObjectExport); ok { - result = trim(fExport.ObjectName) - } - - return result -} - -func FPackageIndexToString(index interface{}) string { - fPackage := index.(*parser.FPackageIndex) - - if fImport, ok := fPackage.Reference.(*parser.FObjectImport); ok { - return trim(fImport.ObjectName) - } else if fExport, ok := fPackage.Reference.(*parser.FObjectExport); ok { - return trim(fExport.ObjectName) - } - - return "" -} diff --git a/validation/paks.go b/validation/paks.go deleted file mode 100644 index 6996eae2..00000000 --- a/validation/paks.go +++ /dev/null @@ -1,266 +0,0 @@ -package validation - -import ( - "context" - "fmt" - "runtime/debug" - "strings" - - "github.com/Vilsol/ue4pak/parser" - "github.com/rs/zerolog/log" - - // Import satisfactory-specific types - _ "github.com/Vilsol/ue4pak/parser/games/satisfactory" -) - -var classInheritance = map[string]string{ - // FGItemDescriptor Tree - "FGItemDescriptor": "", - "FGBuildDescriptor": "FGItemDescriptor", - "FGEquipmentDescriptor": "FGItemDescriptor", - "FGItemDescriptorBiomass": "FGItemDescriptor", - "FGItemDescriptorNuclearFuel": "FGItemDescriptor", - // "FGNoneDescriptor": "FGItemDescriptor", - "FGResourceDescriptor": "FGItemDescriptor", - "FGWildCardDescriptor": "FGItemDescriptor", - "FGResourceSinkCreditDescriptor": "FGItemDescriptor", - - "FGBuildingDescriptor": "FGBuildDescriptor", - "FGVehicleDescriptor": "FGBuildDescriptor", - - "FGDecorDescriptor": "FGBuildingDescriptor", - "FGPoleDescriptor": "FGBuildingDescriptor", - - "FGConsumableDescriptor": "FGEquipmentDescriptor", - "FGDecorationDescriptor": "FGEquipmentDescriptor", - - "FGResourceDescriptorGeyser": "FGResourceDescriptor", - - // FGBuildable Tree - "FGBuildable": "", - "FGBuildableConveyorBase": "FGBuildable", - "FGBuildableDecor": "FGBuildable", - "FGBuildableFactory": "FGBuildable", - "FGBuildableFactoryBuilding": "FGBuildable", - "FGBuildableHubTerminal": "FGBuildable", - "FGBuildablePole": "FGBuildable", - "FGBuildablePowerPole": "FGBuildable", - "FGBuildableRailroadBridge": "FGBuildable", - "FGBuildableRailroadTrack": "FGBuildable", - "FGBuildableBuildableRoad": "FGBuildable", - "FGBuildableSpeedSign": "FGBuildable", - "FGBuildableStandaloneSign": "FGBuildable", - "FGBuildableWire": "FGBuildable", - - "FGBuildableConveyorBelt": "FGBuildableConveyorBase", - "FGBuildableConveyorLift": "FGBuildableConveyorBase", - - "FGBuildableConveyorAttachment": "FGBuildableFactory", - "FGBuildableDockingStation": "FGBuildableFactory", - "FGBuildableGenerator": "FGBuildableFactory", - "FGBuildableManufacturer": "FGBuildableFactory", - "FGBuildableRadarTower": "FGBuildableFactory", - "FGBuildableRailroadSignal": "FGBuildableFactory", - "FGBuildableRailroadSwitchControl": "FGBuildableFactory", - "FGBuildableResourceExtractor": "FGBuildableFactory", - "FGBuildableSpaceElevator": "FGBuildableFactory", - "FGBuildableStorage": "FGBuildableFactory", - "FGBuildableTradingPost": "FGBuildableFactory", - "FGBuildableTrainPlatform": "FGBuildableFactory", - "FGBuildableWindTurbine": "FGBuildableFactory", - "FGBuildableResourceSink": "FGBuildableFactory", - "FGBuildablePipeReservoir": "FGBuildableFactory", - "FGBuildableResourceSinkShop": "FGBuildableFactory", - "FGBuildablePipePart": "FGBuildableFactory", - - "FGBuildableFloor": "FGBuildableFactoryBuilding", - "FGBuildableFoundation": "FGBuildableFactoryBuilding", - "FGBuildableWalkway": "FGBuildableFactoryBuilding", - "FGBuildableWall": "FGBuildableFactoryBuilding", - - "FGConveyorPoleStackable": "FGBuildablePole", - - "FGBuildableAttachmentMerger": "FGBuildableConveyorAttachment", - "FGBuildableAttachmentSplitter": "FGBuildableConveyorAttachment", - "FGBuildableSplitterSmart": "FGBuildableAttachmentSplitter", - - "FGBuildableGeneratorFuel": "FGBuildableGenerator", - "FGBuildableGeneratorGeoThermal": "FGBuildableGenerator", - "FGBuildableGeneratorNuclear": "FGBuildableGeneratorFuel", - - "FGBuildableAutomatedWorkBench": "FGBuildableManufacturer", - "FGBuildableConverter": "FGBuildableManufacturer", - - "FGBuildableCentralStorageContainer": "FGBuildableStorage", - - "FGBuildableRailroadStation": "FGBuildableTrainPlatform", - "FGBuildableTrainPlatformCargo": "FGBuildableTrainPlatform", - "FGBuildableTrainPlatformEmpty": "FGBuildableTrainPlatform", - - "FGBuildableRamp": "FGBuildableFoundation", - "FGBuildableStair": "FGBuildableFoundation", - - "FGBuildablePoweredWall": "FGBuildableWall", - "FGBuildableSignWall": "FGBuildableWall", - - "FGBuildablePipeHyperPart": "FGBuildablePipePart", - "FGBuildablePipeHyperStart": "FGBuildablePipeHyperPart", - "FGPipeHyperStart": "FGBuildablePipeHyperPart", - - // FGBuildablePipeBase Tree - "FGBuildablePipeBase": "", - "FGBuildablePipeHype": "FGBuildablePipeBase", - "FGBuildablePipeline": "FGBuildablePipeBase", - "FGBuildablePipeHyper": "FGBuildablePipeBase", - - // FGRecipe Tree - "FGRecipe": "", - "FGResearchRecipe": "FGRecipe", - - // FGBuildCategory Tree - "FGBuildCategory": "", - "FGBuildSubCategory": "FGBuildCategory", - - // FGResourceNode Tree - "FGResourceNode": "", - "FGResourceNodeGeyser": "FGResourceNode", - "FGResourceDeposit": "FGResourceNode", - - // FGUnlock Tree - "FGUnlock": "", - "FGUnlockRecipe": "FGUnlock", - "FGUnlockScannableResource": "FGUnlock", - - // FGCharacterBase Tree - "FGCharacterBase": "", - "FGCreature": "FGCharacterBase", - "FGEnemy": "FGCreature", - - // FGBuildablePipelineAttachment Tree - "FGBuildablePipelineAttachment": "", - "FGBuildablePipelineJunction": "FGBuildablePipelineAttachment", - "FGBuildablePipelinePump": "FGBuildablePipelineAttachment", - - // FGEquipment Tree - "FGEquipment": "", - "FGConsumableEquipment": "FGEquipment", - - // FGVehicle Tree - "FGVehicle": "", - "FGRailroadVehicle": "FGVehicle", - "FGLocomotive": "FGRailroadVehicle", - "FGFreightWagon": "FGRailroadVehicle", - - // Root - // "FGFactoryConnectionComponent": "", - "FGSchematic": "", - "FGResearchTree": "", - "FGResearchTreeNode": "", - "FGItemCategory": "", - "FGSchematicCategory": "", - "FGInventoryComponent": "", - "FGDamageOverTime": "", - "FGResourceSinkSettings": "", - "FGWorkBench": "", - "FGEquipmentAttachment": "", - - // Special - "BodySetup": "", -} - -func AttemptExtractDataFromPak(ctx context.Context, reader parser.PakReader) (map[string]map[string][]interface{}, error) { - var err error - defer func() { - if r := recover(); r != nil { - err = fmt.Errorf("%s\n%s", r, string(debug.Stack())) - } - }() - - return ExtractDataFromPak(ctx, reader), err -} - -// TODO Extract Images -func ExtractDataFromPak(ctx context.Context, reader parser.PakReader) map[string]map[string][]interface{} { - p := parser.NewParser(reader) - - entries := make([]*parser.PakEntrySet, 0) - p.ProcessPak(ctx, nil, func(s string, entry *parser.PakEntrySet, _ *parser.PakFile) { - entries = append(entries, entry) - }) - - exportsData := make(map[string]map[string][]interface{}) - - for _, entry := range entries { - exportData := make(map[string][]interface{}) - for _, export := range entry.Exports { - if export.Export.TemplateIndex.Reference != nil { - if imp, ok := export.Export.TemplateIndex.Reference.(*parser.FObjectImport); ok { - cleanName := trim(imp.ClassName) - treeSize := GetTreeSize(cleanName) - if treeSize > 0 || strings.HasPrefix(cleanName, "BP_") { - if _, ok := exportData[cleanName]; !ok { - exportData[cleanName] = make([]interface{}, 0) - } - - exportData[cleanName] = append(exportData[cleanName], DecodePropertyFields(ctx, export.Data.Properties)) - } else { - if _, ok := ignoredClasses[cleanName]; !ok { - if !strings.HasPrefix(cleanName, "Widget_") && - !strings.HasPrefix(cleanName, "ParticleModule") { - log.Warn().Msgf("Parsing unknown class name: %s", cleanName) - - if _, ok := exportData[cleanName]; !ok { - exportData[cleanName] = make([]interface{}, 0) - } - - exportData[cleanName] = append(exportData[cleanName], DecodePropertyFields(ctx, export.Data.Properties)) - } - } - } - } - } - } - - if len(exportData) > 0 { - exportsData[trim(entry.ExportRecord.FileName)] = exportData - } - } - - return exportsData -} - -func trim(s string) string { - return strings.Trim(s, "\x00") -} - -func GetTreeSize(className string) int { - size := 0 - - for { - parent, ok := classInheritance[className] - - if !ok { - break - } - - size++ - className = parent - } - - return size -} - -func IsA(child string, parent string) bool { - for { - if parent == child { - return true - } - - var ok bool - child, ok = classInheritance[child] - - if !ok { - return false - } - } -} diff --git a/validation/paks_test.go b/validation/paks_test.go deleted file mode 100644 index 2a8bbc32..00000000 --- a/validation/paks_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package validation - -import ( - "context" - "encoding/json" - "fmt" - "os" - "path/filepath" - "testing" - "time" - - "github.com/Vilsol/ue4pak/parser" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func TestExtractDataFromPak(t *testing.T) { - paks, err := filepath.Glob("paks/*.pak") - - ctx := context.Background() - zerolog.SetGlobalLevel(zerolog.ErrorLevel) - log.Logger = zerolog.New(zerolog.ConsoleWriter{ - Out: os.Stdout, - TimeFormat: time.RFC3339, - }).With().Timestamp().Logger() - - if err != nil { - panic(err) - } - - for _, f := range paks { - fmt.Println("Parsing file:", f) - - data, err := os.ReadFile(f) - if err != nil { - panic(err) - } - - reader := &parser.PakByteReader{ - Bytes: data, - } - - pakData, err := AttemptExtractDataFromPak(ctx, reader) - - if err != nil { - log.Err(err).Msg("error parsing pak") - t.Error(err) - } else { - marshal, _ := json.MarshalIndent(pakData, "", " ") - - if err := os.WriteFile(f+".json", marshal, 0o644); err != nil { - t.Error(err) - } - } - } - - /* - f, _ := os.Open("E:\\Program Files\\Epic Games\\SatisfactoryExperimental\\FactoryGame\\Content\\Paks\\FactoryGame-WindowsNoEditor.pak") - pakData, err := AttemptExtractDataFromPak(f) - - if err != nil { - fmt.Println(err) - } - - marshal, _ := json.MarshalIndent(pakData, "", " ") - - ioutil.WriteFile("E:\\Program Files\\Epic Games\\SatisfactoryExperimental\\FactoryGame\\Content\\Paks\\FactoryGame-WindowsNoEditor.pak.json", marshal, 0644) - */ -} diff --git a/validation/validation.go b/validation/validation.go index af9cad44..0f97cfb3 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "log/slog" "path" "path/filepath" "sort" @@ -17,8 +18,8 @@ import ( "time" "github.com/Masterminds/semver/v3" + "github.com/Vilsol/slox" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "github.com/xeipuuv/gojsonschema" "google.golang.org/grpc" @@ -137,7 +138,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal // Extract all possible metadata conn, err := grpc.Dial(viper.GetString("extractor_host"), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - return nil, errors.Wrap(err, "failed to connect to metadata server") + return nil, fmt.Errorf("failed to connect to metadata server: %w", err) } defer conn.Close() @@ -155,7 +156,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal for _, version := range smlVersions { constraint, err := semver.NewConstraint(modInfo.SMLVersion) if err != nil { - return nil, errors.Wrap(err, "failed to create semver constraint") + return nil, fmt.Errorf("failed to create semver constraint: %w", err) } if constraint.Check(semver.MustParse(version.Version)) { @@ -174,13 +175,13 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal grpc.MaxCallRecvMsgSize(1024*1024*1024), // 1GB ) if err != nil { - return nil, errors.Wrap(err, "failed to parse mod") + return nil, fmt.Errorf("failed to parse mod: %w", err) } defer func(stream parser.Parser_ParseClient) { err := stream.CloseSend() if err != nil { - log.Ctx(ctx).Err(err).Msg("failed closing parser stream") + slox.Error(ctx, "failed closing parser stream", slog.Any("err", err)) } }(stream) @@ -192,10 +193,10 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal if errors.Is(err, io.EOF) || err == io.EOF { break } - return nil, errors.Wrap(err, "failed reading parser stream") + return nil, fmt.Errorf("failed reading parser stream: %w", err) } - log.Ctx(ctx).Info().Str("path", asset.GetPath()).Msg("received asset from parser") + slox.Info(ctx, "received asset from parser", slog.String("path", asset.GetPath())) if asset.Path == "metadata.json" { out, err := ExtractMetadata(asset.Data) @@ -208,7 +209,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal storage.UploadModAsset(ctx, modInfo.ModReference, asset.GetPath(), asset.GetData()) } - storage.DeleteOldModAssets(modInfo.ModReference, beforeUpload) + storage.DeleteOldModAssets(ctx, modInfo.ModReference, beforeUpload) } modInfo.Size = int64(len(body)) @@ -217,15 +218,15 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal _, err = hash.Write(body) if err != nil { - log.Err(err).Msg("error hashing pak") + slox.Error(ctx, "error hashing pak", slog.Any("err", err)) } modInfo.Hash = hex.EncodeToString(hash.Sum(nil)) version, err := semver.StrictNewVersion(modInfo.Version) if err != nil { - log.Err(err).Msg("error parsing semver") - return nil, errors.Wrap(err, "error parsing semver") + slox.Error(ctx, "error parsing semver", slog.Any("err", err)) + return nil, fmt.Errorf("error parsing semver: %w", err) } modInfo.Semver = version @@ -481,12 +482,12 @@ func validateMultiTargetPlugin(archive *zip.Reader, withValidation bool, modRefe for _, uPluginFile := range uPluginFiles { file, err := uPluginFile.Open() if err != nil { - return nil, errors.Wrap(err, "failed to open .uplugin file") + return nil, fmt.Errorf("failed to open .uplugin file: %w", err) } data, err := io.ReadAll(file) file.Close() if err != nil { - return nil, errors.Wrap(err, "failed to read .uplugin file") + return nil, fmt.Errorf("failed to read .uplugin file: %w", err) } if lastData != nil && !bytes.Equal(lastData, data) { @@ -499,7 +500,7 @@ func validateMultiTargetPlugin(archive *zip.Reader, withValidation bool, modRefe // All the .uplugin files should be the same at this point (assuming validation is enabled) modInfo, err := validateUPluginJSON(archive, uPluginFiles[0], withValidation, modReference) if err != nil { - return nil, errors.Wrap(err, "failed to validate multi-target plugin") + return nil, fmt.Errorf("failed to validate multi-target plugin: %w", err) } modInfo.Targets = targets diff --git a/validation/virustotal.go b/validation/virustotal.go index bbfe8dc5..171fb3e3 100644 --- a/validation/virustotal.go +++ b/validation/virustotal.go @@ -2,12 +2,13 @@ package validation import ( "context" + "fmt" "io" + "log/slog" "time" + "github.com/Vilsol/slox" "github.com/VirusTotal/vt-go" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/viper" "golang.org/x/sync/errgroup" ) @@ -32,7 +33,7 @@ type AnalysisResults struct { } `json:"attributes,omitempty"` } -func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, error) { +func ScanFiles(_ context.Context, files []io.Reader, names []string) (bool, error) { errs, gctx := errgroup.WithContext(context.Background()) fileCount := len(files) @@ -43,7 +44,7 @@ func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, er errs.Go(func() error { ok, err := scanFile(gctx, files[count], names[count]) if err != nil { - return errors.Wrap(err, "failed to scan file") + return fmt.Errorf("failed to scan file: %w", err) } c <- ok return nil @@ -63,7 +64,7 @@ func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, er } if err := errs.Wait(); err != nil { - return false, errors.Wrap(err, "failed to scan file") + return false, fmt.Errorf("failed to scan file: %w", err) } return success, nil @@ -72,12 +73,12 @@ func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, er func scanFile(ctx context.Context, file io.Reader, name string) (bool, error) { scan, err := client.NewFileScanner().Scan(file, name, nil) if err != nil { - return false, errors.Wrap(err, "failed to scan file") + return false, fmt.Errorf("failed to scan file: %w", err) } analysisID := scan.ID() - log.Info().Msgf("uploaded virus scan for file %s and analysis ID: %s", name, analysisID) + slox.Info(ctx, "uploaded virus scan", slog.String("file", name), slog.String("analysis_id", analysisID)) for { time.Sleep(time.Second * 15) @@ -86,7 +87,7 @@ func scanFile(ctx context.Context, file io.Reader, name string) (bool, error) { _, err = client.GetData(vt.URL("analyses/%s", analysisID), &target) if err != nil { - return false, errors.Wrap(err, "failed to get analysis results") + return false, fmt.Errorf("failed to get analysis results: %w", err) } if target.Attributes.Status != "completed" { @@ -94,18 +95,18 @@ func scanFile(ctx context.Context, file io.Reader, name string) (bool, error) { } if target.Attributes.Stats == nil { - log.Error().Msgf("no stats available. failing file: %s", name) + slox.Error(ctx, "no stats available", slog.Any("err", err), slog.String("file", name)) return false, nil } if target.Attributes.Stats.Malicious == nil || target.Attributes.Stats.Suspicious == nil { - log.Error().Msgf("unable to determine malicious or suspicious File: %s", name) + slox.Error(ctx, "unable to determine malicious or suspicious file", slog.Any("err", err), slog.String("file", name)) return false, nil } // Why 1? Well because some company made a shitty AI and it flags random mods. if *target.Attributes.Stats.Malicious > 1 || *target.Attributes.Stats.Suspicious > 1 { - log.Error().Msgf("suspicious or malicious file found: %s", name) + slox.Error(ctx, "suspicious or malicious file found", slog.Any("err", err), slog.String("file", name)) return false, nil } From a807c4066ecd4e6a4990ae8c7a2f4bcb610c81ee Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Sat, 21 Oct 2023 03:35:57 +0300 Subject: [PATCH 02/19] refactor: more yes --- config/config.go | 8 +++++--- db/postgres/postgres.go | 2 +- models/filters.go | 6 +++++- storage/s3.go | 10 ++++++++-- storage/storage.go | 5 ++++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index 9cc2fd79..545731f2 100644 --- a/config/config.go +++ b/config/config.go @@ -57,9 +57,11 @@ func InitializeConfig(baseCtx context.Context) context.Context { }, )) } else { - slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{ - AddSource: true, - }))) + slog.SetDefault(slog.New(StackRewriter{ + Upstream: slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{ + AddSource: true, + }), + })) } if baseCtx == nil { diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go index 2f8b2727..76b94b1e 100644 --- a/db/postgres/postgres.go +++ b/db/postgres/postgres.go @@ -77,7 +77,7 @@ func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (stri attrs = append(attrs, slog.Float64("elapsed", elapsed)) attrs = append(attrs, slog.Int64("rows", rows)) - slox.LogAttrs(ctx, level, sql, attrs...) + slog.LogAttrs(ctx, level, sql, attrs...) } } diff --git a/models/filters.go b/models/filters.go index 856044e3..72d1be24 100644 --- a/models/filters.go +++ b/models/filters.go @@ -285,7 +285,11 @@ func ApplyChanges(changes interface{}, to interface{}) error { return fmt.Errorf("failed to create decoder: %w", err) } - return fmt.Errorf("failed to decode changes: %w", dec.Decode(changes)) + if err := dec.Decode(changes); err != nil { + return fmt.Errorf("failed to decode changes: %w", err) + } + + return nil } type BootstrapVersionFilter struct { diff --git a/storage/s3.go b/storage/s3.go index 92eec1a2..185c1f38 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -145,8 +145,11 @@ func (s3o *S3) CompleteMultipartUpload(key string) error { MultipartUpload: &s3.CompletedMultipartUpload{Parts: completedParts}, UploadId: aws.String(id), }) + if err != nil { + return fmt.Errorf("failed to complete multipart upload: %w", err) + } - return fmt.Errorf("failed to complete multipart upload: %w", err) + return nil } func (s3o *S3) Rename(from string, to string) error { @@ -157,8 +160,11 @@ func (s3o *S3) Rename(from string, to string) error { CopySource: aws.String(viper.GetString("storage.bucket") + from), Key: aws.String(cleanedKey), }) + if err != nil { + return fmt.Errorf("failed to copy object: %w", err) + } - return fmt.Errorf("failed to copy object: %w", err) + return nil } func (s3o *S3) Delete(key string) error { diff --git a/storage/storage.go b/storage/storage.go index 9863c6f7..33421a4d 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -164,7 +164,10 @@ func UploadUserAvatar(ctx context.Context, userID string, data io.ReadSeeker) (b func() error { var err error key, err = storage.Put(ctx, key, data) - return fmt.Errorf("failed to upload user avatar: %w", err) + if err != nil { + return fmt.Errorf("failed to upload user avatar: %w", err) + } + return nil }, retry.Attempts(3), retry.LastErrorOnly(true), From 5c19e400f7737c8cdb4ade1b1234a902fda3f9e3 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Sun, 22 Oct 2023 23:41:34 +0300 Subject: [PATCH 03/19] feat: preliminary ent --- .gitignore | 3 +- api.go => api/api.go | 7 +- cmd/api/serve.go | 4 +- db/ent.go | 124 ++++++++++++++++ db/pgxpooldriver.go | 269 ++++++++++++++++++++++++++++++++++ db/schema/announcement.go | 25 ++++ db/schema/mixin_id.go | 25 ++++ db/schema/mixin_softdelete.go | 87 +++++++++++ db/schema/mixin_time.go | 33 +++++ go.mod | 12 +- go.sum | 29 ++++ storage/storage.go | 2 + tests/utils.go | 2 +- tool_imports.go | 9 ++ tools.go | 38 ++++- 15 files changed, 660 insertions(+), 9 deletions(-) rename api.go => api/api.go (99%) create mode 100644 db/ent.go create mode 100644 db/pgxpooldriver.go create mode 100644 db/schema/announcement.go create mode 100644 db/schema/mixin_id.go create mode 100644 db/schema/mixin_softdelete.go create mode 100644 db/schema/mixin_time.go create mode 100644 tool_imports.go diff --git a/.gitignore b/.gitignore index 7baf40da..da129573 100755 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ config.json vendor/ /docs/ /paks/ -*.smod \ No newline at end of file +*.smod +/ent/ \ No newline at end of file diff --git a/api.go b/api/api.go similarity index 99% rename from api.go rename to api/api.go index 05758919..d47da661 100644 --- a/api.go +++ b/api/api.go @@ -1,4 +1,4 @@ -package smr +package api import ( "context" @@ -75,6 +75,11 @@ func Initialize(baseCtx context.Context) context.Context { redis.InitializeRedis(ctx) postgres.InitializePostgres(ctx) + ctx, err := db.WithDB(ctx) + if err != nil { + panic(err) + } + storage.InitializeStorage(ctx) oauth.InitializeOAuth() util.InitializeSecurity() diff --git a/cmd/api/serve.go b/cmd/api/serve.go index 2fc957c9..6274a7ff 100644 --- a/cmd/api/serve.go +++ b/cmd/api/serve.go @@ -1,6 +1,6 @@ package main -import "github.com/satisfactorymodding/smr-api" +import "github.com/satisfactorymodding/smr-api/api" // @title Satisfactory Mod Repo API // @version 1 @@ -12,5 +12,5 @@ import "github.com/satisfactorymodding/smr-api" // @host api.ficsit.app // @BasePath /v1 func main() { - smr.Start() + api.Start() } diff --git a/db/ent.go b/db/ent.go new file mode 100644 index 00000000..e917c85a --- /dev/null +++ b/db/ent.go @@ -0,0 +1,124 @@ +package db + +import ( + "context" + "errors" + "fmt" + "github.com/Vilsol/slox" + "github.com/jackc/pgx/v5/pgxpool" + "github.com/satisfactorymodding/smr-api/ent" + "github.com/spf13/viper" + + _ "github.com/jackc/pgx/v5/stdlib" + _ "github.com/satisfactorymodding/smr-api/ent/runtime" +) + +type dbKey struct{} +type txKey struct{} + +type dbClient struct { + Client *ent.Client +} + +type Config struct { + Address string +} + +type ShowDB struct{} + +func WithDB(ctx context.Context) (context.Context, error) { + slox.Info(ctx, "initializing db") + + poolConfig, err := pgxpool.ParseConfig(fmt.Sprintf( + "sslmode=disable host=%s port=%d user=%s dbname=%s password=%s", + viper.GetString("database.postgres.host"), + viper.GetInt("database.postgres.port"), + viper.GetString("database.postgres.user"), + viper.GetString("database.postgres.db"), + viper.GetString("database.postgres.pass"), + )) + if err != nil { + return nil, fmt.Errorf("failed to parse database connection string: %w", err) + } + + pool, err := pgxpool.NewWithConfig(ctx, poolConfig) + if err != nil { + return nil, fmt.Errorf("failed to connect to database: %w", err) + } + + poolDriver := NewPgxPoolDriver(pool) + + realClient := ent.NewClient( + ent.Driver(poolDriver), + ent.Log(func(v ...interface{}) { + fmt.Println(v...) + slox.Info(ctx, fmt.Sprint(v...)) + }), + ) + + return context.WithValue(ctx, dbKey{}, &dbClient{ + Client: realClient, + }), nil +} + +func From(ctx context.Context) *ent.Client { + tx := ctx.Value(txKey{}) + if tx != nil { + return tx.(*ent.Tx).Client() + } + + db := ctx.Value(dbKey{}) + if db == nil { + return nil + } + return db.(*dbClient).Client +} + +func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, onError func() error) error { + db := ctx.Value(dbKey{}) + if db == nil { + return errors.New("db key not found in context") + } + + client := db.(*dbClient).Client + + tx, err := client.Tx(ctx) + if err != nil { + return fmt.Errorf("failed to start database transaction: %w", err) + } + + newCtx := context.WithValue(ctx, txKey{}, tx) + + if err := f(newCtx, tx); err != nil { + finalError := err + + func() { + defer func() { + if err := recover(); err != nil { + finalError = errors.Join(finalError, fmt.Errorf("panic when rolling back: %w", err)) + } + }() + + rollbackErr := tx.Rollback() + if rollbackErr != nil { + finalError = errors.Join(finalError, fmt.Errorf("failed rolling back transaction: %w", rollbackErr)) + } + + if onError() != nil { + onErrorErr := onError() + if onErrorErr != nil { + finalError = errors.Join(finalError, onErrorErr) + } + } + }() + + return finalError + } + + err = tx.Commit() + if err != nil { + return fmt.Errorf("failed committing transaction: %w", err) + } + + return nil +} diff --git a/db/pgxpooldriver.go b/db/pgxpooldriver.go new file mode 100644 index 00000000..8f930bf9 --- /dev/null +++ b/db/pgxpooldriver.go @@ -0,0 +1,269 @@ +// Taken from https://github.com/ent/ent/discussions/1797#discussioncomment-5111111 + +package db + +import ( + "context" + stdsql "database/sql" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "fmt" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/trace" +) + +func NewPgxPoolDriver(pool *pgxpool.Pool) dialect.Driver { + return &EntPgxpoolDriver{ + pool: pool, + tracer: otel.Tracer("pgxpool"), + } +} + +type EntPgxpoolDriver struct { + pool *pgxpool.Pool + tracer trace.Tracer +} + +func (e *EntPgxpoolDriver) Exec(ctx context.Context, query string, args, result any) error { + var _ stdsql.Result + argv, ok := args.([]any) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect []any for args", result) + } + switch result := result.(type) { + case nil: + if _, err := e.pool.Exec(ctx, query, argv...); err != nil { + return err + } + case *sql.Result: + commandTag, err := e.pool.Exec(ctx, query, argv...) + if err != nil { + return err + } + *result = execResult{rowsAffected: commandTag.RowsAffected()} + default: + return fmt.Errorf("dialect/sql: invalid type %T. expect *sql.Result", result) + } + return nil +} + +func (e *EntPgxpoolDriver) Query(ctx context.Context, query string, args, v any) error { + vr, ok := v.(*sql.Rows) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect *sql.Rows", v) + } + argv, ok := args.([]any) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect []any for args", args) + } + pgxRows, err := e.pool.Query(ctx, query, argv...) + if err != nil { + return err + } + columnScanner := &entPgxRows{pgxRows: pgxRows} + *vr = sql.Rows{ + columnScanner, + } + return nil +} + +func (e *EntPgxpoolDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + commandTag, err := e.pool.Exec(ctx, query, args...) + if err != nil { + return nil, err + } + return &execResult{rowsAffected: commandTag.RowsAffected()}, nil +} + +func (e *EntPgxpoolDriver) Tx(ctx context.Context) (dialect.Tx, error) { + return e.BeginTx(ctx, nil) +} + +func (e *EntPgxpoolDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error) { + ctx, span := e.tracer.Start(ctx, "BeginTx", trace.WithAttributes()) + defer span.End() + + pgxOpts, err := getPgxTxOptions(opts) + if err != nil { + return nil, err + } + tx, err := e.pool.BeginTx(ctx, *pgxOpts) + if err != nil { + return nil, err + } + return &EntPgxPoolTx{ + tx: tx, + }, nil +} + +func getPgxTxOptions(opts *sql.TxOptions) (*pgx.TxOptions, error) { + var pgxOpts pgx.TxOptions + if opts == nil { + return &pgxOpts, nil + } + switch opts.Isolation { + case stdsql.LevelDefault: + case stdsql.LevelReadUncommitted: + pgxOpts.IsoLevel = pgx.ReadUncommitted + case stdsql.LevelReadCommitted: + pgxOpts.IsoLevel = pgx.ReadCommitted + case stdsql.LevelRepeatableRead, stdsql.LevelSnapshot: + pgxOpts.IsoLevel = pgx.RepeatableRead + case stdsql.LevelSerializable: + pgxOpts.IsoLevel = pgx.Serializable + default: + return nil, fmt.Errorf("unsupported isolation: %v", opts.Isolation) + } + + if opts.ReadOnly { + pgxOpts.AccessMode = pgx.ReadOnly + } + return &pgxOpts, nil +} + +func (e *EntPgxpoolDriver) Close() error { + e.pool.Close() + return nil +} + +func (e *EntPgxpoolDriver) Dialect() string { + return dialect.Postgres +} + +type EntPgxPoolTx struct { + tx pgx.Tx +} + +func (e *EntPgxPoolTx) Exec(ctx context.Context, query string, args, result any) error { + var _ stdsql.Result + + argv, ok := args.([]any) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect []any for args", result) + } + switch result := result.(type) { + case nil: + if _, err := e.tx.Exec(ctx, query, argv...); err != nil { + return err + } + case *sql.Result: + commandTag, err := e.tx.Exec(ctx, query, argv...) + if err != nil { + return err + } + *result = execResult{rowsAffected: commandTag.RowsAffected()} + default: + return fmt.Errorf("dialect/sql: invalid type %T. expect *sql.Result", result) + } + return nil +} + +func (e *EntPgxPoolTx) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + commandTag, err := e.tx.Exec(ctx, query, args...) + if err != nil { + return nil, err + } + return &execResult{rowsAffected: commandTag.RowsAffected()}, nil +} + +func (e *EntPgxPoolTx) Query(ctx context.Context, query string, args, v any) error { + vr, ok := v.(*sql.Rows) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect *sql.Rows", v) + } + argv, ok := args.([]any) + if !ok { + return fmt.Errorf("dialect/sql: invalid type %T. expect []any for args", args) + } + pgxRows, err := e.tx.Query(ctx, query, argv...) + if err != nil { + return err + } + columnScanner := &entPgxRows{pgxRows: pgxRows} + *vr = sql.Rows{ + columnScanner, + } + return nil +} + +func (e *EntPgxPoolTx) Commit() error { + return e.tx.Commit(context.TODO()) +} + +func (e *EntPgxPoolTx) Rollback() error { + return e.tx.Rollback(context.TODO()) +} + +func (e *EntPgxPoolTx) PGXTransaction() pgx.Tx { + return e.tx +} + +type entPgxRows struct { + pgxRows pgx.Rows +} + +func (e entPgxRows) Close() error { + e.pgxRows.Close() + return nil +} + +// ColumnTypes returns column information such as column type, length, +// and nullable. Some information may not be available from some drivers. +func (e entPgxRows) ColumnTypes() ([]*stdsql.ColumnType, error) { + return []*stdsql.ColumnType{}, nil +} + +// Columns returns the column names. +// Columns returns an error if the rows are closed. +func (e entPgxRows) Columns() ([]string, error) { + fieldDescs := e.pgxRows.FieldDescriptions() + columnNames := make([]string, len(fieldDescs)) + for i, fd := range fieldDescs { + columnNames[i] = fd.Name + + } + return columnNames, nil +} + +func (e entPgxRows) Err() error { + return e.pgxRows.Err() +} + +func (e entPgxRows) Next() bool { + return e.pgxRows.Next() +} + +// NextResultSet prepares the next result set for reading. It reports whether +// there is further result sets, or false if there is no further result set +// or if there is an error advancing to it. The Err method should be consulted +// to distinguish between the two cases. +// +// After calling NextResultSet, the Next method should always be called before +// scanning. If there are further result sets they may not have rows in the result +// set. +func (e entPgxRows) NextResultSet() bool { + // For now this does not seem like a must have for normal database functionality. + // This seems to be useful if we want to send 2 sql statements in a single query + // and when the results of the first query are exhausted, then check if the NextResultSet + // has values. + return e.pgxRows.Next() +} + +func (e entPgxRows) Scan(dest ...any) error { + return e.pgxRows.Scan(dest...) +} + +type execResult struct { + lastInsertId int64 + rowsAffected int64 +} + +func (e execResult) LastInsertId() (int64, error) { + return e.lastInsertId, nil +} + +func (e execResult) RowsAffected() (int64, error) { + return e.rowsAffected, nil +} diff --git a/db/schema/announcement.go b/db/schema/announcement.go new file mode 100644 index 00000000..c43dd4d6 --- /dev/null +++ b/db/schema/announcement.go @@ -0,0 +1,25 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +type Announcement struct { + ent.Schema +} + +func (Announcement) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (Announcement) Fields() []ent.Field { + return []ent.Field{ + field.String("message"), + field.String("importance"), + } +} diff --git a/db/schema/mixin_id.go b/db/schema/mixin_id.go new file mode 100644 index 00000000..975ef2b4 --- /dev/null +++ b/db/schema/mixin_id.go @@ -0,0 +1,25 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" + "github.com/satisfactorymodding/smr-api/util" +) + +type IDMixin struct { + mixin.Schema +} + +func (IDMixin) Fields() []ent.Field { + return []ent.Field{ + field.String("id").DefaultFunc(util.GenerateUniqueID), + } +} + +func (IDMixin) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("id"), + } +} diff --git a/db/schema/mixin_softdelete.go b/db/schema/mixin_softdelete.go new file mode 100644 index 00000000..a8a7358d --- /dev/null +++ b/db/schema/mixin_softdelete.go @@ -0,0 +1,87 @@ +package schema + +import ( + "context" + "fmt" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" + + gen "github.com/satisfactorymodding/smr-api/ent" + "github.com/satisfactorymodding/smr-api/ent/hook" + "github.com/satisfactorymodding/smr-api/ent/intercept" +) + +// SoftDeleteMixin implements the soft delete pattern for schemas. +type SoftDeleteMixin struct { + mixin.Schema +} + +// Fields of the SoftDeleteMixin. +func (SoftDeleteMixin) Fields() []ent.Field { + return []ent.Field{ + field.Time("deleted_at"). + Optional(), + } +} + +type softDeleteKey struct{} + +// SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators. +func SkipSoftDelete(parent context.Context) context.Context { + return context.WithValue(parent, softDeleteKey{}, true) +} + +// Interceptors of the SoftDeleteMixin. +func (d SoftDeleteMixin) Interceptors() []ent.Interceptor { + return []ent.Interceptor{ + intercept.TraverseFunc(func(ctx context.Context, q intercept.Query) error { + // Skip soft-delete, means include soft-deleted entities. + if skip, _ := ctx.Value(softDeleteKey{}).(bool); skip { + return nil + } + d.P(q) + return nil + }), + } +} + +// Hooks of the SoftDeleteMixin. +func (d SoftDeleteMixin) Hooks() []ent.Hook { + return []ent.Hook{ + hook.On( + func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Skip soft-delete, means delete the entity permanently. + if skip, _ := ctx.Value(softDeleteKey{}).(bool); skip { + return next.Mutate(ctx, m) + } + mx, ok := m.(interface { + SetOp(ent.Op) + Client() *gen.Client + SetDeleteTime(time.Time) + WhereP(...func(*sql.Selector)) + }) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + d.P(mx) + mx.SetOp(ent.OpUpdate) + mx.SetDeleteTime(time.Now()) + return mx.Client().Mutate(ctx, m) + }) + }, + ent.OpDeleteOne|ent.OpDelete, + ), + } +} + +// P adds a storage-level predicate to the queries and mutations. +func (d SoftDeleteMixin) P(w interface{ WhereP(...func(*sql.Selector)) }) { + w.WhereP( + sql.FieldIsNull(d.Fields()[0].Descriptor().Name), + ) +} diff --git a/db/schema/mixin_time.go b/db/schema/mixin_time.go new file mode 100644 index 00000000..92708032 --- /dev/null +++ b/db/schema/mixin_time.go @@ -0,0 +1,33 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" +) + +type TimeMixin struct { + mixin.Schema +} + +func (TimeMixin) Fields() []ent.Field { + return []ent.Field{ + field.Time("created_at"). + Immutable(). + Default(time.Now). + Optional(), + field.Time("updated_at"). + Default(time.Now). + UpdateDefault(time.Now). + Optional(), + } +} + +func (TimeMixin) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("deleted_at"), + } +} diff --git a/go.mod b/go.mod index b3fbd322..d03fb7ff 100755 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/satisfactorymodding/smr-api go 1.21 require ( + entgo.io/ent v0.12.4 github.com/99designs/gqlgen v0.17.39 github.com/MarvinJWendt/testza v0.5.2 github.com/Masterminds/semver/v3 v3.2.1 @@ -19,6 +20,7 @@ require ( github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis/v8 v8.11.5 github.com/golang-migrate/migrate/v4 v4.16.2 + github.com/jackc/pgx/v5 v5.4.3 github.com/lab259/go-migration v1.3.1 github.com/labstack/echo-contrib v0.15.0 github.com/labstack/echo/v4 v4.11.2 @@ -58,6 +60,7 @@ require ( ) require ( + ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect atomicgo.dev/assert v0.0.2 // indirect atomicgo.dev/cursor v0.2.0 // indirect atomicgo.dev/keyboard v0.2.9 // indirect @@ -68,7 +71,9 @@ require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29 // indirect github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 // indirect + github.com/agext/levenshtein v1.2.1 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bsm/redislock v0.7.2 // indirect github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 // indirect @@ -86,6 +91,7 @@ require ( github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/spec v0.20.9 // indirect @@ -96,6 +102,7 @@ require ( github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/glog v1.1.2 // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect github.com/google/uuid v1.3.1 // indirect github.com/gookit/color v1.5.4 // indirect @@ -107,9 +114,10 @@ require ( github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/hcl/v2 v2.13.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.4.3 // indirect + github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect @@ -126,6 +134,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/pterm/pterm v0.12.69 // indirect github.com/rivo/uniseg v0.4.4 // indirect @@ -151,6 +160,7 @@ require ( github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/zclconf/go-cty v1.8.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.11.0 // indirect diff --git a/go.sum b/go.sum index b0d0d079..ea6cbb21 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 h1:JnYs/y8RJ3+MiIUp+3RgyyeO48VHLAZimqiaZYnMKk8= +ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935/go.mod h1:isZrlzJ5cpoCoKFoY9knZug7Lq4pP1cm8g3XciLZ0Pw= atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg= atomicgo.dev/assert v0.0.2/go.mod h1:ut4NcI3QDdJtlmAxQULOmA13Gz6e2DWbSAS8RUOmNYQ= atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw= @@ -49,12 +51,16 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +entgo.io/ent v0.12.4 h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8= +entgo.io/ent v0.12.4/go.mod h1:Y3JVAjtlIk8xVZYSn3t3mf8xlZIn5SAOXZQxD6kKI+Q= github.com/99designs/gqlgen v0.17.39 h1:wPTAyc2fqVjAWT5DsJ21k/lLudgnXzURwbsjVNegFpU= github.com/99designs/gqlgen v0.17.39/go.mod h1:b62q1USk82GYIVjC60h02YguAZLqYZtvWml8KkhJps4= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= @@ -84,10 +90,14 @@ github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29/go.mod h1:Uz github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 h1:52m0LGchQBBVqJRyYYufQuIbVqRawmubW3OFGqK1ekw= github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk= @@ -205,6 +215,8 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= +github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= @@ -232,6 +244,8 @@ github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq github.com/go-redis/redis_rate/v9 v9.1.2 h1:H0l5VzoAtOE6ydd38j8MCq3ABlGLnvvbA1xDSVVCHgQ= github.com/go-redis/redis_rate/v9 v9.1.2/go.mod h1:oam2de2apSgRG8aJzwJddXbNu91Iyz1m8IKJE2vpvlQ= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= @@ -331,6 +345,8 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= +github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -343,6 +359,8 @@ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY= github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033 h1:R0efOJW2JdoZ7ValaK6iFhWHrlZFeRvV4alZbHg5hnQ= github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033/go.mod h1:JHpPOBFu/UpmWT79z9fw5lQn7Oem6lnkS3jN4ZQdfLQ= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -378,6 +396,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/lab259/go-migration v1.3.1 h1:9ymcS7IywHzcl/6xePMhht9fLUgPeZFUNbrj0f3z2mU= github.com/lab259/go-migration v1.3.1/go.mod h1:9SB2RbONCWrBN7VXFLt/qOU6ar/uJNnaIGnHDkYK+lE= github.com/lab259/rlog/v2 v2.1.0/go.mod h1:Rfy8HYLxXb0s/1F98p8fRtrCiIwxA8q5HqsQmXLvKfM= @@ -419,8 +439,12 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= +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/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -548,8 +572,10 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9 h1:HPsSGLvvTXQRENUWUPTJOiwjQhimBHgJrCzp+cKzma0= @@ -573,6 +599,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -804,6 +832,7 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= diff --git a/storage/storage.go b/storage/storage.go index 33421a4d..8451dfb7 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -81,6 +81,8 @@ func configToStorage(ctx context.Context, config Config) Storage { } panic("Unknown storage type: " + viper.GetString("storage.type")) + + return nil } func StartUploadMultipartMod(ctx context.Context, modID string, name string, versionID string) (bool, string) { diff --git a/tests/utils.go b/tests/utils.go index 15086cd3..8b40f4b2 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -8,7 +8,7 @@ import ( "github.com/Vilsol/slox" "github.com/machinebox/graphql" - "github.com/satisfactorymodding/smr-api" + smr "github.com/satisfactorymodding/smr-api/api" "github.com/satisfactorymodding/smr-api/auth" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/redis" diff --git a/tool_imports.go b/tool_imports.go new file mode 100644 index 00000000..de8f8e4f --- /dev/null +++ b/tool_imports.go @@ -0,0 +1,9 @@ +//go:build tools +// +build tools + +package main + +import ( + _ "github.com/99designs/gqlgen" + _ "github.com/swaggo/swag/cmd/swag" +) diff --git a/tools.go b/tools.go index bf720453..8582e63b 100644 --- a/tools.go +++ b/tools.go @@ -1,11 +1,43 @@ //go:build tools // +build tools -package smr +package main -import _ "github.com/99designs/gqlgen" -import _ "github.com/swaggo/swag/cmd/swag" +import ( + "entgo.io/ent/entc" + "entgo.io/ent/entc/gen" + "entgo.io/ent/schema/field" +) + +// go generate -tags tools -x ./... //go:generate protoc -I./proto --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative proto/parser/parser.proto //go:generate go run github.com/99designs/gqlgen generate //go:generate go run github.com/swaggo/swag/cmd/swag init --generalInfo cmd/api/serve.go +//go:generate go run tools.go + +func main() { + generateEnt() +} + +func generateEnt() { + err := entc.Generate("./db/schema", &gen.Config{ + Target: "./ent", + Package: "github.com/satisfactorymodding/smr-api/ent", + Features: []gen.Feature{ + gen.FeatureLock, + gen.FeatureModifier, + gen.FeatureUpsert, + gen.FeaturePrivacy, + gen.FeatureIntercept, + gen.FeatureSnapshot, + }, + IDType: &field.TypeInfo{ + Type: field.TypeString, + }, + }) + + if err != nil { + panic(err) + } +} From 0a59acd4c124e3666ef6b716d5ec1bec617f213d Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Sun, 29 Oct 2023 02:38:15 +0300 Subject: [PATCH 04/19] refactor: even more yes --- .gitignore | 4 +- .golangci.yml | 2 +- api/api.go | 23 +- conversion/graphql.go | 40 + db/ctx.go | 15 + db/ent.go | 50 +- db/pgxpooldriver.go | 38 +- db/postgres/announcement.go | 64 - db/postgres/bootstrap_version.go | 71 - db/postgres/postgres.go | 2 - db/postgres/postgres_types.go | 17 - db/postgres/sml_version.go | 53 - db/postgres/user.go | 19 - db/schema/guide.go | 39 + db/schema/guide_tags.go | 38 + db/schema/mixin_id.go | 1 + db/schema/mixin_softdelete.go | 19 +- db/schema/mixin_time.go | 13 +- db/schema/mod.go | 64 + db/schema/mod_tags.go | 38 + db/schema/sml_version.go | 38 + db/schema/sml_version_target.go | 42 + db/schema/tag.go | 36 + db/schema/user.go | 55 + db/schema/user_group.go | 43 + db/schema/user_mod.go | 39 + db/schema/user_session.go | 35 + db/schema/version.go | 51 + db/schema/version_dependency.go | 47 + db/statistics.go | 113 +- db/user.go | 70 + db/utils.go | 11 + generated/.gitignore | 2 - generated/README.md | 7 + generated/conv/announcement.go | 32 + generated/conv/sml_version.go | 85 + generated/docs/docs.go | 801 + generated/docs/swagger.json | 777 + generated/docs/swagger.yaml | 515 + generated/ent/announcement.go | 148 + generated/ent/announcement/announcement.go | 100 + generated/ent/announcement/where.go | 365 + generated/ent/announcement_create.go | 306 + generated/ent/announcement_delete.go | 88 + generated/ent/announcement_query.go | 548 + generated/ent/announcement_update.go | 328 + generated/ent/client.go | 2578 ++ generated/ent/ent.go | 634 + generated/ent/enttest/enttest.go | 84 + generated/ent/guide.go | 245 + generated/ent/guide/guide.go | 219 + generated/ent/guide/where.go | 550 + generated/ent/guide_create.go | 406 + generated/ent/guide_delete.go | 88 + generated/ent/guide_query.go | 815 + generated/ent/guide_update.go | 682 + generated/ent/guidetag.go | 155 + generated/ent/guidetag/guidetag.go | 98 + generated/ent/guidetag/where.go | 210 + generated/ent/guidetag_create.go | 237 + generated/ent/guidetag_delete.go | 87 + generated/ent/guidetag_query.go | 624 + generated/ent/guidetag_update.go | 419 + generated/ent/hook/hook.go | 355 + generated/ent/intercept/intercept.go | 539 + generated/ent/internal/schema.go | 9 + generated/ent/migrate/migrate.go | 64 + generated/ent/migrate/schema.go | 540 + generated/ent/mod.go | 434 + generated/ent/mod/mod.go | 434 + generated/ent/mod/where.go | 1147 + generated/ent/mod_create.go | 659 + generated/ent/mod_delete.go | 88 + generated/ent/mod_query.go | 1166 + generated/ent/mod_update.go | 1414 + generated/ent/modtag.go | 155 + generated/ent/modtag/modtag.go | 98 + generated/ent/modtag/where.go | 210 + generated/ent/modtag_create.go | 231 + generated/ent/modtag_delete.go | 87 + generated/ent/modtag_query.go | 624 + generated/ent/modtag_update.go | 407 + generated/ent/mutation.go | 11676 ++++++++ generated/ent/predicate/predicate.go | 49 + generated/ent/runtime.go | 5 + generated/ent/runtime/runtime.go | 412 + generated/ent/smlversion.go | 242 + generated/ent/smlversion/smlversion.go | 212 + generated/ent/smlversion/where.go | 719 + generated/ent/smlversion_create.go | 453 + generated/ent/smlversion_delete.go | 88 + generated/ent/smlversion_query.go | 627 + generated/ent/smlversion_update.go | 725 + generated/ent/smlversiontarget.go | 154 + .../ent/smlversiontarget/smlversiontarget.go | 92 + generated/ent/smlversiontarget/where.go | 312 + generated/ent/smlversiontarget_create.go | 266 + generated/ent/smlversiontarget_delete.go | 88 + generated/ent/smlversiontarget_query.go | 627 + generated/ent/smlversiontarget_update.go | 354 + generated/ent/tag.go | 211 + generated/ent/tag/tag.go | 220 + generated/ent/tag/where.go | 388 + generated/ent/tag_create.go | 362 + generated/ent/tag_delete.go | 88 + generated/ent/tag_query.go | 911 + generated/ent/tag_update.go | 662 + generated/ent/tx.go | 275 + generated/ent/user.go | 319 + generated/ent/user/user.go | 325 + generated/ent/user/where.go | 941 + generated/ent/user_create.go | 599 + generated/ent/user_delete.go | 88 + generated/ent/user_query.go | 956 + generated/ent/user_update.go | 1394 + generated/ent/usergroup.go | 179 + generated/ent/usergroup/usergroup.go | 128 + generated/ent/usergroup/where.go | 389 + generated/ent/usergroup_create.go | 338 + generated/ent/usergroup_delete.go | 88 + generated/ent/usergroup_query.go | 627 + generated/ent/usergroup_update.go | 445 + generated/ent/usermod.go | 166 + generated/ent/usermod/usermod.go | 106 + generated/ent/usermod/where.go | 280 + generated/ent/usermod_create.go | 244 + generated/ent/usermod_delete.go | 87 + generated/ent/usermod_query.go | 624 + generated/ent/usermod_update.go | 425 + generated/ent/usersession.go | 189 + generated/ent/usersession/usersession.go | 137 + generated/ent/usersession/where.go | 399 + generated/ent/usersession_create.go | 348 + generated/ent/usersession_delete.go | 88 + generated/ent/usersession_query.go | 635 + generated/ent/usersession_update.go | 487 + generated/ent/version.go | 379 + generated/ent/version/version.go | 348 + generated/ent/version/where.go | 1105 + generated/ent/version_create.go | 604 + generated/ent/version_delete.go | 88 + generated/ent/version_query.go | 816 + generated/ent/version_update.go | 1083 + generated/ent/versiondependency.go | 215 + .../versiondependency/versiondependency.go | 159 + generated/ent/versiondependency/where.go | 442 + generated/ent/versiondependency_create.go | 346 + generated/ent/versiondependency_delete.go | 87 + generated/ent/versiondependency_query.go | 624 + generated/ent/versiondependency_update.go | 554 + generated/generated.go | 24841 ++++++++++++++++ generated/models_gen.go | 732 + go.mod | 3 + go.sum | 8 + gql/directive.go | 109 +- gql/gql_types.go | 38 - gql/gql_utils.go | 26 + gql/resolver.go | 4 - gql/resolver_announcements.go | 74 +- gql/resolver_bootstrap_versions.go | 151 - gql/resolver_guides.go | 6 +- gql/resolver_mods.go | 8 +- gql/resolver_sml_versions.go | 243 +- gql/resolver_users.go | 55 +- gql/resolver_versions.go | 5 +- gql/versions.go | 3 +- migrations/sql/000025_add_rng.down.sql | 1 + migrations/sql/000025_add_rng.up.sql | 16 + migrations/sql/000026_add_id_columns.down.sql | 8 + migrations/sql/000026_add_id_columns.up.sql | 26 + models/filters.go | 41 - .../consumer_scan_mod_on_virus_total.go | 4 +- schemas/bootstrap_version.graphql | 73 - shell.nix | 1 + storage/storage.go | 2 - tests/announcements_test.go | 207 +- tests/bootstrap_versions_test.go | 137 - tests/guides_test.go | 202 +- tests/paks/.gitignore | 1 + tests/paks/Test_mod_for_Vilsol-1.0.1.smod | Bin 0 -> 90686 bytes tests/sml_versions_test.go | 252 + tests/utils.go | 48 +- tools.go | 13 +- util/logging.go | 12 - util/random.go | 2 +- 185 files changed, 86343 insertions(+), 1192 deletions(-) create mode 100644 conversion/graphql.go create mode 100644 db/ctx.go delete mode 100644 db/postgres/announcement.go delete mode 100644 db/postgres/bootstrap_version.go create mode 100644 db/schema/guide.go create mode 100644 db/schema/guide_tags.go create mode 100644 db/schema/mod.go create mode 100644 db/schema/mod_tags.go create mode 100644 db/schema/sml_version.go create mode 100644 db/schema/sml_version_target.go create mode 100644 db/schema/tag.go create mode 100644 db/schema/user.go create mode 100644 db/schema/user_group.go create mode 100644 db/schema/user_mod.go create mode 100644 db/schema/user_session.go create mode 100644 db/schema/version.go create mode 100644 db/schema/version_dependency.go create mode 100644 db/user.go create mode 100644 db/utils.go delete mode 100755 generated/.gitignore create mode 100644 generated/README.md create mode 100755 generated/conv/announcement.go create mode 100755 generated/conv/sml_version.go create mode 100644 generated/docs/docs.go create mode 100644 generated/docs/swagger.json create mode 100644 generated/docs/swagger.yaml create mode 100644 generated/ent/announcement.go create mode 100644 generated/ent/announcement/announcement.go create mode 100644 generated/ent/announcement/where.go create mode 100644 generated/ent/announcement_create.go create mode 100644 generated/ent/announcement_delete.go create mode 100644 generated/ent/announcement_query.go create mode 100644 generated/ent/announcement_update.go create mode 100644 generated/ent/client.go create mode 100644 generated/ent/ent.go create mode 100644 generated/ent/enttest/enttest.go create mode 100644 generated/ent/guide.go create mode 100644 generated/ent/guide/guide.go create mode 100644 generated/ent/guide/where.go create mode 100644 generated/ent/guide_create.go create mode 100644 generated/ent/guide_delete.go create mode 100644 generated/ent/guide_query.go create mode 100644 generated/ent/guide_update.go create mode 100644 generated/ent/guidetag.go create mode 100644 generated/ent/guidetag/guidetag.go create mode 100644 generated/ent/guidetag/where.go create mode 100644 generated/ent/guidetag_create.go create mode 100644 generated/ent/guidetag_delete.go create mode 100644 generated/ent/guidetag_query.go create mode 100644 generated/ent/guidetag_update.go create mode 100644 generated/ent/hook/hook.go create mode 100644 generated/ent/intercept/intercept.go create mode 100644 generated/ent/internal/schema.go create mode 100644 generated/ent/migrate/migrate.go create mode 100644 generated/ent/migrate/schema.go create mode 100644 generated/ent/mod.go create mode 100644 generated/ent/mod/mod.go create mode 100644 generated/ent/mod/where.go create mode 100644 generated/ent/mod_create.go create mode 100644 generated/ent/mod_delete.go create mode 100644 generated/ent/mod_query.go create mode 100644 generated/ent/mod_update.go create mode 100644 generated/ent/modtag.go create mode 100644 generated/ent/modtag/modtag.go create mode 100644 generated/ent/modtag/where.go create mode 100644 generated/ent/modtag_create.go create mode 100644 generated/ent/modtag_delete.go create mode 100644 generated/ent/modtag_query.go create mode 100644 generated/ent/modtag_update.go create mode 100644 generated/ent/mutation.go create mode 100644 generated/ent/predicate/predicate.go create mode 100644 generated/ent/runtime.go create mode 100644 generated/ent/runtime/runtime.go create mode 100644 generated/ent/smlversion.go create mode 100644 generated/ent/smlversion/smlversion.go create mode 100644 generated/ent/smlversion/where.go create mode 100644 generated/ent/smlversion_create.go create mode 100644 generated/ent/smlversion_delete.go create mode 100644 generated/ent/smlversion_query.go create mode 100644 generated/ent/smlversion_update.go create mode 100644 generated/ent/smlversiontarget.go create mode 100644 generated/ent/smlversiontarget/smlversiontarget.go create mode 100644 generated/ent/smlversiontarget/where.go create mode 100644 generated/ent/smlversiontarget_create.go create mode 100644 generated/ent/smlversiontarget_delete.go create mode 100644 generated/ent/smlversiontarget_query.go create mode 100644 generated/ent/smlversiontarget_update.go create mode 100644 generated/ent/tag.go create mode 100644 generated/ent/tag/tag.go create mode 100644 generated/ent/tag/where.go create mode 100644 generated/ent/tag_create.go create mode 100644 generated/ent/tag_delete.go create mode 100644 generated/ent/tag_query.go create mode 100644 generated/ent/tag_update.go create mode 100644 generated/ent/tx.go create mode 100644 generated/ent/user.go create mode 100644 generated/ent/user/user.go create mode 100644 generated/ent/user/where.go create mode 100644 generated/ent/user_create.go create mode 100644 generated/ent/user_delete.go create mode 100644 generated/ent/user_query.go create mode 100644 generated/ent/user_update.go create mode 100644 generated/ent/usergroup.go create mode 100644 generated/ent/usergroup/usergroup.go create mode 100644 generated/ent/usergroup/where.go create mode 100644 generated/ent/usergroup_create.go create mode 100644 generated/ent/usergroup_delete.go create mode 100644 generated/ent/usergroup_query.go create mode 100644 generated/ent/usergroup_update.go create mode 100644 generated/ent/usermod.go create mode 100644 generated/ent/usermod/usermod.go create mode 100644 generated/ent/usermod/where.go create mode 100644 generated/ent/usermod_create.go create mode 100644 generated/ent/usermod_delete.go create mode 100644 generated/ent/usermod_query.go create mode 100644 generated/ent/usermod_update.go create mode 100644 generated/ent/usersession.go create mode 100644 generated/ent/usersession/usersession.go create mode 100644 generated/ent/usersession/where.go create mode 100644 generated/ent/usersession_create.go create mode 100644 generated/ent/usersession_delete.go create mode 100644 generated/ent/usersession_query.go create mode 100644 generated/ent/usersession_update.go create mode 100644 generated/ent/version.go create mode 100644 generated/ent/version/version.go create mode 100644 generated/ent/version/where.go create mode 100644 generated/ent/version_create.go create mode 100644 generated/ent/version_delete.go create mode 100644 generated/ent/version_query.go create mode 100644 generated/ent/version_update.go create mode 100644 generated/ent/versiondependency.go create mode 100644 generated/ent/versiondependency/versiondependency.go create mode 100644 generated/ent/versiondependency/where.go create mode 100644 generated/ent/versiondependency_create.go create mode 100644 generated/ent/versiondependency_delete.go create mode 100644 generated/ent/versiondependency_query.go create mode 100644 generated/ent/versiondependency_update.go create mode 100644 generated/generated.go create mode 100644 generated/models_gen.go delete mode 100644 gql/resolver_bootstrap_versions.go create mode 100644 migrations/sql/000025_add_rng.down.sql create mode 100644 migrations/sql/000025_add_rng.up.sql create mode 100644 migrations/sql/000026_add_id_columns.down.sql create mode 100644 migrations/sql/000026_add_id_columns.up.sql delete mode 100755 schemas/bootstrap_version.graphql delete mode 100644 tests/bootstrap_versions_test.go create mode 100644 tests/paks/.gitignore create mode 100644 tests/paks/Test_mod_for_Vilsol-1.0.1.smod create mode 100644 tests/sml_versions_test.go delete mode 100644 util/logging.go diff --git a/.gitignore b/.gitignore index da129573..b10762e2 100755 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,5 @@ modules.xml config.json vendor/ -/docs/ /paks/ -*.smod -/ent/ \ No newline at end of file +*.smod \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 08345800..d775fb76 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,7 +36,7 @@ run: - ./generated/generated.go - ./generated/models_gen.go skip-dirs: - - ./docs/ + - ./generated/ issues: exclude: diff --git a/api/api.go b/api/api.go index d47da661..db941b99 100644 --- a/api/api.go +++ b/api/api.go @@ -10,6 +10,8 @@ import ( "syscall" "time" + "ariga.io/entcache" + "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/lru" @@ -22,6 +24,7 @@ import ( "github.com/labstack/echo/v4/middleware" "github.com/spf13/viper" echoSwagger "github.com/swaggo/echo-swagger" + "github.com/vektah/gqlparser/v2/ast" "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" @@ -49,7 +52,9 @@ import ( "github.com/satisfactorymodding/smr-api/validation" // Load REST docs - _ "github.com/satisfactorymodding/smr-api/docs" + _ "github.com/satisfactorymodding/smr-api/generated/docs" + // Load ent + _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" // Load redis consumers _ "github.com/satisfactorymodding/smr-api/redis/jobs/consumers" ) @@ -75,6 +80,7 @@ func Initialize(baseCtx context.Context) context.Context { redis.InitializeRedis(ctx) postgres.InitializePostgres(ctx) + ctx, err := db.WithDB(ctx) if err != nil { panic(err) @@ -195,6 +201,13 @@ func Setup(ctx context.Context) { Cache: lru.New(5000), }) + gqlHandler.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + if op := graphql.GetOperationContext(ctx).Operation; op != nil && op.Operation == ast.Query { + ctx = entcache.NewContext(ctx) + } + return next(ctx) + }) + v2Query.Any("", echo.WrapHandler(gqlHandler)) e.Any("/analytics*", func(ctx echo.Context) error { @@ -204,6 +217,14 @@ func Setup(ctx context.Context) { e.GET("/swagger/*", echoSwagger.WrapHandler) + e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + req := c.Request() + c.SetRequest(req.WithContext(db.TransferContext(ctx, req.Context()))) + return next(c) + } + }) + e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { defer func() { diff --git a/conversion/graphql.go b/conversion/graphql.go new file mode 100644 index 00000000..9d6f1d24 --- /dev/null +++ b/conversion/graphql.go @@ -0,0 +1,40 @@ +package conversion + +import ( + "time" + + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/ent" +) + +// goverter:converter +// goverter:output:file ../generated/conv/announcement.go +// goverter:output:package conv +// goverter:extend TimeToString +type Announcement interface { + Convert(source *ent.Announcement) *generated.Announcement + ConvertSlice(source []*ent.Announcement) []*generated.Announcement +} + +// goverter:converter +// goverter:output:file ../generated/conv/sml_version.go +// goverter:output:package conv +// goverter:extend TimeToString +type SMLVersion interface { + // goverter:map Edges.Targets Targets + Convert(source *ent.SmlVersion) *generated.SMLVersion + ConvertSlice(source []*ent.SmlVersion) []*generated.SMLVersion +} + +// goverter:converter +// goverter:output:file ../generated/conv/user.go +// goverter:output:package conv +// goverter:extend TimeToString +type User interface { + // goverter:ignore Roles Groups Mods Guides + Convert(source *ent.User) *generated.User +} + +func TimeToString(i time.Time) string { + return i.Format(time.RFC3339) +} diff --git a/db/ctx.go b/db/ctx.go new file mode 100644 index 00000000..88ebb101 --- /dev/null +++ b/db/ctx.go @@ -0,0 +1,15 @@ +package db + +import ( + "context" + + "github.com/Vilsol/slox" +) + +// ReWrapCtx re-wraps the old logger and database but with a new context +func ReWrapCtx(ctx context.Context) context.Context { + newCtx := context.Background() + newCtx = slox.Into(newCtx, slox.From(ctx)) + newCtx = TransferContext(ctx, newCtx) + return newCtx +} diff --git a/db/ent.go b/db/ent.go index e917c85a..9fe3dbb5 100644 --- a/db/ent.go +++ b/db/ent.go @@ -4,28 +4,30 @@ import ( "context" "errors" "fmt" + + "ariga.io/entcache" "github.com/Vilsol/slox" "github.com/jackc/pgx/v5/pgxpool" - "github.com/satisfactorymodding/smr-api/ent" "github.com/spf13/viper" + "github.com/satisfactorymodding/smr-api/generated/ent" + + // Required PGX driver _ "github.com/jackc/pgx/v5/stdlib" - _ "github.com/satisfactorymodding/smr-api/ent/runtime" ) -type dbKey struct{} -type txKey struct{} +type ( + dbKey struct{} + txKey struct{} +) type dbClient struct { Client *ent.Client } -type Config struct { - Address string -} - -type ShowDB struct{} +var debugEnabled = false +// WithDB initializes a new database instance and puts it in the context func WithDB(ctx context.Context) (context.Context, error) { slox.Info(ctx, "initializing db") @@ -48,19 +50,28 @@ func WithDB(ctx context.Context) (context.Context, error) { poolDriver := NewPgxPoolDriver(pool) + cacheDriver := entcache.NewDriver( + poolDriver, + entcache.ContextLevel(), + ) + realClient := ent.NewClient( - ent.Driver(poolDriver), + ent.Driver(cacheDriver), ent.Log(func(v ...interface{}) { - fmt.Println(v...) slox.Info(ctx, fmt.Sprint(v...)) }), ) + if debugEnabled { + realClient = realClient.Debug() + } + return context.WithValue(ctx, dbKey{}, &dbClient{ Client: realClient, }), nil } +// From retrieves a database instance from the context func From(ctx context.Context) *ent.Client { tx := ctx.Value(txKey{}) if tx != nil { @@ -74,6 +85,15 @@ func From(ctx context.Context) *ent.Client { return db.(*dbClient).Client } +// TransferContext transfers a database instance from source to target context +func TransferContext(source context.Context, target context.Context) context.Context { + db := source.Value(dbKey{}) + if db == nil { + return target + } + return context.WithValue(target, dbKey{}, db) +} + func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, onError func() error) error { db := ctx.Value(dbKey{}) if db == nil { @@ -95,7 +115,7 @@ func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, o func() { defer func() { if err := recover(); err != nil { - finalError = errors.Join(finalError, fmt.Errorf("panic when rolling back: %w", err)) + finalError = errors.Join(finalError, fmt.Errorf("panic when rolling back: %w", err.(error))) } }() @@ -112,7 +132,7 @@ func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, o } }() - return finalError + return finalError // nolint } err = tx.Commit() @@ -122,3 +142,7 @@ func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, o return nil } + +func EnableDebug() { + debugEnabled = true +} diff --git a/db/pgxpooldriver.go b/db/pgxpooldriver.go index 8f930bf9..8a6641ff 100644 --- a/db/pgxpooldriver.go +++ b/db/pgxpooldriver.go @@ -5,9 +5,10 @@ package db import ( "context" stdsql "database/sql" + "fmt" + "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" - "fmt" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" "go.opentelemetry.io/otel" @@ -35,12 +36,12 @@ func (e *EntPgxpoolDriver) Exec(ctx context.Context, query string, args, result switch result := result.(type) { case nil: if _, err := e.pool.Exec(ctx, query, argv...); err != nil { - return err + return err // nolint } case *sql.Result: commandTag, err := e.pool.Exec(ctx, query, argv...) if err != nil { - return err + return err // nolint } *result = execResult{rowsAffected: commandTag.RowsAffected()} default: @@ -60,11 +61,11 @@ func (e *EntPgxpoolDriver) Query(ctx context.Context, query string, args, v any) } pgxRows, err := e.pool.Query(ctx, query, argv...) if err != nil { - return err + return err // nolint } columnScanner := &entPgxRows{pgxRows: pgxRows} *vr = sql.Rows{ - columnScanner, + ColumnScanner: columnScanner, } return nil } @@ -72,7 +73,7 @@ func (e *EntPgxpoolDriver) Query(ctx context.Context, query string, args, v any) func (e *EntPgxpoolDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { commandTag, err := e.pool.Exec(ctx, query, args...) if err != nil { - return nil, err + return nil, err // nolint } return &execResult{rowsAffected: commandTag.RowsAffected()}, nil } @@ -91,7 +92,7 @@ func (e *EntPgxpoolDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (di } tx, err := e.pool.BeginTx(ctx, *pgxOpts) if err != nil { - return nil, err + return nil, err // nolint } return &EntPgxPoolTx{ tx: tx, @@ -146,12 +147,12 @@ func (e *EntPgxPoolTx) Exec(ctx context.Context, query string, args, result any) switch result := result.(type) { case nil: if _, err := e.tx.Exec(ctx, query, argv...); err != nil { - return err + return err // nolint } case *sql.Result: commandTag, err := e.tx.Exec(ctx, query, argv...) if err != nil { - return err + return err // nolint } *result = execResult{rowsAffected: commandTag.RowsAffected()} default: @@ -163,7 +164,7 @@ func (e *EntPgxPoolTx) Exec(ctx context.Context, query string, args, result any) func (e *EntPgxPoolTx) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { commandTag, err := e.tx.Exec(ctx, query, args...) if err != nil { - return nil, err + return nil, err // nolint } return &execResult{rowsAffected: commandTag.RowsAffected()}, nil } @@ -179,21 +180,21 @@ func (e *EntPgxPoolTx) Query(ctx context.Context, query string, args, v any) err } pgxRows, err := e.tx.Query(ctx, query, argv...) if err != nil { - return err + return err // nolint } columnScanner := &entPgxRows{pgxRows: pgxRows} *vr = sql.Rows{ - columnScanner, + ColumnScanner: columnScanner, } return nil } func (e *EntPgxPoolTx) Commit() error { - return e.tx.Commit(context.TODO()) + return e.tx.Commit(context.TODO()) // nolint } func (e *EntPgxPoolTx) Rollback() error { - return e.tx.Rollback(context.TODO()) + return e.tx.Rollback(context.TODO()) // nolint } func (e *EntPgxPoolTx) PGXTransaction() pgx.Tx { @@ -222,13 +223,12 @@ func (e entPgxRows) Columns() ([]string, error) { columnNames := make([]string, len(fieldDescs)) for i, fd := range fieldDescs { columnNames[i] = fd.Name - } return columnNames, nil } func (e entPgxRows) Err() error { - return e.pgxRows.Err() + return e.pgxRows.Err() // nolint } func (e entPgxRows) Next() bool { @@ -252,16 +252,16 @@ func (e entPgxRows) NextResultSet() bool { } func (e entPgxRows) Scan(dest ...any) error { - return e.pgxRows.Scan(dest...) + return e.pgxRows.Scan(dest...) // nolint } type execResult struct { - lastInsertId int64 + lastInsertID int64 rowsAffected int64 } func (e execResult) LastInsertId() (int64, error) { - return e.lastInsertId, nil + return e.lastInsertID, nil } func (e execResult) RowsAffected() (int64, error) { diff --git a/db/postgres/announcement.go b/db/postgres/announcement.go deleted file mode 100644 index 46481bed..00000000 --- a/db/postgres/announcement.go +++ /dev/null @@ -1,64 +0,0 @@ -package postgres - -import ( - "context" - - "github.com/patrickmn/go-cache" - - "github.com/satisfactorymodding/smr-api/util" -) - -func CreateAnnouncement(ctx context.Context, announcement *Announcement) (*Announcement, error) { - announcement.ID = util.GenerateUniqueID() - DBCtx(ctx).Create(&announcement) - return announcement, nil -} - -func GetAnnouncementByID(ctx context.Context, announcementID string) *Announcement { - cacheKey := "GetAnnouncementByID_" + announcementID - - if announcement, ok := dbCache.Get(cacheKey); ok { - return announcement.(*Announcement) - } - - var announcement Announcement - DBCtx(ctx).Find(&announcement, "id = ?", announcementID) - - if announcement.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &announcement, cache.DefaultExpiration) - - return &announcement -} - -func GetAnnouncements(ctx context.Context) []Announcement { - cacheKey := "GetAnnouncements" - - if announcements, ok := dbCache.Get(cacheKey); ok { - return announcements.([]Announcement) - } - - var announcements []Announcement - DBCtx(ctx).Find(&announcements) - - dbCache.Set(cacheKey, announcements, cache.DefaultExpiration) - - return announcements -} - -func GetAnnouncementsByImportance(ctx context.Context, importance string) []Announcement { - cacheKey := "GetAnnouncementsByImportance_" + importance - - if announcements, ok := dbCache.Get(cacheKey); ok { - return announcements.([]Announcement) - } - - var announcements []Announcement - DBCtx(ctx).Find(&announcements, "importance = ?", importance) - - dbCache.Set(cacheKey, announcements, cache.DefaultExpiration) - - return announcements -} diff --git a/db/postgres/bootstrap_version.go b/db/postgres/bootstrap_version.go deleted file mode 100644 index 3e08ea7e..00000000 --- a/db/postgres/bootstrap_version.go +++ /dev/null @@ -1,71 +0,0 @@ -package postgres - -import ( - "context" - "strings" - - "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" -) - -func CreateBootstrapVersion(ctx context.Context, bootstrapVersion *BootstrapVersion) (*BootstrapVersion, error) { - bootstrapVersion.ID = util.GenerateUniqueID() - - DBCtx(ctx).Create(&bootstrapVersion) - - return bootstrapVersion, nil -} - -func GetBootstrapVersionByID(ctx context.Context, bootstrapVersionID string) *BootstrapVersion { - var bootstrapVersion BootstrapVersion - DBCtx(ctx).Find(&bootstrapVersion, "id = ?", bootstrapVersionID) - - if bootstrapVersion.ID == "" { - return nil - } - - return &bootstrapVersion -} - -func GetBootstrapVersions(ctx context.Context, filter *models.BootstrapVersionFilter) []BootstrapVersion { - var bootstrapVersions []BootstrapVersion - query := DBCtx(ctx) - - if filter != nil { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset). - Order(string(*filter.OrderBy) + " " + string(*filter.Order)) - - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Find(&bootstrapVersions) - return bootstrapVersions -} - -func GetBootstrapVersionsByID(ctx context.Context, bootstrapVersionIds []string) []BootstrapVersion { - var bootstrapVersions []BootstrapVersion - DBCtx(ctx).Find(&bootstrapVersions, "id in (?)", bootstrapVersionIds) - - if len(bootstrapVersionIds) != len(bootstrapVersions) { - return nil - } - - return bootstrapVersions -} - -func GetBootstrapVersionCount(ctx context.Context, filter *models.BootstrapVersionFilter) int64 { - var bootstrapVersionCount int64 - query := DBCtx(ctx).Model(BootstrapVersion{}) - - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Count(&bootstrapVersionCount) - return bootstrapVersionCount -} diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go index 76b94b1e..275ecad7 100644 --- a/db/postgres/postgres.go +++ b/db/postgres/postgres.go @@ -22,8 +22,6 @@ var ( dbCache *cache.Cache ) -type UserKey struct{} - type GormLogger struct { SlowThreshold time.Duration Debug bool diff --git a/db/postgres/postgres_types.go b/db/postgres/postgres_types.go index 4d12da1d..9adf4683 100644 --- a/db/postgres/postgres_types.go +++ b/db/postgres/postgres_types.go @@ -149,23 +149,6 @@ type VersionDependency struct { Optional bool } -type BootstrapVersion struct { - Date time.Time - SMRModel - Version string `gorm:"type:varchar(32);unique_index"` - Stability string `sql:"type:version_stability"` - Link string - Changelog string - SatisfactoryVersion int -} - -type Announcement struct { - SMRModel - - Message string - Importance string -} - type Tag struct { SMRModel diff --git a/db/postgres/sml_version.go b/db/postgres/sml_version.go index 46f6e213..398f56c6 100644 --- a/db/postgres/sml_version.go +++ b/db/postgres/sml_version.go @@ -5,28 +5,8 @@ import ( "strings" "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" ) -func CreateSMLVersion(ctx context.Context, smlVersion *SMLVersion) (*SMLVersion, error) { - smlVersion.ID = util.GenerateUniqueID() - - DBCtx(ctx).Create(&smlVersion) - - return smlVersion, nil -} - -func GetSMLVersionByID(ctx context.Context, smlVersionID string) *SMLVersion { - var smlVersion SMLVersion - DBCtx(ctx).Preload("Targets").Find(&smlVersion, "id in (?)", smlVersionID) - - if smlVersion.ID == "" { - return nil - } - - return &smlVersion -} - func GetSMLVersions(ctx context.Context, filter *models.SMLVersionFilter) []SMLVersion { var smlVersions []SMLVersion query := DBCtx(ctx) @@ -46,31 +26,6 @@ func GetSMLVersions(ctx context.Context, filter *models.SMLVersionFilter) []SMLV return smlVersions } -func GetSMLVersionsByID(ctx context.Context, smlVersionIds []string) []SMLVersion { - var smlVersions []SMLVersion - DBCtx(ctx).Preload("Targets").Find(&smlVersions, "id in (?)", smlVersionIds) - - if len(smlVersionIds) != len(smlVersions) { - return nil - } - - return smlVersions -} - -func GetSMLVersionCount(ctx context.Context, filter *models.SMLVersionFilter) int64 { - var smlVersionCount int64 - query := DBCtx(ctx).Model(SMLVersion{}) - - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Count(&smlVersionCount) - return smlVersionCount -} - func GetSMLLatestVersions(ctx context.Context) *[]SMLVersion { var smlVersions []SMLVersion @@ -80,11 +35,3 @@ func GetSMLLatestVersions(ctx context.Context) *[]SMLVersion { return &smlVersions } - -func GetSMLVersionTargets(ctx context.Context, smlVersionID string) []SMLVersionTarget { - var smlVersionTargets []SMLVersionTarget - - DBCtx(ctx).Find(&smlVersionTargets, "version_id = ?", smlVersionID) - - return smlVersionTargets -} diff --git a/db/postgres/user.go b/db/postgres/user.go index c2bba548..ce12df66 100644 --- a/db/postgres/user.go +++ b/db/postgres/user.go @@ -137,22 +137,3 @@ func GetModAuthors(ctx context.Context, modID string) []UserMod { DBCtx(ctx).Find(&authors, "mod_id = ?", modID) return authors } - -func UserCanUploadModVersions(ctx context.Context, user *User, modID string) bool { - if user.Banned { - return false - } - - var userMod UserMod - DBCtx(ctx).First(&userMod, "user_id = ? AND mod_id = ?", user.ID, modID) - - if userMod.UserID == "" { - return false - } - - if userMod.Role != "creator" && userMod.Role != "editor" { - return false - } - - return true -} diff --git a/db/schema/guide.go b/db/schema/guide.go new file mode 100644 index 00000000..cd2a42e0 --- /dev/null +++ b/db/schema/guide.go @@ -0,0 +1,39 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type Guide struct { + ent.Schema +} + +func (Guide) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (Guide) Fields() []ent.Field { + return []ent.Field{ + field.String("name").MaxLen(32), + field.String("short_description").MaxLen(128), + field.String("guide"), + field.Int("views"), + } +} + +func (Guide) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("user", User.Type). + Ref("guides"). + Unique(). + Required(), + edge.To("tags", Tag.Type). + Through("guide_tags", GuideTag.Type), + } +} diff --git a/db/schema/guide_tags.go b/db/schema/guide_tags.go new file mode 100644 index 00000000..a0779518 --- /dev/null +++ b/db/schema/guide_tags.go @@ -0,0 +1,38 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type GuideTag struct { + ent.Schema +} + +func (GuideTag) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("guide_tag", "tag_id"), + } +} + +func (GuideTag) Fields() []ent.Field { + return []ent.Field{ + field.String("guide_tag"), + field.String("tag_id"), + } +} + +func (GuideTag) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("guide", Guide.Type). + Unique(). + Required(). + Field("guide_tag"), + edge.To("tag", Tag.Type). + Unique(). + Required(). + Field("tag_id"), + } +} diff --git a/db/schema/mixin_id.go b/db/schema/mixin_id.go index 975ef2b4..7fe88f77 100644 --- a/db/schema/mixin_id.go +++ b/db/schema/mixin_id.go @@ -5,6 +5,7 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" + "github.com/satisfactorymodding/smr-api/util" ) diff --git a/db/schema/mixin_softdelete.go b/db/schema/mixin_softdelete.go index a8a7358d..81f5f3d8 100644 --- a/db/schema/mixin_softdelete.go +++ b/db/schema/mixin_softdelete.go @@ -8,11 +8,12 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" - gen "github.com/satisfactorymodding/smr-api/ent" - "github.com/satisfactorymodding/smr-api/ent/hook" - "github.com/satisfactorymodding/smr-api/ent/intercept" + gen "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/hook" + "github.com/satisfactorymodding/smr-api/generated/ent/intercept" ) // SoftDeleteMixin implements the soft delete pattern for schemas. @@ -28,6 +29,12 @@ func (SoftDeleteMixin) Fields() []ent.Field { } } +func (SoftDeleteMixin) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("deleted_at"), + } +} + type softDeleteKey struct{} // SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators. @@ -57,12 +64,12 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { // Skip soft-delete, means delete the entity permanently. if skip, _ := ctx.Value(softDeleteKey{}).(bool); skip { - return next.Mutate(ctx, m) + return next.Mutate(ctx, m) // nolint } mx, ok := m.(interface { SetOp(ent.Op) Client() *gen.Client - SetDeleteTime(time.Time) + SetDeletedAt(time.Time) WhereP(...func(*sql.Selector)) }) if !ok { @@ -70,7 +77,7 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook { } d.P(mx) mx.SetOp(ent.OpUpdate) - mx.SetDeleteTime(time.Now()) + mx.SetDeletedAt(time.Now()) return mx.Client().Mutate(ctx, m) }) }, diff --git a/db/schema/mixin_time.go b/db/schema/mixin_time.go index 92708032..cd34f641 100644 --- a/db/schema/mixin_time.go +++ b/db/schema/mixin_time.go @@ -5,7 +5,6 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" ) @@ -17,17 +16,9 @@ func (TimeMixin) Fields() []ent.Field { return []ent.Field{ field.Time("created_at"). Immutable(). - Default(time.Now). - Optional(), + Default(time.Now), field.Time("updated_at"). Default(time.Now). - UpdateDefault(time.Now). - Optional(), - } -} - -func (TimeMixin) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("deleted_at"), + UpdateDefault(time.Now), } } diff --git a/db/schema/mod.go b/db/schema/mod.go new file mode 100644 index 00000000..48dabda8 --- /dev/null +++ b/db/schema/mod.go @@ -0,0 +1,64 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + + "github.com/satisfactorymodding/smr-api/db/postgres" +) + +type Mod struct { + ent.Schema +} + +func (Mod) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (Mod) Fields() []ent.Field { + return []ent.Field{ + field.String("name").MaxLen(32), + field.String("short_description").MaxLen(128), + field.String("full_description"), + field.String("logo"), + field.String("source_url"), + field.String("creator_id"), + field.Bool("approved").Default(false), + field.Uint("views"), + field.Uint("hotness"), + field.Uint("popularity"), + field.Uint("downloads"), + field.Bool("denied").Default(false), + field.Time("last_version_date"), + field.String("mod_reference").MaxLen(32).Unique(), + field.Bool("hidden"), + field.JSON("compatibility", &postgres.CompatibilityInfo{}), + } +} + +func (Mod) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("last_version_date"), + } +} + +func (Mod) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("versions", Version.Type). + StorageKey(edge.Column("mod_id")), + edge.From("authors", User.Type). + Ref("mods"). + Through("user_mods", UserMod.Type), + edge.To("tags", Tag.Type). + Through("mod_tags", ModTag.Type), + edge.From("dependents", Version.Type). + Ref("dependencies"). + Through("version_dependencies", VersionDependency.Type), + } +} diff --git a/db/schema/mod_tags.go b/db/schema/mod_tags.go new file mode 100644 index 00000000..de69deb6 --- /dev/null +++ b/db/schema/mod_tags.go @@ -0,0 +1,38 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type ModTag struct { + ent.Schema +} + +func (ModTag) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("mod_id", "tag_id"), + } +} + +func (ModTag) Fields() []ent.Field { + return []ent.Field{ + field.String("mod_id"), + field.String("tag_id"), + } +} + +func (ModTag) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("mod", Mod.Type). + Unique(). + Required(). + Field("mod_id"), + edge.To("tag", Tag.Type). + Unique(). + Required(). + Field("tag_id"), + } +} diff --git a/db/schema/sml_version.go b/db/schema/sml_version.go new file mode 100644 index 00000000..5c37fd08 --- /dev/null +++ b/db/schema/sml_version.go @@ -0,0 +1,38 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type SmlVersion struct { + ent.Schema +} + +func (SmlVersion) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (SmlVersion) Fields() []ent.Field { + return []ent.Field{ + field.String("version").MaxLen(32).Unique(), + field.Int("satisfactory_version"), + field.Enum("stability").Values("alpha", "beta", "release"), + field.Time("date"), + field.String("link"), + field.String("changelog"), + field.String("bootstrap_version").MaxLen(14).Optional(), + field.String("engine_version").MaxLen(16).Default("4.26"), + } +} + +func (SmlVersion) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("targets", SmlVersionTarget.Type), + } +} diff --git a/db/schema/sml_version_target.go b/db/schema/sml_version_target.go new file mode 100644 index 00000000..20196c07 --- /dev/null +++ b/db/schema/sml_version_target.go @@ -0,0 +1,42 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type SmlVersionTarget struct { + ent.Schema +} + +func (SmlVersionTarget) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + } +} + +func (SmlVersionTarget) Fields() []ent.Field { + return []ent.Field{ + field.String("version_id"), + field.String("target_name"), + field.String("link"), + } +} + +func (SmlVersionTarget) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("sml_version", SmlVersion.Type). + Ref("targets"). + Field("version_id"). + Unique(). + Required(), + } +} + +func (SmlVersionTarget) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("version_id", "target_name").Unique(), + } +} diff --git a/db/schema/tag.go b/db/schema/tag.go new file mode 100644 index 00000000..89ab737c --- /dev/null +++ b/db/schema/tag.go @@ -0,0 +1,36 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type Tag struct { + ent.Schema +} + +func (Tag) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (Tag) Fields() []ent.Field { + return []ent.Field{ + field.String("name").MaxLen(24).Unique(), + } +} + +func (Tag) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("mods", Mod.Type). + Ref("tags"). + Through("mod_tags", ModTag.Type), + edge.From("guides", Guide.Type). + Ref("tags"). + Through("guide_tags", GuideTag.Type), + } +} diff --git a/db/schema/user.go b/db/schema/user.go new file mode 100644 index 00000000..5e59f492 --- /dev/null +++ b/db/schema/user.go @@ -0,0 +1,55 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type User struct { + ent.Schema +} + +func (User) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (User) Fields() []ent.Field { + return []ent.Field{ + field.String("email").MaxLen(256).Unique(), + field.String("username").MaxLen(32), + field.String("avatar").Optional(), + field.String("joined_from").Optional(), + field.Bool("banned").Default(false), + field.Int("rank").Default(1), + field.String("github_id").MaxLen(16).Unique().Optional(), + field.String("google_id").MaxLen(16).Unique().Optional(), + field.String("facebook_id").MaxLen(16).Unique().Optional(), + } +} + +func (User) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("email"), + index.Fields("github_id"), + index.Fields("google_id"), + index.Fields("facebook_id"), + } +} + +func (User) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("guides", Guide.Type). + StorageKey(edge.Column("user_id")), + edge.To("sessions", UserSession.Type). + StorageKey(edge.Column("user_id")), + edge.To("mods", Mod.Type). + Through("user_mods", UserMod.Type), + edge.To("groups", UserGroup.Type), + } +} diff --git a/db/schema/user_group.go b/db/schema/user_group.go new file mode 100644 index 00000000..30034c5b --- /dev/null +++ b/db/schema/user_group.go @@ -0,0 +1,43 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type UserGroup struct { + ent.Schema +} + +func (UserGroup) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (UserGroup) Fields() []ent.Field { + return []ent.Field{ + field.String("user_id").MaxLen(14), + field.String("group_id").MaxLen(14), + } +} + +func (UserGroup) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("user_id", "group_id").Unique(), + } +} + +func (UserGroup) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("user", User.Type). + Ref("groups"). + Field("user_id"). + Unique(). + Required(), + } +} diff --git a/db/schema/user_mod.go b/db/schema/user_mod.go new file mode 100644 index 00000000..65bad1d8 --- /dev/null +++ b/db/schema/user_mod.go @@ -0,0 +1,39 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type UserMod struct { + ent.Schema +} + +func (UserMod) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("user_id", "mod_id"), + } +} + +func (UserMod) Fields() []ent.Field { + return []ent.Field{ + field.String("user_id"), + field.String("mod_id"), + field.String("role"), + } +} + +func (UserMod) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("user", User.Type). + Unique(). + Required(). + Field("user_id"), + edge.To("mod", Mod.Type). + Unique(). + Required(). + Field("mod_id"), + } +} diff --git a/db/schema/user_session.go b/db/schema/user_session.go new file mode 100644 index 00000000..8f23ef66 --- /dev/null +++ b/db/schema/user_session.go @@ -0,0 +1,35 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type UserSession struct { + ent.Schema +} + +func (UserSession) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (UserSession) Fields() []ent.Field { + return []ent.Field{ + field.String("token").MaxLen(256).Unique(), + field.String("user_agent").Optional(), + } +} + +func (UserSession) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("user", User.Type). + Ref("sessions"). + Unique(). + Required(), + } +} diff --git a/db/schema/version.go b/db/schema/version.go new file mode 100644 index 00000000..4a588393 --- /dev/null +++ b/db/schema/version.go @@ -0,0 +1,51 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type Version struct { + ent.Schema +} + +func (Version) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (Version) Fields() []ent.Field { + return []ent.Field{ + field.String("version").MaxLen(16), + field.String("sml_version").MaxLen(16), + field.String("changelog"), + field.Uint("downloads"), + field.String("key"), + field.Enum("stability").Values("alpha", "beta", "release"), + field.Bool("approved").Default(false), + field.Uint("hotness"), + field.Bool("denied").Default(false), + field.String("metadata"), + field.String("mod_reference").MaxLen(32), + field.Int("version_major"), + field.Int("version_minor"), + field.Int("version_patch"), + field.Int64("size"), + field.String("hash").MinLen(64).MaxLen(64), + } +} + +func (Version) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("mod", Mod.Type). + Ref("versions"). + Unique(). + Required(), + edge.To("dependencies", Mod.Type). + Through("version_dependencies", VersionDependency.Type), + } +} diff --git a/db/schema/version_dependency.go b/db/schema/version_dependency.go new file mode 100644 index 00000000..efffdc53 --- /dev/null +++ b/db/schema/version_dependency.go @@ -0,0 +1,47 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +type VersionDependency struct { + ent.Schema +} + +func (VersionDependency) Mixin() []ent.Mixin { + return []ent.Mixin{ + TimeMixin{}, + SoftDeleteMixin{}, + } +} + +func (VersionDependency) Annotations() []schema.Annotation { + return []schema.Annotation{ + field.ID("version_id", "mod_id"), + } +} + +func (VersionDependency) Fields() []ent.Field { + return []ent.Field{ + field.String("version_id"), + field.String("mod_id"), + field.String("condition").MaxLen(64), + field.Bool("optional"), + } +} + +func (VersionDependency) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("version", Version.Type). + Unique(). + Required(). + Field("version_id"), + edge.To("mod", Mod.Type). + Unique(). + Required(). + Field("mod_id"), + } +} diff --git a/db/statistics.go b/db/statistics.go index 105d79d0..fa32a66f 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -8,7 +8,8 @@ import ( "github.com/Vilsol/slox" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/redis" ) @@ -42,65 +43,95 @@ func RunAsyncStatisticLoop(ctx context.Context) { for entityType, entityValue := range resultMap { for action, actionValue := range entityValue { for entityID, count := range actionValue { - updateTx := postgres.DBCtx(ctx).Begin() - ctxWithTx := postgres.ContextWithDB(ctx, updateTx) - switch entityType { - case "mod": - if action == "view" { - mod := postgres.GetModByID(ctxWithTx, entityID) - if mod != nil { - currentHotness := mod.Hotness - if currentHotness > 4 { - // Preserve some of the hotness - currentHotness /= 4 + err := Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + switch entityType { + case "mod": + if action == "view" { + mod, err := tx.Mod.Get(ctx, entityID) + if err != nil { + return err + } + + if mod != nil { + currentHotness := mod.Hotness + if currentHotness > 4 { + // Preserve some of the hotness + currentHotness /= 4 + } + + return mod.Update().SetHotness(currentHotness + count).Exec(ctx) } - updateTx.Model(&mod).UpdateColumns(postgres.Mod{Hotness: currentHotness + count}) } - } - case "version": - if action == "download" { - version := postgres.GetVersion(ctxWithTx, entityID) - if version != nil { - currentHotness := version.Hotness - if currentHotness > 4 { - // Preserve some of the popularity - currentHotness /= 4 + case "version": + if action == "download" { + version, err := tx.Version.Get(ctx, entityID) + if err != nil { + return err + } + + if version != nil { + currentHotness := version.Hotness + if currentHotness > 4 { + // Preserve some of the popularity + currentHotness /= 4 + } + return version.Update().SetHotness(currentHotness + count).Exec(ctx) } - updateTx.Model(&version).UpdateColumns(postgres.Version{Hotness: currentHotness + count}) } } + + return nil + }, nil) + if err != nil { + slox.From(ctx).Error("failed updating statistics", slog.Any("err", err)) } - updateTx.Commit() } } } type Result struct { - ModID string - Hotness uint - Downloads uint + ModID string `json:"mod_id"` + Hotness uint `json:"hotness"` + Downloads uint `json:"downloads"` } var resultRows []Result - postgres.DBCtx(ctx).Raw("SELECT mod_id, SUM(hotness) AS hotness, SUM(downloads) AS downloads FROM versions GROUP BY mod_id").Scan(&resultRows) + err := From(ctx).Version. + Query(). + GroupBy("mod_id"). + Aggregate( + ent.As(ent.Sum(version.FieldHotness), "hotness"), + ent.As(ent.Sum(version.FieldDownloads), "downloads"), + ). + Scan(ctx, &resultRows) + if err != nil { + slox.From(ctx).Error("failed summing version data", slog.Any("err", err)) + continue + } for _, row := range resultRows { - updateTx := postgres.DBCtx(ctx).Begin() - ctxWithTx := postgres.ContextWithDB(ctx, updateTx) - mod := postgres.GetModByID(ctxWithTx, row.ModID) - if mod != nil { - currentPopularity := mod.Popularity - if currentPopularity > 4 { - // Preserve some of the popularity - currentPopularity /= 4 + err := Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + mod, err := tx.Mod.Get(ctx, row.ModID) + if err != nil { + return err + } + + if mod != nil { + currentPopularity := mod.Popularity + if currentPopularity > 4 { + // Preserve some of the popularity + currentPopularity /= 4 + } + return mod.Update().SetPopularity(currentPopularity + row.Hotness).SetDownloads(row.Downloads).Exec(ctx) } - updateTx.Model(&mod).UpdateColumns(postgres.Mod{ - Popularity: currentPopularity + row.Hotness, - Downloads: row.Downloads, - }) + + return nil + }, nil) + if err != nil { + slox.From(ctx).Error("failed updating mod data", slog.Any("err", err)) + continue } - updateTx.Commit() } slox.Info(ctx, "statistics updated", slog.Duration("took", time.Since(start))) diff --git a/db/user.go b/db/user.go new file mode 100644 index 00000000..be84a9a8 --- /dev/null +++ b/db/user.go @@ -0,0 +1,70 @@ +package db + +import ( + "context" + "errors" + "log/slog" + "net/http" + + "github.com/Vilsol/slox" + + "github.com/satisfactorymodding/smr-api/auth" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/util" +) + +func UserHas(ctx context.Context, role *auth.Role, usr *ent.User) bool { + groups := auth.GetRoleGroups(role) + groupIds := make([]string, len(groups)) + for i, group := range groups { + groupIds[i] = group.ID + } + + exist, err := usr.QueryGroups().Where(usergroup.GroupIDIn(groupIds...)).Exist(ctx) + if err != nil { + slox.Error(ctx, "failed retrieving user groups", slog.Any("err", err)) + return false + } + + return exist +} + +func UserFromGQLContext(ctx context.Context) (*ent.User, error) { + header := ctx.Value(util.ContextHeader{}).(http.Header) + authorization := header.Get("Authorization") + + if authorization == "" { + return nil, errors.New("user not logged in") + } + + user, err := From(ctx).UserSession.Query().Where(usersession.Token(authorization)).QueryUser().First(ctx) + if err != nil { + if ent.IsNotFound(err) { + return nil, errors.New("user not logged in") + } + + return nil, err + } + + return user, nil +} + +func UserCanUploadModVersions(ctx context.Context, user *ent.User, modID string) bool { + if user.Banned { + return false + } + + exists, err := user.QueryUserMods().Where( + usermod.ModID(modID), + usermod.RoleIn("creator", "editor"), + ).Exist(ctx) + if err != nil { + slox.Error(ctx, "failed retrieving user mods", slog.Any("err", err)) + return false + } + + return exists +} diff --git a/db/utils.go b/db/utils.go new file mode 100644 index 00000000..e2218f7d --- /dev/null +++ b/db/utils.go @@ -0,0 +1,11 @@ +package db + +import "entgo.io/ent/dialect/sql" + +func OrderToOrder(order string) sql.OrderTermOption { + if order == "asc" || order == "ascending" { + return sql.OrderAsc() + } + + return sql.OrderDesc() +} diff --git a/generated/.gitignore b/generated/.gitignore deleted file mode 100755 index 215660d9..00000000 --- a/generated/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -generated.go -models_gen.go \ No newline at end of file diff --git a/generated/README.md b/generated/README.md new file mode 100644 index 00000000..6d67e059 --- /dev/null +++ b/generated/README.md @@ -0,0 +1,7 @@ +Do not touch any files in this directory. (except for [custom_models.go](custom_models.go)) + +It is generated by running the following command in the root directory: + +```shell +go generate -tags tools -x ./... +``` \ No newline at end of file diff --git a/generated/conv/announcement.go b/generated/conv/announcement.go new file mode 100755 index 00000000..cd35261f --- /dev/null +++ b/generated/conv/announcement.go @@ -0,0 +1,32 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +package conv + +import ( + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type AnnouncementImpl struct{} + +func (c *AnnouncementImpl) Convert(source *ent.Announcement) *generated.Announcement { + var pGeneratedAnnouncement *generated.Announcement + if source != nil { + var generatedAnnouncement generated.Announcement + generatedAnnouncement.ID = (*source).ID + generatedAnnouncement.Message = (*source).Message + generatedAnnouncement.Importance = generated.AnnouncementImportance((*source).Importance) + pGeneratedAnnouncement = &generatedAnnouncement + } + return pGeneratedAnnouncement +} +func (c *AnnouncementImpl) ConvertSlice(source []*ent.Announcement) []*generated.Announcement { + var pGeneratedAnnouncementList []*generated.Announcement + if source != nil { + pGeneratedAnnouncementList = make([]*generated.Announcement, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedAnnouncementList[i] = c.Convert(source[i]) + } + } + return pGeneratedAnnouncementList +} diff --git a/generated/conv/sml_version.go b/generated/conv/sml_version.go new file mode 100755 index 00000000..97064aae --- /dev/null +++ b/generated/conv/sml_version.go @@ -0,0 +1,85 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +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 SMLVersionImpl struct{} + +func (c *SMLVersionImpl) Convert(source *ent.SmlVersion) *generated.SMLVersion { + var pGeneratedSMLVersion *generated.SMLVersion + if source != nil { + var generatedSMLVersion generated.SMLVersion + generatedSMLVersion.ID = (*source).ID + generatedSMLVersion.Version = (*source).Version + generatedSMLVersion.SatisfactoryVersion = (*source).SatisfactoryVersion + generatedSMLVersion.Stability = generated.VersionStabilities((*source).Stability) + generatedSMLVersion.Link = (*source).Link + var pGeneratedSMLVersionTargetList []*generated.SMLVersionTarget + if (*source).Edges.Targets != nil { + pGeneratedSMLVersionTargetList = make([]*generated.SMLVersionTarget, len((*source).Edges.Targets)) + for i := 0; i < len((*source).Edges.Targets); i++ { + pGeneratedSMLVersionTargetList[i] = c.pEntSmlVersionTargetToPGeneratedSMLVersionTarget((*source).Edges.Targets[i]) + } + } + generatedSMLVersion.Targets = pGeneratedSMLVersionTargetList + generatedSMLVersion.Changelog = (*source).Changelog + generatedSMLVersion.Date = conversion.TimeToString((*source).Date) + pString := (*source).BootstrapVersion + generatedSMLVersion.BootstrapVersion = &pString + generatedSMLVersion.EngineVersion = (*source).EngineVersion + generatedSMLVersion.UpdatedAt = conversion.TimeToString((*source).UpdatedAt) + generatedSMLVersion.CreatedAt = conversion.TimeToString((*source).CreatedAt) + pGeneratedSMLVersion = &generatedSMLVersion + } + return pGeneratedSMLVersion +} +func (c *SMLVersionImpl) ConvertSlice(source []*ent.SmlVersion) []*generated.SMLVersion { + var pGeneratedSMLVersionList []*generated.SMLVersion + if source != nil { + pGeneratedSMLVersionList = make([]*generated.SMLVersion, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedSMLVersionList[i] = c.Convert(source[i]) + } + } + return pGeneratedSMLVersionList +} +func (c *SMLVersionImpl) pEntSmlVersionTargetToPGeneratedSMLVersionTarget(source *ent.SmlVersionTarget) *generated.SMLVersionTarget { + var pGeneratedSMLVersionTarget *generated.SMLVersionTarget + if source != nil { + var generatedSMLVersionTarget generated.SMLVersionTarget + generatedSMLVersionTarget.VersionID = (*source).VersionID + generatedSMLVersionTarget.TargetName = generated.TargetName((*source).TargetName) + generatedSMLVersionTarget.Link = (*source).Link + pGeneratedSMLVersionTarget = &generatedSMLVersionTarget + } + return pGeneratedSMLVersionTarget +} + +type UserImpl struct{} + +func (c *UserImpl) Convert(source *ent.User) *generated.User { + var pGeneratedUser *generated.User + if source != nil { + var generatedUser generated.User + generatedUser.ID = (*source).ID + pString := (*source).Email + generatedUser.Email = &pString + generatedUser.Username = (*source).Username + pString2 := (*source).Avatar + generatedUser.Avatar = &pString2 + generatedUser.CreatedAt = conversion.TimeToString((*source).CreatedAt) + pString3 := (*source).GithubID + generatedUser.GithubID = &pString3 + pString4 := (*source).GoogleID + generatedUser.GoogleID = &pString4 + pString5 := (*source).FacebookID + generatedUser.FacebookID = &pString5 + pGeneratedUser = &generatedUser + } + return pGeneratedUser +} diff --git a/generated/docs/docs.go b/generated/docs/docs.go new file mode 100644 index 00000000..dbec75a7 --- /dev/null +++ b/generated/docs/docs.go @@ -0,0 +1,801 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/mod/{modId}": { + "get": { + "description": "Retrieve a mod by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/authors": { + "get": { + "description": "Retrieve a mod authors by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Authors", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for a mod based on mod id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a list of latest versions for a mod", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions": { + "get": { + "description": "Retrieve a mod versions by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Versions", + "parameters": [ + { + "type": "integer", + "description": "How many versions to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of versions to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at" + ], + "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": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/all": { + "get": { + "description": "Retrieve all mod versions by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve all Mod Versions", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}": { + "get": { + "description": "Retrieve a mod version by mod ID and version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Version", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}/download": { + "get": { + "description": "Download a mod version by mod ID and version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Download a Mod Version", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}/{target}/download": { + "get": { + "description": "Download a mod version by mod ID and version ID and TargetName", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Download a Mod Version by TargetName", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "TargetName", + "name": "target", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods": { + "get": { + "description": "Retrieve a list of mods", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of Mods", + "parameters": [ + { + "type": "integer", + "description": "How many mods to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of mods to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at", + "name", + "views", + "downloads", + "hotness", + "popularity", + "last_version_date" + ], + "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" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/count": { + "get": { + "description": "Retrieve a count of Mods", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a count of Mods", + "parameters": [ + { + "type": "string", + "description": "Search string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/{modIds}": { + "get": { + "description": "Retrieve a list of mods by mod IDs", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of Mods by ID", + "parameters": [ + { + "type": "string", + "description": "Mod IDs", + "name": "modIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/{modIds}/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for mods based on mod id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of latest versions for mods", + "parameters": [ + { + "type": "string", + "description": "Mod IDs", + "name": "modIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/oauth": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "OAuth" + ], + "summary": "Retrieve a list of OAuth methods", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/oauth/github": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "OAuth" + ], + "summary": "Callback URL for github OAuth", + "parameters": [ + { + "type": "string", + "description": "OAuth Code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "OAuth Code", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/sml/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for sml", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SML" + ], + "summary": "Retrieve a list of latest versions for sml", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me": { + "get": { + "description": "Retrieve the user associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve Current User", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me/logout": { + "get": { + "description": "Log out the user associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Log Out Current User", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me/mods": { + "get": { + "description": "Retrieve the users mods associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve Current Users Mods", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/{userId}": { + "get": { + "description": "Retrieve a user by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve a User", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/{userId}/mods": { + "get": { + "description": "Retrieve a users mods by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve a Users Mods", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/users/{userIds}": { + "get": { + "description": "Retrieve a list of users by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Retrieve a list of Users", + "parameters": [ + { + "type": "string", + "description": "User IDs comma-separated", + "name": "userIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/version/{versionId}": { + "get": { + "description": "Retrieve a version by version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version" + ], + "summary": "Retrieve a Version", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/versions/{versionId}/download": { + "get": { + "description": "Download a mod version by version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version" + ], + "summary": "Download a Version", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/versions/{versionId}/{target}/download": { + "get": { + "description": "Download a mod version by version ID and TargetName", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version", + "TargetName" + ], + "summary": "Download a TargetName", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "TargetName", + "name": "target", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1", + Host: "api.ficsit.app", + BasePath: "/v1", + Schemes: []string{}, + Title: "Satisfactory Mod Repo API", + Description: "Satisfactory Mod Repo API documentation.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/generated/docs/swagger.json b/generated/docs/swagger.json new file mode 100644 index 00000000..17323290 --- /dev/null +++ b/generated/docs/swagger.json @@ -0,0 +1,777 @@ +{ + "swagger": "2.0", + "info": { + "description": "Satisfactory Mod Repo API documentation.", + "title": "Satisfactory Mod Repo API", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1" + }, + "host": "api.ficsit.app", + "basePath": "/v1", + "paths": { + "/mod/{modId}": { + "get": { + "description": "Retrieve a mod by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/authors": { + "get": { + "description": "Retrieve a mod authors by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Authors", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for a mod based on mod id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a list of latest versions for a mod", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions": { + "get": { + "description": "Retrieve a mod versions by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Versions", + "parameters": [ + { + "type": "integer", + "description": "How many versions to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of versions to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at" + ], + "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": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/all": { + "get": { + "description": "Retrieve all mod versions by mod ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve all Mod Versions", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}": { + "get": { + "description": "Retrieve a mod version by mod ID and version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Retrieve a Mod Version", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}/download": { + "get": { + "description": "Download a mod version by mod ID and version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Download a Mod Version", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mod/{modId}/versions/{versionId}/{target}/download": { + "get": { + "description": "Download a mod version by mod ID and version ID and TargetName", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mod" + ], + "summary": "Download a Mod Version by TargetName", + "parameters": [ + { + "type": "string", + "description": "Mod ID", + "name": "modId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "TargetName", + "name": "target", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods": { + "get": { + "description": "Retrieve a list of mods", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of Mods", + "parameters": [ + { + "type": "integer", + "description": "How many mods to return", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset for list of mods to return", + "name": "offset", + "in": "query" + }, + { + "enum": [ + "created_at", + "updated_at", + "name", + "views", + "downloads", + "hotness", + "popularity", + "last_version_date" + ], + "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" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/count": { + "get": { + "description": "Retrieve a count of Mods", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a count of Mods", + "parameters": [ + { + "type": "string", + "description": "Search string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/{modIds}": { + "get": { + "description": "Retrieve a list of mods by mod IDs", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of Mods by ID", + "parameters": [ + { + "type": "string", + "description": "Mod IDs", + "name": "modIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/mods/{modIds}/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for mods based on mod id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Mods" + ], + "summary": "Retrieve a list of latest versions for mods", + "parameters": [ + { + "type": "string", + "description": "Mod IDs", + "name": "modIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/oauth": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "OAuth" + ], + "summary": "Retrieve a list of OAuth methods", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/oauth/github": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "OAuth" + ], + "summary": "Callback URL for github OAuth", + "parameters": [ + { + "type": "string", + "description": "OAuth Code", + "name": "code", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "OAuth Code", + "name": "state", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/sml/latest-versions": { + "get": { + "description": "Retrieve a list of latest versions for sml", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SML" + ], + "summary": "Retrieve a list of latest versions for sml", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me": { + "get": { + "description": "Retrieve the user associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve Current User", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me/logout": { + "get": { + "description": "Log out the user associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Log Out Current User", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/me/mods": { + "get": { + "description": "Retrieve the users mods associated with the token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve Current Users Mods", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/{userId}": { + "get": { + "description": "Retrieve a user by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve a User", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/user/{userId}/mods": { + "get": { + "description": "Retrieve a users mods by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Retrieve a Users Mods", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/users/{userIds}": { + "get": { + "description": "Retrieve a list of users by user ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Retrieve a list of Users", + "parameters": [ + { + "type": "string", + "description": "User IDs comma-separated", + "name": "userIds", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/version/{versionId}": { + "get": { + "description": "Retrieve a version by version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version" + ], + "summary": "Retrieve a Version", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/versions/{versionId}/download": { + "get": { + "description": "Download a mod version by version ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version" + ], + "summary": "Download a Version", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/versions/{versionId}/{target}/download": { + "get": { + "description": "Download a mod version by version ID and TargetName", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Version", + "TargetName" + ], + "summary": "Download a TargetName", + "parameters": [ + { + "type": "string", + "description": "Version ID", + "name": "versionId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "TargetName", + "name": "target", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/docs/swagger.yaml b/generated/docs/swagger.yaml new file mode 100644 index 00000000..a259841e --- /dev/null +++ b/generated/docs/swagger.yaml @@ -0,0 +1,515 @@ +basePath: /v1 +host: api.ficsit.app +info: + contact: {} + description: Satisfactory Mod Repo API documentation. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + title: Satisfactory Mod Repo API + version: "1" +paths: + /mod/{modId}: + get: + consumes: + - application/json + description: Retrieve a mod by mod ID + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Mod + tags: + - Mod + /mod/{modId}/authors: + get: + consumes: + - application/json + description: Retrieve a mod authors by mod ID + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Mod Authors + tags: + - Mod + /mod/{modId}/latest-versions: + get: + consumes: + - application/json + description: Retrieve a list of latest versions for a mod based on mod id + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of latest versions for a mod + tags: + - Mod + /mod/{modId}/versions: + get: + consumes: + - application/json + description: Retrieve a mod versions by mod ID + parameters: + - description: How many versions to return + in: query + name: limit + type: integer + - description: Offset for list of versions to return + in: query + name: offset + type: integer + - description: Order by field + enum: + - created_at + - updated_at + in: query + name: order_by + type: string + - description: Order of results + enum: + - asc + - desc + in: query + name: order + type: string + - description: Mod ID + in: path + name: modId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Mod Versions + tags: + - Mod + /mod/{modId}/versions/{versionId}: + get: + consumes: + - application/json + description: Retrieve a mod version by mod ID and version ID + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + - description: Version ID + in: path + name: versionId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Mod Version + tags: + - Mod + /mod/{modId}/versions/{versionId}/{target}/download: + get: + consumes: + - application/json + description: Download a mod version by mod ID and version ID and TargetName + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + - description: Version ID + in: path + name: versionId + required: true + type: string + - description: TargetName + in: path + name: target + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Download a Mod Version by TargetName + tags: + - Mod + /mod/{modId}/versions/{versionId}/download: + get: + consumes: + - application/json + description: Download a mod version by mod ID and version ID + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + - description: Version ID + in: path + name: versionId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Download a Mod Version + tags: + - Mod + /mod/{modId}/versions/all: + get: + consumes: + - application/json + description: Retrieve all mod versions by mod ID + parameters: + - description: Mod ID + in: path + name: modId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve all Mod Versions + tags: + - Mod + /mods: + get: + consumes: + - application/json + description: Retrieve a list of mods + parameters: + - description: How many mods to return + in: query + name: limit + type: integer + - description: Offset for list of mods to return + in: query + name: offset + type: integer + - description: Order by field + enum: + - created_at + - updated_at + - name + - views + - downloads + - hotness + - popularity + - last_version_date + 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 + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of Mods + tags: + - Mods + /mods/{modIds}: + get: + consumes: + - application/json + description: Retrieve a list of mods by mod IDs + parameters: + - description: Mod IDs + in: path + name: modIds + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of Mods by ID + tags: + - Mods + /mods/{modIds}/latest-versions: + get: + consumes: + - application/json + description: Retrieve a list of latest versions for mods based on mod id + parameters: + - description: Mod IDs + in: path + name: modIds + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of latest versions for mods + tags: + - Mods + /mods/count: + get: + consumes: + - application/json + description: Retrieve a count of Mods + parameters: + - description: Search string + in: query + name: search + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a count of Mods + tags: + - Mods + /oauth: + get: + consumes: + - application/json + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of OAuth methods + tags: + - OAuth + /oauth/github: + get: + consumes: + - application/json + parameters: + - description: OAuth Code + in: query + name: code + required: true + type: string + - description: OAuth Code + in: query + name: state + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Callback URL for github OAuth + tags: + - OAuth + /sml/latest-versions: + get: + consumes: + - application/json + description: Retrieve a list of latest versions for sml + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of latest versions for sml + tags: + - SML + /user/{userId}: + get: + consumes: + - application/json + description: Retrieve a user by user ID + parameters: + - description: User ID + in: path + name: userId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a User + tags: + - User + /user/{userId}/mods: + get: + consumes: + - application/json + description: Retrieve a users mods by user ID + parameters: + - description: User ID + in: path + name: userId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Users Mods + tags: + - User + /user/me: + get: + consumes: + - application/json + description: Retrieve the user associated with the token + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve Current User + tags: + - User + /user/me/logout: + get: + consumes: + - application/json + description: Log out the user associated with the token + produces: + - application/json + responses: + "200": + description: OK + summary: Log Out Current User + tags: + - User + /user/me/mods: + get: + consumes: + - application/json + description: Retrieve the users mods associated with the token + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve Current Users Mods + tags: + - User + /users/{userIds}: + get: + consumes: + - application/json + description: Retrieve a list of users by user ID + parameters: + - description: User IDs comma-separated + in: path + name: userIds + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a list of Users + tags: + - Users + /version/{versionId}: + get: + consumes: + - application/json + description: Retrieve a version by version ID + parameters: + - description: Version ID + in: path + name: versionId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Retrieve a Version + tags: + - Version + /versions/{versionId}/{target}/download: + get: + consumes: + - application/json + description: Download a mod version by version ID and TargetName + parameters: + - description: Version ID + in: path + name: versionId + required: true + type: string + - description: TargetName + in: path + name: target + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Download a TargetName + tags: + - Version + - TargetName + /versions/{versionId}/download: + get: + consumes: + - application/json + description: Download a mod version by version ID + parameters: + - description: Version ID + in: path + name: versionId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + summary: Download a Version + tags: + - Version +swagger: "2.0" diff --git a/generated/ent/announcement.go b/generated/ent/announcement.go new file mode 100644 index 00000000..d8fe4cdf --- /dev/null +++ b/generated/ent/announcement.go @@ -0,0 +1,148 @@ +// 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/announcement" +) + +// Announcement is the model entity for the Announcement schema. +type Announcement 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Message holds the value of the "message" field. + Message string `json:"message,omitempty"` + // Importance holds the value of the "importance" field. + Importance string `json:"importance,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Announcement) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case announcement.FieldID, announcement.FieldMessage, announcement.FieldImportance: + values[i] = new(sql.NullString) + case announcement.FieldCreatedAt, announcement.FieldUpdatedAt, announcement.FieldDeletedAt: + 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 Announcement fields. +func (a *Announcement) 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 announcement.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + a.ID = value.String + } + case announcement.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 { + a.CreatedAt = value.Time + } + case announcement.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 { + a.UpdatedAt = value.Time + } + case announcement.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + a.DeletedAt = value.Time + } + case announcement.FieldMessage: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field message", values[i]) + } else if value.Valid { + a.Message = value.String + } + case announcement.FieldImportance: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field importance", values[i]) + } else if value.Valid { + a.Importance = value.String + } + default: + a.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Announcement. +// This includes values selected through modifiers, order, etc. +func (a *Announcement) Value(name string) (ent.Value, error) { + return a.selectValues.Get(name) +} + +// Update returns a builder for updating this Announcement. +// Note that you need to call Announcement.Unwrap() before calling this method if this Announcement +// was returned from a transaction, and the transaction was committed or rolled back. +func (a *Announcement) Update() *AnnouncementUpdateOne { + return NewAnnouncementClient(a.config).UpdateOne(a) +} + +// Unwrap unwraps the Announcement 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 (a *Announcement) Unwrap() *Announcement { + _tx, ok := a.config.driver.(*txDriver) + if !ok { + panic("ent: Announcement is not a transactional entity") + } + a.config.driver = _tx.drv + return a +} + +// String implements the fmt.Stringer. +func (a *Announcement) String() string { + var builder strings.Builder + builder.WriteString("Announcement(") + builder.WriteString(fmt.Sprintf("id=%v, ", a.ID)) + builder.WriteString("created_at=") + builder.WriteString(a.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(a.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(a.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("message=") + builder.WriteString(a.Message) + builder.WriteString(", ") + builder.WriteString("importance=") + builder.WriteString(a.Importance) + builder.WriteByte(')') + return builder.String() +} + +// Announcements is a parsable slice of Announcement. +type Announcements []*Announcement diff --git a/generated/ent/announcement/announcement.go b/generated/ent/announcement/announcement.go new file mode 100644 index 00000000..ca25f3f9 --- /dev/null +++ b/generated/ent/announcement/announcement.go @@ -0,0 +1,100 @@ +// Code generated by ent, DO NOT EDIT. + +package announcement + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the announcement type in the database. + Label = "announcement" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldMessage holds the string denoting the message field in the database. + FieldMessage = "message" + // FieldImportance holds the string denoting the importance field in the database. + FieldImportance = "importance" + // Table holds the table name of the announcement in the database. + Table = "announcements" +) + +// Columns holds all SQL columns for announcement fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldMessage, + FieldImportance, +} + +// 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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 Announcement 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByMessage orders the results by the message field. +func ByMessage(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMessage, opts...).ToFunc() +} + +// ByImportance orders the results by the importance field. +func ByImportance(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldImportance, opts...).ToFunc() +} diff --git a/generated/ent/announcement/where.go b/generated/ent/announcement/where.go new file mode 100644 index 00000000..2f9ae05c --- /dev/null +++ b/generated/ent/announcement/where.go @@ -0,0 +1,365 @@ +// Code generated by ent, DO NOT EDIT. + +package announcement + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Announcement { + return predicate.Announcement(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Announcement { + return predicate.Announcement(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.Announcement { + return predicate.Announcement(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.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Message applies equality check predicate on the "message" field. It's identical to MessageEQ. +func Message(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldMessage, v)) +} + +// Importance applies equality check predicate on the "importance" field. It's identical to ImportanceEQ. +func Importance(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldImportance, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Announcement { + return predicate.Announcement(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Announcement { + return predicate.Announcement(sql.FieldNotNull(FieldDeletedAt)) +} + +// MessageEQ applies the EQ predicate on the "message" field. +func MessageEQ(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldMessage, v)) +} + +// MessageNEQ applies the NEQ predicate on the "message" field. +func MessageNEQ(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldMessage, v)) +} + +// MessageIn applies the In predicate on the "message" field. +func MessageIn(vs ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldMessage, vs...)) +} + +// MessageNotIn applies the NotIn predicate on the "message" field. +func MessageNotIn(vs ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldMessage, vs...)) +} + +// MessageGT applies the GT predicate on the "message" field. +func MessageGT(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldMessage, v)) +} + +// MessageGTE applies the GTE predicate on the "message" field. +func MessageGTE(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldMessage, v)) +} + +// MessageLT applies the LT predicate on the "message" field. +func MessageLT(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldMessage, v)) +} + +// MessageLTE applies the LTE predicate on the "message" field. +func MessageLTE(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldMessage, v)) +} + +// MessageContains applies the Contains predicate on the "message" field. +func MessageContains(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldContains(FieldMessage, v)) +} + +// MessageHasPrefix applies the HasPrefix predicate on the "message" field. +func MessageHasPrefix(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldHasPrefix(FieldMessage, v)) +} + +// MessageHasSuffix applies the HasSuffix predicate on the "message" field. +func MessageHasSuffix(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldHasSuffix(FieldMessage, v)) +} + +// MessageEqualFold applies the EqualFold predicate on the "message" field. +func MessageEqualFold(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEqualFold(FieldMessage, v)) +} + +// MessageContainsFold applies the ContainsFold predicate on the "message" field. +func MessageContainsFold(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldContainsFold(FieldMessage, v)) +} + +// ImportanceEQ applies the EQ predicate on the "importance" field. +func ImportanceEQ(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEQ(FieldImportance, v)) +} + +// ImportanceNEQ applies the NEQ predicate on the "importance" field. +func ImportanceNEQ(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldNEQ(FieldImportance, v)) +} + +// ImportanceIn applies the In predicate on the "importance" field. +func ImportanceIn(vs ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldIn(FieldImportance, vs...)) +} + +// ImportanceNotIn applies the NotIn predicate on the "importance" field. +func ImportanceNotIn(vs ...string) predicate.Announcement { + return predicate.Announcement(sql.FieldNotIn(FieldImportance, vs...)) +} + +// ImportanceGT applies the GT predicate on the "importance" field. +func ImportanceGT(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldGT(FieldImportance, v)) +} + +// ImportanceGTE applies the GTE predicate on the "importance" field. +func ImportanceGTE(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldGTE(FieldImportance, v)) +} + +// ImportanceLT applies the LT predicate on the "importance" field. +func ImportanceLT(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldLT(FieldImportance, v)) +} + +// ImportanceLTE applies the LTE predicate on the "importance" field. +func ImportanceLTE(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldLTE(FieldImportance, v)) +} + +// ImportanceContains applies the Contains predicate on the "importance" field. +func ImportanceContains(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldContains(FieldImportance, v)) +} + +// ImportanceHasPrefix applies the HasPrefix predicate on the "importance" field. +func ImportanceHasPrefix(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldHasPrefix(FieldImportance, v)) +} + +// ImportanceHasSuffix applies the HasSuffix predicate on the "importance" field. +func ImportanceHasSuffix(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldHasSuffix(FieldImportance, v)) +} + +// ImportanceEqualFold applies the EqualFold predicate on the "importance" field. +func ImportanceEqualFold(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldEqualFold(FieldImportance, v)) +} + +// ImportanceContainsFold applies the ContainsFold predicate on the "importance" field. +func ImportanceContainsFold(v string) predicate.Announcement { + return predicate.Announcement(sql.FieldContainsFold(FieldImportance, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Announcement) predicate.Announcement { + return predicate.Announcement(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Announcement) predicate.Announcement { + return predicate.Announcement(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Announcement) predicate.Announcement { + return predicate.Announcement(sql.NotPredicates(p)) +} diff --git a/generated/ent/announcement_create.go b/generated/ent/announcement_create.go new file mode 100644 index 00000000..ea0cd27b --- /dev/null +++ b/generated/ent/announcement_create.go @@ -0,0 +1,306 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" +) + +// AnnouncementCreate is the builder for creating a Announcement entity. +type AnnouncementCreate struct { + config + mutation *AnnouncementMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (ac *AnnouncementCreate) SetCreatedAt(t time.Time) *AnnouncementCreate { + ac.mutation.SetCreatedAt(t) + return ac +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (ac *AnnouncementCreate) SetNillableCreatedAt(t *time.Time) *AnnouncementCreate { + if t != nil { + ac.SetCreatedAt(*t) + } + return ac +} + +// SetUpdatedAt sets the "updated_at" field. +func (ac *AnnouncementCreate) SetUpdatedAt(t time.Time) *AnnouncementCreate { + ac.mutation.SetUpdatedAt(t) + return ac +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (ac *AnnouncementCreate) SetNillableUpdatedAt(t *time.Time) *AnnouncementCreate { + if t != nil { + ac.SetUpdatedAt(*t) + } + return ac +} + +// SetDeletedAt sets the "deleted_at" field. +func (ac *AnnouncementCreate) SetDeletedAt(t time.Time) *AnnouncementCreate { + ac.mutation.SetDeletedAt(t) + return ac +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ac *AnnouncementCreate) SetNillableDeletedAt(t *time.Time) *AnnouncementCreate { + if t != nil { + ac.SetDeletedAt(*t) + } + return ac +} + +// SetMessage sets the "message" field. +func (ac *AnnouncementCreate) SetMessage(s string) *AnnouncementCreate { + ac.mutation.SetMessage(s) + return ac +} + +// SetImportance sets the "importance" field. +func (ac *AnnouncementCreate) SetImportance(s string) *AnnouncementCreate { + ac.mutation.SetImportance(s) + return ac +} + +// SetID sets the "id" field. +func (ac *AnnouncementCreate) SetID(s string) *AnnouncementCreate { + ac.mutation.SetID(s) + return ac +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (ac *AnnouncementCreate) SetNillableID(s *string) *AnnouncementCreate { + if s != nil { + ac.SetID(*s) + } + return ac +} + +// Mutation returns the AnnouncementMutation object of the builder. +func (ac *AnnouncementCreate) Mutation() *AnnouncementMutation { + return ac.mutation +} + +// Save creates the Announcement in the database. +func (ac *AnnouncementCreate) Save(ctx context.Context) (*Announcement, error) { + if err := ac.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (ac *AnnouncementCreate) SaveX(ctx context.Context) *Announcement { + v, err := ac.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ac *AnnouncementCreate) Exec(ctx context.Context) error { + _, err := ac.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ac *AnnouncementCreate) ExecX(ctx context.Context) { + if err := ac.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ac *AnnouncementCreate) defaults() error { + if _, ok := ac.mutation.CreatedAt(); !ok { + if announcement.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized announcement.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := announcement.DefaultCreatedAt() + ac.mutation.SetCreatedAt(v) + } + if _, ok := ac.mutation.UpdatedAt(); !ok { + if announcement.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized announcement.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := announcement.DefaultUpdatedAt() + ac.mutation.SetUpdatedAt(v) + } + if _, ok := ac.mutation.ID(); !ok { + if announcement.DefaultID == nil { + return fmt.Errorf("ent: uninitialized announcement.DefaultID (forgotten import ent/runtime?)") + } + v := announcement.DefaultID() + ac.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (ac *AnnouncementCreate) check() error { + if _, ok := ac.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Announcement.created_at"`)} + } + if _, ok := ac.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Announcement.updated_at"`)} + } + if _, ok := ac.mutation.Message(); !ok { + return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "Announcement.message"`)} + } + if _, ok := ac.mutation.Importance(); !ok { + return &ValidationError{Name: "importance", err: errors.New(`ent: missing required field "Announcement.importance"`)} + } + return nil +} + +func (ac *AnnouncementCreate) sqlSave(ctx context.Context) (*Announcement, error) { + if err := ac.check(); err != nil { + return nil, err + } + _node, _spec := ac.createSpec() + if err := sqlgraph.CreateNode(ctx, ac.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 Announcement.ID type: %T", _spec.ID.Value) + } + } + ac.mutation.id = &_node.ID + ac.mutation.done = true + return _node, nil +} + +func (ac *AnnouncementCreate) createSpec() (*Announcement, *sqlgraph.CreateSpec) { + var ( + _node = &Announcement{config: ac.config} + _spec = sqlgraph.NewCreateSpec(announcement.Table, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) + ) + if id, ok := ac.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := ac.mutation.CreatedAt(); ok { + _spec.SetField(announcement.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := ac.mutation.UpdatedAt(); ok { + _spec.SetField(announcement.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := ac.mutation.DeletedAt(); ok { + _spec.SetField(announcement.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := ac.mutation.Message(); ok { + _spec.SetField(announcement.FieldMessage, field.TypeString, value) + _node.Message = value + } + if value, ok := ac.mutation.Importance(); ok { + _spec.SetField(announcement.FieldImportance, field.TypeString, value) + _node.Importance = value + } + return _node, _spec +} + +// AnnouncementCreateBulk is the builder for creating many Announcement entities in bulk. +type AnnouncementCreateBulk struct { + config + err error + builders []*AnnouncementCreate +} + +// Save creates the Announcement entities in the database. +func (acb *AnnouncementCreateBulk) Save(ctx context.Context) ([]*Announcement, error) { + if acb.err != nil { + return nil, acb.err + } + specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) + nodes := make([]*Announcement, len(acb.builders)) + mutators := make([]Mutator, len(acb.builders)) + for i := range acb.builders { + func(i int, root context.Context) { + builder := acb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AnnouncementMutation) + 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, acb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, acb.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, acb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (acb *AnnouncementCreateBulk) SaveX(ctx context.Context) []*Announcement { + v, err := acb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (acb *AnnouncementCreateBulk) Exec(ctx context.Context) error { + _, err := acb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (acb *AnnouncementCreateBulk) ExecX(ctx context.Context) { + if err := acb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/announcement_delete.go b/generated/ent/announcement_delete.go new file mode 100644 index 00000000..9faf0449 --- /dev/null +++ b/generated/ent/announcement_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/announcement" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// AnnouncementDelete is the builder for deleting a Announcement entity. +type AnnouncementDelete struct { + config + hooks []Hook + mutation *AnnouncementMutation +} + +// Where appends a list predicates to the AnnouncementDelete builder. +func (ad *AnnouncementDelete) Where(ps ...predicate.Announcement) *AnnouncementDelete { + ad.mutation.Where(ps...) + return ad +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ad *AnnouncementDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ad *AnnouncementDelete) ExecX(ctx context.Context) int { + n, err := ad.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ad *AnnouncementDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(announcement.Table, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) + if ps := ad.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ad.mutation.done = true + return affected, err +} + +// AnnouncementDeleteOne is the builder for deleting a single Announcement entity. +type AnnouncementDeleteOne struct { + ad *AnnouncementDelete +} + +// Where appends a list predicates to the AnnouncementDelete builder. +func (ado *AnnouncementDeleteOne) Where(ps ...predicate.Announcement) *AnnouncementDeleteOne { + ado.ad.mutation.Where(ps...) + return ado +} + +// Exec executes the deletion query. +func (ado *AnnouncementDeleteOne) Exec(ctx context.Context) error { + n, err := ado.ad.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{announcement.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ado *AnnouncementDeleteOne) ExecX(ctx context.Context) { + if err := ado.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/announcement_query.go b/generated/ent/announcement_query.go new file mode 100644 index 00000000..e396f22e --- /dev/null +++ b/generated/ent/announcement_query.go @@ -0,0 +1,548 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// AnnouncementQuery is the builder for querying Announcement entities. +type AnnouncementQuery struct { + config + ctx *QueryContext + order []announcement.OrderOption + inters []Interceptor + predicates []predicate.Announcement + 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 AnnouncementQuery builder. +func (aq *AnnouncementQuery) Where(ps ...predicate.Announcement) *AnnouncementQuery { + aq.predicates = append(aq.predicates, ps...) + return aq +} + +// Limit the number of records to be returned by this query. +func (aq *AnnouncementQuery) Limit(limit int) *AnnouncementQuery { + aq.ctx.Limit = &limit + return aq +} + +// Offset to start from. +func (aq *AnnouncementQuery) Offset(offset int) *AnnouncementQuery { + aq.ctx.Offset = &offset + return aq +} + +// 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 (aq *AnnouncementQuery) Unique(unique bool) *AnnouncementQuery { + aq.ctx.Unique = &unique + return aq +} + +// Order specifies how the records should be ordered. +func (aq *AnnouncementQuery) Order(o ...announcement.OrderOption) *AnnouncementQuery { + aq.order = append(aq.order, o...) + return aq +} + +// First returns the first Announcement entity from the query. +// Returns a *NotFoundError when no Announcement was found. +func (aq *AnnouncementQuery) First(ctx context.Context) (*Announcement, error) { + nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{announcement.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (aq *AnnouncementQuery) FirstX(ctx context.Context) *Announcement { + node, err := aq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Announcement ID from the query. +// Returns a *NotFoundError when no Announcement ID was found. +func (aq *AnnouncementQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{announcement.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (aq *AnnouncementQuery) FirstIDX(ctx context.Context) string { + id, err := aq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Announcement entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Announcement entity is found. +// Returns a *NotFoundError when no Announcement entities are found. +func (aq *AnnouncementQuery) Only(ctx context.Context) (*Announcement, error) { + nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{announcement.Label} + default: + return nil, &NotSingularError{announcement.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (aq *AnnouncementQuery) OnlyX(ctx context.Context) *Announcement { + node, err := aq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Announcement ID in the query. +// Returns a *NotSingularError when more than one Announcement ID is found. +// Returns a *NotFoundError when no entities are found. +func (aq *AnnouncementQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{announcement.Label} + default: + err = &NotSingularError{announcement.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (aq *AnnouncementQuery) OnlyIDX(ctx context.Context) string { + id, err := aq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Announcements. +func (aq *AnnouncementQuery) All(ctx context.Context) ([]*Announcement, error) { + ctx = setContextOp(ctx, aq.ctx, "All") + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Announcement, *AnnouncementQuery]() + return withInterceptors[[]*Announcement](ctx, aq, qr, aq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (aq *AnnouncementQuery) AllX(ctx context.Context) []*Announcement { + nodes, err := aq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Announcement IDs. +func (aq *AnnouncementQuery) IDs(ctx context.Context) (ids []string, err error) { + if aq.ctx.Unique == nil && aq.path != nil { + aq.Unique(true) + } + ctx = setContextOp(ctx, aq.ctx, "IDs") + if err = aq.Select(announcement.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (aq *AnnouncementQuery) IDsX(ctx context.Context) []string { + ids, err := aq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (aq *AnnouncementQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, aq.ctx, "Count") + if err := aq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, aq, querierCount[*AnnouncementQuery](), aq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (aq *AnnouncementQuery) CountX(ctx context.Context) int { + count, err := aq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (aq *AnnouncementQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, aq.ctx, "Exist") + switch _, err := aq.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 (aq *AnnouncementQuery) ExistX(ctx context.Context) bool { + exist, err := aq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AnnouncementQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (aq *AnnouncementQuery) Clone() *AnnouncementQuery { + if aq == nil { + return nil + } + return &AnnouncementQuery{ + config: aq.config, + ctx: aq.ctx.Clone(), + order: append([]announcement.OrderOption{}, aq.order...), + inters: append([]Interceptor{}, aq.inters...), + predicates: append([]predicate.Announcement{}, aq.predicates...), + // clone intermediate query. + sql: aq.sql.Clone(), + path: aq.path, + } +} + +// 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.Announcement.Query(). +// GroupBy(announcement.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (aq *AnnouncementQuery) GroupBy(field string, fields ...string) *AnnouncementGroupBy { + aq.ctx.Fields = append([]string{field}, fields...) + grbuild := &AnnouncementGroupBy{build: aq} + grbuild.flds = &aq.ctx.Fields + grbuild.label = announcement.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.Announcement.Query(). +// Select(announcement.FieldCreatedAt). +// Scan(ctx, &v) +func (aq *AnnouncementQuery) Select(fields ...string) *AnnouncementSelect { + aq.ctx.Fields = append(aq.ctx.Fields, fields...) + sbuild := &AnnouncementSelect{AnnouncementQuery: aq} + sbuild.label = announcement.Label + sbuild.flds, sbuild.scan = &aq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AnnouncementSelect configured with the given aggregations. +func (aq *AnnouncementQuery) Aggregate(fns ...AggregateFunc) *AnnouncementSelect { + return aq.Select().Aggregate(fns...) +} + +func (aq *AnnouncementQuery) prepareQuery(ctx context.Context) error { + for _, inter := range aq.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, aq); err != nil { + return err + } + } + } + for _, f := range aq.ctx.Fields { + if !announcement.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if aq.path != nil { + prev, err := aq.path(ctx) + if err != nil { + return err + } + aq.sql = prev + } + return nil +} + +func (aq *AnnouncementQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Announcement, error) { + var ( + nodes = []*Announcement{} + _spec = aq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Announcement).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Announcement{config: aq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(aq.modifiers) > 0 { + _spec.Modifiers = aq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (aq *AnnouncementQuery) sqlCount(ctx context.Context) (int, error) { + _spec := aq.querySpec() + if len(aq.modifiers) > 0 { + _spec.Modifiers = aq.modifiers + } + _spec.Node.Columns = aq.ctx.Fields + if len(aq.ctx.Fields) > 0 { + _spec.Unique = aq.ctx.Unique != nil && *aq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, aq.driver, _spec) +} + +func (aq *AnnouncementQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(announcement.Table, announcement.Columns, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) + _spec.From = aq.sql + if unique := aq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if aq.path != nil { + _spec.Unique = true + } + if fields := aq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, announcement.FieldID) + for i := range fields { + if fields[i] != announcement.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := aq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := aq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := aq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := aq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (aq *AnnouncementQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(aq.driver.Dialect()) + t1 := builder.Table(announcement.Table) + columns := aq.ctx.Fields + if len(columns) == 0 { + columns = announcement.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if aq.sql != nil { + selector = aq.sql + selector.Select(selector.Columns(columns...)...) + } + if aq.ctx.Unique != nil && *aq.ctx.Unique { + selector.Distinct() + } + for _, m := range aq.modifiers { + m(selector) + } + for _, p := range aq.predicates { + p(selector) + } + for _, p := range aq.order { + p(selector) + } + if offset := aq.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 := aq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (aq *AnnouncementQuery) Modify(modifiers ...func(s *sql.Selector)) *AnnouncementSelect { + aq.modifiers = append(aq.modifiers, modifiers...) + return aq.Select() +} + +// AnnouncementGroupBy is the group-by builder for Announcement entities. +type AnnouncementGroupBy struct { + selector + build *AnnouncementQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (agb *AnnouncementGroupBy) Aggregate(fns ...AggregateFunc) *AnnouncementGroupBy { + agb.fns = append(agb.fns, fns...) + return agb +} + +// Scan applies the selector query and scans the result into the given value. +func (agb *AnnouncementGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, agb.build.ctx, "GroupBy") + if err := agb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AnnouncementQuery, *AnnouncementGroupBy](ctx, agb.build, agb, agb.build.inters, v) +} + +func (agb *AnnouncementGroupBy) sqlScan(ctx context.Context, root *AnnouncementQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(agb.fns)) + for _, fn := range agb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*agb.flds)+len(agb.fns)) + for _, f := range *agb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*agb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := agb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AnnouncementSelect is the builder for selecting fields of Announcement entities. +type AnnouncementSelect struct { + *AnnouncementQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (as *AnnouncementSelect) Aggregate(fns ...AggregateFunc) *AnnouncementSelect { + as.fns = append(as.fns, fns...) + return as +} + +// Scan applies the selector query and scans the result into the given value. +func (as *AnnouncementSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, as.ctx, "Select") + if err := as.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AnnouncementQuery, *AnnouncementSelect](ctx, as.AnnouncementQuery, as, as.inters, v) +} + +func (as *AnnouncementSelect) sqlScan(ctx context.Context, root *AnnouncementQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(as.fns)) + for _, fn := range as.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*as.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 := as.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 (as *AnnouncementSelect) Modify(modifiers ...func(s *sql.Selector)) *AnnouncementSelect { + as.modifiers = append(as.modifiers, modifiers...) + return as +} diff --git a/generated/ent/announcement_update.go b/generated/ent/announcement_update.go new file mode 100644 index 00000000..4ce22dd2 --- /dev/null +++ b/generated/ent/announcement_update.go @@ -0,0 +1,328 @@ +// 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/announcement" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// AnnouncementUpdate is the builder for updating Announcement entities. +type AnnouncementUpdate struct { + config + hooks []Hook + mutation *AnnouncementMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AnnouncementUpdate builder. +func (au *AnnouncementUpdate) Where(ps ...predicate.Announcement) *AnnouncementUpdate { + au.mutation.Where(ps...) + return au +} + +// SetUpdatedAt sets the "updated_at" field. +func (au *AnnouncementUpdate) SetUpdatedAt(t time.Time) *AnnouncementUpdate { + au.mutation.SetUpdatedAt(t) + return au +} + +// SetDeletedAt sets the "deleted_at" field. +func (au *AnnouncementUpdate) SetDeletedAt(t time.Time) *AnnouncementUpdate { + au.mutation.SetDeletedAt(t) + return au +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (au *AnnouncementUpdate) SetNillableDeletedAt(t *time.Time) *AnnouncementUpdate { + if t != nil { + au.SetDeletedAt(*t) + } + return au +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (au *AnnouncementUpdate) ClearDeletedAt() *AnnouncementUpdate { + au.mutation.ClearDeletedAt() + return au +} + +// SetMessage sets the "message" field. +func (au *AnnouncementUpdate) SetMessage(s string) *AnnouncementUpdate { + au.mutation.SetMessage(s) + return au +} + +// SetImportance sets the "importance" field. +func (au *AnnouncementUpdate) SetImportance(s string) *AnnouncementUpdate { + au.mutation.SetImportance(s) + return au +} + +// Mutation returns the AnnouncementMutation object of the builder. +func (au *AnnouncementUpdate) Mutation() *AnnouncementMutation { + return au.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (au *AnnouncementUpdate) Save(ctx context.Context) (int, error) { + if err := au.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, au.sqlSave, au.mutation, au.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (au *AnnouncementUpdate) SaveX(ctx context.Context) int { + affected, err := au.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (au *AnnouncementUpdate) Exec(ctx context.Context) error { + _, err := au.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (au *AnnouncementUpdate) ExecX(ctx context.Context) { + if err := au.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (au *AnnouncementUpdate) defaults() error { + if _, ok := au.mutation.UpdatedAt(); !ok { + if announcement.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized announcement.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := announcement.UpdateDefaultUpdatedAt() + au.mutation.SetUpdatedAt(v) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (au *AnnouncementUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AnnouncementUpdate { + au.modifiers = append(au.modifiers, modifiers...) + return au +} + +func (au *AnnouncementUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(announcement.Table, announcement.Columns, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) + if ps := au.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := au.mutation.UpdatedAt(); ok { + _spec.SetField(announcement.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := au.mutation.DeletedAt(); ok { + _spec.SetField(announcement.FieldDeletedAt, field.TypeTime, value) + } + if au.mutation.DeletedAtCleared() { + _spec.ClearField(announcement.FieldDeletedAt, field.TypeTime) + } + if value, ok := au.mutation.Message(); ok { + _spec.SetField(announcement.FieldMessage, field.TypeString, value) + } + if value, ok := au.mutation.Importance(); ok { + _spec.SetField(announcement.FieldImportance, field.TypeString, value) + } + _spec.AddModifiers(au.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{announcement.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + au.mutation.done = true + return n, nil +} + +// AnnouncementUpdateOne is the builder for updating a single Announcement entity. +type AnnouncementUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AnnouncementMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (auo *AnnouncementUpdateOne) SetUpdatedAt(t time.Time) *AnnouncementUpdateOne { + auo.mutation.SetUpdatedAt(t) + return auo +} + +// SetDeletedAt sets the "deleted_at" field. +func (auo *AnnouncementUpdateOne) SetDeletedAt(t time.Time) *AnnouncementUpdateOne { + auo.mutation.SetDeletedAt(t) + return auo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (auo *AnnouncementUpdateOne) SetNillableDeletedAt(t *time.Time) *AnnouncementUpdateOne { + if t != nil { + auo.SetDeletedAt(*t) + } + return auo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (auo *AnnouncementUpdateOne) ClearDeletedAt() *AnnouncementUpdateOne { + auo.mutation.ClearDeletedAt() + return auo +} + +// SetMessage sets the "message" field. +func (auo *AnnouncementUpdateOne) SetMessage(s string) *AnnouncementUpdateOne { + auo.mutation.SetMessage(s) + return auo +} + +// SetImportance sets the "importance" field. +func (auo *AnnouncementUpdateOne) SetImportance(s string) *AnnouncementUpdateOne { + auo.mutation.SetImportance(s) + return auo +} + +// Mutation returns the AnnouncementMutation object of the builder. +func (auo *AnnouncementUpdateOne) Mutation() *AnnouncementMutation { + return auo.mutation +} + +// Where appends a list predicates to the AnnouncementUpdate builder. +func (auo *AnnouncementUpdateOne) Where(ps ...predicate.Announcement) *AnnouncementUpdateOne { + auo.mutation.Where(ps...) + return auo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (auo *AnnouncementUpdateOne) Select(field string, fields ...string) *AnnouncementUpdateOne { + auo.fields = append([]string{field}, fields...) + return auo +} + +// Save executes the query and returns the updated Announcement entity. +func (auo *AnnouncementUpdateOne) Save(ctx context.Context) (*Announcement, error) { + if err := auo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (auo *AnnouncementUpdateOne) SaveX(ctx context.Context) *Announcement { + node, err := auo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (auo *AnnouncementUpdateOne) Exec(ctx context.Context) error { + _, err := auo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (auo *AnnouncementUpdateOne) ExecX(ctx context.Context) { + if err := auo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (auo *AnnouncementUpdateOne) defaults() error { + if _, ok := auo.mutation.UpdatedAt(); !ok { + if announcement.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized announcement.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := announcement.UpdateDefaultUpdatedAt() + auo.mutation.SetUpdatedAt(v) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (auo *AnnouncementUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AnnouncementUpdateOne { + auo.modifiers = append(auo.modifiers, modifiers...) + return auo +} + +func (auo *AnnouncementUpdateOne) sqlSave(ctx context.Context) (_node *Announcement, err error) { + _spec := sqlgraph.NewUpdateSpec(announcement.Table, announcement.Columns, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) + id, ok := auo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Announcement.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := auo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, announcement.FieldID) + for _, f := range fields { + if !announcement.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != announcement.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := auo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := auo.mutation.UpdatedAt(); ok { + _spec.SetField(announcement.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := auo.mutation.DeletedAt(); ok { + _spec.SetField(announcement.FieldDeletedAt, field.TypeTime, value) + } + if auo.mutation.DeletedAtCleared() { + _spec.ClearField(announcement.FieldDeletedAt, field.TypeTime) + } + if value, ok := auo.mutation.Message(); ok { + _spec.SetField(announcement.FieldMessage, field.TypeString, value) + } + if value, ok := auo.mutation.Importance(); ok { + _spec.SetField(announcement.FieldImportance, field.TypeString, value) + } + _spec.AddModifiers(auo.modifiers...) + _node = &Announcement{config: auo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{announcement.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + auo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/client.go b/generated/ent/client.go new file mode 100644 index 00000000..5b51f8cc --- /dev/null +++ b/generated/ent/client.go @@ -0,0 +1,2578 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "github.com/satisfactorymodding/smr-api/generated/ent/migrate" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + + stdsql "database/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // Announcement is the client for interacting with the Announcement builders. + Announcement *AnnouncementClient + // Guide is the client for interacting with the Guide builders. + Guide *GuideClient + // GuideTag is the client for interacting with the GuideTag builders. + GuideTag *GuideTagClient + // Mod is the client for interacting with the Mod builders. + Mod *ModClient + // ModTag is the client for interacting with the ModTag builders. + ModTag *ModTagClient + // SmlVersion is the client for interacting with the SmlVersion builders. + SmlVersion *SmlVersionClient + // SmlVersionTarget is the client for interacting with the SmlVersionTarget builders. + SmlVersionTarget *SmlVersionTargetClient + // Tag is the client for interacting with the Tag builders. + Tag *TagClient + // User is the client for interacting with the User builders. + User *UserClient + // UserGroup is the client for interacting with the UserGroup builders. + UserGroup *UserGroupClient + // UserMod is the client for interacting with the UserMod builders. + UserMod *UserModClient + // UserSession is the client for interacting with the UserSession builders. + UserSession *UserSessionClient + // Version is the client for interacting with the Version builders. + Version *VersionClient + // VersionDependency is the client for interacting with the VersionDependency builders. + VersionDependency *VersionDependencyClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + client := &Client{config: cfg} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.Announcement = NewAnnouncementClient(c.config) + c.Guide = NewGuideClient(c.config) + c.GuideTag = NewGuideTagClient(c.config) + c.Mod = NewModClient(c.config) + c.ModTag = NewModTagClient(c.config) + c.SmlVersion = NewSmlVersionClient(c.config) + c.SmlVersionTarget = NewSmlVersionTargetClient(c.config) + c.Tag = NewTagClient(c.config) + c.User = NewUserClient(c.config) + c.UserGroup = NewUserGroupClient(c.config) + c.UserMod = NewUserModClient(c.config) + c.UserSession = NewUserSessionClient(c.config) + c.Version = NewVersionClient(c.config) + c.VersionDependency = NewVersionDependencyClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + Announcement: NewAnnouncementClient(cfg), + Guide: NewGuideClient(cfg), + GuideTag: NewGuideTagClient(cfg), + Mod: NewModClient(cfg), + ModTag: NewModTagClient(cfg), + SmlVersion: NewSmlVersionClient(cfg), + SmlVersionTarget: NewSmlVersionTargetClient(cfg), + Tag: NewTagClient(cfg), + User: NewUserClient(cfg), + UserGroup: NewUserGroupClient(cfg), + UserMod: NewUserModClient(cfg), + UserSession: NewUserSessionClient(cfg), + Version: NewVersionClient(cfg), + VersionDependency: NewVersionDependencyClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + Announcement: NewAnnouncementClient(cfg), + Guide: NewGuideClient(cfg), + GuideTag: NewGuideTagClient(cfg), + Mod: NewModClient(cfg), + ModTag: NewModTagClient(cfg), + SmlVersion: NewSmlVersionClient(cfg), + SmlVersionTarget: NewSmlVersionTargetClient(cfg), + Tag: NewTagClient(cfg), + User: NewUserClient(cfg), + UserGroup: NewUserGroupClient(cfg), + UserMod: NewUserModClient(cfg), + UserSession: NewUserSessionClient(cfg), + Version: NewVersionClient(cfg), + VersionDependency: NewVersionDependencyClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Announcement. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// 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.SmlVersion, + c.SmlVersionTarget, c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, + c.Version, c.VersionDependency, + } { + n.Use(hooks...) + } +} + +// Intercept adds the query interceptors to all the entity clients. +// 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.SmlVersion, + c.SmlVersionTarget, c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, + c.Version, c.VersionDependency, + } { + n.Intercept(interceptors...) + } +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *AnnouncementMutation: + return c.Announcement.mutate(ctx, m) + case *GuideMutation: + return c.Guide.mutate(ctx, m) + case *GuideTagMutation: + return c.GuideTag.mutate(ctx, m) + case *ModMutation: + return c.Mod.mutate(ctx, m) + case *ModTagMutation: + return c.ModTag.mutate(ctx, m) + case *SmlVersionMutation: + return c.SmlVersion.mutate(ctx, m) + case *SmlVersionTargetMutation: + return c.SmlVersionTarget.mutate(ctx, m) + case *TagMutation: + return c.Tag.mutate(ctx, m) + case *UserMutation: + return c.User.mutate(ctx, m) + case *UserGroupMutation: + return c.UserGroup.mutate(ctx, m) + case *UserModMutation: + return c.UserMod.mutate(ctx, m) + case *UserSessionMutation: + return c.UserSession.mutate(ctx, m) + case *VersionMutation: + return c.Version.mutate(ctx, m) + case *VersionDependencyMutation: + return c.VersionDependency.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// AnnouncementClient is a client for the Announcement schema. +type AnnouncementClient struct { + config +} + +// NewAnnouncementClient returns a client for the Announcement from the given config. +func NewAnnouncementClient(c config) *AnnouncementClient { + return &AnnouncementClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `announcement.Hooks(f(g(h())))`. +func (c *AnnouncementClient) Use(hooks ...Hook) { + c.hooks.Announcement = append(c.hooks.Announcement, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `announcement.Intercept(f(g(h())))`. +func (c *AnnouncementClient) Intercept(interceptors ...Interceptor) { + c.inters.Announcement = append(c.inters.Announcement, interceptors...) +} + +// Create returns a builder for creating a Announcement entity. +func (c *AnnouncementClient) Create() *AnnouncementCreate { + mutation := newAnnouncementMutation(c.config, OpCreate) + return &AnnouncementCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Announcement entities. +func (c *AnnouncementClient) CreateBulk(builders ...*AnnouncementCreate) *AnnouncementCreateBulk { + return &AnnouncementCreateBulk{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 *AnnouncementClient) MapCreateBulk(slice any, setFunc func(*AnnouncementCreate, int)) *AnnouncementCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AnnouncementCreateBulk{err: fmt.Errorf("calling to AnnouncementClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AnnouncementCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AnnouncementCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Announcement. +func (c *AnnouncementClient) Update() *AnnouncementUpdate { + mutation := newAnnouncementMutation(c.config, OpUpdate) + return &AnnouncementUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AnnouncementClient) UpdateOne(a *Announcement) *AnnouncementUpdateOne { + mutation := newAnnouncementMutation(c.config, OpUpdateOne, withAnnouncement(a)) + return &AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AnnouncementClient) UpdateOneID(id string) *AnnouncementUpdateOne { + mutation := newAnnouncementMutation(c.config, OpUpdateOne, withAnnouncementID(id)) + return &AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Announcement. +func (c *AnnouncementClient) Delete() *AnnouncementDelete { + mutation := newAnnouncementMutation(c.config, OpDelete) + return &AnnouncementDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AnnouncementClient) DeleteOne(a *Announcement) *AnnouncementDeleteOne { + return c.DeleteOneID(a.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AnnouncementClient) DeleteOneID(id string) *AnnouncementDeleteOne { + builder := c.Delete().Where(announcement.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AnnouncementDeleteOne{builder} +} + +// Query returns a query builder for Announcement. +func (c *AnnouncementClient) Query() *AnnouncementQuery { + return &AnnouncementQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAnnouncement}, + inters: c.Interceptors(), + } +} + +// Get returns a Announcement entity by its id. +func (c *AnnouncementClient) Get(ctx context.Context, id string) (*Announcement, error) { + return c.Query().Where(announcement.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AnnouncementClient) GetX(ctx context.Context, id string) *Announcement { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *AnnouncementClient) Hooks() []Hook { + hooks := c.hooks.Announcement + return append(hooks[:len(hooks):len(hooks)], announcement.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *AnnouncementClient) Interceptors() []Interceptor { + inters := c.inters.Announcement + return append(inters[:len(inters):len(inters)], announcement.Interceptors[:]...) +} + +func (c *AnnouncementClient) mutate(ctx context.Context, m *AnnouncementMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AnnouncementCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AnnouncementUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AnnouncementDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Announcement mutation op: %q", m.Op()) + } +} + +// GuideClient is a client for the Guide schema. +type GuideClient struct { + config +} + +// NewGuideClient returns a client for the Guide from the given config. +func NewGuideClient(c config) *GuideClient { + return &GuideClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `guide.Hooks(f(g(h())))`. +func (c *GuideClient) Use(hooks ...Hook) { + c.hooks.Guide = append(c.hooks.Guide, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `guide.Intercept(f(g(h())))`. +func (c *GuideClient) Intercept(interceptors ...Interceptor) { + c.inters.Guide = append(c.inters.Guide, interceptors...) +} + +// Create returns a builder for creating a Guide entity. +func (c *GuideClient) Create() *GuideCreate { + mutation := newGuideMutation(c.config, OpCreate) + return &GuideCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Guide entities. +func (c *GuideClient) CreateBulk(builders ...*GuideCreate) *GuideCreateBulk { + return &GuideCreateBulk{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 *GuideClient) MapCreateBulk(slice any, setFunc func(*GuideCreate, int)) *GuideCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GuideCreateBulk{err: fmt.Errorf("calling to GuideClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GuideCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GuideCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Guide. +func (c *GuideClient) Update() *GuideUpdate { + mutation := newGuideMutation(c.config, OpUpdate) + return &GuideUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *GuideClient) UpdateOne(gu *Guide) *GuideUpdateOne { + mutation := newGuideMutation(c.config, OpUpdateOne, withGuide(gu)) + return &GuideUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *GuideClient) UpdateOneID(id string) *GuideUpdateOne { + mutation := newGuideMutation(c.config, OpUpdateOne, withGuideID(id)) + return &GuideUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Guide. +func (c *GuideClient) Delete() *GuideDelete { + mutation := newGuideMutation(c.config, OpDelete) + return &GuideDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *GuideClient) DeleteOne(gu *Guide) *GuideDeleteOne { + return c.DeleteOneID(gu.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *GuideClient) DeleteOneID(id string) *GuideDeleteOne { + builder := c.Delete().Where(guide.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &GuideDeleteOne{builder} +} + +// Query returns a query builder for Guide. +func (c *GuideClient) Query() *GuideQuery { + return &GuideQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeGuide}, + inters: c.Interceptors(), + } +} + +// Get returns a Guide entity by its id. +func (c *GuideClient) Get(ctx context.Context, id string) (*Guide, error) { + return c.Query().Where(guide.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *GuideClient) GetX(ctx context.Context, id string) *Guide { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a Guide. +func (c *GuideClient) QueryUser(gu *Guide) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gu.ID + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, guide.UserTable, guide.UserColumn), + ) + fromV = sqlgraph.Neighbors(gu.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTags queries the tags edge of a Guide. +func (c *GuideClient) QueryTags(gu *Guide) *TagQuery { + query := (&TagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gu.ID + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, id), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, guide.TagsTable, guide.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(gu.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryGuideTags queries the guide_tags edge of a Guide. +func (c *GuideClient) QueryGuideTags(gu *Guide) *GuideTagQuery { + query := (&GuideTagClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := gu.ID + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, id), + sqlgraph.To(guidetag.Table, guidetag.GuideColumn), + sqlgraph.Edge(sqlgraph.O2M, true, guide.GuideTagsTable, guide.GuideTagsColumn), + ) + fromV = sqlgraph.Neighbors(gu.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *GuideClient) Hooks() []Hook { + hooks := c.hooks.Guide + return append(hooks[:len(hooks):len(hooks)], guide.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *GuideClient) Interceptors() []Interceptor { + inters := c.inters.Guide + return append(inters[:len(inters):len(inters)], guide.Interceptors[:]...) +} + +func (c *GuideClient) mutate(ctx context.Context, m *GuideMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&GuideCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&GuideUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&GuideUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&GuideDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Guide mutation op: %q", m.Op()) + } +} + +// GuideTagClient is a client for the GuideTag schema. +type GuideTagClient struct { + config +} + +// NewGuideTagClient returns a client for the GuideTag from the given config. +func NewGuideTagClient(c config) *GuideTagClient { + return &GuideTagClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `guidetag.Hooks(f(g(h())))`. +func (c *GuideTagClient) Use(hooks ...Hook) { + c.hooks.GuideTag = append(c.hooks.GuideTag, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `guidetag.Intercept(f(g(h())))`. +func (c *GuideTagClient) Intercept(interceptors ...Interceptor) { + c.inters.GuideTag = append(c.inters.GuideTag, interceptors...) +} + +// Create returns a builder for creating a GuideTag entity. +func (c *GuideTagClient) Create() *GuideTagCreate { + mutation := newGuideTagMutation(c.config, OpCreate) + return &GuideTagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of GuideTag entities. +func (c *GuideTagClient) CreateBulk(builders ...*GuideTagCreate) *GuideTagCreateBulk { + return &GuideTagCreateBulk{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 *GuideTagClient) MapCreateBulk(slice any, setFunc func(*GuideTagCreate, int)) *GuideTagCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GuideTagCreateBulk{err: fmt.Errorf("calling to GuideTagClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GuideTagCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GuideTagCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for GuideTag. +func (c *GuideTagClient) Update() *GuideTagUpdate { + mutation := newGuideTagMutation(c.config, OpUpdate) + return &GuideTagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *GuideTagClient) UpdateOne(gt *GuideTag) *GuideTagUpdateOne { + mutation := newGuideTagMutation(c.config, OpUpdateOne) + mutation.guide = >.GuideTag + mutation.tag = >.TagID + return &GuideTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for GuideTag. +func (c *GuideTagClient) Delete() *GuideTagDelete { + mutation := newGuideTagMutation(c.config, OpDelete) + return &GuideTagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for GuideTag. +func (c *GuideTagClient) Query() *GuideTagQuery { + return &GuideTagQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeGuideTag}, + inters: c.Interceptors(), + } +} + +// QueryGuide queries the guide edge of a GuideTag. +func (c *GuideTagClient) QueryGuide(gt *GuideTag) *GuideQuery { + return c.Query(). + Where(guidetag.GuideTag(gt.GuideTag), guidetag.TagID(gt.TagID)). + QueryGuide() +} + +// QueryTag queries the tag edge of a GuideTag. +func (c *GuideTagClient) QueryTag(gt *GuideTag) *TagQuery { + return c.Query(). + Where(guidetag.GuideTag(gt.GuideTag), guidetag.TagID(gt.TagID)). + QueryTag() +} + +// Hooks returns the client hooks. +func (c *GuideTagClient) Hooks() []Hook { + return c.hooks.GuideTag +} + +// Interceptors returns the client interceptors. +func (c *GuideTagClient) Interceptors() []Interceptor { + return c.inters.GuideTag +} + +func (c *GuideTagClient) mutate(ctx context.Context, m *GuideTagMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&GuideTagCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&GuideTagUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&GuideTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&GuideTagDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown GuideTag mutation op: %q", m.Op()) + } +} + +// ModClient is a client for the Mod schema. +type ModClient struct { + config +} + +// NewModClient returns a client for the Mod from the given config. +func NewModClient(c config) *ModClient { + return &ModClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `mod.Hooks(f(g(h())))`. +func (c *ModClient) Use(hooks ...Hook) { + c.hooks.Mod = append(c.hooks.Mod, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `mod.Intercept(f(g(h())))`. +func (c *ModClient) Intercept(interceptors ...Interceptor) { + c.inters.Mod = append(c.inters.Mod, interceptors...) +} + +// Create returns a builder for creating a Mod entity. +func (c *ModClient) Create() *ModCreate { + mutation := newModMutation(c.config, OpCreate) + return &ModCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Mod entities. +func (c *ModClient) CreateBulk(builders ...*ModCreate) *ModCreateBulk { + return &ModCreateBulk{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 *ModClient) MapCreateBulk(slice any, setFunc func(*ModCreate, int)) *ModCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModCreateBulk{err: fmt.Errorf("calling to ModClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Mod. +func (c *ModClient) Update() *ModUpdate { + mutation := newModMutation(c.config, OpUpdate) + return &ModUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModClient) UpdateOne(m *Mod) *ModUpdateOne { + mutation := newModMutation(c.config, OpUpdateOne, withMod(m)) + return &ModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ModClient) UpdateOneID(id string) *ModUpdateOne { + mutation := newModMutation(c.config, OpUpdateOne, withModID(id)) + return &ModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Mod. +func (c *ModClient) Delete() *ModDelete { + mutation := newModMutation(c.config, OpDelete) + return &ModDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ModClient) DeleteOne(m *Mod) *ModDeleteOne { + return c.DeleteOneID(m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ModClient) DeleteOneID(id string) *ModDeleteOne { + builder := c.Delete().Where(mod.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ModDeleteOne{builder} +} + +// Query returns a query builder for Mod. +func (c *ModClient) Query() *ModQuery { + return &ModQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeMod}, + inters: c.Interceptors(), + } +} + +// Get returns a Mod entity by its id. +func (c *ModClient) Get(ctx context.Context, id string) (*Mod, error) { + return c.Query().Where(mod.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ModClient) GetX(ctx context.Context, id string) *Mod { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryVersions queries the versions edge of a Mod. +func (c *ModClient) QueryVersions(m *Mod) *VersionQuery { + query := (&VersionClient{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(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, mod.VersionsTable, mod.VersionsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAuthors queries the authors edge of a Mod. +func (c *ModClient) QueryAuthors(m *Mod) *UserQuery { + query := (&UserClient{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(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.AuthorsTable, mod.AuthorsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTags queries the tags edge of a Mod. +func (c *ModClient) QueryTags(m *Mod) *TagQuery { + query := (&TagClient{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(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, mod.TagsTable, mod.TagsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryDependents queries the dependents edge of a Mod. +func (c *ModClient) QueryDependents(m *Mod) *VersionQuery { + query := (&VersionClient{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(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.DependentsTable, mod.DependentsPrimaryKey...), + ) + 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() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := m.ID + step := sqlgraph.NewStep( + sqlgraph.From(mod.Table, mod.FieldID, id), + sqlgraph.To(usermod.Table, usermod.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.UserModsTable, mod.UserModsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryModTags queries the mod_tags edge of a Mod. +func (c *ModClient) QueryModTags(m *Mod) *ModTagQuery { + query := (&ModTagClient{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(modtag.Table, modtag.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.ModTagsTable, mod.ModTagsColumn), + ) + fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryVersionDependencies queries the version_dependencies edge of a Mod. +func (c *ModClient) QueryVersionDependencies(m *Mod) *VersionDependencyQuery { + query := (&VersionDependencyClient{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(versiondependency.Table, versiondependency.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.VersionDependenciesTable, mod.VersionDependenciesColumn), + ) + 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 + return append(hooks[:len(hooks):len(hooks)], mod.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *ModClient) Interceptors() []Interceptor { + inters := c.inters.Mod + return append(inters[:len(inters):len(inters)], mod.Interceptors[:]...) +} + +func (c *ModClient) mutate(ctx context.Context, m *ModMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Mod mutation op: %q", m.Op()) + } +} + +// ModTagClient is a client for the ModTag schema. +type ModTagClient struct { + config +} + +// NewModTagClient returns a client for the ModTag from the given config. +func NewModTagClient(c config) *ModTagClient { + return &ModTagClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `modtag.Hooks(f(g(h())))`. +func (c *ModTagClient) Use(hooks ...Hook) { + c.hooks.ModTag = append(c.hooks.ModTag, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `modtag.Intercept(f(g(h())))`. +func (c *ModTagClient) Intercept(interceptors ...Interceptor) { + c.inters.ModTag = append(c.inters.ModTag, interceptors...) +} + +// Create returns a builder for creating a ModTag entity. +func (c *ModTagClient) Create() *ModTagCreate { + mutation := newModTagMutation(c.config, OpCreate) + return &ModTagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ModTag entities. +func (c *ModTagClient) CreateBulk(builders ...*ModTagCreate) *ModTagCreateBulk { + return &ModTagCreateBulk{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 *ModTagClient) MapCreateBulk(slice any, setFunc func(*ModTagCreate, int)) *ModTagCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ModTagCreateBulk{err: fmt.Errorf("calling to ModTagClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ModTagCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ModTagCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ModTag. +func (c *ModTagClient) Update() *ModTagUpdate { + mutation := newModTagMutation(c.config, OpUpdate) + return &ModTagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ModTagClient) UpdateOne(mt *ModTag) *ModTagUpdateOne { + mutation := newModTagMutation(c.config, OpUpdateOne) + mutation.mod = &mt.ModID + mutation.tag = &mt.TagID + return &ModTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ModTag. +func (c *ModTagClient) Delete() *ModTagDelete { + mutation := newModTagMutation(c.config, OpDelete) + return &ModTagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for ModTag. +func (c *ModTagClient) Query() *ModTagQuery { + return &ModTagQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeModTag}, + inters: c.Interceptors(), + } +} + +// QueryMod queries the mod edge of a ModTag. +func (c *ModTagClient) QueryMod(mt *ModTag) *ModQuery { + return c.Query(). + Where(modtag.ModID(mt.ModID), modtag.TagID(mt.TagID)). + QueryMod() +} + +// QueryTag queries the tag edge of a ModTag. +func (c *ModTagClient) QueryTag(mt *ModTag) *TagQuery { + return c.Query(). + Where(modtag.ModID(mt.ModID), modtag.TagID(mt.TagID)). + QueryTag() +} + +// Hooks returns the client hooks. +func (c *ModTagClient) Hooks() []Hook { + return c.hooks.ModTag +} + +// Interceptors returns the client interceptors. +func (c *ModTagClient) Interceptors() []Interceptor { + return c.inters.ModTag +} + +func (c *ModTagClient) mutate(ctx context.Context, m *ModTagMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ModTagCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ModTagUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ModTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ModTagDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ModTag mutation op: %q", m.Op()) + } +} + +// SmlVersionClient is a client for the SmlVersion schema. +type SmlVersionClient struct { + config +} + +// NewSmlVersionClient returns a client for the SmlVersion from the given config. +func NewSmlVersionClient(c config) *SmlVersionClient { + return &SmlVersionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `smlversion.Hooks(f(g(h())))`. +func (c *SmlVersionClient) Use(hooks ...Hook) { + c.hooks.SmlVersion = append(c.hooks.SmlVersion, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `smlversion.Intercept(f(g(h())))`. +func (c *SmlVersionClient) Intercept(interceptors ...Interceptor) { + c.inters.SmlVersion = append(c.inters.SmlVersion, interceptors...) +} + +// Create returns a builder for creating a SmlVersion entity. +func (c *SmlVersionClient) Create() *SmlVersionCreate { + mutation := newSmlVersionMutation(c.config, OpCreate) + return &SmlVersionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of SmlVersion entities. +func (c *SmlVersionClient) CreateBulk(builders ...*SmlVersionCreate) *SmlVersionCreateBulk { + return &SmlVersionCreateBulk{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 *SmlVersionClient) MapCreateBulk(slice any, setFunc func(*SmlVersionCreate, int)) *SmlVersionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SmlVersionCreateBulk{err: fmt.Errorf("calling to SmlVersionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SmlVersionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SmlVersionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for SmlVersion. +func (c *SmlVersionClient) Update() *SmlVersionUpdate { + mutation := newSmlVersionMutation(c.config, OpUpdate) + return &SmlVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SmlVersionClient) UpdateOne(sv *SmlVersion) *SmlVersionUpdateOne { + mutation := newSmlVersionMutation(c.config, OpUpdateOne, withSmlVersion(sv)) + return &SmlVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SmlVersionClient) UpdateOneID(id string) *SmlVersionUpdateOne { + mutation := newSmlVersionMutation(c.config, OpUpdateOne, withSmlVersionID(id)) + return &SmlVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for SmlVersion. +func (c *SmlVersionClient) Delete() *SmlVersionDelete { + mutation := newSmlVersionMutation(c.config, OpDelete) + return &SmlVersionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SmlVersionClient) DeleteOne(sv *SmlVersion) *SmlVersionDeleteOne { + return c.DeleteOneID(sv.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *SmlVersionClient) DeleteOneID(id string) *SmlVersionDeleteOne { + builder := c.Delete().Where(smlversion.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SmlVersionDeleteOne{builder} +} + +// Query returns a query builder for SmlVersion. +func (c *SmlVersionClient) Query() *SmlVersionQuery { + return &SmlVersionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeSmlVersion}, + inters: c.Interceptors(), + } +} + +// Get returns a SmlVersion entity by its id. +func (c *SmlVersionClient) Get(ctx context.Context, id string) (*SmlVersion, error) { + return c.Query().Where(smlversion.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SmlVersionClient) GetX(ctx context.Context, id string) *SmlVersion { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryTargets queries the targets edge of a SmlVersion. +func (c *SmlVersionClient) QueryTargets(sv *SmlVersion) *SmlVersionTargetQuery { + query := (&SmlVersionTargetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := sv.ID + step := sqlgraph.NewStep( + sqlgraph.From(smlversion.Table, smlversion.FieldID, id), + sqlgraph.To(smlversiontarget.Table, smlversiontarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, smlversion.TargetsTable, smlversion.TargetsColumn), + ) + fromV = sqlgraph.Neighbors(sv.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *SmlVersionClient) Hooks() []Hook { + hooks := c.hooks.SmlVersion + return append(hooks[:len(hooks):len(hooks)], smlversion.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *SmlVersionClient) Interceptors() []Interceptor { + inters := c.inters.SmlVersion + return append(inters[:len(inters):len(inters)], smlversion.Interceptors[:]...) +} + +func (c *SmlVersionClient) mutate(ctx context.Context, m *SmlVersionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&SmlVersionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&SmlVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&SmlVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&SmlVersionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown SmlVersion mutation op: %q", m.Op()) + } +} + +// SmlVersionTargetClient is a client for the SmlVersionTarget schema. +type SmlVersionTargetClient struct { + config +} + +// NewSmlVersionTargetClient returns a client for the SmlVersionTarget from the given config. +func NewSmlVersionTargetClient(c config) *SmlVersionTargetClient { + return &SmlVersionTargetClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `smlversiontarget.Hooks(f(g(h())))`. +func (c *SmlVersionTargetClient) Use(hooks ...Hook) { + c.hooks.SmlVersionTarget = append(c.hooks.SmlVersionTarget, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `smlversiontarget.Intercept(f(g(h())))`. +func (c *SmlVersionTargetClient) Intercept(interceptors ...Interceptor) { + c.inters.SmlVersionTarget = append(c.inters.SmlVersionTarget, interceptors...) +} + +// Create returns a builder for creating a SmlVersionTarget entity. +func (c *SmlVersionTargetClient) Create() *SmlVersionTargetCreate { + mutation := newSmlVersionTargetMutation(c.config, OpCreate) + return &SmlVersionTargetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of SmlVersionTarget entities. +func (c *SmlVersionTargetClient) CreateBulk(builders ...*SmlVersionTargetCreate) *SmlVersionTargetCreateBulk { + return &SmlVersionTargetCreateBulk{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 *SmlVersionTargetClient) MapCreateBulk(slice any, setFunc func(*SmlVersionTargetCreate, int)) *SmlVersionTargetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SmlVersionTargetCreateBulk{err: fmt.Errorf("calling to SmlVersionTargetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SmlVersionTargetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SmlVersionTargetCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for SmlVersionTarget. +func (c *SmlVersionTargetClient) Update() *SmlVersionTargetUpdate { + mutation := newSmlVersionTargetMutation(c.config, OpUpdate) + return &SmlVersionTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SmlVersionTargetClient) UpdateOne(svt *SmlVersionTarget) *SmlVersionTargetUpdateOne { + mutation := newSmlVersionTargetMutation(c.config, OpUpdateOne, withSmlVersionTarget(svt)) + return &SmlVersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SmlVersionTargetClient) UpdateOneID(id string) *SmlVersionTargetUpdateOne { + mutation := newSmlVersionTargetMutation(c.config, OpUpdateOne, withSmlVersionTargetID(id)) + return &SmlVersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for SmlVersionTarget. +func (c *SmlVersionTargetClient) Delete() *SmlVersionTargetDelete { + mutation := newSmlVersionTargetMutation(c.config, OpDelete) + return &SmlVersionTargetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SmlVersionTargetClient) DeleteOne(svt *SmlVersionTarget) *SmlVersionTargetDeleteOne { + return c.DeleteOneID(svt.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *SmlVersionTargetClient) DeleteOneID(id string) *SmlVersionTargetDeleteOne { + builder := c.Delete().Where(smlversiontarget.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SmlVersionTargetDeleteOne{builder} +} + +// Query returns a query builder for SmlVersionTarget. +func (c *SmlVersionTargetClient) Query() *SmlVersionTargetQuery { + return &SmlVersionTargetQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeSmlVersionTarget}, + inters: c.Interceptors(), + } +} + +// Get returns a SmlVersionTarget entity by its id. +func (c *SmlVersionTargetClient) Get(ctx context.Context, id string) (*SmlVersionTarget, error) { + return c.Query().Where(smlversiontarget.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SmlVersionTargetClient) GetX(ctx context.Context, id string) *SmlVersionTarget { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySmlVersion queries the sml_version edge of a SmlVersionTarget. +func (c *SmlVersionTargetClient) QuerySmlVersion(svt *SmlVersionTarget) *SmlVersionQuery { + query := (&SmlVersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := svt.ID + step := sqlgraph.NewStep( + sqlgraph.From(smlversiontarget.Table, smlversiontarget.FieldID, id), + sqlgraph.To(smlversion.Table, smlversion.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, smlversiontarget.SmlVersionTable, smlversiontarget.SmlVersionColumn), + ) + fromV = sqlgraph.Neighbors(svt.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *SmlVersionTargetClient) Hooks() []Hook { + return c.hooks.SmlVersionTarget +} + +// Interceptors returns the client interceptors. +func (c *SmlVersionTargetClient) Interceptors() []Interceptor { + return c.inters.SmlVersionTarget +} + +func (c *SmlVersionTargetClient) mutate(ctx context.Context, m *SmlVersionTargetMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&SmlVersionTargetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&SmlVersionTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&SmlVersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&SmlVersionTargetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown SmlVersionTarget mutation op: %q", m.Op()) + } +} + +// TagClient is a client for the Tag schema. +type TagClient struct { + config +} + +// NewTagClient returns a client for the Tag from the given config. +func NewTagClient(c config) *TagClient { + return &TagClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `tag.Hooks(f(g(h())))`. +func (c *TagClient) Use(hooks ...Hook) { + c.hooks.Tag = append(c.hooks.Tag, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `tag.Intercept(f(g(h())))`. +func (c *TagClient) Intercept(interceptors ...Interceptor) { + c.inters.Tag = append(c.inters.Tag, interceptors...) +} + +// Create returns a builder for creating a Tag entity. +func (c *TagClient) Create() *TagCreate { + mutation := newTagMutation(c.config, OpCreate) + return &TagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Tag entities. +func (c *TagClient) CreateBulk(builders ...*TagCreate) *TagCreateBulk { + return &TagCreateBulk{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 *TagClient) MapCreateBulk(slice any, setFunc func(*TagCreate, int)) *TagCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TagCreateBulk{err: fmt.Errorf("calling to TagClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TagCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TagCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Tag. +func (c *TagClient) Update() *TagUpdate { + mutation := newTagMutation(c.config, OpUpdate) + return &TagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *TagClient) UpdateOne(t *Tag) *TagUpdateOne { + mutation := newTagMutation(c.config, OpUpdateOne, withTag(t)) + return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *TagClient) UpdateOneID(id string) *TagUpdateOne { + mutation := newTagMutation(c.config, OpUpdateOne, withTagID(id)) + return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Tag. +func (c *TagClient) Delete() *TagDelete { + mutation := newTagMutation(c.config, OpDelete) + return &TagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *TagClient) DeleteOne(t *Tag) *TagDeleteOne { + return c.DeleteOneID(t.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *TagClient) DeleteOneID(id string) *TagDeleteOne { + builder := c.Delete().Where(tag.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &TagDeleteOne{builder} +} + +// Query returns a query builder for Tag. +func (c *TagClient) Query() *TagQuery { + return &TagQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeTag}, + inters: c.Interceptors(), + } +} + +// Get returns a Tag entity by its id. +func (c *TagClient) Get(ctx context.Context, id string) (*Tag, error) { + return c.Query().Where(tag.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *TagClient) GetX(ctx context.Context, id string) *Tag { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryMods queries the mods edge of a Tag. +func (c *TagClient) QueryMods(t *Tag) *ModQuery { + query := (&ModClient{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(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.ModsTable, tag.ModsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryGuides queries the guides edge of a Tag. +func (c *TagClient) QueryGuides(t *Tag) *GuideQuery { + query := (&GuideClient{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(guide.Table, guide.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.GuidesTable, tag.GuidesPrimaryKey...), + ) + 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() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tag.Table, tag.FieldID, id), + sqlgraph.To(modtag.Table, modtag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.ModTagsTable, tag.ModTagsColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryGuideTags queries the guide_tags edge of a Tag. +func (c *TagClient) QueryGuideTags(t *Tag) *GuideTagQuery { + query := (&GuideTagClient{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(guidetag.Table, guidetag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.GuideTagsTable, tag.GuideTagsColumn), + ) + 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 + return append(hooks[:len(hooks):len(hooks)], tag.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *TagClient) Interceptors() []Interceptor { + inters := c.inters.Tag + return append(inters[:len(inters):len(inters)], tag.Interceptors[:]...) +} + +func (c *TagClient) mutate(ctx context.Context, m *TagMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&TagCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&TagUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&TagDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Tag mutation op: %q", m.Op()) + } +} + +// UserClient is a client for the User schema. +type UserClient struct { + config +} + +// NewUserClient returns a client for the User from the given config. +func NewUserClient(c config) *UserClient { + return &UserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. +func (c *UserClient) Use(hooks ...Hook) { + c.hooks.User = append(c.hooks.User, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. +func (c *UserClient) Intercept(interceptors ...Interceptor) { + c.inters.User = append(c.inters.User, interceptors...) +} + +// Create returns a builder for creating a User entity. +func (c *UserClient) Create() *UserCreate { + mutation := newUserMutation(c.config, OpCreate) + return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of User entities. +func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { + return &UserCreateBulk{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 *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for User. +func (c *UserClient) Update() *UserUpdate { + mutation := newUserMutation(c.config, OpUpdate) + return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserClient) UpdateOne(u *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserClient) UpdateOneID(id string) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for User. +func (c *UserClient) Delete() *UserDelete { + mutation := newUserMutation(c.config, OpDelete) + return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserClient) DeleteOne(u *User) *UserDeleteOne { + return c.DeleteOneID(u.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserClient) DeleteOneID(id string) *UserDeleteOne { + builder := c.Delete().Where(user.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserDeleteOne{builder} +} + +// Query returns a query builder for User. +func (c *UserClient) Query() *UserQuery { + return &UserQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUser}, + inters: c.Interceptors(), + } +} + +// Get returns a User entity by its id. +func (c *UserClient) Get(ctx context.Context, id string) (*User, error) { + return c.Query().Where(user.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserClient) GetX(ctx context.Context, id string) *User { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryGuides queries the guides edge of a User. +func (c *UserClient) QueryGuides(u *User) *GuideQuery { + query := (&GuideClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(guide.Table, guide.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.GuidesTable, user.GuidesColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QuerySessions queries the sessions edge of a User. +func (c *UserClient) QuerySessions(u *User) *UserSessionQuery { + query := (&UserSessionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(usersession.Table, usersession.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.SessionsTable, user.SessionsColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryMods queries the mods edge of a User. +func (c *UserClient) QueryMods(u *User) *ModQuery { + query := (&ModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, user.ModsTable, user.ModsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryGroups queries the groups edge of a User. +func (c *UserClient) QueryGroups(u *User) *UserGroupQuery { + query := (&UserGroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(usergroup.Table, usergroup.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.GroupsTable, user.GroupsColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryUserMods queries the user_mods edge of a User. +func (c *UserClient) QueryUserMods(u *User) *UserModQuery { + query := (&UserModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(usermod.Table, usermod.UserColumn), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserModsTable, user.UserModsColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserClient) Hooks() []Hook { + hooks := c.hooks.User + return append(hooks[:len(hooks):len(hooks)], user.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *UserClient) Interceptors() []Interceptor { + inters := c.inters.User + return append(inters[:len(inters):len(inters)], user.Interceptors[:]...) +} + +func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) + } +} + +// UserGroupClient is a client for the UserGroup schema. +type UserGroupClient struct { + config +} + +// NewUserGroupClient returns a client for the UserGroup from the given config. +func NewUserGroupClient(c config) *UserGroupClient { + return &UserGroupClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `usergroup.Hooks(f(g(h())))`. +func (c *UserGroupClient) Use(hooks ...Hook) { + c.hooks.UserGroup = append(c.hooks.UserGroup, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `usergroup.Intercept(f(g(h())))`. +func (c *UserGroupClient) Intercept(interceptors ...Interceptor) { + c.inters.UserGroup = append(c.inters.UserGroup, interceptors...) +} + +// Create returns a builder for creating a UserGroup entity. +func (c *UserGroupClient) Create() *UserGroupCreate { + mutation := newUserGroupMutation(c.config, OpCreate) + return &UserGroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserGroup entities. +func (c *UserGroupClient) CreateBulk(builders ...*UserGroupCreate) *UserGroupCreateBulk { + return &UserGroupCreateBulk{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 *UserGroupClient) MapCreateBulk(slice any, setFunc func(*UserGroupCreate, int)) *UserGroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserGroupCreateBulk{err: fmt.Errorf("calling to UserGroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserGroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserGroupCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserGroup. +func (c *UserGroupClient) Update() *UserGroupUpdate { + mutation := newUserGroupMutation(c.config, OpUpdate) + return &UserGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserGroupClient) UpdateOne(ug *UserGroup) *UserGroupUpdateOne { + mutation := newUserGroupMutation(c.config, OpUpdateOne, withUserGroup(ug)) + return &UserGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserGroupClient) UpdateOneID(id string) *UserGroupUpdateOne { + mutation := newUserGroupMutation(c.config, OpUpdateOne, withUserGroupID(id)) + return &UserGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserGroup. +func (c *UserGroupClient) Delete() *UserGroupDelete { + mutation := newUserGroupMutation(c.config, OpDelete) + return &UserGroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserGroupClient) DeleteOne(ug *UserGroup) *UserGroupDeleteOne { + return c.DeleteOneID(ug.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserGroupClient) DeleteOneID(id string) *UserGroupDeleteOne { + builder := c.Delete().Where(usergroup.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserGroupDeleteOne{builder} +} + +// Query returns a query builder for UserGroup. +func (c *UserGroupClient) Query() *UserGroupQuery { + return &UserGroupQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserGroup}, + inters: c.Interceptors(), + } +} + +// Get returns a UserGroup entity by its id. +func (c *UserGroupClient) Get(ctx context.Context, id string) (*UserGroup, error) { + return c.Query().Where(usergroup.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserGroupClient) GetX(ctx context.Context, id string) *UserGroup { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a UserGroup. +func (c *UserGroupClient) QueryUser(ug *UserGroup) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := ug.ID + step := sqlgraph.NewStep( + sqlgraph.From(usergroup.Table, usergroup.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, usergroup.UserTable, usergroup.UserColumn), + ) + fromV = sqlgraph.Neighbors(ug.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserGroupClient) Hooks() []Hook { + hooks := c.hooks.UserGroup + return append(hooks[:len(hooks):len(hooks)], usergroup.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *UserGroupClient) Interceptors() []Interceptor { + inters := c.inters.UserGroup + return append(inters[:len(inters):len(inters)], usergroup.Interceptors[:]...) +} + +func (c *UserGroupClient) mutate(ctx context.Context, m *UserGroupMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserGroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserGroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserGroup mutation op: %q", m.Op()) + } +} + +// UserModClient is a client for the UserMod schema. +type UserModClient struct { + config +} + +// NewUserModClient returns a client for the UserMod from the given config. +func NewUserModClient(c config) *UserModClient { + return &UserModClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `usermod.Hooks(f(g(h())))`. +func (c *UserModClient) Use(hooks ...Hook) { + c.hooks.UserMod = append(c.hooks.UserMod, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `usermod.Intercept(f(g(h())))`. +func (c *UserModClient) Intercept(interceptors ...Interceptor) { + c.inters.UserMod = append(c.inters.UserMod, interceptors...) +} + +// Create returns a builder for creating a UserMod entity. +func (c *UserModClient) Create() *UserModCreate { + mutation := newUserModMutation(c.config, OpCreate) + return &UserModCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserMod entities. +func (c *UserModClient) CreateBulk(builders ...*UserModCreate) *UserModCreateBulk { + return &UserModCreateBulk{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 *UserModClient) MapCreateBulk(slice any, setFunc func(*UserModCreate, int)) *UserModCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserModCreateBulk{err: fmt.Errorf("calling to UserModClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserModCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserModCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserMod. +func (c *UserModClient) Update() *UserModUpdate { + mutation := newUserModMutation(c.config, OpUpdate) + return &UserModUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserModClient) UpdateOne(um *UserMod) *UserModUpdateOne { + mutation := newUserModMutation(c.config, OpUpdateOne) + mutation.user = &um.UserID + mutation.mod = &um.ModID + return &UserModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserMod. +func (c *UserModClient) Delete() *UserModDelete { + mutation := newUserModMutation(c.config, OpDelete) + return &UserModDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for UserMod. +func (c *UserModClient) Query() *UserModQuery { + return &UserModQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserMod}, + inters: c.Interceptors(), + } +} + +// QueryUser queries the user edge of a UserMod. +func (c *UserModClient) QueryUser(um *UserMod) *UserQuery { + return c.Query(). + Where(usermod.UserID(um.UserID), usermod.ModID(um.ModID)). + QueryUser() +} + +// QueryMod queries the mod edge of a UserMod. +func (c *UserModClient) QueryMod(um *UserMod) *ModQuery { + return c.Query(). + Where(usermod.UserID(um.UserID), usermod.ModID(um.ModID)). + QueryMod() +} + +// Hooks returns the client hooks. +func (c *UserModClient) Hooks() []Hook { + return c.hooks.UserMod +} + +// Interceptors returns the client interceptors. +func (c *UserModClient) Interceptors() []Interceptor { + return c.inters.UserMod +} + +func (c *UserModClient) mutate(ctx context.Context, m *UserModMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserModCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserModUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserModUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserModDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserMod mutation op: %q", m.Op()) + } +} + +// UserSessionClient is a client for the UserSession schema. +type UserSessionClient struct { + config +} + +// NewUserSessionClient returns a client for the UserSession from the given config. +func NewUserSessionClient(c config) *UserSessionClient { + return &UserSessionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `usersession.Hooks(f(g(h())))`. +func (c *UserSessionClient) Use(hooks ...Hook) { + c.hooks.UserSession = append(c.hooks.UserSession, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `usersession.Intercept(f(g(h())))`. +func (c *UserSessionClient) Intercept(interceptors ...Interceptor) { + c.inters.UserSession = append(c.inters.UserSession, interceptors...) +} + +// Create returns a builder for creating a UserSession entity. +func (c *UserSessionClient) Create() *UserSessionCreate { + mutation := newUserSessionMutation(c.config, OpCreate) + return &UserSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserSession entities. +func (c *UserSessionClient) CreateBulk(builders ...*UserSessionCreate) *UserSessionCreateBulk { + return &UserSessionCreateBulk{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 *UserSessionClient) MapCreateBulk(slice any, setFunc func(*UserSessionCreate, int)) *UserSessionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserSessionCreateBulk{err: fmt.Errorf("calling to UserSessionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserSessionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserSessionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserSession. +func (c *UserSessionClient) Update() *UserSessionUpdate { + mutation := newUserSessionMutation(c.config, OpUpdate) + return &UserSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserSessionClient) UpdateOne(us *UserSession) *UserSessionUpdateOne { + mutation := newUserSessionMutation(c.config, OpUpdateOne, withUserSession(us)) + return &UserSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserSessionClient) UpdateOneID(id string) *UserSessionUpdateOne { + mutation := newUserSessionMutation(c.config, OpUpdateOne, withUserSessionID(id)) + return &UserSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserSession. +func (c *UserSessionClient) Delete() *UserSessionDelete { + mutation := newUserSessionMutation(c.config, OpDelete) + return &UserSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserSessionClient) DeleteOne(us *UserSession) *UserSessionDeleteOne { + return c.DeleteOneID(us.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserSessionClient) DeleteOneID(id string) *UserSessionDeleteOne { + builder := c.Delete().Where(usersession.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserSessionDeleteOne{builder} +} + +// Query returns a query builder for UserSession. +func (c *UserSessionClient) Query() *UserSessionQuery { + return &UserSessionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserSession}, + inters: c.Interceptors(), + } +} + +// Get returns a UserSession entity by its id. +func (c *UserSessionClient) Get(ctx context.Context, id string) (*UserSession, error) { + return c.Query().Where(usersession.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserSessionClient) GetX(ctx context.Context, id string) *UserSession { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a UserSession. +func (c *UserSessionClient) QueryUser(us *UserSession) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := us.ID + step := sqlgraph.NewStep( + sqlgraph.From(usersession.Table, usersession.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, usersession.UserTable, usersession.UserColumn), + ) + fromV = sqlgraph.Neighbors(us.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserSessionClient) Hooks() []Hook { + hooks := c.hooks.UserSession + return append(hooks[:len(hooks):len(hooks)], usersession.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *UserSessionClient) Interceptors() []Interceptor { + inters := c.inters.UserSession + return append(inters[:len(inters):len(inters)], usersession.Interceptors[:]...) +} + +func (c *UserSessionClient) mutate(ctx context.Context, m *UserSessionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserSession mutation op: %q", m.Op()) + } +} + +// VersionClient is a client for the Version schema. +type VersionClient struct { + config +} + +// NewVersionClient returns a client for the Version from the given config. +func NewVersionClient(c config) *VersionClient { + return &VersionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `version.Hooks(f(g(h())))`. +func (c *VersionClient) Use(hooks ...Hook) { + c.hooks.Version = append(c.hooks.Version, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `version.Intercept(f(g(h())))`. +func (c *VersionClient) Intercept(interceptors ...Interceptor) { + c.inters.Version = append(c.inters.Version, interceptors...) +} + +// Create returns a builder for creating a Version entity. +func (c *VersionClient) Create() *VersionCreate { + mutation := newVersionMutation(c.config, OpCreate) + return &VersionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Version entities. +func (c *VersionClient) CreateBulk(builders ...*VersionCreate) *VersionCreateBulk { + return &VersionCreateBulk{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 *VersionClient) MapCreateBulk(slice any, setFunc func(*VersionCreate, int)) *VersionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VersionCreateBulk{err: fmt.Errorf("calling to VersionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VersionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VersionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Version. +func (c *VersionClient) Update() *VersionUpdate { + mutation := newVersionMutation(c.config, OpUpdate) + return &VersionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *VersionClient) UpdateOne(v *Version) *VersionUpdateOne { + mutation := newVersionMutation(c.config, OpUpdateOne, withVersion(v)) + return &VersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *VersionClient) UpdateOneID(id string) *VersionUpdateOne { + mutation := newVersionMutation(c.config, OpUpdateOne, withVersionID(id)) + return &VersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Version. +func (c *VersionClient) Delete() *VersionDelete { + mutation := newVersionMutation(c.config, OpDelete) + return &VersionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *VersionClient) DeleteOne(v *Version) *VersionDeleteOne { + return c.DeleteOneID(v.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *VersionClient) DeleteOneID(id string) *VersionDeleteOne { + builder := c.Delete().Where(version.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &VersionDeleteOne{builder} +} + +// Query returns a query builder for Version. +func (c *VersionClient) Query() *VersionQuery { + return &VersionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeVersion}, + inters: c.Interceptors(), + } +} + +// Get returns a Version entity by its id. +func (c *VersionClient) Get(ctx context.Context, id string) (*Version, error) { + return c.Query().Where(version.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *VersionClient) GetX(ctx context.Context, id string) *Version { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryMod queries the mod edge of a Version. +func (c *VersionClient) QueryMod(v *Version) *ModQuery { + query := (&ModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := v.ID + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, id), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, version.ModTable, version.ModColumn), + ) + fromV = sqlgraph.Neighbors(v.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryDependencies queries the dependencies edge of a Version. +func (c *VersionClient) QueryDependencies(v *Version) *ModQuery { + query := (&ModClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := v.ID + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, id), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, version.DependenciesTable, version.DependenciesPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(v.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryVersionDependencies queries the version_dependencies edge of a Version. +func (c *VersionClient) QueryVersionDependencies(v *Version) *VersionDependencyQuery { + query := (&VersionDependencyClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := v.ID + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, id), + sqlgraph.To(versiondependency.Table, versiondependency.VersionColumn), + sqlgraph.Edge(sqlgraph.O2M, true, version.VersionDependenciesTable, version.VersionDependenciesColumn), + ) + fromV = sqlgraph.Neighbors(v.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *VersionClient) Hooks() []Hook { + hooks := c.hooks.Version + return append(hooks[:len(hooks):len(hooks)], version.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *VersionClient) Interceptors() []Interceptor { + inters := c.inters.Version + return append(inters[:len(inters):len(inters)], version.Interceptors[:]...) +} + +func (c *VersionClient) mutate(ctx context.Context, m *VersionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&VersionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&VersionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&VersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&VersionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Version mutation op: %q", m.Op()) + } +} + +// VersionDependencyClient is a client for the VersionDependency schema. +type VersionDependencyClient struct { + config +} + +// NewVersionDependencyClient returns a client for the VersionDependency from the given config. +func NewVersionDependencyClient(c config) *VersionDependencyClient { + return &VersionDependencyClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `versiondependency.Hooks(f(g(h())))`. +func (c *VersionDependencyClient) Use(hooks ...Hook) { + c.hooks.VersionDependency = append(c.hooks.VersionDependency, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `versiondependency.Intercept(f(g(h())))`. +func (c *VersionDependencyClient) Intercept(interceptors ...Interceptor) { + c.inters.VersionDependency = append(c.inters.VersionDependency, interceptors...) +} + +// Create returns a builder for creating a VersionDependency entity. +func (c *VersionDependencyClient) Create() *VersionDependencyCreate { + mutation := newVersionDependencyMutation(c.config, OpCreate) + return &VersionDependencyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of VersionDependency entities. +func (c *VersionDependencyClient) CreateBulk(builders ...*VersionDependencyCreate) *VersionDependencyCreateBulk { + return &VersionDependencyCreateBulk{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 *VersionDependencyClient) MapCreateBulk(slice any, setFunc func(*VersionDependencyCreate, int)) *VersionDependencyCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VersionDependencyCreateBulk{err: fmt.Errorf("calling to VersionDependencyClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VersionDependencyCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VersionDependencyCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for VersionDependency. +func (c *VersionDependencyClient) Update() *VersionDependencyUpdate { + mutation := newVersionDependencyMutation(c.config, OpUpdate) + return &VersionDependencyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *VersionDependencyClient) UpdateOne(vd *VersionDependency) *VersionDependencyUpdateOne { + mutation := newVersionDependencyMutation(c.config, OpUpdateOne) + mutation.version = &vd.VersionID + mutation.mod = &vd.ModID + return &VersionDependencyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for VersionDependency. +func (c *VersionDependencyClient) Delete() *VersionDependencyDelete { + mutation := newVersionDependencyMutation(c.config, OpDelete) + return &VersionDependencyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Query returns a query builder for VersionDependency. +func (c *VersionDependencyClient) Query() *VersionDependencyQuery { + return &VersionDependencyQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeVersionDependency}, + inters: c.Interceptors(), + } +} + +// QueryVersion queries the version edge of a VersionDependency. +func (c *VersionDependencyClient) QueryVersion(vd *VersionDependency) *VersionQuery { + return c.Query(). + Where(versiondependency.VersionID(vd.VersionID), versiondependency.ModID(vd.ModID)). + QueryVersion() +} + +// QueryMod queries the mod edge of a VersionDependency. +func (c *VersionDependencyClient) QueryMod(vd *VersionDependency) *ModQuery { + return c.Query(). + Where(versiondependency.VersionID(vd.VersionID), versiondependency.ModID(vd.ModID)). + QueryMod() +} + +// Hooks returns the client hooks. +func (c *VersionDependencyClient) Hooks() []Hook { + hooks := c.hooks.VersionDependency + return append(hooks[:len(hooks):len(hooks)], versiondependency.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *VersionDependencyClient) Interceptors() []Interceptor { + inters := c.inters.VersionDependency + return append(inters[:len(inters):len(inters)], versiondependency.Interceptors[:]...) +} + +func (c *VersionDependencyClient) mutate(ctx context.Context, m *VersionDependencyMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&VersionDependencyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&VersionDependencyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&VersionDependencyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&VersionDependencyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown VersionDependency mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + Announcement, Guide, GuideTag, Mod, ModTag, SmlVersion, SmlVersionTarget, Tag, + User, UserGroup, UserMod, UserSession, Version, VersionDependency []ent.Hook + } + inters struct { + Announcement, Guide, GuideTag, Mod, ModTag, SmlVersion, SmlVersionTarget, Tag, + User, UserGroup, UserMod, UserSession, Version, + VersionDependency []ent.Interceptor + } +) + +// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. +// See, database/sql#DB.ExecContext for more information. +func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := c.driver.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. +// See, database/sql#DB.QueryContext for more information. +func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := c.driver.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/generated/ent/ent.go b/generated/ent/ent.go new file mode 100644 index 00000000..24011c05 --- /dev/null +++ b/generated/ent/ent.go @@ -0,0 +1,634 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// columnChecker checks if the column exists in the given table. +func checkColumn(table, column string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + announcement.Table: announcement.ValidColumn, + guide.Table: guide.ValidColumn, + guidetag.Table: guidetag.ValidColumn, + mod.Table: mod.ValidColumn, + modtag.Table: modtag.ValidColumn, + smlversion.Table: smlversion.ValidColumn, + smlversiontarget.Table: smlversiontarget.ValidColumn, + tag.Table: tag.ValidColumn, + user.Table: user.ValidColumn, + usergroup.Table: usergroup.ValidColumn, + usermod.Table: usermod.ValidColumn, + usersession.Table: usersession.ValidColumn, + version.Table: version.ValidColumn, + versiondependency.Table: versiondependency.ValidColumn, + }) + }) + return columnCheck(table, column) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/generated/ent/enttest/enttest.go b/generated/ent/enttest/enttest.go new file mode 100644 index 00000000..7b2462e1 --- /dev/null +++ b/generated/ent/enttest/enttest.go @@ -0,0 +1,84 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "github.com/satisfactorymodding/smr-api/generated/ent" + // required by schema hooks. + _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" + + "entgo.io/ent/dialect/sql/schema" + "github.com/satisfactorymodding/smr-api/generated/ent/migrate" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/generated/ent/guide.go b/generated/ent/guide.go new file mode 100644 index 00000000..6ae19858 --- /dev/null +++ b/generated/ent/guide.go @@ -0,0 +1,245 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/user" +) + +// Guide is the model entity for the Guide schema. +type Guide 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_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"` + // Guide holds the value of the "guide" field. + Guide string `json:"guide,omitempty"` + // Views holds the value of the "views" field. + Views int `json:"views,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the GuideQuery when eager-loading is set. + Edges GuideEdges `json:"edges"` + user_id *string + selectValues sql.SelectValues +} + +// GuideEdges holds the relations/edges for other nodes in the graph. +type GuideEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // Tags holds the value of the tags edge. + Tags []*Tag `json:"tags,omitempty"` + // GuideTags holds the value of the guide_tags edge. + GuideTags []*GuideTag `json:"guide_tags,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [3]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e GuideEdges) UserOrErr() (*User, error) { + if e.loadedTypes[0] { + if e.User == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.User, nil + } + return nil, &NotLoadedError{edge: "user"} +} + +// TagsOrErr returns the Tags value or an error if the edge +// was not loaded in eager-loading. +func (e GuideEdges) TagsOrErr() ([]*Tag, error) { + if e.loadedTypes[1] { + return e.Tags, nil + } + return nil, &NotLoadedError{edge: "tags"} +} + +// GuideTagsOrErr returns the GuideTags value or an error if the edge +// was not loaded in eager-loading. +func (e GuideEdges) GuideTagsOrErr() ([]*GuideTag, error) { + if e.loadedTypes[2] { + return e.GuideTags, nil + } + return nil, &NotLoadedError{edge: "guide_tags"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Guide) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case guide.FieldViews: + values[i] = new(sql.NullInt64) + case guide.FieldID, guide.FieldName, guide.FieldShortDescription, guide.FieldGuide: + values[i] = new(sql.NullString) + case guide.FieldCreatedAt, guide.FieldUpdatedAt, guide.FieldDeletedAt: + values[i] = new(sql.NullTime) + case guide.ForeignKeys[0]: // user_id + 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 Guide fields. +func (gu *Guide) 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 guide.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + gu.ID = value.String + } + case guide.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 { + gu.CreatedAt = value.Time + } + case guide.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 { + gu.UpdatedAt = value.Time + } + case guide.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + gu.DeletedAt = value.Time + } + case guide.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + gu.Name = value.String + } + case guide.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 { + gu.ShortDescription = value.String + } + case guide.FieldGuide: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field guide", values[i]) + } else if value.Valid { + gu.Guide = value.String + } + case guide.FieldViews: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field views", values[i]) + } else if value.Valid { + gu.Views = int(value.Int64) + } + case guide.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + gu.user_id = new(string) + *gu.user_id = value.String + } + default: + gu.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Guide. +// This includes values selected through modifiers, order, etc. +func (gu *Guide) Value(name string) (ent.Value, error) { + return gu.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the Guide entity. +func (gu *Guide) QueryUser() *UserQuery { + return NewGuideClient(gu.config).QueryUser(gu) +} + +// QueryTags queries the "tags" edge of the Guide entity. +func (gu *Guide) QueryTags() *TagQuery { + return NewGuideClient(gu.config).QueryTags(gu) +} + +// QueryGuideTags queries the "guide_tags" edge of the Guide entity. +func (gu *Guide) QueryGuideTags() *GuideTagQuery { + return NewGuideClient(gu.config).QueryGuideTags(gu) +} + +// Update returns a builder for updating this Guide. +// Note that you need to call Guide.Unwrap() before calling this method if this Guide +// was returned from a transaction, and the transaction was committed or rolled back. +func (gu *Guide) Update() *GuideUpdateOne { + return NewGuideClient(gu.config).UpdateOne(gu) +} + +// Unwrap unwraps the Guide 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 (gu *Guide) Unwrap() *Guide { + _tx, ok := gu.config.driver.(*txDriver) + if !ok { + panic("ent: Guide is not a transactional entity") + } + gu.config.driver = _tx.drv + return gu +} + +// String implements the fmt.Stringer. +func (gu *Guide) String() string { + var builder strings.Builder + builder.WriteString("Guide(") + builder.WriteString(fmt.Sprintf("id=%v, ", gu.ID)) + builder.WriteString("created_at=") + builder.WriteString(gu.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(gu.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(gu.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(gu.Name) + builder.WriteString(", ") + builder.WriteString("short_description=") + builder.WriteString(gu.ShortDescription) + builder.WriteString(", ") + builder.WriteString("guide=") + builder.WriteString(gu.Guide) + builder.WriteString(", ") + builder.WriteString("views=") + builder.WriteString(fmt.Sprintf("%v", gu.Views)) + builder.WriteByte(')') + return builder.String() +} + +// Guides is a parsable slice of Guide. +type Guides []*Guide diff --git a/generated/ent/guide/guide.go b/generated/ent/guide/guide.go new file mode 100644 index 00000000..ac5167de --- /dev/null +++ b/generated/ent/guide/guide.go @@ -0,0 +1,219 @@ +// Code generated by ent, DO NOT EDIT. + +package guide + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the guide type in the database. + Label = "guide" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_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" + // FieldGuide holds the string denoting the guide field in the database. + FieldGuide = "guide" + // FieldViews holds the string denoting the views field in the database. + FieldViews = "views" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeTags holds the string denoting the tags edge name in mutations. + EdgeTags = "tags" + // EdgeGuideTags holds the string denoting the guide_tags edge name in mutations. + EdgeGuideTags = "guide_tags" + // Table holds the table name of the guide in the database. + Table = "guides" + // UserTable is the table that holds the user relation/edge. + UserTable = "guides" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // TagsTable is the table that holds the tags relation/edge. The primary key declared below. + TagsTable = "guide_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" + // GuideTagsTable is the table that holds the guide_tags relation/edge. + GuideTagsTable = "guide_tags" + // GuideTagsInverseTable is the table name for the GuideTag entity. + // It exists in this package in order to avoid circular dependency with the "guidetag" package. + GuideTagsInverseTable = "guide_tags" + // GuideTagsColumn is the table column denoting the guide_tags relation/edge. + GuideTagsColumn = "guide_tag" +) + +// Columns holds all SQL columns for guide fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, + FieldShortDescription, + FieldGuide, + FieldViews, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "guides" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "user_id", +} + +var ( + // TagsPrimaryKey and TagsColumn2 are the table columns denoting the + // primary key for the tags relation (M2M). + TagsPrimaryKey = []string{"guide_tag", "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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + ShortDescriptionValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the Guide 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, 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() +} + +// ByGuide orders the results by the guide field. +func ByGuide(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGuide, opts...).ToFunc() +} + +// ByViews orders the results by the views field. +func ByViews(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldViews, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// 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...)...) + } +} + +// ByGuideTagsCount orders the results by guide_tags count. +func ByGuideTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newGuideTagsStep(), opts...) + } +} + +// ByGuideTags orders the results by guide_tags terms. +func ByGuideTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGuideTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) +} +func newTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) +} +func newGuideTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GuideTagsInverseTable, GuideTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, GuideTagsTable, GuideTagsColumn), + ) +} diff --git a/generated/ent/guide/where.go b/generated/ent/guide/where.go new file mode 100644 index 00000000..3945a8e4 --- /dev/null +++ b/generated/ent/guide/where.go @@ -0,0 +1,550 @@ +// Code generated by ent, DO NOT EDIT. + +package guide + +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.Guide { + return predicate.Guide(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Guide { + return predicate.Guide(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Guide { + return predicate.Guide(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.Guide { + return predicate.Guide(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.Guide { + return predicate.Guide(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldName, v)) +} + +// ShortDescription applies equality check predicate on the "short_description" field. It's identical to ShortDescriptionEQ. +func ShortDescription(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldShortDescription, v)) +} + +// Guide applies equality check predicate on the "guide" field. It's identical to GuideEQ. +func Guide(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldGuide, v)) +} + +// Views applies equality check predicate on the "views" field. It's identical to ViewsEQ. +func Views(v int) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldViews, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Guide { + return predicate.Guide(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Guide { + return predicate.Guide(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Guide { + return predicate.Guide(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldContainsFold(FieldName, v)) +} + +// ShortDescriptionEQ applies the EQ predicate on the "short_description" field. +func ShortDescriptionEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldShortDescription, v)) +} + +// ShortDescriptionNEQ applies the NEQ predicate on the "short_description" field. +func ShortDescriptionNEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldShortDescription, v)) +} + +// ShortDescriptionIn applies the In predicate on the "short_description" field. +func ShortDescriptionIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionNotIn applies the NotIn predicate on the "short_description" field. +func ShortDescriptionNotIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionGT applies the GT predicate on the "short_description" field. +func ShortDescriptionGT(v string) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldShortDescription, v)) +} + +// ShortDescriptionGTE applies the GTE predicate on the "short_description" field. +func ShortDescriptionGTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldShortDescription, v)) +} + +// ShortDescriptionLT applies the LT predicate on the "short_description" field. +func ShortDescriptionLT(v string) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldShortDescription, v)) +} + +// ShortDescriptionLTE applies the LTE predicate on the "short_description" field. +func ShortDescriptionLTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldShortDescription, v)) +} + +// ShortDescriptionContains applies the Contains predicate on the "short_description" field. +func ShortDescriptionContains(v string) predicate.Guide { + return predicate.Guide(sql.FieldContains(FieldShortDescription, v)) +} + +// ShortDescriptionHasPrefix applies the HasPrefix predicate on the "short_description" field. +func ShortDescriptionHasPrefix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasPrefix(FieldShortDescription, v)) +} + +// ShortDescriptionHasSuffix applies the HasSuffix predicate on the "short_description" field. +func ShortDescriptionHasSuffix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasSuffix(FieldShortDescription, v)) +} + +// ShortDescriptionEqualFold applies the EqualFold predicate on the "short_description" field. +func ShortDescriptionEqualFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldEqualFold(FieldShortDescription, v)) +} + +// ShortDescriptionContainsFold applies the ContainsFold predicate on the "short_description" field. +func ShortDescriptionContainsFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldContainsFold(FieldShortDescription, v)) +} + +// GuideEQ applies the EQ predicate on the "guide" field. +func GuideEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldGuide, v)) +} + +// GuideNEQ applies the NEQ predicate on the "guide" field. +func GuideNEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldGuide, v)) +} + +// GuideIn applies the In predicate on the "guide" field. +func GuideIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldGuide, vs...)) +} + +// GuideNotIn applies the NotIn predicate on the "guide" field. +func GuideNotIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldGuide, vs...)) +} + +// GuideGT applies the GT predicate on the "guide" field. +func GuideGT(v string) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldGuide, v)) +} + +// GuideGTE applies the GTE predicate on the "guide" field. +func GuideGTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldGuide, v)) +} + +// GuideLT applies the LT predicate on the "guide" field. +func GuideLT(v string) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldGuide, v)) +} + +// GuideLTE applies the LTE predicate on the "guide" field. +func GuideLTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldGuide, v)) +} + +// GuideContains applies the Contains predicate on the "guide" field. +func GuideContains(v string) predicate.Guide { + return predicate.Guide(sql.FieldContains(FieldGuide, v)) +} + +// GuideHasPrefix applies the HasPrefix predicate on the "guide" field. +func GuideHasPrefix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasPrefix(FieldGuide, v)) +} + +// GuideHasSuffix applies the HasSuffix predicate on the "guide" field. +func GuideHasSuffix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasSuffix(FieldGuide, v)) +} + +// GuideEqualFold applies the EqualFold predicate on the "guide" field. +func GuideEqualFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldEqualFold(FieldGuide, v)) +} + +// GuideContainsFold applies the ContainsFold predicate on the "guide" field. +func GuideContainsFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldContainsFold(FieldGuide, v)) +} + +// ViewsEQ applies the EQ predicate on the "views" field. +func ViewsEQ(v int) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldViews, v)) +} + +// ViewsNEQ applies the NEQ predicate on the "views" field. +func ViewsNEQ(v int) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldViews, v)) +} + +// ViewsIn applies the In predicate on the "views" field. +func ViewsIn(vs ...int) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldViews, vs...)) +} + +// ViewsNotIn applies the NotIn predicate on the "views" field. +func ViewsNotIn(vs ...int) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldViews, vs...)) +} + +// ViewsGT applies the GT predicate on the "views" field. +func ViewsGT(v int) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldViews, v)) +} + +// ViewsGTE applies the GTE predicate on the "views" field. +func ViewsGTE(v int) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldViews, v)) +} + +// ViewsLT applies the LT predicate on the "views" field. +func ViewsLT(v int) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldViews, v)) +} + +// ViewsLTE applies the LTE predicate on the "views" field. +func ViewsLTE(v int) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldViews, v)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.Guide { + return predicate.Guide(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.Guide { + return predicate.Guide(func(s *sql.Selector) { + step := newUserStep() + 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.Guide { + return predicate.Guide(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.Guide { + return predicate.Guide(func(s *sql.Selector) { + step := newTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasGuideTags applies the HasEdge predicate on the "guide_tags" edge. +func HasGuideTags() predicate.Guide { + return predicate.Guide(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, GuideTagsTable, GuideTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGuideTagsWith applies the HasEdge predicate on the "guide_tags" edge with a given conditions (other predicates). +func HasGuideTagsWith(preds ...predicate.GuideTag) predicate.Guide { + return predicate.Guide(func(s *sql.Selector) { + step := newGuideTagsStep() + 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.Guide) predicate.Guide { + return predicate.Guide(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Guide) predicate.Guide { + return predicate.Guide(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Guide) predicate.Guide { + return predicate.Guide(sql.NotPredicates(p)) +} diff --git a/generated/ent/guide_create.go b/generated/ent/guide_create.go new file mode 100644 index 00000000..0e5f1533 --- /dev/null +++ b/generated/ent/guide_create.go @@ -0,0 +1,406 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" +) + +// GuideCreate is the builder for creating a Guide entity. +type GuideCreate struct { + config + mutation *GuideMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (gc *GuideCreate) SetCreatedAt(t time.Time) *GuideCreate { + gc.mutation.SetCreatedAt(t) + return gc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (gc *GuideCreate) SetNillableCreatedAt(t *time.Time) *GuideCreate { + if t != nil { + gc.SetCreatedAt(*t) + } + return gc +} + +// SetUpdatedAt sets the "updated_at" field. +func (gc *GuideCreate) SetUpdatedAt(t time.Time) *GuideCreate { + gc.mutation.SetUpdatedAt(t) + return gc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (gc *GuideCreate) SetNillableUpdatedAt(t *time.Time) *GuideCreate { + if t != nil { + gc.SetUpdatedAt(*t) + } + return gc +} + +// SetDeletedAt sets the "deleted_at" field. +func (gc *GuideCreate) SetDeletedAt(t time.Time) *GuideCreate { + gc.mutation.SetDeletedAt(t) + return gc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (gc *GuideCreate) SetNillableDeletedAt(t *time.Time) *GuideCreate { + if t != nil { + gc.SetDeletedAt(*t) + } + return gc +} + +// SetName sets the "name" field. +func (gc *GuideCreate) SetName(s string) *GuideCreate { + gc.mutation.SetName(s) + return gc +} + +// SetShortDescription sets the "short_description" field. +func (gc *GuideCreate) SetShortDescription(s string) *GuideCreate { + gc.mutation.SetShortDescription(s) + return gc +} + +// SetGuide sets the "guide" field. +func (gc *GuideCreate) SetGuide(s string) *GuideCreate { + gc.mutation.SetGuide(s) + return gc +} + +// SetViews sets the "views" field. +func (gc *GuideCreate) SetViews(i int) *GuideCreate { + gc.mutation.SetViews(i) + return gc +} + +// SetID sets the "id" field. +func (gc *GuideCreate) SetID(s string) *GuideCreate { + gc.mutation.SetID(s) + return gc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (gc *GuideCreate) SetNillableID(s *string) *GuideCreate { + if s != nil { + gc.SetID(*s) + } + return gc +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (gc *GuideCreate) SetUserID(id string) *GuideCreate { + gc.mutation.SetUserID(id) + return gc +} + +// SetUser sets the "user" edge to the User entity. +func (gc *GuideCreate) SetUser(u *User) *GuideCreate { + return gc.SetUserID(u.ID) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (gc *GuideCreate) AddTagIDs(ids ...string) *GuideCreate { + gc.mutation.AddTagIDs(ids...) + return gc +} + +// AddTags adds the "tags" edges to the Tag entity. +func (gc *GuideCreate) AddTags(t ...*Tag) *GuideCreate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return gc.AddTagIDs(ids...) +} + +// Mutation returns the GuideMutation object of the builder. +func (gc *GuideCreate) Mutation() *GuideMutation { + return gc.mutation +} + +// Save creates the Guide in the database. +func (gc *GuideCreate) Save(ctx context.Context) (*Guide, error) { + if err := gc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (gc *GuideCreate) SaveX(ctx context.Context) *Guide { + v, err := gc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (gc *GuideCreate) Exec(ctx context.Context) error { + _, err := gc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gc *GuideCreate) ExecX(ctx context.Context) { + if err := gc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (gc *GuideCreate) defaults() error { + if _, ok := gc.mutation.CreatedAt(); !ok { + if guide.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized guide.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := guide.DefaultCreatedAt() + gc.mutation.SetCreatedAt(v) + } + if _, ok := gc.mutation.UpdatedAt(); !ok { + if guide.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized guide.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := guide.DefaultUpdatedAt() + gc.mutation.SetUpdatedAt(v) + } + if _, ok := gc.mutation.ID(); !ok { + if guide.DefaultID == nil { + return fmt.Errorf("ent: uninitialized guide.DefaultID (forgotten import ent/runtime?)") + } + v := guide.DefaultID() + gc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (gc *GuideCreate) check() error { + if _, ok := gc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Guide.created_at"`)} + } + if _, ok := gc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Guide.updated_at"`)} + } + if _, ok := gc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Guide.name"`)} + } + if v, ok := gc.mutation.Name(); ok { + if err := guide.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Guide.name": %w`, err)} + } + } + if _, ok := gc.mutation.ShortDescription(); !ok { + return &ValidationError{Name: "short_description", err: errors.New(`ent: missing required field "Guide.short_description"`)} + } + if v, ok := gc.mutation.ShortDescription(); ok { + if err := guide.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Guide.short_description": %w`, err)} + } + } + if _, ok := gc.mutation.Guide(); !ok { + return &ValidationError{Name: "guide", err: errors.New(`ent: missing required field "Guide.guide"`)} + } + if _, ok := gc.mutation.Views(); !ok { + return &ValidationError{Name: "views", err: errors.New(`ent: missing required field "Guide.views"`)} + } + if _, ok := gc.mutation.UserID(); !ok { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Guide.user"`)} + } + return nil +} + +func (gc *GuideCreate) sqlSave(ctx context.Context) (*Guide, error) { + if err := gc.check(); err != nil { + return nil, err + } + _node, _spec := gc.createSpec() + if err := sqlgraph.CreateNode(ctx, gc.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 Guide.ID type: %T", _spec.ID.Value) + } + } + gc.mutation.id = &_node.ID + gc.mutation.done = true + return _node, nil +} + +func (gc *GuideCreate) createSpec() (*Guide, *sqlgraph.CreateSpec) { + var ( + _node = &Guide{config: gc.config} + _spec = sqlgraph.NewCreateSpec(guide.Table, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) + ) + if id, ok := gc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := gc.mutation.CreatedAt(); ok { + _spec.SetField(guide.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := gc.mutation.UpdatedAt(); ok { + _spec.SetField(guide.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := gc.mutation.DeletedAt(); ok { + _spec.SetField(guide.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := gc.mutation.Name(); ok { + _spec.SetField(guide.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := gc.mutation.ShortDescription(); ok { + _spec.SetField(guide.FieldShortDescription, field.TypeString, value) + _node.ShortDescription = value + } + if value, ok := gc.mutation.Guide(); ok { + _spec.SetField(guide.FieldGuide, field.TypeString, value) + _node.Guide = value + } + if value, ok := gc.mutation.Views(); ok { + _spec.SetField(guide.FieldViews, field.TypeInt, value) + _node.Views = value + } + if nodes := gc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: guide.UserTable, + Columns: []string{guide.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_id = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := gc.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.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 +} + +// GuideCreateBulk is the builder for creating many Guide entities in bulk. +type GuideCreateBulk struct { + config + err error + builders []*GuideCreate +} + +// Save creates the Guide entities in the database. +func (gcb *GuideCreateBulk) Save(ctx context.Context) ([]*Guide, error) { + if gcb.err != nil { + return nil, gcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) + nodes := make([]*Guide, len(gcb.builders)) + mutators := make([]Mutator, len(gcb.builders)) + for i := range gcb.builders { + func(i int, root context.Context) { + builder := gcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*GuideMutation) + 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, gcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, gcb.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, gcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (gcb *GuideCreateBulk) SaveX(ctx context.Context) []*Guide { + v, err := gcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (gcb *GuideCreateBulk) Exec(ctx context.Context) error { + _, err := gcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gcb *GuideCreateBulk) ExecX(ctx context.Context) { + if err := gcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guide_delete.go b/generated/ent/guide_delete.go new file mode 100644 index 00000000..8494f15c --- /dev/null +++ b/generated/ent/guide_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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// GuideDelete is the builder for deleting a Guide entity. +type GuideDelete struct { + config + hooks []Hook + mutation *GuideMutation +} + +// Where appends a list predicates to the GuideDelete builder. +func (gd *GuideDelete) Where(ps ...predicate.Guide) *GuideDelete { + gd.mutation.Where(ps...) + return gd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (gd *GuideDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (gd *GuideDelete) ExecX(ctx context.Context) int { + n, err := gd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (gd *GuideDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(guide.Table, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) + if ps := gd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, gd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + gd.mutation.done = true + return affected, err +} + +// GuideDeleteOne is the builder for deleting a single Guide entity. +type GuideDeleteOne struct { + gd *GuideDelete +} + +// Where appends a list predicates to the GuideDelete builder. +func (gdo *GuideDeleteOne) Where(ps ...predicate.Guide) *GuideDeleteOne { + gdo.gd.mutation.Where(ps...) + return gdo +} + +// Exec executes the deletion query. +func (gdo *GuideDeleteOne) Exec(ctx context.Context) error { + n, err := gdo.gd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{guide.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (gdo *GuideDeleteOne) ExecX(ctx context.Context) { + if err := gdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guide_query.go b/generated/ent/guide_query.go new file mode 100644 index 00000000..e38779ca --- /dev/null +++ b/generated/ent/guide_query.go @@ -0,0 +1,815 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" +) + +// GuideQuery is the builder for querying Guide entities. +type GuideQuery struct { + config + ctx *QueryContext + order []guide.OrderOption + inters []Interceptor + predicates []predicate.Guide + withUser *UserQuery + withTags *TagQuery + withGuideTags *GuideTagQuery + withFKs bool + 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 GuideQuery builder. +func (gq *GuideQuery) Where(ps ...predicate.Guide) *GuideQuery { + gq.predicates = append(gq.predicates, ps...) + return gq +} + +// Limit the number of records to be returned by this query. +func (gq *GuideQuery) Limit(limit int) *GuideQuery { + gq.ctx.Limit = &limit + return gq +} + +// Offset to start from. +func (gq *GuideQuery) Offset(offset int) *GuideQuery { + gq.ctx.Offset = &offset + return gq +} + +// 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 (gq *GuideQuery) Unique(unique bool) *GuideQuery { + gq.ctx.Unique = &unique + return gq +} + +// Order specifies how the records should be ordered. +func (gq *GuideQuery) Order(o ...guide.OrderOption) *GuideQuery { + gq.order = append(gq.order, o...) + return gq +} + +// QueryUser chains the current query on the "user" edge. +func (gq *GuideQuery) QueryUser() *UserQuery { + query := (&UserClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, guide.UserTable, guide.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTags chains the current query on the "tags" edge. +func (gq *GuideQuery) QueryTags() *TagQuery { + query := (&TagClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, guide.TagsTable, guide.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryGuideTags chains the current query on the "guide_tags" edge. +func (gq *GuideQuery) QueryGuideTags() *GuideTagQuery { + query := (&GuideTagClient{config: gq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(guide.Table, guide.FieldID, selector), + sqlgraph.To(guidetag.Table, guidetag.GuideColumn), + sqlgraph.Edge(sqlgraph.O2M, true, guide.GuideTagsTable, guide.GuideTagsColumn), + ) + fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Guide entity from the query. +// Returns a *NotFoundError when no Guide was found. +func (gq *GuideQuery) First(ctx context.Context) (*Guide, error) { + nodes, err := gq.Limit(1).All(setContextOp(ctx, gq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{guide.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (gq *GuideQuery) FirstX(ctx context.Context) *Guide { + node, err := gq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Guide ID from the query. +// Returns a *NotFoundError when no Guide ID was found. +func (gq *GuideQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = gq.Limit(1).IDs(setContextOp(ctx, gq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{guide.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (gq *GuideQuery) FirstIDX(ctx context.Context) string { + id, err := gq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Guide entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Guide entity is found. +// Returns a *NotFoundError when no Guide entities are found. +func (gq *GuideQuery) Only(ctx context.Context) (*Guide, error) { + nodes, err := gq.Limit(2).All(setContextOp(ctx, gq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{guide.Label} + default: + return nil, &NotSingularError{guide.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (gq *GuideQuery) OnlyX(ctx context.Context) *Guide { + node, err := gq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Guide ID in the query. +// Returns a *NotSingularError when more than one Guide ID is found. +// Returns a *NotFoundError when no entities are found. +func (gq *GuideQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = gq.Limit(2).IDs(setContextOp(ctx, gq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{guide.Label} + default: + err = &NotSingularError{guide.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (gq *GuideQuery) OnlyIDX(ctx context.Context) string { + id, err := gq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Guides. +func (gq *GuideQuery) All(ctx context.Context) ([]*Guide, error) { + ctx = setContextOp(ctx, gq.ctx, "All") + if err := gq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Guide, *GuideQuery]() + return withInterceptors[[]*Guide](ctx, gq, qr, gq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (gq *GuideQuery) AllX(ctx context.Context) []*Guide { + nodes, err := gq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Guide IDs. +func (gq *GuideQuery) IDs(ctx context.Context) (ids []string, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } + ctx = setContextOp(ctx, gq.ctx, "IDs") + if err = gq.Select(guide.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (gq *GuideQuery) IDsX(ctx context.Context) []string { + ids, err := gq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (gq *GuideQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, gq.ctx, "Count") + if err := gq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, gq, querierCount[*GuideQuery](), gq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (gq *GuideQuery) CountX(ctx context.Context) int { + count, err := gq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (gq *GuideQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, gq.ctx, "Exist") + switch _, err := gq.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 (gq *GuideQuery) ExistX(ctx context.Context) bool { + exist, err := gq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the GuideQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (gq *GuideQuery) Clone() *GuideQuery { + if gq == nil { + return nil + } + return &GuideQuery{ + config: gq.config, + ctx: gq.ctx.Clone(), + order: append([]guide.OrderOption{}, gq.order...), + inters: append([]Interceptor{}, gq.inters...), + predicates: append([]predicate.Guide{}, gq.predicates...), + withUser: gq.withUser.Clone(), + withTags: gq.withTags.Clone(), + withGuideTags: gq.withGuideTags.Clone(), + // clone intermediate query. + sql: gq.sql.Clone(), + path: gq.path, + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (gq *GuideQuery) WithUser(opts ...func(*UserQuery)) *GuideQuery { + query := (&UserClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withUser = query + return gq +} + +// 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 (gq *GuideQuery) WithTags(opts ...func(*TagQuery)) *GuideQuery { + query := (&TagClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withTags = query + return gq +} + +// WithGuideTags tells the query-builder to eager-load the nodes that are connected to +// the "guide_tags" edge. The optional arguments are used to configure the query builder of the edge. +func (gq *GuideQuery) WithGuideTags(opts ...func(*GuideTagQuery)) *GuideQuery { + query := (&GuideTagClient{config: gq.config}).Query() + for _, opt := range opts { + opt(query) + } + gq.withGuideTags = query + return gq +} + +// 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.Guide.Query(). +// GroupBy(guide.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (gq *GuideQuery) GroupBy(field string, fields ...string) *GuideGroupBy { + gq.ctx.Fields = append([]string{field}, fields...) + grbuild := &GuideGroupBy{build: gq} + grbuild.flds = &gq.ctx.Fields + grbuild.label = guide.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.Guide.Query(). +// Select(guide.FieldCreatedAt). +// Scan(ctx, &v) +func (gq *GuideQuery) Select(fields ...string) *GuideSelect { + gq.ctx.Fields = append(gq.ctx.Fields, fields...) + sbuild := &GuideSelect{GuideQuery: gq} + sbuild.label = guide.Label + sbuild.flds, sbuild.scan = &gq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a GuideSelect configured with the given aggregations. +func (gq *GuideQuery) Aggregate(fns ...AggregateFunc) *GuideSelect { + return gq.Select().Aggregate(fns...) +} + +func (gq *GuideQuery) prepareQuery(ctx context.Context) error { + for _, inter := range gq.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, gq); err != nil { + return err + } + } + } + for _, f := range gq.ctx.Fields { + if !guide.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if gq.path != nil { + prev, err := gq.path(ctx) + if err != nil { + return err + } + gq.sql = prev + } + return nil +} + +func (gq *GuideQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Guide, error) { + var ( + nodes = []*Guide{} + withFKs = gq.withFKs + _spec = gq.querySpec() + loadedTypes = [3]bool{ + gq.withUser != nil, + gq.withTags != nil, + gq.withGuideTags != nil, + } + ) + if gq.withUser != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, guide.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Guide).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Guide{config: gq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(gq.modifiers) > 0 { + _spec.Modifiers = gq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, gq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := gq.withUser; query != nil { + if err := gq.loadUser(ctx, query, nodes, nil, + func(n *Guide, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + if query := gq.withTags; query != nil { + if err := gq.loadTags(ctx, query, nodes, + func(n *Guide) { n.Edges.Tags = []*Tag{} }, + func(n *Guide, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + if query := gq.withGuideTags; query != nil { + if err := gq.loadGuideTags(ctx, query, nodes, + func(n *Guide) { n.Edges.GuideTags = []*GuideTag{} }, + func(n *Guide, e *GuideTag) { n.Edges.GuideTags = append(n.Edges.GuideTags, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (gq *GuideQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Guide, init func(*Guide), assign func(*Guide, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*Guide) + for i := range nodes { + if nodes[i].user_id == nil { + continue + } + fk := *nodes[i].user_id + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (gq *GuideQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Guide, init func(*Guide), assign func(*Guide, *Tag)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Guide) + nids := make(map[string]map[*Guide]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(guide.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(guide.TagsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(guide.TagsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(guide.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[*Guide]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 (gq *GuideQuery) loadGuideTags(ctx context.Context, query *GuideTagQuery, nodes []*Guide, init func(*Guide), assign func(*Guide, *GuideTag)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Guide) + 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(guidetag.FieldGuideTag) + } + query.Where(predicate.GuideTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(guide.GuideTagsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.GuideTag + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "guide_tag" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} + +func (gq *GuideQuery) sqlCount(ctx context.Context) (int, error) { + _spec := gq.querySpec() + if len(gq.modifiers) > 0 { + _spec.Modifiers = gq.modifiers + } + _spec.Node.Columns = gq.ctx.Fields + if len(gq.ctx.Fields) > 0 { + _spec.Unique = gq.ctx.Unique != nil && *gq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, gq.driver, _spec) +} + +func (gq *GuideQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(guide.Table, guide.Columns, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) + _spec.From = gq.sql + if unique := gq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true + } + if fields := gq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, guide.FieldID) + for i := range fields { + if fields[i] != guide.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := gq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := gq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := gq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := gq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (gq *GuideQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(gq.driver.Dialect()) + t1 := builder.Table(guide.Table) + columns := gq.ctx.Fields + if len(columns) == 0 { + columns = guide.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if gq.sql != nil { + selector = gq.sql + selector.Select(selector.Columns(columns...)...) + } + if gq.ctx.Unique != nil && *gq.ctx.Unique { + selector.Distinct() + } + for _, m := range gq.modifiers { + m(selector) + } + for _, p := range gq.predicates { + p(selector) + } + for _, p := range gq.order { + p(selector) + } + if offset := gq.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 := gq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (gq *GuideQuery) Modify(modifiers ...func(s *sql.Selector)) *GuideSelect { + gq.modifiers = append(gq.modifiers, modifiers...) + return gq.Select() +} + +// GuideGroupBy is the group-by builder for Guide entities. +type GuideGroupBy struct { + selector + build *GuideQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ggb *GuideGroupBy) Aggregate(fns ...AggregateFunc) *GuideGroupBy { + ggb.fns = append(ggb.fns, fns...) + return ggb +} + +// Scan applies the selector query and scans the result into the given value. +func (ggb *GuideGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ggb.build.ctx, "GroupBy") + if err := ggb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GuideQuery, *GuideGroupBy](ctx, ggb.build, ggb, ggb.build.inters, v) +} + +func (ggb *GuideGroupBy) sqlScan(ctx context.Context, root *GuideQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ggb.fns)) + for _, fn := range ggb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ggb.flds)+len(ggb.fns)) + for _, f := range *ggb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ggb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ggb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// GuideSelect is the builder for selecting fields of Guide entities. +type GuideSelect struct { + *GuideQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (gs *GuideSelect) Aggregate(fns ...AggregateFunc) *GuideSelect { + gs.fns = append(gs.fns, fns...) + return gs +} + +// Scan applies the selector query and scans the result into the given value. +func (gs *GuideSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, gs.ctx, "Select") + if err := gs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GuideQuery, *GuideSelect](ctx, gs.GuideQuery, gs, gs.inters, v) +} + +func (gs *GuideSelect) sqlScan(ctx context.Context, root *GuideQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(gs.fns)) + for _, fn := range gs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*gs.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 := gs.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 (gs *GuideSelect) Modify(modifiers ...func(s *sql.Selector)) *GuideSelect { + gs.modifiers = append(gs.modifiers, modifiers...) + return gs +} diff --git a/generated/ent/guide_update.go b/generated/ent/guide_update.go new file mode 100644 index 00000000..282da860 --- /dev/null +++ b/generated/ent/guide_update.go @@ -0,0 +1,682 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" +) + +// GuideUpdate is the builder for updating Guide entities. +type GuideUpdate struct { + config + hooks []Hook + mutation *GuideMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the GuideUpdate builder. +func (gu *GuideUpdate) Where(ps ...predicate.Guide) *GuideUpdate { + gu.mutation.Where(ps...) + return gu +} + +// SetUpdatedAt sets the "updated_at" field. +func (gu *GuideUpdate) SetUpdatedAt(t time.Time) *GuideUpdate { + gu.mutation.SetUpdatedAt(t) + return gu +} + +// SetDeletedAt sets the "deleted_at" field. +func (gu *GuideUpdate) SetDeletedAt(t time.Time) *GuideUpdate { + gu.mutation.SetDeletedAt(t) + return gu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableDeletedAt(t *time.Time) *GuideUpdate { + if t != nil { + gu.SetDeletedAt(*t) + } + return gu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (gu *GuideUpdate) ClearDeletedAt() *GuideUpdate { + gu.mutation.ClearDeletedAt() + return gu +} + +// SetName sets the "name" field. +func (gu *GuideUpdate) SetName(s string) *GuideUpdate { + gu.mutation.SetName(s) + return gu +} + +// SetShortDescription sets the "short_description" field. +func (gu *GuideUpdate) SetShortDescription(s string) *GuideUpdate { + gu.mutation.SetShortDescription(s) + return gu +} + +// SetGuide sets the "guide" field. +func (gu *GuideUpdate) SetGuide(s string) *GuideUpdate { + gu.mutation.SetGuide(s) + return gu +} + +// SetViews sets the "views" field. +func (gu *GuideUpdate) SetViews(i int) *GuideUpdate { + gu.mutation.ResetViews() + gu.mutation.SetViews(i) + return gu +} + +// AddViews adds i to the "views" field. +func (gu *GuideUpdate) AddViews(i int) *GuideUpdate { + gu.mutation.AddViews(i) + return gu +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (gu *GuideUpdate) SetUserID(id string) *GuideUpdate { + gu.mutation.SetUserID(id) + return gu +} + +// SetUser sets the "user" edge to the User entity. +func (gu *GuideUpdate) SetUser(u *User) *GuideUpdate { + return gu.SetUserID(u.ID) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (gu *GuideUpdate) AddTagIDs(ids ...string) *GuideUpdate { + gu.mutation.AddTagIDs(ids...) + return gu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (gu *GuideUpdate) AddTags(t ...*Tag) *GuideUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return gu.AddTagIDs(ids...) +} + +// Mutation returns the GuideMutation object of the builder. +func (gu *GuideUpdate) Mutation() *GuideMutation { + return gu.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (gu *GuideUpdate) ClearUser() *GuideUpdate { + gu.mutation.ClearUser() + return gu +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (gu *GuideUpdate) ClearTags() *GuideUpdate { + gu.mutation.ClearTags() + return gu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (gu *GuideUpdate) RemoveTagIDs(ids ...string) *GuideUpdate { + gu.mutation.RemoveTagIDs(ids...) + return gu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (gu *GuideUpdate) RemoveTags(t ...*Tag) *GuideUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return gu.RemoveTagIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (gu *GuideUpdate) Save(ctx context.Context) (int, error) { + if err := gu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (gu *GuideUpdate) SaveX(ctx context.Context) int { + affected, err := gu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (gu *GuideUpdate) Exec(ctx context.Context) error { + _, err := gu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gu *GuideUpdate) ExecX(ctx context.Context) { + if err := gu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (gu *GuideUpdate) defaults() error { + if _, ok := gu.mutation.UpdatedAt(); !ok { + if guide.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized guide.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := guide.UpdateDefaultUpdatedAt() + gu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (gu *GuideUpdate) check() error { + if v, ok := gu.mutation.Name(); ok { + if err := guide.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Guide.name": %w`, err)} + } + } + if v, ok := gu.mutation.ShortDescription(); ok { + if err := guide.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Guide.short_description": %w`, err)} + } + } + if _, ok := gu.mutation.UserID(); gu.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Guide.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (gu *GuideUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GuideUpdate { + gu.modifiers = append(gu.modifiers, modifiers...) + return gu +} + +func (gu *GuideUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := gu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(guide.Table, guide.Columns, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) + if ps := gu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := gu.mutation.UpdatedAt(); ok { + _spec.SetField(guide.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := gu.mutation.DeletedAt(); ok { + _spec.SetField(guide.FieldDeletedAt, field.TypeTime, value) + } + if gu.mutation.DeletedAtCleared() { + _spec.ClearField(guide.FieldDeletedAt, field.TypeTime) + } + if value, ok := gu.mutation.Name(); ok { + _spec.SetField(guide.FieldName, field.TypeString, value) + } + if value, ok := gu.mutation.ShortDescription(); ok { + _spec.SetField(guide.FieldShortDescription, field.TypeString, value) + } + if value, ok := gu.mutation.Guide(); ok { + _spec.SetField(guide.FieldGuide, field.TypeString, value) + } + if value, ok := gu.mutation.Views(); ok { + _spec.SetField(guide.FieldViews, field.TypeInt, value) + } + if value, ok := gu.mutation.AddedViews(); ok { + _spec.AddField(guide.FieldViews, field.TypeInt, value) + } + if gu.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: guide.UserTable, + Columns: []string{guide.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: guide.UserTable, + Columns: []string{guide.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if gu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gu.mutation.RemovedTagsIDs(); len(nodes) > 0 && !gu.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.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 := gu.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.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(gu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{guide.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + gu.mutation.done = true + return n, nil +} + +// GuideUpdateOne is the builder for updating a single Guide entity. +type GuideUpdateOne struct { + config + fields []string + hooks []Hook + mutation *GuideMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (guo *GuideUpdateOne) SetUpdatedAt(t time.Time) *GuideUpdateOne { + guo.mutation.SetUpdatedAt(t) + return guo +} + +// SetDeletedAt sets the "deleted_at" field. +func (guo *GuideUpdateOne) SetDeletedAt(t time.Time) *GuideUpdateOne { + guo.mutation.SetDeletedAt(t) + return guo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableDeletedAt(t *time.Time) *GuideUpdateOne { + if t != nil { + guo.SetDeletedAt(*t) + } + return guo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (guo *GuideUpdateOne) ClearDeletedAt() *GuideUpdateOne { + guo.mutation.ClearDeletedAt() + return guo +} + +// SetName sets the "name" field. +func (guo *GuideUpdateOne) SetName(s string) *GuideUpdateOne { + guo.mutation.SetName(s) + return guo +} + +// SetShortDescription sets the "short_description" field. +func (guo *GuideUpdateOne) SetShortDescription(s string) *GuideUpdateOne { + guo.mutation.SetShortDescription(s) + return guo +} + +// SetGuide sets the "guide" field. +func (guo *GuideUpdateOne) SetGuide(s string) *GuideUpdateOne { + guo.mutation.SetGuide(s) + return guo +} + +// SetViews sets the "views" field. +func (guo *GuideUpdateOne) SetViews(i int) *GuideUpdateOne { + guo.mutation.ResetViews() + guo.mutation.SetViews(i) + return guo +} + +// AddViews adds i to the "views" field. +func (guo *GuideUpdateOne) AddViews(i int) *GuideUpdateOne { + guo.mutation.AddViews(i) + return guo +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (guo *GuideUpdateOne) SetUserID(id string) *GuideUpdateOne { + guo.mutation.SetUserID(id) + return guo +} + +// SetUser sets the "user" edge to the User entity. +func (guo *GuideUpdateOne) SetUser(u *User) *GuideUpdateOne { + return guo.SetUserID(u.ID) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (guo *GuideUpdateOne) AddTagIDs(ids ...string) *GuideUpdateOne { + guo.mutation.AddTagIDs(ids...) + return guo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (guo *GuideUpdateOne) AddTags(t ...*Tag) *GuideUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return guo.AddTagIDs(ids...) +} + +// Mutation returns the GuideMutation object of the builder. +func (guo *GuideUpdateOne) Mutation() *GuideMutation { + return guo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (guo *GuideUpdateOne) ClearUser() *GuideUpdateOne { + guo.mutation.ClearUser() + return guo +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (guo *GuideUpdateOne) ClearTags() *GuideUpdateOne { + guo.mutation.ClearTags() + return guo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (guo *GuideUpdateOne) RemoveTagIDs(ids ...string) *GuideUpdateOne { + guo.mutation.RemoveTagIDs(ids...) + return guo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (guo *GuideUpdateOne) RemoveTags(t ...*Tag) *GuideUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return guo.RemoveTagIDs(ids...) +} + +// Where appends a list predicates to the GuideUpdate builder. +func (guo *GuideUpdateOne) Where(ps ...predicate.Guide) *GuideUpdateOne { + guo.mutation.Where(ps...) + return guo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (guo *GuideUpdateOne) Select(field string, fields ...string) *GuideUpdateOne { + guo.fields = append([]string{field}, fields...) + return guo +} + +// Save executes the query and returns the updated Guide entity. +func (guo *GuideUpdateOne) Save(ctx context.Context) (*Guide, error) { + if err := guo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (guo *GuideUpdateOne) SaveX(ctx context.Context) *Guide { + node, err := guo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (guo *GuideUpdateOne) Exec(ctx context.Context) error { + _, err := guo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (guo *GuideUpdateOne) ExecX(ctx context.Context) { + if err := guo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (guo *GuideUpdateOne) defaults() error { + if _, ok := guo.mutation.UpdatedAt(); !ok { + if guide.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized guide.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := guide.UpdateDefaultUpdatedAt() + guo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (guo *GuideUpdateOne) check() error { + if v, ok := guo.mutation.Name(); ok { + if err := guide.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Guide.name": %w`, err)} + } + } + if v, ok := guo.mutation.ShortDescription(); ok { + if err := guide.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Guide.short_description": %w`, err)} + } + } + if _, ok := guo.mutation.UserID(); guo.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Guide.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (guo *GuideUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GuideUpdateOne { + guo.modifiers = append(guo.modifiers, modifiers...) + return guo +} + +func (guo *GuideUpdateOne) sqlSave(ctx context.Context) (_node *Guide, err error) { + if err := guo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(guide.Table, guide.Columns, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) + id, ok := guo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Guide.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := guo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, guide.FieldID) + for _, f := range fields { + if !guide.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != guide.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := guo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := guo.mutation.UpdatedAt(); ok { + _spec.SetField(guide.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := guo.mutation.DeletedAt(); ok { + _spec.SetField(guide.FieldDeletedAt, field.TypeTime, value) + } + if guo.mutation.DeletedAtCleared() { + _spec.ClearField(guide.FieldDeletedAt, field.TypeTime) + } + if value, ok := guo.mutation.Name(); ok { + _spec.SetField(guide.FieldName, field.TypeString, value) + } + if value, ok := guo.mutation.ShortDescription(); ok { + _spec.SetField(guide.FieldShortDescription, field.TypeString, value) + } + if value, ok := guo.mutation.Guide(); ok { + _spec.SetField(guide.FieldGuide, field.TypeString, value) + } + if value, ok := guo.mutation.Views(); ok { + _spec.SetField(guide.FieldViews, field.TypeInt, value) + } + if value, ok := guo.mutation.AddedViews(); ok { + _spec.AddField(guide.FieldViews, field.TypeInt, value) + } + if guo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: guide.UserTable, + Columns: []string{guide.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: guide.UserTable, + Columns: []string{guide.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if guo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.TagsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := guo.mutation.RemovedTagsIDs(); len(nodes) > 0 && !guo.mutation.TagsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.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 := guo.mutation.TagsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: guide.TagsTable, + Columns: guide.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(guo.modifiers...) + _node = &Guide{config: guo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{guide.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + guo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/guidetag.go b/generated/ent/guidetag.go new file mode 100644 index 00000000..d2442d9c --- /dev/null +++ b/generated/ent/guidetag.go @@ -0,0 +1,155 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// GuideTag is the model entity for the GuideTag schema. +type GuideTag struct { + config `json:"-"` + // GuideTag holds the value of the "guide_tag" field. + GuideTag string `json:"guide_tag,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 GuideTagQuery when eager-loading is set. + Edges GuideTagEdges `json:"edges"` + selectValues sql.SelectValues +} + +// GuideTagEdges holds the relations/edges for other nodes in the graph. +type GuideTagEdges struct { + // Guide holds the value of the guide edge. + Guide *Guide `json:"guide,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 +} + +// GuideOrErr returns the Guide value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e GuideTagEdges) GuideOrErr() (*Guide, error) { + if e.loadedTypes[0] { + if e.Guide == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: guide.Label} + } + return e.Guide, nil + } + return nil, &NotLoadedError{edge: "guide"} +} + +// 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 GuideTagEdges) TagOrErr() (*Tag, error) { + if e.loadedTypes[1] { + if e.Tag == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: tag.Label} + } + return e.Tag, nil + } + return nil, &NotLoadedError{edge: "tag"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*GuideTag) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case guidetag.FieldGuideTag, guidetag.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 GuideTag fields. +func (gt *GuideTag) 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 guidetag.FieldGuideTag: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field guide_tag", values[i]) + } else if value.Valid { + gt.GuideTag = value.String + } + case guidetag.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 { + gt.TagID = value.String + } + default: + gt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the GuideTag. +// This includes values selected through modifiers, order, etc. +func (gt *GuideTag) Value(name string) (ent.Value, error) { + return gt.selectValues.Get(name) +} + +// QueryGuide queries the "guide" edge of the GuideTag entity. +func (gt *GuideTag) QueryGuide() *GuideQuery { + return NewGuideTagClient(gt.config).QueryGuide(gt) +} + +// QueryTag queries the "tag" edge of the GuideTag entity. +func (gt *GuideTag) QueryTag() *TagQuery { + return NewGuideTagClient(gt.config).QueryTag(gt) +} + +// Update returns a builder for updating this GuideTag. +// Note that you need to call GuideTag.Unwrap() before calling this method if this GuideTag +// was returned from a transaction, and the transaction was committed or rolled back. +func (gt *GuideTag) Update() *GuideTagUpdateOne { + return NewGuideTagClient(gt.config).UpdateOne(gt) +} + +// Unwrap unwraps the GuideTag 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 (gt *GuideTag) Unwrap() *GuideTag { + _tx, ok := gt.config.driver.(*txDriver) + if !ok { + panic("ent: GuideTag is not a transactional entity") + } + gt.config.driver = _tx.drv + return gt +} + +// String implements the fmt.Stringer. +func (gt *GuideTag) String() string { + var builder strings.Builder + builder.WriteString("GuideTag(") + builder.WriteString("guide_tag=") + builder.WriteString(gt.GuideTag) + builder.WriteString(", ") + builder.WriteString("tag_id=") + builder.WriteString(gt.TagID) + builder.WriteByte(')') + return builder.String() +} + +// GuideTags is a parsable slice of GuideTag. +type GuideTags []*GuideTag diff --git a/generated/ent/guidetag/guidetag.go b/generated/ent/guidetag/guidetag.go new file mode 100644 index 00000000..4dbe2e5e --- /dev/null +++ b/generated/ent/guidetag/guidetag.go @@ -0,0 +1,98 @@ +// Code generated by ent, DO NOT EDIT. + +package guidetag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the guidetag type in the database. + Label = "guide_tag" + // FieldGuideTag holds the string denoting the guide_tag field in the database. + FieldGuideTag = "guide_tag" + // FieldTagID holds the string denoting the tag_id field in the database. + FieldTagID = "tag_id" + // EdgeGuide holds the string denoting the guide edge name in mutations. + EdgeGuide = "guide" + // EdgeTag holds the string denoting the tag edge name in mutations. + EdgeTag = "tag" + // GuideFieldID holds the string denoting the ID field of the Guide. + GuideFieldID = "id" + // TagFieldID holds the string denoting the ID field of the Tag. + TagFieldID = "id" + // Table holds the table name of the guidetag in the database. + Table = "guide_tags" + // GuideTable is the table that holds the guide relation/edge. + GuideTable = "guide_tags" + // GuideInverseTable is the table name for the Guide entity. + // It exists in this package in order to avoid circular dependency with the "guide" package. + GuideInverseTable = "guides" + // GuideColumn is the table column denoting the guide relation/edge. + GuideColumn = "guide_tag" + // TagTable is the table that holds the tag relation/edge. + TagTable = "guide_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 guidetag fields. +var Columns = []string{ + FieldGuideTag, + 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 GuideTag queries. +type OrderOption func(*sql.Selector) + +// ByGuideTag orders the results by the guide_tag field. +func ByGuideTag(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGuideTag, opts...).ToFunc() +} + +// ByTagID orders the results by the tag_id field. +func ByTagID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTagID, opts...).ToFunc() +} + +// ByGuideField orders the results by guide field. +func ByGuideField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGuideStep(), 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 newGuideStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, GuideColumn), + sqlgraph.To(GuideInverseTable, GuideFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, GuideTable, GuideColumn), + ) +} +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/guidetag/where.go b/generated/ent/guidetag/where.go new file mode 100644 index 00000000..3dbf826d --- /dev/null +++ b/generated/ent/guidetag/where.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package guidetag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// GuideTag applies equality check predicate on the "guide_tag" field. It's identical to GuideTagEQ. +func GuideTag(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldGuideTag, v)) +} + +// TagID applies equality check predicate on the "tag_id" field. It's identical to TagIDEQ. +func TagID(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldTagID, v)) +} + +// GuideTagEQ applies the EQ predicate on the "guide_tag" field. +func GuideTagEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldGuideTag, v)) +} + +// GuideTagNEQ applies the NEQ predicate on the "guide_tag" field. +func GuideTagNEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNEQ(FieldGuideTag, v)) +} + +// GuideTagIn applies the In predicate on the "guide_tag" field. +func GuideTagIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldIn(FieldGuideTag, vs...)) +} + +// GuideTagNotIn applies the NotIn predicate on the "guide_tag" field. +func GuideTagNotIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNotIn(FieldGuideTag, vs...)) +} + +// GuideTagGT applies the GT predicate on the "guide_tag" field. +func GuideTagGT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGT(FieldGuideTag, v)) +} + +// GuideTagGTE applies the GTE predicate on the "guide_tag" field. +func GuideTagGTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGTE(FieldGuideTag, v)) +} + +// GuideTagLT applies the LT predicate on the "guide_tag" field. +func GuideTagLT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLT(FieldGuideTag, v)) +} + +// GuideTagLTE applies the LTE predicate on the "guide_tag" field. +func GuideTagLTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLTE(FieldGuideTag, v)) +} + +// GuideTagContains applies the Contains predicate on the "guide_tag" field. +func GuideTagContains(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContains(FieldGuideTag, v)) +} + +// GuideTagHasPrefix applies the HasPrefix predicate on the "guide_tag" field. +func GuideTagHasPrefix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasPrefix(FieldGuideTag, v)) +} + +// GuideTagHasSuffix applies the HasSuffix predicate on the "guide_tag" field. +func GuideTagHasSuffix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasSuffix(FieldGuideTag, v)) +} + +// GuideTagEqualFold applies the EqualFold predicate on the "guide_tag" field. +func GuideTagEqualFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEqualFold(FieldGuideTag, v)) +} + +// GuideTagContainsFold applies the ContainsFold predicate on the "guide_tag" field. +func GuideTagContainsFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContainsFold(FieldGuideTag, v)) +} + +// TagIDEQ applies the EQ predicate on the "tag_id" field. +func TagIDEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldTagID, v)) +} + +// TagIDNEQ applies the NEQ predicate on the "tag_id" field. +func TagIDNEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNEQ(FieldTagID, v)) +} + +// TagIDIn applies the In predicate on the "tag_id" field. +func TagIDIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldIn(FieldTagID, vs...)) +} + +// TagIDNotIn applies the NotIn predicate on the "tag_id" field. +func TagIDNotIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNotIn(FieldTagID, vs...)) +} + +// TagIDGT applies the GT predicate on the "tag_id" field. +func TagIDGT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGT(FieldTagID, v)) +} + +// TagIDGTE applies the GTE predicate on the "tag_id" field. +func TagIDGTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGTE(FieldTagID, v)) +} + +// TagIDLT applies the LT predicate on the "tag_id" field. +func TagIDLT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLT(FieldTagID, v)) +} + +// TagIDLTE applies the LTE predicate on the "tag_id" field. +func TagIDLTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLTE(FieldTagID, v)) +} + +// TagIDContains applies the Contains predicate on the "tag_id" field. +func TagIDContains(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContains(FieldTagID, v)) +} + +// TagIDHasPrefix applies the HasPrefix predicate on the "tag_id" field. +func TagIDHasPrefix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasPrefix(FieldTagID, v)) +} + +// TagIDHasSuffix applies the HasSuffix predicate on the "tag_id" field. +func TagIDHasSuffix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasSuffix(FieldTagID, v)) +} + +// TagIDEqualFold applies the EqualFold predicate on the "tag_id" field. +func TagIDEqualFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEqualFold(FieldTagID, v)) +} + +// TagIDContainsFold applies the ContainsFold predicate on the "tag_id" field. +func TagIDContainsFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContainsFold(FieldTagID, v)) +} + +// HasGuide applies the HasEdge predicate on the "guide" edge. +func HasGuide() predicate.GuideTag { + return predicate.GuideTag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, GuideColumn), + sqlgraph.Edge(sqlgraph.M2O, false, GuideTable, GuideColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGuideWith applies the HasEdge predicate on the "guide" edge with a given conditions (other predicates). +func HasGuideWith(preds ...predicate.Guide) predicate.GuideTag { + return predicate.GuideTag(func(s *sql.Selector) { + step := newGuideStep() + 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.GuideTag { + return predicate.GuideTag(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.GuideTag { + return predicate.GuideTag(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.GuideTag) predicate.GuideTag { + return predicate.GuideTag(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.GuideTag) predicate.GuideTag { + return predicate.GuideTag(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.GuideTag) predicate.GuideTag { + return predicate.GuideTag(sql.NotPredicates(p)) +} diff --git a/generated/ent/guidetag_create.go b/generated/ent/guidetag_create.go new file mode 100644 index 00000000..71aaea6c --- /dev/null +++ b/generated/ent/guidetag_create.go @@ -0,0 +1,237 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// GuideTagCreate is the builder for creating a GuideTag entity. +type GuideTagCreate struct { + config + mutation *GuideTagMutation + hooks []Hook +} + +// SetGuideTag sets the "guide_tag" field. +func (gtc *GuideTagCreate) SetGuideTag(s string) *GuideTagCreate { + gtc.mutation.SetGuideTag(s) + return gtc +} + +// SetTagID sets the "tag_id" field. +func (gtc *GuideTagCreate) SetTagID(s string) *GuideTagCreate { + gtc.mutation.SetTagID(s) + return gtc +} + +// SetGuideID sets the "guide" edge to the Guide entity by ID. +func (gtc *GuideTagCreate) SetGuideID(id string) *GuideTagCreate { + gtc.mutation.SetGuideID(id) + return gtc +} + +// SetGuide sets the "guide" edge to the Guide entity. +func (gtc *GuideTagCreate) SetGuide(g *Guide) *GuideTagCreate { + return gtc.SetGuideID(g.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (gtc *GuideTagCreate) SetTag(t *Tag) *GuideTagCreate { + return gtc.SetTagID(t.ID) +} + +// Mutation returns the GuideTagMutation object of the builder. +func (gtc *GuideTagCreate) Mutation() *GuideTagMutation { + return gtc.mutation +} + +// Save creates the GuideTag in the database. +func (gtc *GuideTagCreate) Save(ctx context.Context) (*GuideTag, error) { + return withHooks(ctx, gtc.sqlSave, gtc.mutation, gtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (gtc *GuideTagCreate) SaveX(ctx context.Context) *GuideTag { + v, err := gtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (gtc *GuideTagCreate) Exec(ctx context.Context) error { + _, err := gtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtc *GuideTagCreate) ExecX(ctx context.Context) { + if err := gtc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (gtc *GuideTagCreate) check() error { + if _, ok := gtc.mutation.GuideTag(); !ok { + return &ValidationError{Name: "guide_tag", err: errors.New(`ent: missing required field "GuideTag.guide_tag"`)} + } + if _, ok := gtc.mutation.TagID(); !ok { + return &ValidationError{Name: "tag_id", err: errors.New(`ent: missing required field "GuideTag.tag_id"`)} + } + if _, ok := gtc.mutation.GuideID(); !ok { + return &ValidationError{Name: "guide", err: errors.New(`ent: missing required edge "GuideTag.guide"`)} + } + if _, ok := gtc.mutation.TagID(); !ok { + return &ValidationError{Name: "tag", err: errors.New(`ent: missing required edge "GuideTag.tag"`)} + } + return nil +} + +func (gtc *GuideTagCreate) sqlSave(ctx context.Context) (*GuideTag, error) { + if err := gtc.check(); err != nil { + return nil, err + } + _node, _spec := gtc.createSpec() + if err := sqlgraph.CreateNode(ctx, gtc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} + +func (gtc *GuideTagCreate) createSpec() (*GuideTag, *sqlgraph.CreateSpec) { + var ( + _node = &GuideTag{config: gtc.config} + _spec = sqlgraph.NewCreateSpec(guidetag.Table, nil) + ) + if nodes := gtc.mutation.GuideIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.GuideTable, + Columns: []string{guidetag.GuideColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.GuideTag = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := gtc.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.TagTable, + Columns: []string{guidetag.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 +} + +// GuideTagCreateBulk is the builder for creating many GuideTag entities in bulk. +type GuideTagCreateBulk struct { + config + err error + builders []*GuideTagCreate +} + +// Save creates the GuideTag entities in the database. +func (gtcb *GuideTagCreateBulk) Save(ctx context.Context) ([]*GuideTag, error) { + if gtcb.err != nil { + return nil, gtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(gtcb.builders)) + nodes := make([]*GuideTag, len(gtcb.builders)) + mutators := make([]Mutator, len(gtcb.builders)) + for i := range gtcb.builders { + func(i int, root context.Context) { + builder := gtcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*GuideTagMutation) + 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, gtcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, gtcb.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, gtcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (gtcb *GuideTagCreateBulk) SaveX(ctx context.Context) []*GuideTag { + v, err := gtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (gtcb *GuideTagCreateBulk) Exec(ctx context.Context) error { + _, err := gtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtcb *GuideTagCreateBulk) ExecX(ctx context.Context) { + if err := gtcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guidetag_delete.go b/generated/ent/guidetag_delete.go new file mode 100644 index 00000000..25c73fbc --- /dev/null +++ b/generated/ent/guidetag_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/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// GuideTagDelete is the builder for deleting a GuideTag entity. +type GuideTagDelete struct { + config + hooks []Hook + mutation *GuideTagMutation +} + +// Where appends a list predicates to the GuideTagDelete builder. +func (gtd *GuideTagDelete) Where(ps ...predicate.GuideTag) *GuideTagDelete { + gtd.mutation.Where(ps...) + return gtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (gtd *GuideTagDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, gtd.sqlExec, gtd.mutation, gtd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtd *GuideTagDelete) ExecX(ctx context.Context) int { + n, err := gtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (gtd *GuideTagDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(guidetag.Table, nil) + if ps := gtd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, gtd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + gtd.mutation.done = true + return affected, err +} + +// GuideTagDeleteOne is the builder for deleting a single GuideTag entity. +type GuideTagDeleteOne struct { + gtd *GuideTagDelete +} + +// Where appends a list predicates to the GuideTagDelete builder. +func (gtdo *GuideTagDeleteOne) Where(ps ...predicate.GuideTag) *GuideTagDeleteOne { + gtdo.gtd.mutation.Where(ps...) + return gtdo +} + +// Exec executes the deletion query. +func (gtdo *GuideTagDeleteOne) Exec(ctx context.Context) error { + n, err := gtdo.gtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{guidetag.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtdo *GuideTagDeleteOne) ExecX(ctx context.Context) { + if err := gtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guidetag_query.go b/generated/ent/guidetag_query.go new file mode 100644 index 00000000..8845f619 --- /dev/null +++ b/generated/ent/guidetag_query.go @@ -0,0 +1,624 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// GuideTagQuery is the builder for querying GuideTag entities. +type GuideTagQuery struct { + config + ctx *QueryContext + order []guidetag.OrderOption + inters []Interceptor + predicates []predicate.GuideTag + withGuide *GuideQuery + 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 GuideTagQuery builder. +func (gtq *GuideTagQuery) Where(ps ...predicate.GuideTag) *GuideTagQuery { + gtq.predicates = append(gtq.predicates, ps...) + return gtq +} + +// Limit the number of records to be returned by this query. +func (gtq *GuideTagQuery) Limit(limit int) *GuideTagQuery { + gtq.ctx.Limit = &limit + return gtq +} + +// Offset to start from. +func (gtq *GuideTagQuery) Offset(offset int) *GuideTagQuery { + gtq.ctx.Offset = &offset + return gtq +} + +// 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 (gtq *GuideTagQuery) Unique(unique bool) *GuideTagQuery { + gtq.ctx.Unique = &unique + return gtq +} + +// Order specifies how the records should be ordered. +func (gtq *GuideTagQuery) Order(o ...guidetag.OrderOption) *GuideTagQuery { + gtq.order = append(gtq.order, o...) + return gtq +} + +// QueryGuide chains the current query on the "guide" edge. +func (gtq *GuideTagQuery) QueryGuide() *GuideQuery { + query := (&GuideClient{config: gtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(guidetag.Table, guidetag.GuideColumn, selector), + sqlgraph.To(guide.Table, guide.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, guidetag.GuideTable, guidetag.GuideColumn), + ) + fromU = sqlgraph.SetNeighbors(gtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTag chains the current query on the "tag" edge. +func (gtq *GuideTagQuery) QueryTag() *TagQuery { + query := (&TagClient{config: gtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := gtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := gtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(guidetag.Table, guidetag.TagColumn, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, guidetag.TagTable, guidetag.TagColumn), + ) + fromU = sqlgraph.SetNeighbors(gtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first GuideTag entity from the query. +// Returns a *NotFoundError when no GuideTag was found. +func (gtq *GuideTagQuery) First(ctx context.Context) (*GuideTag, error) { + nodes, err := gtq.Limit(1).All(setContextOp(ctx, gtq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{guidetag.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (gtq *GuideTagQuery) FirstX(ctx context.Context) *GuideTag { + node, err := gtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single GuideTag entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one GuideTag entity is found. +// Returns a *NotFoundError when no GuideTag entities are found. +func (gtq *GuideTagQuery) Only(ctx context.Context) (*GuideTag, error) { + nodes, err := gtq.Limit(2).All(setContextOp(ctx, gtq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{guidetag.Label} + default: + return nil, &NotSingularError{guidetag.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (gtq *GuideTagQuery) OnlyX(ctx context.Context) *GuideTag { + node, err := gtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of GuideTags. +func (gtq *GuideTagQuery) All(ctx context.Context) ([]*GuideTag, error) { + ctx = setContextOp(ctx, gtq.ctx, "All") + if err := gtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*GuideTag, *GuideTagQuery]() + return withInterceptors[[]*GuideTag](ctx, gtq, qr, gtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (gtq *GuideTagQuery) AllX(ctx context.Context) []*GuideTag { + nodes, err := gtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (gtq *GuideTagQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, gtq.ctx, "Count") + if err := gtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, gtq, querierCount[*GuideTagQuery](), gtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (gtq *GuideTagQuery) CountX(ctx context.Context) int { + count, err := gtq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (gtq *GuideTagQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, gtq.ctx, "Exist") + switch _, err := gtq.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 (gtq *GuideTagQuery) ExistX(ctx context.Context) bool { + exist, err := gtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the GuideTagQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (gtq *GuideTagQuery) Clone() *GuideTagQuery { + if gtq == nil { + return nil + } + return &GuideTagQuery{ + config: gtq.config, + ctx: gtq.ctx.Clone(), + order: append([]guidetag.OrderOption{}, gtq.order...), + inters: append([]Interceptor{}, gtq.inters...), + predicates: append([]predicate.GuideTag{}, gtq.predicates...), + withGuide: gtq.withGuide.Clone(), + withTag: gtq.withTag.Clone(), + // clone intermediate query. + sql: gtq.sql.Clone(), + path: gtq.path, + } +} + +// WithGuide tells the query-builder to eager-load the nodes that are connected to +// the "guide" edge. The optional arguments are used to configure the query builder of the edge. +func (gtq *GuideTagQuery) WithGuide(opts ...func(*GuideQuery)) *GuideTagQuery { + query := (&GuideClient{config: gtq.config}).Query() + for _, opt := range opts { + opt(query) + } + gtq.withGuide = query + return gtq +} + +// 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 (gtq *GuideTagQuery) WithTag(opts ...func(*TagQuery)) *GuideTagQuery { + query := (&TagClient{config: gtq.config}).Query() + for _, opt := range opts { + opt(query) + } + gtq.withTag = query + return gtq +} + +// 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 { +// GuideTag string `json:"guide_tag,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.GuideTag.Query(). +// GroupBy(guidetag.FieldGuideTag). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (gtq *GuideTagQuery) GroupBy(field string, fields ...string) *GuideTagGroupBy { + gtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &GuideTagGroupBy{build: gtq} + grbuild.flds = >q.ctx.Fields + grbuild.label = guidetag.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 { +// GuideTag string `json:"guide_tag,omitempty"` +// } +// +// client.GuideTag.Query(). +// Select(guidetag.FieldGuideTag). +// Scan(ctx, &v) +func (gtq *GuideTagQuery) Select(fields ...string) *GuideTagSelect { + gtq.ctx.Fields = append(gtq.ctx.Fields, fields...) + sbuild := &GuideTagSelect{GuideTagQuery: gtq} + sbuild.label = guidetag.Label + sbuild.flds, sbuild.scan = >q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a GuideTagSelect configured with the given aggregations. +func (gtq *GuideTagQuery) Aggregate(fns ...AggregateFunc) *GuideTagSelect { + return gtq.Select().Aggregate(fns...) +} + +func (gtq *GuideTagQuery) prepareQuery(ctx context.Context) error { + for _, inter := range gtq.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, gtq); err != nil { + return err + } + } + } + for _, f := range gtq.ctx.Fields { + if !guidetag.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if gtq.path != nil { + prev, err := gtq.path(ctx) + if err != nil { + return err + } + gtq.sql = prev + } + return nil +} + +func (gtq *GuideTagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*GuideTag, error) { + var ( + nodes = []*GuideTag{} + _spec = gtq.querySpec() + loadedTypes = [2]bool{ + gtq.withGuide != nil, + gtq.withTag != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*GuideTag).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &GuideTag{config: gtq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(gtq.modifiers) > 0 { + _spec.Modifiers = gtq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, gtq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := gtq.withGuide; query != nil { + if err := gtq.loadGuide(ctx, query, nodes, nil, + func(n *GuideTag, e *Guide) { n.Edges.Guide = e }); err != nil { + return nil, err + } + } + if query := gtq.withTag; query != nil { + if err := gtq.loadTag(ctx, query, nodes, nil, + func(n *GuideTag, e *Tag) { n.Edges.Tag = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (gtq *GuideTagQuery) loadGuide(ctx context.Context, query *GuideQuery, nodes []*GuideTag, init func(*GuideTag), assign func(*GuideTag, *Guide)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*GuideTag) + for i := range nodes { + fk := nodes[i].GuideTag + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(guide.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 "guide_tag" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (gtq *GuideTagQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*GuideTag, init func(*GuideTag), assign func(*GuideTag, *Tag)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*GuideTag) + 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 (gtq *GuideTagQuery) sqlCount(ctx context.Context) (int, error) { + _spec := gtq.querySpec() + if len(gtq.modifiers) > 0 { + _spec.Modifiers = gtq.modifiers + } + _spec.Unique = false + _spec.Node.Columns = nil + return sqlgraph.CountNodes(ctx, gtq.driver, _spec) +} + +func (gtq *GuideTagQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(guidetag.Table, guidetag.Columns, nil) + _spec.From = gtq.sql + if unique := gtq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if gtq.path != nil { + _spec.Unique = true + } + if fields := gtq.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 gtq.withGuide != nil { + _spec.Node.AddColumnOnce(guidetag.FieldGuideTag) + } + if gtq.withTag != nil { + _spec.Node.AddColumnOnce(guidetag.FieldTagID) + } + } + if ps := gtq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := gtq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := gtq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := gtq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (gtq *GuideTagQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(gtq.driver.Dialect()) + t1 := builder.Table(guidetag.Table) + columns := gtq.ctx.Fields + if len(columns) == 0 { + columns = guidetag.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if gtq.sql != nil { + selector = gtq.sql + selector.Select(selector.Columns(columns...)...) + } + if gtq.ctx.Unique != nil && *gtq.ctx.Unique { + selector.Distinct() + } + for _, m := range gtq.modifiers { + m(selector) + } + for _, p := range gtq.predicates { + p(selector) + } + for _, p := range gtq.order { + p(selector) + } + if offset := gtq.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 := gtq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (gtq *GuideTagQuery) Modify(modifiers ...func(s *sql.Selector)) *GuideTagSelect { + gtq.modifiers = append(gtq.modifiers, modifiers...) + return gtq.Select() +} + +// GuideTagGroupBy is the group-by builder for GuideTag entities. +type GuideTagGroupBy struct { + selector + build *GuideTagQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (gtgb *GuideTagGroupBy) Aggregate(fns ...AggregateFunc) *GuideTagGroupBy { + gtgb.fns = append(gtgb.fns, fns...) + return gtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (gtgb *GuideTagGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, gtgb.build.ctx, "GroupBy") + if err := gtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GuideTagQuery, *GuideTagGroupBy](ctx, gtgb.build, gtgb, gtgb.build.inters, v) +} + +func (gtgb *GuideTagGroupBy) sqlScan(ctx context.Context, root *GuideTagQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(gtgb.fns)) + for _, fn := range gtgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*gtgb.flds)+len(gtgb.fns)) + for _, f := range *gtgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*gtgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := gtgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// GuideTagSelect is the builder for selecting fields of GuideTag entities. +type GuideTagSelect struct { + *GuideTagQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (gts *GuideTagSelect) Aggregate(fns ...AggregateFunc) *GuideTagSelect { + gts.fns = append(gts.fns, fns...) + return gts +} + +// Scan applies the selector query and scans the result into the given value. +func (gts *GuideTagSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, gts.ctx, "Select") + if err := gts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*GuideTagQuery, *GuideTagSelect](ctx, gts.GuideTagQuery, gts, gts.inters, v) +} + +func (gts *GuideTagSelect) sqlScan(ctx context.Context, root *GuideTagQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(gts.fns)) + for _, fn := range gts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*gts.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 := gts.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 (gts *GuideTagSelect) Modify(modifiers ...func(s *sql.Selector)) *GuideTagSelect { + gts.modifiers = append(gts.modifiers, modifiers...) + return gts +} diff --git a/generated/ent/guidetag_update.go b/generated/ent/guidetag_update.go new file mode 100644 index 00000000..5bf54bdd --- /dev/null +++ b/generated/ent/guidetag_update.go @@ -0,0 +1,419 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// GuideTagUpdate is the builder for updating GuideTag entities. +type GuideTagUpdate struct { + config + hooks []Hook + mutation *GuideTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the GuideTagUpdate builder. +func (gtu *GuideTagUpdate) Where(ps ...predicate.GuideTag) *GuideTagUpdate { + gtu.mutation.Where(ps...) + return gtu +} + +// SetGuideTag sets the "guide_tag" field. +func (gtu *GuideTagUpdate) SetGuideTag(s string) *GuideTagUpdate { + gtu.mutation.SetGuideTag(s) + return gtu +} + +// SetTagID sets the "tag_id" field. +func (gtu *GuideTagUpdate) SetTagID(s string) *GuideTagUpdate { + gtu.mutation.SetTagID(s) + return gtu +} + +// SetGuideID sets the "guide" edge to the Guide entity by ID. +func (gtu *GuideTagUpdate) SetGuideID(id string) *GuideTagUpdate { + gtu.mutation.SetGuideID(id) + return gtu +} + +// SetGuide sets the "guide" edge to the Guide entity. +func (gtu *GuideTagUpdate) SetGuide(g *Guide) *GuideTagUpdate { + return gtu.SetGuideID(g.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (gtu *GuideTagUpdate) SetTag(t *Tag) *GuideTagUpdate { + return gtu.SetTagID(t.ID) +} + +// Mutation returns the GuideTagMutation object of the builder. +func (gtu *GuideTagUpdate) Mutation() *GuideTagMutation { + return gtu.mutation +} + +// ClearGuide clears the "guide" edge to the Guide entity. +func (gtu *GuideTagUpdate) ClearGuide() *GuideTagUpdate { + gtu.mutation.ClearGuide() + return gtu +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (gtu *GuideTagUpdate) ClearTag() *GuideTagUpdate { + gtu.mutation.ClearTag() + return gtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (gtu *GuideTagUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, gtu.sqlSave, gtu.mutation, gtu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (gtu *GuideTagUpdate) SaveX(ctx context.Context) int { + affected, err := gtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (gtu *GuideTagUpdate) Exec(ctx context.Context) error { + _, err := gtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtu *GuideTagUpdate) ExecX(ctx context.Context) { + if err := gtu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (gtu *GuideTagUpdate) check() error { + if _, ok := gtu.mutation.GuideID(); gtu.mutation.GuideCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "GuideTag.guide"`) + } + if _, ok := gtu.mutation.TagID(); gtu.mutation.TagCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "GuideTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (gtu *GuideTagUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GuideTagUpdate { + gtu.modifiers = append(gtu.modifiers, modifiers...) + return gtu +} + +func (gtu *GuideTagUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := gtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideTag, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) + if ps := gtu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if gtu.mutation.GuideCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.GuideTable, + Columns: []string{guidetag.GuideColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gtu.mutation.GuideIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.GuideTable, + Columns: []string{guidetag.GuideColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if gtu.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.TagTable, + Columns: []string{guidetag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gtu.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.TagTable, + Columns: []string{guidetag.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(gtu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, gtu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{guidetag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + gtu.mutation.done = true + return n, nil +} + +// GuideTagUpdateOne is the builder for updating a single GuideTag entity. +type GuideTagUpdateOne struct { + config + fields []string + hooks []Hook + mutation *GuideTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetGuideTag sets the "guide_tag" field. +func (gtuo *GuideTagUpdateOne) SetGuideTag(s string) *GuideTagUpdateOne { + gtuo.mutation.SetGuideTag(s) + return gtuo +} + +// SetTagID sets the "tag_id" field. +func (gtuo *GuideTagUpdateOne) SetTagID(s string) *GuideTagUpdateOne { + gtuo.mutation.SetTagID(s) + return gtuo +} + +// SetGuideID sets the "guide" edge to the Guide entity by ID. +func (gtuo *GuideTagUpdateOne) SetGuideID(id string) *GuideTagUpdateOne { + gtuo.mutation.SetGuideID(id) + return gtuo +} + +// SetGuide sets the "guide" edge to the Guide entity. +func (gtuo *GuideTagUpdateOne) SetGuide(g *Guide) *GuideTagUpdateOne { + return gtuo.SetGuideID(g.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (gtuo *GuideTagUpdateOne) SetTag(t *Tag) *GuideTagUpdateOne { + return gtuo.SetTagID(t.ID) +} + +// Mutation returns the GuideTagMutation object of the builder. +func (gtuo *GuideTagUpdateOne) Mutation() *GuideTagMutation { + return gtuo.mutation +} + +// ClearGuide clears the "guide" edge to the Guide entity. +func (gtuo *GuideTagUpdateOne) ClearGuide() *GuideTagUpdateOne { + gtuo.mutation.ClearGuide() + return gtuo +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (gtuo *GuideTagUpdateOne) ClearTag() *GuideTagUpdateOne { + gtuo.mutation.ClearTag() + return gtuo +} + +// Where appends a list predicates to the GuideTagUpdate builder. +func (gtuo *GuideTagUpdateOne) Where(ps ...predicate.GuideTag) *GuideTagUpdateOne { + gtuo.mutation.Where(ps...) + return gtuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (gtuo *GuideTagUpdateOne) Select(field string, fields ...string) *GuideTagUpdateOne { + gtuo.fields = append([]string{field}, fields...) + return gtuo +} + +// Save executes the query and returns the updated GuideTag entity. +func (gtuo *GuideTagUpdateOne) Save(ctx context.Context) (*GuideTag, error) { + return withHooks(ctx, gtuo.sqlSave, gtuo.mutation, gtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (gtuo *GuideTagUpdateOne) SaveX(ctx context.Context) *GuideTag { + node, err := gtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (gtuo *GuideTagUpdateOne) Exec(ctx context.Context) error { + _, err := gtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (gtuo *GuideTagUpdateOne) ExecX(ctx context.Context) { + if err := gtuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (gtuo *GuideTagUpdateOne) check() error { + if _, ok := gtuo.mutation.GuideID(); gtuo.mutation.GuideCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "GuideTag.guide"`) + } + if _, ok := gtuo.mutation.TagID(); gtuo.mutation.TagCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "GuideTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (gtuo *GuideTagUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GuideTagUpdateOne { + gtuo.modifiers = append(gtuo.modifiers, modifiers...) + return gtuo +} + +func (gtuo *GuideTagUpdateOne) sqlSave(ctx context.Context) (_node *GuideTag, err error) { + if err := gtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideTag, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) + if id, ok := gtuo.mutation.GuideTag(); !ok { + return nil, &ValidationError{Name: "guide_tag", err: errors.New(`ent: missing "GuideTag.guide_tag" for update`)} + } else { + _spec.Node.CompositeID[0].Value = id + } + if id, ok := gtuo.mutation.TagID(); !ok { + return nil, &ValidationError{Name: "tag_id", err: errors.New(`ent: missing "GuideTag.tag_id" for update`)} + } else { + _spec.Node.CompositeID[1].Value = id + } + if fields := gtuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, len(fields)) + for i, f := range fields { + if !guidetag.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + _spec.Node.Columns[i] = f + } + } + if ps := gtuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if gtuo.mutation.GuideCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.GuideTable, + Columns: []string{guidetag.GuideColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gtuo.mutation.GuideIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.GuideTable, + Columns: []string{guidetag.GuideColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if gtuo.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.TagTable, + Columns: []string{guidetag.TagColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := gtuo.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: guidetag.TagTable, + Columns: []string{guidetag.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(gtuo.modifiers...) + _node = &GuideTag{config: gtuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, gtuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{guidetag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + gtuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/hook/hook.go b/generated/ent/hook/hook.go new file mode 100644 index 00000000..01347f9f --- /dev/null +++ b/generated/ent/hook/hook.go @@ -0,0 +1,355 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + + "github.com/satisfactorymodding/smr-api/generated/ent" +) + +// The AnnouncementFunc type is an adapter to allow the use of ordinary +// function as Announcement mutator. +type AnnouncementFunc func(context.Context, *ent.AnnouncementMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f AnnouncementFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.AnnouncementMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AnnouncementMutation", m) +} + +// The GuideFunc type is an adapter to allow the use of ordinary +// function as Guide mutator. +type GuideFunc func(context.Context, *ent.GuideMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f GuideFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.GuideMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GuideMutation", m) +} + +// The GuideTagFunc type is an adapter to allow the use of ordinary +// function as GuideTag mutator. +type GuideTagFunc func(context.Context, *ent.GuideTagMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f GuideTagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.GuideTagMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GuideTagMutation", m) +} + +// The ModFunc type is an adapter to allow the use of ordinary +// function as Mod mutator. +type ModFunc func(context.Context, *ent.ModMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModMutation", m) +} + +// The ModTagFunc type is an adapter to allow the use of ordinary +// function as ModTag mutator. +type ModTagFunc func(context.Context, *ent.ModTagMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ModTagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ModTagMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ModTagMutation", m) +} + +// The SmlVersionFunc type is an adapter to allow the use of ordinary +// function as SmlVersion mutator. +type SmlVersionFunc func(context.Context, *ent.SmlVersionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f SmlVersionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.SmlVersionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SmlVersionMutation", m) +} + +// The SmlVersionTargetFunc type is an adapter to allow the use of ordinary +// function as SmlVersionTarget mutator. +type SmlVersionTargetFunc func(context.Context, *ent.SmlVersionTargetMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f SmlVersionTargetFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.SmlVersionTargetMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SmlVersionTargetMutation", m) +} + +// The TagFunc type is an adapter to allow the use of ordinary +// function as Tag mutator. +type TagFunc func(context.Context, *ent.TagMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f TagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.TagMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TagMutation", m) +} + +// The UserFunc type is an adapter to allow the use of ordinary +// function as User mutator. +type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) +} + +// The UserGroupFunc type is an adapter to allow the use of ordinary +// function as UserGroup mutator. +type UserGroupFunc func(context.Context, *ent.UserGroupMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserGroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserGroupMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserGroupMutation", m) +} + +// The UserModFunc type is an adapter to allow the use of ordinary +// function as UserMod mutator. +type UserModFunc func(context.Context, *ent.UserModMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserModFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserModMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserModMutation", m) +} + +// The UserSessionFunc type is an adapter to allow the use of ordinary +// function as UserSession mutator. +type UserSessionFunc func(context.Context, *ent.UserSessionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserSessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserSessionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserSessionMutation", m) +} + +// The VersionFunc type is an adapter to allow the use of ordinary +// function as Version mutator. +type VersionFunc func(context.Context, *ent.VersionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f VersionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.VersionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VersionMutation", m) +} + +// The VersionDependencyFunc type is an adapter to allow the use of ordinary +// function as VersionDependency mutator. +type VersionDependencyFunc func(context.Context, *ent.VersionDependencyMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f VersionDependencyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.VersionDependencyMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VersionDependencyMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/generated/ent/intercept/intercept.go b/generated/ent/intercept/intercept.go new file mode 100644 index 00000000..63d93251 --- /dev/null +++ b/generated/ent/intercept/intercept.go @@ -0,0 +1,539 @@ +// Code generated by ent, DO NOT EDIT. + +package intercept + +import ( + "context" + "fmt" + + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// The Query interface represents an operation that queries a graph. +// By using this interface, users can write generic code that manipulates +// query builders of different types. +type Query interface { + // Type returns the string representation of the query type. + Type() string + // Limit the number of records to be returned by this query. + Limit(int) + // Offset to start from. + Offset(int) + // Unique configures the query builder to filter duplicate records. + Unique(bool) + // Order specifies how the records should be ordered. + Order(...func(*sql.Selector)) + // WhereP appends storage-level predicates to the query builder. Using this method, users + // can use type-assertion to append predicates that do not depend on any generated package. + WhereP(...func(*sql.Selector)) +} + +// The Func type is an adapter that allows ordinary functions to be used as interceptors. +// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the +// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. +type Func func(context.Context, Query) error + +// Intercept calls f(ctx, q) and then applied the next Querier. +func (f Func) Intercept(next ent.Querier) ent.Querier { + return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { + query, err := NewQuery(q) + if err != nil { + return nil, err + } + if err := f(ctx, query); err != nil { + return nil, err + } + return next.Query(ctx, q) + }) +} + +// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. +// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. +type TraverseFunc func(context.Context, Query) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { + query, err := NewQuery(q) + if err != nil { + return err + } + return f(ctx, query) +} + +// The AnnouncementFunc type is an adapter to allow the use of ordinary function as a Querier. +type AnnouncementFunc func(context.Context, *ent.AnnouncementQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f AnnouncementFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.AnnouncementQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.AnnouncementQuery", q) +} + +// The TraverseAnnouncement type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAnnouncement func(context.Context, *ent.AnnouncementQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAnnouncement) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAnnouncement) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.AnnouncementQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.AnnouncementQuery", q) +} + +// The GuideFunc type is an adapter to allow the use of ordinary function as a Querier. +type GuideFunc func(context.Context, *ent.GuideQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f GuideFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.GuideQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.GuideQuery", q) +} + +// The TraverseGuide type is an adapter to allow the use of ordinary function as Traverser. +type TraverseGuide func(context.Context, *ent.GuideQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseGuide) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseGuide) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.GuideQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.GuideQuery", q) +} + +// The GuideTagFunc type is an adapter to allow the use of ordinary function as a Querier. +type GuideTagFunc func(context.Context, *ent.GuideTagQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f GuideTagFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.GuideTagQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.GuideTagQuery", q) +} + +// The TraverseGuideTag type is an adapter to allow the use of ordinary function as Traverser. +type TraverseGuideTag func(context.Context, *ent.GuideTagQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseGuideTag) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseGuideTag) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.GuideTagQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.GuideTagQuery", q) +} + +// The ModFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModFunc func(context.Context, *ent.ModQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModQuery", q) +} + +// The TraverseMod type is an adapter to allow the use of ordinary function as Traverser. +type TraverseMod func(context.Context, *ent.ModQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseMod) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseMod) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModQuery", q) +} + +// The ModTagFunc type is an adapter to allow the use of ordinary function as a Querier. +type ModTagFunc func(context.Context, *ent.ModTagQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ModTagFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ModTagQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ModTagQuery", q) +} + +// The TraverseModTag type is an adapter to allow the use of ordinary function as Traverser. +type TraverseModTag func(context.Context, *ent.ModTagQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseModTag) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseModTag) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ModTagQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ModTagQuery", q) +} + +// The SmlVersionFunc type is an adapter to allow the use of ordinary function as a Querier. +type SmlVersionFunc func(context.Context, *ent.SmlVersionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f SmlVersionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.SmlVersionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.SmlVersionQuery", q) +} + +// The TraverseSmlVersion type is an adapter to allow the use of ordinary function as Traverser. +type TraverseSmlVersion func(context.Context, *ent.SmlVersionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseSmlVersion) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseSmlVersion) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.SmlVersionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.SmlVersionQuery", q) +} + +// The SmlVersionTargetFunc type is an adapter to allow the use of ordinary function as a Querier. +type SmlVersionTargetFunc func(context.Context, *ent.SmlVersionTargetQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f SmlVersionTargetFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.SmlVersionTargetQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.SmlVersionTargetQuery", q) +} + +// The TraverseSmlVersionTarget type is an adapter to allow the use of ordinary function as Traverser. +type TraverseSmlVersionTarget func(context.Context, *ent.SmlVersionTargetQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseSmlVersionTarget) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseSmlVersionTarget) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.SmlVersionTargetQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.SmlVersionTargetQuery", q) +} + +// The TagFunc type is an adapter to allow the use of ordinary function as a Querier. +type TagFunc func(context.Context, *ent.TagQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f TagFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.TagQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.TagQuery", q) +} + +// The TraverseTag type is an adapter to allow the use of ordinary function as Traverser. +type TraverseTag func(context.Context, *ent.TagQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseTag) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseTag) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.TagQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.TagQuery", q) +} + +// The UserFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserFunc func(context.Context, *ent.UserQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUser func(context.Context, *ent.UserQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUser) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUser) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The UserGroupFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserGroupFunc func(context.Context, *ent.UserGroupQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserGroupFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserGroupQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserGroupQuery", q) +} + +// The TraverseUserGroup type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserGroup func(context.Context, *ent.UserGroupQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserGroup) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserGroup) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserGroupQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserGroupQuery", q) +} + +// The UserModFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserModFunc func(context.Context, *ent.UserModQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserModFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserModQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserModQuery", q) +} + +// The TraverseUserMod type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserMod func(context.Context, *ent.UserModQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserMod) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserMod) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserModQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserModQuery", q) +} + +// The UserSessionFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserSessionFunc func(context.Context, *ent.UserSessionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserSessionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserSessionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserSessionQuery", q) +} + +// The TraverseUserSession type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserSession func(context.Context, *ent.UserSessionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserSession) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserSession) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserSessionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserSessionQuery", q) +} + +// The VersionFunc type is an adapter to allow the use of ordinary function as a Querier. +type VersionFunc func(context.Context, *ent.VersionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f VersionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.VersionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.VersionQuery", q) +} + +// The TraverseVersion type is an adapter to allow the use of ordinary function as Traverser. +type TraverseVersion func(context.Context, *ent.VersionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseVersion) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseVersion) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.VersionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.VersionQuery", q) +} + +// The VersionDependencyFunc type is an adapter to allow the use of ordinary function as a Querier. +type VersionDependencyFunc func(context.Context, *ent.VersionDependencyQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f VersionDependencyFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.VersionDependencyQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.VersionDependencyQuery", q) +} + +// The TraverseVersionDependency type is an adapter to allow the use of ordinary function as Traverser. +type TraverseVersionDependency func(context.Context, *ent.VersionDependencyQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseVersionDependency) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseVersionDependency) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.VersionDependencyQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.VersionDependencyQuery", q) +} + +// NewQuery returns the generic Query interface for the given typed query. +func NewQuery(q ent.Query) (Query, error) { + switch q := q.(type) { + case *ent.AnnouncementQuery: + return &query[*ent.AnnouncementQuery, predicate.Announcement, announcement.OrderOption]{typ: ent.TypeAnnouncement, tq: q}, nil + case *ent.GuideQuery: + return &query[*ent.GuideQuery, predicate.Guide, guide.OrderOption]{typ: ent.TypeGuide, tq: q}, nil + case *ent.GuideTagQuery: + return &query[*ent.GuideTagQuery, predicate.GuideTag, guidetag.OrderOption]{typ: ent.TypeGuideTag, tq: q}, nil + case *ent.ModQuery: + 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.SmlVersionQuery: + return &query[*ent.SmlVersionQuery, predicate.SmlVersion, smlversion.OrderOption]{typ: ent.TypeSmlVersion, tq: q}, nil + case *ent.SmlVersionTargetQuery: + return &query[*ent.SmlVersionTargetQuery, predicate.SmlVersionTarget, smlversiontarget.OrderOption]{typ: ent.TypeSmlVersionTarget, tq: q}, nil + case *ent.TagQuery: + return &query[*ent.TagQuery, predicate.Tag, tag.OrderOption]{typ: ent.TypeTag, tq: q}, nil + case *ent.UserQuery: + return &query[*ent.UserQuery, predicate.User, user.OrderOption]{typ: ent.TypeUser, tq: q}, nil + case *ent.UserGroupQuery: + return &query[*ent.UserGroupQuery, predicate.UserGroup, usergroup.OrderOption]{typ: ent.TypeUserGroup, tq: q}, nil + case *ent.UserModQuery: + return &query[*ent.UserModQuery, predicate.UserMod, usermod.OrderOption]{typ: ent.TypeUserMod, tq: q}, nil + case *ent.UserSessionQuery: + return &query[*ent.UserSessionQuery, predicate.UserSession, usersession.OrderOption]{typ: ent.TypeUserSession, tq: q}, nil + case *ent.VersionQuery: + return &query[*ent.VersionQuery, predicate.Version, version.OrderOption]{typ: ent.TypeVersion, tq: q}, nil + case *ent.VersionDependencyQuery: + return &query[*ent.VersionDependencyQuery, predicate.VersionDependency, versiondependency.OrderOption]{typ: ent.TypeVersionDependency, tq: q}, nil + default: + return nil, fmt.Errorf("unknown query type %T", q) + } +} + +type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { + typ string + tq interface { + Limit(int) T + Offset(int) T + Unique(bool) T + Order(...R) T + Where(...P) T + } +} + +func (q query[T, P, R]) Type() string { + return q.typ +} + +func (q query[T, P, R]) Limit(limit int) { + q.tq.Limit(limit) +} + +func (q query[T, P, R]) Offset(offset int) { + q.tq.Offset(offset) +} + +func (q query[T, P, R]) Unique(unique bool) { + q.tq.Unique(unique) +} + +func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { + rs := make([]R, len(orders)) + for i := range orders { + rs[i] = orders[i] + } + q.tq.Order(rs...) +} + +func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { + p := make([]P, len(ps)) + for i := range ps { + p[i] = ps[i] + } + q.tq.Where(p...) +} diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go new file mode 100644 index 00000000..742d9dda --- /dev/null +++ b/generated/ent/internal/schema.go @@ -0,0 +1,9 @@ +// Code generated by ent, DO NOT EDIT. + +//go:build tools +// +build tools + +// 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":["id"]},{"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","ref_name":"guides","unique":true,"inverse":true,"required":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":"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":"guide","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"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_tag","unique":true,"required":true},{"name":"tag","type":"Tag","field":"tag_id","unique":true,"required":true}],"fields":[{"name":"guide_tag","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_tag","tag_id"],"StructTag":null}}},{"name":"Mod","config":{"Table":""},"edges":[{"name":"versions","type":"Version","storage_key":{"Table":"","Symbols":null,"Columns":["mod_id"]}},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"MixedIn":false,"MixinIndex":0}},{"name":"popularity","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"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":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"hidden","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"compatibility","type":{"Type":3,"Ident":"*postgres.CompatibilityInfo","PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","PkgName":"postgres","Nillable":true,"RType":{"Name":"CompatibilityInfo","Ident":"postgres.CompatibilityInfo","Kind":22,"PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","Methods":{}}},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"smlversion.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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","storage_key":{"Table":"","Symbols":null,"Columns":["user_id"]}},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"Version","config":{"Table":""},"edges":[{"name":"mod","type":"Mod","ref_name":"versions","unique":true,"inverse":true,"required":true},{"name":"dependencies","type":"Mod","through":{"N":"version_dependencies","T":"VersionDependency"}}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"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":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"version.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":5,"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":6,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"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":8,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"validators":2,"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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}}}],"Features":["sql/modifier","intercept","schema/snapshot","sql/execquery"]}` diff --git a/generated/ent/migrate/migrate.go b/generated/ent/migrate/migrate.go new file mode 100644 index 00000000..1956a6bf --- /dev/null +++ b/generated/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/generated/ent/migrate/schema.go b/generated/ent/migrate/schema.go new file mode 100644 index 00000000..37104bf6 --- /dev/null +++ b/generated/ent/migrate/schema.go @@ -0,0 +1,540 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // AnnouncementsColumns holds the columns for the "announcements" table. + AnnouncementsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "message", Type: field.TypeString}, + {Name: "importance", Type: field.TypeString}, + } + // AnnouncementsTable holds the schema information for the "announcements" table. + AnnouncementsTable = &schema.Table{ + Name: "announcements", + Columns: AnnouncementsColumns, + PrimaryKey: []*schema.Column{AnnouncementsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "announcement_id", + Unique: false, + Columns: []*schema.Column{AnnouncementsColumns[0]}, + }, + { + Name: "announcement_deleted_at", + Unique: false, + Columns: []*schema.Column{AnnouncementsColumns[3]}, + }, + }, + } + // GuidesColumns holds the columns for the "guides" table. + GuidesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString, Size: 32}, + {Name: "short_description", Type: field.TypeString, Size: 128}, + {Name: "guide", Type: field.TypeString}, + {Name: "views", Type: field.TypeInt}, + {Name: "user_id", Type: field.TypeString}, + } + // GuidesTable holds the schema information for the "guides" table. + GuidesTable = &schema.Table{ + Name: "guides", + Columns: GuidesColumns, + PrimaryKey: []*schema.Column{GuidesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "guides_users_guides", + Columns: []*schema.Column{GuidesColumns[8]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "guide_id", + Unique: false, + Columns: []*schema.Column{GuidesColumns[0]}, + }, + { + Name: "guide_deleted_at", + Unique: false, + Columns: []*schema.Column{GuidesColumns[3]}, + }, + }, + } + // GuideTagsColumns holds the columns for the "guide_tags" table. + GuideTagsColumns = []*schema.Column{ + {Name: "guide_tag", Type: field.TypeString}, + {Name: "tag_id", Type: field.TypeString}, + } + // GuideTagsTable holds the schema information for the "guide_tags" table. + GuideTagsTable = &schema.Table{ + Name: "guide_tags", + Columns: GuideTagsColumns, + PrimaryKey: []*schema.Column{GuideTagsColumns[0], GuideTagsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "guide_tags_guides_guide", + Columns: []*schema.Column{GuideTagsColumns[0]}, + RefColumns: []*schema.Column{GuidesColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "guide_tags_tags_tag", + Columns: []*schema.Column{GuideTagsColumns[1]}, + RefColumns: []*schema.Column{TagsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } + // ModsColumns holds the columns for the "mods" table. + ModsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString, Size: 32}, + {Name: "short_description", Type: field.TypeString, Size: 128}, + {Name: "full_description", Type: field.TypeString}, + {Name: "logo", Type: field.TypeString}, + {Name: "source_url", Type: field.TypeString}, + {Name: "creator_id", Type: field.TypeString}, + {Name: "approved", Type: field.TypeBool, Default: false}, + {Name: "views", Type: field.TypeUint}, + {Name: "hotness", Type: field.TypeUint}, + {Name: "popularity", Type: field.TypeUint}, + {Name: "downloads", Type: field.TypeUint}, + {Name: "denied", Type: field.TypeBool, Default: false}, + {Name: "last_version_date", Type: field.TypeTime}, + {Name: "mod_reference", Type: field.TypeString, Unique: true, Size: 32}, + {Name: "hidden", Type: field.TypeBool}, + {Name: "compatibility", Type: field.TypeJSON}, + } + // ModsTable holds the schema information for the "mods" table. + ModsTable = &schema.Table{ + Name: "mods", + Columns: ModsColumns, + PrimaryKey: []*schema.Column{ModsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "mod_id", + Unique: false, + Columns: []*schema.Column{ModsColumns[0]}, + }, + { + Name: "mod_deleted_at", + Unique: false, + Columns: []*schema.Column{ModsColumns[3]}, + }, + { + Name: "mod_last_version_date", + Unique: false, + Columns: []*schema.Column{ModsColumns[16]}, + }, + }, + } + // ModTagsColumns holds the columns for the "mod_tags" table. + ModTagsColumns = []*schema.Column{ + {Name: "mod_id", Type: field.TypeString}, + {Name: "tag_id", Type: field.TypeString}, + } + // ModTagsTable holds the schema information for the "mod_tags" table. + ModTagsTable = &schema.Table{ + Name: "mod_tags", + Columns: ModTagsColumns, + PrimaryKey: []*schema.Column{ModTagsColumns[0], ModTagsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "mod_tags_mods_mod", + Columns: []*schema.Column{ModTagsColumns[0]}, + RefColumns: []*schema.Column{ModsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "mod_tags_tags_tag", + Columns: []*schema.Column{ModTagsColumns[1]}, + RefColumns: []*schema.Column{TagsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } + // SmlVersionsColumns holds the columns for the "sml_versions" table. + SmlVersionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "version", Type: field.TypeString, Unique: true, Size: 32}, + {Name: "satisfactory_version", Type: field.TypeInt}, + {Name: "stability", Type: field.TypeEnum, Enums: []string{"alpha", "beta", "release"}}, + {Name: "date", Type: field.TypeTime}, + {Name: "link", Type: field.TypeString}, + {Name: "changelog", Type: field.TypeString}, + {Name: "bootstrap_version", Type: field.TypeString, Nullable: true, Size: 14}, + {Name: "engine_version", Type: field.TypeString, Size: 16, Default: "4.26"}, + } + // SmlVersionsTable holds the schema information for the "sml_versions" table. + SmlVersionsTable = &schema.Table{ + Name: "sml_versions", + Columns: SmlVersionsColumns, + PrimaryKey: []*schema.Column{SmlVersionsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "smlversion_id", + Unique: false, + Columns: []*schema.Column{SmlVersionsColumns[0]}, + }, + { + Name: "smlversion_deleted_at", + Unique: false, + Columns: []*schema.Column{SmlVersionsColumns[3]}, + }, + }, + } + // SmlVersionTargetsColumns holds the columns for the "sml_version_targets" table. + SmlVersionTargetsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "target_name", Type: field.TypeString}, + {Name: "link", Type: field.TypeString}, + {Name: "version_id", Type: field.TypeString}, + } + // SmlVersionTargetsTable holds the schema information for the "sml_version_targets" table. + SmlVersionTargetsTable = &schema.Table{ + Name: "sml_version_targets", + Columns: SmlVersionTargetsColumns, + PrimaryKey: []*schema.Column{SmlVersionTargetsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sml_version_targets_sml_versions_targets", + Columns: []*schema.Column{SmlVersionTargetsColumns[3]}, + RefColumns: []*schema.Column{SmlVersionsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "smlversiontarget_id", + Unique: false, + Columns: []*schema.Column{SmlVersionTargetsColumns[0]}, + }, + { + Name: "smlversiontarget_version_id_target_name", + Unique: true, + Columns: []*schema.Column{SmlVersionTargetsColumns[3], SmlVersionTargetsColumns[1]}, + }, + }, + } + // TagsColumns holds the columns for the "tags" table. + TagsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString, Unique: true, Size: 24}, + } + // TagsTable holds the schema information for the "tags" table. + TagsTable = &schema.Table{ + Name: "tags", + Columns: TagsColumns, + PrimaryKey: []*schema.Column{TagsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "tag_id", + Unique: false, + Columns: []*schema.Column{TagsColumns[0]}, + }, + { + Name: "tag_deleted_at", + Unique: false, + Columns: []*schema.Column{TagsColumns[3]}, + }, + }, + } + // UsersColumns holds the columns for the "users" table. + UsersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "email", Type: field.TypeString, Unique: true, Size: 256}, + {Name: "username", Type: field.TypeString, Size: 32}, + {Name: "avatar", Type: field.TypeString, Nullable: true}, + {Name: "joined_from", Type: field.TypeString, Nullable: true}, + {Name: "banned", Type: field.TypeBool, Default: false}, + {Name: "rank", Type: field.TypeInt, Default: 1}, + {Name: "github_id", Type: field.TypeString, Unique: true, Nullable: true, Size: 16}, + {Name: "google_id", Type: field.TypeString, Unique: true, Nullable: true, Size: 16}, + {Name: "facebook_id", Type: field.TypeString, Unique: true, Nullable: true, Size: 16}, + } + // UsersTable holds the schema information for the "users" table. + UsersTable = &schema.Table{ + Name: "users", + Columns: UsersColumns, + PrimaryKey: []*schema.Column{UsersColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "user_id", + Unique: false, + Columns: []*schema.Column{UsersColumns[0]}, + }, + { + Name: "user_deleted_at", + Unique: false, + Columns: []*schema.Column{UsersColumns[3]}, + }, + { + Name: "user_email", + Unique: false, + Columns: []*schema.Column{UsersColumns[4]}, + }, + { + Name: "user_github_id", + Unique: false, + Columns: []*schema.Column{UsersColumns[10]}, + }, + { + Name: "user_google_id", + Unique: false, + Columns: []*schema.Column{UsersColumns[11]}, + }, + { + Name: "user_facebook_id", + Unique: false, + Columns: []*schema.Column{UsersColumns[12]}, + }, + }, + } + // UserGroupsColumns holds the columns for the "user_groups" table. + UserGroupsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "group_id", Type: field.TypeString, Size: 14}, + {Name: "user_id", Type: field.TypeString}, + } + // UserGroupsTable holds the schema information for the "user_groups" table. + UserGroupsTable = &schema.Table{ + Name: "user_groups", + Columns: UserGroupsColumns, + PrimaryKey: []*schema.Column{UserGroupsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "user_groups_users_groups", + Columns: []*schema.Column{UserGroupsColumns[5]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "usergroup_id", + Unique: false, + Columns: []*schema.Column{UserGroupsColumns[0]}, + }, + { + Name: "usergroup_deleted_at", + Unique: false, + Columns: []*schema.Column{UserGroupsColumns[3]}, + }, + { + Name: "usergroup_user_id_group_id", + Unique: true, + Columns: []*schema.Column{UserGroupsColumns[5], UserGroupsColumns[4]}, + }, + }, + } + // UserModsColumns holds the columns for the "user_mods" table. + UserModsColumns = []*schema.Column{ + {Name: "role", Type: field.TypeString}, + {Name: "user_id", Type: field.TypeString}, + {Name: "mod_id", Type: field.TypeString}, + } + // UserModsTable holds the schema information for the "user_mods" table. + UserModsTable = &schema.Table{ + Name: "user_mods", + Columns: UserModsColumns, + PrimaryKey: []*schema.Column{UserModsColumns[1], UserModsColumns[2]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "user_mods_users_user", + Columns: []*schema.Column{UserModsColumns[1]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "user_mods_mods_mod", + Columns: []*schema.Column{UserModsColumns[2]}, + RefColumns: []*schema.Column{ModsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } + // UserSessionsColumns holds the columns for the "user_sessions" table. + UserSessionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "token", Type: field.TypeString, Unique: true, Size: 256}, + {Name: "user_agent", Type: field.TypeString, Nullable: true}, + {Name: "user_id", Type: field.TypeString}, + } + // UserSessionsTable holds the schema information for the "user_sessions" table. + UserSessionsTable = &schema.Table{ + Name: "user_sessions", + Columns: UserSessionsColumns, + PrimaryKey: []*schema.Column{UserSessionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "user_sessions_users_sessions", + Columns: []*schema.Column{UserSessionsColumns[6]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "usersession_id", + Unique: false, + Columns: []*schema.Column{UserSessionsColumns[0]}, + }, + { + Name: "usersession_deleted_at", + Unique: false, + Columns: []*schema.Column{UserSessionsColumns[3]}, + }, + }, + } + // VersionsColumns holds the columns for the "versions" table. + VersionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "version", Type: field.TypeString, Size: 16}, + {Name: "sml_version", Type: field.TypeString, Size: 16}, + {Name: "changelog", Type: field.TypeString}, + {Name: "downloads", Type: field.TypeUint}, + {Name: "key", Type: field.TypeString}, + {Name: "stability", Type: field.TypeEnum, Enums: []string{"alpha", "beta", "release"}}, + {Name: "approved", Type: field.TypeBool, Default: false}, + {Name: "hotness", Type: field.TypeUint}, + {Name: "denied", Type: field.TypeBool, Default: false}, + {Name: "metadata", Type: field.TypeString}, + {Name: "mod_reference", Type: field.TypeString, Size: 32}, + {Name: "version_major", Type: field.TypeInt}, + {Name: "version_minor", Type: field.TypeInt}, + {Name: "version_patch", Type: field.TypeInt}, + {Name: "size", Type: field.TypeInt64}, + {Name: "hash", Type: field.TypeString, Size: 64}, + {Name: "mod_id", Type: field.TypeString}, + } + // VersionsTable holds the schema information for the "versions" table. + VersionsTable = &schema.Table{ + Name: "versions", + Columns: VersionsColumns, + PrimaryKey: []*schema.Column{VersionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "versions_mods_versions", + Columns: []*schema.Column{VersionsColumns[20]}, + RefColumns: []*schema.Column{ModsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "version_id", + Unique: false, + Columns: []*schema.Column{VersionsColumns[0]}, + }, + { + Name: "version_deleted_at", + Unique: false, + Columns: []*schema.Column{VersionsColumns[3]}, + }, + }, + } + // VersionDependenciesColumns holds the columns for the "version_dependencies" table. + VersionDependenciesColumns = []*schema.Column{ + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "condition", Type: field.TypeString, Size: 64}, + {Name: "optional", Type: field.TypeBool}, + {Name: "version_id", Type: field.TypeString}, + {Name: "mod_id", Type: field.TypeString}, + } + // VersionDependenciesTable holds the schema information for the "version_dependencies" table. + VersionDependenciesTable = &schema.Table{ + Name: "version_dependencies", + Columns: VersionDependenciesColumns, + PrimaryKey: []*schema.Column{VersionDependenciesColumns[5], VersionDependenciesColumns[6]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "version_dependencies_versions_version", + Columns: []*schema.Column{VersionDependenciesColumns[5]}, + RefColumns: []*schema.Column{VersionsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "version_dependencies_mods_mod", + Columns: []*schema.Column{VersionDependenciesColumns[6]}, + RefColumns: []*schema.Column{ModsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "versiondependency_deleted_at", + Unique: false, + Columns: []*schema.Column{VersionDependenciesColumns[2]}, + }, + }, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + AnnouncementsTable, + GuidesTable, + GuideTagsTable, + ModsTable, + ModTagsTable, + SmlVersionsTable, + SmlVersionTargetsTable, + TagsTable, + UsersTable, + UserGroupsTable, + UserModsTable, + UserSessionsTable, + VersionsTable, + VersionDependenciesTable, + } +) + +func init() { + GuidesTable.ForeignKeys[0].RefTable = UsersTable + GuideTagsTable.ForeignKeys[0].RefTable = GuidesTable + GuideTagsTable.ForeignKeys[1].RefTable = TagsTable + ModTagsTable.ForeignKeys[0].RefTable = ModsTable + ModTagsTable.ForeignKeys[1].RefTable = TagsTable + SmlVersionTargetsTable.ForeignKeys[0].RefTable = SmlVersionsTable + UserGroupsTable.ForeignKeys[0].RefTable = UsersTable + UserModsTable.ForeignKeys[0].RefTable = UsersTable + UserModsTable.ForeignKeys[1].RefTable = ModsTable + UserSessionsTable.ForeignKeys[0].RefTable = UsersTable + VersionsTable.ForeignKeys[0].RefTable = ModsTable + VersionDependenciesTable.ForeignKeys[0].RefTable = VersionsTable + VersionDependenciesTable.ForeignKeys[1].RefTable = ModsTable +} diff --git a/generated/ent/mod.go b/generated/ent/mod.go new file mode 100644 index 00000000..7c7bbeb4 --- /dev/null +++ b/generated/ent/mod.go @@ -0,0 +1,434 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" +) + +// Mod is the model entity for the Mod schema. +type Mod 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_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"` + // SourceURL holds the value of the "source_url" field. + SourceURL string `json:"source_url,omitempty"` + // CreatorID holds the value of the "creator_id" field. + CreatorID string `json:"creator_id,omitempty"` + // Approved holds the value of the "approved" field. + Approved bool `json:"approved,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"` + // Popularity holds the value of the "popularity" field. + Popularity uint `json:"popularity,omitempty"` + // Downloads holds the value of the "downloads" field. + Downloads uint `json:"downloads,omitempty"` + // Denied holds the value of the "denied" field. + Denied bool `json:"denied,omitempty"` + // LastVersionDate holds the value of the "last_version_date" field. + LastVersionDate time.Time `json:"last_version_date,omitempty"` + // ModReference holds the value of the "mod_reference" field. + ModReference string `json:"mod_reference,omitempty"` + // Hidden holds the value of the "hidden" field. + Hidden bool `json:"hidden,omitempty"` + // Compatibility holds the value of the "compatibility" field. + Compatibility *postgres.CompatibilityInfo `json:"compatibility,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ModQuery when eager-loading is set. + Edges ModEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModEdges holds the relations/edges for other nodes in the graph. +type ModEdges struct { + // Versions holds the value of the versions edge. + Versions []*Version `json:"versions,omitempty"` + // Authors holds the value of the authors edge. + Authors []*User `json:"authors,omitempty"` + // Tags holds the value of the tags edge. + Tags []*Tag `json:"tags,omitempty"` + // Dependents holds the value of the dependents edge. + Dependents []*Version `json:"dependents,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"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [7]bool +} + +// VersionsOrErr returns the Versions value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) VersionsOrErr() ([]*Version, error) { + if e.loadedTypes[0] { + return e.Versions, nil + } + return nil, &NotLoadedError{edge: "versions"} +} + +// AuthorsOrErr returns the Authors value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) AuthorsOrErr() ([]*User, error) { + if e.loadedTypes[1] { + return e.Authors, nil + } + return nil, &NotLoadedError{edge: "authors"} +} + +// TagsOrErr returns the Tags value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) TagsOrErr() ([]*Tag, error) { + if e.loadedTypes[2] { + return e.Tags, nil + } + return nil, &NotLoadedError{edge: "tags"} +} + +// DependentsOrErr returns the Dependents value or an error if the edge +// was not loaded in eager-loading. +func (e ModEdges) DependentsOrErr() ([]*Version, error) { + if e.loadedTypes[3] { + return e.Dependents, nil + } + return nil, &NotLoadedError{edge: "dependents"} +} + +// 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] { + return e.UserMods, nil + } + return nil, &NotLoadedError{edge: "user_mods"} +} + +// 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] { + return e.ModTags, nil + } + return nil, &NotLoadedError{edge: "mod_tags"} +} + +// 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] { + return e.VersionDependencies, nil + } + return nil, &NotLoadedError{edge: "version_dependencies"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Mod) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case mod.FieldCompatibility: + values[i] = new([]byte) + case mod.FieldApproved, mod.FieldDenied, mod.FieldHidden: + values[i] = new(sql.NullBool) + case mod.FieldViews, mod.FieldHotness, mod.FieldPopularity, mod.FieldDownloads: + values[i] = new(sql.NullInt64) + case mod.FieldID, mod.FieldName, mod.FieldShortDescription, mod.FieldFullDescription, mod.FieldLogo, mod.FieldSourceURL, mod.FieldCreatorID, mod.FieldModReference: + values[i] = new(sql.NullString) + case mod.FieldCreatedAt, mod.FieldUpdatedAt, mod.FieldDeletedAt, mod.FieldLastVersionDate: + 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 Mod fields. +func (m *Mod) 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 mod.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 mod.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 mod.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 mod.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + m.DeletedAt = value.Time + } + case mod.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 mod.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 mod.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 mod.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 mod.FieldSourceURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source_url", values[i]) + } else if value.Valid { + m.SourceURL = value.String + } + case mod.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 mod.FieldApproved: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field approved", values[i]) + } else if value.Valid { + m.Approved = value.Bool + } + case mod.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 mod.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 mod.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 mod.FieldDownloads: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field downloads", values[i]) + } else if value.Valid { + m.Downloads = uint(value.Int64) + } + case mod.FieldDenied: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field denied", values[i]) + } else if value.Valid { + m.Denied = value.Bool + } + case mod.FieldLastVersionDate: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_version_date", values[i]) + } else if value.Valid { + m.LastVersionDate = value.Time + } + case mod.FieldModReference: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mod_reference", values[i]) + } else if value.Valid { + m.ModReference = value.String + } + case mod.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 mod.FieldCompatibility: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field compatibility", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &m.Compatibility); err != nil { + return fmt.Errorf("unmarshal field compatibility: %w", err) + } + } + default: + m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Mod. +// This includes values selected through modifiers, order, etc. +func (m *Mod) Value(name string) (ent.Value, error) { + return m.selectValues.Get(name) +} + +// QueryVersions queries the "versions" edge of the Mod entity. +func (m *Mod) QueryVersions() *VersionQuery { + return NewModClient(m.config).QueryVersions(m) +} + +// QueryAuthors queries the "authors" edge of the Mod entity. +func (m *Mod) QueryAuthors() *UserQuery { + return NewModClient(m.config).QueryAuthors(m) +} + +// QueryTags queries the "tags" edge of the Mod entity. +func (m *Mod) QueryTags() *TagQuery { + return NewModClient(m.config).QueryTags(m) +} + +// QueryDependents queries the "dependents" edge of the Mod entity. +func (m *Mod) QueryDependents() *VersionQuery { + return NewModClient(m.config).QueryDependents(m) +} + +// QueryUserMods queries the "user_mods" edge of the Mod entity. +func (m *Mod) QueryUserMods() *UserModQuery { + return NewModClient(m.config).QueryUserMods(m) +} + +// QueryModTags queries the "mod_tags" edge of the Mod entity. +func (m *Mod) QueryModTags() *ModTagQuery { + return NewModClient(m.config).QueryModTags(m) +} + +// QueryVersionDependencies queries the "version_dependencies" edge of the Mod entity. +func (m *Mod) QueryVersionDependencies() *VersionDependencyQuery { + return NewModClient(m.config).QueryVersionDependencies(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. +func (m *Mod) Update() *ModUpdateOne { + return NewModClient(m.config).UpdateOne(m) +} + +// Unwrap unwraps the Mod 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 *Mod) Unwrap() *Mod { + _tx, ok := m.config.driver.(*txDriver) + if !ok { + panic("ent: Mod is not a transactional entity") + } + m.config.driver = _tx.drv + return m +} + +// String implements the fmt.Stringer. +func (m *Mod) String() string { + var builder strings.Builder + builder.WriteString("Mod(") + 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("deleted_at=") + builder.WriteString(m.DeletedAt.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("source_url=") + builder.WriteString(m.SourceURL) + builder.WriteString(", ") + builder.WriteString("creator_id=") + builder.WriteString(m.CreatorID) + builder.WriteString(", ") + builder.WriteString("approved=") + builder.WriteString(fmt.Sprintf("%v", m.Approved)) + 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("popularity=") + builder.WriteString(fmt.Sprintf("%v", m.Popularity)) + builder.WriteString(", ") + builder.WriteString("downloads=") + builder.WriteString(fmt.Sprintf("%v", m.Downloads)) + builder.WriteString(", ") + builder.WriteString("denied=") + builder.WriteString(fmt.Sprintf("%v", m.Denied)) + builder.WriteString(", ") + builder.WriteString("last_version_date=") + builder.WriteString(m.LastVersionDate.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("mod_reference=") + builder.WriteString(m.ModReference) + builder.WriteString(", ") + builder.WriteString("hidden=") + builder.WriteString(fmt.Sprintf("%v", m.Hidden)) + builder.WriteString(", ") + builder.WriteString("compatibility=") + builder.WriteString(fmt.Sprintf("%v", m.Compatibility)) + builder.WriteByte(')') + return builder.String() +} + +// Mods is a parsable slice of Mod. +type Mods []*Mod diff --git a/generated/ent/mod/mod.go b/generated/ent/mod/mod.go new file mode 100644 index 00000000..ebda24d3 --- /dev/null +++ b/generated/ent/mod/mod.go @@ -0,0 +1,434 @@ +// Code generated by ent, DO NOT EDIT. + +package mod + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the mod type in the database. + Label = "mod" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_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" + // FieldSourceURL holds the string denoting the source_url field in the database. + FieldSourceURL = "source_url" + // FieldCreatorID holds the string denoting the creator_id field in the database. + FieldCreatorID = "creator_id" + // FieldApproved holds the string denoting the approved field in the database. + FieldApproved = "approved" + // 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" + // FieldPopularity holds the string denoting the popularity field in the database. + FieldPopularity = "popularity" + // FieldDownloads holds the string denoting the downloads field in the database. + FieldDownloads = "downloads" + // FieldDenied holds the string denoting the denied field in the database. + FieldDenied = "denied" + // FieldLastVersionDate holds the string denoting the last_version_date field in the database. + FieldLastVersionDate = "last_version_date" + // FieldModReference holds the string denoting the mod_reference field in the database. + FieldModReference = "mod_reference" + // FieldHidden holds the string denoting the hidden field in the database. + FieldHidden = "hidden" + // FieldCompatibility holds the string denoting the compatibility field in the database. + FieldCompatibility = "compatibility" + // EdgeVersions holds the string denoting the versions edge name in mutations. + EdgeVersions = "versions" + // EdgeAuthors holds the string denoting the authors edge name in mutations. + EdgeAuthors = "authors" + // EdgeTags holds the string denoting the tags edge name in mutations. + EdgeTags = "tags" + // EdgeDependents holds the string denoting the dependents edge name in mutations. + EdgeDependents = "dependents" + // 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" + // Table holds the table name of the mod in the database. + Table = "mods" + // VersionsTable is the table that holds the versions relation/edge. + VersionsTable = "versions" + // VersionsInverseTable is the table name for the Version entity. + // It exists in this package in order to avoid circular dependency with the "version" package. + VersionsInverseTable = "versions" + // VersionsColumn is the table column denoting the versions relation/edge. + VersionsColumn = "mod_id" + // AuthorsTable is the table that holds the authors relation/edge. The primary key declared below. + AuthorsTable = "user_mods" + // AuthorsInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + AuthorsInverseTable = "users" + // TagsTable is the table that holds the tags relation/edge. The primary key declared below. + TagsTable = "mod_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" + // DependentsTable is the table that holds the dependents relation/edge. The primary key declared below. + DependentsTable = "version_dependencies" + // 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" + // UserModsTable is the table that holds the user_mods relation/edge. + UserModsTable = "user_mods" + // UserModsInverseTable is the table name for the UserMod entity. + // It exists in this package in order to avoid circular dependency with the "usermod" package. + UserModsInverseTable = "user_mods" + // UserModsColumn is the table column denoting the user_mods relation/edge. + UserModsColumn = "mod_id" + // ModTagsTable is the table that holds the mod_tags relation/edge. + ModTagsTable = "mod_tags" + // ModTagsInverseTable is the table name for the ModTag entity. + // It exists in this package in order to avoid circular dependency with the "modtag" package. + ModTagsInverseTable = "mod_tags" + // ModTagsColumn is the table column denoting the mod_tags relation/edge. + ModTagsColumn = "mod_id" + // VersionDependenciesTable is the table that holds the version_dependencies relation/edge. + VersionDependenciesTable = "version_dependencies" + // VersionDependenciesInverseTable is the table name for the VersionDependency entity. + // It exists in this package in order to avoid circular dependency with the "versiondependency" package. + VersionDependenciesInverseTable = "version_dependencies" + // VersionDependenciesColumn is the table column denoting the version_dependencies relation/edge. + VersionDependenciesColumn = "mod_id" +) + +// Columns holds all SQL columns for mod fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, + FieldShortDescription, + FieldFullDescription, + FieldLogo, + FieldSourceURL, + FieldCreatorID, + FieldApproved, + FieldViews, + FieldHotness, + FieldPopularity, + FieldDownloads, + FieldDenied, + FieldLastVersionDate, + FieldModReference, + FieldHidden, + FieldCompatibility, +} + +var ( + // AuthorsPrimaryKey and AuthorsColumn2 are the table columns denoting the + // primary key for the authors relation (M2M). + AuthorsPrimaryKey = []string{"user_id", "mod_id"} + // TagsPrimaryKey and TagsColumn2 are the table columns denoting the + // primary key for the tags relation (M2M). + TagsPrimaryKey = []string{"mod_id", "tag_id"} + // DependentsPrimaryKey and DependentsColumn2 are the table columns denoting the + // primary key for the dependents relation (M2M). + DependentsPrimaryKey = []string{"version_id", "mod_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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + ShortDescriptionValidator func(string) error + // DefaultApproved holds the default value on creation for the "approved" field. + DefaultApproved bool + // DefaultDenied holds the default value on creation for the "denied" field. + DefaultDenied bool + // ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. + ModReferenceValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the Mod 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, 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() +} + +// BySourceURL orders the results by the source_url field. +func BySourceURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSourceURL, opts...).ToFunc() +} + +// ByCreatorID orders the results by the creator_id field. +func ByCreatorID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatorID, opts...).ToFunc() +} + +// ByApproved orders the results by the approved field. +func ByApproved(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldApproved, 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() +} + +// ByPopularity orders the results by the popularity field. +func ByPopularity(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPopularity, opts...).ToFunc() +} + +// ByDownloads orders the results by the downloads field. +func ByDownloads(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDownloads, opts...).ToFunc() +} + +// ByDenied orders the results by the denied field. +func ByDenied(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDenied, opts...).ToFunc() +} + +// ByLastVersionDate orders the results by the last_version_date field. +func ByLastVersionDate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastVersionDate, opts...).ToFunc() +} + +// ByModReference orders the results by the mod_reference field. +func ByModReference(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModReference, opts...).ToFunc() +} + +// ByHidden orders the results by the hidden field. +func ByHidden(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHidden, opts...).ToFunc() +} + +// ByVersionsCount orders the results by versions count. +func ByVersionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionsStep(), opts...) + } +} + +// ByVersions orders the results by versions terms. +func ByVersions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByAuthorsCount orders the results by authors count. +func ByAuthorsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newAuthorsStep(), opts...) + } +} + +// ByAuthors orders the results by authors terms. +func ByAuthors(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAuthorsStep(), 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...)...) + } +} + +// ByDependentsCount orders the results by dependents count. +func ByDependentsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newDependentsStep(), opts...) + } +} + +// ByDependents orders the results by dependents terms. +func ByDependents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newDependentsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserModsCount orders the results by user_mods count. +func ByUserModsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserModsStep(), opts...) + } +} + +// ByUserMods orders the results by user_mods terms. +func ByUserMods(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserModsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModTagsCount orders the results by mod_tags count. +func ByModTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModTagsStep(), opts...) + } +} + +// ByModTags orders the results by mod_tags terms. +func ByModTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByVersionDependenciesCount orders the results by version_dependencies count. +func ByVersionDependenciesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionDependenciesStep(), opts...) + } +} + +// ByVersionDependencies orders the results by version_dependencies terms. +func ByVersionDependencies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionDependenciesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newVersionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) +} +func newAuthorsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AuthorsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, AuthorsTable, AuthorsPrimaryKey...), + ) +} +func newTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TagsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, TagsTable, TagsPrimaryKey...), + ) +} +func newDependentsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(DependentsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, DependentsTable, DependentsPrimaryKey...), + ) +} +func newUserModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserModsInverseTable, UserModsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, UserModsTable, UserModsColumn), + ) +} +func newModTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModTagsInverseTable, ModTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModTagsTable, ModTagsColumn), + ) +} +func newVersionDependenciesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionDependenciesInverseTable, VersionDependenciesColumn), + sqlgraph.Edge(sqlgraph.O2M, true, VersionDependenciesTable, VersionDependenciesColumn), + ) +} diff --git a/generated/ent/mod/where.go b/generated/ent/mod/where.go new file mode 100644 index 00000000..170d06bf --- /dev/null +++ b/generated/ent/mod/where.go @@ -0,0 +1,1147 @@ +// Code generated by ent, DO NOT EDIT. + +package mod + +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.Mod { + return predicate.Mod(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Mod { + return predicate.Mod(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.Mod { + return predicate.Mod(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.Mod { + return predicate.Mod(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldName, v)) +} + +// ShortDescription applies equality check predicate on the "short_description" field. It's identical to ShortDescriptionEQ. +func ShortDescription(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldShortDescription, v)) +} + +// FullDescription applies equality check predicate on the "full_description" field. It's identical to FullDescriptionEQ. +func FullDescription(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldFullDescription, v)) +} + +// Logo applies equality check predicate on the "logo" field. It's identical to LogoEQ. +func Logo(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldLogo, v)) +} + +// SourceURL applies equality check predicate on the "source_url" field. It's identical to SourceURLEQ. +func SourceURL(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldSourceURL, v)) +} + +// CreatorID applies equality check predicate on the "creator_id" field. It's identical to CreatorIDEQ. +func CreatorID(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldCreatorID, v)) +} + +// Approved applies equality check predicate on the "approved" field. It's identical to ApprovedEQ. +func Approved(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldApproved, v)) +} + +// Views applies equality check predicate on the "views" field. It's identical to ViewsEQ. +func Views(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldViews, v)) +} + +// Hotness applies equality check predicate on the "hotness" field. It's identical to HotnessEQ. +func Hotness(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldHotness, v)) +} + +// Popularity applies equality check predicate on the "popularity" field. It's identical to PopularityEQ. +func Popularity(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldPopularity, v)) +} + +// Downloads applies equality check predicate on the "downloads" field. It's identical to DownloadsEQ. +func Downloads(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDownloads, v)) +} + +// Denied applies equality check predicate on the "denied" field. It's identical to DeniedEQ. +func Denied(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDenied, v)) +} + +// LastVersionDate applies equality check predicate on the "last_version_date" field. It's identical to LastVersionDateEQ. +func LastVersionDate(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldLastVersionDate, v)) +} + +// ModReference applies equality check predicate on the "mod_reference" field. It's identical to ModReferenceEQ. +func ModReference(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldModReference, v)) +} + +// Hidden applies equality check predicate on the "hidden" field. It's identical to HiddenEQ. +func Hidden(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldHidden, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Mod { + return predicate.Mod(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Mod { + return predicate.Mod(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldName, v)) +} + +// ShortDescriptionEQ applies the EQ predicate on the "short_description" field. +func ShortDescriptionEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldShortDescription, v)) +} + +// ShortDescriptionNEQ applies the NEQ predicate on the "short_description" field. +func ShortDescriptionNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldShortDescription, v)) +} + +// ShortDescriptionIn applies the In predicate on the "short_description" field. +func ShortDescriptionIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionNotIn applies the NotIn predicate on the "short_description" field. +func ShortDescriptionNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldShortDescription, vs...)) +} + +// ShortDescriptionGT applies the GT predicate on the "short_description" field. +func ShortDescriptionGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldShortDescription, v)) +} + +// ShortDescriptionGTE applies the GTE predicate on the "short_description" field. +func ShortDescriptionGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldShortDescription, v)) +} + +// ShortDescriptionLT applies the LT predicate on the "short_description" field. +func ShortDescriptionLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldShortDescription, v)) +} + +// ShortDescriptionLTE applies the LTE predicate on the "short_description" field. +func ShortDescriptionLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldShortDescription, v)) +} + +// ShortDescriptionContains applies the Contains predicate on the "short_description" field. +func ShortDescriptionContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldShortDescription, v)) +} + +// ShortDescriptionHasPrefix applies the HasPrefix predicate on the "short_description" field. +func ShortDescriptionHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldShortDescription, v)) +} + +// ShortDescriptionHasSuffix applies the HasSuffix predicate on the "short_description" field. +func ShortDescriptionHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldShortDescription, v)) +} + +// ShortDescriptionEqualFold applies the EqualFold predicate on the "short_description" field. +func ShortDescriptionEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldShortDescription, v)) +} + +// ShortDescriptionContainsFold applies the ContainsFold predicate on the "short_description" field. +func ShortDescriptionContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldShortDescription, v)) +} + +// FullDescriptionEQ applies the EQ predicate on the "full_description" field. +func FullDescriptionEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldFullDescription, v)) +} + +// FullDescriptionNEQ applies the NEQ predicate on the "full_description" field. +func FullDescriptionNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldFullDescription, v)) +} + +// FullDescriptionIn applies the In predicate on the "full_description" field. +func FullDescriptionIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldFullDescription, vs...)) +} + +// FullDescriptionNotIn applies the NotIn predicate on the "full_description" field. +func FullDescriptionNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldFullDescription, vs...)) +} + +// FullDescriptionGT applies the GT predicate on the "full_description" field. +func FullDescriptionGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldFullDescription, v)) +} + +// FullDescriptionGTE applies the GTE predicate on the "full_description" field. +func FullDescriptionGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldFullDescription, v)) +} + +// FullDescriptionLT applies the LT predicate on the "full_description" field. +func FullDescriptionLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldFullDescription, v)) +} + +// FullDescriptionLTE applies the LTE predicate on the "full_description" field. +func FullDescriptionLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldFullDescription, v)) +} + +// FullDescriptionContains applies the Contains predicate on the "full_description" field. +func FullDescriptionContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldFullDescription, v)) +} + +// FullDescriptionHasPrefix applies the HasPrefix predicate on the "full_description" field. +func FullDescriptionHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldFullDescription, v)) +} + +// FullDescriptionHasSuffix applies the HasSuffix predicate on the "full_description" field. +func FullDescriptionHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldFullDescription, v)) +} + +// FullDescriptionEqualFold applies the EqualFold predicate on the "full_description" field. +func FullDescriptionEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldFullDescription, v)) +} + +// FullDescriptionContainsFold applies the ContainsFold predicate on the "full_description" field. +func FullDescriptionContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldFullDescription, v)) +} + +// LogoEQ applies the EQ predicate on the "logo" field. +func LogoEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldLogo, v)) +} + +// LogoNEQ applies the NEQ predicate on the "logo" field. +func LogoNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldLogo, v)) +} + +// LogoIn applies the In predicate on the "logo" field. +func LogoIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldLogo, vs...)) +} + +// LogoNotIn applies the NotIn predicate on the "logo" field. +func LogoNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldLogo, vs...)) +} + +// LogoGT applies the GT predicate on the "logo" field. +func LogoGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldLogo, v)) +} + +// LogoGTE applies the GTE predicate on the "logo" field. +func LogoGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldLogo, v)) +} + +// LogoLT applies the LT predicate on the "logo" field. +func LogoLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldLogo, v)) +} + +// LogoLTE applies the LTE predicate on the "logo" field. +func LogoLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldLogo, v)) +} + +// LogoContains applies the Contains predicate on the "logo" field. +func LogoContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldLogo, v)) +} + +// LogoHasPrefix applies the HasPrefix predicate on the "logo" field. +func LogoHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldLogo, v)) +} + +// LogoHasSuffix applies the HasSuffix predicate on the "logo" field. +func LogoHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldLogo, v)) +} + +// LogoEqualFold applies the EqualFold predicate on the "logo" field. +func LogoEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldLogo, v)) +} + +// LogoContainsFold applies the ContainsFold predicate on the "logo" field. +func LogoContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldLogo, v)) +} + +// SourceURLEQ applies the EQ predicate on the "source_url" field. +func SourceURLEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldSourceURL, v)) +} + +// SourceURLNEQ applies the NEQ predicate on the "source_url" field. +func SourceURLNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldSourceURL, v)) +} + +// SourceURLIn applies the In predicate on the "source_url" field. +func SourceURLIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldSourceURL, vs...)) +} + +// SourceURLNotIn applies the NotIn predicate on the "source_url" field. +func SourceURLNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldSourceURL, vs...)) +} + +// SourceURLGT applies the GT predicate on the "source_url" field. +func SourceURLGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldSourceURL, v)) +} + +// SourceURLGTE applies the GTE predicate on the "source_url" field. +func SourceURLGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldSourceURL, v)) +} + +// SourceURLLT applies the LT predicate on the "source_url" field. +func SourceURLLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldSourceURL, v)) +} + +// SourceURLLTE applies the LTE predicate on the "source_url" field. +func SourceURLLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldSourceURL, v)) +} + +// SourceURLContains applies the Contains predicate on the "source_url" field. +func SourceURLContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldSourceURL, v)) +} + +// SourceURLHasPrefix applies the HasPrefix predicate on the "source_url" field. +func SourceURLHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldSourceURL, v)) +} + +// SourceURLHasSuffix applies the HasSuffix predicate on the "source_url" field. +func SourceURLHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldSourceURL, v)) +} + +// SourceURLEqualFold applies the EqualFold predicate on the "source_url" field. +func SourceURLEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldSourceURL, v)) +} + +// SourceURLContainsFold applies the ContainsFold predicate on the "source_url" field. +func SourceURLContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldSourceURL, v)) +} + +// CreatorIDEQ applies the EQ predicate on the "creator_id" field. +func CreatorIDEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldCreatorID, v)) +} + +// CreatorIDNEQ applies the NEQ predicate on the "creator_id" field. +func CreatorIDNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldCreatorID, v)) +} + +// CreatorIDIn applies the In predicate on the "creator_id" field. +func CreatorIDIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldCreatorID, vs...)) +} + +// CreatorIDNotIn applies the NotIn predicate on the "creator_id" field. +func CreatorIDNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldCreatorID, vs...)) +} + +// CreatorIDGT applies the GT predicate on the "creator_id" field. +func CreatorIDGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldCreatorID, v)) +} + +// CreatorIDGTE applies the GTE predicate on the "creator_id" field. +func CreatorIDGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldCreatorID, v)) +} + +// CreatorIDLT applies the LT predicate on the "creator_id" field. +func CreatorIDLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldCreatorID, v)) +} + +// CreatorIDLTE applies the LTE predicate on the "creator_id" field. +func CreatorIDLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldCreatorID, v)) +} + +// CreatorIDContains applies the Contains predicate on the "creator_id" field. +func CreatorIDContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldCreatorID, v)) +} + +// CreatorIDHasPrefix applies the HasPrefix predicate on the "creator_id" field. +func CreatorIDHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldCreatorID, v)) +} + +// CreatorIDHasSuffix applies the HasSuffix predicate on the "creator_id" field. +func CreatorIDHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldCreatorID, v)) +} + +// CreatorIDEqualFold applies the EqualFold predicate on the "creator_id" field. +func CreatorIDEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldCreatorID, v)) +} + +// CreatorIDContainsFold applies the ContainsFold predicate on the "creator_id" field. +func CreatorIDContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldCreatorID, v)) +} + +// ApprovedEQ applies the EQ predicate on the "approved" field. +func ApprovedEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldApproved, v)) +} + +// ApprovedNEQ applies the NEQ predicate on the "approved" field. +func ApprovedNEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldApproved, v)) +} + +// ViewsEQ applies the EQ predicate on the "views" field. +func ViewsEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldViews, v)) +} + +// ViewsNEQ applies the NEQ predicate on the "views" field. +func ViewsNEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldViews, v)) +} + +// ViewsIn applies the In predicate on the "views" field. +func ViewsIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldViews, vs...)) +} + +// ViewsNotIn applies the NotIn predicate on the "views" field. +func ViewsNotIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldViews, vs...)) +} + +// ViewsGT applies the GT predicate on the "views" field. +func ViewsGT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldViews, v)) +} + +// ViewsGTE applies the GTE predicate on the "views" field. +func ViewsGTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldViews, v)) +} + +// ViewsLT applies the LT predicate on the "views" field. +func ViewsLT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldViews, v)) +} + +// ViewsLTE applies the LTE predicate on the "views" field. +func ViewsLTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldViews, v)) +} + +// HotnessEQ applies the EQ predicate on the "hotness" field. +func HotnessEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldHotness, v)) +} + +// HotnessNEQ applies the NEQ predicate on the "hotness" field. +func HotnessNEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldHotness, v)) +} + +// HotnessIn applies the In predicate on the "hotness" field. +func HotnessIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldHotness, vs...)) +} + +// HotnessNotIn applies the NotIn predicate on the "hotness" field. +func HotnessNotIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldHotness, vs...)) +} + +// HotnessGT applies the GT predicate on the "hotness" field. +func HotnessGT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldHotness, v)) +} + +// HotnessGTE applies the GTE predicate on the "hotness" field. +func HotnessGTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldHotness, v)) +} + +// HotnessLT applies the LT predicate on the "hotness" field. +func HotnessLT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldHotness, v)) +} + +// HotnessLTE applies the LTE predicate on the "hotness" field. +func HotnessLTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldHotness, v)) +} + +// PopularityEQ applies the EQ predicate on the "popularity" field. +func PopularityEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldPopularity, v)) +} + +// PopularityNEQ applies the NEQ predicate on the "popularity" field. +func PopularityNEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldPopularity, v)) +} + +// PopularityIn applies the In predicate on the "popularity" field. +func PopularityIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldPopularity, vs...)) +} + +// PopularityNotIn applies the NotIn predicate on the "popularity" field. +func PopularityNotIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldPopularity, vs...)) +} + +// PopularityGT applies the GT predicate on the "popularity" field. +func PopularityGT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldPopularity, v)) +} + +// PopularityGTE applies the GTE predicate on the "popularity" field. +func PopularityGTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldPopularity, v)) +} + +// PopularityLT applies the LT predicate on the "popularity" field. +func PopularityLT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldPopularity, v)) +} + +// PopularityLTE applies the LTE predicate on the "popularity" field. +func PopularityLTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldPopularity, v)) +} + +// DownloadsEQ applies the EQ predicate on the "downloads" field. +func DownloadsEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDownloads, v)) +} + +// DownloadsNEQ applies the NEQ predicate on the "downloads" field. +func DownloadsNEQ(v uint) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldDownloads, v)) +} + +// DownloadsIn applies the In predicate on the "downloads" field. +func DownloadsIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldDownloads, vs...)) +} + +// DownloadsNotIn applies the NotIn predicate on the "downloads" field. +func DownloadsNotIn(vs ...uint) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldDownloads, vs...)) +} + +// DownloadsGT applies the GT predicate on the "downloads" field. +func DownloadsGT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldDownloads, v)) +} + +// DownloadsGTE applies the GTE predicate on the "downloads" field. +func DownloadsGTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldDownloads, v)) +} + +// DownloadsLT applies the LT predicate on the "downloads" field. +func DownloadsLT(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldDownloads, v)) +} + +// DownloadsLTE applies the LTE predicate on the "downloads" field. +func DownloadsLTE(v uint) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldDownloads, v)) +} + +// DeniedEQ applies the EQ predicate on the "denied" field. +func DeniedEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldDenied, v)) +} + +// DeniedNEQ applies the NEQ predicate on the "denied" field. +func DeniedNEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldDenied, v)) +} + +// LastVersionDateEQ applies the EQ predicate on the "last_version_date" field. +func LastVersionDateEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldLastVersionDate, v)) +} + +// LastVersionDateNEQ applies the NEQ predicate on the "last_version_date" field. +func LastVersionDateNEQ(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldLastVersionDate, v)) +} + +// LastVersionDateIn applies the In predicate on the "last_version_date" field. +func LastVersionDateIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldLastVersionDate, vs...)) +} + +// LastVersionDateNotIn applies the NotIn predicate on the "last_version_date" field. +func LastVersionDateNotIn(vs ...time.Time) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldLastVersionDate, vs...)) +} + +// LastVersionDateGT applies the GT predicate on the "last_version_date" field. +func LastVersionDateGT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldLastVersionDate, v)) +} + +// LastVersionDateGTE applies the GTE predicate on the "last_version_date" field. +func LastVersionDateGTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldLastVersionDate, v)) +} + +// LastVersionDateLT applies the LT predicate on the "last_version_date" field. +func LastVersionDateLT(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldLastVersionDate, v)) +} + +// LastVersionDateLTE applies the LTE predicate on the "last_version_date" field. +func LastVersionDateLTE(v time.Time) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldLastVersionDate, v)) +} + +// ModReferenceEQ applies the EQ predicate on the "mod_reference" field. +func ModReferenceEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldModReference, v)) +} + +// ModReferenceNEQ applies the NEQ predicate on the "mod_reference" field. +func ModReferenceNEQ(v string) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldModReference, v)) +} + +// ModReferenceIn applies the In predicate on the "mod_reference" field. +func ModReferenceIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldIn(FieldModReference, vs...)) +} + +// ModReferenceNotIn applies the NotIn predicate on the "mod_reference" field. +func ModReferenceNotIn(vs ...string) predicate.Mod { + return predicate.Mod(sql.FieldNotIn(FieldModReference, vs...)) +} + +// ModReferenceGT applies the GT predicate on the "mod_reference" field. +func ModReferenceGT(v string) predicate.Mod { + return predicate.Mod(sql.FieldGT(FieldModReference, v)) +} + +// ModReferenceGTE applies the GTE predicate on the "mod_reference" field. +func ModReferenceGTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldGTE(FieldModReference, v)) +} + +// ModReferenceLT applies the LT predicate on the "mod_reference" field. +func ModReferenceLT(v string) predicate.Mod { + return predicate.Mod(sql.FieldLT(FieldModReference, v)) +} + +// ModReferenceLTE applies the LTE predicate on the "mod_reference" field. +func ModReferenceLTE(v string) predicate.Mod { + return predicate.Mod(sql.FieldLTE(FieldModReference, v)) +} + +// ModReferenceContains applies the Contains predicate on the "mod_reference" field. +func ModReferenceContains(v string) predicate.Mod { + return predicate.Mod(sql.FieldContains(FieldModReference, v)) +} + +// ModReferenceHasPrefix applies the HasPrefix predicate on the "mod_reference" field. +func ModReferenceHasPrefix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasPrefix(FieldModReference, v)) +} + +// ModReferenceHasSuffix applies the HasSuffix predicate on the "mod_reference" field. +func ModReferenceHasSuffix(v string) predicate.Mod { + return predicate.Mod(sql.FieldHasSuffix(FieldModReference, v)) +} + +// ModReferenceEqualFold applies the EqualFold predicate on the "mod_reference" field. +func ModReferenceEqualFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldEqualFold(FieldModReference, v)) +} + +// ModReferenceContainsFold applies the ContainsFold predicate on the "mod_reference" field. +func ModReferenceContainsFold(v string) predicate.Mod { + return predicate.Mod(sql.FieldContainsFold(FieldModReference, v)) +} + +// HiddenEQ applies the EQ predicate on the "hidden" field. +func HiddenEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldEQ(FieldHidden, v)) +} + +// HiddenNEQ applies the NEQ predicate on the "hidden" field. +func HiddenNEQ(v bool) predicate.Mod { + return predicate.Mod(sql.FieldNEQ(FieldHidden, v)) +} + +// HasVersions applies the HasEdge predicate on the "versions" edge. +func HasVersions() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionsWith applies the HasEdge predicate on the "versions" edge with a given conditions (other predicates). +func HasVersionsWith(preds ...predicate.Version) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newVersionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAuthors applies the HasEdge predicate on the "authors" edge. +func HasAuthors() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, AuthorsTable, AuthorsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAuthorsWith applies the HasEdge predicate on the "authors" edge with a given conditions (other predicates). +func HasAuthorsWith(preds ...predicate.User) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newAuthorsStep() + 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.Mod { + return predicate.Mod(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.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasDependents applies the HasEdge predicate on the "dependents" edge. +func HasDependents() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, DependentsTable, DependentsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasDependentsWith applies the HasEdge predicate on the "dependents" edge with a given conditions (other predicates). +func HasDependentsWith(preds ...predicate.Version) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newDependentsStep() + 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) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserModsTable, UserModsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserModsWith applies the HasEdge predicate on the "user_mods" edge with a given conditions (other predicates). +func HasUserModsWith(preds ...predicate.UserMod) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newUserModsStep() + 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.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModTagsTable, ModTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModTagsWith applies the HasEdge predicate on the "mod_tags" edge with a given conditions (other predicates). +func HasModTagsWith(preds ...predicate.ModTag) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newModTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasVersionDependencies applies the HasEdge predicate on the "version_dependencies" edge. +func HasVersionDependencies() predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, VersionDependenciesTable, VersionDependenciesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionDependenciesWith applies the HasEdge predicate on the "version_dependencies" edge with a given conditions (other predicates). +func HasVersionDependenciesWith(preds ...predicate.VersionDependency) predicate.Mod { + return predicate.Mod(func(s *sql.Selector) { + step := newVersionDependenciesStep() + 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...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Mod) predicate.Mod { + return predicate.Mod(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Mod) predicate.Mod { + return predicate.Mod(sql.NotPredicates(p)) +} diff --git a/generated/ent/mod_create.go b/generated/ent/mod_create.go new file mode 100644 index 00000000..f8b7821a --- /dev/null +++ b/generated/ent/mod_create.go @@ -0,0 +1,659 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +// ModCreate is the builder for creating a Mod entity. +type ModCreate struct { + config + mutation *ModMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (mc *ModCreate) SetCreatedAt(t time.Time) *ModCreate { + mc.mutation.SetCreatedAt(t) + return mc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (mc *ModCreate) SetNillableCreatedAt(t *time.Time) *ModCreate { + if t != nil { + mc.SetCreatedAt(*t) + } + return mc +} + +// SetUpdatedAt sets the "updated_at" field. +func (mc *ModCreate) SetUpdatedAt(t time.Time) *ModCreate { + mc.mutation.SetUpdatedAt(t) + return mc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (mc *ModCreate) SetNillableUpdatedAt(t *time.Time) *ModCreate { + if t != nil { + mc.SetUpdatedAt(*t) + } + return mc +} + +// SetDeletedAt sets the "deleted_at" field. +func (mc *ModCreate) SetDeletedAt(t time.Time) *ModCreate { + mc.mutation.SetDeletedAt(t) + return mc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (mc *ModCreate) SetNillableDeletedAt(t *time.Time) *ModCreate { + if t != nil { + mc.SetDeletedAt(*t) + } + return mc +} + +// SetName sets the "name" field. +func (mc *ModCreate) SetName(s string) *ModCreate { + mc.mutation.SetName(s) + return mc +} + +// SetShortDescription sets the "short_description" field. +func (mc *ModCreate) SetShortDescription(s string) *ModCreate { + mc.mutation.SetShortDescription(s) + return mc +} + +// SetFullDescription sets the "full_description" field. +func (mc *ModCreate) SetFullDescription(s string) *ModCreate { + mc.mutation.SetFullDescription(s) + return mc +} + +// SetLogo sets the "logo" field. +func (mc *ModCreate) SetLogo(s string) *ModCreate { + mc.mutation.SetLogo(s) + return mc +} + +// SetSourceURL sets the "source_url" field. +func (mc *ModCreate) SetSourceURL(s string) *ModCreate { + mc.mutation.SetSourceURL(s) + return mc +} + +// SetCreatorID sets the "creator_id" field. +func (mc *ModCreate) SetCreatorID(s string) *ModCreate { + mc.mutation.SetCreatorID(s) + return mc +} + +// SetApproved sets the "approved" field. +func (mc *ModCreate) SetApproved(b bool) *ModCreate { + mc.mutation.SetApproved(b) + return mc +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (mc *ModCreate) SetNillableApproved(b *bool) *ModCreate { + if b != nil { + mc.SetApproved(*b) + } + return mc +} + +// SetViews sets the "views" field. +func (mc *ModCreate) SetViews(u uint) *ModCreate { + mc.mutation.SetViews(u) + return mc +} + +// SetHotness sets the "hotness" field. +func (mc *ModCreate) SetHotness(u uint) *ModCreate { + mc.mutation.SetHotness(u) + return mc +} + +// SetPopularity sets the "popularity" field. +func (mc *ModCreate) SetPopularity(u uint) *ModCreate { + mc.mutation.SetPopularity(u) + return mc +} + +// SetDownloads sets the "downloads" field. +func (mc *ModCreate) SetDownloads(u uint) *ModCreate { + mc.mutation.SetDownloads(u) + return mc +} + +// SetDenied sets the "denied" field. +func (mc *ModCreate) SetDenied(b bool) *ModCreate { + mc.mutation.SetDenied(b) + return mc +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (mc *ModCreate) SetNillableDenied(b *bool) *ModCreate { + if b != nil { + mc.SetDenied(*b) + } + return mc +} + +// SetLastVersionDate sets the "last_version_date" field. +func (mc *ModCreate) SetLastVersionDate(t time.Time) *ModCreate { + mc.mutation.SetLastVersionDate(t) + return mc +} + +// SetModReference sets the "mod_reference" field. +func (mc *ModCreate) SetModReference(s string) *ModCreate { + mc.mutation.SetModReference(s) + return mc +} + +// SetHidden sets the "hidden" field. +func (mc *ModCreate) SetHidden(b bool) *ModCreate { + mc.mutation.SetHidden(b) + return mc +} + +// SetCompatibility sets the "compatibility" field. +func (mc *ModCreate) SetCompatibility(pi *postgres.CompatibilityInfo) *ModCreate { + mc.mutation.SetCompatibility(pi) + return mc +} + +// SetID sets the "id" field. +func (mc *ModCreate) SetID(s string) *ModCreate { + mc.mutation.SetID(s) + return mc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (mc *ModCreate) SetNillableID(s *string) *ModCreate { + if s != nil { + mc.SetID(*s) + } + return mc +} + +// AddVersionIDs adds the "versions" edge to the Version entity by IDs. +func (mc *ModCreate) AddVersionIDs(ids ...string) *ModCreate { + mc.mutation.AddVersionIDs(ids...) + return mc +} + +// AddVersions adds the "versions" edges to the Version entity. +func (mc *ModCreate) AddVersions(v ...*Version) *ModCreate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mc.AddVersionIDs(ids...) +} + +// AddAuthorIDs adds the "authors" edge to the User entity by IDs. +func (mc *ModCreate) AddAuthorIDs(ids ...string) *ModCreate { + mc.mutation.AddAuthorIDs(ids...) + return mc +} + +// AddAuthors adds the "authors" edges to the User entity. +func (mc *ModCreate) AddAuthors(u ...*User) *ModCreate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return mc.AddAuthorIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (mc *ModCreate) AddTagIDs(ids ...string) *ModCreate { + mc.mutation.AddTagIDs(ids...) + return mc +} + +// AddTags adds the "tags" edges to the Tag entity. +func (mc *ModCreate) AddTags(t ...*Tag) *ModCreate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mc.AddTagIDs(ids...) +} + +// AddDependentIDs adds the "dependents" edge to the Version entity by IDs. +func (mc *ModCreate) AddDependentIDs(ids ...string) *ModCreate { + mc.mutation.AddDependentIDs(ids...) + return mc +} + +// AddDependents adds the "dependents" edges to the Version entity. +func (mc *ModCreate) AddDependents(v ...*Version) *ModCreate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mc.AddDependentIDs(ids...) +} + +// Mutation returns the ModMutation object of the builder. +func (mc *ModCreate) Mutation() *ModMutation { + return mc.mutation +} + +// Save creates the Mod in the database. +func (mc *ModCreate) Save(ctx context.Context) (*Mod, error) { + if err := mc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mc *ModCreate) SaveX(ctx context.Context) *Mod { + v, err := mc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mc *ModCreate) Exec(ctx context.Context) error { + _, err := mc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mc *ModCreate) 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 *ModCreate) defaults() error { + if _, ok := mc.mutation.CreatedAt(); !ok { + if mod.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized mod.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := mod.DefaultCreatedAt() + mc.mutation.SetCreatedAt(v) + } + if _, ok := mc.mutation.UpdatedAt(); !ok { + if mod.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized mod.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := mod.DefaultUpdatedAt() + mc.mutation.SetUpdatedAt(v) + } + if _, ok := mc.mutation.Approved(); !ok { + v := mod.DefaultApproved + mc.mutation.SetApproved(v) + } + if _, ok := mc.mutation.Denied(); !ok { + v := mod.DefaultDenied + mc.mutation.SetDenied(v) + } + if _, ok := mc.mutation.ID(); !ok { + if mod.DefaultID == nil { + return fmt.Errorf("ent: uninitialized mod.DefaultID (forgotten import ent/runtime?)") + } + v := mod.DefaultID() + mc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (mc *ModCreate) check() error { + if _, ok := mc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Mod.created_at"`)} + } + if _, ok := mc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Mod.updated_at"`)} + } + if _, ok := mc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Mod.name"`)} + } + if v, ok := mc.mutation.Name(); ok { + if err := mod.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Mod.name": %w`, err)} + } + } + if _, ok := mc.mutation.ShortDescription(); !ok { + return &ValidationError{Name: "short_description", err: errors.New(`ent: missing required field "Mod.short_description"`)} + } + if v, ok := mc.mutation.ShortDescription(); ok { + if err := mod.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Mod.short_description": %w`, err)} + } + } + if _, ok := mc.mutation.FullDescription(); !ok { + return &ValidationError{Name: "full_description", err: errors.New(`ent: missing required field "Mod.full_description"`)} + } + if _, ok := mc.mutation.Logo(); !ok { + return &ValidationError{Name: "logo", err: errors.New(`ent: missing required field "Mod.logo"`)} + } + if _, ok := mc.mutation.SourceURL(); !ok { + return &ValidationError{Name: "source_url", err: errors.New(`ent: missing required field "Mod.source_url"`)} + } + if _, ok := mc.mutation.CreatorID(); !ok { + return &ValidationError{Name: "creator_id", err: errors.New(`ent: missing required field "Mod.creator_id"`)} + } + if _, ok := mc.mutation.Approved(); !ok { + return &ValidationError{Name: "approved", err: errors.New(`ent: missing required field "Mod.approved"`)} + } + if _, ok := mc.mutation.Views(); !ok { + return &ValidationError{Name: "views", err: errors.New(`ent: missing required field "Mod.views"`)} + } + if _, ok := mc.mutation.Hotness(); !ok { + return &ValidationError{Name: "hotness", err: errors.New(`ent: missing required field "Mod.hotness"`)} + } + if _, ok := mc.mutation.Popularity(); !ok { + return &ValidationError{Name: "popularity", err: errors.New(`ent: missing required field "Mod.popularity"`)} + } + if _, ok := mc.mutation.Downloads(); !ok { + return &ValidationError{Name: "downloads", err: errors.New(`ent: missing required field "Mod.downloads"`)} + } + if _, ok := mc.mutation.Denied(); !ok { + return &ValidationError{Name: "denied", err: errors.New(`ent: missing required field "Mod.denied"`)} + } + if _, ok := mc.mutation.LastVersionDate(); !ok { + return &ValidationError{Name: "last_version_date", err: errors.New(`ent: missing required field "Mod.last_version_date"`)} + } + if _, ok := mc.mutation.ModReference(); !ok { + return &ValidationError{Name: "mod_reference", err: errors.New(`ent: missing required field "Mod.mod_reference"`)} + } + if v, ok := mc.mutation.ModReference(); ok { + if err := mod.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Mod.mod_reference": %w`, err)} + } + } + if _, ok := mc.mutation.Hidden(); !ok { + return &ValidationError{Name: "hidden", err: errors.New(`ent: missing required field "Mod.hidden"`)} + } + if _, ok := mc.mutation.Compatibility(); !ok { + return &ValidationError{Name: "compatibility", err: errors.New(`ent: missing required field "Mod.compatibility"`)} + } + return nil +} + +func (mc *ModCreate) sqlSave(ctx context.Context) (*Mod, 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 Mod.ID type: %T", _spec.ID.Value) + } + } + mc.mutation.id = &_node.ID + mc.mutation.done = true + return _node, nil +} + +func (mc *ModCreate) createSpec() (*Mod, *sqlgraph.CreateSpec) { + var ( + _node = &Mod{config: mc.config} + _spec = sqlgraph.NewCreateSpec(mod.Table, sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString)) + ) + if id, ok := mc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := mc.mutation.CreatedAt(); ok { + _spec.SetField(mod.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := mc.mutation.UpdatedAt(); ok { + _spec.SetField(mod.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := mc.mutation.DeletedAt(); ok { + _spec.SetField(mod.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := mc.mutation.Name(); ok { + _spec.SetField(mod.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := mc.mutation.ShortDescription(); ok { + _spec.SetField(mod.FieldShortDescription, field.TypeString, value) + _node.ShortDescription = value + } + if value, ok := mc.mutation.FullDescription(); ok { + _spec.SetField(mod.FieldFullDescription, field.TypeString, value) + _node.FullDescription = value + } + if value, ok := mc.mutation.Logo(); ok { + _spec.SetField(mod.FieldLogo, field.TypeString, value) + _node.Logo = value + } + if value, ok := mc.mutation.SourceURL(); ok { + _spec.SetField(mod.FieldSourceURL, field.TypeString, value) + _node.SourceURL = value + } + if value, ok := mc.mutation.CreatorID(); ok { + _spec.SetField(mod.FieldCreatorID, field.TypeString, value) + _node.CreatorID = value + } + if value, ok := mc.mutation.Approved(); ok { + _spec.SetField(mod.FieldApproved, field.TypeBool, value) + _node.Approved = value + } + if value, ok := mc.mutation.Views(); ok { + _spec.SetField(mod.FieldViews, field.TypeUint, value) + _node.Views = value + } + if value, ok := mc.mutation.Hotness(); ok { + _spec.SetField(mod.FieldHotness, field.TypeUint, value) + _node.Hotness = value + } + if value, ok := mc.mutation.Popularity(); ok { + _spec.SetField(mod.FieldPopularity, field.TypeUint, value) + _node.Popularity = value + } + if value, ok := mc.mutation.Downloads(); ok { + _spec.SetField(mod.FieldDownloads, field.TypeUint, value) + _node.Downloads = value + } + if value, ok := mc.mutation.Denied(); ok { + _spec.SetField(mod.FieldDenied, field.TypeBool, value) + _node.Denied = value + } + if value, ok := mc.mutation.LastVersionDate(); ok { + _spec.SetField(mod.FieldLastVersionDate, field.TypeTime, value) + _node.LastVersionDate = value + } + if value, ok := mc.mutation.ModReference(); ok { + _spec.SetField(mod.FieldModReference, field.TypeString, value) + _node.ModReference = value + } + if value, ok := mc.mutation.Hidden(); ok { + _spec.SetField(mod.FieldHidden, field.TypeBool, value) + _node.Hidden = value + } + if value, ok := mc.mutation.Compatibility(); ok { + _spec.SetField(mod.FieldCompatibility, field.TypeJSON, value) + _node.Compatibility = value + } + if nodes := mc.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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.AuthorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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: mod.TagsTable, + Columns: mod.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) + } + if nodes := mc.mutation.DependentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: mc.config, mutation: newVersionDependencyMutation(mc.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ModCreateBulk is the builder for creating many Mod entities in bulk. +type ModCreateBulk struct { + config + err error + builders []*ModCreate +} + +// Save creates the Mod entities in the database. +func (mcb *ModCreateBulk) Save(ctx context.Context) ([]*Mod, error) { + if mcb.err != nil { + return nil, mcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) + nodes := make([]*Mod, 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.(*ModMutation) + 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} + // 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 *ModCreateBulk) SaveX(ctx context.Context) []*Mod { + v, err := mcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mcb *ModCreateBulk) Exec(ctx context.Context) error { + _, err := mcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mcb *ModCreateBulk) ExecX(ctx context.Context) { + if err := mcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/mod_delete.go b/generated/ent/mod_delete.go new file mode 100644 index 00000000..12040901 --- /dev/null +++ b/generated/ent/mod_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/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModDelete is the builder for deleting a Mod entity. +type ModDelete struct { + config + hooks []Hook + mutation *ModMutation +} + +// Where appends a list predicates to the ModDelete builder. +func (md *ModDelete) Where(ps ...predicate.Mod) *ModDelete { + md.mutation.Where(ps...) + return md +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (md *ModDelete) 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 *ModDelete) ExecX(ctx context.Context) int { + n, err := md.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (md *ModDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(mod.Table, sqlgraph.NewFieldSpec(mod.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 +} + +// ModDeleteOne is the builder for deleting a single Mod entity. +type ModDeleteOne struct { + md *ModDelete +} + +// Where appends a list predicates to the ModDelete builder. +func (mdo *ModDeleteOne) Where(ps ...predicate.Mod) *ModDeleteOne { + mdo.md.mutation.Where(ps...) + return mdo +} + +// Exec executes the deletion query. +func (mdo *ModDeleteOne) Exec(ctx context.Context) error { + n, err := mdo.md.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{mod.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mdo *ModDeleteOne) ExecX(ctx context.Context) { + if err := mdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/mod_query.go b/generated/ent/mod_query.go new file mode 100644 index 00000000..7fcad71d --- /dev/null +++ b/generated/ent/mod_query.go @@ -0,0 +1,1166 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// ModQuery is the builder for querying Mod entities. +type ModQuery struct { + config + ctx *QueryContext + order []mod.OrderOption + inters []Interceptor + predicates []predicate.Mod + withVersions *VersionQuery + withAuthors *UserQuery + withTags *TagQuery + withDependents *VersionQuery + withUserMods *UserModQuery + withModTags *ModTagQuery + withVersionDependencies *VersionDependencyQuery + 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 ModQuery builder. +func (mq *ModQuery) Where(ps ...predicate.Mod) *ModQuery { + mq.predicates = append(mq.predicates, ps...) + return mq +} + +// Limit the number of records to be returned by this query. +func (mq *ModQuery) Limit(limit int) *ModQuery { + mq.ctx.Limit = &limit + return mq +} + +// Offset to start from. +func (mq *ModQuery) Offset(offset int) *ModQuery { + 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 *ModQuery) Unique(unique bool) *ModQuery { + mq.ctx.Unique = &unique + return mq +} + +// Order specifies how the records should be ordered. +func (mq *ModQuery) Order(o ...mod.OrderOption) *ModQuery { + mq.order = append(mq.order, o...) + return mq +} + +// QueryVersions chains the current query on the "versions" edge. +func (mq *ModQuery) QueryVersions() *VersionQuery { + query := (&VersionClient{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(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, mod.VersionsTable, mod.VersionsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAuthors chains the current query on the "authors" edge. +func (mq *ModQuery) QueryAuthors() *UserQuery { + query := (&UserClient{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(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.AuthorsTable, mod.AuthorsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTags chains the current query on the "tags" edge. +func (mq *ModQuery) 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(mod.Table, mod.FieldID, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, mod.TagsTable, mod.TagsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryDependents chains the current query on the "dependents" edge. +func (mq *ModQuery) QueryDependents() *VersionQuery { + query := (&VersionClient{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(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, mod.DependentsTable, mod.DependentsPrimaryKey...), + ) + 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() + 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(usermod.Table, usermod.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.UserModsTable, mod.UserModsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryModTags chains the current query on the "mod_tags" edge. +func (mq *ModQuery) QueryModTags() *ModTagQuery { + query := (&ModTagClient{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(modtag.Table, modtag.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.ModTagsTable, mod.ModTagsColumn), + ) + fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryVersionDependencies chains the current query on the "version_dependencies" edge. +func (mq *ModQuery) QueryVersionDependencies() *VersionDependencyQuery { + query := (&VersionDependencyClient{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(versiondependency.Table, versiondependency.ModColumn), + sqlgraph.Edge(sqlgraph.O2M, true, mod.VersionDependenciesTable, mod.VersionDependenciesColumn), + ) + 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) { + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{mod.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mq *ModQuery) FirstX(ctx context.Context) *Mod { + node, err := mq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Mod ID from the query. +// Returns a *NotFoundError when no Mod ID was found. +func (mq *ModQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{mod.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mq *ModQuery) FirstIDX(ctx context.Context) string { + id, err := mq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Mod entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Mod entity is found. +// Returns a *NotFoundError when no Mod entities are found. +func (mq *ModQuery) Only(ctx context.Context) (*Mod, error) { + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{mod.Label} + default: + return nil, &NotSingularError{mod.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mq *ModQuery) OnlyX(ctx context.Context) *Mod { + node, err := mq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Mod ID in the query. +// Returns a *NotSingularError when more than one Mod ID is found. +// Returns a *NotFoundError when no entities are found. +func (mq *ModQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{mod.Label} + default: + err = &NotSingularError{mod.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mq *ModQuery) 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 Mods. +func (mq *ModQuery) All(ctx context.Context) ([]*Mod, error) { + ctx = setContextOp(ctx, mq.ctx, "All") + if err := mq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Mod, *ModQuery]() + return withInterceptors[[]*Mod](ctx, mq, qr, mq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mq *ModQuery) AllX(ctx context.Context) []*Mod { + nodes, err := mq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Mod IDs. +func (mq *ModQuery) IDs(ctx context.Context) (ids []string, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } + ctx = setContextOp(ctx, mq.ctx, "IDs") + if err = mq.Select(mod.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mq *ModQuery) 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 *ModQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mq.ctx, "Count") + if err := mq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mq, querierCount[*ModQuery](), mq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mq *ModQuery) 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 *ModQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mq.ctx, "Exist") + 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 *ModQuery) ExistX(ctx context.Context) bool { + exist, err := mq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModQuery 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 *ModQuery) Clone() *ModQuery { + if mq == nil { + return nil + } + return &ModQuery{ + config: mq.config, + ctx: mq.ctx.Clone(), + order: append([]mod.OrderOption{}, mq.order...), + inters: append([]Interceptor{}, mq.inters...), + predicates: append([]predicate.Mod{}, mq.predicates...), + withVersions: mq.withVersions.Clone(), + withAuthors: mq.withAuthors.Clone(), + withTags: mq.withTags.Clone(), + withDependents: mq.withDependents.Clone(), + withUserMods: mq.withUserMods.Clone(), + withModTags: mq.withModTags.Clone(), + withVersionDependencies: mq.withVersionDependencies.Clone(), + // clone intermediate query. + sql: mq.sql.Clone(), + path: mq.path, + } +} + +// WithVersions tells the query-builder to eager-load the nodes that are connected to +// the "versions" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithVersions(opts ...func(*VersionQuery)) *ModQuery { + query := (&VersionClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withVersions = query + return mq +} + +// WithAuthors tells the query-builder to eager-load the nodes that are connected to +// the "authors" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithAuthors(opts ...func(*UserQuery)) *ModQuery { + query := (&UserClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withAuthors = 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 *ModQuery) WithTags(opts ...func(*TagQuery)) *ModQuery { + query := (&TagClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withTags = query + return mq +} + +// WithDependents tells the query-builder to eager-load the nodes that are connected to +// the "dependents" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithDependents(opts ...func(*VersionQuery)) *ModQuery { + query := (&VersionClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withDependents = 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 { + query := (&UserModClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withUserMods = query + return mq +} + +// 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 (mq *ModQuery) WithModTags(opts ...func(*ModTagQuery)) *ModQuery { + query := (&ModTagClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withModTags = query + return mq +} + +// WithVersionDependencies tells the query-builder to eager-load the nodes that are connected to +// the "version_dependencies" edge. The optional arguments are used to configure the query builder of the edge. +func (mq *ModQuery) WithVersionDependencies(opts ...func(*VersionDependencyQuery)) *ModQuery { + query := (&VersionDependencyClient{config: mq.config}).Query() + for _, opt := range opts { + opt(query) + } + mq.withVersionDependencies = 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.Mod.Query(). +// GroupBy(mod.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mq *ModQuery) GroupBy(field string, fields ...string) *ModGroupBy { + mq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModGroupBy{build: mq} + grbuild.flds = &mq.ctx.Fields + grbuild.label = mod.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.Mod.Query(). +// Select(mod.FieldCreatedAt). +// Scan(ctx, &v) +func (mq *ModQuery) Select(fields ...string) *ModSelect { + mq.ctx.Fields = append(mq.ctx.Fields, fields...) + sbuild := &ModSelect{ModQuery: mq} + sbuild.label = mod.Label + sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModSelect configured with the given aggregations. +func (mq *ModQuery) Aggregate(fns ...AggregateFunc) *ModSelect { + return mq.Select().Aggregate(fns...) +} + +func (mq *ModQuery) 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 !mod.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 *ModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mod, error) { + var ( + nodes = []*Mod{} + _spec = mq.querySpec() + loadedTypes = [7]bool{ + mq.withVersions != nil, + mq.withAuthors != nil, + mq.withTags != nil, + mq.withDependents != nil, + mq.withUserMods != nil, + mq.withModTags != nil, + mq.withVersionDependencies != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Mod).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Mod{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.withVersions; query != nil { + if err := mq.loadVersions(ctx, query, nodes, + func(n *Mod) { n.Edges.Versions = []*Version{} }, + func(n *Mod, e *Version) { n.Edges.Versions = append(n.Edges.Versions, e) }); err != nil { + return nil, err + } + } + if query := mq.withAuthors; query != nil { + if err := mq.loadAuthors(ctx, query, nodes, + func(n *Mod) { n.Edges.Authors = []*User{} }, + func(n *Mod, e *User) { n.Edges.Authors = append(n.Edges.Authors, e) }); err != nil { + return nil, err + } + } + if query := mq.withTags; query != nil { + if err := mq.loadTags(ctx, query, nodes, + func(n *Mod) { n.Edges.Tags = []*Tag{} }, + func(n *Mod, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil { + return nil, err + } + } + if query := mq.withDependents; query != nil { + if err := mq.loadDependents(ctx, query, nodes, + func(n *Mod) { n.Edges.Dependents = []*Version{} }, + func(n *Mod, e *Version) { n.Edges.Dependents = append(n.Edges.Dependents, 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{} }, + func(n *Mod, e *UserMod) { n.Edges.UserMods = append(n.Edges.UserMods, e) }); err != nil { + return nil, err + } + } + if query := mq.withModTags; query != nil { + if err := mq.loadModTags(ctx, query, nodes, + func(n *Mod) { n.Edges.ModTags = []*ModTag{} }, + func(n *Mod, e *ModTag) { n.Edges.ModTags = append(n.Edges.ModTags, e) }); err != nil { + return nil, err + } + } + if query := mq.withVersionDependencies; query != nil { + if err := mq.loadVersionDependencies(ctx, query, nodes, + func(n *Mod) { n.Edges.VersionDependencies = []*VersionDependency{} }, + func(n *Mod, e *VersionDependency) { + n.Edges.VersionDependencies = append(n.Edges.VersionDependencies, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mq *ModQuery) loadVersions(ctx context.Context, query *VersionQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *Version)) 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]) + } + } + query.withFKs = true + query.Where(predicate.Version(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mod.VersionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.mod_id + if fk == nil { + return fmt.Errorf(`foreign-key "mod_id" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "mod_id" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (mq *ModQuery) loadAuthors(ctx context.Context, query *UserQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *User)) 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.AuthorsTable) + s.Join(joinT).On(s.C(user.FieldID), joinT.C(mod.AuthorsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(mod.AuthorsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(mod.AuthorsPrimaryKey[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[[]*User](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 "authors" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (mq *ModQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *Tag)) 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.TagsTable) + s.Join(joinT).On(s.C(tag.FieldID), joinT.C(mod.TagsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(mod.TagsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(mod.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[*Mod]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 *ModQuery) loadDependents(ctx context.Context, query *VersionQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *Version)) 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.DependentsTable) + s.Join(joinT).On(s.C(version.FieldID), joinT.C(mod.DependentsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(mod.DependentsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(mod.DependentsPrimaryKey[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[[]*Version](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 "dependents" 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) + 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(usermod.FieldModID) + } + query.Where(predicate.UserMod(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mod.UserModsColumn), 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) loadModTags(ctx context.Context, query *ModTagQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *ModTag)) 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(modtag.FieldModID) + } + query.Where(predicate.ModTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mod.ModTagsColumn), 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) loadVersionDependencies(ctx context.Context, query *VersionDependencyQuery, nodes []*Mod, init func(*Mod), assign func(*Mod, *VersionDependency)) 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(versiondependency.FieldModID) + } + query.Where(predicate.VersionDependency(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(mod.VersionDependenciesColumn), 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() + 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 *ModQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(mod.Table, mod.Columns, sqlgraph.NewFieldSpec(mod.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, mod.FieldID) + for i := range fields { + if fields[i] != mod.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + 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 *ModQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mq.driver.Dialect()) + t1 := builder.Table(mod.Table) + columns := mq.ctx.Fields + if len(columns) == 0 { + columns = mod.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 *ModQuery) Modify(modifiers ...func(s *sql.Selector)) *ModSelect { + mq.modifiers = append(mq.modifiers, modifiers...) + return mq.Select() +} + +// ModGroupBy is the group-by builder for Mod entities. +type ModGroupBy struct { + selector + build *ModQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mgb *ModGroupBy) Aggregate(fns ...AggregateFunc) *ModGroupBy { + mgb.fns = append(mgb.fns, fns...) + return mgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mgb *ModGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + if err := mgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModQuery, *ModGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) +} + +func (mgb *ModGroupBy) sqlScan(ctx context.Context, root *ModQuery, 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) +} + +// ModSelect is the builder for selecting fields of Mod entities. +type ModSelect struct { + *ModQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ms *ModSelect) Aggregate(fns ...AggregateFunc) *ModSelect { + ms.fns = append(ms.fns, fns...) + return ms +} + +// Scan applies the selector query and scans the result into the given value. +func (ms *ModSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ms.ctx, "Select") + if err := ms.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModQuery, *ModSelect](ctx, ms.ModQuery, ms, ms.inters, v) +} + +func (ms *ModSelect) sqlScan(ctx context.Context, root *ModQuery, 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 *ModSelect) Modify(modifiers ...func(s *sql.Selector)) *ModSelect { + ms.modifiers = append(ms.modifiers, modifiers...) + return ms +} diff --git a/generated/ent/mod_update.go b/generated/ent/mod_update.go new file mode 100644 index 00000000..fe182682 --- /dev/null +++ b/generated/ent/mod_update.go @@ -0,0 +1,1414 @@ +// 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/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +// ModUpdate is the builder for updating Mod entities. +type ModUpdate struct { + config + hooks []Hook + mutation *ModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModUpdate builder. +func (mu *ModUpdate) Where(ps ...predicate.Mod) *ModUpdate { + mu.mutation.Where(ps...) + return mu +} + +// SetUpdatedAt sets the "updated_at" field. +func (mu *ModUpdate) SetUpdatedAt(t time.Time) *ModUpdate { + mu.mutation.SetUpdatedAt(t) + return mu +} + +// SetDeletedAt sets the "deleted_at" field. +func (mu *ModUpdate) SetDeletedAt(t time.Time) *ModUpdate { + mu.mutation.SetDeletedAt(t) + return mu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (mu *ModUpdate) SetNillableDeletedAt(t *time.Time) *ModUpdate { + if t != nil { + mu.SetDeletedAt(*t) + } + return mu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (mu *ModUpdate) ClearDeletedAt() *ModUpdate { + mu.mutation.ClearDeletedAt() + return mu +} + +// SetName sets the "name" field. +func (mu *ModUpdate) SetName(s string) *ModUpdate { + mu.mutation.SetName(s) + return mu +} + +// SetShortDescription sets the "short_description" field. +func (mu *ModUpdate) SetShortDescription(s string) *ModUpdate { + mu.mutation.SetShortDescription(s) + return mu +} + +// SetFullDescription sets the "full_description" field. +func (mu *ModUpdate) SetFullDescription(s string) *ModUpdate { + mu.mutation.SetFullDescription(s) + return mu +} + +// SetLogo sets the "logo" field. +func (mu *ModUpdate) SetLogo(s string) *ModUpdate { + mu.mutation.SetLogo(s) + return mu +} + +// SetSourceURL sets the "source_url" field. +func (mu *ModUpdate) SetSourceURL(s string) *ModUpdate { + mu.mutation.SetSourceURL(s) + return mu +} + +// SetCreatorID sets the "creator_id" field. +func (mu *ModUpdate) SetCreatorID(s string) *ModUpdate { + mu.mutation.SetCreatorID(s) + return mu +} + +// SetApproved sets the "approved" field. +func (mu *ModUpdate) SetApproved(b bool) *ModUpdate { + mu.mutation.SetApproved(b) + return mu +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (mu *ModUpdate) SetNillableApproved(b *bool) *ModUpdate { + if b != nil { + mu.SetApproved(*b) + } + return mu +} + +// SetViews sets the "views" field. +func (mu *ModUpdate) SetViews(u uint) *ModUpdate { + mu.mutation.ResetViews() + mu.mutation.SetViews(u) + return mu +} + +// AddViews adds u to the "views" field. +func (mu *ModUpdate) AddViews(u int) *ModUpdate { + mu.mutation.AddViews(u) + return mu +} + +// SetHotness sets the "hotness" field. +func (mu *ModUpdate) SetHotness(u uint) *ModUpdate { + mu.mutation.ResetHotness() + mu.mutation.SetHotness(u) + return mu +} + +// AddHotness adds u to the "hotness" field. +func (mu *ModUpdate) AddHotness(u int) *ModUpdate { + mu.mutation.AddHotness(u) + return mu +} + +// SetPopularity sets the "popularity" field. +func (mu *ModUpdate) SetPopularity(u uint) *ModUpdate { + mu.mutation.ResetPopularity() + mu.mutation.SetPopularity(u) + return mu +} + +// AddPopularity adds u to the "popularity" field. +func (mu *ModUpdate) AddPopularity(u int) *ModUpdate { + mu.mutation.AddPopularity(u) + return mu +} + +// SetDownloads sets the "downloads" field. +func (mu *ModUpdate) SetDownloads(u uint) *ModUpdate { + mu.mutation.ResetDownloads() + mu.mutation.SetDownloads(u) + return mu +} + +// AddDownloads adds u to the "downloads" field. +func (mu *ModUpdate) AddDownloads(u int) *ModUpdate { + mu.mutation.AddDownloads(u) + return mu +} + +// SetDenied sets the "denied" field. +func (mu *ModUpdate) SetDenied(b bool) *ModUpdate { + mu.mutation.SetDenied(b) + return mu +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (mu *ModUpdate) SetNillableDenied(b *bool) *ModUpdate { + if b != nil { + mu.SetDenied(*b) + } + return mu +} + +// SetLastVersionDate sets the "last_version_date" field. +func (mu *ModUpdate) SetLastVersionDate(t time.Time) *ModUpdate { + mu.mutation.SetLastVersionDate(t) + return mu +} + +// SetModReference sets the "mod_reference" field. +func (mu *ModUpdate) SetModReference(s string) *ModUpdate { + mu.mutation.SetModReference(s) + return mu +} + +// SetHidden sets the "hidden" field. +func (mu *ModUpdate) SetHidden(b bool) *ModUpdate { + mu.mutation.SetHidden(b) + return mu +} + +// SetCompatibility sets the "compatibility" field. +func (mu *ModUpdate) SetCompatibility(pi *postgres.CompatibilityInfo) *ModUpdate { + mu.mutation.SetCompatibility(pi) + return mu +} + +// AddVersionIDs adds the "versions" edge to the Version entity by IDs. +func (mu *ModUpdate) AddVersionIDs(ids ...string) *ModUpdate { + mu.mutation.AddVersionIDs(ids...) + return mu +} + +// AddVersions adds the "versions" edges to the Version entity. +func (mu *ModUpdate) AddVersions(v ...*Version) *ModUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mu.AddVersionIDs(ids...) +} + +// AddAuthorIDs adds the "authors" edge to the User entity by IDs. +func (mu *ModUpdate) AddAuthorIDs(ids ...string) *ModUpdate { + mu.mutation.AddAuthorIDs(ids...) + return mu +} + +// AddAuthors adds the "authors" edges to the User entity. +func (mu *ModUpdate) AddAuthors(u ...*User) *ModUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return mu.AddAuthorIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (mu *ModUpdate) AddTagIDs(ids ...string) *ModUpdate { + mu.mutation.AddTagIDs(ids...) + return mu +} + +// AddTags adds the "tags" edges to the Tag entity. +func (mu *ModUpdate) AddTags(t ...*Tag) *ModUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mu.AddTagIDs(ids...) +} + +// AddDependentIDs adds the "dependents" edge to the Version entity by IDs. +func (mu *ModUpdate) AddDependentIDs(ids ...string) *ModUpdate { + mu.mutation.AddDependentIDs(ids...) + return mu +} + +// AddDependents adds the "dependents" edges to the Version entity. +func (mu *ModUpdate) AddDependents(v ...*Version) *ModUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mu.AddDependentIDs(ids...) +} + +// Mutation returns the ModMutation object of the builder. +func (mu *ModUpdate) Mutation() *ModMutation { + return mu.mutation +} + +// ClearVersions clears all "versions" edges to the Version entity. +func (mu *ModUpdate) ClearVersions() *ModUpdate { + mu.mutation.ClearVersions() + return mu +} + +// RemoveVersionIDs removes the "versions" edge to Version entities by IDs. +func (mu *ModUpdate) RemoveVersionIDs(ids ...string) *ModUpdate { + mu.mutation.RemoveVersionIDs(ids...) + return mu +} + +// RemoveVersions removes "versions" edges to Version entities. +func (mu *ModUpdate) RemoveVersions(v ...*Version) *ModUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mu.RemoveVersionIDs(ids...) +} + +// ClearAuthors clears all "authors" edges to the User entity. +func (mu *ModUpdate) ClearAuthors() *ModUpdate { + mu.mutation.ClearAuthors() + return mu +} + +// RemoveAuthorIDs removes the "authors" edge to User entities by IDs. +func (mu *ModUpdate) RemoveAuthorIDs(ids ...string) *ModUpdate { + mu.mutation.RemoveAuthorIDs(ids...) + return mu +} + +// RemoveAuthors removes "authors" edges to User entities. +func (mu *ModUpdate) RemoveAuthors(u ...*User) *ModUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return mu.RemoveAuthorIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (mu *ModUpdate) ClearTags() *ModUpdate { + mu.mutation.ClearTags() + return mu +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (mu *ModUpdate) RemoveTagIDs(ids ...string) *ModUpdate { + mu.mutation.RemoveTagIDs(ids...) + return mu +} + +// RemoveTags removes "tags" edges to Tag entities. +func (mu *ModUpdate) RemoveTags(t ...*Tag) *ModUpdate { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return mu.RemoveTagIDs(ids...) +} + +// ClearDependents clears all "dependents" edges to the Version entity. +func (mu *ModUpdate) ClearDependents() *ModUpdate { + mu.mutation.ClearDependents() + return mu +} + +// RemoveDependentIDs removes the "dependents" edge to Version entities by IDs. +func (mu *ModUpdate) RemoveDependentIDs(ids ...string) *ModUpdate { + mu.mutation.RemoveDependentIDs(ids...) + return mu +} + +// RemoveDependents removes "dependents" edges to Version entities. +func (mu *ModUpdate) RemoveDependents(v ...*Version) *ModUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return mu.RemoveDependentIDs(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 { + return 0, err + } + return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mu *ModUpdate) SaveX(ctx context.Context) int { + affected, err := mu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mu *ModUpdate) Exec(ctx context.Context) error { + _, err := mu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mu *ModUpdate) 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 *ModUpdate) defaults() error { + if _, ok := mu.mutation.UpdatedAt(); !ok { + if mod.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized mod.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := mod.UpdateDefaultUpdatedAt() + mu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (mu *ModUpdate) check() error { + if v, ok := mu.mutation.Name(); ok { + if err := mod.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Mod.name": %w`, err)} + } + } + if v, ok := mu.mutation.ShortDescription(); ok { + if err := mod.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Mod.short_description": %w`, err)} + } + } + if v, ok := mu.mutation.ModReference(); ok { + if err := mod.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Mod.mod_reference": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mu *ModUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModUpdate { + mu.modifiers = append(mu.modifiers, modifiers...) + return mu +} + +func (mu *ModUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(mod.Table, mod.Columns, sqlgraph.NewFieldSpec(mod.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(mod.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := mu.mutation.DeletedAt(); ok { + _spec.SetField(mod.FieldDeletedAt, field.TypeTime, value) + } + if mu.mutation.DeletedAtCleared() { + _spec.ClearField(mod.FieldDeletedAt, field.TypeTime) + } + if value, ok := mu.mutation.Name(); ok { + _spec.SetField(mod.FieldName, field.TypeString, value) + } + if value, ok := mu.mutation.ShortDescription(); ok { + _spec.SetField(mod.FieldShortDescription, field.TypeString, value) + } + if value, ok := mu.mutation.FullDescription(); ok { + _spec.SetField(mod.FieldFullDescription, field.TypeString, value) + } + if value, ok := mu.mutation.Logo(); ok { + _spec.SetField(mod.FieldLogo, field.TypeString, value) + } + if value, ok := mu.mutation.SourceURL(); ok { + _spec.SetField(mod.FieldSourceURL, field.TypeString, value) + } + if value, ok := mu.mutation.CreatorID(); ok { + _spec.SetField(mod.FieldCreatorID, field.TypeString, value) + } + if value, ok := mu.mutation.Approved(); ok { + _spec.SetField(mod.FieldApproved, field.TypeBool, value) + } + if value, ok := mu.mutation.Views(); ok { + _spec.SetField(mod.FieldViews, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedViews(); ok { + _spec.AddField(mod.FieldViews, field.TypeUint, value) + } + if value, ok := mu.mutation.Hotness(); ok { + _spec.SetField(mod.FieldHotness, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedHotness(); ok { + _spec.AddField(mod.FieldHotness, field.TypeUint, value) + } + if value, ok := mu.mutation.Popularity(); ok { + _spec.SetField(mod.FieldPopularity, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedPopularity(); ok { + _spec.AddField(mod.FieldPopularity, field.TypeUint, value) + } + if value, ok := mu.mutation.Downloads(); ok { + _spec.SetField(mod.FieldDownloads, field.TypeUint, value) + } + if value, ok := mu.mutation.AddedDownloads(); ok { + _spec.AddField(mod.FieldDownloads, field.TypeUint, value) + } + if value, ok := mu.mutation.Denied(); ok { + _spec.SetField(mod.FieldDenied, field.TypeBool, value) + } + if value, ok := mu.mutation.LastVersionDate(); ok { + _spec.SetField(mod.FieldLastVersionDate, field.TypeTime, value) + } + if value, ok := mu.mutation.ModReference(); ok { + _spec.SetField(mod.FieldModReference, field.TypeString, value) + } + if value, ok := mu.mutation.Hidden(); ok { + _spec.SetField(mod.FieldHidden, field.TypeBool, value) + } + if value, ok := mu.mutation.Compatibility(); ok { + _spec.SetField(mod.FieldCompatibility, field.TypeJSON, value) + } + if mu.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !mu.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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.AuthorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedAuthorsIDs(); len(nodes) > 0 && !mu.mutation.AuthorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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.AuthorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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: mod.TagsTable, + Columns: mod.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: mod.TagsTable, + Columns: mod.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: mod.TagsTable, + Columns: mod.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) + } + if mu.mutation.DependentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + createE := &VersionDependencyCreate{config: mu.config, mutation: newVersionDependencyMutation(mu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.RemovedDependentsIDs(); len(nodes) > 0 && !mu.mutation.DependentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: mu.config, mutation: newVersionDependencyMutation(mu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mu.mutation.DependentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: mu.config, mutation: newVersionDependencyMutation(mu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _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{mod.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mu.mutation.done = true + return n, nil +} + +// ModUpdateOne is the builder for updating a single Mod entity. +type ModUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (muo *ModUpdateOne) SetUpdatedAt(t time.Time) *ModUpdateOne { + muo.mutation.SetUpdatedAt(t) + return muo +} + +// SetDeletedAt sets the "deleted_at" field. +func (muo *ModUpdateOne) SetDeletedAt(t time.Time) *ModUpdateOne { + muo.mutation.SetDeletedAt(t) + return muo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableDeletedAt(t *time.Time) *ModUpdateOne { + if t != nil { + muo.SetDeletedAt(*t) + } + return muo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (muo *ModUpdateOne) ClearDeletedAt() *ModUpdateOne { + muo.mutation.ClearDeletedAt() + return muo +} + +// SetName sets the "name" field. +func (muo *ModUpdateOne) SetName(s string) *ModUpdateOne { + muo.mutation.SetName(s) + return muo +} + +// SetShortDescription sets the "short_description" field. +func (muo *ModUpdateOne) SetShortDescription(s string) *ModUpdateOne { + muo.mutation.SetShortDescription(s) + return muo +} + +// SetFullDescription sets the "full_description" field. +func (muo *ModUpdateOne) SetFullDescription(s string) *ModUpdateOne { + muo.mutation.SetFullDescription(s) + return muo +} + +// SetLogo sets the "logo" field. +func (muo *ModUpdateOne) SetLogo(s string) *ModUpdateOne { + muo.mutation.SetLogo(s) + return muo +} + +// SetSourceURL sets the "source_url" field. +func (muo *ModUpdateOne) SetSourceURL(s string) *ModUpdateOne { + muo.mutation.SetSourceURL(s) + return muo +} + +// SetCreatorID sets the "creator_id" field. +func (muo *ModUpdateOne) SetCreatorID(s string) *ModUpdateOne { + muo.mutation.SetCreatorID(s) + return muo +} + +// SetApproved sets the "approved" field. +func (muo *ModUpdateOne) SetApproved(b bool) *ModUpdateOne { + muo.mutation.SetApproved(b) + return muo +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableApproved(b *bool) *ModUpdateOne { + if b != nil { + muo.SetApproved(*b) + } + return muo +} + +// SetViews sets the "views" field. +func (muo *ModUpdateOne) SetViews(u uint) *ModUpdateOne { + muo.mutation.ResetViews() + muo.mutation.SetViews(u) + return muo +} + +// AddViews adds u to the "views" field. +func (muo *ModUpdateOne) AddViews(u int) *ModUpdateOne { + muo.mutation.AddViews(u) + return muo +} + +// SetHotness sets the "hotness" field. +func (muo *ModUpdateOne) SetHotness(u uint) *ModUpdateOne { + muo.mutation.ResetHotness() + muo.mutation.SetHotness(u) + return muo +} + +// AddHotness adds u to the "hotness" field. +func (muo *ModUpdateOne) AddHotness(u int) *ModUpdateOne { + muo.mutation.AddHotness(u) + return muo +} + +// SetPopularity sets the "popularity" field. +func (muo *ModUpdateOne) SetPopularity(u uint) *ModUpdateOne { + muo.mutation.ResetPopularity() + muo.mutation.SetPopularity(u) + return muo +} + +// AddPopularity adds u to the "popularity" field. +func (muo *ModUpdateOne) AddPopularity(u int) *ModUpdateOne { + muo.mutation.AddPopularity(u) + return muo +} + +// SetDownloads sets the "downloads" field. +func (muo *ModUpdateOne) SetDownloads(u uint) *ModUpdateOne { + muo.mutation.ResetDownloads() + muo.mutation.SetDownloads(u) + return muo +} + +// AddDownloads adds u to the "downloads" field. +func (muo *ModUpdateOne) AddDownloads(u int) *ModUpdateOne { + muo.mutation.AddDownloads(u) + return muo +} + +// SetDenied sets the "denied" field. +func (muo *ModUpdateOne) SetDenied(b bool) *ModUpdateOne { + muo.mutation.SetDenied(b) + return muo +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableDenied(b *bool) *ModUpdateOne { + if b != nil { + muo.SetDenied(*b) + } + return muo +} + +// SetLastVersionDate sets the "last_version_date" field. +func (muo *ModUpdateOne) SetLastVersionDate(t time.Time) *ModUpdateOne { + muo.mutation.SetLastVersionDate(t) + return muo +} + +// SetModReference sets the "mod_reference" field. +func (muo *ModUpdateOne) SetModReference(s string) *ModUpdateOne { + muo.mutation.SetModReference(s) + return muo +} + +// SetHidden sets the "hidden" field. +func (muo *ModUpdateOne) SetHidden(b bool) *ModUpdateOne { + muo.mutation.SetHidden(b) + return muo +} + +// SetCompatibility sets the "compatibility" field. +func (muo *ModUpdateOne) SetCompatibility(pi *postgres.CompatibilityInfo) *ModUpdateOne { + muo.mutation.SetCompatibility(pi) + return muo +} + +// AddVersionIDs adds the "versions" edge to the Version entity by IDs. +func (muo *ModUpdateOne) AddVersionIDs(ids ...string) *ModUpdateOne { + muo.mutation.AddVersionIDs(ids...) + return muo +} + +// AddVersions adds the "versions" edges to the Version entity. +func (muo *ModUpdateOne) AddVersions(v ...*Version) *ModUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return muo.AddVersionIDs(ids...) +} + +// AddAuthorIDs adds the "authors" edge to the User entity by IDs. +func (muo *ModUpdateOne) AddAuthorIDs(ids ...string) *ModUpdateOne { + muo.mutation.AddAuthorIDs(ids...) + return muo +} + +// AddAuthors adds the "authors" edges to the User entity. +func (muo *ModUpdateOne) AddAuthors(u ...*User) *ModUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return muo.AddAuthorIDs(ids...) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by IDs. +func (muo *ModUpdateOne) AddTagIDs(ids ...string) *ModUpdateOne { + muo.mutation.AddTagIDs(ids...) + return muo +} + +// AddTags adds the "tags" edges to the Tag entity. +func (muo *ModUpdateOne) AddTags(t ...*Tag) *ModUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return muo.AddTagIDs(ids...) +} + +// AddDependentIDs adds the "dependents" edge to the Version entity by IDs. +func (muo *ModUpdateOne) AddDependentIDs(ids ...string) *ModUpdateOne { + muo.mutation.AddDependentIDs(ids...) + return muo +} + +// AddDependents adds the "dependents" edges to the Version entity. +func (muo *ModUpdateOne) AddDependents(v ...*Version) *ModUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return muo.AddDependentIDs(ids...) +} + +// Mutation returns the ModMutation object of the builder. +func (muo *ModUpdateOne) Mutation() *ModMutation { + return muo.mutation +} + +// ClearVersions clears all "versions" edges to the Version entity. +func (muo *ModUpdateOne) ClearVersions() *ModUpdateOne { + muo.mutation.ClearVersions() + return muo +} + +// RemoveVersionIDs removes the "versions" edge to Version entities by IDs. +func (muo *ModUpdateOne) RemoveVersionIDs(ids ...string) *ModUpdateOne { + muo.mutation.RemoveVersionIDs(ids...) + return muo +} + +// RemoveVersions removes "versions" edges to Version entities. +func (muo *ModUpdateOne) RemoveVersions(v ...*Version) *ModUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return muo.RemoveVersionIDs(ids...) +} + +// ClearAuthors clears all "authors" edges to the User entity. +func (muo *ModUpdateOne) ClearAuthors() *ModUpdateOne { + muo.mutation.ClearAuthors() + return muo +} + +// RemoveAuthorIDs removes the "authors" edge to User entities by IDs. +func (muo *ModUpdateOne) RemoveAuthorIDs(ids ...string) *ModUpdateOne { + muo.mutation.RemoveAuthorIDs(ids...) + return muo +} + +// RemoveAuthors removes "authors" edges to User entities. +func (muo *ModUpdateOne) RemoveAuthors(u ...*User) *ModUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return muo.RemoveAuthorIDs(ids...) +} + +// ClearTags clears all "tags" edges to the Tag entity. +func (muo *ModUpdateOne) ClearTags() *ModUpdateOne { + muo.mutation.ClearTags() + return muo +} + +// RemoveTagIDs removes the "tags" edge to Tag entities by IDs. +func (muo *ModUpdateOne) RemoveTagIDs(ids ...string) *ModUpdateOne { + muo.mutation.RemoveTagIDs(ids...) + return muo +} + +// RemoveTags removes "tags" edges to Tag entities. +func (muo *ModUpdateOne) RemoveTags(t ...*Tag) *ModUpdateOne { + ids := make([]string, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return muo.RemoveTagIDs(ids...) +} + +// ClearDependents clears all "dependents" edges to the Version entity. +func (muo *ModUpdateOne) ClearDependents() *ModUpdateOne { + muo.mutation.ClearDependents() + return muo +} + +// RemoveDependentIDs removes the "dependents" edge to Version entities by IDs. +func (muo *ModUpdateOne) RemoveDependentIDs(ids ...string) *ModUpdateOne { + muo.mutation.RemoveDependentIDs(ids...) + return muo +} + +// RemoveDependents removes "dependents" edges to Version entities. +func (muo *ModUpdateOne) RemoveDependents(v ...*Version) *ModUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return muo.RemoveDependentIDs(ids...) +} + +// Where appends a list predicates to the ModUpdate builder. +func (muo *ModUpdateOne) Where(ps ...predicate.Mod) *ModUpdateOne { + 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 *ModUpdateOne) Select(field string, fields ...string) *ModUpdateOne { + muo.fields = append([]string{field}, fields...) + return muo +} + +// Save executes the query and returns the updated Mod entity. +func (muo *ModUpdateOne) Save(ctx context.Context) (*Mod, error) { + if err := muo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (muo *ModUpdateOne) SaveX(ctx context.Context) *Mod { + node, err := muo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (muo *ModUpdateOne) Exec(ctx context.Context) error { + _, err := muo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (muo *ModUpdateOne) 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 *ModUpdateOne) defaults() error { + if _, ok := muo.mutation.UpdatedAt(); !ok { + if mod.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized mod.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := mod.UpdateDefaultUpdatedAt() + muo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (muo *ModUpdateOne) check() error { + if v, ok := muo.mutation.Name(); ok { + if err := mod.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Mod.name": %w`, err)} + } + } + if v, ok := muo.mutation.ShortDescription(); ok { + if err := mod.ShortDescriptionValidator(v); err != nil { + return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Mod.short_description": %w`, err)} + } + } + if v, ok := muo.mutation.ModReference(); ok { + if err := mod.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Mod.mod_reference": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (muo *ModUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModUpdateOne { + muo.modifiers = append(muo.modifiers, modifiers...) + return muo +} + +func (muo *ModUpdateOne) sqlSave(ctx context.Context) (_node *Mod, err error) { + if err := muo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(mod.Table, mod.Columns, sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString)) + id, ok := muo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Mod.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, mod.FieldID) + for _, f := range fields { + if !mod.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != mod.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(mod.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := muo.mutation.DeletedAt(); ok { + _spec.SetField(mod.FieldDeletedAt, field.TypeTime, value) + } + if muo.mutation.DeletedAtCleared() { + _spec.ClearField(mod.FieldDeletedAt, field.TypeTime) + } + if value, ok := muo.mutation.Name(); ok { + _spec.SetField(mod.FieldName, field.TypeString, value) + } + if value, ok := muo.mutation.ShortDescription(); ok { + _spec.SetField(mod.FieldShortDescription, field.TypeString, value) + } + if value, ok := muo.mutation.FullDescription(); ok { + _spec.SetField(mod.FieldFullDescription, field.TypeString, value) + } + if value, ok := muo.mutation.Logo(); ok { + _spec.SetField(mod.FieldLogo, field.TypeString, value) + } + if value, ok := muo.mutation.SourceURL(); ok { + _spec.SetField(mod.FieldSourceURL, field.TypeString, value) + } + if value, ok := muo.mutation.CreatorID(); ok { + _spec.SetField(mod.FieldCreatorID, field.TypeString, value) + } + if value, ok := muo.mutation.Approved(); ok { + _spec.SetField(mod.FieldApproved, field.TypeBool, value) + } + if value, ok := muo.mutation.Views(); ok { + _spec.SetField(mod.FieldViews, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedViews(); ok { + _spec.AddField(mod.FieldViews, field.TypeUint, value) + } + if value, ok := muo.mutation.Hotness(); ok { + _spec.SetField(mod.FieldHotness, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedHotness(); ok { + _spec.AddField(mod.FieldHotness, field.TypeUint, value) + } + if value, ok := muo.mutation.Popularity(); ok { + _spec.SetField(mod.FieldPopularity, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedPopularity(); ok { + _spec.AddField(mod.FieldPopularity, field.TypeUint, value) + } + if value, ok := muo.mutation.Downloads(); ok { + _spec.SetField(mod.FieldDownloads, field.TypeUint, value) + } + if value, ok := muo.mutation.AddedDownloads(); ok { + _spec.AddField(mod.FieldDownloads, field.TypeUint, value) + } + if value, ok := muo.mutation.Denied(); ok { + _spec.SetField(mod.FieldDenied, field.TypeBool, value) + } + if value, ok := muo.mutation.LastVersionDate(); ok { + _spec.SetField(mod.FieldLastVersionDate, field.TypeTime, value) + } + if value, ok := muo.mutation.ModReference(); ok { + _spec.SetField(mod.FieldModReference, field.TypeString, value) + } + if value, ok := muo.mutation.Hidden(); ok { + _spec.SetField(mod.FieldHidden, field.TypeBool, value) + } + if value, ok := muo.mutation.Compatibility(); ok { + _spec.SetField(mod.FieldCompatibility, field.TypeJSON, value) + } + if muo.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !muo.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: mod.VersionsTable, + Columns: []string{mod.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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.AuthorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedAuthorsIDs(); len(nodes) > 0 && !muo.mutation.AuthorsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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.AuthorsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.AuthorsTable, + Columns: mod.AuthorsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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: mod.TagsTable, + Columns: mod.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: mod.TagsTable, + Columns: mod.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: mod.TagsTable, + Columns: mod.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) + } + if muo.mutation.DependentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + createE := &VersionDependencyCreate{config: muo.config, mutation: newVersionDependencyMutation(muo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.RemovedDependentsIDs(); len(nodes) > 0 && !muo.mutation.DependentsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: muo.config, mutation: newVersionDependencyMutation(muo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := muo.mutation.DependentsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: mod.DependentsTable, + Columns: mod.DependentsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: muo.config, mutation: newVersionDependencyMutation(muo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(muo.modifiers...) + _node = &Mod{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{mod.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/modtag.go b/generated/ent/modtag.go new file mode 100644 index 00000000..fec4075b --- /dev/null +++ b/generated/ent/modtag.go @@ -0,0 +1,155 @@ +// 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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModTag is the model entity for the ModTag schema. +type ModTag struct { + config `json:"-"` + // ModID holds the value of the "mod_id" field. + ModID string `json:"mod_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 ModTagQuery when eager-loading is set. + Edges ModTagEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ModTagEdges holds the relations/edges for other nodes in the graph. +type ModTagEdges struct { + // Mod holds the value of the mod edge. + Mod *Mod `json:"mod,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 +} + +// 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 ModTagEdges) ModOrErr() (*Mod, error) { + if e.loadedTypes[0] { + if e.Mod == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: mod.Label} + } + return e.Mod, nil + } + return nil, &NotLoadedError{edge: "mod"} +} + +// 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 ModTagEdges) TagOrErr() (*Tag, error) { + if e.loadedTypes[1] { + if e.Tag == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: tag.Label} + } + return e.Tag, nil + } + return nil, &NotLoadedError{edge: "tag"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ModTag) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case modtag.FieldModID, modtag.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 ModTag fields. +func (mt *ModTag) 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 modtag.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 { + mt.ModID = value.String + } + case modtag.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 ModTag. +// This includes values selected through modifiers, order, etc. +func (mt *ModTag) Value(name string) (ent.Value, error) { + return mt.selectValues.Get(name) +} + +// QueryMod queries the "mod" edge of the ModTag entity. +func (mt *ModTag) QueryMod() *ModQuery { + return NewModTagClient(mt.config).QueryMod(mt) +} + +// QueryTag queries the "tag" edge of the ModTag entity. +func (mt *ModTag) QueryTag() *TagQuery { + return NewModTagClient(mt.config).QueryTag(mt) +} + +// Update returns a builder for updating this ModTag. +// Note that you need to call ModTag.Unwrap() before calling this method if this ModTag +// was returned from a transaction, and the transaction was committed or rolled back. +func (mt *ModTag) Update() *ModTagUpdateOne { + return NewModTagClient(mt.config).UpdateOne(mt) +} + +// Unwrap unwraps the ModTag 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 *ModTag) Unwrap() *ModTag { + _tx, ok := mt.config.driver.(*txDriver) + if !ok { + panic("ent: ModTag is not a transactional entity") + } + mt.config.driver = _tx.drv + return mt +} + +// String implements the fmt.Stringer. +func (mt *ModTag) String() string { + var builder strings.Builder + builder.WriteString("ModTag(") + builder.WriteString("mod_id=") + builder.WriteString(mt.ModID) + builder.WriteString(", ") + builder.WriteString("tag_id=") + builder.WriteString(mt.TagID) + builder.WriteByte(')') + return builder.String() +} + +// ModTags is a parsable slice of ModTag. +type ModTags []*ModTag diff --git a/generated/ent/modtag/modtag.go b/generated/ent/modtag/modtag.go new file mode 100644 index 00000000..7b05fcf4 --- /dev/null +++ b/generated/ent/modtag/modtag.go @@ -0,0 +1,98 @@ +// Code generated by ent, DO NOT EDIT. + +package modtag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the modtag type in the database. + Label = "mod_tag" + // FieldModID holds the string denoting the mod_id field in the database. + FieldModID = "mod_id" + // FieldTagID holds the string denoting the tag_id field in the database. + FieldTagID = "tag_id" + // EdgeMod holds the string denoting the mod edge name in mutations. + EdgeMod = "mod" + // EdgeTag holds the string denoting the tag edge name in mutations. + EdgeTag = "tag" + // ModFieldID holds the string denoting the ID field of the Mod. + ModFieldID = "id" + // TagFieldID holds the string denoting the ID field of the Tag. + TagFieldID = "id" + // Table holds the table name of the modtag in the database. + Table = "mod_tags" + // ModTable is the table that holds the mod relation/edge. + ModTable = "mod_tags" + // 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" + // TagTable is the table that holds the tag relation/edge. + TagTable = "mod_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 modtag fields. +var Columns = []string{ + FieldModID, + 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 ModTag queries. +type OrderOption func(*sql.Selector) + +// ByModID orders the results by the mod_id field. +func ByModID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModID, opts...).ToFunc() +} + +// ByTagID orders the results by the tag_id field. +func ByTagID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTagID, opts...).ToFunc() +} + +// 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...)) + } +} + +// 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 newModStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, ModColumn), + sqlgraph.To(ModInverseTable, ModFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ModTable, ModColumn), + ) +} +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/modtag/where.go b/generated/ent/modtag/where.go new file mode 100644 index 00000000..d054d836 --- /dev/null +++ b/generated/ent/modtag/where.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package modtag + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModID applies equality check predicate on the "mod_id" field. It's identical to ModIDEQ. +func ModID(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEQ(FieldModID, v)) +} + +// TagID applies equality check predicate on the "tag_id" field. It's identical to TagIDEQ. +func TagID(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEQ(FieldTagID, v)) +} + +// ModIDEQ applies the EQ predicate on the "mod_id" field. +func ModIDEQ(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEQ(FieldModID, v)) +} + +// ModIDNEQ applies the NEQ predicate on the "mod_id" field. +func ModIDNEQ(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldNEQ(FieldModID, v)) +} + +// ModIDIn applies the In predicate on the "mod_id" field. +func ModIDIn(vs ...string) predicate.ModTag { + return predicate.ModTag(sql.FieldIn(FieldModID, vs...)) +} + +// ModIDNotIn applies the NotIn predicate on the "mod_id" field. +func ModIDNotIn(vs ...string) predicate.ModTag { + return predicate.ModTag(sql.FieldNotIn(FieldModID, vs...)) +} + +// ModIDGT applies the GT predicate on the "mod_id" field. +func ModIDGT(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldGT(FieldModID, v)) +} + +// ModIDGTE applies the GTE predicate on the "mod_id" field. +func ModIDGTE(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldGTE(FieldModID, v)) +} + +// ModIDLT applies the LT predicate on the "mod_id" field. +func ModIDLT(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldLT(FieldModID, v)) +} + +// ModIDLTE applies the LTE predicate on the "mod_id" field. +func ModIDLTE(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldLTE(FieldModID, v)) +} + +// ModIDContains applies the Contains predicate on the "mod_id" field. +func ModIDContains(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldContains(FieldModID, v)) +} + +// ModIDHasPrefix applies the HasPrefix predicate on the "mod_id" field. +func ModIDHasPrefix(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldHasPrefix(FieldModID, v)) +} + +// ModIDHasSuffix applies the HasSuffix predicate on the "mod_id" field. +func ModIDHasSuffix(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldHasSuffix(FieldModID, v)) +} + +// ModIDEqualFold applies the EqualFold predicate on the "mod_id" field. +func ModIDEqualFold(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEqualFold(FieldModID, v)) +} + +// ModIDContainsFold applies the ContainsFold predicate on the "mod_id" field. +func ModIDContainsFold(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldContainsFold(FieldModID, v)) +} + +// TagIDEQ applies the EQ predicate on the "tag_id" field. +func TagIDEQ(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEQ(FieldTagID, v)) +} + +// TagIDNEQ applies the NEQ predicate on the "tag_id" field. +func TagIDNEQ(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldNEQ(FieldTagID, v)) +} + +// TagIDIn applies the In predicate on the "tag_id" field. +func TagIDIn(vs ...string) predicate.ModTag { + return predicate.ModTag(sql.FieldIn(FieldTagID, vs...)) +} + +// TagIDNotIn applies the NotIn predicate on the "tag_id" field. +func TagIDNotIn(vs ...string) predicate.ModTag { + return predicate.ModTag(sql.FieldNotIn(FieldTagID, vs...)) +} + +// TagIDGT applies the GT predicate on the "tag_id" field. +func TagIDGT(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldGT(FieldTagID, v)) +} + +// TagIDGTE applies the GTE predicate on the "tag_id" field. +func TagIDGTE(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldGTE(FieldTagID, v)) +} + +// TagIDLT applies the LT predicate on the "tag_id" field. +func TagIDLT(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldLT(FieldTagID, v)) +} + +// TagIDLTE applies the LTE predicate on the "tag_id" field. +func TagIDLTE(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldLTE(FieldTagID, v)) +} + +// TagIDContains applies the Contains predicate on the "tag_id" field. +func TagIDContains(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldContains(FieldTagID, v)) +} + +// TagIDHasPrefix applies the HasPrefix predicate on the "tag_id" field. +func TagIDHasPrefix(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldHasPrefix(FieldTagID, v)) +} + +// TagIDHasSuffix applies the HasSuffix predicate on the "tag_id" field. +func TagIDHasSuffix(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldHasSuffix(FieldTagID, v)) +} + +// TagIDEqualFold applies the EqualFold predicate on the "tag_id" field. +func TagIDEqualFold(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldEqualFold(FieldTagID, v)) +} + +// TagIDContainsFold applies the ContainsFold predicate on the "tag_id" field. +func TagIDContainsFold(v string) predicate.ModTag { + return predicate.ModTag(sql.FieldContainsFold(FieldTagID, v)) +} + +// HasMod applies the HasEdge predicate on the "mod" edge. +func HasMod() predicate.ModTag { + return predicate.ModTag(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.ModTag { + return predicate.ModTag(func(s *sql.Selector) { + step := newModStep() + 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.ModTag { + return predicate.ModTag(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.ModTag { + return predicate.ModTag(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.ModTag) predicate.ModTag { + return predicate.ModTag(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ModTag) predicate.ModTag { + return predicate.ModTag(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ModTag) predicate.ModTag { + return predicate.ModTag(sql.NotPredicates(p)) +} diff --git a/generated/ent/modtag_create.go b/generated/ent/modtag_create.go new file mode 100644 index 00000000..7330d929 --- /dev/null +++ b/generated/ent/modtag_create.go @@ -0,0 +1,231 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModTagCreate is the builder for creating a ModTag entity. +type ModTagCreate struct { + config + mutation *ModTagMutation + hooks []Hook +} + +// SetModID sets the "mod_id" field. +func (mtc *ModTagCreate) SetModID(s string) *ModTagCreate { + mtc.mutation.SetModID(s) + return mtc +} + +// SetTagID sets the "tag_id" field. +func (mtc *ModTagCreate) SetTagID(s string) *ModTagCreate { + mtc.mutation.SetTagID(s) + return mtc +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mtc *ModTagCreate) SetMod(m *Mod) *ModTagCreate { + return mtc.SetModID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtc *ModTagCreate) SetTag(t *Tag) *ModTagCreate { + return mtc.SetTagID(t.ID) +} + +// Mutation returns the ModTagMutation object of the builder. +func (mtc *ModTagCreate) Mutation() *ModTagMutation { + return mtc.mutation +} + +// Save creates the ModTag in the database. +func (mtc *ModTagCreate) Save(ctx context.Context) (*ModTag, error) { + return withHooks(ctx, mtc.sqlSave, mtc.mutation, mtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mtc *ModTagCreate) SaveX(ctx context.Context) *ModTag { + v, err := mtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtc *ModTagCreate) Exec(ctx context.Context) error { + _, err := mtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtc *ModTagCreate) 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 *ModTagCreate) check() error { + if _, ok := mtc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod_id", err: errors.New(`ent: missing required field "ModTag.mod_id"`)} + } + if _, ok := mtc.mutation.TagID(); !ok { + return &ValidationError{Name: "tag_id", err: errors.New(`ent: missing required field "ModTag.tag_id"`)} + } + if _, ok := mtc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod", err: errors.New(`ent: missing required edge "ModTag.mod"`)} + } + if _, ok := mtc.mutation.TagID(); !ok { + return &ValidationError{Name: "tag", err: errors.New(`ent: missing required edge "ModTag.tag"`)} + } + return nil +} + +func (mtc *ModTagCreate) sqlSave(ctx context.Context) (*ModTag, 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 *ModTagCreate) createSpec() (*ModTag, *sqlgraph.CreateSpec) { + var ( + _node = &ModTag{config: mtc.config} + _spec = sqlgraph.NewCreateSpec(modtag.Table, nil) + ) + if nodes := mtc.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.ModTable, + Columns: []string{modtag.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) + } + if nodes := mtc.mutation.TagIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.TagTable, + Columns: []string{modtag.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 +} + +// ModTagCreateBulk is the builder for creating many ModTag entities in bulk. +type ModTagCreateBulk struct { + config + err error + builders []*ModTagCreate +} + +// Save creates the ModTag entities in the database. +func (mtcb *ModTagCreateBulk) Save(ctx context.Context) ([]*ModTag, error) { + if mtcb.err != nil { + return nil, mtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mtcb.builders)) + nodes := make([]*ModTag, 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.(*ModTagMutation) + 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} + // 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 *ModTagCreateBulk) SaveX(ctx context.Context) []*ModTag { + v, err := mtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mtcb *ModTagCreateBulk) Exec(ctx context.Context) error { + _, err := mtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtcb *ModTagCreateBulk) ExecX(ctx context.Context) { + if err := mtcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modtag_delete.go b/generated/ent/modtag_delete.go new file mode 100644 index 00000000..4ebd6b20 --- /dev/null +++ b/generated/ent/modtag_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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// ModTagDelete is the builder for deleting a ModTag entity. +type ModTagDelete struct { + config + hooks []Hook + mutation *ModTagMutation +} + +// Where appends a list predicates to the ModTagDelete builder. +func (mtd *ModTagDelete) Where(ps ...predicate.ModTag) *ModTagDelete { + mtd.mutation.Where(ps...) + return mtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mtd *ModTagDelete) 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 *ModTagDelete) ExecX(ctx context.Context) int { + n, err := mtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mtd *ModTagDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(modtag.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 +} + +// ModTagDeleteOne is the builder for deleting a single ModTag entity. +type ModTagDeleteOne struct { + mtd *ModTagDelete +} + +// Where appends a list predicates to the ModTagDelete builder. +func (mtdo *ModTagDeleteOne) Where(ps ...predicate.ModTag) *ModTagDeleteOne { + mtdo.mtd.mutation.Where(ps...) + return mtdo +} + +// Exec executes the deletion query. +func (mtdo *ModTagDeleteOne) Exec(ctx context.Context) error { + n, err := mtdo.mtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{modtag.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtdo *ModTagDeleteOne) ExecX(ctx context.Context) { + if err := mtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/modtag_query.go b/generated/ent/modtag_query.go new file mode 100644 index 00000000..457cc629 --- /dev/null +++ b/generated/ent/modtag_query.go @@ -0,0 +1,624 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModTagQuery is the builder for querying ModTag entities. +type ModTagQuery struct { + config + ctx *QueryContext + order []modtag.OrderOption + inters []Interceptor + predicates []predicate.ModTag + withMod *ModQuery + 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 ModTagQuery builder. +func (mtq *ModTagQuery) Where(ps ...predicate.ModTag) *ModTagQuery { + mtq.predicates = append(mtq.predicates, ps...) + return mtq +} + +// Limit the number of records to be returned by this query. +func (mtq *ModTagQuery) Limit(limit int) *ModTagQuery { + mtq.ctx.Limit = &limit + return mtq +} + +// Offset to start from. +func (mtq *ModTagQuery) Offset(offset int) *ModTagQuery { + 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 *ModTagQuery) Unique(unique bool) *ModTagQuery { + mtq.ctx.Unique = &unique + return mtq +} + +// Order specifies how the records should be ordered. +func (mtq *ModTagQuery) Order(o ...modtag.OrderOption) *ModTagQuery { + mtq.order = append(mtq.order, o...) + return mtq +} + +// QueryMod chains the current query on the "mod" edge. +func (mtq *ModTagQuery) QueryMod() *ModQuery { + query := (&ModClient{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(modtag.Table, modtag.ModColumn, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modtag.ModTable, modtag.ModColumn), + ) + fromU = sqlgraph.SetNeighbors(mtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTag chains the current query on the "tag" edge. +func (mtq *ModTagQuery) 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(modtag.Table, modtag.TagColumn, selector), + sqlgraph.To(tag.Table, tag.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, modtag.TagTable, modtag.TagColumn), + ) + fromU = sqlgraph.SetNeighbors(mtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ModTag entity from the query. +// Returns a *NotFoundError when no ModTag was found. +func (mtq *ModTagQuery) First(ctx context.Context) (*ModTag, error) { + nodes, err := mtq.Limit(1).All(setContextOp(ctx, mtq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{modtag.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mtq *ModTagQuery) FirstX(ctx context.Context) *ModTag { + node, err := mtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single ModTag entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ModTag entity is found. +// Returns a *NotFoundError when no ModTag entities are found. +func (mtq *ModTagQuery) Only(ctx context.Context) (*ModTag, error) { + nodes, err := mtq.Limit(2).All(setContextOp(ctx, mtq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{modtag.Label} + default: + return nil, &NotSingularError{modtag.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mtq *ModTagQuery) OnlyX(ctx context.Context) *ModTag { + node, err := mtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of ModTags. +func (mtq *ModTagQuery) All(ctx context.Context) ([]*ModTag, error) { + ctx = setContextOp(ctx, mtq.ctx, "All") + if err := mtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ModTag, *ModTagQuery]() + return withInterceptors[[]*ModTag](ctx, mtq, qr, mtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mtq *ModTagQuery) AllX(ctx context.Context) []*ModTag { + nodes, err := mtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (mtq *ModTagQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mtq.ctx, "Count") + if err := mtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mtq, querierCount[*ModTagQuery](), mtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mtq *ModTagQuery) 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 *ModTagQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mtq.ctx, "Exist") + 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 *ModTagQuery) ExistX(ctx context.Context) bool { + exist, err := mtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ModTagQuery 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 *ModTagQuery) Clone() *ModTagQuery { + if mtq == nil { + return nil + } + return &ModTagQuery{ + config: mtq.config, + ctx: mtq.ctx.Clone(), + order: append([]modtag.OrderOption{}, mtq.order...), + inters: append([]Interceptor{}, mtq.inters...), + predicates: append([]predicate.ModTag{}, mtq.predicates...), + withMod: mtq.withMod.Clone(), + withTag: mtq.withTag.Clone(), + // clone intermediate query. + sql: mtq.sql.Clone(), + path: mtq.path, + } +} + +// 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 (mtq *ModTagQuery) WithMod(opts ...func(*ModQuery)) *ModTagQuery { + query := (&ModClient{config: mtq.config}).Query() + for _, opt := range opts { + opt(query) + } + mtq.withMod = 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 *ModTagQuery) WithTag(opts ...func(*TagQuery)) *ModTagQuery { + 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 { +// ModID string `json:"mod_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ModTag.Query(). +// GroupBy(modtag.FieldModID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mtq *ModTagQuery) GroupBy(field string, fields ...string) *ModTagGroupBy { + mtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ModTagGroupBy{build: mtq} + grbuild.flds = &mtq.ctx.Fields + grbuild.label = modtag.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 { +// ModID string `json:"mod_id,omitempty"` +// } +// +// client.ModTag.Query(). +// Select(modtag.FieldModID). +// Scan(ctx, &v) +func (mtq *ModTagQuery) Select(fields ...string) *ModTagSelect { + mtq.ctx.Fields = append(mtq.ctx.Fields, fields...) + sbuild := &ModTagSelect{ModTagQuery: mtq} + sbuild.label = modtag.Label + sbuild.flds, sbuild.scan = &mtq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ModTagSelect configured with the given aggregations. +func (mtq *ModTagQuery) Aggregate(fns ...AggregateFunc) *ModTagSelect { + return mtq.Select().Aggregate(fns...) +} + +func (mtq *ModTagQuery) 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 !modtag.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 *ModTagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ModTag, error) { + var ( + nodes = []*ModTag{} + _spec = mtq.querySpec() + loadedTypes = [2]bool{ + mtq.withMod != nil, + mtq.withTag != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ModTag).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ModTag{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.withMod; query != nil { + if err := mtq.loadMod(ctx, query, nodes, nil, + func(n *ModTag, e *Mod) { n.Edges.Mod = e }); err != nil { + return nil, err + } + } + if query := mtq.withTag; query != nil { + if err := mtq.loadTag(ctx, query, nodes, nil, + func(n *ModTag, e *Tag) { n.Edges.Tag = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (mtq *ModTagQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*ModTag, init func(*ModTag), assign func(*ModTag, *Mod)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModTag) + 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 (mtq *ModTagQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*ModTag, init func(*ModTag), assign func(*ModTag, *Tag)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*ModTag) + 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 *ModTagQuery) 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 *ModTagQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(modtag.Table, modtag.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.withMod != nil { + _spec.Node.AddColumnOnce(modtag.FieldModID) + } + if mtq.withTag != nil { + _spec.Node.AddColumnOnce(modtag.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 *ModTagQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mtq.driver.Dialect()) + t1 := builder.Table(modtag.Table) + columns := mtq.ctx.Fields + if len(columns) == 0 { + columns = modtag.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 *ModTagQuery) Modify(modifiers ...func(s *sql.Selector)) *ModTagSelect { + mtq.modifiers = append(mtq.modifiers, modifiers...) + return mtq.Select() +} + +// ModTagGroupBy is the group-by builder for ModTag entities. +type ModTagGroupBy struct { + selector + build *ModTagQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mtgb *ModTagGroupBy) Aggregate(fns ...AggregateFunc) *ModTagGroupBy { + mtgb.fns = append(mtgb.fns, fns...) + return mtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (mtgb *ModTagGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mtgb.build.ctx, "GroupBy") + if err := mtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModTagQuery, *ModTagGroupBy](ctx, mtgb.build, mtgb, mtgb.build.inters, v) +} + +func (mtgb *ModTagGroupBy) sqlScan(ctx context.Context, root *ModTagQuery, 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) +} + +// ModTagSelect is the builder for selecting fields of ModTag entities. +type ModTagSelect struct { + *ModTagQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mts *ModTagSelect) Aggregate(fns ...AggregateFunc) *ModTagSelect { + mts.fns = append(mts.fns, fns...) + return mts +} + +// Scan applies the selector query and scans the result into the given value. +func (mts *ModTagSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mts.ctx, "Select") + if err := mts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ModTagQuery, *ModTagSelect](ctx, mts.ModTagQuery, mts, mts.inters, v) +} + +func (mts *ModTagSelect) sqlScan(ctx context.Context, root *ModTagQuery, 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 *ModTagSelect) Modify(modifiers ...func(s *sql.Selector)) *ModTagSelect { + mts.modifiers = append(mts.modifiers, modifiers...) + return mts +} diff --git a/generated/ent/modtag_update.go b/generated/ent/modtag_update.go new file mode 100644 index 00000000..597f1630 --- /dev/null +++ b/generated/ent/modtag_update.go @@ -0,0 +1,407 @@ +// 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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// ModTagUpdate is the builder for updating ModTag entities. +type ModTagUpdate struct { + config + hooks []Hook + mutation *ModTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ModTagUpdate builder. +func (mtu *ModTagUpdate) Where(ps ...predicate.ModTag) *ModTagUpdate { + mtu.mutation.Where(ps...) + return mtu +} + +// SetModID sets the "mod_id" field. +func (mtu *ModTagUpdate) SetModID(s string) *ModTagUpdate { + mtu.mutation.SetModID(s) + return mtu +} + +// SetTagID sets the "tag_id" field. +func (mtu *ModTagUpdate) SetTagID(s string) *ModTagUpdate { + mtu.mutation.SetTagID(s) + return mtu +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mtu *ModTagUpdate) SetMod(m *Mod) *ModTagUpdate { + return mtu.SetModID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtu *ModTagUpdate) SetTag(t *Tag) *ModTagUpdate { + return mtu.SetTagID(t.ID) +} + +// Mutation returns the ModTagMutation object of the builder. +func (mtu *ModTagUpdate) Mutation() *ModTagMutation { + return mtu.mutation +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (mtu *ModTagUpdate) ClearMod() *ModTagUpdate { + mtu.mutation.ClearMod() + return mtu +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (mtu *ModTagUpdate) ClearTag() *ModTagUpdate { + mtu.mutation.ClearTag() + return mtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mtu *ModTagUpdate) 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 *ModTagUpdate) SaveX(ctx context.Context) int { + affected, err := mtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mtu *ModTagUpdate) Exec(ctx context.Context) error { + _, err := mtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtu *ModTagUpdate) 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 *ModTagUpdate) check() error { + if _, ok := mtu.mutation.ModID(); mtu.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ModTag.mod"`) + } + if _, ok := mtu.mutation.TagID(); mtu.mutation.TagCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ModTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtu *ModTagUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModTagUpdate { + mtu.modifiers = append(mtu.modifiers, modifiers...) + return mtu +} + +func (mtu *ModTagUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := mtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(modtag.Table, modtag.Columns, sqlgraph.NewFieldSpec(modtag.FieldModID, field.TypeString), sqlgraph.NewFieldSpec(modtag.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.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.ModTable, + Columns: []string{modtag.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtu.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.ModTable, + Columns: []string{modtag.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) + } + if mtu.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.TagTable, + Columns: []string{modtag.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: modtag.TagTable, + Columns: []string{modtag.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{modtag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mtu.mutation.done = true + return n, nil +} + +// ModTagUpdateOne is the builder for updating a single ModTag entity. +type ModTagUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ModTagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetModID sets the "mod_id" field. +func (mtuo *ModTagUpdateOne) SetModID(s string) *ModTagUpdateOne { + mtuo.mutation.SetModID(s) + return mtuo +} + +// SetTagID sets the "tag_id" field. +func (mtuo *ModTagUpdateOne) SetTagID(s string) *ModTagUpdateOne { + mtuo.mutation.SetTagID(s) + return mtuo +} + +// SetMod sets the "mod" edge to the Mod entity. +func (mtuo *ModTagUpdateOne) SetMod(m *Mod) *ModTagUpdateOne { + return mtuo.SetModID(m.ID) +} + +// SetTag sets the "tag" edge to the Tag entity. +func (mtuo *ModTagUpdateOne) SetTag(t *Tag) *ModTagUpdateOne { + return mtuo.SetTagID(t.ID) +} + +// Mutation returns the ModTagMutation object of the builder. +func (mtuo *ModTagUpdateOne) Mutation() *ModTagMutation { + return mtuo.mutation +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (mtuo *ModTagUpdateOne) ClearMod() *ModTagUpdateOne { + mtuo.mutation.ClearMod() + return mtuo +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (mtuo *ModTagUpdateOne) ClearTag() *ModTagUpdateOne { + mtuo.mutation.ClearTag() + return mtuo +} + +// Where appends a list predicates to the ModTagUpdate builder. +func (mtuo *ModTagUpdateOne) Where(ps ...predicate.ModTag) *ModTagUpdateOne { + 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 *ModTagUpdateOne) Select(field string, fields ...string) *ModTagUpdateOne { + mtuo.fields = append([]string{field}, fields...) + return mtuo +} + +// Save executes the query and returns the updated ModTag entity. +func (mtuo *ModTagUpdateOne) Save(ctx context.Context) (*ModTag, error) { + return withHooks(ctx, mtuo.sqlSave, mtuo.mutation, mtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mtuo *ModTagUpdateOne) SaveX(ctx context.Context) *ModTag { + node, err := mtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mtuo *ModTagUpdateOne) Exec(ctx context.Context) error { + _, err := mtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mtuo *ModTagUpdateOne) 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 *ModTagUpdateOne) check() error { + if _, ok := mtuo.mutation.ModID(); mtuo.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ModTag.mod"`) + } + if _, ok := mtuo.mutation.TagID(); mtuo.mutation.TagCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "ModTag.tag"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (mtuo *ModTagUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ModTagUpdateOne { + mtuo.modifiers = append(mtuo.modifiers, modifiers...) + return mtuo +} + +func (mtuo *ModTagUpdateOne) sqlSave(ctx context.Context) (_node *ModTag, err error) { + if err := mtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(modtag.Table, modtag.Columns, sqlgraph.NewFieldSpec(modtag.FieldModID, field.TypeString), sqlgraph.NewFieldSpec(modtag.FieldTagID, field.TypeString)) + if id, ok := mtuo.mutation.ModID(); !ok { + return nil, &ValidationError{Name: "mod_id", err: errors.New(`ent: missing "ModTag.mod_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 "ModTag.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 !modtag.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.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.ModTable, + Columns: []string{modtag.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := mtuo.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.ModTable, + Columns: []string{modtag.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) + } + if mtuo.mutation.TagCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: modtag.TagTable, + Columns: []string{modtag.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: modtag.TagTable, + Columns: []string{modtag.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 = &ModTag{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{modtag.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 new file mode 100644 index 00000000..3e5eb695 --- /dev/null +++ b/generated/ent/mutation.go @@ -0,0 +1,11676 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "sync" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent/announcement" + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeAnnouncement = "Announcement" + TypeGuide = "Guide" + TypeGuideTag = "GuideTag" + TypeMod = "Mod" + TypeModTag = "ModTag" + TypeSmlVersion = "SmlVersion" + TypeSmlVersionTarget = "SmlVersionTarget" + TypeTag = "Tag" + TypeUser = "User" + TypeUserGroup = "UserGroup" + TypeUserMod = "UserMod" + TypeUserSession = "UserSession" + TypeVersion = "Version" + TypeVersionDependency = "VersionDependency" +) + +// AnnouncementMutation represents an operation that mutates the Announcement nodes in the graph. +type AnnouncementMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + message *string + importance *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Announcement, error) + predicates []predicate.Announcement +} + +var _ ent.Mutation = (*AnnouncementMutation)(nil) + +// announcementOption allows management of the mutation configuration using functional options. +type announcementOption func(*AnnouncementMutation) + +// newAnnouncementMutation creates new mutation for the Announcement entity. +func newAnnouncementMutation(c config, op Op, opts ...announcementOption) *AnnouncementMutation { + m := &AnnouncementMutation{ + config: c, + op: op, + typ: TypeAnnouncement, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withAnnouncementID sets the ID field of the mutation. +func withAnnouncementID(id string) announcementOption { + return func(m *AnnouncementMutation) { + var ( + err error + once sync.Once + value *Announcement + ) + m.oldValue = func(ctx context.Context) (*Announcement, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Announcement.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withAnnouncement sets the old Announcement of the mutation. +func withAnnouncement(node *Announcement) announcementOption { + return func(m *AnnouncementMutation) { + m.oldValue = func(context.Context) (*Announcement, 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 AnnouncementMutation) 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 AnnouncementMutation) 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 Announcement entities. +func (m *AnnouncementMutation) 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 *AnnouncementMutation) 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 *AnnouncementMutation) 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().Announcement.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 *AnnouncementMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AnnouncementMutation) 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 Announcement entity. +// If the Announcement 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 *AnnouncementMutation) 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 *AnnouncementMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AnnouncementMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AnnouncementMutation) 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 Announcement entity. +// If the Announcement 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 *AnnouncementMutation) 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 *AnnouncementMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *AnnouncementMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *AnnouncementMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Announcement entity. +// If the Announcement 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 *AnnouncementMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *AnnouncementMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[announcement.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *AnnouncementMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[announcement.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *AnnouncementMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, announcement.FieldDeletedAt) +} + +// SetMessage sets the "message" field. +func (m *AnnouncementMutation) SetMessage(s string) { + m.message = &s +} + +// Message returns the value of the "message" field in the mutation. +func (m *AnnouncementMutation) Message() (r string, exists bool) { + v := m.message + if v == nil { + return + } + return *v, true +} + +// OldMessage returns the old "message" field's value of the Announcement entity. +// If the Announcement 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 *AnnouncementMutation) OldMessage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMessage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMessage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMessage: %w", err) + } + return oldValue.Message, nil +} + +// ResetMessage resets all changes to the "message" field. +func (m *AnnouncementMutation) ResetMessage() { + m.message = nil +} + +// SetImportance sets the "importance" field. +func (m *AnnouncementMutation) SetImportance(s string) { + m.importance = &s +} + +// Importance returns the value of the "importance" field in the mutation. +func (m *AnnouncementMutation) Importance() (r string, exists bool) { + v := m.importance + if v == nil { + return + } + return *v, true +} + +// OldImportance returns the old "importance" field's value of the Announcement entity. +// If the Announcement 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 *AnnouncementMutation) OldImportance(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldImportance is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldImportance requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldImportance: %w", err) + } + return oldValue.Importance, nil +} + +// ResetImportance resets all changes to the "importance" field. +func (m *AnnouncementMutation) ResetImportance() { + m.importance = nil +} + +// Where appends a list predicates to the AnnouncementMutation builder. +func (m *AnnouncementMutation) Where(ps ...predicate.Announcement) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the AnnouncementMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AnnouncementMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Announcement, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *AnnouncementMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *AnnouncementMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Announcement). +func (m *AnnouncementMutation) 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 *AnnouncementMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.created_at != nil { + fields = append(fields, announcement.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, announcement.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, announcement.FieldDeletedAt) + } + if m.message != nil { + fields = append(fields, announcement.FieldMessage) + } + if m.importance != nil { + fields = append(fields, announcement.FieldImportance) + } + 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 *AnnouncementMutation) Field(name string) (ent.Value, bool) { + switch name { + case announcement.FieldCreatedAt: + return m.CreatedAt() + case announcement.FieldUpdatedAt: + return m.UpdatedAt() + case announcement.FieldDeletedAt: + return m.DeletedAt() + case announcement.FieldMessage: + return m.Message() + case announcement.FieldImportance: + return m.Importance() + } + 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 *AnnouncementMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case announcement.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case announcement.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case announcement.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case announcement.FieldMessage: + return m.OldMessage(ctx) + case announcement.FieldImportance: + return m.OldImportance(ctx) + } + return nil, fmt.Errorf("unknown Announcement 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 *AnnouncementMutation) SetField(name string, value ent.Value) error { + switch name { + case announcement.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 announcement.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 announcement.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case announcement.FieldMessage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMessage(v) + return nil + case announcement.FieldImportance: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetImportance(v) + return nil + } + return fmt.Errorf("unknown Announcement field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AnnouncementMutation) 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 *AnnouncementMutation) 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 *AnnouncementMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Announcement numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AnnouncementMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(announcement.FieldDeletedAt) { + fields = append(fields, announcement.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AnnouncementMutation) 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 *AnnouncementMutation) ClearField(name string) error { + switch name { + case announcement.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown Announcement 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 *AnnouncementMutation) ResetField(name string) error { + switch name { + case announcement.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case announcement.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case announcement.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case announcement.FieldMessage: + m.ResetMessage() + return nil + case announcement.FieldImportance: + m.ResetImportance() + return nil + } + return fmt.Errorf("unknown Announcement field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AnnouncementMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AnnouncementMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AnnouncementMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AnnouncementMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AnnouncementMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AnnouncementMutation) EdgeCleared(name string) bool { + 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 *AnnouncementMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Announcement 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 *AnnouncementMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Announcement edge %s", name) +} + +// GuideMutation represents an operation that mutates the Guide nodes in the graph. +type GuideMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + short_description *string + guide *string + views *int + addviews *int + clearedFields map[string]struct{} + user *string + cleareduser bool + tags map[string]struct{} + removedtags map[string]struct{} + clearedtags bool + done bool + oldValue func(context.Context) (*Guide, error) + predicates []predicate.Guide +} + +var _ ent.Mutation = (*GuideMutation)(nil) + +// guideOption allows management of the mutation configuration using functional options. +type guideOption func(*GuideMutation) + +// newGuideMutation creates new mutation for the Guide entity. +func newGuideMutation(c config, op Op, opts ...guideOption) *GuideMutation { + m := &GuideMutation{ + config: c, + op: op, + typ: TypeGuide, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withGuideID sets the ID field of the mutation. +func withGuideID(id string) guideOption { + return func(m *GuideMutation) { + var ( + err error + once sync.Once + value *Guide + ) + m.oldValue = func(ctx context.Context) (*Guide, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Guide.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withGuide sets the old Guide of the mutation. +func withGuide(node *Guide) guideOption { + return func(m *GuideMutation) { + m.oldValue = func(context.Context) (*Guide, 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 GuideMutation) 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 GuideMutation) 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 Guide entities. +func (m *GuideMutation) 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 *GuideMutation) 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 *GuideMutation) 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().Guide.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 *GuideMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *GuideMutation) 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 Guide entity. +// If the Guide 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 *GuideMutation) 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 *GuideMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *GuideMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *GuideMutation) 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 Guide entity. +// If the Guide 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 *GuideMutation) 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 *GuideMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *GuideMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *GuideMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Guide entity. +// If the Guide 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 *GuideMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *GuideMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[guide.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *GuideMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[guide.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *GuideMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, guide.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *GuideMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *GuideMutation) 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 Guide entity. +// If the Guide 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 *GuideMutation) 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 *GuideMutation) ResetName() { + m.name = nil +} + +// SetShortDescription sets the "short_description" field. +func (m *GuideMutation) SetShortDescription(s string) { + m.short_description = &s +} + +// ShortDescription returns the value of the "short_description" field in the mutation. +func (m *GuideMutation) 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 Guide entity. +// If the Guide 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 *GuideMutation) 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 *GuideMutation) ResetShortDescription() { + m.short_description = nil +} + +// SetGuide sets the "guide" field. +func (m *GuideMutation) SetGuide(s string) { + m.guide = &s +} + +// Guide returns the value of the "guide" field in the mutation. +func (m *GuideMutation) Guide() (r string, exists bool) { + v := m.guide + if v == nil { + return + } + return *v, true +} + +// OldGuide returns the old "guide" field's value of the Guide entity. +// If the Guide 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 *GuideMutation) OldGuide(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGuide is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGuide requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGuide: %w", err) + } + return oldValue.Guide, nil +} + +// ResetGuide resets all changes to the "guide" field. +func (m *GuideMutation) ResetGuide() { + m.guide = nil +} + +// SetViews sets the "views" field. +func (m *GuideMutation) SetViews(i int) { + m.views = &i + m.addviews = nil +} + +// Views returns the value of the "views" field in the mutation. +func (m *GuideMutation) Views() (r int, exists bool) { + v := m.views + if v == nil { + return + } + return *v, true +} + +// OldViews returns the old "views" field's value of the Guide entity. +// If the Guide 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 *GuideMutation) OldViews(ctx context.Context) (v int, 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 i to the "views" field. +func (m *GuideMutation) AddViews(i int) { + if m.addviews != nil { + *m.addviews += i + } else { + m.addviews = &i + } +} + +// AddedViews returns the value that was added to the "views" field in this mutation. +func (m *GuideMutation) 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 *GuideMutation) ResetViews() { + m.views = nil + m.addviews = nil +} + +// SetUserID sets the "user" edge to the User entity by id. +func (m *GuideMutation) SetUserID(id string) { + m.user = &id +} + +// ClearUser clears the "user" edge to the User entity. +func (m *GuideMutation) ClearUser() { + m.cleareduser = true +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *GuideMutation) UserCleared() bool { + return m.cleareduser +} + +// UserID returns the "user" edge ID in the mutation. +func (m *GuideMutation) UserID() (id string, exists bool) { + if m.user != nil { + return *m.user, true + } + return +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *GuideMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *GuideMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *GuideMutation) 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 *GuideMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *GuideMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *GuideMutation) 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 *GuideMutation) RemovedTagsIDs() (ids []string) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *GuideMutation) TagsIDs() (ids []string) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *GuideMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// Where appends a list predicates to the GuideMutation builder. +func (m *GuideMutation) Where(ps ...predicate.Guide) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the GuideMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *GuideMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Guide, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *GuideMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *GuideMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Guide). +func (m *GuideMutation) 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 *GuideMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.created_at != nil { + fields = append(fields, guide.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, guide.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, guide.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, guide.FieldName) + } + if m.short_description != nil { + fields = append(fields, guide.FieldShortDescription) + } + if m.guide != nil { + fields = append(fields, guide.FieldGuide) + } + if m.views != nil { + fields = append(fields, guide.FieldViews) + } + 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 *GuideMutation) Field(name string) (ent.Value, bool) { + switch name { + case guide.FieldCreatedAt: + return m.CreatedAt() + case guide.FieldUpdatedAt: + return m.UpdatedAt() + case guide.FieldDeletedAt: + return m.DeletedAt() + case guide.FieldName: + return m.Name() + case guide.FieldShortDescription: + return m.ShortDescription() + case guide.FieldGuide: + return m.Guide() + case guide.FieldViews: + return m.Views() + } + 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 *GuideMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case guide.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case guide.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case guide.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case guide.FieldName: + return m.OldName(ctx) + case guide.FieldShortDescription: + return m.OldShortDescription(ctx) + case guide.FieldGuide: + return m.OldGuide(ctx) + case guide.FieldViews: + return m.OldViews(ctx) + } + return nil, fmt.Errorf("unknown Guide 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 *GuideMutation) SetField(name string, value ent.Value) error { + switch name { + case guide.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 guide.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 guide.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case guide.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case guide.FieldShortDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetShortDescription(v) + return nil + case guide.FieldGuide: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGuide(v) + return nil + case guide.FieldViews: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetViews(v) + return nil + } + return fmt.Errorf("unknown Guide field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *GuideMutation) AddedFields() []string { + var fields []string + if m.addviews != nil { + fields = append(fields, guide.FieldViews) + } + 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 *GuideMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case guide.FieldViews: + return m.AddedViews() + } + 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 *GuideMutation) AddField(name string, value ent.Value) error { + switch name { + case guide.FieldViews: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddViews(v) + return nil + } + return fmt.Errorf("unknown Guide numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *GuideMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(guide.FieldDeletedAt) { + fields = append(fields, guide.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *GuideMutation) 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 *GuideMutation) ClearField(name string) error { + switch name { + case guide.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown Guide 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 *GuideMutation) ResetField(name string) error { + switch name { + case guide.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case guide.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case guide.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case guide.FieldName: + m.ResetName() + return nil + case guide.FieldShortDescription: + m.ResetShortDescription() + return nil + case guide.FieldGuide: + m.ResetGuide() + return nil + case guide.FieldViews: + m.ResetViews() + return nil + } + return fmt.Errorf("unknown Guide field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GuideMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.user != nil { + edges = append(edges, guide.EdgeUser) + } + if m.tags != nil { + edges = append(edges, guide.EdgeTags) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GuideMutation) AddedIDs(name string) []ent.Value { + switch name { + case guide.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case guide.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 *GuideMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedtags != nil { + edges = append(edges, guide.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 *GuideMutation) RemovedIDs(name string) []ent.Value { + switch name { + case guide.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 *GuideMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleareduser { + edges = append(edges, guide.EdgeUser) + } + if m.clearedtags { + edges = append(edges, guide.EdgeTags) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GuideMutation) EdgeCleared(name string) bool { + switch name { + case guide.EdgeUser: + return m.cleareduser + case guide.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 *GuideMutation) ClearEdge(name string) error { + switch name { + case guide.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown Guide 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 *GuideMutation) ResetEdge(name string) error { + switch name { + case guide.EdgeUser: + m.ResetUser() + return nil + case guide.EdgeTags: + m.ResetTags() + return nil + } + return fmt.Errorf("unknown Guide edge %s", name) +} + +// GuideTagMutation represents an operation that mutates the GuideTag nodes in the graph. +type GuideTagMutation struct { + config + op Op + typ string + clearedFields map[string]struct{} + guide *string + clearedguide bool + tag *string + clearedtag bool + done bool + oldValue func(context.Context) (*GuideTag, error) + predicates []predicate.GuideTag +} + +var _ ent.Mutation = (*GuideTagMutation)(nil) + +// guidetagOption allows management of the mutation configuration using functional options. +type guidetagOption func(*GuideTagMutation) + +// newGuideTagMutation creates new mutation for the GuideTag entity. +func newGuideTagMutation(c config, op Op, opts ...guidetagOption) *GuideTagMutation { + m := &GuideTagMutation{ + config: c, + op: op, + typ: TypeGuideTag, + 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 GuideTagMutation) 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 GuideTagMutation) 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 +} + +// SetGuideTag sets the "guide_tag" field. +func (m *GuideTagMutation) SetGuideTag(s string) { + m.guide = &s +} + +// GuideTag returns the value of the "guide_tag" field in the mutation. +func (m *GuideTagMutation) GuideTag() (r string, exists bool) { + v := m.guide + if v == nil { + return + } + return *v, true +} + +// ResetGuideTag resets all changes to the "guide_tag" field. +func (m *GuideTagMutation) ResetGuideTag() { + m.guide = nil +} + +// SetTagID sets the "tag_id" field. +func (m *GuideTagMutation) SetTagID(s string) { + m.tag = &s +} + +// TagID returns the value of the "tag_id" field in the mutation. +func (m *GuideTagMutation) 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 *GuideTagMutation) ResetTagID() { + m.tag = nil +} + +// SetGuideID sets the "guide" edge to the Guide entity by id. +func (m *GuideTagMutation) SetGuideID(id string) { + m.guide = &id +} + +// ClearGuide clears the "guide" edge to the Guide entity. +func (m *GuideTagMutation) ClearGuide() { + m.clearedguide = true + m.clearedFields[guidetag.FieldGuideTag] = struct{}{} +} + +// GuideCleared reports if the "guide" edge to the Guide entity was cleared. +func (m *GuideTagMutation) GuideCleared() bool { + return m.clearedguide +} + +// GuideID returns the "guide" edge ID in the mutation. +func (m *GuideTagMutation) GuideID() (id string, exists bool) { + if m.guide != nil { + return *m.guide, true + } + return +} + +// GuideIDs returns the "guide" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GuideID instead. It exists only for internal usage by the builders. +func (m *GuideTagMutation) GuideIDs() (ids []string) { + if id := m.guide; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetGuide resets all changes to the "guide" edge. +func (m *GuideTagMutation) ResetGuide() { + m.guide = nil + m.clearedguide = false +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (m *GuideTagMutation) ClearTag() { + m.clearedtag = true + m.clearedFields[guidetag.FieldTagID] = struct{}{} +} + +// TagCleared reports if the "tag" edge to the Tag entity was cleared. +func (m *GuideTagMutation) 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 *GuideTagMutation) TagIDs() (ids []string) { + if id := m.tag; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTag resets all changes to the "tag" edge. +func (m *GuideTagMutation) ResetTag() { + m.tag = nil + m.clearedtag = false +} + +// Where appends a list predicates to the GuideTagMutation builder. +func (m *GuideTagMutation) Where(ps ...predicate.GuideTag) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the GuideTagMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *GuideTagMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GuideTag, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *GuideTagMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *GuideTagMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (GuideTag). +func (m *GuideTagMutation) 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 *GuideTagMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.guide != nil { + fields = append(fields, guidetag.FieldGuideTag) + } + if m.tag != nil { + fields = append(fields, guidetag.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 *GuideTagMutation) Field(name string) (ent.Value, bool) { + switch name { + case guidetag.FieldGuideTag: + return m.GuideTag() + case guidetag.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 *GuideTagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema GuideTag 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 *GuideTagMutation) SetField(name string, value ent.Value) error { + switch name { + case guidetag.FieldGuideTag: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGuideTag(v) + return nil + case guidetag.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 GuideTag field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *GuideTagMutation) 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 *GuideTagMutation) 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 *GuideTagMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown GuideTag numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *GuideTagMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *GuideTagMutation) 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 *GuideTagMutation) ClearField(name string) error { + return fmt.Errorf("unknown GuideTag 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 *GuideTagMutation) ResetField(name string) error { + switch name { + case guidetag.FieldGuideTag: + m.ResetGuideTag() + return nil + case guidetag.FieldTagID: + m.ResetTagID() + return nil + } + return fmt.Errorf("unknown GuideTag field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GuideTagMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.guide != nil { + edges = append(edges, guidetag.EdgeGuide) + } + if m.tag != nil { + edges = append(edges, guidetag.EdgeTag) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GuideTagMutation) AddedIDs(name string) []ent.Value { + switch name { + case guidetag.EdgeGuide: + if id := m.guide; id != nil { + return []ent.Value{*id} + } + case guidetag.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 *GuideTagMutation) 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 *GuideTagMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *GuideTagMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedguide { + edges = append(edges, guidetag.EdgeGuide) + } + if m.clearedtag { + edges = append(edges, guidetag.EdgeTag) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GuideTagMutation) EdgeCleared(name string) bool { + switch name { + case guidetag.EdgeGuide: + return m.clearedguide + case guidetag.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 *GuideTagMutation) ClearEdge(name string) error { + switch name { + case guidetag.EdgeGuide: + m.ClearGuide() + return nil + case guidetag.EdgeTag: + m.ClearTag() + return nil + } + return fmt.Errorf("unknown GuideTag 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 *GuideTagMutation) ResetEdge(name string) error { + switch name { + case guidetag.EdgeGuide: + m.ResetGuide() + return nil + case guidetag.EdgeTag: + m.ResetTag() + return nil + } + return fmt.Errorf("unknown GuideTag edge %s", name) +} + +// ModMutation represents an operation that mutates the Mod nodes in the graph. +type ModMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + short_description *string + full_description *string + logo *string + source_url *string + creator_id *string + approved *bool + views *uint + addviews *int + hotness *uint + addhotness *int + popularity *uint + addpopularity *int + downloads *uint + adddownloads *int + denied *bool + last_version_date *time.Time + mod_reference *string + hidden *bool + compatibility **postgres.CompatibilityInfo + clearedFields map[string]struct{} + versions map[string]struct{} + removedversions map[string]struct{} + clearedversions bool + authors map[string]struct{} + removedauthors map[string]struct{} + clearedauthors bool + tags map[string]struct{} + removedtags map[string]struct{} + clearedtags bool + dependents map[string]struct{} + removeddependents map[string]struct{} + cleareddependents bool + done bool + oldValue func(context.Context) (*Mod, error) + predicates []predicate.Mod +} + +var _ ent.Mutation = (*ModMutation)(nil) + +// modOption allows management of the mutation configuration using functional options. +type modOption func(*ModMutation) + +// newModMutation creates new mutation for the Mod entity. +func newModMutation(c config, op Op, opts ...modOption) *ModMutation { + m := &ModMutation{ + config: c, + op: op, + typ: TypeMod, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withModID sets the ID field of the mutation. +func withModID(id string) modOption { + return func(m *ModMutation) { + var ( + err error + once sync.Once + value *Mod + ) + m.oldValue = func(ctx context.Context) (*Mod, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Mod.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMod sets the old Mod of the mutation. +func withMod(node *Mod) modOption { + return func(m *ModMutation) { + m.oldValue = func(context.Context) (*Mod, 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 ModMutation) 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 ModMutation) 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 Mod entities. +func (m *ModMutation) 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 *ModMutation) 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 *ModMutation) 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().Mod.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 *ModMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ModMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *ModMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ModMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ModMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[mod.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ModMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[mod.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ModMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, mod.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *ModMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetName() { + m.name = nil +} + +// SetShortDescription sets the "short_description" field. +func (m *ModMutation) SetShortDescription(s string) { + m.short_description = &s +} + +// ShortDescription returns the value of the "short_description" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetShortDescription() { + m.short_description = nil +} + +// SetFullDescription sets the "full_description" field. +func (m *ModMutation) SetFullDescription(s string) { + m.full_description = &s +} + +// FullDescription returns the value of the "full_description" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetFullDescription() { + m.full_description = nil +} + +// SetLogo sets the "logo" field. +func (m *ModMutation) SetLogo(s string) { + m.logo = &s +} + +// Logo returns the value of the "logo" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 +} + +// ResetLogo resets all changes to the "logo" field. +func (m *ModMutation) ResetLogo() { + m.logo = nil +} + +// SetSourceURL sets the "source_url" field. +func (m *ModMutation) SetSourceURL(s string) { + m.source_url = &s +} + +// SourceURL returns the value of the "source_url" field in the mutation. +func (m *ModMutation) SourceURL() (r string, exists bool) { + v := m.source_url + if v == nil { + return + } + return *v, true +} + +// OldSourceURL returns the old "source_url" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldSourceURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSourceURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSourceURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSourceURL: %w", err) + } + return oldValue.SourceURL, nil +} + +// ResetSourceURL resets all changes to the "source_url" field. +func (m *ModMutation) ResetSourceURL() { + m.source_url = nil +} + +// SetCreatorID sets the "creator_id" field. +func (m *ModMutation) SetCreatorID(s string) { + m.creator_id = &s +} + +// CreatorID returns the value of the "creator_id" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetCreatorID() { + m.creator_id = nil +} + +// SetApproved sets the "approved" field. +func (m *ModMutation) SetApproved(b bool) { + m.approved = &b +} + +// Approved returns the value of the "approved" field in the mutation. +func (m *ModMutation) Approved() (r bool, exists bool) { + v := m.approved + if v == nil { + return + } + return *v, true +} + +// OldApproved returns the old "approved" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldApproved(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldApproved is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldApproved requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldApproved: %w", err) + } + return oldValue.Approved, nil +} + +// ResetApproved resets all changes to the "approved" field. +func (m *ModMutation) ResetApproved() { + m.approved = nil +} + +// SetViews sets the "views" field. +func (m *ModMutation) SetViews(u uint) { + m.views = &u + m.addviews = nil +} + +// Views returns the value of the "views" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) ResetViews() { + m.views = nil + m.addviews = nil +} + +// SetHotness sets the "hotness" field. +func (m *ModMutation) SetHotness(u uint) { + m.hotness = &u + m.addhotness = nil +} + +// Hotness returns the value of the "hotness" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) ResetHotness() { + m.hotness = nil + m.addhotness = nil +} + +// SetPopularity sets the "popularity" field. +func (m *ModMutation) SetPopularity(u uint) { + m.popularity = &u + m.addpopularity = nil +} + +// Popularity returns the value of the "popularity" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) 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 *ModMutation) ResetPopularity() { + m.popularity = nil + m.addpopularity = nil +} + +// SetDownloads sets the "downloads" field. +func (m *ModMutation) SetDownloads(u uint) { + m.downloads = &u + m.adddownloads = nil +} + +// Downloads returns the value of the "downloads" field in the mutation. +func (m *ModMutation) Downloads() (r uint, exists bool) { + v := m.downloads + if v == nil { + return + } + return *v, true +} + +// OldDownloads returns the old "downloads" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldDownloads(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDownloads is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDownloads requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDownloads: %w", err) + } + return oldValue.Downloads, nil +} + +// AddDownloads adds u to the "downloads" field. +func (m *ModMutation) AddDownloads(u int) { + if m.adddownloads != nil { + *m.adddownloads += u + } else { + m.adddownloads = &u + } +} + +// AddedDownloads returns the value that was added to the "downloads" field in this mutation. +func (m *ModMutation) AddedDownloads() (r int, exists bool) { + v := m.adddownloads + if v == nil { + return + } + return *v, true +} + +// ResetDownloads resets all changes to the "downloads" field. +func (m *ModMutation) ResetDownloads() { + m.downloads = nil + m.adddownloads = nil +} + +// SetDenied sets the "denied" field. +func (m *ModMutation) SetDenied(b bool) { + m.denied = &b +} + +// Denied returns the value of the "denied" field in the mutation. +func (m *ModMutation) Denied() (r bool, exists bool) { + v := m.denied + if v == nil { + return + } + return *v, true +} + +// OldDenied returns the old "denied" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldDenied(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDenied is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDenied requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDenied: %w", err) + } + return oldValue.Denied, nil +} + +// ResetDenied resets all changes to the "denied" field. +func (m *ModMutation) ResetDenied() { + m.denied = nil +} + +// SetLastVersionDate sets the "last_version_date" field. +func (m *ModMutation) SetLastVersionDate(t time.Time) { + m.last_version_date = &t +} + +// LastVersionDate returns the value of the "last_version_date" field in the mutation. +func (m *ModMutation) LastVersionDate() (r time.Time, exists bool) { + v := m.last_version_date + if v == nil { + return + } + return *v, true +} + +// OldLastVersionDate returns the old "last_version_date" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldLastVersionDate(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastVersionDate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastVersionDate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastVersionDate: %w", err) + } + return oldValue.LastVersionDate, nil +} + +// ResetLastVersionDate resets all changes to the "last_version_date" field. +func (m *ModMutation) ResetLastVersionDate() { + m.last_version_date = nil +} + +// SetModReference sets the "mod_reference" field. +func (m *ModMutation) SetModReference(s string) { + m.mod_reference = &s +} + +// ModReference returns the value of the "mod_reference" field in the mutation. +func (m *ModMutation) ModReference() (r string, exists bool) { + v := m.mod_reference + if v == nil { + return + } + return *v, true +} + +// OldModReference returns the old "mod_reference" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldModReference(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModReference is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModReference requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModReference: %w", err) + } + return oldValue.ModReference, nil +} + +// ResetModReference resets all changes to the "mod_reference" field. +func (m *ModMutation) ResetModReference() { + m.mod_reference = nil +} + +// SetHidden sets the "hidden" field. +func (m *ModMutation) SetHidden(b bool) { + m.hidden = &b +} + +// Hidden returns the value of the "hidden" field in the mutation. +func (m *ModMutation) 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 Mod entity. +// If the Mod 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 *ModMutation) 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 *ModMutation) ResetHidden() { + m.hidden = nil +} + +// SetCompatibility sets the "compatibility" field. +func (m *ModMutation) SetCompatibility(pi *postgres.CompatibilityInfo) { + m.compatibility = &pi +} + +// Compatibility returns the value of the "compatibility" field in the mutation. +func (m *ModMutation) Compatibility() (r *postgres.CompatibilityInfo, exists bool) { + v := m.compatibility + if v == nil { + return + } + return *v, true +} + +// OldCompatibility returns the old "compatibility" field's value of the Mod entity. +// If the Mod 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 *ModMutation) OldCompatibility(ctx context.Context) (v *postgres.CompatibilityInfo, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCompatibility is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCompatibility requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCompatibility: %w", err) + } + return oldValue.Compatibility, nil +} + +// ResetCompatibility resets all changes to the "compatibility" field. +func (m *ModMutation) ResetCompatibility() { + m.compatibility = nil +} + +// AddVersionIDs adds the "versions" edge to the Version entity by ids. +func (m *ModMutation) AddVersionIDs(ids ...string) { + if m.versions == nil { + m.versions = make(map[string]struct{}) + } + for i := range ids { + m.versions[ids[i]] = struct{}{} + } +} + +// ClearVersions clears the "versions" edge to the Version entity. +func (m *ModMutation) ClearVersions() { + m.clearedversions = true +} + +// VersionsCleared reports if the "versions" edge to the Version entity was cleared. +func (m *ModMutation) VersionsCleared() bool { + return m.clearedversions +} + +// RemoveVersionIDs removes the "versions" edge to the Version entity by IDs. +func (m *ModMutation) RemoveVersionIDs(ids ...string) { + if m.removedversions == nil { + m.removedversions = make(map[string]struct{}) + } + for i := range ids { + delete(m.versions, ids[i]) + m.removedversions[ids[i]] = struct{}{} + } +} + +// RemovedVersions returns the removed IDs of the "versions" edge to the Version entity. +func (m *ModMutation) RemovedVersionsIDs() (ids []string) { + for id := range m.removedversions { + ids = append(ids, id) + } + return +} + +// VersionsIDs returns the "versions" edge IDs in the mutation. +func (m *ModMutation) VersionsIDs() (ids []string) { + for id := range m.versions { + ids = append(ids, id) + } + return +} + +// ResetVersions resets all changes to the "versions" edge. +func (m *ModMutation) ResetVersions() { + m.versions = nil + m.clearedversions = false + m.removedversions = nil +} + +// AddAuthorIDs adds the "authors" edge to the User entity by ids. +func (m *ModMutation) AddAuthorIDs(ids ...string) { + if m.authors == nil { + m.authors = make(map[string]struct{}) + } + for i := range ids { + m.authors[ids[i]] = struct{}{} + } +} + +// ClearAuthors clears the "authors" edge to the User entity. +func (m *ModMutation) ClearAuthors() { + m.clearedauthors = true +} + +// AuthorsCleared reports if the "authors" edge to the User entity was cleared. +func (m *ModMutation) AuthorsCleared() bool { + return m.clearedauthors +} + +// RemoveAuthorIDs removes the "authors" edge to the User entity by IDs. +func (m *ModMutation) RemoveAuthorIDs(ids ...string) { + if m.removedauthors == nil { + m.removedauthors = make(map[string]struct{}) + } + for i := range ids { + delete(m.authors, ids[i]) + m.removedauthors[ids[i]] = struct{}{} + } +} + +// RemovedAuthors returns the removed IDs of the "authors" edge to the User entity. +func (m *ModMutation) RemovedAuthorsIDs() (ids []string) { + for id := range m.removedauthors { + ids = append(ids, id) + } + return +} + +// AuthorsIDs returns the "authors" edge IDs in the mutation. +func (m *ModMutation) AuthorsIDs() (ids []string) { + for id := range m.authors { + ids = append(ids, id) + } + return +} + +// ResetAuthors resets all changes to the "authors" edge. +func (m *ModMutation) ResetAuthors() { + m.authors = nil + m.clearedauthors = false + m.removedauthors = nil +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *ModMutation) 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 *ModMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *ModMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *ModMutation) 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 *ModMutation) RemovedTagsIDs() (ids []string) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *ModMutation) TagsIDs() (ids []string) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *ModMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// AddDependentIDs adds the "dependents" edge to the Version entity by ids. +func (m *ModMutation) AddDependentIDs(ids ...string) { + if m.dependents == nil { + m.dependents = make(map[string]struct{}) + } + for i := range ids { + m.dependents[ids[i]] = struct{}{} + } +} + +// ClearDependents clears the "dependents" edge to the Version entity. +func (m *ModMutation) ClearDependents() { + m.cleareddependents = true +} + +// DependentsCleared reports if the "dependents" edge to the Version entity was cleared. +func (m *ModMutation) DependentsCleared() bool { + return m.cleareddependents +} + +// RemoveDependentIDs removes the "dependents" edge to the Version entity by IDs. +func (m *ModMutation) RemoveDependentIDs(ids ...string) { + if m.removeddependents == nil { + m.removeddependents = make(map[string]struct{}) + } + for i := range ids { + delete(m.dependents, ids[i]) + m.removeddependents[ids[i]] = struct{}{} + } +} + +// RemovedDependents returns the removed IDs of the "dependents" edge to the Version entity. +func (m *ModMutation) RemovedDependentsIDs() (ids []string) { + for id := range m.removeddependents { + ids = append(ids, id) + } + return +} + +// DependentsIDs returns the "dependents" edge IDs in the mutation. +func (m *ModMutation) DependentsIDs() (ids []string) { + for id := range m.dependents { + ids = append(ids, id) + } + return +} + +// ResetDependents resets all changes to the "dependents" edge. +func (m *ModMutation) ResetDependents() { + m.dependents = nil + m.cleareddependents = false + m.removeddependents = nil +} + +// Where appends a list predicates to the ModMutation builder. +func (m *ModMutation) Where(ps ...predicate.Mod) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ModMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ModMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Mod, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ModMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ModMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Mod). +func (m *ModMutation) 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 *ModMutation) Fields() []string { + fields := make([]string, 0, 19) + if m.created_at != nil { + fields = append(fields, mod.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, mod.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, mod.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, mod.FieldName) + } + if m.short_description != nil { + fields = append(fields, mod.FieldShortDescription) + } + if m.full_description != nil { + fields = append(fields, mod.FieldFullDescription) + } + if m.logo != nil { + fields = append(fields, mod.FieldLogo) + } + if m.source_url != nil { + fields = append(fields, mod.FieldSourceURL) + } + if m.creator_id != nil { + fields = append(fields, mod.FieldCreatorID) + } + if m.approved != nil { + fields = append(fields, mod.FieldApproved) + } + if m.views != nil { + fields = append(fields, mod.FieldViews) + } + if m.hotness != nil { + fields = append(fields, mod.FieldHotness) + } + if m.popularity != nil { + fields = append(fields, mod.FieldPopularity) + } + if m.downloads != nil { + fields = append(fields, mod.FieldDownloads) + } + if m.denied != nil { + fields = append(fields, mod.FieldDenied) + } + if m.last_version_date != nil { + fields = append(fields, mod.FieldLastVersionDate) + } + if m.mod_reference != nil { + fields = append(fields, mod.FieldModReference) + } + if m.hidden != nil { + fields = append(fields, mod.FieldHidden) + } + if m.compatibility != nil { + fields = append(fields, mod.FieldCompatibility) + } + 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 *ModMutation) Field(name string) (ent.Value, bool) { + switch name { + case mod.FieldCreatedAt: + return m.CreatedAt() + case mod.FieldUpdatedAt: + return m.UpdatedAt() + case mod.FieldDeletedAt: + return m.DeletedAt() + case mod.FieldName: + return m.Name() + case mod.FieldShortDescription: + return m.ShortDescription() + case mod.FieldFullDescription: + return m.FullDescription() + case mod.FieldLogo: + return m.Logo() + case mod.FieldSourceURL: + return m.SourceURL() + case mod.FieldCreatorID: + return m.CreatorID() + case mod.FieldApproved: + return m.Approved() + case mod.FieldViews: + return m.Views() + case mod.FieldHotness: + return m.Hotness() + case mod.FieldPopularity: + return m.Popularity() + case mod.FieldDownloads: + return m.Downloads() + case mod.FieldDenied: + return m.Denied() + case mod.FieldLastVersionDate: + return m.LastVersionDate() + case mod.FieldModReference: + return m.ModReference() + case mod.FieldHidden: + return m.Hidden() + case mod.FieldCompatibility: + return m.Compatibility() + } + 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 *ModMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case mod.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case mod.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case mod.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case mod.FieldName: + return m.OldName(ctx) + case mod.FieldShortDescription: + return m.OldShortDescription(ctx) + case mod.FieldFullDescription: + return m.OldFullDescription(ctx) + case mod.FieldLogo: + return m.OldLogo(ctx) + case mod.FieldSourceURL: + return m.OldSourceURL(ctx) + case mod.FieldCreatorID: + return m.OldCreatorID(ctx) + case mod.FieldApproved: + return m.OldApproved(ctx) + case mod.FieldViews: + return m.OldViews(ctx) + case mod.FieldHotness: + return m.OldHotness(ctx) + case mod.FieldPopularity: + return m.OldPopularity(ctx) + case mod.FieldDownloads: + return m.OldDownloads(ctx) + case mod.FieldDenied: + return m.OldDenied(ctx) + case mod.FieldLastVersionDate: + return m.OldLastVersionDate(ctx) + case mod.FieldModReference: + return m.OldModReference(ctx) + case mod.FieldHidden: + return m.OldHidden(ctx) + case mod.FieldCompatibility: + return m.OldCompatibility(ctx) + } + return nil, fmt.Errorf("unknown Mod 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 *ModMutation) SetField(name string, value ent.Value) error { + switch name { + case mod.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 mod.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 mod.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case mod.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case mod.FieldShortDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetShortDescription(v) + return nil + case mod.FieldFullDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFullDescription(v) + return nil + case mod.FieldLogo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLogo(v) + return nil + case mod.FieldSourceURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSourceURL(v) + return nil + case mod.FieldCreatorID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatorID(v) + return nil + case mod.FieldApproved: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetApproved(v) + return nil + case mod.FieldViews: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetViews(v) + return nil + case mod.FieldHotness: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHotness(v) + return nil + case mod.FieldPopularity: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPopularity(v) + return nil + case mod.FieldDownloads: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDownloads(v) + return nil + case mod.FieldDenied: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDenied(v) + return nil + case mod.FieldLastVersionDate: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastVersionDate(v) + return nil + case mod.FieldModReference: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModReference(v) + return nil + case mod.FieldHidden: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHidden(v) + return nil + case mod.FieldCompatibility: + v, ok := value.(*postgres.CompatibilityInfo) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCompatibility(v) + return nil + } + return fmt.Errorf("unknown Mod field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModMutation) AddedFields() []string { + var fields []string + if m.addviews != nil { + fields = append(fields, mod.FieldViews) + } + if m.addhotness != nil { + fields = append(fields, mod.FieldHotness) + } + if m.addpopularity != nil { + fields = append(fields, mod.FieldPopularity) + } + if m.adddownloads != nil { + fields = append(fields, mod.FieldDownloads) + } + 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 *ModMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case mod.FieldViews: + return m.AddedViews() + case mod.FieldHotness: + return m.AddedHotness() + case mod.FieldPopularity: + return m.AddedPopularity() + case mod.FieldDownloads: + return m.AddedDownloads() + } + 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 *ModMutation) AddField(name string, value ent.Value) error { + switch name { + case mod.FieldViews: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddViews(v) + return nil + case mod.FieldHotness: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHotness(v) + return nil + case mod.FieldPopularity: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPopularity(v) + return nil + case mod.FieldDownloads: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDownloads(v) + return nil + } + return fmt.Errorf("unknown Mod numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ModMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(mod.FieldDeletedAt) { + fields = append(fields, mod.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ModMutation) 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 *ModMutation) ClearField(name string) error { + switch name { + case mod.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown Mod 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 *ModMutation) ResetField(name string) error { + switch name { + case mod.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case mod.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case mod.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case mod.FieldName: + m.ResetName() + return nil + case mod.FieldShortDescription: + m.ResetShortDescription() + return nil + case mod.FieldFullDescription: + m.ResetFullDescription() + return nil + case mod.FieldLogo: + m.ResetLogo() + return nil + case mod.FieldSourceURL: + m.ResetSourceURL() + return nil + case mod.FieldCreatorID: + m.ResetCreatorID() + return nil + case mod.FieldApproved: + m.ResetApproved() + return nil + case mod.FieldViews: + m.ResetViews() + return nil + case mod.FieldHotness: + m.ResetHotness() + return nil + case mod.FieldPopularity: + m.ResetPopularity() + return nil + case mod.FieldDownloads: + m.ResetDownloads() + return nil + case mod.FieldDenied: + m.ResetDenied() + return nil + case mod.FieldLastVersionDate: + m.ResetLastVersionDate() + return nil + case mod.FieldModReference: + m.ResetModReference() + return nil + case mod.FieldHidden: + m.ResetHidden() + return nil + case mod.FieldCompatibility: + m.ResetCompatibility() + return nil + } + return fmt.Errorf("unknown Mod field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ModMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.versions != nil { + edges = append(edges, mod.EdgeVersions) + } + if m.authors != nil { + edges = append(edges, mod.EdgeAuthors) + } + if m.tags != nil { + edges = append(edges, mod.EdgeTags) + } + if m.dependents != nil { + edges = append(edges, mod.EdgeDependents) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ModMutation) AddedIDs(name string) []ent.Value { + switch name { + case mod.EdgeVersions: + ids := make([]ent.Value, 0, len(m.versions)) + for id := range m.versions { + ids = append(ids, id) + } + return ids + case mod.EdgeAuthors: + ids := make([]ent.Value, 0, len(m.authors)) + for id := range m.authors { + ids = append(ids, id) + } + return ids + case mod.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + case mod.EdgeDependents: + ids := make([]ent.Value, 0, len(m.dependents)) + for id := range m.dependents { + 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) + if m.removedversions != nil { + edges = append(edges, mod.EdgeVersions) + } + if m.removedauthors != nil { + edges = append(edges, mod.EdgeAuthors) + } + if m.removedtags != nil { + edges = append(edges, mod.EdgeTags) + } + if m.removeddependents != nil { + edges = append(edges, mod.EdgeDependents) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ModMutation) RemovedIDs(name string) []ent.Value { + switch name { + case mod.EdgeVersions: + ids := make([]ent.Value, 0, len(m.removedversions)) + for id := range m.removedversions { + ids = append(ids, id) + } + return ids + case mod.EdgeAuthors: + ids := make([]ent.Value, 0, len(m.removedauthors)) + for id := range m.removedauthors { + ids = append(ids, id) + } + return ids + case mod.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) + } + return ids + case mod.EdgeDependents: + ids := make([]ent.Value, 0, len(m.removeddependents)) + for id := range m.removeddependents { + 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) + if m.clearedversions { + edges = append(edges, mod.EdgeVersions) + } + if m.clearedauthors { + edges = append(edges, mod.EdgeAuthors) + } + if m.clearedtags { + edges = append(edges, mod.EdgeTags) + } + if m.cleareddependents { + edges = append(edges, mod.EdgeDependents) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ModMutation) EdgeCleared(name string) bool { + switch name { + case mod.EdgeVersions: + return m.clearedversions + case mod.EdgeAuthors: + return m.clearedauthors + case mod.EdgeTags: + return m.clearedtags + case mod.EdgeDependents: + return m.cleareddependents + } + 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 *ModMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Mod 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 *ModMutation) ResetEdge(name string) error { + switch name { + case mod.EdgeVersions: + m.ResetVersions() + return nil + case mod.EdgeAuthors: + m.ResetAuthors() + return nil + case mod.EdgeTags: + m.ResetTags() + return nil + case mod.EdgeDependents: + m.ResetDependents() + return nil + } + return fmt.Errorf("unknown Mod edge %s", name) +} + +// ModTagMutation represents an operation that mutates the ModTag nodes in the graph. +type ModTagMutation struct { + config + op Op + typ string + clearedFields map[string]struct{} + mod *string + clearedmod bool + tag *string + clearedtag bool + done bool + oldValue func(context.Context) (*ModTag, error) + predicates []predicate.ModTag +} + +var _ ent.Mutation = (*ModTagMutation)(nil) + +// modtagOption allows management of the mutation configuration using functional options. +type modtagOption func(*ModTagMutation) + +// newModTagMutation creates new mutation for the ModTag entity. +func newModTagMutation(c config, op Op, opts ...modtagOption) *ModTagMutation { + m := &ModTagMutation{ + config: c, + op: op, + typ: TypeModTag, + 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 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) +} + +// SmlVersionMutation represents an operation that mutates the SmlVersion nodes in the graph. +type SmlVersionMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + version *string + satisfactory_version *int + addsatisfactory_version *int + stability *smlversion.Stability + date *time.Time + link *string + changelog *string + bootstrap_version *string + engine_version *string + clearedFields map[string]struct{} + targets map[string]struct{} + removedtargets map[string]struct{} + clearedtargets bool + done bool + oldValue func(context.Context) (*SmlVersion, error) + predicates []predicate.SmlVersion +} + +var _ ent.Mutation = (*SmlVersionMutation)(nil) + +// smlversionOption allows management of the mutation configuration using functional options. +type smlversionOption func(*SmlVersionMutation) + +// newSmlVersionMutation creates new mutation for the SmlVersion entity. +func newSmlVersionMutation(c config, op Op, opts ...smlversionOption) *SmlVersionMutation { + m := &SmlVersionMutation{ + config: c, + op: op, + typ: TypeSmlVersion, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSmlVersionID sets the ID field of the mutation. +func withSmlVersionID(id string) smlversionOption { + return func(m *SmlVersionMutation) { + var ( + err error + once sync.Once + value *SmlVersion + ) + m.oldValue = func(ctx context.Context) (*SmlVersion, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().SmlVersion.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSmlVersion sets the old SmlVersion of the mutation. +func withSmlVersion(node *SmlVersion) smlversionOption { + return func(m *SmlVersionMutation) { + m.oldValue = func(context.Context) (*SmlVersion, 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 SmlVersionMutation) 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 SmlVersionMutation) 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 SmlVersion entities. +func (m *SmlVersionMutation) 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 *SmlVersionMutation) 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 *SmlVersionMutation) 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().SmlVersion.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 *SmlVersionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *SmlVersionMutation) 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 SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) 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 *SmlVersionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *SmlVersionMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *SmlVersionMutation) 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 SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) 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 *SmlVersionMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *SmlVersionMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *SmlVersionMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *SmlVersionMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[smlversion.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *SmlVersionMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[smlversion.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *SmlVersionMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, smlversion.FieldDeletedAt) +} + +// SetVersion sets the "version" field. +func (m *SmlVersionMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *SmlVersionMutation) 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 SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) 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 *SmlVersionMutation) ResetVersion() { + m.version = nil +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (m *SmlVersionMutation) SetSatisfactoryVersion(i int) { + m.satisfactory_version = &i + m.addsatisfactory_version = nil +} + +// SatisfactoryVersion returns the value of the "satisfactory_version" field in the mutation. +func (m *SmlVersionMutation) SatisfactoryVersion() (r int, exists bool) { + v := m.satisfactory_version + if v == nil { + return + } + return *v, true +} + +// OldSatisfactoryVersion returns the old "satisfactory_version" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldSatisfactoryVersion(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSatisfactoryVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSatisfactoryVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSatisfactoryVersion: %w", err) + } + return oldValue.SatisfactoryVersion, nil +} + +// AddSatisfactoryVersion adds i to the "satisfactory_version" field. +func (m *SmlVersionMutation) AddSatisfactoryVersion(i int) { + if m.addsatisfactory_version != nil { + *m.addsatisfactory_version += i + } else { + m.addsatisfactory_version = &i + } +} + +// AddedSatisfactoryVersion returns the value that was added to the "satisfactory_version" field in this mutation. +func (m *SmlVersionMutation) AddedSatisfactoryVersion() (r int, exists bool) { + v := m.addsatisfactory_version + if v == nil { + return + } + return *v, true +} + +// ResetSatisfactoryVersion resets all changes to the "satisfactory_version" field. +func (m *SmlVersionMutation) ResetSatisfactoryVersion() { + m.satisfactory_version = nil + m.addsatisfactory_version = nil +} + +// SetStability sets the "stability" field. +func (m *SmlVersionMutation) SetStability(s smlversion.Stability) { + m.stability = &s +} + +// Stability returns the value of the "stability" field in the mutation. +func (m *SmlVersionMutation) Stability() (r smlversion.Stability, exists bool) { + v := m.stability + if v == nil { + return + } + return *v, true +} + +// OldStability returns the old "stability" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldStability(ctx context.Context) (v smlversion.Stability, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStability is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStability requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStability: %w", err) + } + return oldValue.Stability, nil +} + +// ResetStability resets all changes to the "stability" field. +func (m *SmlVersionMutation) ResetStability() { + m.stability = nil +} + +// SetDate sets the "date" field. +func (m *SmlVersionMutation) SetDate(t time.Time) { + m.date = &t +} + +// Date returns the value of the "date" field in the mutation. +func (m *SmlVersionMutation) Date() (r time.Time, exists bool) { + v := m.date + if v == nil { + return + } + return *v, true +} + +// OldDate returns the old "date" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldDate(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDate: %w", err) + } + return oldValue.Date, nil +} + +// ResetDate resets all changes to the "date" field. +func (m *SmlVersionMutation) ResetDate() { + m.date = nil +} + +// SetLink sets the "link" field. +func (m *SmlVersionMutation) SetLink(s string) { + m.link = &s +} + +// Link returns the value of the "link" field in the mutation. +func (m *SmlVersionMutation) Link() (r string, exists bool) { + v := m.link + if v == nil { + return + } + return *v, true +} + +// OldLink returns the old "link" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldLink(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLink is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLink: %w", err) + } + return oldValue.Link, nil +} + +// ResetLink resets all changes to the "link" field. +func (m *SmlVersionMutation) ResetLink() { + m.link = nil +} + +// SetChangelog sets the "changelog" field. +func (m *SmlVersionMutation) SetChangelog(s string) { + m.changelog = &s +} + +// Changelog returns the value of the "changelog" field in the mutation. +func (m *SmlVersionMutation) 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 SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) 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 *SmlVersionMutation) ResetChangelog() { + m.changelog = nil +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (m *SmlVersionMutation) SetBootstrapVersion(s string) { + m.bootstrap_version = &s +} + +// BootstrapVersion returns the value of the "bootstrap_version" field in the mutation. +func (m *SmlVersionMutation) BootstrapVersion() (r string, exists bool) { + v := m.bootstrap_version + if v == nil { + return + } + return *v, true +} + +// OldBootstrapVersion returns the old "bootstrap_version" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldBootstrapVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBootstrapVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBootstrapVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBootstrapVersion: %w", err) + } + return oldValue.BootstrapVersion, nil +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (m *SmlVersionMutation) ClearBootstrapVersion() { + m.bootstrap_version = nil + m.clearedFields[smlversion.FieldBootstrapVersion] = struct{}{} +} + +// BootstrapVersionCleared returns if the "bootstrap_version" field was cleared in this mutation. +func (m *SmlVersionMutation) BootstrapVersionCleared() bool { + _, ok := m.clearedFields[smlversion.FieldBootstrapVersion] + return ok +} + +// ResetBootstrapVersion resets all changes to the "bootstrap_version" field. +func (m *SmlVersionMutation) ResetBootstrapVersion() { + m.bootstrap_version = nil + delete(m.clearedFields, smlversion.FieldBootstrapVersion) +} + +// SetEngineVersion sets the "engine_version" field. +func (m *SmlVersionMutation) SetEngineVersion(s string) { + m.engine_version = &s +} + +// EngineVersion returns the value of the "engine_version" field in the mutation. +func (m *SmlVersionMutation) EngineVersion() (r string, exists bool) { + v := m.engine_version + if v == nil { + return + } + return *v, true +} + +// OldEngineVersion returns the old "engine_version" field's value of the SmlVersion entity. +// If the SmlVersion 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 *SmlVersionMutation) OldEngineVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEngineVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEngineVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEngineVersion: %w", err) + } + return oldValue.EngineVersion, nil +} + +// ResetEngineVersion resets all changes to the "engine_version" field. +func (m *SmlVersionMutation) ResetEngineVersion() { + m.engine_version = nil +} + +// AddTargetIDs adds the "targets" edge to the SmlVersionTarget entity by ids. +func (m *SmlVersionMutation) 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 SmlVersionTarget entity. +func (m *SmlVersionMutation) ClearTargets() { + m.clearedtargets = true +} + +// TargetsCleared reports if the "targets" edge to the SmlVersionTarget entity was cleared. +func (m *SmlVersionMutation) TargetsCleared() bool { + return m.clearedtargets +} + +// RemoveTargetIDs removes the "targets" edge to the SmlVersionTarget entity by IDs. +func (m *SmlVersionMutation) 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 SmlVersionTarget entity. +func (m *SmlVersionMutation) RemovedTargetsIDs() (ids []string) { + for id := range m.removedtargets { + ids = append(ids, id) + } + return +} + +// TargetsIDs returns the "targets" edge IDs in the mutation. +func (m *SmlVersionMutation) TargetsIDs() (ids []string) { + for id := range m.targets { + ids = append(ids, id) + } + return +} + +// ResetTargets resets all changes to the "targets" edge. +func (m *SmlVersionMutation) ResetTargets() { + m.targets = nil + m.clearedtargets = false + m.removedtargets = nil +} + +// Where appends a list predicates to the SmlVersionMutation builder. +func (m *SmlVersionMutation) Where(ps ...predicate.SmlVersion) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the SmlVersionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SmlVersionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.SmlVersion, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *SmlVersionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *SmlVersionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (SmlVersion). +func (m *SmlVersionMutation) 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 *SmlVersionMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.created_at != nil { + fields = append(fields, smlversion.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, smlversion.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, smlversion.FieldDeletedAt) + } + if m.version != nil { + fields = append(fields, smlversion.FieldVersion) + } + if m.satisfactory_version != nil { + fields = append(fields, smlversion.FieldSatisfactoryVersion) + } + if m.stability != nil { + fields = append(fields, smlversion.FieldStability) + } + if m.date != nil { + fields = append(fields, smlversion.FieldDate) + } + if m.link != nil { + fields = append(fields, smlversion.FieldLink) + } + if m.changelog != nil { + fields = append(fields, smlversion.FieldChangelog) + } + if m.bootstrap_version != nil { + fields = append(fields, smlversion.FieldBootstrapVersion) + } + if m.engine_version != nil { + fields = append(fields, smlversion.FieldEngineVersion) + } + 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 *SmlVersionMutation) Field(name string) (ent.Value, bool) { + switch name { + case smlversion.FieldCreatedAt: + return m.CreatedAt() + case smlversion.FieldUpdatedAt: + return m.UpdatedAt() + case smlversion.FieldDeletedAt: + return m.DeletedAt() + case smlversion.FieldVersion: + return m.Version() + case smlversion.FieldSatisfactoryVersion: + return m.SatisfactoryVersion() + case smlversion.FieldStability: + return m.Stability() + case smlversion.FieldDate: + return m.Date() + case smlversion.FieldLink: + return m.Link() + case smlversion.FieldChangelog: + return m.Changelog() + case smlversion.FieldBootstrapVersion: + return m.BootstrapVersion() + case smlversion.FieldEngineVersion: + return m.EngineVersion() + } + 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 *SmlVersionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case smlversion.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case smlversion.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case smlversion.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case smlversion.FieldVersion: + return m.OldVersion(ctx) + case smlversion.FieldSatisfactoryVersion: + return m.OldSatisfactoryVersion(ctx) + case smlversion.FieldStability: + return m.OldStability(ctx) + case smlversion.FieldDate: + return m.OldDate(ctx) + case smlversion.FieldLink: + return m.OldLink(ctx) + case smlversion.FieldChangelog: + return m.OldChangelog(ctx) + case smlversion.FieldBootstrapVersion: + return m.OldBootstrapVersion(ctx) + case smlversion.FieldEngineVersion: + return m.OldEngineVersion(ctx) + } + return nil, fmt.Errorf("unknown SmlVersion 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 *SmlVersionMutation) SetField(name string, value ent.Value) error { + switch name { + case smlversion.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 smlversion.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 smlversion.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case smlversion.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case smlversion.FieldSatisfactoryVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSatisfactoryVersion(v) + return nil + case smlversion.FieldStability: + v, ok := value.(smlversion.Stability) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStability(v) + return nil + case smlversion.FieldDate: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDate(v) + return nil + case smlversion.FieldLink: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLink(v) + return nil + case smlversion.FieldChangelog: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChangelog(v) + return nil + case smlversion.FieldBootstrapVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBootstrapVersion(v) + return nil + case smlversion.FieldEngineVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEngineVersion(v) + return nil + } + return fmt.Errorf("unknown SmlVersion field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SmlVersionMutation) AddedFields() []string { + var fields []string + if m.addsatisfactory_version != nil { + fields = append(fields, smlversion.FieldSatisfactoryVersion) + } + 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 *SmlVersionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case smlversion.FieldSatisfactoryVersion: + return m.AddedSatisfactoryVersion() + } + 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 *SmlVersionMutation) AddField(name string, value ent.Value) error { + switch name { + case smlversion.FieldSatisfactoryVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSatisfactoryVersion(v) + return nil + } + return fmt.Errorf("unknown SmlVersion numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SmlVersionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(smlversion.FieldDeletedAt) { + fields = append(fields, smlversion.FieldDeletedAt) + } + if m.FieldCleared(smlversion.FieldBootstrapVersion) { + fields = append(fields, smlversion.FieldBootstrapVersion) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SmlVersionMutation) 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 *SmlVersionMutation) ClearField(name string) error { + switch name { + case smlversion.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case smlversion.FieldBootstrapVersion: + m.ClearBootstrapVersion() + return nil + } + return fmt.Errorf("unknown SmlVersion 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 *SmlVersionMutation) ResetField(name string) error { + switch name { + case smlversion.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case smlversion.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case smlversion.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case smlversion.FieldVersion: + m.ResetVersion() + return nil + case smlversion.FieldSatisfactoryVersion: + m.ResetSatisfactoryVersion() + return nil + case smlversion.FieldStability: + m.ResetStability() + return nil + case smlversion.FieldDate: + m.ResetDate() + return nil + case smlversion.FieldLink: + m.ResetLink() + return nil + case smlversion.FieldChangelog: + m.ResetChangelog() + return nil + case smlversion.FieldBootstrapVersion: + m.ResetBootstrapVersion() + return nil + case smlversion.FieldEngineVersion: + m.ResetEngineVersion() + return nil + } + return fmt.Errorf("unknown SmlVersion field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SmlVersionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.targets != nil { + edges = append(edges, smlversion.EdgeTargets) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SmlVersionMutation) AddedIDs(name string) []ent.Value { + switch name { + case smlversion.EdgeTargets: + ids := make([]ent.Value, 0, len(m.targets)) + for id := range m.targets { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SmlVersionMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedtargets != nil { + edges = append(edges, smlversion.EdgeTargets) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SmlVersionMutation) RemovedIDs(name string) []ent.Value { + switch name { + case smlversion.EdgeTargets: + ids := make([]ent.Value, 0, len(m.removedtargets)) + for id := range m.removedtargets { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SmlVersionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedtargets { + edges = append(edges, smlversion.EdgeTargets) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SmlVersionMutation) EdgeCleared(name string) bool { + switch name { + case smlversion.EdgeTargets: + return m.clearedtargets + } + 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 *SmlVersionMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown SmlVersion 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 *SmlVersionMutation) ResetEdge(name string) error { + switch name { + case smlversion.EdgeTargets: + m.ResetTargets() + return nil + } + return fmt.Errorf("unknown SmlVersion edge %s", name) +} + +// SmlVersionTargetMutation represents an operation that mutates the SmlVersionTarget nodes in the graph. +type SmlVersionTargetMutation struct { + config + op Op + typ string + id *string + target_name *string + link *string + clearedFields map[string]struct{} + sml_version *string + clearedsml_version bool + done bool + oldValue func(context.Context) (*SmlVersionTarget, error) + predicates []predicate.SmlVersionTarget +} + +var _ ent.Mutation = (*SmlVersionTargetMutation)(nil) + +// smlversiontargetOption allows management of the mutation configuration using functional options. +type smlversiontargetOption func(*SmlVersionTargetMutation) + +// newSmlVersionTargetMutation creates new mutation for the SmlVersionTarget entity. +func newSmlVersionTargetMutation(c config, op Op, opts ...smlversiontargetOption) *SmlVersionTargetMutation { + m := &SmlVersionTargetMutation{ + config: c, + op: op, + typ: TypeSmlVersionTarget, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSmlVersionTargetID sets the ID field of the mutation. +func withSmlVersionTargetID(id string) smlversiontargetOption { + return func(m *SmlVersionTargetMutation) { + var ( + err error + once sync.Once + value *SmlVersionTarget + ) + m.oldValue = func(ctx context.Context) (*SmlVersionTarget, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().SmlVersionTarget.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSmlVersionTarget sets the old SmlVersionTarget of the mutation. +func withSmlVersionTarget(node *SmlVersionTarget) smlversiontargetOption { + return func(m *SmlVersionTargetMutation) { + m.oldValue = func(context.Context) (*SmlVersionTarget, 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 SmlVersionTargetMutation) 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 SmlVersionTargetMutation) 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 SmlVersionTarget entities. +func (m *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) 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().SmlVersionTarget.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetVersionID sets the "version_id" field. +func (m *SmlVersionTargetMutation) SetVersionID(s string) { + m.sml_version = &s +} + +// VersionID returns the value of the "version_id" field in the mutation. +func (m *SmlVersionTargetMutation) VersionID() (r string, exists bool) { + v := m.sml_version + if v == nil { + return + } + return *v, true +} + +// OldVersionID returns the old "version_id" field's value of the SmlVersionTarget entity. +// If the SmlVersionTarget 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 *SmlVersionTargetMutation) OldVersionID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionID: %w", err) + } + return oldValue.VersionID, nil +} + +// ResetVersionID resets all changes to the "version_id" field. +func (m *SmlVersionTargetMutation) ResetVersionID() { + m.sml_version = nil +} + +// SetTargetName sets the "target_name" field. +func (m *SmlVersionTargetMutation) SetTargetName(s string) { + m.target_name = &s +} + +// TargetName returns the value of the "target_name" field in the mutation. +func (m *SmlVersionTargetMutation) TargetName() (r string, exists bool) { + v := m.target_name + if v == nil { + return + } + return *v, true +} + +// OldTargetName returns the old "target_name" field's value of the SmlVersionTarget entity. +// If the SmlVersionTarget 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 *SmlVersionTargetMutation) 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 +} + +// ResetTargetName resets all changes to the "target_name" field. +func (m *SmlVersionTargetMutation) ResetTargetName() { + m.target_name = nil +} + +// SetLink sets the "link" field. +func (m *SmlVersionTargetMutation) SetLink(s string) { + m.link = &s +} + +// Link returns the value of the "link" field in the mutation. +func (m *SmlVersionTargetMutation) Link() (r string, exists bool) { + v := m.link + if v == nil { + return + } + return *v, true +} + +// OldLink returns the old "link" field's value of the SmlVersionTarget entity. +// If the SmlVersionTarget 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 *SmlVersionTargetMutation) OldLink(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLink is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLink: %w", err) + } + return oldValue.Link, nil +} + +// ResetLink resets all changes to the "link" field. +func (m *SmlVersionTargetMutation) ResetLink() { + m.link = nil +} + +// SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by id. +func (m *SmlVersionTargetMutation) SetSmlVersionID(id string) { + m.sml_version = &id +} + +// ClearSmlVersion clears the "sml_version" edge to the SmlVersion entity. +func (m *SmlVersionTargetMutation) ClearSmlVersion() { + m.clearedsml_version = true + m.clearedFields[smlversiontarget.FieldVersionID] = struct{}{} +} + +// SmlVersionCleared reports if the "sml_version" edge to the SmlVersion entity was cleared. +func (m *SmlVersionTargetMutation) SmlVersionCleared() bool { + return m.clearedsml_version +} + +// SmlVersionID returns the "sml_version" edge ID in the mutation. +func (m *SmlVersionTargetMutation) SmlVersionID() (id string, exists bool) { + if m.sml_version != nil { + return *m.sml_version, true + } + return +} + +// SmlVersionIDs returns the "sml_version" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SmlVersionID instead. It exists only for internal usage by the builders. +func (m *SmlVersionTargetMutation) SmlVersionIDs() (ids []string) { + if id := m.sml_version; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetSmlVersion resets all changes to the "sml_version" edge. +func (m *SmlVersionTargetMutation) ResetSmlVersion() { + m.sml_version = nil + m.clearedsml_version = false +} + +// Where appends a list predicates to the SmlVersionTargetMutation builder. +func (m *SmlVersionTargetMutation) Where(ps ...predicate.SmlVersionTarget) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the SmlVersionTargetMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SmlVersionTargetMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.SmlVersionTarget, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *SmlVersionTargetMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *SmlVersionTargetMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (SmlVersionTarget). +func (m *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.sml_version != nil { + fields = append(fields, smlversiontarget.FieldVersionID) + } + if m.target_name != nil { + fields = append(fields, smlversiontarget.FieldTargetName) + } + if m.link != nil { + fields = append(fields, smlversiontarget.FieldLink) + } + 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 *SmlVersionTargetMutation) Field(name string) (ent.Value, bool) { + switch name { + case smlversiontarget.FieldVersionID: + return m.VersionID() + case smlversiontarget.FieldTargetName: + return m.TargetName() + case smlversiontarget.FieldLink: + return m.Link() + } + 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 *SmlVersionTargetMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case smlversiontarget.FieldVersionID: + return m.OldVersionID(ctx) + case smlversiontarget.FieldTargetName: + return m.OldTargetName(ctx) + case smlversiontarget.FieldLink: + return m.OldLink(ctx) + } + return nil, fmt.Errorf("unknown SmlVersionTarget 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 *SmlVersionTargetMutation) SetField(name string, value ent.Value) error { + switch name { + case smlversiontarget.FieldVersionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionID(v) + return nil + case smlversiontarget.FieldTargetName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTargetName(v) + return nil + case smlversiontarget.FieldLink: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLink(v) + return nil + } + return fmt.Errorf("unknown SmlVersionTarget field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown SmlVersionTarget numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SmlVersionTargetMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) ClearField(name string) error { + return fmt.Errorf("unknown SmlVersionTarget 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 *SmlVersionTargetMutation) ResetField(name string) error { + switch name { + case smlversiontarget.FieldVersionID: + m.ResetVersionID() + return nil + case smlversiontarget.FieldTargetName: + m.ResetTargetName() + return nil + case smlversiontarget.FieldLink: + m.ResetLink() + return nil + } + return fmt.Errorf("unknown SmlVersionTarget field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SmlVersionTargetMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sml_version != nil { + edges = append(edges, smlversiontarget.EdgeSmlVersion) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SmlVersionTargetMutation) AddedIDs(name string) []ent.Value { + switch name { + case smlversiontarget.EdgeSmlVersion: + if id := m.sml_version; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SmlVersionTargetMutation) 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 *SmlVersionTargetMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SmlVersionTargetMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsml_version { + edges = append(edges, smlversiontarget.EdgeSmlVersion) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SmlVersionTargetMutation) EdgeCleared(name string) bool { + switch name { + case smlversiontarget.EdgeSmlVersion: + return m.clearedsml_version + } + 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 *SmlVersionTargetMutation) ClearEdge(name string) error { + switch name { + case smlversiontarget.EdgeSmlVersion: + m.ClearSmlVersion() + return nil + } + return fmt.Errorf("unknown SmlVersionTarget 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 *SmlVersionTargetMutation) ResetEdge(name string) error { + switch name { + case smlversiontarget.EdgeSmlVersion: + m.ResetSmlVersion() + return nil + } + return fmt.Errorf("unknown SmlVersionTarget edge %s", name) +} + +// 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 + 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 +} + +var _ ent.Mutation = (*TagMutation)(nil) + +// tagOption allows management of the mutation configuration using functional options. +type tagOption func(*TagMutation) + +// newTagMutation creates new mutation for the Tag entity. +func newTagMutation(c config, op Op, opts ...tagOption) *TagMutation { + m := &TagMutation{ + config: c, + op: op, + typ: TypeTag, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withTagID sets the ID field of the mutation. +func withTagID(id string) tagOption { + return func(m *TagMutation) { + var ( + err error + once sync.Once + value *Tag + ) + m.oldValue = func(ctx context.Context) (*Tag, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Tag.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withTag sets the old Tag of the mutation. +func withTag(node *Tag) tagOption { + return func(m *TagMutation) { + m.oldValue = func(context.Context) (*Tag, 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 TagMutation) 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 TagMutation) 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 Tag entities. +func (m *TagMutation) 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 *TagMutation) 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 *TagMutation) 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().Tag.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 *TagMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *TagMutation) 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 Tag entity. +// If the Tag 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 *TagMutation) 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 *TagMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *TagMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *TagMutation) 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 Tag entity. +// If the Tag 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 *TagMutation) 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 *TagMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *TagMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *TagMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Tag entity. +// If the Tag 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 *TagMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *TagMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[tag.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *TagMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[tag.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *TagMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, tag.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *TagMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *TagMutation) 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 Tag entity. +// If the Tag 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 *TagMutation) 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 *TagMutation) ResetName() { + m.name = nil +} + +// AddModIDs adds the "mods" edge to the Mod entity by ids. +func (m *TagMutation) 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 *TagMutation) ClearMods() { + m.clearedmods = true +} + +// ModsCleared reports if the "mods" edge to the Mod entity was cleared. +func (m *TagMutation) ModsCleared() bool { + return m.clearedmods +} + +// RemoveModIDs removes the "mods" edge to the Mod entity by IDs. +func (m *TagMutation) 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 *TagMutation) RemovedModsIDs() (ids []string) { + for id := range m.removedmods { + ids = append(ids, id) + } + return +} + +// ModsIDs returns the "mods" edge IDs in the mutation. +func (m *TagMutation) ModsIDs() (ids []string) { + for id := range m.mods { + ids = append(ids, id) + } + return +} + +// ResetMods resets all changes to the "mods" edge. +func (m *TagMutation) ResetMods() { + m.mods = nil + m.clearedmods = false + m.removedmods = nil +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by ids. +func (m *TagMutation) AddGuideIDs(ids ...string) { + if m.guides == nil { + m.guides = make(map[string]struct{}) + } + for i := range ids { + m.guides[ids[i]] = struct{}{} + } +} + +// ClearGuides clears the "guides" edge to the Guide entity. +func (m *TagMutation) ClearGuides() { + m.clearedguides = true +} + +// GuidesCleared reports if the "guides" edge to the Guide entity was cleared. +func (m *TagMutation) GuidesCleared() bool { + return m.clearedguides +} + +// RemoveGuideIDs removes the "guides" edge to the Guide entity by IDs. +func (m *TagMutation) RemoveGuideIDs(ids ...string) { + if m.removedguides == nil { + m.removedguides = make(map[string]struct{}) + } + for i := range ids { + delete(m.guides, ids[i]) + m.removedguides[ids[i]] = struct{}{} + } +} + +// RemovedGuides returns the removed IDs of the "guides" edge to the Guide entity. +func (m *TagMutation) RemovedGuidesIDs() (ids []string) { + for id := range m.removedguides { + ids = append(ids, id) + } + return +} + +// GuidesIDs returns the "guides" edge IDs in the mutation. +func (m *TagMutation) GuidesIDs() (ids []string) { + for id := range m.guides { + ids = append(ids, id) + } + return +} + +// ResetGuides resets all changes to the "guides" edge. +func (m *TagMutation) ResetGuides() { + m.guides = nil + m.clearedguides = false + m.removedguides = nil +} + +// Where appends a list predicates to the TagMutation builder. +func (m *TagMutation) Where(ps ...predicate.Tag) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the TagMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TagMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Tag, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *TagMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *TagMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Tag). +func (m *TagMutation) 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 *TagMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.created_at != nil { + fields = append(fields, tag.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, tag.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, tag.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, tag.FieldName) + } + 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 *TagMutation) Field(name string) (ent.Value, bool) { + switch name { + case tag.FieldCreatedAt: + return m.CreatedAt() + case tag.FieldUpdatedAt: + return m.UpdatedAt() + case tag.FieldDeletedAt: + return m.DeletedAt() + case tag.FieldName: + return m.Name() + } + 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 *TagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case tag.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case tag.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case tag.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case tag.FieldName: + return m.OldName(ctx) + } + return nil, fmt.Errorf("unknown Tag 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 *TagMutation) SetField(name string, value ent.Value) error { + switch name { + case tag.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 tag.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 tag.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case tag.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + } + return fmt.Errorf("unknown Tag field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TagMutation) 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 *TagMutation) 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 *TagMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Tag numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TagMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(tag.FieldDeletedAt) { + fields = append(fields, tag.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TagMutation) 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 *TagMutation) ClearField(name string) error { + switch name { + case tag.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown Tag 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 *TagMutation) ResetField(name string) error { + switch name { + case tag.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case tag.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case tag.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case tag.FieldName: + m.ResetName() + return nil + } + return fmt.Errorf("unknown Tag field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *TagMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.mods != nil { + edges = append(edges, tag.EdgeMods) + } + if m.guides != nil { + edges = append(edges, tag.EdgeGuides) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *TagMutation) AddedIDs(name string) []ent.Value { + switch name { + case tag.EdgeMods: + ids := make([]ent.Value, 0, len(m.mods)) + for id := range m.mods { + ids = append(ids, id) + } + return ids + case tag.EdgeGuides: + ids := make([]ent.Value, 0, len(m.guides)) + for id := range m.guides { + 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) + if m.removedmods != nil { + edges = append(edges, tag.EdgeMods) + } + if m.removedguides != nil { + edges = append(edges, tag.EdgeGuides) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *TagMutation) RemovedIDs(name string) []ent.Value { + switch name { + case tag.EdgeMods: + ids := make([]ent.Value, 0, len(m.removedmods)) + for id := range m.removedmods { + ids = append(ids, id) + } + return ids + case tag.EdgeGuides: + ids := make([]ent.Value, 0, len(m.removedguides)) + for id := range m.removedguides { + 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) + if m.clearedmods { + edges = append(edges, tag.EdgeMods) + } + if m.clearedguides { + edges = append(edges, tag.EdgeGuides) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *TagMutation) EdgeCleared(name string) bool { + switch name { + case tag.EdgeMods: + return m.clearedmods + case tag.EdgeGuides: + return m.clearedguides + } + 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 *TagMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Tag 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 *TagMutation) ResetEdge(name string) error { + switch name { + case tag.EdgeMods: + m.ResetMods() + return nil + case tag.EdgeGuides: + m.ResetGuides() + return nil + } + return fmt.Errorf("unknown Tag edge %s", name) +} + +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + email *string + username *string + avatar *string + joined_from *string + banned *bool + rank *int + addrank *int + github_id *string + google_id *string + facebook_id *string + clearedFields map[string]struct{} + guides map[string]struct{} + removedguides map[string]struct{} + clearedguides bool + sessions map[string]struct{} + removedsessions map[string]struct{} + clearedsessions bool + mods map[string]struct{} + removedmods map[string]struct{} + clearedmods bool + groups map[string]struct{} + removedgroups map[string]struct{} + clearedgroups bool + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User +} + +var _ ent.Mutation = (*UserMutation)(nil) + +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) + +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ + config: c, + op: op, + typ: TypeUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserID sets the ID field of the mutation. +func withUserID(id string) userOption { + return func(m *UserMutation) { + var ( + err error + once sync.Once + value *User + ) + m.oldValue = func(ctx context.Context) (*User, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().User.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, 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 UserMutation) 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 UserMutation) 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 User entities. +func (m *UserMutation) 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 *UserMutation) 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 *UserMutation) 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().User.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 *UserMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 *UserMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserMutation) 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 User entity. +// If the User 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 *UserMutation) 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 *UserMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the User entity. +// If the User 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 *UserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[user.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[user.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, user.FieldDeletedAt) +} + +// SetEmail sets the "email" field. +func (m *UserMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *UserMutation) Email() (r string, exists bool) { + v := m.email + if v == nil { + return + } + return *v, true +} + +// OldEmail returns the old "email" field's value of the User entity. +// If the User 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 *UserMutation) OldEmail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmail is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmail: %w", err) + } + return oldValue.Email, nil +} + +// ResetEmail resets all changes to the "email" field. +func (m *UserMutation) ResetEmail() { + m.email = nil +} + +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the User entity. +// If the User 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 *UserMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil +} + +// SetAvatar sets the "avatar" field. +func (m *UserMutation) SetAvatar(s string) { + m.avatar = &s +} + +// Avatar returns the value of the "avatar" field in the mutation. +func (m *UserMutation) Avatar() (r string, exists bool) { + v := m.avatar + if v == nil { + return + } + return *v, true +} + +// OldAvatar returns the old "avatar" field's value of the User entity. +// If the User 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 *UserMutation) OldAvatar(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAvatar is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAvatar requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAvatar: %w", err) + } + return oldValue.Avatar, nil +} + +// ClearAvatar clears the value of the "avatar" field. +func (m *UserMutation) ClearAvatar() { + m.avatar = nil + m.clearedFields[user.FieldAvatar] = struct{}{} +} + +// AvatarCleared returns if the "avatar" field was cleared in this mutation. +func (m *UserMutation) AvatarCleared() bool { + _, ok := m.clearedFields[user.FieldAvatar] + return ok +} + +// ResetAvatar resets all changes to the "avatar" field. +func (m *UserMutation) ResetAvatar() { + m.avatar = nil + delete(m.clearedFields, user.FieldAvatar) +} + +// SetJoinedFrom sets the "joined_from" field. +func (m *UserMutation) SetJoinedFrom(s string) { + m.joined_from = &s +} + +// JoinedFrom returns the value of the "joined_from" field in the mutation. +func (m *UserMutation) JoinedFrom() (r string, exists bool) { + v := m.joined_from + if v == nil { + return + } + return *v, true +} + +// OldJoinedFrom returns the old "joined_from" field's value of the User entity. +// If the User 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 *UserMutation) OldJoinedFrom(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldJoinedFrom is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldJoinedFrom requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldJoinedFrom: %w", err) + } + return oldValue.JoinedFrom, nil +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (m *UserMutation) ClearJoinedFrom() { + m.joined_from = nil + m.clearedFields[user.FieldJoinedFrom] = struct{}{} +} + +// JoinedFromCleared returns if the "joined_from" field was cleared in this mutation. +func (m *UserMutation) JoinedFromCleared() bool { + _, ok := m.clearedFields[user.FieldJoinedFrom] + return ok +} + +// ResetJoinedFrom resets all changes to the "joined_from" field. +func (m *UserMutation) ResetJoinedFrom() { + m.joined_from = nil + delete(m.clearedFields, user.FieldJoinedFrom) +} + +// SetBanned sets the "banned" field. +func (m *UserMutation) SetBanned(b bool) { + m.banned = &b +} + +// Banned returns the value of the "banned" field in the mutation. +func (m *UserMutation) Banned() (r bool, exists bool) { + v := m.banned + if v == nil { + return + } + return *v, true +} + +// OldBanned returns the old "banned" field's value of the User entity. +// If the User 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 *UserMutation) OldBanned(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBanned is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBanned requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBanned: %w", err) + } + return oldValue.Banned, nil +} + +// ResetBanned resets all changes to the "banned" field. +func (m *UserMutation) ResetBanned() { + m.banned = nil +} + +// SetRank sets the "rank" field. +func (m *UserMutation) SetRank(i int) { + m.rank = &i + m.addrank = nil +} + +// Rank returns the value of the "rank" field in the mutation. +func (m *UserMutation) Rank() (r int, exists bool) { + v := m.rank + if v == nil { + return + } + return *v, true +} + +// OldRank returns the old "rank" field's value of the User entity. +// If the User 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 *UserMutation) OldRank(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRank is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRank requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRank: %w", err) + } + return oldValue.Rank, nil +} + +// AddRank adds i to the "rank" field. +func (m *UserMutation) AddRank(i int) { + if m.addrank != nil { + *m.addrank += i + } else { + m.addrank = &i + } +} + +// AddedRank returns the value that was added to the "rank" field in this mutation. +func (m *UserMutation) AddedRank() (r int, exists bool) { + v := m.addrank + if v == nil { + return + } + return *v, true +} + +// ResetRank resets all changes to the "rank" field. +func (m *UserMutation) ResetRank() { + m.rank = nil + m.addrank = nil +} + +// SetGithubID sets the "github_id" field. +func (m *UserMutation) SetGithubID(s string) { + m.github_id = &s +} + +// GithubID returns the value of the "github_id" field in the mutation. +func (m *UserMutation) GithubID() (r string, exists bool) { + v := m.github_id + if v == nil { + return + } + return *v, true +} + +// OldGithubID returns the old "github_id" field's value of the User entity. +// If the User 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 *UserMutation) OldGithubID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGithubID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGithubID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGithubID: %w", err) + } + return oldValue.GithubID, nil +} + +// ClearGithubID clears the value of the "github_id" field. +func (m *UserMutation) ClearGithubID() { + m.github_id = nil + m.clearedFields[user.FieldGithubID] = struct{}{} +} + +// GithubIDCleared returns if the "github_id" field was cleared in this mutation. +func (m *UserMutation) GithubIDCleared() bool { + _, ok := m.clearedFields[user.FieldGithubID] + return ok +} + +// ResetGithubID resets all changes to the "github_id" field. +func (m *UserMutation) ResetGithubID() { + m.github_id = nil + delete(m.clearedFields, user.FieldGithubID) +} + +// SetGoogleID sets the "google_id" field. +func (m *UserMutation) SetGoogleID(s string) { + m.google_id = &s +} + +// GoogleID returns the value of the "google_id" field in the mutation. +func (m *UserMutation) GoogleID() (r string, exists bool) { + v := m.google_id + if v == nil { + return + } + return *v, true +} + +// OldGoogleID returns the old "google_id" field's value of the User entity. +// If the User 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 *UserMutation) OldGoogleID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGoogleID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGoogleID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGoogleID: %w", err) + } + return oldValue.GoogleID, nil +} + +// ClearGoogleID clears the value of the "google_id" field. +func (m *UserMutation) ClearGoogleID() { + m.google_id = nil + m.clearedFields[user.FieldGoogleID] = struct{}{} +} + +// GoogleIDCleared returns if the "google_id" field was cleared in this mutation. +func (m *UserMutation) GoogleIDCleared() bool { + _, ok := m.clearedFields[user.FieldGoogleID] + return ok +} + +// ResetGoogleID resets all changes to the "google_id" field. +func (m *UserMutation) ResetGoogleID() { + m.google_id = nil + delete(m.clearedFields, user.FieldGoogleID) +} + +// SetFacebookID sets the "facebook_id" field. +func (m *UserMutation) SetFacebookID(s string) { + m.facebook_id = &s +} + +// FacebookID returns the value of the "facebook_id" field in the mutation. +func (m *UserMutation) FacebookID() (r string, exists bool) { + v := m.facebook_id + if v == nil { + return + } + return *v, true +} + +// OldFacebookID returns the old "facebook_id" field's value of the User entity. +// If the User 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 *UserMutation) OldFacebookID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFacebookID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFacebookID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFacebookID: %w", err) + } + return oldValue.FacebookID, nil +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (m *UserMutation) ClearFacebookID() { + m.facebook_id = nil + m.clearedFields[user.FieldFacebookID] = struct{}{} +} + +// FacebookIDCleared returns if the "facebook_id" field was cleared in this mutation. +func (m *UserMutation) FacebookIDCleared() bool { + _, ok := m.clearedFields[user.FieldFacebookID] + return ok +} + +// ResetFacebookID resets all changes to the "facebook_id" field. +func (m *UserMutation) ResetFacebookID() { + m.facebook_id = nil + delete(m.clearedFields, user.FieldFacebookID) +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by ids. +func (m *UserMutation) AddGuideIDs(ids ...string) { + if m.guides == nil { + m.guides = make(map[string]struct{}) + } + for i := range ids { + m.guides[ids[i]] = struct{}{} + } +} + +// ClearGuides clears the "guides" edge to the Guide entity. +func (m *UserMutation) ClearGuides() { + m.clearedguides = true +} + +// GuidesCleared reports if the "guides" edge to the Guide entity was cleared. +func (m *UserMutation) GuidesCleared() bool { + return m.clearedguides +} + +// RemoveGuideIDs removes the "guides" edge to the Guide entity by IDs. +func (m *UserMutation) RemoveGuideIDs(ids ...string) { + if m.removedguides == nil { + m.removedguides = make(map[string]struct{}) + } + for i := range ids { + delete(m.guides, ids[i]) + m.removedguides[ids[i]] = struct{}{} + } +} + +// RemovedGuides returns the removed IDs of the "guides" edge to the Guide entity. +func (m *UserMutation) RemovedGuidesIDs() (ids []string) { + for id := range m.removedguides { + ids = append(ids, id) + } + return +} + +// GuidesIDs returns the "guides" edge IDs in the mutation. +func (m *UserMutation) GuidesIDs() (ids []string) { + for id := range m.guides { + ids = append(ids, id) + } + return +} + +// ResetGuides resets all changes to the "guides" edge. +func (m *UserMutation) ResetGuides() { + m.guides = nil + m.clearedguides = false + m.removedguides = nil +} + +// AddSessionIDs adds the "sessions" edge to the UserSession entity by ids. +func (m *UserMutation) AddSessionIDs(ids ...string) { + if m.sessions == nil { + m.sessions = make(map[string]struct{}) + } + for i := range ids { + m.sessions[ids[i]] = struct{}{} + } +} + +// ClearSessions clears the "sessions" edge to the UserSession entity. +func (m *UserMutation) ClearSessions() { + m.clearedsessions = true +} + +// SessionsCleared reports if the "sessions" edge to the UserSession entity was cleared. +func (m *UserMutation) SessionsCleared() bool { + return m.clearedsessions +} + +// RemoveSessionIDs removes the "sessions" edge to the UserSession entity by IDs. +func (m *UserMutation) RemoveSessionIDs(ids ...string) { + if m.removedsessions == nil { + m.removedsessions = make(map[string]struct{}) + } + for i := range ids { + delete(m.sessions, ids[i]) + m.removedsessions[ids[i]] = struct{}{} + } +} + +// RemovedSessions returns the removed IDs of the "sessions" edge to the UserSession entity. +func (m *UserMutation) RemovedSessionsIDs() (ids []string) { + for id := range m.removedsessions { + ids = append(ids, id) + } + return +} + +// SessionsIDs returns the "sessions" edge IDs in the mutation. +func (m *UserMutation) SessionsIDs() (ids []string) { + for id := range m.sessions { + ids = append(ids, id) + } + return +} + +// ResetSessions resets all changes to the "sessions" edge. +func (m *UserMutation) ResetSessions() { + m.sessions = nil + m.clearedsessions = false + m.removedsessions = nil +} + +// AddModIDs adds the "mods" edge to the Mod entity by ids. +func (m *UserMutation) 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 *UserMutation) ClearMods() { + m.clearedmods = true +} + +// ModsCleared reports if the "mods" edge to the Mod entity was cleared. +func (m *UserMutation) ModsCleared() bool { + return m.clearedmods +} + +// RemoveModIDs removes the "mods" edge to the Mod entity by IDs. +func (m *UserMutation) 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 *UserMutation) RemovedModsIDs() (ids []string) { + for id := range m.removedmods { + ids = append(ids, id) + } + return +} + +// ModsIDs returns the "mods" edge IDs in the mutation. +func (m *UserMutation) ModsIDs() (ids []string) { + for id := range m.mods { + ids = append(ids, id) + } + return +} + +// ResetMods resets all changes to the "mods" edge. +func (m *UserMutation) ResetMods() { + m.mods = nil + m.clearedmods = false + m.removedmods = nil +} + +// AddGroupIDs adds the "groups" edge to the UserGroup entity by ids. +func (m *UserMutation) AddGroupIDs(ids ...string) { + if m.groups == nil { + m.groups = make(map[string]struct{}) + } + for i := range ids { + m.groups[ids[i]] = struct{}{} + } +} + +// ClearGroups clears the "groups" edge to the UserGroup entity. +func (m *UserMutation) ClearGroups() { + m.clearedgroups = true +} + +// GroupsCleared reports if the "groups" edge to the UserGroup entity was cleared. +func (m *UserMutation) GroupsCleared() bool { + return m.clearedgroups +} + +// RemoveGroupIDs removes the "groups" edge to the UserGroup entity by IDs. +func (m *UserMutation) RemoveGroupIDs(ids ...string) { + if m.removedgroups == nil { + m.removedgroups = make(map[string]struct{}) + } + for i := range ids { + delete(m.groups, ids[i]) + m.removedgroups[ids[i]] = struct{}{} + } +} + +// RemovedGroups returns the removed IDs of the "groups" edge to the UserGroup entity. +func (m *UserMutation) RemovedGroupsIDs() (ids []string) { + for id := range m.removedgroups { + ids = append(ids, id) + } + return +} + +// GroupsIDs returns the "groups" edge IDs in the mutation. +func (m *UserMutation) GroupsIDs() (ids []string) { + for id := range m.groups { + ids = append(ids, id) + } + return +} + +// ResetGroups resets all changes to the "groups" edge. +func (m *UserMutation) ResetGroups() { + m.groups = nil + m.clearedgroups = false + m.removedgroups = nil +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) 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 *UserMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.created_at != nil { + fields = append(fields, user.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, user.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, user.FieldDeletedAt) + } + if m.email != nil { + fields = append(fields, user.FieldEmail) + } + if m.username != nil { + fields = append(fields, user.FieldUsername) + } + if m.avatar != nil { + fields = append(fields, user.FieldAvatar) + } + if m.joined_from != nil { + fields = append(fields, user.FieldJoinedFrom) + } + if m.banned != nil { + fields = append(fields, user.FieldBanned) + } + if m.rank != nil { + fields = append(fields, user.FieldRank) + } + if m.github_id != nil { + fields = append(fields, user.FieldGithubID) + } + if m.google_id != nil { + fields = append(fields, user.FieldGoogleID) + } + if m.facebook_id != nil { + fields = append(fields, user.FieldFacebookID) + } + 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 *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldCreatedAt: + return m.CreatedAt() + case user.FieldUpdatedAt: + return m.UpdatedAt() + case user.FieldDeletedAt: + return m.DeletedAt() + case user.FieldEmail: + return m.Email() + case user.FieldUsername: + return m.Username() + case user.FieldAvatar: + return m.Avatar() + case user.FieldJoinedFrom: + return m.JoinedFrom() + case user.FieldBanned: + return m.Banned() + case user.FieldRank: + return m.Rank() + case user.FieldGithubID: + return m.GithubID() + case user.FieldGoogleID: + return m.GoogleID() + case user.FieldFacebookID: + return m.FacebookID() + } + 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 *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case user.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case user.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case user.FieldEmail: + return m.OldEmail(ctx) + case user.FieldUsername: + return m.OldUsername(ctx) + case user.FieldAvatar: + return m.OldAvatar(ctx) + case user.FieldJoinedFrom: + return m.OldJoinedFrom(ctx) + case user.FieldBanned: + return m.OldBanned(ctx) + case user.FieldRank: + return m.OldRank(ctx) + case user.FieldGithubID: + return m.OldGithubID(ctx) + case user.FieldGoogleID: + return m.OldGoogleID(ctx) + case user.FieldFacebookID: + return m.OldFacebookID(ctx) + } + return nil, fmt.Errorf("unknown User 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 *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.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 user.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 user.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case user.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case user.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case user.FieldAvatar: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAvatar(v) + return nil + case user.FieldJoinedFrom: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetJoinedFrom(v) + return nil + case user.FieldBanned: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBanned(v) + return nil + case user.FieldRank: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRank(v) + return nil + case user.FieldGithubID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGithubID(v) + return nil + case user.FieldGoogleID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGoogleID(v) + return nil + case user.FieldFacebookID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFacebookID(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addrank != nil { + fields = append(fields, user.FieldRank) + } + 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 *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldRank: + return m.AddedRank() + } + 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 *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldRank: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRank(v) + return nil + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldDeletedAt) { + fields = append(fields, user.FieldDeletedAt) + } + if m.FieldCleared(user.FieldAvatar) { + fields = append(fields, user.FieldAvatar) + } + if m.FieldCleared(user.FieldJoinedFrom) { + fields = append(fields, user.FieldJoinedFrom) + } + if m.FieldCleared(user.FieldGithubID) { + fields = append(fields, user.FieldGithubID) + } + if m.FieldCleared(user.FieldGoogleID) { + fields = append(fields, user.FieldGoogleID) + } + if m.FieldCleared(user.FieldFacebookID) { + fields = append(fields, user.FieldFacebookID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) 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 *UserMutation) ClearField(name string) error { + switch name { + case user.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case user.FieldAvatar: + m.ClearAvatar() + return nil + case user.FieldJoinedFrom: + m.ClearJoinedFrom() + return nil + case user.FieldGithubID: + m.ClearGithubID() + return nil + case user.FieldGoogleID: + m.ClearGoogleID() + return nil + case user.FieldFacebookID: + m.ClearFacebookID() + return nil + } + return fmt.Errorf("unknown User 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 *UserMutation) ResetField(name string) error { + switch name { + case user.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case user.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case user.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case user.FieldEmail: + m.ResetEmail() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldAvatar: + m.ResetAvatar() + return nil + case user.FieldJoinedFrom: + m.ResetJoinedFrom() + return nil + case user.FieldBanned: + m.ResetBanned() + return nil + case user.FieldRank: + m.ResetRank() + return nil + case user.FieldGithubID: + m.ResetGithubID() + return nil + case user.FieldGoogleID: + m.ResetGoogleID() + return nil + case user.FieldFacebookID: + m.ResetFacebookID() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.guides != nil { + edges = append(edges, user.EdgeGuides) + } + if m.sessions != nil { + edges = append(edges, user.EdgeSessions) + } + if m.mods != nil { + edges = append(edges, user.EdgeMods) + } + if m.groups != nil { + edges = append(edges, user.EdgeGroups) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + switch name { + case user.EdgeGuides: + ids := make([]ent.Value, 0, len(m.guides)) + for id := range m.guides { + ids = append(ids, id) + } + return ids + case user.EdgeSessions: + ids := make([]ent.Value, 0, len(m.sessions)) + for id := range m.sessions { + ids = append(ids, id) + } + return ids + case user.EdgeMods: + ids := make([]ent.Value, 0, len(m.mods)) + for id := range m.mods { + ids = append(ids, id) + } + return ids + case user.EdgeGroups: + ids := make([]ent.Value, 0, len(m.groups)) + for id := range m.groups { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedguides != nil { + edges = append(edges, user.EdgeGuides) + } + if m.removedsessions != nil { + edges = append(edges, user.EdgeSessions) + } + if m.removedmods != nil { + edges = append(edges, user.EdgeMods) + } + if m.removedgroups != nil { + edges = append(edges, user.EdgeGroups) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + switch name { + case user.EdgeGuides: + ids := make([]ent.Value, 0, len(m.removedguides)) + for id := range m.removedguides { + ids = append(ids, id) + } + return ids + case user.EdgeSessions: + ids := make([]ent.Value, 0, len(m.removedsessions)) + for id := range m.removedsessions { + ids = append(ids, id) + } + return ids + case user.EdgeMods: + ids := make([]ent.Value, 0, len(m.removedmods)) + for id := range m.removedmods { + ids = append(ids, id) + } + return ids + case user.EdgeGroups: + ids := make([]ent.Value, 0, len(m.removedgroups)) + for id := range m.removedgroups { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedguides { + edges = append(edges, user.EdgeGuides) + } + if m.clearedsessions { + edges = append(edges, user.EdgeSessions) + } + if m.clearedmods { + edges = append(edges, user.EdgeMods) + } + if m.clearedgroups { + edges = append(edges, user.EdgeGroups) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + switch name { + case user.EdgeGuides: + return m.clearedguides + case user.EdgeSessions: + return m.clearedsessions + case user.EdgeMods: + return m.clearedmods + case user.EdgeGroups: + return m.clearedgroups + } + 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 *UserMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown User 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 *UserMutation) ResetEdge(name string) error { + switch name { + case user.EdgeGuides: + m.ResetGuides() + return nil + case user.EdgeSessions: + m.ResetSessions() + return nil + case user.EdgeMods: + m.ResetMods() + return nil + case user.EdgeGroups: + m.ResetGroups() + return nil + } + return fmt.Errorf("unknown User edge %s", name) +} + +// UserGroupMutation represents an operation that mutates the UserGroup nodes in the graph. +type UserGroupMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + group_id *string + clearedFields map[string]struct{} + user *string + cleareduser bool + done bool + oldValue func(context.Context) (*UserGroup, error) + predicates []predicate.UserGroup +} + +var _ ent.Mutation = (*UserGroupMutation)(nil) + +// usergroupOption allows management of the mutation configuration using functional options. +type usergroupOption func(*UserGroupMutation) + +// newUserGroupMutation creates new mutation for the UserGroup entity. +func newUserGroupMutation(c config, op Op, opts ...usergroupOption) *UserGroupMutation { + m := &UserGroupMutation{ + config: c, + op: op, + typ: TypeUserGroup, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserGroupID sets the ID field of the mutation. +func withUserGroupID(id string) usergroupOption { + return func(m *UserGroupMutation) { + var ( + err error + once sync.Once + value *UserGroup + ) + m.oldValue = func(ctx context.Context) (*UserGroup, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserGroup.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserGroup sets the old UserGroup of the mutation. +func withUserGroup(node *UserGroup) usergroupOption { + return func(m *UserGroupMutation) { + m.oldValue = func(context.Context) (*UserGroup, 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 UserGroupMutation) 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 UserGroupMutation) 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 UserGroup entities. +func (m *UserGroupMutation) 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 *UserGroupMutation) 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 *UserGroupMutation) 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().UserGroup.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 *UserGroupMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserGroupMutation) 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 UserGroup entity. +// If the UserGroup 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 *UserGroupMutation) 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 *UserGroupMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserGroupMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserGroupMutation) 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 UserGroup entity. +// If the UserGroup 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 *UserGroupMutation) 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 *UserGroupMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserGroupMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserGroupMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the UserGroup entity. +// If the UserGroup 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 *UserGroupMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserGroupMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[usergroup.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserGroupMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[usergroup.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserGroupMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, usergroup.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *UserGroupMutation) SetUserID(s string) { + m.user = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserGroupMutation) UserID() (r string, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserGroup entity. +// If the UserGroup 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 *UserGroupMutation) OldUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserGroupMutation) ResetUserID() { + m.user = nil +} + +// SetGroupID sets the "group_id" field. +func (m *UserGroupMutation) SetGroupID(s string) { + m.group_id = &s +} + +// GroupID returns the value of the "group_id" field in the mutation. +func (m *UserGroupMutation) GroupID() (r string, exists bool) { + v := m.group_id + if v == nil { + return + } + return *v, true +} + +// OldGroupID returns the old "group_id" field's value of the UserGroup entity. +// If the UserGroup 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 *UserGroupMutation) OldGroupID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGroupID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGroupID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGroupID: %w", err) + } + return oldValue.GroupID, nil +} + +// ResetGroupID resets all changes to the "group_id" field. +func (m *UserGroupMutation) ResetGroupID() { + m.group_id = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserGroupMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[usergroup.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserGroupMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserGroupMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserGroupMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// Where appends a list predicates to the UserGroupMutation builder. +func (m *UserGroupMutation) Where(ps ...predicate.UserGroup) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserGroupMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserGroupMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserGroup, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserGroupMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserGroupMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserGroup). +func (m *UserGroupMutation) 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 *UserGroupMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.created_at != nil { + fields = append(fields, usergroup.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, usergroup.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, usergroup.FieldDeletedAt) + } + if m.user != nil { + fields = append(fields, usergroup.FieldUserID) + } + if m.group_id != nil { + fields = append(fields, usergroup.FieldGroupID) + } + 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 *UserGroupMutation) Field(name string) (ent.Value, bool) { + switch name { + case usergroup.FieldCreatedAt: + return m.CreatedAt() + case usergroup.FieldUpdatedAt: + return m.UpdatedAt() + case usergroup.FieldDeletedAt: + return m.DeletedAt() + case usergroup.FieldUserID: + return m.UserID() + case usergroup.FieldGroupID: + return m.GroupID() + } + 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 *UserGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case usergroup.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case usergroup.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case usergroup.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case usergroup.FieldUserID: + return m.OldUserID(ctx) + case usergroup.FieldGroupID: + return m.OldGroupID(ctx) + } + return nil, fmt.Errorf("unknown UserGroup 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 *UserGroupMutation) SetField(name string, value ent.Value) error { + switch name { + case usergroup.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 usergroup.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 usergroup.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case usergroup.FieldUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case usergroup.FieldGroupID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGroupID(v) + return nil + } + return fmt.Errorf("unknown UserGroup field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserGroupMutation) 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 *UserGroupMutation) 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 *UserGroupMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown UserGroup numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserGroupMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(usergroup.FieldDeletedAt) { + fields = append(fields, usergroup.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserGroupMutation) 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 *UserGroupMutation) ClearField(name string) error { + switch name { + case usergroup.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown UserGroup 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 *UserGroupMutation) ResetField(name string) error { + switch name { + case usergroup.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case usergroup.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case usergroup.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case usergroup.FieldUserID: + m.ResetUserID() + return nil + case usergroup.FieldGroupID: + m.ResetGroupID() + return nil + } + return fmt.Errorf("unknown UserGroup field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserGroupMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.user != nil { + edges = append(edges, usergroup.EdgeUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserGroupMutation) AddedIDs(name string) []ent.Value { + switch name { + case usergroup.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserGroupMutation) 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 *UserGroupMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserGroupMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareduser { + edges = append(edges, usergroup.EdgeUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserGroupMutation) EdgeCleared(name string) bool { + switch name { + case usergroup.EdgeUser: + return m.cleareduser + } + 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 *UserGroupMutation) ClearEdge(name string) error { + switch name { + case usergroup.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown UserGroup 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 *UserGroupMutation) ResetEdge(name string) error { + switch name { + case usergroup.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown UserGroup edge %s", name) +} + +// UserModMutation represents an operation that mutates the UserMod nodes in the graph. +type UserModMutation struct { + config + op Op + typ string + role *string + clearedFields map[string]struct{} + user *string + cleareduser bool + mod *string + clearedmod bool + done bool + oldValue func(context.Context) (*UserMod, error) + predicates []predicate.UserMod +} + +var _ ent.Mutation = (*UserModMutation)(nil) + +// usermodOption allows management of the mutation configuration using functional options. +type usermodOption func(*UserModMutation) + +// newUserModMutation creates new mutation for the UserMod entity. +func newUserModMutation(c config, op Op, opts ...usermodOption) *UserModMutation { + m := &UserModMutation{ + config: c, + op: op, + typ: TypeUserMod, + 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 UserModMutation) 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 UserModMutation) 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 +} + +// SetUserID sets the "user_id" field. +func (m *UserModMutation) SetUserID(s string) { + m.user = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserModMutation) UserID() (r string, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserModMutation) ResetUserID() { + m.user = nil +} + +// SetModID sets the "mod_id" field. +func (m *UserModMutation) SetModID(s string) { + m.mod = &s +} + +// ModID returns the value of the "mod_id" field in the mutation. +func (m *UserModMutation) 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 *UserModMutation) ResetModID() { + m.mod = nil +} + +// SetRole sets the "role" field. +func (m *UserModMutation) SetRole(s string) { + m.role = &s +} + +// Role returns the value of the "role" field in the mutation. +func (m *UserModMutation) Role() (r string, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// ResetRole resets all changes to the "role" field. +func (m *UserModMutation) ResetRole() { + m.role = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserModMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[usermod.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserModMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserModMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserModMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (m *UserModMutation) ClearMod() { + m.clearedmod = true + m.clearedFields[usermod.FieldModID] = struct{}{} +} + +// ModCleared reports if the "mod" edge to the Mod entity was cleared. +func (m *UserModMutation) 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 *UserModMutation) ModIDs() (ids []string) { + if id := m.mod; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMod resets all changes to the "mod" edge. +func (m *UserModMutation) ResetMod() { + m.mod = nil + m.clearedmod = false +} + +// Where appends a list predicates to the UserModMutation builder. +func (m *UserModMutation) Where(ps ...predicate.UserMod) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserModMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserModMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserMod, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserModMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserModMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserMod). +func (m *UserModMutation) 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 *UserModMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.user != nil { + fields = append(fields, usermod.FieldUserID) + } + if m.mod != nil { + fields = append(fields, usermod.FieldModID) + } + if m.role != nil { + fields = append(fields, usermod.FieldRole) + } + 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 *UserModMutation) Field(name string) (ent.Value, bool) { + switch name { + case usermod.FieldUserID: + return m.UserID() + case usermod.FieldModID: + return m.ModID() + case usermod.FieldRole: + return m.Role() + } + 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 *UserModMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema UserMod 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 *UserModMutation) SetField(name string, value ent.Value) error { + switch name { + case usermod.FieldUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case usermod.FieldModID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModID(v) + return nil + case usermod.FieldRole: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRole(v) + return nil + } + return fmt.Errorf("unknown UserMod field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserModMutation) 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 *UserModMutation) 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 *UserModMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown UserMod numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserModMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserModMutation) 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 *UserModMutation) ClearField(name string) error { + return fmt.Errorf("unknown UserMod 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 *UserModMutation) ResetField(name string) error { + switch name { + case usermod.FieldUserID: + m.ResetUserID() + return nil + case usermod.FieldModID: + m.ResetModID() + return nil + case usermod.FieldRole: + m.ResetRole() + return nil + } + return fmt.Errorf("unknown UserMod field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserModMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.user != nil { + edges = append(edges, usermod.EdgeUser) + } + if m.mod != nil { + edges = append(edges, usermod.EdgeMod) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserModMutation) AddedIDs(name string) []ent.Value { + switch name { + case usermod.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case usermod.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 *UserModMutation) 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 *UserModMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserModMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleareduser { + edges = append(edges, usermod.EdgeUser) + } + if m.clearedmod { + edges = append(edges, usermod.EdgeMod) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserModMutation) EdgeCleared(name string) bool { + switch name { + case usermod.EdgeUser: + return m.cleareduser + case usermod.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 *UserModMutation) ClearEdge(name string) error { + switch name { + case usermod.EdgeUser: + m.ClearUser() + return nil + case usermod.EdgeMod: + m.ClearMod() + return nil + } + return fmt.Errorf("unknown UserMod 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 *UserModMutation) ResetEdge(name string) error { + switch name { + case usermod.EdgeUser: + m.ResetUser() + return nil + case usermod.EdgeMod: + m.ResetMod() + return nil + } + return fmt.Errorf("unknown UserMod edge %s", name) +} + +// UserSessionMutation represents an operation that mutates the UserSession nodes in the graph. +type UserSessionMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + token *string + user_agent *string + clearedFields map[string]struct{} + user *string + cleareduser bool + done bool + oldValue func(context.Context) (*UserSession, error) + predicates []predicate.UserSession +} + +var _ ent.Mutation = (*UserSessionMutation)(nil) + +// usersessionOption allows management of the mutation configuration using functional options. +type usersessionOption func(*UserSessionMutation) + +// newUserSessionMutation creates new mutation for the UserSession entity. +func newUserSessionMutation(c config, op Op, opts ...usersessionOption) *UserSessionMutation { + m := &UserSessionMutation{ + config: c, + op: op, + typ: TypeUserSession, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserSessionID sets the ID field of the mutation. +func withUserSessionID(id string) usersessionOption { + return func(m *UserSessionMutation) { + var ( + err error + once sync.Once + value *UserSession + ) + m.oldValue = func(ctx context.Context) (*UserSession, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserSession.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserSession sets the old UserSession of the mutation. +func withUserSession(node *UserSession) usersessionOption { + return func(m *UserSessionMutation) { + m.oldValue = func(context.Context) (*UserSession, 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 UserSessionMutation) 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 UserSessionMutation) 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 UserSession entities. +func (m *UserSessionMutation) 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 *UserSessionMutation) 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 *UserSessionMutation) 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().UserSession.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 *UserSessionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserSessionMutation) 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 UserSession entity. +// If the UserSession 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 *UserSessionMutation) 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 *UserSessionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserSessionMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserSessionMutation) 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 UserSession entity. +// If the UserSession 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 *UserSessionMutation) 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 *UserSessionMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *UserSessionMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *UserSessionMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the UserSession entity. +// If the UserSession 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 *UserSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *UserSessionMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[usersession.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *UserSessionMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[usersession.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *UserSessionMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, usersession.FieldDeletedAt) +} + +// SetToken sets the "token" field. +func (m *UserSessionMutation) SetToken(s string) { + m.token = &s +} + +// Token returns the value of the "token" field in the mutation. +func (m *UserSessionMutation) Token() (r string, exists bool) { + v := m.token + if v == nil { + return + } + return *v, true +} + +// OldToken returns the old "token" field's value of the UserSession entity. +// If the UserSession 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 *UserSessionMutation) OldToken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldToken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldToken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldToken: %w", err) + } + return oldValue.Token, nil +} + +// ResetToken resets all changes to the "token" field. +func (m *UserSessionMutation) ResetToken() { + m.token = nil +} + +// SetUserAgent sets the "user_agent" field. +func (m *UserSessionMutation) SetUserAgent(s string) { + m.user_agent = &s +} + +// UserAgent returns the value of the "user_agent" field in the mutation. +func (m *UserSessionMutation) UserAgent() (r string, exists bool) { + v := m.user_agent + if v == nil { + return + } + return *v, true +} + +// OldUserAgent returns the old "user_agent" field's value of the UserSession entity. +// If the UserSession 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 *UserSessionMutation) OldUserAgent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserAgent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserAgent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserAgent: %w", err) + } + return oldValue.UserAgent, nil +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (m *UserSessionMutation) ClearUserAgent() { + m.user_agent = nil + m.clearedFields[usersession.FieldUserAgent] = struct{}{} +} + +// UserAgentCleared returns if the "user_agent" field was cleared in this mutation. +func (m *UserSessionMutation) UserAgentCleared() bool { + _, ok := m.clearedFields[usersession.FieldUserAgent] + return ok +} + +// ResetUserAgent resets all changes to the "user_agent" field. +func (m *UserSessionMutation) ResetUserAgent() { + m.user_agent = nil + delete(m.clearedFields, usersession.FieldUserAgent) +} + +// SetUserID sets the "user" edge to the User entity by id. +func (m *UserSessionMutation) SetUserID(id string) { + m.user = &id +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserSessionMutation) ClearUser() { + m.cleareduser = true +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserSessionMutation) UserCleared() bool { + return m.cleareduser +} + +// UserID returns the "user" edge ID in the mutation. +func (m *UserSessionMutation) UserID() (id string, exists bool) { + if m.user != nil { + return *m.user, true + } + return +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserSessionMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserSessionMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// Where appends a list predicates to the UserSessionMutation builder. +func (m *UserSessionMutation) Where(ps ...predicate.UserSession) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserSessionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserSessionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserSession, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserSessionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserSessionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserSession). +func (m *UserSessionMutation) 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 *UserSessionMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.created_at != nil { + fields = append(fields, usersession.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, usersession.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, usersession.FieldDeletedAt) + } + if m.token != nil { + fields = append(fields, usersession.FieldToken) + } + if m.user_agent != nil { + fields = append(fields, usersession.FieldUserAgent) + } + 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 *UserSessionMutation) Field(name string) (ent.Value, bool) { + switch name { + case usersession.FieldCreatedAt: + return m.CreatedAt() + case usersession.FieldUpdatedAt: + return m.UpdatedAt() + case usersession.FieldDeletedAt: + return m.DeletedAt() + case usersession.FieldToken: + return m.Token() + case usersession.FieldUserAgent: + return m.UserAgent() + } + 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 *UserSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case usersession.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case usersession.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case usersession.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case usersession.FieldToken: + return m.OldToken(ctx) + case usersession.FieldUserAgent: + return m.OldUserAgent(ctx) + } + return nil, fmt.Errorf("unknown UserSession 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 *UserSessionMutation) SetField(name string, value ent.Value) error { + switch name { + case usersession.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 usersession.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 usersession.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case usersession.FieldToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetToken(v) + return nil + case usersession.FieldUserAgent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserAgent(v) + return nil + } + return fmt.Errorf("unknown UserSession field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserSessionMutation) 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 *UserSessionMutation) 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 *UserSessionMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown UserSession numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserSessionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(usersession.FieldDeletedAt) { + fields = append(fields, usersession.FieldDeletedAt) + } + if m.FieldCleared(usersession.FieldUserAgent) { + fields = append(fields, usersession.FieldUserAgent) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserSessionMutation) 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 *UserSessionMutation) ClearField(name string) error { + switch name { + case usersession.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case usersession.FieldUserAgent: + m.ClearUserAgent() + return nil + } + return fmt.Errorf("unknown UserSession 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 *UserSessionMutation) ResetField(name string) error { + switch name { + case usersession.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case usersession.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case usersession.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case usersession.FieldToken: + m.ResetToken() + return nil + case usersession.FieldUserAgent: + m.ResetUserAgent() + return nil + } + return fmt.Errorf("unknown UserSession field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserSessionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.user != nil { + edges = append(edges, usersession.EdgeUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserSessionMutation) AddedIDs(name string) []ent.Value { + switch name { + case usersession.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserSessionMutation) 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 *UserSessionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserSessionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareduser { + edges = append(edges, usersession.EdgeUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserSessionMutation) EdgeCleared(name string) bool { + switch name { + case usersession.EdgeUser: + return m.cleareduser + } + 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 *UserSessionMutation) ClearEdge(name string) error { + switch name { + case usersession.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown UserSession 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 *UserSessionMutation) ResetEdge(name string) error { + switch name { + case usersession.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown UserSession edge %s", name) +} + +// VersionMutation represents an operation that mutates the Version nodes in the graph. +type VersionMutation struct { + config + op Op + typ string + id *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + version *string + sml_version *string + changelog *string + downloads *uint + adddownloads *int + key *string + stability *version.Stability + approved *bool + hotness *uint + addhotness *int + denied *bool + metadata *string + mod_reference *string + version_major *int + addversion_major *int + version_minor *int + addversion_minor *int + version_patch *int + addversion_patch *int + size *int64 + addsize *int64 + hash *string + clearedFields map[string]struct{} + mod *string + clearedmod bool + dependencies map[string]struct{} + removeddependencies map[string]struct{} + cleareddependencies bool + done bool + oldValue func(context.Context) (*Version, error) + predicates []predicate.Version +} + +var _ ent.Mutation = (*VersionMutation)(nil) + +// versionOption allows management of the mutation configuration using functional options. +type versionOption func(*VersionMutation) + +// newVersionMutation creates new mutation for the Version entity. +func newVersionMutation(c config, op Op, opts ...versionOption) *VersionMutation { + m := &VersionMutation{ + config: c, + op: op, + typ: TypeVersion, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withVersionID sets the ID field of the mutation. +func withVersionID(id string) versionOption { + return func(m *VersionMutation) { + var ( + err error + once sync.Once + value *Version + ) + m.oldValue = func(ctx context.Context) (*Version, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Version.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withVersion sets the old Version of the mutation. +func withVersion(node *Version) versionOption { + return func(m *VersionMutation) { + m.oldValue = func(context.Context) (*Version, 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 VersionMutation) 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 VersionMutation) 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 Version entities. +func (m *VersionMutation) 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 *VersionMutation) 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 *VersionMutation) 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().Version.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 *VersionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *VersionMutation) 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 Version entity. +// If the Version 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 *VersionMutation) 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 *VersionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *VersionMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *VersionMutation) 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 Version entity. +// If the Version 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 *VersionMutation) 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 *VersionMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *VersionMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *VersionMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *VersionMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[version.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *VersionMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[version.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *VersionMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, version.FieldDeletedAt) +} + +// SetVersion sets the "version" field. +func (m *VersionMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *VersionMutation) 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 Version entity. +// If the Version 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 *VersionMutation) 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 *VersionMutation) ResetVersion() { + m.version = nil +} + +// SetSmlVersion sets the "sml_version" field. +func (m *VersionMutation) SetSmlVersion(s string) { + m.sml_version = &s +} + +// SmlVersion returns the value of the "sml_version" field in the mutation. +func (m *VersionMutation) SmlVersion() (r string, exists bool) { + v := m.sml_version + if v == nil { + return + } + return *v, true +} + +// OldSmlVersion returns the old "sml_version" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldSmlVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSmlVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSmlVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSmlVersion: %w", err) + } + return oldValue.SmlVersion, nil +} + +// ResetSmlVersion resets all changes to the "sml_version" field. +func (m *VersionMutation) ResetSmlVersion() { + m.sml_version = nil +} + +// SetChangelog sets the "changelog" field. +func (m *VersionMutation) SetChangelog(s string) { + m.changelog = &s +} + +// Changelog returns the value of the "changelog" field in the mutation. +func (m *VersionMutation) 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 Version entity. +// If the Version 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 *VersionMutation) 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 *VersionMutation) ResetChangelog() { + m.changelog = nil +} + +// SetDownloads sets the "downloads" field. +func (m *VersionMutation) SetDownloads(u uint) { + m.downloads = &u + m.adddownloads = nil +} + +// Downloads returns the value of the "downloads" field in the mutation. +func (m *VersionMutation) Downloads() (r uint, exists bool) { + v := m.downloads + if v == nil { + return + } + return *v, true +} + +// OldDownloads returns the old "downloads" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldDownloads(ctx context.Context) (v uint, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDownloads is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDownloads requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDownloads: %w", err) + } + return oldValue.Downloads, nil +} + +// AddDownloads adds u to the "downloads" field. +func (m *VersionMutation) AddDownloads(u int) { + if m.adddownloads != nil { + *m.adddownloads += u + } else { + m.adddownloads = &u + } +} + +// AddedDownloads returns the value that was added to the "downloads" field in this mutation. +func (m *VersionMutation) AddedDownloads() (r int, exists bool) { + v := m.adddownloads + if v == nil { + return + } + return *v, true +} + +// ResetDownloads resets all changes to the "downloads" field. +func (m *VersionMutation) ResetDownloads() { + m.downloads = nil + m.adddownloads = nil +} + +// SetKey sets the "key" field. +func (m *VersionMutation) SetKey(s string) { + m.key = &s +} + +// Key returns the value of the "key" field in the mutation. +func (m *VersionMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return + } + return *v, true +} + +// OldKey returns the old "key" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil +} + +// ResetKey resets all changes to the "key" field. +func (m *VersionMutation) ResetKey() { + m.key = nil +} + +// SetStability sets the "stability" field. +func (m *VersionMutation) SetStability(v version.Stability) { + m.stability = &v +} + +// Stability returns the value of the "stability" field in the mutation. +func (m *VersionMutation) Stability() (r version.Stability, exists bool) { + v := m.stability + if v == nil { + return + } + return *v, true +} + +// OldStability returns the old "stability" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldStability(ctx context.Context) (v version.Stability, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStability is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStability requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStability: %w", err) + } + return oldValue.Stability, nil +} + +// ResetStability resets all changes to the "stability" field. +func (m *VersionMutation) ResetStability() { + m.stability = nil +} + +// SetApproved sets the "approved" field. +func (m *VersionMutation) SetApproved(b bool) { + m.approved = &b +} + +// Approved returns the value of the "approved" field in the mutation. +func (m *VersionMutation) Approved() (r bool, exists bool) { + v := m.approved + if v == nil { + return + } + return *v, true +} + +// OldApproved returns the old "approved" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldApproved(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldApproved is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldApproved requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldApproved: %w", err) + } + return oldValue.Approved, nil +} + +// ResetApproved resets all changes to the "approved" field. +func (m *VersionMutation) ResetApproved() { + m.approved = nil +} + +// SetHotness sets the "hotness" field. +func (m *VersionMutation) SetHotness(u uint) { + m.hotness = &u + m.addhotness = nil +} + +// Hotness returns the value of the "hotness" field in the mutation. +func (m *VersionMutation) 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 Version entity. +// If the Version 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 *VersionMutation) 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 *VersionMutation) 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 *VersionMutation) 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 *VersionMutation) ResetHotness() { + m.hotness = nil + m.addhotness = nil +} + +// SetDenied sets the "denied" field. +func (m *VersionMutation) SetDenied(b bool) { + m.denied = &b +} + +// Denied returns the value of the "denied" field in the mutation. +func (m *VersionMutation) Denied() (r bool, exists bool) { + v := m.denied + if v == nil { + return + } + return *v, true +} + +// OldDenied returns the old "denied" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldDenied(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDenied is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDenied requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDenied: %w", err) + } + return oldValue.Denied, nil +} + +// ResetDenied resets all changes to the "denied" field. +func (m *VersionMutation) ResetDenied() { + m.denied = nil +} + +// SetMetadata sets the "metadata" field. +func (m *VersionMutation) SetMetadata(s string) { + m.metadata = &s +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *VersionMutation) Metadata() (r string, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldMetadata(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *VersionMutation) ResetMetadata() { + m.metadata = nil +} + +// SetModReference sets the "mod_reference" field. +func (m *VersionMutation) SetModReference(s string) { + m.mod_reference = &s +} + +// ModReference returns the value of the "mod_reference" field in the mutation. +func (m *VersionMutation) ModReference() (r string, exists bool) { + v := m.mod_reference + if v == nil { + return + } + return *v, true +} + +// OldModReference returns the old "mod_reference" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldModReference(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModReference is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModReference requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModReference: %w", err) + } + return oldValue.ModReference, nil +} + +// ResetModReference resets all changes to the "mod_reference" field. +func (m *VersionMutation) ResetModReference() { + m.mod_reference = nil +} + +// SetVersionMajor sets the "version_major" field. +func (m *VersionMutation) SetVersionMajor(i int) { + m.version_major = &i + m.addversion_major = nil +} + +// VersionMajor returns the value of the "version_major" field in the mutation. +func (m *VersionMutation) VersionMajor() (r int, exists bool) { + v := m.version_major + if v == nil { + return + } + return *v, true +} + +// OldVersionMajor returns the old "version_major" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldVersionMajor(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionMajor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionMajor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionMajor: %w", err) + } + return oldValue.VersionMajor, nil +} + +// AddVersionMajor adds i to the "version_major" field. +func (m *VersionMutation) AddVersionMajor(i int) { + if m.addversion_major != nil { + *m.addversion_major += i + } else { + m.addversion_major = &i + } +} + +// AddedVersionMajor returns the value that was added to the "version_major" field in this mutation. +func (m *VersionMutation) AddedVersionMajor() (r int, exists bool) { + v := m.addversion_major + if v == nil { + return + } + return *v, true +} + +// ResetVersionMajor resets all changes to the "version_major" field. +func (m *VersionMutation) ResetVersionMajor() { + m.version_major = nil + m.addversion_major = nil +} + +// SetVersionMinor sets the "version_minor" field. +func (m *VersionMutation) SetVersionMinor(i int) { + m.version_minor = &i + m.addversion_minor = nil +} + +// VersionMinor returns the value of the "version_minor" field in the mutation. +func (m *VersionMutation) VersionMinor() (r int, exists bool) { + v := m.version_minor + if v == nil { + return + } + return *v, true +} + +// OldVersionMinor returns the old "version_minor" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldVersionMinor(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionMinor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionMinor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionMinor: %w", err) + } + return oldValue.VersionMinor, nil +} + +// AddVersionMinor adds i to the "version_minor" field. +func (m *VersionMutation) AddVersionMinor(i int) { + if m.addversion_minor != nil { + *m.addversion_minor += i + } else { + m.addversion_minor = &i + } +} + +// AddedVersionMinor returns the value that was added to the "version_minor" field in this mutation. +func (m *VersionMutation) AddedVersionMinor() (r int, exists bool) { + v := m.addversion_minor + if v == nil { + return + } + return *v, true +} + +// ResetVersionMinor resets all changes to the "version_minor" field. +func (m *VersionMutation) ResetVersionMinor() { + m.version_minor = nil + m.addversion_minor = nil +} + +// SetVersionPatch sets the "version_patch" field. +func (m *VersionMutation) SetVersionPatch(i int) { + m.version_patch = &i + m.addversion_patch = nil +} + +// VersionPatch returns the value of the "version_patch" field in the mutation. +func (m *VersionMutation) VersionPatch() (r int, exists bool) { + v := m.version_patch + if v == nil { + return + } + return *v, true +} + +// OldVersionPatch returns the old "version_patch" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldVersionPatch(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionPatch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionPatch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionPatch: %w", err) + } + return oldValue.VersionPatch, nil +} + +// AddVersionPatch adds i to the "version_patch" field. +func (m *VersionMutation) AddVersionPatch(i int) { + if m.addversion_patch != nil { + *m.addversion_patch += i + } else { + m.addversion_patch = &i + } +} + +// AddedVersionPatch returns the value that was added to the "version_patch" field in this mutation. +func (m *VersionMutation) AddedVersionPatch() (r int, exists bool) { + v := m.addversion_patch + if v == nil { + return + } + return *v, true +} + +// ResetVersionPatch resets all changes to the "version_patch" field. +func (m *VersionMutation) ResetVersionPatch() { + m.version_patch = nil + m.addversion_patch = nil +} + +// SetSize sets the "size" field. +func (m *VersionMutation) SetSize(i int64) { + m.size = &i + m.addsize = nil +} + +// Size returns the value of the "size" field in the mutation. +func (m *VersionMutation) Size() (r int64, exists bool) { + v := m.size + if v == nil { + return + } + return *v, true +} + +// OldSize returns the old "size" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldSize(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSize: %w", err) + } + return oldValue.Size, nil +} + +// AddSize adds i to the "size" field. +func (m *VersionMutation) AddSize(i int64) { + if m.addsize != nil { + *m.addsize += i + } else { + m.addsize = &i + } +} + +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *VersionMutation) AddedSize() (r int64, exists bool) { + v := m.addsize + if v == nil { + return + } + return *v, true +} + +// ResetSize resets all changes to the "size" field. +func (m *VersionMutation) ResetSize() { + m.size = nil + m.addsize = nil +} + +// SetHash sets the "hash" field. +func (m *VersionMutation) SetHash(s string) { + m.hash = &s +} + +// Hash returns the value of the "hash" field in the mutation. +func (m *VersionMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true +} + +// OldHash returns the old "hash" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil +} + +// ResetHash resets all changes to the "hash" field. +func (m *VersionMutation) ResetHash() { + m.hash = nil +} + +// SetModID sets the "mod" edge to the Mod entity by id. +func (m *VersionMutation) SetModID(id string) { + m.mod = &id +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (m *VersionMutation) ClearMod() { + m.clearedmod = true +} + +// ModCleared reports if the "mod" edge to the Mod entity was cleared. +func (m *VersionMutation) ModCleared() bool { + return m.clearedmod +} + +// ModID returns the "mod" edge ID in the mutation. +func (m *VersionMutation) ModID() (id string, exists bool) { + if m.mod != nil { + return *m.mod, true + } + return +} + +// 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 *VersionMutation) ModIDs() (ids []string) { + if id := m.mod; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMod resets all changes to the "mod" edge. +func (m *VersionMutation) ResetMod() { + m.mod = nil + m.clearedmod = false +} + +// AddDependencyIDs adds the "dependencies" edge to the Mod entity by ids. +func (m *VersionMutation) AddDependencyIDs(ids ...string) { + if m.dependencies == nil { + m.dependencies = make(map[string]struct{}) + } + for i := range ids { + m.dependencies[ids[i]] = struct{}{} + } +} + +// ClearDependencies clears the "dependencies" edge to the Mod entity. +func (m *VersionMutation) ClearDependencies() { + m.cleareddependencies = true +} + +// DependenciesCleared reports if the "dependencies" edge to the Mod entity was cleared. +func (m *VersionMutation) DependenciesCleared() bool { + return m.cleareddependencies +} + +// RemoveDependencyIDs removes the "dependencies" edge to the Mod entity by IDs. +func (m *VersionMutation) RemoveDependencyIDs(ids ...string) { + if m.removeddependencies == nil { + m.removeddependencies = make(map[string]struct{}) + } + for i := range ids { + delete(m.dependencies, ids[i]) + m.removeddependencies[ids[i]] = struct{}{} + } +} + +// RemovedDependencies returns the removed IDs of the "dependencies" edge to the Mod entity. +func (m *VersionMutation) RemovedDependenciesIDs() (ids []string) { + for id := range m.removeddependencies { + ids = append(ids, id) + } + return +} + +// DependenciesIDs returns the "dependencies" edge IDs in the mutation. +func (m *VersionMutation) DependenciesIDs() (ids []string) { + for id := range m.dependencies { + ids = append(ids, id) + } + return +} + +// ResetDependencies resets all changes to the "dependencies" edge. +func (m *VersionMutation) ResetDependencies() { + m.dependencies = nil + m.cleareddependencies = false + m.removeddependencies = nil +} + +// Where appends a list predicates to the VersionMutation builder. +func (m *VersionMutation) Where(ps ...predicate.Version) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the VersionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *VersionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Version, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *VersionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *VersionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Version). +func (m *VersionMutation) 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 *VersionMutation) Fields() []string { + fields := make([]string, 0, 19) + if m.created_at != nil { + fields = append(fields, version.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, version.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, version.FieldDeletedAt) + } + if m.version != nil { + fields = append(fields, version.FieldVersion) + } + if m.sml_version != nil { + fields = append(fields, version.FieldSmlVersion) + } + if m.changelog != nil { + fields = append(fields, version.FieldChangelog) + } + if m.downloads != nil { + fields = append(fields, version.FieldDownloads) + } + if m.key != nil { + fields = append(fields, version.FieldKey) + } + if m.stability != nil { + fields = append(fields, version.FieldStability) + } + if m.approved != nil { + fields = append(fields, version.FieldApproved) + } + if m.hotness != nil { + fields = append(fields, version.FieldHotness) + } + if m.denied != nil { + fields = append(fields, version.FieldDenied) + } + if m.metadata != nil { + fields = append(fields, version.FieldMetadata) + } + if m.mod_reference != nil { + fields = append(fields, version.FieldModReference) + } + if m.version_major != nil { + fields = append(fields, version.FieldVersionMajor) + } + if m.version_minor != nil { + fields = append(fields, version.FieldVersionMinor) + } + if m.version_patch != nil { + fields = append(fields, version.FieldVersionPatch) + } + if m.size != nil { + fields = append(fields, version.FieldSize) + } + if m.hash != nil { + fields = append(fields, version.FieldHash) + } + 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 *VersionMutation) Field(name string) (ent.Value, bool) { + switch name { + case version.FieldCreatedAt: + return m.CreatedAt() + case version.FieldUpdatedAt: + return m.UpdatedAt() + case version.FieldDeletedAt: + return m.DeletedAt() + case version.FieldVersion: + return m.Version() + case version.FieldSmlVersion: + return m.SmlVersion() + case version.FieldChangelog: + return m.Changelog() + case version.FieldDownloads: + return m.Downloads() + case version.FieldKey: + return m.Key() + case version.FieldStability: + return m.Stability() + case version.FieldApproved: + return m.Approved() + case version.FieldHotness: + return m.Hotness() + case version.FieldDenied: + return m.Denied() + case version.FieldMetadata: + return m.Metadata() + case version.FieldModReference: + return m.ModReference() + case version.FieldVersionMajor: + return m.VersionMajor() + case version.FieldVersionMinor: + return m.VersionMinor() + case version.FieldVersionPatch: + return m.VersionPatch() + case version.FieldSize: + return m.Size() + case version.FieldHash: + return m.Hash() + } + 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 *VersionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case version.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case version.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case version.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case version.FieldVersion: + return m.OldVersion(ctx) + case version.FieldSmlVersion: + return m.OldSmlVersion(ctx) + case version.FieldChangelog: + return m.OldChangelog(ctx) + case version.FieldDownloads: + return m.OldDownloads(ctx) + case version.FieldKey: + return m.OldKey(ctx) + case version.FieldStability: + return m.OldStability(ctx) + case version.FieldApproved: + return m.OldApproved(ctx) + case version.FieldHotness: + return m.OldHotness(ctx) + case version.FieldDenied: + return m.OldDenied(ctx) + case version.FieldMetadata: + return m.OldMetadata(ctx) + case version.FieldModReference: + return m.OldModReference(ctx) + case version.FieldVersionMajor: + return m.OldVersionMajor(ctx) + case version.FieldVersionMinor: + return m.OldVersionMinor(ctx) + case version.FieldVersionPatch: + return m.OldVersionPatch(ctx) + case version.FieldSize: + return m.OldSize(ctx) + case version.FieldHash: + return m.OldHash(ctx) + } + return nil, fmt.Errorf("unknown Version 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 *VersionMutation) SetField(name string, value ent.Value) error { + switch name { + case version.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 version.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 version.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case version.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case version.FieldSmlVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSmlVersion(v) + return nil + case version.FieldChangelog: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChangelog(v) + return nil + case version.FieldDownloads: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDownloads(v) + return nil + case version.FieldKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKey(v) + return nil + case version.FieldStability: + v, ok := value.(version.Stability) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStability(v) + return nil + case version.FieldApproved: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetApproved(v) + return nil + case version.FieldHotness: + v, ok := value.(uint) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHotness(v) + return nil + case version.FieldDenied: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDenied(v) + return nil + case version.FieldMetadata: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case version.FieldModReference: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModReference(v) + return nil + case version.FieldVersionMajor: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionMajor(v) + return nil + case version.FieldVersionMinor: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionMinor(v) + return nil + case version.FieldVersionPatch: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionPatch(v) + return nil + case version.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + case version.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + } + return fmt.Errorf("unknown Version field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *VersionMutation) AddedFields() []string { + var fields []string + if m.adddownloads != nil { + fields = append(fields, version.FieldDownloads) + } + if m.addhotness != nil { + fields = append(fields, version.FieldHotness) + } + if m.addversion_major != nil { + fields = append(fields, version.FieldVersionMajor) + } + if m.addversion_minor != nil { + fields = append(fields, version.FieldVersionMinor) + } + if m.addversion_patch != nil { + fields = append(fields, version.FieldVersionPatch) + } + if m.addsize != nil { + fields = append(fields, version.FieldSize) + } + 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 *VersionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case version.FieldDownloads: + return m.AddedDownloads() + case version.FieldHotness: + return m.AddedHotness() + case version.FieldVersionMajor: + return m.AddedVersionMajor() + case version.FieldVersionMinor: + return m.AddedVersionMinor() + case version.FieldVersionPatch: + return m.AddedVersionPatch() + case version.FieldSize: + return m.AddedSize() + } + 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 *VersionMutation) AddField(name string, value ent.Value) error { + switch name { + case version.FieldDownloads: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDownloads(v) + return nil + case version.FieldHotness: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddHotness(v) + return nil + case version.FieldVersionMajor: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVersionMajor(v) + return nil + case version.FieldVersionMinor: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVersionMinor(v) + return nil + case version.FieldVersionPatch: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVersionPatch(v) + return nil + case version.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSize(v) + return nil + } + return fmt.Errorf("unknown Version numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *VersionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(version.FieldDeletedAt) { + fields = append(fields, version.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *VersionMutation) 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 *VersionMutation) ClearField(name string) error { + switch name { + case version.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown Version 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 *VersionMutation) ResetField(name string) error { + switch name { + case version.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case version.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case version.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case version.FieldVersion: + m.ResetVersion() + return nil + case version.FieldSmlVersion: + m.ResetSmlVersion() + return nil + case version.FieldChangelog: + m.ResetChangelog() + return nil + case version.FieldDownloads: + m.ResetDownloads() + return nil + case version.FieldKey: + m.ResetKey() + return nil + case version.FieldStability: + m.ResetStability() + return nil + case version.FieldApproved: + m.ResetApproved() + return nil + case version.FieldHotness: + m.ResetHotness() + return nil + case version.FieldDenied: + m.ResetDenied() + return nil + case version.FieldMetadata: + m.ResetMetadata() + return nil + case version.FieldModReference: + m.ResetModReference() + return nil + case version.FieldVersionMajor: + m.ResetVersionMajor() + return nil + case version.FieldVersionMinor: + m.ResetVersionMinor() + return nil + case version.FieldVersionPatch: + m.ResetVersionPatch() + return nil + case version.FieldSize: + m.ResetSize() + return nil + case version.FieldHash: + m.ResetHash() + return nil + } + return fmt.Errorf("unknown Version field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *VersionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.mod != nil { + edges = append(edges, version.EdgeMod) + } + if m.dependencies != nil { + edges = append(edges, version.EdgeDependencies) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *VersionMutation) AddedIDs(name string) []ent.Value { + switch name { + case version.EdgeMod: + if id := m.mod; id != nil { + return []ent.Value{*id} + } + case version.EdgeDependencies: + ids := make([]ent.Value, 0, len(m.dependencies)) + for id := range m.dependencies { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *VersionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removeddependencies != nil { + edges = append(edges, version.EdgeDependencies) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *VersionMutation) RemovedIDs(name string) []ent.Value { + switch name { + case version.EdgeDependencies: + ids := make([]ent.Value, 0, len(m.removeddependencies)) + for id := range m.removeddependencies { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *VersionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmod { + edges = append(edges, version.EdgeMod) + } + if m.cleareddependencies { + edges = append(edges, version.EdgeDependencies) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *VersionMutation) EdgeCleared(name string) bool { + switch name { + case version.EdgeMod: + return m.clearedmod + case version.EdgeDependencies: + return m.cleareddependencies + } + 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 *VersionMutation) ClearEdge(name string) error { + switch name { + case version.EdgeMod: + m.ClearMod() + return nil + } + return fmt.Errorf("unknown Version 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 *VersionMutation) ResetEdge(name string) error { + switch name { + case version.EdgeMod: + m.ResetMod() + return nil + case version.EdgeDependencies: + m.ResetDependencies() + return nil + } + return fmt.Errorf("unknown Version edge %s", name) +} + +// VersionDependencyMutation represents an operation that mutates the VersionDependency nodes in the graph. +type VersionDependencyMutation struct { + config + op Op + typ string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + condition *string + optional *bool + clearedFields map[string]struct{} + version *string + clearedversion bool + mod *string + clearedmod bool + done bool + oldValue func(context.Context) (*VersionDependency, error) + predicates []predicate.VersionDependency +} + +var _ ent.Mutation = (*VersionDependencyMutation)(nil) + +// versiondependencyOption allows management of the mutation configuration using functional options. +type versiondependencyOption func(*VersionDependencyMutation) + +// newVersionDependencyMutation creates new mutation for the VersionDependency entity. +func newVersionDependencyMutation(c config, op Op, opts ...versiondependencyOption) *VersionDependencyMutation { + m := &VersionDependencyMutation{ + config: c, + op: op, + typ: TypeVersionDependency, + 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 VersionDependencyMutation) 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 VersionDependencyMutation) 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 +} + +// SetCreatedAt sets the "created_at" field. +func (m *VersionDependencyMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *VersionDependencyMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *VersionDependencyMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *VersionDependencyMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *VersionDependencyMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *VersionDependencyMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *VersionDependencyMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *VersionDependencyMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *VersionDependencyMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[versiondependency.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *VersionDependencyMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[versiondependency.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *VersionDependencyMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, versiondependency.FieldDeletedAt) +} + +// SetVersionID sets the "version_id" field. +func (m *VersionDependencyMutation) SetVersionID(s string) { + m.version = &s +} + +// VersionID returns the value of the "version_id" field in the mutation. +func (m *VersionDependencyMutation) VersionID() (r string, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// ResetVersionID resets all changes to the "version_id" field. +func (m *VersionDependencyMutation) ResetVersionID() { + m.version = nil +} + +// SetModID sets the "mod_id" field. +func (m *VersionDependencyMutation) SetModID(s string) { + m.mod = &s +} + +// ModID returns the value of the "mod_id" field in the mutation. +func (m *VersionDependencyMutation) 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 *VersionDependencyMutation) ResetModID() { + m.mod = nil +} + +// SetCondition sets the "condition" field. +func (m *VersionDependencyMutation) SetCondition(s string) { + m.condition = &s +} + +// Condition returns the value of the "condition" field in the mutation. +func (m *VersionDependencyMutation) Condition() (r string, exists bool) { + v := m.condition + if v == nil { + return + } + return *v, true +} + +// ResetCondition resets all changes to the "condition" field. +func (m *VersionDependencyMutation) ResetCondition() { + m.condition = nil +} + +// SetOptional sets the "optional" field. +func (m *VersionDependencyMutation) SetOptional(b bool) { + m.optional = &b +} + +// Optional returns the value of the "optional" field in the mutation. +func (m *VersionDependencyMutation) Optional() (r bool, exists bool) { + v := m.optional + if v == nil { + return + } + return *v, true +} + +// ResetOptional resets all changes to the "optional" field. +func (m *VersionDependencyMutation) ResetOptional() { + m.optional = nil +} + +// ClearVersion clears the "version" edge to the Version entity. +func (m *VersionDependencyMutation) ClearVersion() { + m.clearedversion = true + m.clearedFields[versiondependency.FieldVersionID] = struct{}{} +} + +// VersionCleared reports if the "version" edge to the Version entity was cleared. +func (m *VersionDependencyMutation) VersionCleared() bool { + return m.clearedversion +} + +// VersionIDs returns the "version" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// VersionID instead. It exists only for internal usage by the builders. +func (m *VersionDependencyMutation) VersionIDs() (ids []string) { + if id := m.version; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetVersion resets all changes to the "version" edge. +func (m *VersionDependencyMutation) ResetVersion() { + m.version = nil + m.clearedversion = false +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (m *VersionDependencyMutation) ClearMod() { + m.clearedmod = true + m.clearedFields[versiondependency.FieldModID] = struct{}{} +} + +// ModCleared reports if the "mod" edge to the Mod entity was cleared. +func (m *VersionDependencyMutation) 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 *VersionDependencyMutation) ModIDs() (ids []string) { + if id := m.mod; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetMod resets all changes to the "mod" edge. +func (m *VersionDependencyMutation) ResetMod() { + m.mod = nil + m.clearedmod = false +} + +// Where appends a list predicates to the VersionDependencyMutation builder. +func (m *VersionDependencyMutation) Where(ps ...predicate.VersionDependency) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the VersionDependencyMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *VersionDependencyMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.VersionDependency, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *VersionDependencyMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *VersionDependencyMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (VersionDependency). +func (m *VersionDependencyMutation) 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 *VersionDependencyMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.created_at != nil { + fields = append(fields, versiondependency.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, versiondependency.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, versiondependency.FieldDeletedAt) + } + if m.version != nil { + fields = append(fields, versiondependency.FieldVersionID) + } + if m.mod != nil { + fields = append(fields, versiondependency.FieldModID) + } + if m.condition != nil { + fields = append(fields, versiondependency.FieldCondition) + } + if m.optional != nil { + fields = append(fields, versiondependency.FieldOptional) + } + 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 *VersionDependencyMutation) Field(name string) (ent.Value, bool) { + switch name { + case versiondependency.FieldCreatedAt: + return m.CreatedAt() + case versiondependency.FieldUpdatedAt: + return m.UpdatedAt() + case versiondependency.FieldDeletedAt: + return m.DeletedAt() + case versiondependency.FieldVersionID: + return m.VersionID() + case versiondependency.FieldModID: + return m.ModID() + case versiondependency.FieldCondition: + return m.Condition() + case versiondependency.FieldOptional: + return m.Optional() + } + 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 *VersionDependencyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, errors.New("edge schema VersionDependency 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 *VersionDependencyMutation) SetField(name string, value ent.Value) error { + switch name { + case versiondependency.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 versiondependency.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 versiondependency.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case versiondependency.FieldVersionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionID(v) + return nil + case versiondependency.FieldModID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModID(v) + return nil + case versiondependency.FieldCondition: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCondition(v) + return nil + case versiondependency.FieldOptional: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOptional(v) + return nil + } + return fmt.Errorf("unknown VersionDependency field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *VersionDependencyMutation) 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 *VersionDependencyMutation) 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 *VersionDependencyMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown VersionDependency numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *VersionDependencyMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(versiondependency.FieldDeletedAt) { + fields = append(fields, versiondependency.FieldDeletedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *VersionDependencyMutation) 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 *VersionDependencyMutation) ClearField(name string) error { + switch name { + case versiondependency.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown VersionDependency 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 *VersionDependencyMutation) ResetField(name string) error { + switch name { + case versiondependency.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case versiondependency.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case versiondependency.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case versiondependency.FieldVersionID: + m.ResetVersionID() + return nil + case versiondependency.FieldModID: + m.ResetModID() + return nil + case versiondependency.FieldCondition: + m.ResetCondition() + return nil + case versiondependency.FieldOptional: + m.ResetOptional() + return nil + } + return fmt.Errorf("unknown VersionDependency field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *VersionDependencyMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.version != nil { + edges = append(edges, versiondependency.EdgeVersion) + } + if m.mod != nil { + edges = append(edges, versiondependency.EdgeMod) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *VersionDependencyMutation) AddedIDs(name string) []ent.Value { + switch name { + case versiondependency.EdgeVersion: + if id := m.version; id != nil { + return []ent.Value{*id} + } + case versiondependency.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 *VersionDependencyMutation) 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 *VersionDependencyMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *VersionDependencyMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedversion { + edges = append(edges, versiondependency.EdgeVersion) + } + if m.clearedmod { + edges = append(edges, versiondependency.EdgeMod) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *VersionDependencyMutation) EdgeCleared(name string) bool { + switch name { + case versiondependency.EdgeVersion: + return m.clearedversion + case versiondependency.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 *VersionDependencyMutation) ClearEdge(name string) error { + switch name { + case versiondependency.EdgeVersion: + m.ClearVersion() + return nil + case versiondependency.EdgeMod: + m.ClearMod() + return nil + } + return fmt.Errorf("unknown VersionDependency 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 *VersionDependencyMutation) ResetEdge(name string) error { + switch name { + case versiondependency.EdgeVersion: + m.ResetVersion() + return nil + case versiondependency.EdgeMod: + m.ResetMod() + return nil + } + return fmt.Errorf("unknown VersionDependency edge %s", name) +} diff --git a/generated/ent/predicate/predicate.go b/generated/ent/predicate/predicate.go new file mode 100644 index 00000000..e035ad9d --- /dev/null +++ b/generated/ent/predicate/predicate.go @@ -0,0 +1,49 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// Announcement is the predicate function for announcement builders. +type Announcement func(*sql.Selector) + +// Guide is the predicate function for guide builders. +type Guide func(*sql.Selector) + +// GuideTag is the predicate function for guidetag builders. +type GuideTag func(*sql.Selector) + +// Mod is the predicate function for mod builders. +type Mod func(*sql.Selector) + +// ModTag is the predicate function for modtag builders. +type ModTag func(*sql.Selector) + +// SmlVersion is the predicate function for smlversion builders. +type SmlVersion func(*sql.Selector) + +// SmlVersionTarget is the predicate function for smlversiontarget builders. +type SmlVersionTarget func(*sql.Selector) + +// Tag is the predicate function for tag builders. +type Tag func(*sql.Selector) + +// User is the predicate function for user builders. +type User func(*sql.Selector) + +// UserGroup is the predicate function for usergroup builders. +type UserGroup func(*sql.Selector) + +// UserMod is the predicate function for usermod builders. +type UserMod func(*sql.Selector) + +// UserSession is the predicate function for usersession builders. +type UserSession func(*sql.Selector) + +// Version is the predicate function for version builders. +type Version func(*sql.Selector) + +// VersionDependency is the predicate function for versiondependency builders. +type VersionDependency func(*sql.Selector) diff --git a/generated/ent/runtime.go b/generated/ent/runtime.go new file mode 100644 index 00000000..6b26bc5f --- /dev/null +++ b/generated/ent/runtime.go @@ -0,0 +1,5 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +// The schema-stitching logic is generated in github.com/satisfactorymodding/smr-api/generated/ent/runtime/runtime.go diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go new file mode 100644 index 00000000..ab3c3387 --- /dev/null +++ b/generated/ent/runtime/runtime.go @@ -0,0 +1,412 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +import ( + "time" + + "github.com/satisfactorymodding/smr-api/db/schema" + "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/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + announcementMixin := schema.Announcement{}.Mixin() + announcementMixinHooks2 := announcementMixin[2].Hooks() + announcement.Hooks[0] = announcementMixinHooks2[0] + announcementMixinInters2 := announcementMixin[2].Interceptors() + announcement.Interceptors[0] = announcementMixinInters2[0] + announcementMixinFields0 := announcementMixin[0].Fields() + _ = announcementMixinFields0 + announcementMixinFields1 := announcementMixin[1].Fields() + _ = announcementMixinFields1 + announcementFields := schema.Announcement{}.Fields() + _ = announcementFields + // announcementDescCreatedAt is the schema descriptor for created_at field. + announcementDescCreatedAt := announcementMixinFields1[0].Descriptor() + // announcement.DefaultCreatedAt holds the default value on creation for the created_at field. + announcement.DefaultCreatedAt = announcementDescCreatedAt.Default.(func() time.Time) + // announcementDescUpdatedAt is the schema descriptor for updated_at field. + announcementDescUpdatedAt := announcementMixinFields1[1].Descriptor() + // announcement.DefaultUpdatedAt holds the default value on creation for the updated_at field. + announcement.DefaultUpdatedAt = announcementDescUpdatedAt.Default.(func() time.Time) + // announcement.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + announcement.UpdateDefaultUpdatedAt = announcementDescUpdatedAt.UpdateDefault.(func() time.Time) + // announcementDescID is the schema descriptor for id field. + announcementDescID := announcementMixinFields0[0].Descriptor() + // announcement.DefaultID holds the default value on creation for the id field. + announcement.DefaultID = announcementDescID.Default.(func() string) + guideMixin := schema.Guide{}.Mixin() + guideMixinHooks2 := guideMixin[2].Hooks() + guide.Hooks[0] = guideMixinHooks2[0] + guideMixinInters2 := guideMixin[2].Interceptors() + guide.Interceptors[0] = guideMixinInters2[0] + guideMixinFields0 := guideMixin[0].Fields() + _ = guideMixinFields0 + guideMixinFields1 := guideMixin[1].Fields() + _ = guideMixinFields1 + guideFields := schema.Guide{}.Fields() + _ = guideFields + // guideDescCreatedAt is the schema descriptor for created_at field. + guideDescCreatedAt := guideMixinFields1[0].Descriptor() + // guide.DefaultCreatedAt holds the default value on creation for the created_at field. + guide.DefaultCreatedAt = guideDescCreatedAt.Default.(func() time.Time) + // guideDescUpdatedAt is the schema descriptor for updated_at field. + guideDescUpdatedAt := guideMixinFields1[1].Descriptor() + // guide.DefaultUpdatedAt holds the default value on creation for the updated_at field. + guide.DefaultUpdatedAt = guideDescUpdatedAt.Default.(func() time.Time) + // guide.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + guide.UpdateDefaultUpdatedAt = guideDescUpdatedAt.UpdateDefault.(func() time.Time) + // guideDescName is the schema descriptor for name field. + guideDescName := guideFields[0].Descriptor() + // guide.NameValidator is a validator for the "name" field. It is called by the builders before save. + guide.NameValidator = guideDescName.Validators[0].(func(string) error) + // guideDescShortDescription is the schema descriptor for short_description field. + guideDescShortDescription := guideFields[1].Descriptor() + // guide.ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + guide.ShortDescriptionValidator = guideDescShortDescription.Validators[0].(func(string) error) + // guideDescID is the schema descriptor for id field. + guideDescID := guideMixinFields0[0].Descriptor() + // guide.DefaultID holds the default value on creation for the id field. + guide.DefaultID = guideDescID.Default.(func() string) + modMixin := schema.Mod{}.Mixin() + modMixinHooks2 := modMixin[2].Hooks() + mod.Hooks[0] = modMixinHooks2[0] + modMixinInters2 := modMixin[2].Interceptors() + mod.Interceptors[0] = modMixinInters2[0] + modMixinFields0 := modMixin[0].Fields() + _ = modMixinFields0 + modMixinFields1 := modMixin[1].Fields() + _ = modMixinFields1 + modFields := schema.Mod{}.Fields() + _ = modFields + // modDescCreatedAt is the schema descriptor for created_at field. + modDescCreatedAt := modMixinFields1[0].Descriptor() + // mod.DefaultCreatedAt holds the default value on creation for the created_at field. + mod.DefaultCreatedAt = modDescCreatedAt.Default.(func() time.Time) + // modDescUpdatedAt is the schema descriptor for updated_at field. + modDescUpdatedAt := modMixinFields1[1].Descriptor() + // mod.DefaultUpdatedAt holds the default value on creation for the updated_at field. + mod.DefaultUpdatedAt = modDescUpdatedAt.Default.(func() time.Time) + // mod.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + mod.UpdateDefaultUpdatedAt = modDescUpdatedAt.UpdateDefault.(func() time.Time) + // modDescName is the schema descriptor for name field. + modDescName := modFields[0].Descriptor() + // mod.NameValidator is a validator for the "name" field. It is called by the builders before save. + mod.NameValidator = modDescName.Validators[0].(func(string) error) + // modDescShortDescription is the schema descriptor for short_description field. + modDescShortDescription := modFields[1].Descriptor() + // mod.ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. + mod.ShortDescriptionValidator = modDescShortDescription.Validators[0].(func(string) error) + // modDescApproved is the schema descriptor for approved field. + modDescApproved := modFields[6].Descriptor() + // mod.DefaultApproved holds the default value on creation for the approved field. + mod.DefaultApproved = modDescApproved.Default.(bool) + // modDescDenied is the schema descriptor for denied field. + modDescDenied := modFields[11].Descriptor() + // mod.DefaultDenied holds the default value on creation for the denied field. + mod.DefaultDenied = modDescDenied.Default.(bool) + // modDescModReference is the schema descriptor for mod_reference field. + modDescModReference := modFields[13].Descriptor() + // mod.ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. + mod.ModReferenceValidator = modDescModReference.Validators[0].(func(string) error) + // modDescID is the schema descriptor for id field. + modDescID := modMixinFields0[0].Descriptor() + // mod.DefaultID holds the default value on creation for the id field. + mod.DefaultID = modDescID.Default.(func() string) + smlversionMixin := schema.SmlVersion{}.Mixin() + smlversionMixinHooks2 := smlversionMixin[2].Hooks() + smlversion.Hooks[0] = smlversionMixinHooks2[0] + smlversionMixinInters2 := smlversionMixin[2].Interceptors() + smlversion.Interceptors[0] = smlversionMixinInters2[0] + smlversionMixinFields0 := smlversionMixin[0].Fields() + _ = smlversionMixinFields0 + smlversionMixinFields1 := smlversionMixin[1].Fields() + _ = smlversionMixinFields1 + smlversionFields := schema.SmlVersion{}.Fields() + _ = smlversionFields + // smlversionDescCreatedAt is the schema descriptor for created_at field. + smlversionDescCreatedAt := smlversionMixinFields1[0].Descriptor() + // smlversion.DefaultCreatedAt holds the default value on creation for the created_at field. + smlversion.DefaultCreatedAt = smlversionDescCreatedAt.Default.(func() time.Time) + // smlversionDescUpdatedAt is the schema descriptor for updated_at field. + smlversionDescUpdatedAt := smlversionMixinFields1[1].Descriptor() + // smlversion.DefaultUpdatedAt holds the default value on creation for the updated_at field. + smlversion.DefaultUpdatedAt = smlversionDescUpdatedAt.Default.(func() time.Time) + // smlversion.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + smlversion.UpdateDefaultUpdatedAt = smlversionDescUpdatedAt.UpdateDefault.(func() time.Time) + // smlversionDescVersion is the schema descriptor for version field. + smlversionDescVersion := smlversionFields[0].Descriptor() + // smlversion.VersionValidator is a validator for the "version" field. It is called by the builders before save. + smlversion.VersionValidator = smlversionDescVersion.Validators[0].(func(string) error) + // smlversionDescBootstrapVersion is the schema descriptor for bootstrap_version field. + smlversionDescBootstrapVersion := smlversionFields[6].Descriptor() + // smlversion.BootstrapVersionValidator is a validator for the "bootstrap_version" field. It is called by the builders before save. + smlversion.BootstrapVersionValidator = smlversionDescBootstrapVersion.Validators[0].(func(string) error) + // smlversionDescEngineVersion is the schema descriptor for engine_version field. + smlversionDescEngineVersion := smlversionFields[7].Descriptor() + // smlversion.DefaultEngineVersion holds the default value on creation for the engine_version field. + smlversion.DefaultEngineVersion = smlversionDescEngineVersion.Default.(string) + // smlversion.EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save. + smlversion.EngineVersionValidator = smlversionDescEngineVersion.Validators[0].(func(string) error) + // smlversionDescID is the schema descriptor for id field. + smlversionDescID := smlversionMixinFields0[0].Descriptor() + // smlversion.DefaultID holds the default value on creation for the id field. + smlversion.DefaultID = smlversionDescID.Default.(func() string) + smlversiontargetMixin := schema.SmlVersionTarget{}.Mixin() + smlversiontargetMixinFields0 := smlversiontargetMixin[0].Fields() + _ = smlversiontargetMixinFields0 + smlversiontargetFields := schema.SmlVersionTarget{}.Fields() + _ = smlversiontargetFields + // smlversiontargetDescID is the schema descriptor for id field. + smlversiontargetDescID := smlversiontargetMixinFields0[0].Descriptor() + // smlversiontarget.DefaultID holds the default value on creation for the id field. + smlversiontarget.DefaultID = smlversiontargetDescID.Default.(func() string) + tagMixin := schema.Tag{}.Mixin() + tagMixinHooks2 := tagMixin[2].Hooks() + tag.Hooks[0] = tagMixinHooks2[0] + tagMixinInters2 := tagMixin[2].Interceptors() + tag.Interceptors[0] = tagMixinInters2[0] + tagMixinFields0 := tagMixin[0].Fields() + _ = tagMixinFields0 + tagMixinFields1 := tagMixin[1].Fields() + _ = tagMixinFields1 + tagFields := schema.Tag{}.Fields() + _ = tagFields + // tagDescCreatedAt is the schema descriptor for created_at field. + tagDescCreatedAt := tagMixinFields1[0].Descriptor() + // tag.DefaultCreatedAt holds the default value on creation for the created_at field. + tag.DefaultCreatedAt = tagDescCreatedAt.Default.(func() time.Time) + // tagDescUpdatedAt is the schema descriptor for updated_at field. + tagDescUpdatedAt := tagMixinFields1[1].Descriptor() + // tag.DefaultUpdatedAt holds the default value on creation for the updated_at field. + tag.DefaultUpdatedAt = tagDescUpdatedAt.Default.(func() time.Time) + // tag.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + tag.UpdateDefaultUpdatedAt = tagDescUpdatedAt.UpdateDefault.(func() time.Time) + // tagDescName is the schema descriptor for name field. + tagDescName := tagFields[0].Descriptor() + // tag.NameValidator is a validator for the "name" field. It is called by the builders before save. + tag.NameValidator = tagDescName.Validators[0].(func(string) error) + // tagDescID is the schema descriptor for id field. + tagDescID := tagMixinFields0[0].Descriptor() + // tag.DefaultID holds the default value on creation for the id field. + tag.DefaultID = tagDescID.Default.(func() string) + userMixin := schema.User{}.Mixin() + userMixinHooks2 := userMixin[2].Hooks() + user.Hooks[0] = userMixinHooks2[0] + userMixinInters2 := userMixin[2].Interceptors() + user.Interceptors[0] = userMixinInters2[0] + userMixinFields0 := userMixin[0].Fields() + _ = userMixinFields0 + userMixinFields1 := userMixin[1].Fields() + _ = userMixinFields1 + userFields := schema.User{}.Fields() + _ = userFields + // userDescCreatedAt is the schema descriptor for created_at field. + userDescCreatedAt := userMixinFields1[0].Descriptor() + // user.DefaultCreatedAt holds the default value on creation for the created_at field. + user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time) + // userDescUpdatedAt is the schema descriptor for updated_at field. + userDescUpdatedAt := userMixinFields1[1].Descriptor() + // user.DefaultUpdatedAt holds the default value on creation for the updated_at field. + user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time) + // user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + user.UpdateDefaultUpdatedAt = userDescUpdatedAt.UpdateDefault.(func() time.Time) + // userDescEmail is the schema descriptor for email field. + userDescEmail := userFields[0].Descriptor() + // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. + user.EmailValidator = userDescEmail.Validators[0].(func(string) error) + // userDescUsername is the schema descriptor for username field. + userDescUsername := userFields[1].Descriptor() + // user.UsernameValidator is a validator for the "username" field. It is called by the builders before save. + user.UsernameValidator = userDescUsername.Validators[0].(func(string) error) + // userDescBanned is the schema descriptor for banned field. + userDescBanned := userFields[4].Descriptor() + // user.DefaultBanned holds the default value on creation for the banned field. + user.DefaultBanned = userDescBanned.Default.(bool) + // userDescRank is the schema descriptor for rank field. + userDescRank := userFields[5].Descriptor() + // user.DefaultRank holds the default value on creation for the rank field. + user.DefaultRank = userDescRank.Default.(int) + // userDescGithubID is the schema descriptor for github_id field. + userDescGithubID := userFields[6].Descriptor() + // user.GithubIDValidator is a validator for the "github_id" field. It is called by the builders before save. + user.GithubIDValidator = userDescGithubID.Validators[0].(func(string) error) + // userDescGoogleID is the schema descriptor for google_id field. + userDescGoogleID := userFields[7].Descriptor() + // user.GoogleIDValidator is a validator for the "google_id" field. It is called by the builders before save. + user.GoogleIDValidator = userDescGoogleID.Validators[0].(func(string) error) + // userDescFacebookID is the schema descriptor for facebook_id field. + userDescFacebookID := userFields[8].Descriptor() + // user.FacebookIDValidator is a validator for the "facebook_id" field. It is called by the builders before save. + user.FacebookIDValidator = userDescFacebookID.Validators[0].(func(string) error) + // userDescID is the schema descriptor for id field. + userDescID := userMixinFields0[0].Descriptor() + // user.DefaultID holds the default value on creation for the id field. + user.DefaultID = userDescID.Default.(func() string) + usergroupMixin := schema.UserGroup{}.Mixin() + usergroupMixinHooks2 := usergroupMixin[2].Hooks() + usergroup.Hooks[0] = usergroupMixinHooks2[0] + usergroupMixinInters2 := usergroupMixin[2].Interceptors() + usergroup.Interceptors[0] = usergroupMixinInters2[0] + usergroupMixinFields0 := usergroupMixin[0].Fields() + _ = usergroupMixinFields0 + usergroupMixinFields1 := usergroupMixin[1].Fields() + _ = usergroupMixinFields1 + usergroupFields := schema.UserGroup{}.Fields() + _ = usergroupFields + // usergroupDescCreatedAt is the schema descriptor for created_at field. + usergroupDescCreatedAt := usergroupMixinFields1[0].Descriptor() + // usergroup.DefaultCreatedAt holds the default value on creation for the created_at field. + usergroup.DefaultCreatedAt = usergroupDescCreatedAt.Default.(func() time.Time) + // usergroupDescUpdatedAt is the schema descriptor for updated_at field. + usergroupDescUpdatedAt := usergroupMixinFields1[1].Descriptor() + // usergroup.DefaultUpdatedAt holds the default value on creation for the updated_at field. + usergroup.DefaultUpdatedAt = usergroupDescUpdatedAt.Default.(func() time.Time) + // usergroup.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + usergroup.UpdateDefaultUpdatedAt = usergroupDescUpdatedAt.UpdateDefault.(func() time.Time) + // usergroupDescUserID is the schema descriptor for user_id field. + usergroupDescUserID := usergroupFields[0].Descriptor() + // usergroup.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + usergroup.UserIDValidator = usergroupDescUserID.Validators[0].(func(string) error) + // usergroupDescGroupID is the schema descriptor for group_id field. + usergroupDescGroupID := usergroupFields[1].Descriptor() + // usergroup.GroupIDValidator is a validator for the "group_id" field. It is called by the builders before save. + usergroup.GroupIDValidator = usergroupDescGroupID.Validators[0].(func(string) error) + // usergroupDescID is the schema descriptor for id field. + usergroupDescID := usergroupMixinFields0[0].Descriptor() + // usergroup.DefaultID holds the default value on creation for the id field. + usergroup.DefaultID = usergroupDescID.Default.(func() string) + usersessionMixin := schema.UserSession{}.Mixin() + usersessionMixinHooks2 := usersessionMixin[2].Hooks() + usersession.Hooks[0] = usersessionMixinHooks2[0] + usersessionMixinInters2 := usersessionMixin[2].Interceptors() + usersession.Interceptors[0] = usersessionMixinInters2[0] + usersessionMixinFields0 := usersessionMixin[0].Fields() + _ = usersessionMixinFields0 + usersessionMixinFields1 := usersessionMixin[1].Fields() + _ = usersessionMixinFields1 + usersessionFields := schema.UserSession{}.Fields() + _ = usersessionFields + // usersessionDescCreatedAt is the schema descriptor for created_at field. + usersessionDescCreatedAt := usersessionMixinFields1[0].Descriptor() + // usersession.DefaultCreatedAt holds the default value on creation for the created_at field. + usersession.DefaultCreatedAt = usersessionDescCreatedAt.Default.(func() time.Time) + // usersessionDescUpdatedAt is the schema descriptor for updated_at field. + usersessionDescUpdatedAt := usersessionMixinFields1[1].Descriptor() + // usersession.DefaultUpdatedAt holds the default value on creation for the updated_at field. + usersession.DefaultUpdatedAt = usersessionDescUpdatedAt.Default.(func() time.Time) + // usersession.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + usersession.UpdateDefaultUpdatedAt = usersessionDescUpdatedAt.UpdateDefault.(func() time.Time) + // usersessionDescToken is the schema descriptor for token field. + usersessionDescToken := usersessionFields[0].Descriptor() + // usersession.TokenValidator is a validator for the "token" field. It is called by the builders before save. + usersession.TokenValidator = usersessionDescToken.Validators[0].(func(string) error) + // usersessionDescID is the schema descriptor for id field. + usersessionDescID := usersessionMixinFields0[0].Descriptor() + // usersession.DefaultID holds the default value on creation for the id field. + usersession.DefaultID = usersessionDescID.Default.(func() string) + versionMixin := schema.Version{}.Mixin() + versionMixinHooks2 := versionMixin[2].Hooks() + version.Hooks[0] = versionMixinHooks2[0] + versionMixinInters2 := versionMixin[2].Interceptors() + version.Interceptors[0] = versionMixinInters2[0] + versionMixinFields0 := versionMixin[0].Fields() + _ = versionMixinFields0 + versionMixinFields1 := versionMixin[1].Fields() + _ = versionMixinFields1 + versionFields := schema.Version{}.Fields() + _ = versionFields + // versionDescCreatedAt is the schema descriptor for created_at field. + versionDescCreatedAt := versionMixinFields1[0].Descriptor() + // version.DefaultCreatedAt holds the default value on creation for the created_at field. + version.DefaultCreatedAt = versionDescCreatedAt.Default.(func() time.Time) + // versionDescUpdatedAt is the schema descriptor for updated_at field. + versionDescUpdatedAt := versionMixinFields1[1].Descriptor() + // version.DefaultUpdatedAt holds the default value on creation for the updated_at field. + version.DefaultUpdatedAt = versionDescUpdatedAt.Default.(func() time.Time) + // version.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + version.UpdateDefaultUpdatedAt = versionDescUpdatedAt.UpdateDefault.(func() time.Time) + // versionDescVersion is the schema descriptor for version field. + versionDescVersion := versionFields[0].Descriptor() + // version.VersionValidator is a validator for the "version" field. It is called by the builders before save. + version.VersionValidator = versionDescVersion.Validators[0].(func(string) error) + // versionDescSmlVersion is the schema descriptor for sml_version field. + versionDescSmlVersion := versionFields[1].Descriptor() + // version.SmlVersionValidator is a validator for the "sml_version" field. It is called by the builders before save. + version.SmlVersionValidator = versionDescSmlVersion.Validators[0].(func(string) error) + // versionDescApproved is the schema descriptor for approved field. + versionDescApproved := versionFields[6].Descriptor() + // version.DefaultApproved holds the default value on creation for the approved field. + version.DefaultApproved = versionDescApproved.Default.(bool) + // versionDescDenied is the schema descriptor for denied field. + versionDescDenied := versionFields[8].Descriptor() + // version.DefaultDenied holds the default value on creation for the denied field. + version.DefaultDenied = versionDescDenied.Default.(bool) + // versionDescModReference is the schema descriptor for mod_reference field. + versionDescModReference := versionFields[10].Descriptor() + // version.ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. + version.ModReferenceValidator = versionDescModReference.Validators[0].(func(string) error) + // versionDescHash is the schema descriptor for hash field. + versionDescHash := versionFields[15].Descriptor() + // version.HashValidator is a validator for the "hash" field. It is called by the builders before save. + version.HashValidator = func() func(string) error { + validators := versionDescHash.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(hash string) error { + for _, fn := range fns { + if err := fn(hash); err != nil { + return err + } + } + return nil + } + }() + // versionDescID is the schema descriptor for id field. + versionDescID := versionMixinFields0[0].Descriptor() + // version.DefaultID holds the default value on creation for the id field. + version.DefaultID = versionDescID.Default.(func() string) + versiondependencyMixin := schema.VersionDependency{}.Mixin() + versiondependencyMixinHooks1 := versiondependencyMixin[1].Hooks() + versiondependency.Hooks[0] = versiondependencyMixinHooks1[0] + versiondependencyMixinInters1 := versiondependencyMixin[1].Interceptors() + versiondependency.Interceptors[0] = versiondependencyMixinInters1[0] + versiondependencyMixinFields0 := versiondependencyMixin[0].Fields() + _ = versiondependencyMixinFields0 + versiondependencyFields := schema.VersionDependency{}.Fields() + _ = versiondependencyFields + // versiondependencyDescCreatedAt is the schema descriptor for created_at field. + versiondependencyDescCreatedAt := versiondependencyMixinFields0[0].Descriptor() + // versiondependency.DefaultCreatedAt holds the default value on creation for the created_at field. + versiondependency.DefaultCreatedAt = versiondependencyDescCreatedAt.Default.(func() time.Time) + // versiondependencyDescUpdatedAt is the schema descriptor for updated_at field. + versiondependencyDescUpdatedAt := versiondependencyMixinFields0[1].Descriptor() + // versiondependency.DefaultUpdatedAt holds the default value on creation for the updated_at field. + versiondependency.DefaultUpdatedAt = versiondependencyDescUpdatedAt.Default.(func() time.Time) + // versiondependency.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + versiondependency.UpdateDefaultUpdatedAt = versiondependencyDescUpdatedAt.UpdateDefault.(func() time.Time) + // versiondependencyDescCondition is the schema descriptor for condition field. + versiondependencyDescCondition := versiondependencyFields[2].Descriptor() + // versiondependency.ConditionValidator is a validator for the "condition" field. It is called by the builders before save. + versiondependency.ConditionValidator = versiondependencyDescCondition.Validators[0].(func(string) error) +} + +const ( + Version = "v0.12.4" // Version of ent codegen. + Sum = "h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8=" // Sum of ent codegen. +) diff --git a/generated/ent/smlversion.go b/generated/ent/smlversion.go new file mode 100644 index 00000000..491125ae --- /dev/null +++ b/generated/ent/smlversion.go @@ -0,0 +1,242 @@ +// 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/smlversion" +) + +// SmlVersion is the model entity for the SmlVersion schema. +type SmlVersion 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // SatisfactoryVersion holds the value of the "satisfactory_version" field. + SatisfactoryVersion int `json:"satisfactory_version,omitempty"` + // Stability holds the value of the "stability" field. + Stability smlversion.Stability `json:"stability,omitempty"` + // Date holds the value of the "date" field. + Date time.Time `json:"date,omitempty"` + // Link holds the value of the "link" field. + Link string `json:"link,omitempty"` + // Changelog holds the value of the "changelog" field. + Changelog string `json:"changelog,omitempty"` + // BootstrapVersion holds the value of the "bootstrap_version" field. + BootstrapVersion string `json:"bootstrap_version,omitempty"` + // EngineVersion holds the value of the "engine_version" field. + EngineVersion string `json:"engine_version,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the SmlVersionQuery when eager-loading is set. + Edges SmlVersionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// SmlVersionEdges holds the relations/edges for other nodes in the graph. +type SmlVersionEdges struct { + // Targets holds the value of the targets edge. + Targets []*SmlVersionTarget `json:"targets,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// TargetsOrErr returns the Targets value or an error if the edge +// was not loaded in eager-loading. +func (e SmlVersionEdges) TargetsOrErr() ([]*SmlVersionTarget, error) { + if e.loadedTypes[0] { + return e.Targets, nil + } + return nil, &NotLoadedError{edge: "targets"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*SmlVersion) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case smlversion.FieldSatisfactoryVersion: + values[i] = new(sql.NullInt64) + case smlversion.FieldID, smlversion.FieldVersion, smlversion.FieldStability, smlversion.FieldLink, smlversion.FieldChangelog, smlversion.FieldBootstrapVersion, smlversion.FieldEngineVersion: + values[i] = new(sql.NullString) + case smlversion.FieldCreatedAt, smlversion.FieldUpdatedAt, smlversion.FieldDeletedAt, smlversion.FieldDate: + 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 SmlVersion fields. +func (sv *SmlVersion) 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 smlversion.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + sv.ID = value.String + } + case smlversion.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 { + sv.CreatedAt = value.Time + } + case smlversion.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 { + sv.UpdatedAt = value.Time + } + case smlversion.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + sv.DeletedAt = value.Time + } + case smlversion.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + sv.Version = value.String + } + case smlversion.FieldSatisfactoryVersion: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field satisfactory_version", values[i]) + } else if value.Valid { + sv.SatisfactoryVersion = int(value.Int64) + } + case smlversion.FieldStability: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field stability", values[i]) + } else if value.Valid { + sv.Stability = smlversion.Stability(value.String) + } + case smlversion.FieldDate: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field date", values[i]) + } else if value.Valid { + sv.Date = value.Time + } + case smlversion.FieldLink: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field link", values[i]) + } else if value.Valid { + sv.Link = value.String + } + case smlversion.FieldChangelog: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field changelog", values[i]) + } else if value.Valid { + sv.Changelog = value.String + } + case smlversion.FieldBootstrapVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bootstrap_version", values[i]) + } else if value.Valid { + sv.BootstrapVersion = value.String + } + case smlversion.FieldEngineVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field engine_version", values[i]) + } else if value.Valid { + sv.EngineVersion = value.String + } + default: + sv.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the SmlVersion. +// This includes values selected through modifiers, order, etc. +func (sv *SmlVersion) Value(name string) (ent.Value, error) { + return sv.selectValues.Get(name) +} + +// QueryTargets queries the "targets" edge of the SmlVersion entity. +func (sv *SmlVersion) QueryTargets() *SmlVersionTargetQuery { + return NewSmlVersionClient(sv.config).QueryTargets(sv) +} + +// Update returns a builder for updating this SmlVersion. +// Note that you need to call SmlVersion.Unwrap() before calling this method if this SmlVersion +// was returned from a transaction, and the transaction was committed or rolled back. +func (sv *SmlVersion) Update() *SmlVersionUpdateOne { + return NewSmlVersionClient(sv.config).UpdateOne(sv) +} + +// Unwrap unwraps the SmlVersion 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 (sv *SmlVersion) Unwrap() *SmlVersion { + _tx, ok := sv.config.driver.(*txDriver) + if !ok { + panic("ent: SmlVersion is not a transactional entity") + } + sv.config.driver = _tx.drv + return sv +} + +// String implements the fmt.Stringer. +func (sv *SmlVersion) String() string { + var builder strings.Builder + builder.WriteString("SmlVersion(") + builder.WriteString(fmt.Sprintf("id=%v, ", sv.ID)) + builder.WriteString("created_at=") + builder.WriteString(sv.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(sv.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(sv.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(sv.Version) + builder.WriteString(", ") + builder.WriteString("satisfactory_version=") + builder.WriteString(fmt.Sprintf("%v", sv.SatisfactoryVersion)) + builder.WriteString(", ") + builder.WriteString("stability=") + builder.WriteString(fmt.Sprintf("%v", sv.Stability)) + builder.WriteString(", ") + builder.WriteString("date=") + builder.WriteString(sv.Date.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("link=") + builder.WriteString(sv.Link) + builder.WriteString(", ") + builder.WriteString("changelog=") + builder.WriteString(sv.Changelog) + builder.WriteString(", ") + builder.WriteString("bootstrap_version=") + builder.WriteString(sv.BootstrapVersion) + builder.WriteString(", ") + builder.WriteString("engine_version=") + builder.WriteString(sv.EngineVersion) + builder.WriteByte(')') + return builder.String() +} + +// SmlVersions is a parsable slice of SmlVersion. +type SmlVersions []*SmlVersion diff --git a/generated/ent/smlversion/smlversion.go b/generated/ent/smlversion/smlversion.go new file mode 100644 index 00000000..9b372040 --- /dev/null +++ b/generated/ent/smlversion/smlversion.go @@ -0,0 +1,212 @@ +// Code generated by ent, DO NOT EDIT. + +package smlversion + +import ( + "fmt" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the smlversion type in the database. + Label = "sml_version" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldSatisfactoryVersion holds the string denoting the satisfactory_version field in the database. + FieldSatisfactoryVersion = "satisfactory_version" + // FieldStability holds the string denoting the stability field in the database. + FieldStability = "stability" + // FieldDate holds the string denoting the date field in the database. + FieldDate = "date" + // FieldLink holds the string denoting the link field in the database. + FieldLink = "link" + // FieldChangelog holds the string denoting the changelog field in the database. + FieldChangelog = "changelog" + // FieldBootstrapVersion holds the string denoting the bootstrap_version field in the database. + FieldBootstrapVersion = "bootstrap_version" + // FieldEngineVersion holds the string denoting the engine_version field in the database. + FieldEngineVersion = "engine_version" + // EdgeTargets holds the string denoting the targets edge name in mutations. + EdgeTargets = "targets" + // Table holds the table name of the smlversion in the database. + Table = "sml_versions" + // TargetsTable is the table that holds the targets relation/edge. + TargetsTable = "sml_version_targets" + // TargetsInverseTable is the table name for the SmlVersionTarget entity. + // It exists in this package in order to avoid circular dependency with the "smlversiontarget" package. + TargetsInverseTable = "sml_version_targets" + // TargetsColumn is the table column denoting the targets relation/edge. + TargetsColumn = "version_id" +) + +// Columns holds all SQL columns for smlversion fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldVersion, + FieldSatisfactoryVersion, + FieldStability, + FieldDate, + FieldLink, + FieldChangelog, + FieldBootstrapVersion, + FieldEngineVersion, +} + +// 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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(string) error + // BootstrapVersionValidator is a validator for the "bootstrap_version" field. It is called by the builders before save. + BootstrapVersionValidator func(string) error + // DefaultEngineVersion holds the default value on creation for the "engine_version" field. + DefaultEngineVersion string + // EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save. + EngineVersionValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// Stability defines the type for the "stability" enum field. +type Stability string + +// Stability values. +const ( + StabilityAlpha Stability = "alpha" + StabilityBeta Stability = "beta" + StabilityRelease Stability = "release" +) + +func (s Stability) String() string { + return string(s) +} + +// StabilityValidator is a validator for the "stability" field enum values. It is called by the builders before save. +func StabilityValidator(s Stability) error { + switch s { + case StabilityAlpha, StabilityBeta, StabilityRelease: + return nil + default: + return fmt.Errorf("smlversion: invalid enum value for stability field: %q", s) + } +} + +// OrderOption defines the ordering options for the SmlVersion 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// BySatisfactoryVersion orders the results by the satisfactory_version field. +func BySatisfactoryVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSatisfactoryVersion, opts...).ToFunc() +} + +// ByStability orders the results by the stability field. +func ByStability(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStability, opts...).ToFunc() +} + +// ByDate orders the results by the date field. +func ByDate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDate, opts...).ToFunc() +} + +// ByLink orders the results by the link field. +func ByLink(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLink, opts...).ToFunc() +} + +// ByChangelog orders the results by the changelog field. +func ByChangelog(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChangelog, opts...).ToFunc() +} + +// ByBootstrapVersion orders the results by the bootstrap_version field. +func ByBootstrapVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBootstrapVersion, opts...).ToFunc() +} + +// ByEngineVersion orders the results by the engine_version field. +func ByEngineVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEngineVersion, opts...).ToFunc() +} + +// 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...)...) + } +} +func newTargetsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TargetsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TargetsTable, TargetsColumn), + ) +} diff --git a/generated/ent/smlversion/where.go b/generated/ent/smlversion/where.go new file mode 100644 index 00000000..df78e319 --- /dev/null +++ b/generated/ent/smlversion/where.go @@ -0,0 +1,719 @@ +// Code generated by ent, DO NOT EDIT. + +package smlversion + +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.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.SmlVersion { + return predicate.SmlVersion(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.SmlVersion { + return predicate.SmlVersion(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.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldVersion, v)) +} + +// SatisfactoryVersion applies equality check predicate on the "satisfactory_version" field. It's identical to SatisfactoryVersionEQ. +func SatisfactoryVersion(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldSatisfactoryVersion, v)) +} + +// Date applies equality check predicate on the "date" field. It's identical to DateEQ. +func Date(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldDate, v)) +} + +// Link applies equality check predicate on the "link" field. It's identical to LinkEQ. +func Link(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldLink, v)) +} + +// Changelog applies equality check predicate on the "changelog" field. It's identical to ChangelogEQ. +func Changelog(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldChangelog, v)) +} + +// BootstrapVersion applies equality check predicate on the "bootstrap_version" field. It's identical to BootstrapVersionEQ. +func BootstrapVersion(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldBootstrapVersion, v)) +} + +// EngineVersion applies equality check predicate on the "engine_version" field. It's identical to EngineVersionEQ. +func EngineVersion(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldEngineVersion, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotNull(FieldDeletedAt)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContainsFold(FieldVersion, v)) +} + +// SatisfactoryVersionEQ applies the EQ predicate on the "satisfactory_version" field. +func SatisfactoryVersionEQ(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldSatisfactoryVersion, v)) +} + +// SatisfactoryVersionNEQ applies the NEQ predicate on the "satisfactory_version" field. +func SatisfactoryVersionNEQ(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldSatisfactoryVersion, v)) +} + +// SatisfactoryVersionIn applies the In predicate on the "satisfactory_version" field. +func SatisfactoryVersionIn(vs ...int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldSatisfactoryVersion, vs...)) +} + +// SatisfactoryVersionNotIn applies the NotIn predicate on the "satisfactory_version" field. +func SatisfactoryVersionNotIn(vs ...int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldSatisfactoryVersion, vs...)) +} + +// SatisfactoryVersionGT applies the GT predicate on the "satisfactory_version" field. +func SatisfactoryVersionGT(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldSatisfactoryVersion, v)) +} + +// SatisfactoryVersionGTE applies the GTE predicate on the "satisfactory_version" field. +func SatisfactoryVersionGTE(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldSatisfactoryVersion, v)) +} + +// SatisfactoryVersionLT applies the LT predicate on the "satisfactory_version" field. +func SatisfactoryVersionLT(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldSatisfactoryVersion, v)) +} + +// SatisfactoryVersionLTE applies the LTE predicate on the "satisfactory_version" field. +func SatisfactoryVersionLTE(v int) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldSatisfactoryVersion, v)) +} + +// StabilityEQ applies the EQ predicate on the "stability" field. +func StabilityEQ(v Stability) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldStability, v)) +} + +// StabilityNEQ applies the NEQ predicate on the "stability" field. +func StabilityNEQ(v Stability) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldStability, v)) +} + +// StabilityIn applies the In predicate on the "stability" field. +func StabilityIn(vs ...Stability) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldStability, vs...)) +} + +// StabilityNotIn applies the NotIn predicate on the "stability" field. +func StabilityNotIn(vs ...Stability) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldStability, vs...)) +} + +// DateEQ applies the EQ predicate on the "date" field. +func DateEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldDate, v)) +} + +// DateNEQ applies the NEQ predicate on the "date" field. +func DateNEQ(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldDate, v)) +} + +// DateIn applies the In predicate on the "date" field. +func DateIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldDate, vs...)) +} + +// DateNotIn applies the NotIn predicate on the "date" field. +func DateNotIn(vs ...time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldDate, vs...)) +} + +// DateGT applies the GT predicate on the "date" field. +func DateGT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldDate, v)) +} + +// DateGTE applies the GTE predicate on the "date" field. +func DateGTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldDate, v)) +} + +// DateLT applies the LT predicate on the "date" field. +func DateLT(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldDate, v)) +} + +// DateLTE applies the LTE predicate on the "date" field. +func DateLTE(v time.Time) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldDate, v)) +} + +// LinkEQ applies the EQ predicate on the "link" field. +func LinkEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldLink, v)) +} + +// LinkNEQ applies the NEQ predicate on the "link" field. +func LinkNEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldLink, v)) +} + +// LinkIn applies the In predicate on the "link" field. +func LinkIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldLink, vs...)) +} + +// LinkNotIn applies the NotIn predicate on the "link" field. +func LinkNotIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldLink, vs...)) +} + +// LinkGT applies the GT predicate on the "link" field. +func LinkGT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldLink, v)) +} + +// LinkGTE applies the GTE predicate on the "link" field. +func LinkGTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldLink, v)) +} + +// LinkLT applies the LT predicate on the "link" field. +func LinkLT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldLink, v)) +} + +// LinkLTE applies the LTE predicate on the "link" field. +func LinkLTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldLink, v)) +} + +// LinkContains applies the Contains predicate on the "link" field. +func LinkContains(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContains(FieldLink, v)) +} + +// LinkHasPrefix applies the HasPrefix predicate on the "link" field. +func LinkHasPrefix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasPrefix(FieldLink, v)) +} + +// LinkHasSuffix applies the HasSuffix predicate on the "link" field. +func LinkHasSuffix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasSuffix(FieldLink, v)) +} + +// LinkEqualFold applies the EqualFold predicate on the "link" field. +func LinkEqualFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldLink, v)) +} + +// LinkContainsFold applies the ContainsFold predicate on the "link" field. +func LinkContainsFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContainsFold(FieldLink, v)) +} + +// ChangelogEQ applies the EQ predicate on the "changelog" field. +func ChangelogEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldChangelog, v)) +} + +// ChangelogNEQ applies the NEQ predicate on the "changelog" field. +func ChangelogNEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldChangelog, v)) +} + +// ChangelogIn applies the In predicate on the "changelog" field. +func ChangelogIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldChangelog, vs...)) +} + +// ChangelogNotIn applies the NotIn predicate on the "changelog" field. +func ChangelogNotIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldChangelog, vs...)) +} + +// ChangelogGT applies the GT predicate on the "changelog" field. +func ChangelogGT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldChangelog, v)) +} + +// ChangelogGTE applies the GTE predicate on the "changelog" field. +func ChangelogGTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldChangelog, v)) +} + +// ChangelogLT applies the LT predicate on the "changelog" field. +func ChangelogLT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldChangelog, v)) +} + +// ChangelogLTE applies the LTE predicate on the "changelog" field. +func ChangelogLTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldChangelog, v)) +} + +// ChangelogContains applies the Contains predicate on the "changelog" field. +func ChangelogContains(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContains(FieldChangelog, v)) +} + +// ChangelogHasPrefix applies the HasPrefix predicate on the "changelog" field. +func ChangelogHasPrefix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasPrefix(FieldChangelog, v)) +} + +// ChangelogHasSuffix applies the HasSuffix predicate on the "changelog" field. +func ChangelogHasSuffix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasSuffix(FieldChangelog, v)) +} + +// ChangelogEqualFold applies the EqualFold predicate on the "changelog" field. +func ChangelogEqualFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldChangelog, v)) +} + +// ChangelogContainsFold applies the ContainsFold predicate on the "changelog" field. +func ChangelogContainsFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContainsFold(FieldChangelog, v)) +} + +// BootstrapVersionEQ applies the EQ predicate on the "bootstrap_version" field. +func BootstrapVersionEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldBootstrapVersion, v)) +} + +// BootstrapVersionNEQ applies the NEQ predicate on the "bootstrap_version" field. +func BootstrapVersionNEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldBootstrapVersion, v)) +} + +// BootstrapVersionIn applies the In predicate on the "bootstrap_version" field. +func BootstrapVersionIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldBootstrapVersion, vs...)) +} + +// BootstrapVersionNotIn applies the NotIn predicate on the "bootstrap_version" field. +func BootstrapVersionNotIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldBootstrapVersion, vs...)) +} + +// BootstrapVersionGT applies the GT predicate on the "bootstrap_version" field. +func BootstrapVersionGT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldBootstrapVersion, v)) +} + +// BootstrapVersionGTE applies the GTE predicate on the "bootstrap_version" field. +func BootstrapVersionGTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldBootstrapVersion, v)) +} + +// BootstrapVersionLT applies the LT predicate on the "bootstrap_version" field. +func BootstrapVersionLT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldBootstrapVersion, v)) +} + +// BootstrapVersionLTE applies the LTE predicate on the "bootstrap_version" field. +func BootstrapVersionLTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldBootstrapVersion, v)) +} + +// BootstrapVersionContains applies the Contains predicate on the "bootstrap_version" field. +func BootstrapVersionContains(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContains(FieldBootstrapVersion, v)) +} + +// BootstrapVersionHasPrefix applies the HasPrefix predicate on the "bootstrap_version" field. +func BootstrapVersionHasPrefix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasPrefix(FieldBootstrapVersion, v)) +} + +// BootstrapVersionHasSuffix applies the HasSuffix predicate on the "bootstrap_version" field. +func BootstrapVersionHasSuffix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasSuffix(FieldBootstrapVersion, v)) +} + +// BootstrapVersionIsNil applies the IsNil predicate on the "bootstrap_version" field. +func BootstrapVersionIsNil() predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIsNull(FieldBootstrapVersion)) +} + +// BootstrapVersionNotNil applies the NotNil predicate on the "bootstrap_version" field. +func BootstrapVersionNotNil() predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotNull(FieldBootstrapVersion)) +} + +// BootstrapVersionEqualFold applies the EqualFold predicate on the "bootstrap_version" field. +func BootstrapVersionEqualFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldBootstrapVersion, v)) +} + +// BootstrapVersionContainsFold applies the ContainsFold predicate on the "bootstrap_version" field. +func BootstrapVersionContainsFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContainsFold(FieldBootstrapVersion, v)) +} + +// EngineVersionEQ applies the EQ predicate on the "engine_version" field. +func EngineVersionEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEQ(FieldEngineVersion, v)) +} + +// EngineVersionNEQ applies the NEQ predicate on the "engine_version" field. +func EngineVersionNEQ(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNEQ(FieldEngineVersion, v)) +} + +// EngineVersionIn applies the In predicate on the "engine_version" field. +func EngineVersionIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldIn(FieldEngineVersion, vs...)) +} + +// EngineVersionNotIn applies the NotIn predicate on the "engine_version" field. +func EngineVersionNotIn(vs ...string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldNotIn(FieldEngineVersion, vs...)) +} + +// EngineVersionGT applies the GT predicate on the "engine_version" field. +func EngineVersionGT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGT(FieldEngineVersion, v)) +} + +// EngineVersionGTE applies the GTE predicate on the "engine_version" field. +func EngineVersionGTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldGTE(FieldEngineVersion, v)) +} + +// EngineVersionLT applies the LT predicate on the "engine_version" field. +func EngineVersionLT(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLT(FieldEngineVersion, v)) +} + +// EngineVersionLTE applies the LTE predicate on the "engine_version" field. +func EngineVersionLTE(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldLTE(FieldEngineVersion, v)) +} + +// EngineVersionContains applies the Contains predicate on the "engine_version" field. +func EngineVersionContains(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContains(FieldEngineVersion, v)) +} + +// EngineVersionHasPrefix applies the HasPrefix predicate on the "engine_version" field. +func EngineVersionHasPrefix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasPrefix(FieldEngineVersion, v)) +} + +// EngineVersionHasSuffix applies the HasSuffix predicate on the "engine_version" field. +func EngineVersionHasSuffix(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldHasSuffix(FieldEngineVersion, v)) +} + +// EngineVersionEqualFold applies the EqualFold predicate on the "engine_version" field. +func EngineVersionEqualFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldEqualFold(FieldEngineVersion, v)) +} + +// EngineVersionContainsFold applies the ContainsFold predicate on the "engine_version" field. +func EngineVersionContainsFold(v string) predicate.SmlVersion { + return predicate.SmlVersion(sql.FieldContainsFold(FieldEngineVersion, v)) +} + +// HasTargets applies the HasEdge predicate on the "targets" edge. +func HasTargets() predicate.SmlVersion { + return predicate.SmlVersion(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.SmlVersionTarget) predicate.SmlVersion { + return predicate.SmlVersion(func(s *sql.Selector) { + step := newTargetsStep() + 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.SmlVersion) predicate.SmlVersion { + return predicate.SmlVersion(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.SmlVersion) predicate.SmlVersion { + return predicate.SmlVersion(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.SmlVersion) predicate.SmlVersion { + return predicate.SmlVersion(sql.NotPredicates(p)) +} diff --git a/generated/ent/smlversion_create.go b/generated/ent/smlversion_create.go new file mode 100644 index 00000000..e475a714 --- /dev/null +++ b/generated/ent/smlversion_create.go @@ -0,0 +1,453 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionCreate is the builder for creating a SmlVersion entity. +type SmlVersionCreate struct { + config + mutation *SmlVersionMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (svc *SmlVersionCreate) SetCreatedAt(t time.Time) *SmlVersionCreate { + svc.mutation.SetCreatedAt(t) + return svc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableCreatedAt(t *time.Time) *SmlVersionCreate { + if t != nil { + svc.SetCreatedAt(*t) + } + return svc +} + +// SetUpdatedAt sets the "updated_at" field. +func (svc *SmlVersionCreate) SetUpdatedAt(t time.Time) *SmlVersionCreate { + svc.mutation.SetUpdatedAt(t) + return svc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableUpdatedAt(t *time.Time) *SmlVersionCreate { + if t != nil { + svc.SetUpdatedAt(*t) + } + return svc +} + +// SetDeletedAt sets the "deleted_at" field. +func (svc *SmlVersionCreate) SetDeletedAt(t time.Time) *SmlVersionCreate { + svc.mutation.SetDeletedAt(t) + return svc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableDeletedAt(t *time.Time) *SmlVersionCreate { + if t != nil { + svc.SetDeletedAt(*t) + } + return svc +} + +// SetVersion sets the "version" field. +func (svc *SmlVersionCreate) SetVersion(s string) *SmlVersionCreate { + svc.mutation.SetVersion(s) + return svc +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (svc *SmlVersionCreate) SetSatisfactoryVersion(i int) *SmlVersionCreate { + svc.mutation.SetSatisfactoryVersion(i) + return svc +} + +// SetStability sets the "stability" field. +func (svc *SmlVersionCreate) SetStability(s smlversion.Stability) *SmlVersionCreate { + svc.mutation.SetStability(s) + return svc +} + +// SetDate sets the "date" field. +func (svc *SmlVersionCreate) SetDate(t time.Time) *SmlVersionCreate { + svc.mutation.SetDate(t) + return svc +} + +// SetLink sets the "link" field. +func (svc *SmlVersionCreate) SetLink(s string) *SmlVersionCreate { + svc.mutation.SetLink(s) + return svc +} + +// SetChangelog sets the "changelog" field. +func (svc *SmlVersionCreate) SetChangelog(s string) *SmlVersionCreate { + svc.mutation.SetChangelog(s) + return svc +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (svc *SmlVersionCreate) SetBootstrapVersion(s string) *SmlVersionCreate { + svc.mutation.SetBootstrapVersion(s) + return svc +} + +// SetNillableBootstrapVersion sets the "bootstrap_version" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableBootstrapVersion(s *string) *SmlVersionCreate { + if s != nil { + svc.SetBootstrapVersion(*s) + } + return svc +} + +// SetEngineVersion sets the "engine_version" field. +func (svc *SmlVersionCreate) SetEngineVersion(s string) *SmlVersionCreate { + svc.mutation.SetEngineVersion(s) + return svc +} + +// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableEngineVersion(s *string) *SmlVersionCreate { + if s != nil { + svc.SetEngineVersion(*s) + } + return svc +} + +// SetID sets the "id" field. +func (svc *SmlVersionCreate) SetID(s string) *SmlVersionCreate { + svc.mutation.SetID(s) + return svc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (svc *SmlVersionCreate) SetNillableID(s *string) *SmlVersionCreate { + if s != nil { + svc.SetID(*s) + } + return svc +} + +// AddTargetIDs adds the "targets" edge to the SmlVersionTarget entity by IDs. +func (svc *SmlVersionCreate) AddTargetIDs(ids ...string) *SmlVersionCreate { + svc.mutation.AddTargetIDs(ids...) + return svc +} + +// AddTargets adds the "targets" edges to the SmlVersionTarget entity. +func (svc *SmlVersionCreate) AddTargets(s ...*SmlVersionTarget) *SmlVersionCreate { + ids := make([]string, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return svc.AddTargetIDs(ids...) +} + +// Mutation returns the SmlVersionMutation object of the builder. +func (svc *SmlVersionCreate) Mutation() *SmlVersionMutation { + return svc.mutation +} + +// Save creates the SmlVersion in the database. +func (svc *SmlVersionCreate) Save(ctx context.Context) (*SmlVersion, error) { + if err := svc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, svc.sqlSave, svc.mutation, svc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (svc *SmlVersionCreate) SaveX(ctx context.Context) *SmlVersion { + v, err := svc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (svc *SmlVersionCreate) Exec(ctx context.Context) error { + _, err := svc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svc *SmlVersionCreate) ExecX(ctx context.Context) { + if err := svc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (svc *SmlVersionCreate) defaults() error { + if _, ok := svc.mutation.CreatedAt(); !ok { + if smlversion.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized smlversion.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := smlversion.DefaultCreatedAt() + svc.mutation.SetCreatedAt(v) + } + if _, ok := svc.mutation.UpdatedAt(); !ok { + if smlversion.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized smlversion.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := smlversion.DefaultUpdatedAt() + svc.mutation.SetUpdatedAt(v) + } + if _, ok := svc.mutation.EngineVersion(); !ok { + v := smlversion.DefaultEngineVersion + svc.mutation.SetEngineVersion(v) + } + if _, ok := svc.mutation.ID(); !ok { + if smlversion.DefaultID == nil { + return fmt.Errorf("ent: uninitialized smlversion.DefaultID (forgotten import ent/runtime?)") + } + v := smlversion.DefaultID() + svc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (svc *SmlVersionCreate) check() error { + if _, ok := svc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SmlVersion.created_at"`)} + } + if _, ok := svc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SmlVersion.updated_at"`)} + } + if _, ok := svc.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`ent: missing required field "SmlVersion.version"`)} + } + if v, ok := svc.mutation.Version(); ok { + if err := smlversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.version": %w`, err)} + } + } + if _, ok := svc.mutation.SatisfactoryVersion(); !ok { + return &ValidationError{Name: "satisfactory_version", err: errors.New(`ent: missing required field "SmlVersion.satisfactory_version"`)} + } + if _, ok := svc.mutation.Stability(); !ok { + return &ValidationError{Name: "stability", err: errors.New(`ent: missing required field "SmlVersion.stability"`)} + } + if v, ok := svc.mutation.Stability(); ok { + if err := smlversion.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.stability": %w`, err)} + } + } + if _, ok := svc.mutation.Date(); !ok { + return &ValidationError{Name: "date", err: errors.New(`ent: missing required field "SmlVersion.date"`)} + } + if _, ok := svc.mutation.Link(); !ok { + return &ValidationError{Name: "link", err: errors.New(`ent: missing required field "SmlVersion.link"`)} + } + if _, ok := svc.mutation.Changelog(); !ok { + return &ValidationError{Name: "changelog", err: errors.New(`ent: missing required field "SmlVersion.changelog"`)} + } + if v, ok := svc.mutation.BootstrapVersion(); ok { + if err := smlversion.BootstrapVersionValidator(v); err != nil { + return &ValidationError{Name: "bootstrap_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.bootstrap_version": %w`, err)} + } + } + if _, ok := svc.mutation.EngineVersion(); !ok { + return &ValidationError{Name: "engine_version", err: errors.New(`ent: missing required field "SmlVersion.engine_version"`)} + } + if v, ok := svc.mutation.EngineVersion(); ok { + if err := smlversion.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.engine_version": %w`, err)} + } + } + return nil +} + +func (svc *SmlVersionCreate) sqlSave(ctx context.Context) (*SmlVersion, error) { + if err := svc.check(); err != nil { + return nil, err + } + _node, _spec := svc.createSpec() + if err := sqlgraph.CreateNode(ctx, svc.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 SmlVersion.ID type: %T", _spec.ID.Value) + } + } + svc.mutation.id = &_node.ID + svc.mutation.done = true + return _node, nil +} + +func (svc *SmlVersionCreate) createSpec() (*SmlVersion, *sqlgraph.CreateSpec) { + var ( + _node = &SmlVersion{config: svc.config} + _spec = sqlgraph.NewCreateSpec(smlversion.Table, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) + ) + if id, ok := svc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := svc.mutation.CreatedAt(); ok { + _spec.SetField(smlversion.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := svc.mutation.UpdatedAt(); ok { + _spec.SetField(smlversion.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := svc.mutation.DeletedAt(); ok { + _spec.SetField(smlversion.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := svc.mutation.Version(); ok { + _spec.SetField(smlversion.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := svc.mutation.SatisfactoryVersion(); ok { + _spec.SetField(smlversion.FieldSatisfactoryVersion, field.TypeInt, value) + _node.SatisfactoryVersion = value + } + if value, ok := svc.mutation.Stability(); ok { + _spec.SetField(smlversion.FieldStability, field.TypeEnum, value) + _node.Stability = value + } + if value, ok := svc.mutation.Date(); ok { + _spec.SetField(smlversion.FieldDate, field.TypeTime, value) + _node.Date = value + } + if value, ok := svc.mutation.Link(); ok { + _spec.SetField(smlversion.FieldLink, field.TypeString, value) + _node.Link = value + } + if value, ok := svc.mutation.Changelog(); ok { + _spec.SetField(smlversion.FieldChangelog, field.TypeString, value) + _node.Changelog = value + } + if value, ok := svc.mutation.BootstrapVersion(); ok { + _spec.SetField(smlversion.FieldBootstrapVersion, field.TypeString, value) + _node.BootstrapVersion = value + } + if value, ok := svc.mutation.EngineVersion(); ok { + _spec.SetField(smlversion.FieldEngineVersion, field.TypeString, value) + _node.EngineVersion = value + } + if nodes := svc.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SmlVersionCreateBulk is the builder for creating many SmlVersion entities in bulk. +type SmlVersionCreateBulk struct { + config + err error + builders []*SmlVersionCreate +} + +// Save creates the SmlVersion entities in the database. +func (svcb *SmlVersionCreateBulk) Save(ctx context.Context) ([]*SmlVersion, error) { + if svcb.err != nil { + return nil, svcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(svcb.builders)) + nodes := make([]*SmlVersion, len(svcb.builders)) + mutators := make([]Mutator, len(svcb.builders)) + for i := range svcb.builders { + func(i int, root context.Context) { + builder := svcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*SmlVersionMutation) + 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, svcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, svcb.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, svcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (svcb *SmlVersionCreateBulk) SaveX(ctx context.Context) []*SmlVersion { + v, err := svcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (svcb *SmlVersionCreateBulk) Exec(ctx context.Context) error { + _, err := svcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svcb *SmlVersionCreateBulk) ExecX(ctx context.Context) { + if err := svcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/smlversion_delete.go b/generated/ent/smlversion_delete.go new file mode 100644 index 00000000..1b72e656 --- /dev/null +++ b/generated/ent/smlversion_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" +) + +// SmlVersionDelete is the builder for deleting a SmlVersion entity. +type SmlVersionDelete struct { + config + hooks []Hook + mutation *SmlVersionMutation +} + +// Where appends a list predicates to the SmlVersionDelete builder. +func (svd *SmlVersionDelete) Where(ps ...predicate.SmlVersion) *SmlVersionDelete { + svd.mutation.Where(ps...) + return svd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (svd *SmlVersionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, svd.sqlExec, svd.mutation, svd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (svd *SmlVersionDelete) ExecX(ctx context.Context) int { + n, err := svd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (svd *SmlVersionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(smlversion.Table, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) + if ps := svd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, svd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + svd.mutation.done = true + return affected, err +} + +// SmlVersionDeleteOne is the builder for deleting a single SmlVersion entity. +type SmlVersionDeleteOne struct { + svd *SmlVersionDelete +} + +// Where appends a list predicates to the SmlVersionDelete builder. +func (svdo *SmlVersionDeleteOne) Where(ps ...predicate.SmlVersion) *SmlVersionDeleteOne { + svdo.svd.mutation.Where(ps...) + return svdo +} + +// Exec executes the deletion query. +func (svdo *SmlVersionDeleteOne) Exec(ctx context.Context) error { + n, err := svdo.svd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{smlversion.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (svdo *SmlVersionDeleteOne) ExecX(ctx context.Context) { + if err := svdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/smlversion_query.go b/generated/ent/smlversion_query.go new file mode 100644 index 00000000..69248d43 --- /dev/null +++ b/generated/ent/smlversion_query.go @@ -0,0 +1,627 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionQuery is the builder for querying SmlVersion entities. +type SmlVersionQuery struct { + config + ctx *QueryContext + order []smlversion.OrderOption + inters []Interceptor + predicates []predicate.SmlVersion + withTargets *SmlVersionTargetQuery + 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 SmlVersionQuery builder. +func (svq *SmlVersionQuery) Where(ps ...predicate.SmlVersion) *SmlVersionQuery { + svq.predicates = append(svq.predicates, ps...) + return svq +} + +// Limit the number of records to be returned by this query. +func (svq *SmlVersionQuery) Limit(limit int) *SmlVersionQuery { + svq.ctx.Limit = &limit + return svq +} + +// Offset to start from. +func (svq *SmlVersionQuery) Offset(offset int) *SmlVersionQuery { + svq.ctx.Offset = &offset + return svq +} + +// 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 (svq *SmlVersionQuery) Unique(unique bool) *SmlVersionQuery { + svq.ctx.Unique = &unique + return svq +} + +// Order specifies how the records should be ordered. +func (svq *SmlVersionQuery) Order(o ...smlversion.OrderOption) *SmlVersionQuery { + svq.order = append(svq.order, o...) + return svq +} + +// QueryTargets chains the current query on the "targets" edge. +func (svq *SmlVersionQuery) QueryTargets() *SmlVersionTargetQuery { + query := (&SmlVersionTargetClient{config: svq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := svq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := svq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(smlversion.Table, smlversion.FieldID, selector), + sqlgraph.To(smlversiontarget.Table, smlversiontarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, smlversion.TargetsTable, smlversion.TargetsColumn), + ) + fromU = sqlgraph.SetNeighbors(svq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first SmlVersion entity from the query. +// Returns a *NotFoundError when no SmlVersion was found. +func (svq *SmlVersionQuery) First(ctx context.Context) (*SmlVersion, error) { + nodes, err := svq.Limit(1).All(setContextOp(ctx, svq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{smlversion.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (svq *SmlVersionQuery) FirstX(ctx context.Context) *SmlVersion { + node, err := svq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first SmlVersion ID from the query. +// Returns a *NotFoundError when no SmlVersion ID was found. +func (svq *SmlVersionQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = svq.Limit(1).IDs(setContextOp(ctx, svq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{smlversion.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (svq *SmlVersionQuery) FirstIDX(ctx context.Context) string { + id, err := svq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single SmlVersion entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one SmlVersion entity is found. +// Returns a *NotFoundError when no SmlVersion entities are found. +func (svq *SmlVersionQuery) Only(ctx context.Context) (*SmlVersion, error) { + nodes, err := svq.Limit(2).All(setContextOp(ctx, svq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{smlversion.Label} + default: + return nil, &NotSingularError{smlversion.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (svq *SmlVersionQuery) OnlyX(ctx context.Context) *SmlVersion { + node, err := svq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only SmlVersion ID in the query. +// Returns a *NotSingularError when more than one SmlVersion ID is found. +// Returns a *NotFoundError when no entities are found. +func (svq *SmlVersionQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = svq.Limit(2).IDs(setContextOp(ctx, svq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{smlversion.Label} + default: + err = &NotSingularError{smlversion.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (svq *SmlVersionQuery) OnlyIDX(ctx context.Context) string { + id, err := svq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of SmlVersions. +func (svq *SmlVersionQuery) All(ctx context.Context) ([]*SmlVersion, error) { + ctx = setContextOp(ctx, svq.ctx, "All") + if err := svq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*SmlVersion, *SmlVersionQuery]() + return withInterceptors[[]*SmlVersion](ctx, svq, qr, svq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (svq *SmlVersionQuery) AllX(ctx context.Context) []*SmlVersion { + nodes, err := svq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of SmlVersion IDs. +func (svq *SmlVersionQuery) IDs(ctx context.Context) (ids []string, err error) { + if svq.ctx.Unique == nil && svq.path != nil { + svq.Unique(true) + } + ctx = setContextOp(ctx, svq.ctx, "IDs") + if err = svq.Select(smlversion.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (svq *SmlVersionQuery) IDsX(ctx context.Context) []string { + ids, err := svq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (svq *SmlVersionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, svq.ctx, "Count") + if err := svq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, svq, querierCount[*SmlVersionQuery](), svq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (svq *SmlVersionQuery) CountX(ctx context.Context) int { + count, err := svq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (svq *SmlVersionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, svq.ctx, "Exist") + switch _, err := svq.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 (svq *SmlVersionQuery) ExistX(ctx context.Context) bool { + exist, err := svq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the SmlVersionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (svq *SmlVersionQuery) Clone() *SmlVersionQuery { + if svq == nil { + return nil + } + return &SmlVersionQuery{ + config: svq.config, + ctx: svq.ctx.Clone(), + order: append([]smlversion.OrderOption{}, svq.order...), + inters: append([]Interceptor{}, svq.inters...), + predicates: append([]predicate.SmlVersion{}, svq.predicates...), + withTargets: svq.withTargets.Clone(), + // clone intermediate query. + sql: svq.sql.Clone(), + path: svq.path, + } +} + +// 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 (svq *SmlVersionQuery) WithTargets(opts ...func(*SmlVersionTargetQuery)) *SmlVersionQuery { + query := (&SmlVersionTargetClient{config: svq.config}).Query() + for _, opt := range opts { + opt(query) + } + svq.withTargets = query + return svq +} + +// 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.SmlVersion.Query(). +// GroupBy(smlversion.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (svq *SmlVersionQuery) GroupBy(field string, fields ...string) *SmlVersionGroupBy { + svq.ctx.Fields = append([]string{field}, fields...) + grbuild := &SmlVersionGroupBy{build: svq} + grbuild.flds = &svq.ctx.Fields + grbuild.label = smlversion.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.SmlVersion.Query(). +// Select(smlversion.FieldCreatedAt). +// Scan(ctx, &v) +func (svq *SmlVersionQuery) Select(fields ...string) *SmlVersionSelect { + svq.ctx.Fields = append(svq.ctx.Fields, fields...) + sbuild := &SmlVersionSelect{SmlVersionQuery: svq} + sbuild.label = smlversion.Label + sbuild.flds, sbuild.scan = &svq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a SmlVersionSelect configured with the given aggregations. +func (svq *SmlVersionQuery) Aggregate(fns ...AggregateFunc) *SmlVersionSelect { + return svq.Select().Aggregate(fns...) +} + +func (svq *SmlVersionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range svq.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, svq); err != nil { + return err + } + } + } + for _, f := range svq.ctx.Fields { + if !smlversion.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if svq.path != nil { + prev, err := svq.path(ctx) + if err != nil { + return err + } + svq.sql = prev + } + return nil +} + +func (svq *SmlVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SmlVersion, error) { + var ( + nodes = []*SmlVersion{} + _spec = svq.querySpec() + loadedTypes = [1]bool{ + svq.withTargets != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*SmlVersion).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &SmlVersion{config: svq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(svq.modifiers) > 0 { + _spec.Modifiers = svq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, svq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := svq.withTargets; query != nil { + if err := svq.loadTargets(ctx, query, nodes, + func(n *SmlVersion) { n.Edges.Targets = []*SmlVersionTarget{} }, + func(n *SmlVersion, e *SmlVersionTarget) { n.Edges.Targets = append(n.Edges.Targets, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (svq *SmlVersionQuery) loadTargets(ctx context.Context, query *SmlVersionTargetQuery, nodes []*SmlVersion, init func(*SmlVersion), assign func(*SmlVersion, *SmlVersionTarget)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*SmlVersion) + 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(smlversiontarget.FieldVersionID) + } + query.Where(predicate.SmlVersionTarget(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(smlversion.TargetsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.VersionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "version_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (svq *SmlVersionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := svq.querySpec() + if len(svq.modifiers) > 0 { + _spec.Modifiers = svq.modifiers + } + _spec.Node.Columns = svq.ctx.Fields + if len(svq.ctx.Fields) > 0 { + _spec.Unique = svq.ctx.Unique != nil && *svq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, svq.driver, _spec) +} + +func (svq *SmlVersionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(smlversion.Table, smlversion.Columns, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) + _spec.From = svq.sql + if unique := svq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if svq.path != nil { + _spec.Unique = true + } + if fields := svq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, smlversion.FieldID) + for i := range fields { + if fields[i] != smlversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := svq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := svq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := svq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := svq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (svq *SmlVersionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(svq.driver.Dialect()) + t1 := builder.Table(smlversion.Table) + columns := svq.ctx.Fields + if len(columns) == 0 { + columns = smlversion.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if svq.sql != nil { + selector = svq.sql + selector.Select(selector.Columns(columns...)...) + } + if svq.ctx.Unique != nil && *svq.ctx.Unique { + selector.Distinct() + } + for _, m := range svq.modifiers { + m(selector) + } + for _, p := range svq.predicates { + p(selector) + } + for _, p := range svq.order { + p(selector) + } + if offset := svq.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 := svq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (svq *SmlVersionQuery) Modify(modifiers ...func(s *sql.Selector)) *SmlVersionSelect { + svq.modifiers = append(svq.modifiers, modifiers...) + return svq.Select() +} + +// SmlVersionGroupBy is the group-by builder for SmlVersion entities. +type SmlVersionGroupBy struct { + selector + build *SmlVersionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (svgb *SmlVersionGroupBy) Aggregate(fns ...AggregateFunc) *SmlVersionGroupBy { + svgb.fns = append(svgb.fns, fns...) + return svgb +} + +// Scan applies the selector query and scans the result into the given value. +func (svgb *SmlVersionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, svgb.build.ctx, "GroupBy") + if err := svgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SmlVersionQuery, *SmlVersionGroupBy](ctx, svgb.build, svgb, svgb.build.inters, v) +} + +func (svgb *SmlVersionGroupBy) sqlScan(ctx context.Context, root *SmlVersionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(svgb.fns)) + for _, fn := range svgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*svgb.flds)+len(svgb.fns)) + for _, f := range *svgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*svgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := svgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// SmlVersionSelect is the builder for selecting fields of SmlVersion entities. +type SmlVersionSelect struct { + *SmlVersionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (svs *SmlVersionSelect) Aggregate(fns ...AggregateFunc) *SmlVersionSelect { + svs.fns = append(svs.fns, fns...) + return svs +} + +// Scan applies the selector query and scans the result into the given value. +func (svs *SmlVersionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, svs.ctx, "Select") + if err := svs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SmlVersionQuery, *SmlVersionSelect](ctx, svs.SmlVersionQuery, svs, svs.inters, v) +} + +func (svs *SmlVersionSelect) sqlScan(ctx context.Context, root *SmlVersionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(svs.fns)) + for _, fn := range svs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*svs.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 := svs.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 (svs *SmlVersionSelect) Modify(modifiers ...func(s *sql.Selector)) *SmlVersionSelect { + svs.modifiers = append(svs.modifiers, modifiers...) + return svs +} diff --git a/generated/ent/smlversion_update.go b/generated/ent/smlversion_update.go new file mode 100644 index 00000000..c45bb940 --- /dev/null +++ b/generated/ent/smlversion_update.go @@ -0,0 +1,725 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionUpdate is the builder for updating SmlVersion entities. +type SmlVersionUpdate struct { + config + hooks []Hook + mutation *SmlVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the SmlVersionUpdate builder. +func (svu *SmlVersionUpdate) Where(ps ...predicate.SmlVersion) *SmlVersionUpdate { + svu.mutation.Where(ps...) + return svu +} + +// SetUpdatedAt sets the "updated_at" field. +func (svu *SmlVersionUpdate) SetUpdatedAt(t time.Time) *SmlVersionUpdate { + svu.mutation.SetUpdatedAt(t) + return svu +} + +// SetDeletedAt sets the "deleted_at" field. +func (svu *SmlVersionUpdate) SetDeletedAt(t time.Time) *SmlVersionUpdate { + svu.mutation.SetDeletedAt(t) + return svu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableDeletedAt(t *time.Time) *SmlVersionUpdate { + if t != nil { + svu.SetDeletedAt(*t) + } + return svu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (svu *SmlVersionUpdate) ClearDeletedAt() *SmlVersionUpdate { + svu.mutation.ClearDeletedAt() + return svu +} + +// SetVersion sets the "version" field. +func (svu *SmlVersionUpdate) SetVersion(s string) *SmlVersionUpdate { + svu.mutation.SetVersion(s) + return svu +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (svu *SmlVersionUpdate) SetSatisfactoryVersion(i int) *SmlVersionUpdate { + svu.mutation.ResetSatisfactoryVersion() + svu.mutation.SetSatisfactoryVersion(i) + return svu +} + +// AddSatisfactoryVersion adds i to the "satisfactory_version" field. +func (svu *SmlVersionUpdate) AddSatisfactoryVersion(i int) *SmlVersionUpdate { + svu.mutation.AddSatisfactoryVersion(i) + return svu +} + +// SetStability sets the "stability" field. +func (svu *SmlVersionUpdate) SetStability(s smlversion.Stability) *SmlVersionUpdate { + svu.mutation.SetStability(s) + return svu +} + +// SetDate sets the "date" field. +func (svu *SmlVersionUpdate) SetDate(t time.Time) *SmlVersionUpdate { + svu.mutation.SetDate(t) + return svu +} + +// SetLink sets the "link" field. +func (svu *SmlVersionUpdate) SetLink(s string) *SmlVersionUpdate { + svu.mutation.SetLink(s) + return svu +} + +// SetChangelog sets the "changelog" field. +func (svu *SmlVersionUpdate) SetChangelog(s string) *SmlVersionUpdate { + svu.mutation.SetChangelog(s) + return svu +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (svu *SmlVersionUpdate) SetBootstrapVersion(s string) *SmlVersionUpdate { + svu.mutation.SetBootstrapVersion(s) + return svu +} + +// SetNillableBootstrapVersion sets the "bootstrap_version" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableBootstrapVersion(s *string) *SmlVersionUpdate { + if s != nil { + svu.SetBootstrapVersion(*s) + } + return svu +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (svu *SmlVersionUpdate) ClearBootstrapVersion() *SmlVersionUpdate { + svu.mutation.ClearBootstrapVersion() + return svu +} + +// SetEngineVersion sets the "engine_version" field. +func (svu *SmlVersionUpdate) SetEngineVersion(s string) *SmlVersionUpdate { + svu.mutation.SetEngineVersion(s) + return svu +} + +// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableEngineVersion(s *string) *SmlVersionUpdate { + if s != nil { + svu.SetEngineVersion(*s) + } + return svu +} + +// AddTargetIDs adds the "targets" edge to the SmlVersionTarget entity by IDs. +func (svu *SmlVersionUpdate) AddTargetIDs(ids ...string) *SmlVersionUpdate { + svu.mutation.AddTargetIDs(ids...) + return svu +} + +// AddTargets adds the "targets" edges to the SmlVersionTarget entity. +func (svu *SmlVersionUpdate) AddTargets(s ...*SmlVersionTarget) *SmlVersionUpdate { + ids := make([]string, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return svu.AddTargetIDs(ids...) +} + +// Mutation returns the SmlVersionMutation object of the builder. +func (svu *SmlVersionUpdate) Mutation() *SmlVersionMutation { + return svu.mutation +} + +// ClearTargets clears all "targets" edges to the SmlVersionTarget entity. +func (svu *SmlVersionUpdate) ClearTargets() *SmlVersionUpdate { + svu.mutation.ClearTargets() + return svu +} + +// RemoveTargetIDs removes the "targets" edge to SmlVersionTarget entities by IDs. +func (svu *SmlVersionUpdate) RemoveTargetIDs(ids ...string) *SmlVersionUpdate { + svu.mutation.RemoveTargetIDs(ids...) + return svu +} + +// RemoveTargets removes "targets" edges to SmlVersionTarget entities. +func (svu *SmlVersionUpdate) RemoveTargets(s ...*SmlVersionTarget) *SmlVersionUpdate { + ids := make([]string, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return svu.RemoveTargetIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (svu *SmlVersionUpdate) Save(ctx context.Context) (int, error) { + if err := svu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, svu.sqlSave, svu.mutation, svu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (svu *SmlVersionUpdate) SaveX(ctx context.Context) int { + affected, err := svu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (svu *SmlVersionUpdate) Exec(ctx context.Context) error { + _, err := svu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svu *SmlVersionUpdate) ExecX(ctx context.Context) { + if err := svu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (svu *SmlVersionUpdate) defaults() error { + if _, ok := svu.mutation.UpdatedAt(); !ok { + if smlversion.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized smlversion.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := smlversion.UpdateDefaultUpdatedAt() + svu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (svu *SmlVersionUpdate) check() error { + if v, ok := svu.mutation.Version(); ok { + if err := smlversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.version": %w`, err)} + } + } + if v, ok := svu.mutation.Stability(); ok { + if err := smlversion.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.stability": %w`, err)} + } + } + if v, ok := svu.mutation.BootstrapVersion(); ok { + if err := smlversion.BootstrapVersionValidator(v); err != nil { + return &ValidationError{Name: "bootstrap_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.bootstrap_version": %w`, err)} + } + } + if v, ok := svu.mutation.EngineVersion(); ok { + if err := smlversion.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.engine_version": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (svu *SmlVersionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SmlVersionUpdate { + svu.modifiers = append(svu.modifiers, modifiers...) + return svu +} + +func (svu *SmlVersionUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := svu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(smlversion.Table, smlversion.Columns, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) + if ps := svu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := svu.mutation.UpdatedAt(); ok { + _spec.SetField(smlversion.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := svu.mutation.DeletedAt(); ok { + _spec.SetField(smlversion.FieldDeletedAt, field.TypeTime, value) + } + if svu.mutation.DeletedAtCleared() { + _spec.ClearField(smlversion.FieldDeletedAt, field.TypeTime) + } + if value, ok := svu.mutation.Version(); ok { + _spec.SetField(smlversion.FieldVersion, field.TypeString, value) + } + if value, ok := svu.mutation.SatisfactoryVersion(); ok { + _spec.SetField(smlversion.FieldSatisfactoryVersion, field.TypeInt, value) + } + if value, ok := svu.mutation.AddedSatisfactoryVersion(); ok { + _spec.AddField(smlversion.FieldSatisfactoryVersion, field.TypeInt, value) + } + if value, ok := svu.mutation.Stability(); ok { + _spec.SetField(smlversion.FieldStability, field.TypeEnum, value) + } + if value, ok := svu.mutation.Date(); ok { + _spec.SetField(smlversion.FieldDate, field.TypeTime, value) + } + if value, ok := svu.mutation.Link(); ok { + _spec.SetField(smlversion.FieldLink, field.TypeString, value) + } + if value, ok := svu.mutation.Changelog(); ok { + _spec.SetField(smlversion.FieldChangelog, field.TypeString, value) + } + if value, ok := svu.mutation.BootstrapVersion(); ok { + _spec.SetField(smlversion.FieldBootstrapVersion, field.TypeString, value) + } + if svu.mutation.BootstrapVersionCleared() { + _spec.ClearField(smlversion.FieldBootstrapVersion, field.TypeString) + } + if value, ok := svu.mutation.EngineVersion(); ok { + _spec.SetField(smlversion.FieldEngineVersion, field.TypeString, value) + } + if svu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := svu.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !svu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.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 := svu.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.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(svu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, svu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{smlversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + svu.mutation.done = true + return n, nil +} + +// SmlVersionUpdateOne is the builder for updating a single SmlVersion entity. +type SmlVersionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *SmlVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (svuo *SmlVersionUpdateOne) SetUpdatedAt(t time.Time) *SmlVersionUpdateOne { + svuo.mutation.SetUpdatedAt(t) + return svuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (svuo *SmlVersionUpdateOne) SetDeletedAt(t time.Time) *SmlVersionUpdateOne { + svuo.mutation.SetDeletedAt(t) + return svuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableDeletedAt(t *time.Time) *SmlVersionUpdateOne { + if t != nil { + svuo.SetDeletedAt(*t) + } + return svuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (svuo *SmlVersionUpdateOne) ClearDeletedAt() *SmlVersionUpdateOne { + svuo.mutation.ClearDeletedAt() + return svuo +} + +// SetVersion sets the "version" field. +func (svuo *SmlVersionUpdateOne) SetVersion(s string) *SmlVersionUpdateOne { + svuo.mutation.SetVersion(s) + return svuo +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (svuo *SmlVersionUpdateOne) SetSatisfactoryVersion(i int) *SmlVersionUpdateOne { + svuo.mutation.ResetSatisfactoryVersion() + svuo.mutation.SetSatisfactoryVersion(i) + return svuo +} + +// AddSatisfactoryVersion adds i to the "satisfactory_version" field. +func (svuo *SmlVersionUpdateOne) AddSatisfactoryVersion(i int) *SmlVersionUpdateOne { + svuo.mutation.AddSatisfactoryVersion(i) + return svuo +} + +// SetStability sets the "stability" field. +func (svuo *SmlVersionUpdateOne) SetStability(s smlversion.Stability) *SmlVersionUpdateOne { + svuo.mutation.SetStability(s) + return svuo +} + +// SetDate sets the "date" field. +func (svuo *SmlVersionUpdateOne) SetDate(t time.Time) *SmlVersionUpdateOne { + svuo.mutation.SetDate(t) + return svuo +} + +// SetLink sets the "link" field. +func (svuo *SmlVersionUpdateOne) SetLink(s string) *SmlVersionUpdateOne { + svuo.mutation.SetLink(s) + return svuo +} + +// SetChangelog sets the "changelog" field. +func (svuo *SmlVersionUpdateOne) SetChangelog(s string) *SmlVersionUpdateOne { + svuo.mutation.SetChangelog(s) + return svuo +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (svuo *SmlVersionUpdateOne) SetBootstrapVersion(s string) *SmlVersionUpdateOne { + svuo.mutation.SetBootstrapVersion(s) + return svuo +} + +// SetNillableBootstrapVersion sets the "bootstrap_version" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableBootstrapVersion(s *string) *SmlVersionUpdateOne { + if s != nil { + svuo.SetBootstrapVersion(*s) + } + return svuo +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (svuo *SmlVersionUpdateOne) ClearBootstrapVersion() *SmlVersionUpdateOne { + svuo.mutation.ClearBootstrapVersion() + return svuo +} + +// SetEngineVersion sets the "engine_version" field. +func (svuo *SmlVersionUpdateOne) SetEngineVersion(s string) *SmlVersionUpdateOne { + svuo.mutation.SetEngineVersion(s) + return svuo +} + +// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableEngineVersion(s *string) *SmlVersionUpdateOne { + if s != nil { + svuo.SetEngineVersion(*s) + } + return svuo +} + +// AddTargetIDs adds the "targets" edge to the SmlVersionTarget entity by IDs. +func (svuo *SmlVersionUpdateOne) AddTargetIDs(ids ...string) *SmlVersionUpdateOne { + svuo.mutation.AddTargetIDs(ids...) + return svuo +} + +// AddTargets adds the "targets" edges to the SmlVersionTarget entity. +func (svuo *SmlVersionUpdateOne) AddTargets(s ...*SmlVersionTarget) *SmlVersionUpdateOne { + ids := make([]string, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return svuo.AddTargetIDs(ids...) +} + +// Mutation returns the SmlVersionMutation object of the builder. +func (svuo *SmlVersionUpdateOne) Mutation() *SmlVersionMutation { + return svuo.mutation +} + +// ClearTargets clears all "targets" edges to the SmlVersionTarget entity. +func (svuo *SmlVersionUpdateOne) ClearTargets() *SmlVersionUpdateOne { + svuo.mutation.ClearTargets() + return svuo +} + +// RemoveTargetIDs removes the "targets" edge to SmlVersionTarget entities by IDs. +func (svuo *SmlVersionUpdateOne) RemoveTargetIDs(ids ...string) *SmlVersionUpdateOne { + svuo.mutation.RemoveTargetIDs(ids...) + return svuo +} + +// RemoveTargets removes "targets" edges to SmlVersionTarget entities. +func (svuo *SmlVersionUpdateOne) RemoveTargets(s ...*SmlVersionTarget) *SmlVersionUpdateOne { + ids := make([]string, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return svuo.RemoveTargetIDs(ids...) +} + +// Where appends a list predicates to the SmlVersionUpdate builder. +func (svuo *SmlVersionUpdateOne) Where(ps ...predicate.SmlVersion) *SmlVersionUpdateOne { + svuo.mutation.Where(ps...) + return svuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (svuo *SmlVersionUpdateOne) Select(field string, fields ...string) *SmlVersionUpdateOne { + svuo.fields = append([]string{field}, fields...) + return svuo +} + +// Save executes the query and returns the updated SmlVersion entity. +func (svuo *SmlVersionUpdateOne) Save(ctx context.Context) (*SmlVersion, error) { + if err := svuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, svuo.sqlSave, svuo.mutation, svuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (svuo *SmlVersionUpdateOne) SaveX(ctx context.Context) *SmlVersion { + node, err := svuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (svuo *SmlVersionUpdateOne) Exec(ctx context.Context) error { + _, err := svuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svuo *SmlVersionUpdateOne) ExecX(ctx context.Context) { + if err := svuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (svuo *SmlVersionUpdateOne) defaults() error { + if _, ok := svuo.mutation.UpdatedAt(); !ok { + if smlversion.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized smlversion.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := smlversion.UpdateDefaultUpdatedAt() + svuo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (svuo *SmlVersionUpdateOne) check() error { + if v, ok := svuo.mutation.Version(); ok { + if err := smlversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.version": %w`, err)} + } + } + if v, ok := svuo.mutation.Stability(); ok { + if err := smlversion.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.stability": %w`, err)} + } + } + if v, ok := svuo.mutation.BootstrapVersion(); ok { + if err := smlversion.BootstrapVersionValidator(v); err != nil { + return &ValidationError{Name: "bootstrap_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.bootstrap_version": %w`, err)} + } + } + if v, ok := svuo.mutation.EngineVersion(); ok { + if err := smlversion.EngineVersionValidator(v); err != nil { + return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "SmlVersion.engine_version": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (svuo *SmlVersionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SmlVersionUpdateOne { + svuo.modifiers = append(svuo.modifiers, modifiers...) + return svuo +} + +func (svuo *SmlVersionUpdateOne) sqlSave(ctx context.Context) (_node *SmlVersion, err error) { + if err := svuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(smlversion.Table, smlversion.Columns, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) + id, ok := svuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SmlVersion.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := svuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, smlversion.FieldID) + for _, f := range fields { + if !smlversion.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != smlversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := svuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := svuo.mutation.UpdatedAt(); ok { + _spec.SetField(smlversion.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := svuo.mutation.DeletedAt(); ok { + _spec.SetField(smlversion.FieldDeletedAt, field.TypeTime, value) + } + if svuo.mutation.DeletedAtCleared() { + _spec.ClearField(smlversion.FieldDeletedAt, field.TypeTime) + } + if value, ok := svuo.mutation.Version(); ok { + _spec.SetField(smlversion.FieldVersion, field.TypeString, value) + } + if value, ok := svuo.mutation.SatisfactoryVersion(); ok { + _spec.SetField(smlversion.FieldSatisfactoryVersion, field.TypeInt, value) + } + if value, ok := svuo.mutation.AddedSatisfactoryVersion(); ok { + _spec.AddField(smlversion.FieldSatisfactoryVersion, field.TypeInt, value) + } + if value, ok := svuo.mutation.Stability(); ok { + _spec.SetField(smlversion.FieldStability, field.TypeEnum, value) + } + if value, ok := svuo.mutation.Date(); ok { + _spec.SetField(smlversion.FieldDate, field.TypeTime, value) + } + if value, ok := svuo.mutation.Link(); ok { + _spec.SetField(smlversion.FieldLink, field.TypeString, value) + } + if value, ok := svuo.mutation.Changelog(); ok { + _spec.SetField(smlversion.FieldChangelog, field.TypeString, value) + } + if value, ok := svuo.mutation.BootstrapVersion(); ok { + _spec.SetField(smlversion.FieldBootstrapVersion, field.TypeString, value) + } + if svuo.mutation.BootstrapVersionCleared() { + _spec.ClearField(smlversion.FieldBootstrapVersion, field.TypeString) + } + if value, ok := svuo.mutation.EngineVersion(); ok { + _spec.SetField(smlversion.FieldEngineVersion, field.TypeString, value) + } + if svuo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := svuo.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !svuo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.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 := svuo.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: smlversion.TargetsTable, + Columns: []string{smlversion.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversiontarget.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(svuo.modifiers...) + _node = &SmlVersion{config: svuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, svuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{smlversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + svuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/smlversiontarget.go b/generated/ent/smlversiontarget.go new file mode 100644 index 00000000..b5fb2374 --- /dev/null +++ b/generated/ent/smlversiontarget.go @@ -0,0 +1,154 @@ +// 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/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionTarget is the model entity for the SmlVersionTarget schema. +type SmlVersionTarget struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // VersionID holds the value of the "version_id" field. + VersionID string `json:"version_id,omitempty"` + // TargetName holds the value of the "target_name" field. + TargetName string `json:"target_name,omitempty"` + // Link holds the value of the "link" field. + Link string `json:"link,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the SmlVersionTargetQuery when eager-loading is set. + Edges SmlVersionTargetEdges `json:"edges"` + selectValues sql.SelectValues +} + +// SmlVersionTargetEdges holds the relations/edges for other nodes in the graph. +type SmlVersionTargetEdges struct { + // SmlVersion holds the value of the sml_version edge. + SmlVersion *SmlVersion `json:"sml_version,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// SmlVersionOrErr returns the SmlVersion value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e SmlVersionTargetEdges) SmlVersionOrErr() (*SmlVersion, error) { + if e.loadedTypes[0] { + if e.SmlVersion == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: smlversion.Label} + } + return e.SmlVersion, nil + } + return nil, &NotLoadedError{edge: "sml_version"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*SmlVersionTarget) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case smlversiontarget.FieldID, smlversiontarget.FieldVersionID, smlversiontarget.FieldTargetName, smlversiontarget.FieldLink: + 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 SmlVersionTarget fields. +func (svt *SmlVersionTarget) 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 smlversiontarget.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + svt.ID = value.String + } + case smlversiontarget.FieldVersionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version_id", values[i]) + } else if value.Valid { + svt.VersionID = value.String + } + case smlversiontarget.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 { + svt.TargetName = value.String + } + case smlversiontarget.FieldLink: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field link", values[i]) + } else if value.Valid { + svt.Link = value.String + } + default: + svt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the SmlVersionTarget. +// This includes values selected through modifiers, order, etc. +func (svt *SmlVersionTarget) Value(name string) (ent.Value, error) { + return svt.selectValues.Get(name) +} + +// QuerySmlVersion queries the "sml_version" edge of the SmlVersionTarget entity. +func (svt *SmlVersionTarget) QuerySmlVersion() *SmlVersionQuery { + return NewSmlVersionTargetClient(svt.config).QuerySmlVersion(svt) +} + +// Update returns a builder for updating this SmlVersionTarget. +// Note that you need to call SmlVersionTarget.Unwrap() before calling this method if this SmlVersionTarget +// was returned from a transaction, and the transaction was committed or rolled back. +func (svt *SmlVersionTarget) Update() *SmlVersionTargetUpdateOne { + return NewSmlVersionTargetClient(svt.config).UpdateOne(svt) +} + +// Unwrap unwraps the SmlVersionTarget 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 (svt *SmlVersionTarget) Unwrap() *SmlVersionTarget { + _tx, ok := svt.config.driver.(*txDriver) + if !ok { + panic("ent: SmlVersionTarget is not a transactional entity") + } + svt.config.driver = _tx.drv + return svt +} + +// String implements the fmt.Stringer. +func (svt *SmlVersionTarget) String() string { + var builder strings.Builder + builder.WriteString("SmlVersionTarget(") + builder.WriteString(fmt.Sprintf("id=%v, ", svt.ID)) + builder.WriteString("version_id=") + builder.WriteString(svt.VersionID) + builder.WriteString(", ") + builder.WriteString("target_name=") + builder.WriteString(svt.TargetName) + builder.WriteString(", ") + builder.WriteString("link=") + builder.WriteString(svt.Link) + builder.WriteByte(')') + return builder.String() +} + +// SmlVersionTargets is a parsable slice of SmlVersionTarget. +type SmlVersionTargets []*SmlVersionTarget diff --git a/generated/ent/smlversiontarget/smlversiontarget.go b/generated/ent/smlversiontarget/smlversiontarget.go new file mode 100644 index 00000000..31257e80 --- /dev/null +++ b/generated/ent/smlversiontarget/smlversiontarget.go @@ -0,0 +1,92 @@ +// Code generated by ent, DO NOT EDIT. + +package smlversiontarget + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the smlversiontarget type in the database. + Label = "sml_version_target" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldVersionID holds the string denoting the version_id field in the database. + FieldVersionID = "version_id" + // FieldTargetName holds the string denoting the target_name field in the database. + FieldTargetName = "target_name" + // FieldLink holds the string denoting the link field in the database. + FieldLink = "link" + // EdgeSmlVersion holds the string denoting the sml_version edge name in mutations. + EdgeSmlVersion = "sml_version" + // Table holds the table name of the smlversiontarget in the database. + Table = "sml_version_targets" + // SmlVersionTable is the table that holds the sml_version relation/edge. + SmlVersionTable = "sml_version_targets" + // SmlVersionInverseTable is the table name for the SmlVersion entity. + // It exists in this package in order to avoid circular dependency with the "smlversion" package. + SmlVersionInverseTable = "sml_versions" + // SmlVersionColumn is the table column denoting the sml_version relation/edge. + SmlVersionColumn = "version_id" +) + +// Columns holds all SQL columns for smlversiontarget fields. +var Columns = []string{ + FieldID, + FieldVersionID, + FieldTargetName, + FieldLink, +} + +// 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 SmlVersionTarget 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() +} + +// ByVersionID orders the results by the version_id field. +func ByVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionID, opts...).ToFunc() +} + +// ByTargetName orders the results by the target_name field. +func ByTargetName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTargetName, opts...).ToFunc() +} + +// ByLink orders the results by the link field. +func ByLink(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLink, opts...).ToFunc() +} + +// BySmlVersionField orders the results by sml_version field. +func BySmlVersionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSmlVersionStep(), sql.OrderByField(field, opts...)) + } +} +func newSmlVersionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SmlVersionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SmlVersionTable, SmlVersionColumn), + ) +} diff --git a/generated/ent/smlversiontarget/where.go b/generated/ent/smlversiontarget/where.go new file mode 100644 index 00000000..1f401471 --- /dev/null +++ b/generated/ent/smlversiontarget/where.go @@ -0,0 +1,312 @@ +// Code generated by ent, DO NOT EDIT. + +package smlversiontarget + +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.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContainsFold(FieldID, id)) +} + +// VersionID applies equality check predicate on the "version_id" field. It's identical to VersionIDEQ. +func VersionID(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldVersionID, v)) +} + +// TargetName applies equality check predicate on the "target_name" field. It's identical to TargetNameEQ. +func TargetName(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// Link applies equality check predicate on the "link" field. It's identical to LinkEQ. +func Link(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldLink, v)) +} + +// VersionIDEQ applies the EQ predicate on the "version_id" field. +func VersionIDEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldVersionID, v)) +} + +// VersionIDNEQ applies the NEQ predicate on the "version_id" field. +func VersionIDNEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNEQ(FieldVersionID, v)) +} + +// VersionIDIn applies the In predicate on the "version_id" field. +func VersionIDIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldIn(FieldVersionID, vs...)) +} + +// VersionIDNotIn applies the NotIn predicate on the "version_id" field. +func VersionIDNotIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNotIn(FieldVersionID, vs...)) +} + +// VersionIDGT applies the GT predicate on the "version_id" field. +func VersionIDGT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGT(FieldVersionID, v)) +} + +// VersionIDGTE applies the GTE predicate on the "version_id" field. +func VersionIDGTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGTE(FieldVersionID, v)) +} + +// VersionIDLT applies the LT predicate on the "version_id" field. +func VersionIDLT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLT(FieldVersionID, v)) +} + +// VersionIDLTE applies the LTE predicate on the "version_id" field. +func VersionIDLTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLTE(FieldVersionID, v)) +} + +// VersionIDContains applies the Contains predicate on the "version_id" field. +func VersionIDContains(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContains(FieldVersionID, v)) +} + +// VersionIDHasPrefix applies the HasPrefix predicate on the "version_id" field. +func VersionIDHasPrefix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasPrefix(FieldVersionID, v)) +} + +// VersionIDHasSuffix applies the HasSuffix predicate on the "version_id" field. +func VersionIDHasSuffix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasSuffix(FieldVersionID, v)) +} + +// VersionIDEqualFold applies the EqualFold predicate on the "version_id" field. +func VersionIDEqualFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEqualFold(FieldVersionID, v)) +} + +// VersionIDContainsFold applies the ContainsFold predicate on the "version_id" field. +func VersionIDContainsFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContainsFold(FieldVersionID, v)) +} + +// TargetNameEQ applies the EQ predicate on the "target_name" field. +func TargetNameEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// TargetNameNEQ applies the NEQ predicate on the "target_name" field. +func TargetNameNEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNEQ(FieldTargetName, v)) +} + +// TargetNameIn applies the In predicate on the "target_name" field. +func TargetNameIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldIn(FieldTargetName, vs...)) +} + +// TargetNameNotIn applies the NotIn predicate on the "target_name" field. +func TargetNameNotIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNotIn(FieldTargetName, vs...)) +} + +// TargetNameGT applies the GT predicate on the "target_name" field. +func TargetNameGT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGT(FieldTargetName, v)) +} + +// TargetNameGTE applies the GTE predicate on the "target_name" field. +func TargetNameGTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGTE(FieldTargetName, v)) +} + +// TargetNameLT applies the LT predicate on the "target_name" field. +func TargetNameLT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLT(FieldTargetName, v)) +} + +// TargetNameLTE applies the LTE predicate on the "target_name" field. +func TargetNameLTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLTE(FieldTargetName, v)) +} + +// TargetNameContains applies the Contains predicate on the "target_name" field. +func TargetNameContains(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContains(FieldTargetName, v)) +} + +// TargetNameHasPrefix applies the HasPrefix predicate on the "target_name" field. +func TargetNameHasPrefix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasPrefix(FieldTargetName, v)) +} + +// TargetNameHasSuffix applies the HasSuffix predicate on the "target_name" field. +func TargetNameHasSuffix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasSuffix(FieldTargetName, v)) +} + +// TargetNameEqualFold applies the EqualFold predicate on the "target_name" field. +func TargetNameEqualFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEqualFold(FieldTargetName, v)) +} + +// TargetNameContainsFold applies the ContainsFold predicate on the "target_name" field. +func TargetNameContainsFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContainsFold(FieldTargetName, v)) +} + +// LinkEQ applies the EQ predicate on the "link" field. +func LinkEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEQ(FieldLink, v)) +} + +// LinkNEQ applies the NEQ predicate on the "link" field. +func LinkNEQ(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNEQ(FieldLink, v)) +} + +// LinkIn applies the In predicate on the "link" field. +func LinkIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldIn(FieldLink, vs...)) +} + +// LinkNotIn applies the NotIn predicate on the "link" field. +func LinkNotIn(vs ...string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldNotIn(FieldLink, vs...)) +} + +// LinkGT applies the GT predicate on the "link" field. +func LinkGT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGT(FieldLink, v)) +} + +// LinkGTE applies the GTE predicate on the "link" field. +func LinkGTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldGTE(FieldLink, v)) +} + +// LinkLT applies the LT predicate on the "link" field. +func LinkLT(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLT(FieldLink, v)) +} + +// LinkLTE applies the LTE predicate on the "link" field. +func LinkLTE(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldLTE(FieldLink, v)) +} + +// LinkContains applies the Contains predicate on the "link" field. +func LinkContains(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContains(FieldLink, v)) +} + +// LinkHasPrefix applies the HasPrefix predicate on the "link" field. +func LinkHasPrefix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasPrefix(FieldLink, v)) +} + +// LinkHasSuffix applies the HasSuffix predicate on the "link" field. +func LinkHasSuffix(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldHasSuffix(FieldLink, v)) +} + +// LinkEqualFold applies the EqualFold predicate on the "link" field. +func LinkEqualFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldEqualFold(FieldLink, v)) +} + +// LinkContainsFold applies the ContainsFold predicate on the "link" field. +func LinkContainsFold(v string) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.FieldContainsFold(FieldLink, v)) +} + +// HasSmlVersion applies the HasEdge predicate on the "sml_version" edge. +func HasSmlVersion() predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SmlVersionTable, SmlVersionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSmlVersionWith applies the HasEdge predicate on the "sml_version" edge with a given conditions (other predicates). +func HasSmlVersionWith(preds ...predicate.SmlVersion) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(func(s *sql.Selector) { + step := newSmlVersionStep() + 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.SmlVersionTarget) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.SmlVersionTarget) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.SmlVersionTarget) predicate.SmlVersionTarget { + return predicate.SmlVersionTarget(sql.NotPredicates(p)) +} diff --git a/generated/ent/smlversiontarget_create.go b/generated/ent/smlversiontarget_create.go new file mode 100644 index 00000000..09d7f040 --- /dev/null +++ b/generated/ent/smlversiontarget_create.go @@ -0,0 +1,266 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionTargetCreate is the builder for creating a SmlVersionTarget entity. +type SmlVersionTargetCreate struct { + config + mutation *SmlVersionTargetMutation + hooks []Hook +} + +// SetVersionID sets the "version_id" field. +func (svtc *SmlVersionTargetCreate) SetVersionID(s string) *SmlVersionTargetCreate { + svtc.mutation.SetVersionID(s) + return svtc +} + +// SetTargetName sets the "target_name" field. +func (svtc *SmlVersionTargetCreate) SetTargetName(s string) *SmlVersionTargetCreate { + svtc.mutation.SetTargetName(s) + return svtc +} + +// SetLink sets the "link" field. +func (svtc *SmlVersionTargetCreate) SetLink(s string) *SmlVersionTargetCreate { + svtc.mutation.SetLink(s) + return svtc +} + +// SetID sets the "id" field. +func (svtc *SmlVersionTargetCreate) SetID(s string) *SmlVersionTargetCreate { + svtc.mutation.SetID(s) + return svtc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (svtc *SmlVersionTargetCreate) SetNillableID(s *string) *SmlVersionTargetCreate { + if s != nil { + svtc.SetID(*s) + } + return svtc +} + +// SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by ID. +func (svtc *SmlVersionTargetCreate) SetSmlVersionID(id string) *SmlVersionTargetCreate { + svtc.mutation.SetSmlVersionID(id) + return svtc +} + +// SetSmlVersion sets the "sml_version" edge to the SmlVersion entity. +func (svtc *SmlVersionTargetCreate) SetSmlVersion(s *SmlVersion) *SmlVersionTargetCreate { + return svtc.SetSmlVersionID(s.ID) +} + +// Mutation returns the SmlVersionTargetMutation object of the builder. +func (svtc *SmlVersionTargetCreate) Mutation() *SmlVersionTargetMutation { + return svtc.mutation +} + +// Save creates the SmlVersionTarget in the database. +func (svtc *SmlVersionTargetCreate) Save(ctx context.Context) (*SmlVersionTarget, error) { + svtc.defaults() + return withHooks(ctx, svtc.sqlSave, svtc.mutation, svtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (svtc *SmlVersionTargetCreate) SaveX(ctx context.Context) *SmlVersionTarget { + v, err := svtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (svtc *SmlVersionTargetCreate) Exec(ctx context.Context) error { + _, err := svtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtc *SmlVersionTargetCreate) ExecX(ctx context.Context) { + if err := svtc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (svtc *SmlVersionTargetCreate) defaults() { + if _, ok := svtc.mutation.ID(); !ok { + v := smlversiontarget.DefaultID() + svtc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (svtc *SmlVersionTargetCreate) check() error { + if _, ok := svtc.mutation.VersionID(); !ok { + return &ValidationError{Name: "version_id", err: errors.New(`ent: missing required field "SmlVersionTarget.version_id"`)} + } + if _, ok := svtc.mutation.TargetName(); !ok { + return &ValidationError{Name: "target_name", err: errors.New(`ent: missing required field "SmlVersionTarget.target_name"`)} + } + if _, ok := svtc.mutation.Link(); !ok { + return &ValidationError{Name: "link", err: errors.New(`ent: missing required field "SmlVersionTarget.link"`)} + } + if _, ok := svtc.mutation.SmlVersionID(); !ok { + return &ValidationError{Name: "sml_version", err: errors.New(`ent: missing required edge "SmlVersionTarget.sml_version"`)} + } + return nil +} + +func (svtc *SmlVersionTargetCreate) sqlSave(ctx context.Context) (*SmlVersionTarget, error) { + if err := svtc.check(); err != nil { + return nil, err + } + _node, _spec := svtc.createSpec() + if err := sqlgraph.CreateNode(ctx, svtc.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 SmlVersionTarget.ID type: %T", _spec.ID.Value) + } + } + svtc.mutation.id = &_node.ID + svtc.mutation.done = true + return _node, nil +} + +func (svtc *SmlVersionTargetCreate) createSpec() (*SmlVersionTarget, *sqlgraph.CreateSpec) { + var ( + _node = &SmlVersionTarget{config: svtc.config} + _spec = sqlgraph.NewCreateSpec(smlversiontarget.Table, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) + ) + if id, ok := svtc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := svtc.mutation.TargetName(); ok { + _spec.SetField(smlversiontarget.FieldTargetName, field.TypeString, value) + _node.TargetName = value + } + if value, ok := svtc.mutation.Link(); ok { + _spec.SetField(smlversiontarget.FieldLink, field.TypeString, value) + _node.Link = value + } + if nodes := svtc.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: smlversiontarget.SmlVersionTable, + Columns: []string{smlversiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.VersionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SmlVersionTargetCreateBulk is the builder for creating many SmlVersionTarget entities in bulk. +type SmlVersionTargetCreateBulk struct { + config + err error + builders []*SmlVersionTargetCreate +} + +// Save creates the SmlVersionTarget entities in the database. +func (svtcb *SmlVersionTargetCreateBulk) Save(ctx context.Context) ([]*SmlVersionTarget, error) { + if svtcb.err != nil { + return nil, svtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(svtcb.builders)) + nodes := make([]*SmlVersionTarget, len(svtcb.builders)) + mutators := make([]Mutator, len(svtcb.builders)) + for i := range svtcb.builders { + func(i int, root context.Context) { + builder := svtcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*SmlVersionTargetMutation) + 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, svtcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, svtcb.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, svtcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (svtcb *SmlVersionTargetCreateBulk) SaveX(ctx context.Context) []*SmlVersionTarget { + v, err := svtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (svtcb *SmlVersionTargetCreateBulk) Exec(ctx context.Context) error { + _, err := svtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtcb *SmlVersionTargetCreateBulk) ExecX(ctx context.Context) { + if err := svtcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/smlversiontarget_delete.go b/generated/ent/smlversiontarget_delete.go new file mode 100644 index 00000000..1ecfb3d9 --- /dev/null +++ b/generated/ent/smlversiontarget_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionTargetDelete is the builder for deleting a SmlVersionTarget entity. +type SmlVersionTargetDelete struct { + config + hooks []Hook + mutation *SmlVersionTargetMutation +} + +// Where appends a list predicates to the SmlVersionTargetDelete builder. +func (svtd *SmlVersionTargetDelete) Where(ps ...predicate.SmlVersionTarget) *SmlVersionTargetDelete { + svtd.mutation.Where(ps...) + return svtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (svtd *SmlVersionTargetDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, svtd.sqlExec, svtd.mutation, svtd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtd *SmlVersionTargetDelete) ExecX(ctx context.Context) int { + n, err := svtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (svtd *SmlVersionTargetDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(smlversiontarget.Table, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) + if ps := svtd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, svtd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + svtd.mutation.done = true + return affected, err +} + +// SmlVersionTargetDeleteOne is the builder for deleting a single SmlVersionTarget entity. +type SmlVersionTargetDeleteOne struct { + svtd *SmlVersionTargetDelete +} + +// Where appends a list predicates to the SmlVersionTargetDelete builder. +func (svtdo *SmlVersionTargetDeleteOne) Where(ps ...predicate.SmlVersionTarget) *SmlVersionTargetDeleteOne { + svtdo.svtd.mutation.Where(ps...) + return svtdo +} + +// Exec executes the deletion query. +func (svtdo *SmlVersionTargetDeleteOne) Exec(ctx context.Context) error { + n, err := svtdo.svtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{smlversiontarget.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtdo *SmlVersionTargetDeleteOne) ExecX(ctx context.Context) { + if err := svtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/smlversiontarget_query.go b/generated/ent/smlversiontarget_query.go new file mode 100644 index 00000000..4ba6ca3f --- /dev/null +++ b/generated/ent/smlversiontarget_query.go @@ -0,0 +1,627 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionTargetQuery is the builder for querying SmlVersionTarget entities. +type SmlVersionTargetQuery struct { + config + ctx *QueryContext + order []smlversiontarget.OrderOption + inters []Interceptor + predicates []predicate.SmlVersionTarget + withSmlVersion *SmlVersionQuery + 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 SmlVersionTargetQuery builder. +func (svtq *SmlVersionTargetQuery) Where(ps ...predicate.SmlVersionTarget) *SmlVersionTargetQuery { + svtq.predicates = append(svtq.predicates, ps...) + return svtq +} + +// Limit the number of records to be returned by this query. +func (svtq *SmlVersionTargetQuery) Limit(limit int) *SmlVersionTargetQuery { + svtq.ctx.Limit = &limit + return svtq +} + +// Offset to start from. +func (svtq *SmlVersionTargetQuery) Offset(offset int) *SmlVersionTargetQuery { + svtq.ctx.Offset = &offset + return svtq +} + +// 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 (svtq *SmlVersionTargetQuery) Unique(unique bool) *SmlVersionTargetQuery { + svtq.ctx.Unique = &unique + return svtq +} + +// Order specifies how the records should be ordered. +func (svtq *SmlVersionTargetQuery) Order(o ...smlversiontarget.OrderOption) *SmlVersionTargetQuery { + svtq.order = append(svtq.order, o...) + return svtq +} + +// QuerySmlVersion chains the current query on the "sml_version" edge. +func (svtq *SmlVersionTargetQuery) QuerySmlVersion() *SmlVersionQuery { + query := (&SmlVersionClient{config: svtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := svtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := svtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(smlversiontarget.Table, smlversiontarget.FieldID, selector), + sqlgraph.To(smlversion.Table, smlversion.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, smlversiontarget.SmlVersionTable, smlversiontarget.SmlVersionColumn), + ) + fromU = sqlgraph.SetNeighbors(svtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first SmlVersionTarget entity from the query. +// Returns a *NotFoundError when no SmlVersionTarget was found. +func (svtq *SmlVersionTargetQuery) First(ctx context.Context) (*SmlVersionTarget, error) { + nodes, err := svtq.Limit(1).All(setContextOp(ctx, svtq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{smlversiontarget.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) FirstX(ctx context.Context) *SmlVersionTarget { + node, err := svtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first SmlVersionTarget ID from the query. +// Returns a *NotFoundError when no SmlVersionTarget ID was found. +func (svtq *SmlVersionTargetQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = svtq.Limit(1).IDs(setContextOp(ctx, svtq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{smlversiontarget.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) FirstIDX(ctx context.Context) string { + id, err := svtq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single SmlVersionTarget entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one SmlVersionTarget entity is found. +// Returns a *NotFoundError when no SmlVersionTarget entities are found. +func (svtq *SmlVersionTargetQuery) Only(ctx context.Context) (*SmlVersionTarget, error) { + nodes, err := svtq.Limit(2).All(setContextOp(ctx, svtq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{smlversiontarget.Label} + default: + return nil, &NotSingularError{smlversiontarget.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) OnlyX(ctx context.Context) *SmlVersionTarget { + node, err := svtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only SmlVersionTarget ID in the query. +// Returns a *NotSingularError when more than one SmlVersionTarget ID is found. +// Returns a *NotFoundError when no entities are found. +func (svtq *SmlVersionTargetQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = svtq.Limit(2).IDs(setContextOp(ctx, svtq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{smlversiontarget.Label} + default: + err = &NotSingularError{smlversiontarget.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) OnlyIDX(ctx context.Context) string { + id, err := svtq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of SmlVersionTargets. +func (svtq *SmlVersionTargetQuery) All(ctx context.Context) ([]*SmlVersionTarget, error) { + ctx = setContextOp(ctx, svtq.ctx, "All") + if err := svtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*SmlVersionTarget, *SmlVersionTargetQuery]() + return withInterceptors[[]*SmlVersionTarget](ctx, svtq, qr, svtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) AllX(ctx context.Context) []*SmlVersionTarget { + nodes, err := svtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of SmlVersionTarget IDs. +func (svtq *SmlVersionTargetQuery) IDs(ctx context.Context) (ids []string, err error) { + if svtq.ctx.Unique == nil && svtq.path != nil { + svtq.Unique(true) + } + ctx = setContextOp(ctx, svtq.ctx, "IDs") + if err = svtq.Select(smlversiontarget.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) IDsX(ctx context.Context) []string { + ids, err := svtq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (svtq *SmlVersionTargetQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, svtq.ctx, "Count") + if err := svtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, svtq, querierCount[*SmlVersionTargetQuery](), svtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (svtq *SmlVersionTargetQuery) CountX(ctx context.Context) int { + count, err := svtq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (svtq *SmlVersionTargetQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, svtq.ctx, "Exist") + switch _, err := svtq.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 (svtq *SmlVersionTargetQuery) ExistX(ctx context.Context) bool { + exist, err := svtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the SmlVersionTargetQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (svtq *SmlVersionTargetQuery) Clone() *SmlVersionTargetQuery { + if svtq == nil { + return nil + } + return &SmlVersionTargetQuery{ + config: svtq.config, + ctx: svtq.ctx.Clone(), + order: append([]smlversiontarget.OrderOption{}, svtq.order...), + inters: append([]Interceptor{}, svtq.inters...), + predicates: append([]predicate.SmlVersionTarget{}, svtq.predicates...), + withSmlVersion: svtq.withSmlVersion.Clone(), + // clone intermediate query. + sql: svtq.sql.Clone(), + path: svtq.path, + } +} + +// WithSmlVersion tells the query-builder to eager-load the nodes that are connected to +// the "sml_version" edge. The optional arguments are used to configure the query builder of the edge. +func (svtq *SmlVersionTargetQuery) WithSmlVersion(opts ...func(*SmlVersionQuery)) *SmlVersionTargetQuery { + query := (&SmlVersionClient{config: svtq.config}).Query() + for _, opt := range opts { + opt(query) + } + svtq.withSmlVersion = query + return svtq +} + +// 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 { +// VersionID string `json:"version_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.SmlVersionTarget.Query(). +// GroupBy(smlversiontarget.FieldVersionID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (svtq *SmlVersionTargetQuery) GroupBy(field string, fields ...string) *SmlVersionTargetGroupBy { + svtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &SmlVersionTargetGroupBy{build: svtq} + grbuild.flds = &svtq.ctx.Fields + grbuild.label = smlversiontarget.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 { +// VersionID string `json:"version_id,omitempty"` +// } +// +// client.SmlVersionTarget.Query(). +// Select(smlversiontarget.FieldVersionID). +// Scan(ctx, &v) +func (svtq *SmlVersionTargetQuery) Select(fields ...string) *SmlVersionTargetSelect { + svtq.ctx.Fields = append(svtq.ctx.Fields, fields...) + sbuild := &SmlVersionTargetSelect{SmlVersionTargetQuery: svtq} + sbuild.label = smlversiontarget.Label + sbuild.flds, sbuild.scan = &svtq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a SmlVersionTargetSelect configured with the given aggregations. +func (svtq *SmlVersionTargetQuery) Aggregate(fns ...AggregateFunc) *SmlVersionTargetSelect { + return svtq.Select().Aggregate(fns...) +} + +func (svtq *SmlVersionTargetQuery) prepareQuery(ctx context.Context) error { + for _, inter := range svtq.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, svtq); err != nil { + return err + } + } + } + for _, f := range svtq.ctx.Fields { + if !smlversiontarget.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if svtq.path != nil { + prev, err := svtq.path(ctx) + if err != nil { + return err + } + svtq.sql = prev + } + return nil +} + +func (svtq *SmlVersionTargetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SmlVersionTarget, error) { + var ( + nodes = []*SmlVersionTarget{} + _spec = svtq.querySpec() + loadedTypes = [1]bool{ + svtq.withSmlVersion != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*SmlVersionTarget).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &SmlVersionTarget{config: svtq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(svtq.modifiers) > 0 { + _spec.Modifiers = svtq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, svtq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := svtq.withSmlVersion; query != nil { + if err := svtq.loadSmlVersion(ctx, query, nodes, nil, + func(n *SmlVersionTarget, e *SmlVersion) { n.Edges.SmlVersion = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (svtq *SmlVersionTargetQuery) loadSmlVersion(ctx context.Context, query *SmlVersionQuery, nodes []*SmlVersionTarget, init func(*SmlVersionTarget), assign func(*SmlVersionTarget, *SmlVersion)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*SmlVersionTarget) + for i := range nodes { + fk := nodes[i].VersionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(smlversion.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 "version_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (svtq *SmlVersionTargetQuery) sqlCount(ctx context.Context) (int, error) { + _spec := svtq.querySpec() + if len(svtq.modifiers) > 0 { + _spec.Modifiers = svtq.modifiers + } + _spec.Node.Columns = svtq.ctx.Fields + if len(svtq.ctx.Fields) > 0 { + _spec.Unique = svtq.ctx.Unique != nil && *svtq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, svtq.driver, _spec) +} + +func (svtq *SmlVersionTargetQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(smlversiontarget.Table, smlversiontarget.Columns, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) + _spec.From = svtq.sql + if unique := svtq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if svtq.path != nil { + _spec.Unique = true + } + if fields := svtq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, smlversiontarget.FieldID) + for i := range fields { + if fields[i] != smlversiontarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if svtq.withSmlVersion != nil { + _spec.Node.AddColumnOnce(smlversiontarget.FieldVersionID) + } + } + if ps := svtq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := svtq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := svtq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := svtq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (svtq *SmlVersionTargetQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(svtq.driver.Dialect()) + t1 := builder.Table(smlversiontarget.Table) + columns := svtq.ctx.Fields + if len(columns) == 0 { + columns = smlversiontarget.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if svtq.sql != nil { + selector = svtq.sql + selector.Select(selector.Columns(columns...)...) + } + if svtq.ctx.Unique != nil && *svtq.ctx.Unique { + selector.Distinct() + } + for _, m := range svtq.modifiers { + m(selector) + } + for _, p := range svtq.predicates { + p(selector) + } + for _, p := range svtq.order { + p(selector) + } + if offset := svtq.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 := svtq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (svtq *SmlVersionTargetQuery) Modify(modifiers ...func(s *sql.Selector)) *SmlVersionTargetSelect { + svtq.modifiers = append(svtq.modifiers, modifiers...) + return svtq.Select() +} + +// SmlVersionTargetGroupBy is the group-by builder for SmlVersionTarget entities. +type SmlVersionTargetGroupBy struct { + selector + build *SmlVersionTargetQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (svtgb *SmlVersionTargetGroupBy) Aggregate(fns ...AggregateFunc) *SmlVersionTargetGroupBy { + svtgb.fns = append(svtgb.fns, fns...) + return svtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (svtgb *SmlVersionTargetGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, svtgb.build.ctx, "GroupBy") + if err := svtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SmlVersionTargetQuery, *SmlVersionTargetGroupBy](ctx, svtgb.build, svtgb, svtgb.build.inters, v) +} + +func (svtgb *SmlVersionTargetGroupBy) sqlScan(ctx context.Context, root *SmlVersionTargetQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(svtgb.fns)) + for _, fn := range svtgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*svtgb.flds)+len(svtgb.fns)) + for _, f := range *svtgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*svtgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := svtgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// SmlVersionTargetSelect is the builder for selecting fields of SmlVersionTarget entities. +type SmlVersionTargetSelect struct { + *SmlVersionTargetQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (svts *SmlVersionTargetSelect) Aggregate(fns ...AggregateFunc) *SmlVersionTargetSelect { + svts.fns = append(svts.fns, fns...) + return svts +} + +// Scan applies the selector query and scans the result into the given value. +func (svts *SmlVersionTargetSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, svts.ctx, "Select") + if err := svts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SmlVersionTargetQuery, *SmlVersionTargetSelect](ctx, svts.SmlVersionTargetQuery, svts, svts.inters, v) +} + +func (svts *SmlVersionTargetSelect) sqlScan(ctx context.Context, root *SmlVersionTargetQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(svts.fns)) + for _, fn := range svts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*svts.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 := svts.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 (svts *SmlVersionTargetSelect) Modify(modifiers ...func(s *sql.Selector)) *SmlVersionTargetSelect { + svts.modifiers = append(svts.modifiers, modifiers...) + return svts +} diff --git a/generated/ent/smlversiontarget_update.go b/generated/ent/smlversiontarget_update.go new file mode 100644 index 00000000..94bcffab --- /dev/null +++ b/generated/ent/smlversiontarget_update.go @@ -0,0 +1,354 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" +) + +// SmlVersionTargetUpdate is the builder for updating SmlVersionTarget entities. +type SmlVersionTargetUpdate struct { + config + hooks []Hook + mutation *SmlVersionTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the SmlVersionTargetUpdate builder. +func (svtu *SmlVersionTargetUpdate) Where(ps ...predicate.SmlVersionTarget) *SmlVersionTargetUpdate { + svtu.mutation.Where(ps...) + return svtu +} + +// SetVersionID sets the "version_id" field. +func (svtu *SmlVersionTargetUpdate) SetVersionID(s string) *SmlVersionTargetUpdate { + svtu.mutation.SetVersionID(s) + return svtu +} + +// SetTargetName sets the "target_name" field. +func (svtu *SmlVersionTargetUpdate) SetTargetName(s string) *SmlVersionTargetUpdate { + svtu.mutation.SetTargetName(s) + return svtu +} + +// SetLink sets the "link" field. +func (svtu *SmlVersionTargetUpdate) SetLink(s string) *SmlVersionTargetUpdate { + svtu.mutation.SetLink(s) + return svtu +} + +// SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by ID. +func (svtu *SmlVersionTargetUpdate) SetSmlVersionID(id string) *SmlVersionTargetUpdate { + svtu.mutation.SetSmlVersionID(id) + return svtu +} + +// SetSmlVersion sets the "sml_version" edge to the SmlVersion entity. +func (svtu *SmlVersionTargetUpdate) SetSmlVersion(s *SmlVersion) *SmlVersionTargetUpdate { + return svtu.SetSmlVersionID(s.ID) +} + +// Mutation returns the SmlVersionTargetMutation object of the builder. +func (svtu *SmlVersionTargetUpdate) Mutation() *SmlVersionTargetMutation { + return svtu.mutation +} + +// ClearSmlVersion clears the "sml_version" edge to the SmlVersion entity. +func (svtu *SmlVersionTargetUpdate) ClearSmlVersion() *SmlVersionTargetUpdate { + svtu.mutation.ClearSmlVersion() + return svtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (svtu *SmlVersionTargetUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, svtu.sqlSave, svtu.mutation, svtu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (svtu *SmlVersionTargetUpdate) SaveX(ctx context.Context) int { + affected, err := svtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (svtu *SmlVersionTargetUpdate) Exec(ctx context.Context) error { + _, err := svtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtu *SmlVersionTargetUpdate) ExecX(ctx context.Context) { + if err := svtu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (svtu *SmlVersionTargetUpdate) check() error { + if _, ok := svtu.mutation.SmlVersionID(); svtu.mutation.SmlVersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "SmlVersionTarget.sml_version"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (svtu *SmlVersionTargetUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SmlVersionTargetUpdate { + svtu.modifiers = append(svtu.modifiers, modifiers...) + return svtu +} + +func (svtu *SmlVersionTargetUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := svtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(smlversiontarget.Table, smlversiontarget.Columns, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) + if ps := svtu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := svtu.mutation.TargetName(); ok { + _spec.SetField(smlversiontarget.FieldTargetName, field.TypeString, value) + } + if value, ok := svtu.mutation.Link(); ok { + _spec.SetField(smlversiontarget.FieldLink, field.TypeString, value) + } + if svtu.mutation.SmlVersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: smlversiontarget.SmlVersionTable, + Columns: []string{smlversiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := svtu.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: smlversiontarget.SmlVersionTable, + Columns: []string{smlversiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversion.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(svtu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, svtu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{smlversiontarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + svtu.mutation.done = true + return n, nil +} + +// SmlVersionTargetUpdateOne is the builder for updating a single SmlVersionTarget entity. +type SmlVersionTargetUpdateOne struct { + config + fields []string + hooks []Hook + mutation *SmlVersionTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetVersionID sets the "version_id" field. +func (svtuo *SmlVersionTargetUpdateOne) SetVersionID(s string) *SmlVersionTargetUpdateOne { + svtuo.mutation.SetVersionID(s) + return svtuo +} + +// SetTargetName sets the "target_name" field. +func (svtuo *SmlVersionTargetUpdateOne) SetTargetName(s string) *SmlVersionTargetUpdateOne { + svtuo.mutation.SetTargetName(s) + return svtuo +} + +// SetLink sets the "link" field. +func (svtuo *SmlVersionTargetUpdateOne) SetLink(s string) *SmlVersionTargetUpdateOne { + svtuo.mutation.SetLink(s) + return svtuo +} + +// SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by ID. +func (svtuo *SmlVersionTargetUpdateOne) SetSmlVersionID(id string) *SmlVersionTargetUpdateOne { + svtuo.mutation.SetSmlVersionID(id) + return svtuo +} + +// SetSmlVersion sets the "sml_version" edge to the SmlVersion entity. +func (svtuo *SmlVersionTargetUpdateOne) SetSmlVersion(s *SmlVersion) *SmlVersionTargetUpdateOne { + return svtuo.SetSmlVersionID(s.ID) +} + +// Mutation returns the SmlVersionTargetMutation object of the builder. +func (svtuo *SmlVersionTargetUpdateOne) Mutation() *SmlVersionTargetMutation { + return svtuo.mutation +} + +// ClearSmlVersion clears the "sml_version" edge to the SmlVersion entity. +func (svtuo *SmlVersionTargetUpdateOne) ClearSmlVersion() *SmlVersionTargetUpdateOne { + svtuo.mutation.ClearSmlVersion() + return svtuo +} + +// Where appends a list predicates to the SmlVersionTargetUpdate builder. +func (svtuo *SmlVersionTargetUpdateOne) Where(ps ...predicate.SmlVersionTarget) *SmlVersionTargetUpdateOne { + svtuo.mutation.Where(ps...) + return svtuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (svtuo *SmlVersionTargetUpdateOne) Select(field string, fields ...string) *SmlVersionTargetUpdateOne { + svtuo.fields = append([]string{field}, fields...) + return svtuo +} + +// Save executes the query and returns the updated SmlVersionTarget entity. +func (svtuo *SmlVersionTargetUpdateOne) Save(ctx context.Context) (*SmlVersionTarget, error) { + return withHooks(ctx, svtuo.sqlSave, svtuo.mutation, svtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (svtuo *SmlVersionTargetUpdateOne) SaveX(ctx context.Context) *SmlVersionTarget { + node, err := svtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (svtuo *SmlVersionTargetUpdateOne) Exec(ctx context.Context) error { + _, err := svtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (svtuo *SmlVersionTargetUpdateOne) ExecX(ctx context.Context) { + if err := svtuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (svtuo *SmlVersionTargetUpdateOne) check() error { + if _, ok := svtuo.mutation.SmlVersionID(); svtuo.mutation.SmlVersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "SmlVersionTarget.sml_version"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (svtuo *SmlVersionTargetUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SmlVersionTargetUpdateOne { + svtuo.modifiers = append(svtuo.modifiers, modifiers...) + return svtuo +} + +func (svtuo *SmlVersionTargetUpdateOne) sqlSave(ctx context.Context) (_node *SmlVersionTarget, err error) { + if err := svtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(smlversiontarget.Table, smlversiontarget.Columns, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) + id, ok := svtuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SmlVersionTarget.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := svtuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, smlversiontarget.FieldID) + for _, f := range fields { + if !smlversiontarget.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != smlversiontarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := svtuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := svtuo.mutation.TargetName(); ok { + _spec.SetField(smlversiontarget.FieldTargetName, field.TypeString, value) + } + if value, ok := svtuo.mutation.Link(); ok { + _spec.SetField(smlversiontarget.FieldLink, field.TypeString, value) + } + if svtuo.mutation.SmlVersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: smlversiontarget.SmlVersionTable, + Columns: []string{smlversiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := svtuo.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: smlversiontarget.SmlVersionTable, + Columns: []string{smlversiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(smlversion.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(svtuo.modifiers...) + _node = &SmlVersionTarget{config: svtuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, svtuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{smlversiontarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + svtuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/tag.go b/generated/ent/tag.go new file mode 100644 index 00000000..2ebf8da4 --- /dev/null +++ b/generated/ent/tag.go @@ -0,0 +1,211 @@ +// 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/tag" +) + +// Tag is the model entity for the Tag schema. +type Tag 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the TagQuery when eager-loading is set. + Edges TagEdges `json:"edges"` + selectValues sql.SelectValues +} + +// TagEdges holds the relations/edges for other nodes in the graph. +type TagEdges struct { + // Mods holds the value of the mods edge. + Mods []*Mod `json:"mods,omitempty"` + // Guides holds the value of the guides edge. + Guides []*Guide `json:"guides,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"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// ModsOrErr returns the Mods value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) ModsOrErr() ([]*Mod, error) { + if e.loadedTypes[0] { + return e.Mods, nil + } + return nil, &NotLoadedError{edge: "mods"} +} + +// GuidesOrErr returns the Guides value or an error if the edge +// was not loaded in eager-loading. +func (e TagEdges) GuidesOrErr() ([]*Guide, error) { + if e.loadedTypes[1] { + return e.Guides, nil + } + return nil, &NotLoadedError{edge: "guides"} +} + +// 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] { + return e.ModTags, nil + } + return nil, &NotLoadedError{edge: "mod_tags"} +} + +// 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] { + return e.GuideTags, nil + } + return nil, &NotLoadedError{edge: "guide_tags"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Tag) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case tag.FieldID, tag.FieldName: + values[i] = new(sql.NullString) + case tag.FieldCreatedAt, tag.FieldUpdatedAt, tag.FieldDeletedAt: + 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 Tag fields. +func (t *Tag) 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 tag.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + t.ID = value.String + } + case tag.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 { + t.CreatedAt = value.Time + } + case tag.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 { + t.UpdatedAt = value.Time + } + case tag.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + t.DeletedAt = value.Time + } + case tag.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + t.Name = value.String + } + default: + t.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Tag. +// This includes values selected through modifiers, order, etc. +func (t *Tag) Value(name string) (ent.Value, error) { + return t.selectValues.Get(name) +} + +// QueryMods queries the "mods" edge of the Tag entity. +func (t *Tag) QueryMods() *ModQuery { + return NewTagClient(t.config).QueryMods(t) +} + +// QueryGuides queries the "guides" edge of the Tag entity. +func (t *Tag) QueryGuides() *GuideQuery { + return NewTagClient(t.config).QueryGuides(t) +} + +// QueryModTags queries the "mod_tags" edge of the Tag entity. +func (t *Tag) QueryModTags() *ModTagQuery { + return NewTagClient(t.config).QueryModTags(t) +} + +// QueryGuideTags queries the "guide_tags" edge of the Tag entity. +func (t *Tag) QueryGuideTags() *GuideTagQuery { + return NewTagClient(t.config).QueryGuideTags(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. +func (t *Tag) Update() *TagUpdateOne { + return NewTagClient(t.config).UpdateOne(t) +} + +// Unwrap unwraps the Tag 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 (t *Tag) Unwrap() *Tag { + _tx, ok := t.config.driver.(*txDriver) + if !ok { + panic("ent: Tag is not a transactional entity") + } + t.config.driver = _tx.drv + return t +} + +// String implements the fmt.Stringer. +func (t *Tag) String() string { + var builder strings.Builder + builder.WriteString("Tag(") + builder.WriteString(fmt.Sprintf("id=%v, ", t.ID)) + builder.WriteString("created_at=") + builder.WriteString(t.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(t.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(t.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(t.Name) + builder.WriteByte(')') + return builder.String() +} + +// Tags is a parsable slice of Tag. +type Tags []*Tag diff --git a/generated/ent/tag/tag.go b/generated/ent/tag/tag.go new file mode 100644 index 00000000..aea3e0e8 --- /dev/null +++ b/generated/ent/tag/tag.go @@ -0,0 +1,220 @@ +// Code generated by ent, DO NOT EDIT. + +package tag + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the tag type in the database. + Label = "tag" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // EdgeMods holds the string denoting the mods edge name in mutations. + EdgeMods = "mods" + // EdgeGuides holds the string denoting the guides edge name in mutations. + EdgeGuides = "guides" + // 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" + // 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. + ModsTable = "mod_tags" + // 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" + // GuidesTable is the table that holds the guides relation/edge. The primary key declared below. + GuidesTable = "guide_tags" + // 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" + // ModTagsTable is the table that holds the mod_tags relation/edge. + ModTagsTable = "mod_tags" + // ModTagsInverseTable is the table name for the ModTag entity. + // It exists in this package in order to avoid circular dependency with the "modtag" package. + ModTagsInverseTable = "mod_tags" + // ModTagsColumn is the table column denoting the mod_tags relation/edge. + ModTagsColumn = "tag_id" + // GuideTagsTable is the table that holds the guide_tags relation/edge. + GuideTagsTable = "guide_tags" + // GuideTagsInverseTable is the table name for the GuideTag entity. + // It exists in this package in order to avoid circular dependency with the "guidetag" package. + GuideTagsInverseTable = "guide_tags" + // GuideTagsColumn is the table column denoting the guide_tags relation/edge. + GuideTagsColumn = "tag_id" +) + +// Columns holds all SQL columns for tag fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, +} + +var ( + // ModsPrimaryKey and ModsColumn2 are the table columns denoting the + // primary key for the mods relation (M2M). + ModsPrimaryKey = []string{"mod_id", "tag_id"} + // GuidesPrimaryKey and GuidesColumn2 are the table columns denoting the + // primary key for the guides relation (M2M). + GuidesPrimaryKey = []string{"guide_tag", "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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the Tag 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// 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...)...) + } +} + +// ByGuidesCount orders the results by guides count. +func ByGuidesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newGuidesStep(), opts...) + } +} + +// ByGuides orders the results by guides terms. +func ByGuides(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGuidesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByModTagsCount orders the results by mod_tags count. +func ByModTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newModTagsStep(), opts...) + } +} + +// ByModTags orders the results by mod_tags terms. +func ByModTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newModTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByGuideTagsCount orders the results by guide_tags count. +func ByGuideTagsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newGuideTagsStep(), opts...) + } +} + +// ByGuideTags orders the results by guide_tags terms. +func ByGuideTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGuideTagsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ModsTable, ModsPrimaryKey...), + ) +} +func newGuidesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GuidesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, GuidesTable, GuidesPrimaryKey...), + ) +} +func newModTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModTagsInverseTable, ModTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, ModTagsTable, ModTagsColumn), + ) +} +func newGuideTagsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GuideTagsInverseTable, GuideTagsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, GuideTagsTable, GuideTagsColumn), + ) +} diff --git a/generated/ent/tag/where.go b/generated/ent/tag/where.go new file mode 100644 index 00000000..d32739d5 --- /dev/null +++ b/generated/ent/tag/where.go @@ -0,0 +1,388 @@ +// Code generated by ent, DO NOT EDIT. + +package tag + +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.Tag { + return predicate.Tag(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Tag { + return predicate.Tag(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Tag { + return predicate.Tag(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.Tag { + return predicate.Tag(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.Tag { + return predicate.Tag(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldName, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Tag { + return predicate.Tag(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Tag { + return predicate.Tag(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Tag { + return predicate.Tag(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Tag { + return predicate.Tag(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Tag { + return predicate.Tag(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Tag { + return predicate.Tag(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Tag { + return predicate.Tag(sql.FieldContainsFold(FieldName, v)) +} + +// HasMods applies the HasEdge predicate on the "mods" edge. +func HasMods() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, 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.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newModsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasGuides applies the HasEdge predicate on the "guides" edge. +func HasGuides() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, GuidesTable, GuidesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGuidesWith applies the HasEdge predicate on the "guides" edge with a given conditions (other predicates). +func HasGuidesWith(preds ...predicate.Guide) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newGuidesStep() + 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) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ModTagsTable, ModTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasModTagsWith applies the HasEdge predicate on the "mod_tags" edge with a given conditions (other predicates). +func HasModTagsWith(preds ...predicate.ModTag) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newModTagsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasGuideTags applies the HasEdge predicate on the "guide_tags" edge. +func HasGuideTags() predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, GuideTagsTable, GuideTagsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGuideTagsWith applies the HasEdge predicate on the "guide_tags" edge with a given conditions (other predicates). +func HasGuideTagsWith(preds ...predicate.GuideTag) predicate.Tag { + return predicate.Tag(func(s *sql.Selector) { + step := newGuideTagsStep() + 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...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Tag) predicate.Tag { + return predicate.Tag(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Tag) predicate.Tag { + return predicate.Tag(sql.NotPredicates(p)) +} diff --git a/generated/ent/tag_create.go b/generated/ent/tag_create.go new file mode 100644 index 00000000..d0e7bee4 --- /dev/null +++ b/generated/ent/tag_create.go @@ -0,0 +1,362 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "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/tag" +) + +// TagCreate is the builder for creating a Tag entity. +type TagCreate struct { + config + mutation *TagMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (tc *TagCreate) SetCreatedAt(t time.Time) *TagCreate { + tc.mutation.SetCreatedAt(t) + return tc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (tc *TagCreate) SetNillableCreatedAt(t *time.Time) *TagCreate { + if t != nil { + tc.SetCreatedAt(*t) + } + return tc +} + +// SetUpdatedAt sets the "updated_at" field. +func (tc *TagCreate) SetUpdatedAt(t time.Time) *TagCreate { + tc.mutation.SetUpdatedAt(t) + return tc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (tc *TagCreate) SetNillableUpdatedAt(t *time.Time) *TagCreate { + if t != nil { + tc.SetUpdatedAt(*t) + } + return tc +} + +// SetDeletedAt sets the "deleted_at" field. +func (tc *TagCreate) SetDeletedAt(t time.Time) *TagCreate { + tc.mutation.SetDeletedAt(t) + return tc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (tc *TagCreate) SetNillableDeletedAt(t *time.Time) *TagCreate { + if t != nil { + tc.SetDeletedAt(*t) + } + return tc +} + +// SetName sets the "name" field. +func (tc *TagCreate) SetName(s string) *TagCreate { + tc.mutation.SetName(s) + return tc +} + +// SetID sets the "id" field. +func (tc *TagCreate) SetID(s string) *TagCreate { + tc.mutation.SetID(s) + return tc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (tc *TagCreate) SetNillableID(s *string) *TagCreate { + if s != nil { + tc.SetID(*s) + } + return tc +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (tc *TagCreate) AddModIDs(ids ...string) *TagCreate { + tc.mutation.AddModIDs(ids...) + return tc +} + +// AddMods adds the "mods" edges to the Mod entity. +func (tc *TagCreate) AddMods(m ...*Mod) *TagCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tc.AddModIDs(ids...) +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (tc *TagCreate) AddGuideIDs(ids ...string) *TagCreate { + tc.mutation.AddGuideIDs(ids...) + return tc +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (tc *TagCreate) AddGuides(g ...*Guide) *TagCreate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return tc.AddGuideIDs(ids...) +} + +// Mutation returns the TagMutation object of the builder. +func (tc *TagCreate) Mutation() *TagMutation { + return tc.mutation +} + +// Save creates the Tag in the database. +func (tc *TagCreate) Save(ctx context.Context) (*Tag, error) { + if err := tc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (tc *TagCreate) SaveX(ctx context.Context) *Tag { + v, err := tc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (tc *TagCreate) Exec(ctx context.Context) error { + _, err := tc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tc *TagCreate) ExecX(ctx context.Context) { + if err := tc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (tc *TagCreate) defaults() error { + if _, ok := tc.mutation.CreatedAt(); !ok { + if tag.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized tag.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := tag.DefaultCreatedAt() + tc.mutation.SetCreatedAt(v) + } + if _, ok := tc.mutation.UpdatedAt(); !ok { + if tag.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized tag.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := tag.DefaultUpdatedAt() + tc.mutation.SetUpdatedAt(v) + } + if _, ok := tc.mutation.ID(); !ok { + if tag.DefaultID == nil { + return fmt.Errorf("ent: uninitialized tag.DefaultID (forgotten import ent/runtime?)") + } + v := tag.DefaultID() + tc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (tc *TagCreate) check() error { + if _, ok := tc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Tag.created_at"`)} + } + if _, ok := tc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Tag.updated_at"`)} + } + if _, ok := tc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Tag.name"`)} + } + if v, ok := tc.mutation.Name(); ok { + if err := tag.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} + } + } + return nil +} + +func (tc *TagCreate) sqlSave(ctx context.Context) (*Tag, error) { + if err := tc.check(); err != nil { + return nil, err + } + _node, _spec := tc.createSpec() + if err := sqlgraph.CreateNode(ctx, tc.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 Tag.ID type: %T", _spec.ID.Value) + } + } + tc.mutation.id = &_node.ID + tc.mutation.done = true + return _node, nil +} + +func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { + var ( + _node = &Tag{config: tc.config} + _spec = sqlgraph.NewCreateSpec(tag.Table, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) + ) + if id, ok := tc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := tc.mutation.CreatedAt(); ok { + _spec.SetField(tag.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := tc.mutation.UpdatedAt(); ok { + _spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := tc.mutation.DeletedAt(); ok { + _spec.SetField(tag.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := tc.mutation.Name(); ok { + _spec.SetField(tag.FieldName, field.TypeString, value) + _node.Name = value + } + if nodes := tc.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.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 := tc.mutation.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// TagCreateBulk is the builder for creating many Tag entities in bulk. +type TagCreateBulk struct { + config + err error + builders []*TagCreate +} + +// Save creates the Tag entities in the database. +func (tcb *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error) { + if tcb.err != nil { + return nil, tcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) + nodes := make([]*Tag, len(tcb.builders)) + mutators := make([]Mutator, len(tcb.builders)) + for i := range tcb.builders { + func(i int, root context.Context) { + builder := tcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*TagMutation) + 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, tcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, tcb.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, tcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (tcb *TagCreateBulk) SaveX(ctx context.Context) []*Tag { + v, err := tcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (tcb *TagCreateBulk) Exec(ctx context.Context) error { + _, err := tcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tcb *TagCreateBulk) ExecX(ctx context.Context) { + if err := tcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/tag_delete.go b/generated/ent/tag_delete.go new file mode 100644 index 00000000..628455fb --- /dev/null +++ b/generated/ent/tag_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// TagDelete is the builder for deleting a Tag entity. +type TagDelete struct { + config + hooks []Hook + mutation *TagMutation +} + +// Where appends a list predicates to the TagDelete builder. +func (td *TagDelete) Where(ps ...predicate.Tag) *TagDelete { + td.mutation.Where(ps...) + return td +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (td *TagDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (td *TagDelete) ExecX(ctx context.Context) int { + n, err := td.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (td *TagDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(tag.Table, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) + if ps := td.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, td.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + td.mutation.done = true + return affected, err +} + +// TagDeleteOne is the builder for deleting a single Tag entity. +type TagDeleteOne struct { + td *TagDelete +} + +// Where appends a list predicates to the TagDelete builder. +func (tdo *TagDeleteOne) Where(ps ...predicate.Tag) *TagDeleteOne { + tdo.td.mutation.Where(ps...) + return tdo +} + +// Exec executes the deletion query. +func (tdo *TagDeleteOne) Exec(ctx context.Context) error { + n, err := tdo.td.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{tag.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (tdo *TagDeleteOne) ExecX(ctx context.Context) { + if err := tdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/tag_query.go b/generated/ent/tag_query.go new file mode 100644 index 00000000..e756e161 --- /dev/null +++ b/generated/ent/tag_query.go @@ -0,0 +1,911 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// 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) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the TagQuery builder. +func (tq *TagQuery) Where(ps ...predicate.Tag) *TagQuery { + tq.predicates = append(tq.predicates, ps...) + return tq +} + +// Limit the number of records to be returned by this query. +func (tq *TagQuery) Limit(limit int) *TagQuery { + tq.ctx.Limit = &limit + return tq +} + +// Offset to start from. +func (tq *TagQuery) Offset(offset int) *TagQuery { + tq.ctx.Offset = &offset + return tq +} + +// 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 (tq *TagQuery) Unique(unique bool) *TagQuery { + tq.ctx.Unique = &unique + return tq +} + +// Order specifies how the records should be ordered. +func (tq *TagQuery) Order(o ...tag.OrderOption) *TagQuery { + tq.order = append(tq.order, o...) + return tq +} + +// QueryMods chains the current query on the "mods" edge. +func (tq *TagQuery) QueryMods() *ModQuery { + query := (&ModClient{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(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.ModsTable, tag.ModsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryGuides chains the current query on the "guides" edge. +func (tq *TagQuery) QueryGuides() *GuideQuery { + query := (&GuideClient{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(guide.Table, guide.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, tag.GuidesTable, tag.GuidesPrimaryKey...), + ) + 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() + 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(modtag.Table, modtag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.ModTagsTable, tag.ModTagsColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryGuideTags chains the current query on the "guide_tags" edge. +func (tq *TagQuery) QueryGuideTags() *GuideTagQuery { + query := (&GuideTagClient{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(guidetag.Table, guidetag.TagColumn), + sqlgraph.Edge(sqlgraph.O2M, true, tag.GuideTagsTable, tag.GuideTagsColumn), + ) + 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) { + nodes, err := tq.Limit(1).All(setContextOp(ctx, tq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{tag.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (tq *TagQuery) FirstX(ctx context.Context) *Tag { + node, err := tq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Tag ID from the query. +// Returns a *NotFoundError when no Tag ID was found. +func (tq *TagQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = tq.Limit(1).IDs(setContextOp(ctx, tq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{tag.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (tq *TagQuery) FirstIDX(ctx context.Context) string { + id, err := tq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Tag entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Tag entity is found. +// Returns a *NotFoundError when no Tag entities are found. +func (tq *TagQuery) Only(ctx context.Context) (*Tag, error) { + nodes, err := tq.Limit(2).All(setContextOp(ctx, tq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{tag.Label} + default: + return nil, &NotSingularError{tag.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (tq *TagQuery) OnlyX(ctx context.Context) *Tag { + node, err := tq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Tag ID in the query. +// Returns a *NotSingularError when more than one Tag ID is found. +// Returns a *NotFoundError when no entities are found. +func (tq *TagQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = tq.Limit(2).IDs(setContextOp(ctx, tq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{tag.Label} + default: + err = &NotSingularError{tag.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (tq *TagQuery) OnlyIDX(ctx context.Context) string { + id, err := tq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Tags. +func (tq *TagQuery) All(ctx context.Context) ([]*Tag, error) { + ctx = setContextOp(ctx, tq.ctx, "All") + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Tag, *TagQuery]() + return withInterceptors[[]*Tag](ctx, tq, qr, tq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (tq *TagQuery) AllX(ctx context.Context) []*Tag { + nodes, err := tq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Tag IDs. +func (tq *TagQuery) IDs(ctx context.Context) (ids []string, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } + ctx = setContextOp(ctx, tq.ctx, "IDs") + if err = tq.Select(tag.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (tq *TagQuery) IDsX(ctx context.Context) []string { + ids, err := tq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (tq *TagQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, tq.ctx, "Count") + if err := tq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, tq, querierCount[*TagQuery](), tq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (tq *TagQuery) CountX(ctx context.Context) int { + count, err := tq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (tq *TagQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, tq.ctx, "Exist") + switch _, err := tq.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 (tq *TagQuery) ExistX(ctx context.Context) bool { + exist, err := tq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the TagQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (tq *TagQuery) Clone() *TagQuery { + if tq == nil { + 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(), + // clone intermediate query. + sql: tq.sql.Clone(), + path: tq.path, + } +} + +// 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 (tq *TagQuery) WithMods(opts ...func(*ModQuery)) *TagQuery { + query := (&ModClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withMods = query + return tq +} + +// WithGuides tells the query-builder to eager-load the nodes that are connected to +// the "guides" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithGuides(opts ...func(*GuideQuery)) *TagQuery { + query := (&GuideClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withGuides = 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 { + query := (&ModTagClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withModTags = query + return tq +} + +// WithGuideTags tells the query-builder to eager-load the nodes that are connected to +// the "guide_tags" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TagQuery) WithGuideTags(opts ...func(*GuideTagQuery)) *TagQuery { + query := (&GuideTagClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withGuideTags = 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. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Tag.Query(). +// GroupBy(tag.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (tq *TagQuery) GroupBy(field string, fields ...string) *TagGroupBy { + tq.ctx.Fields = append([]string{field}, fields...) + grbuild := &TagGroupBy{build: tq} + grbuild.flds = &tq.ctx.Fields + grbuild.label = tag.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.Tag.Query(). +// Select(tag.FieldCreatedAt). +// Scan(ctx, &v) +func (tq *TagQuery) Select(fields ...string) *TagSelect { + tq.ctx.Fields = append(tq.ctx.Fields, fields...) + sbuild := &TagSelect{TagQuery: tq} + sbuild.label = tag.Label + sbuild.flds, sbuild.scan = &tq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a TagSelect configured with the given aggregations. +func (tq *TagQuery) Aggregate(fns ...AggregateFunc) *TagSelect { + return tq.Select().Aggregate(fns...) +} + +func (tq *TagQuery) prepareQuery(ctx context.Context) error { + for _, inter := range tq.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, tq); err != nil { + return err + } + } + } + for _, f := range tq.ctx.Fields { + if !tag.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if tq.path != nil { + prev, err := tq.path(ctx) + if err != nil { + return err + } + tq.sql = prev + } + return nil +} + +func (tq *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, error) { + var ( + nodes = []*Tag{} + _spec = tq.querySpec() + loadedTypes = [4]bool{ + tq.withMods != nil, + tq.withGuides != nil, + tq.withModTags != nil, + tq.withGuideTags != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Tag).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Tag{config: tq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(tq.modifiers) > 0 { + _spec.Modifiers = tq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, tq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := tq.withMods; query != nil { + if err := tq.loadMods(ctx, query, nodes, + func(n *Tag) { n.Edges.Mods = []*Mod{} }, + func(n *Tag, e *Mod) { n.Edges.Mods = append(n.Edges.Mods, e) }); err != nil { + return nil, err + } + } + if query := tq.withGuides; query != nil { + if err := tq.loadGuides(ctx, query, nodes, + func(n *Tag) { n.Edges.Guides = []*Guide{} }, + func(n *Tag, e *Guide) { n.Edges.Guides = append(n.Edges.Guides, 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{} }, + func(n *Tag, e *ModTag) { n.Edges.ModTags = append(n.Edges.ModTags, e) }); err != nil { + return nil, err + } + } + if query := tq.withGuideTags; query != nil { + if err := tq.loadGuideTags(ctx, query, nodes, + func(n *Tag) { n.Edges.GuideTags = []*GuideTag{} }, + func(n *Tag, e *GuideTag) { n.Edges.GuideTags = append(n.Edges.GuideTags, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (tq *TagQuery) loadMods(ctx context.Context, query *ModQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Mod)) 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.ModsTable) + s.Join(joinT).On(s.C(mod.FieldID), joinT.C(tag.ModsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(tag.ModsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(tag.ModsPrimaryKey[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[[]*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 (tq *TagQuery) loadGuides(ctx context.Context, query *GuideQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Guide)) 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.GuidesTable) + s.Join(joinT).On(s.C(guide.FieldID), joinT.C(tag.GuidesPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(tag.GuidesPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(tag.GuidesPrimaryKey[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[[]*Guide](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 "guides" 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) + 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(modtag.FieldTagID) + } + query.Where(predicate.ModTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(tag.ModTagsColumn), 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) loadGuideTags(ctx context.Context, query *GuideTagQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *GuideTag)) 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(guidetag.FieldTagID) + } + query.Where(predicate.GuideTag(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(tag.GuideTagsColumn), 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() + if len(tq.modifiers) > 0 { + _spec.Modifiers = tq.modifiers + } + _spec.Node.Columns = tq.ctx.Fields + if len(tq.ctx.Fields) > 0 { + _spec.Unique = tq.ctx.Unique != nil && *tq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, tq.driver, _spec) +} + +func (tq *TagQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) + _spec.From = tq.sql + if unique := tq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true + } + if fields := tq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, tag.FieldID) + for i := range fields { + if fields[i] != tag.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := tq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := tq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := tq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := tq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (tq *TagQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(tq.driver.Dialect()) + t1 := builder.Table(tag.Table) + columns := tq.ctx.Fields + if len(columns) == 0 { + columns = tag.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if tq.sql != nil { + selector = tq.sql + selector.Select(selector.Columns(columns...)...) + } + if tq.ctx.Unique != nil && *tq.ctx.Unique { + selector.Distinct() + } + for _, m := range tq.modifiers { + m(selector) + } + for _, p := range tq.predicates { + p(selector) + } + for _, p := range tq.order { + p(selector) + } + if offset := tq.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 := tq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (tq *TagQuery) Modify(modifiers ...func(s *sql.Selector)) *TagSelect { + tq.modifiers = append(tq.modifiers, modifiers...) + return tq.Select() +} + +// TagGroupBy is the group-by builder for Tag entities. +type TagGroupBy struct { + selector + build *TagQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (tgb *TagGroupBy) Aggregate(fns ...AggregateFunc) *TagGroupBy { + tgb.fns = append(tgb.fns, fns...) + return tgb +} + +// Scan applies the selector query and scans the result into the given value. +func (tgb *TagGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, tgb.build.ctx, "GroupBy") + if err := tgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TagQuery, *TagGroupBy](ctx, tgb.build, tgb, tgb.build.inters, v) +} + +func (tgb *TagGroupBy) sqlScan(ctx context.Context, root *TagQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(tgb.fns)) + for _, fn := range tgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*tgb.flds)+len(tgb.fns)) + for _, f := range *tgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*tgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := tgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// TagSelect is the builder for selecting fields of Tag entities. +type TagSelect struct { + *TagQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ts *TagSelect) Aggregate(fns ...AggregateFunc) *TagSelect { + ts.fns = append(ts.fns, fns...) + return ts +} + +// Scan applies the selector query and scans the result into the given value. +func (ts *TagSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ts.ctx, "Select") + if err := ts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TagQuery, *TagSelect](ctx, ts.TagQuery, ts, ts.inters, v) +} + +func (ts *TagSelect) sqlScan(ctx context.Context, root *TagQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ts.fns)) + for _, fn := range ts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ts.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 := ts.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 (ts *TagSelect) Modify(modifiers ...func(s *sql.Selector)) *TagSelect { + ts.modifiers = append(ts.modifiers, modifiers...) + return ts +} diff --git a/generated/ent/tag_update.go b/generated/ent/tag_update.go new file mode 100644 index 00000000..8fd148dd --- /dev/null +++ b/generated/ent/tag_update.go @@ -0,0 +1,662 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" +) + +// TagUpdate is the builder for updating Tag entities. +type TagUpdate struct { + config + hooks []Hook + mutation *TagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the TagUpdate builder. +func (tu *TagUpdate) Where(ps ...predicate.Tag) *TagUpdate { + tu.mutation.Where(ps...) + return tu +} + +// SetUpdatedAt sets the "updated_at" field. +func (tu *TagUpdate) SetUpdatedAt(t time.Time) *TagUpdate { + tu.mutation.SetUpdatedAt(t) + return tu +} + +// SetDeletedAt sets the "deleted_at" field. +func (tu *TagUpdate) SetDeletedAt(t time.Time) *TagUpdate { + tu.mutation.SetDeletedAt(t) + return tu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (tu *TagUpdate) SetNillableDeletedAt(t *time.Time) *TagUpdate { + if t != nil { + tu.SetDeletedAt(*t) + } + return tu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (tu *TagUpdate) ClearDeletedAt() *TagUpdate { + tu.mutation.ClearDeletedAt() + return tu +} + +// SetName sets the "name" field. +func (tu *TagUpdate) SetName(s string) *TagUpdate { + tu.mutation.SetName(s) + return tu +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (tu *TagUpdate) AddModIDs(ids ...string) *TagUpdate { + tu.mutation.AddModIDs(ids...) + return tu +} + +// AddMods adds the "mods" edges to the Mod entity. +func (tu *TagUpdate) AddMods(m ...*Mod) *TagUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tu.AddModIDs(ids...) +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (tu *TagUpdate) AddGuideIDs(ids ...string) *TagUpdate { + tu.mutation.AddGuideIDs(ids...) + return tu +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (tu *TagUpdate) AddGuides(g ...*Guide) *TagUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return tu.AddGuideIDs(ids...) +} + +// Mutation returns the TagMutation object of the builder. +func (tu *TagUpdate) Mutation() *TagMutation { + return tu.mutation +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (tu *TagUpdate) ClearMods() *TagUpdate { + tu.mutation.ClearMods() + return tu +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (tu *TagUpdate) RemoveModIDs(ids ...string) *TagUpdate { + tu.mutation.RemoveModIDs(ids...) + return tu +} + +// RemoveMods removes "mods" edges to Mod entities. +func (tu *TagUpdate) RemoveMods(m ...*Mod) *TagUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tu.RemoveModIDs(ids...) +} + +// ClearGuides clears all "guides" edges to the Guide entity. +func (tu *TagUpdate) ClearGuides() *TagUpdate { + tu.mutation.ClearGuides() + return tu +} + +// RemoveGuideIDs removes the "guides" edge to Guide entities by IDs. +func (tu *TagUpdate) RemoveGuideIDs(ids ...string) *TagUpdate { + tu.mutation.RemoveGuideIDs(ids...) + return tu +} + +// RemoveGuides removes "guides" edges to Guide entities. +func (tu *TagUpdate) RemoveGuides(g ...*Guide) *TagUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return tu.RemoveGuideIDs(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 { + return 0, err + } + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (tu *TagUpdate) SaveX(ctx context.Context) int { + affected, err := tu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (tu *TagUpdate) Exec(ctx context.Context) error { + _, err := tu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tu *TagUpdate) ExecX(ctx context.Context) { + if err := tu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (tu *TagUpdate) defaults() error { + if _, ok := tu.mutation.UpdatedAt(); !ok { + if tag.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized tag.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := tag.UpdateDefaultUpdatedAt() + tu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (tu *TagUpdate) check() error { + if v, ok := tu.mutation.Name(); ok { + if err := tag.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (tu *TagUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TagUpdate { + tu.modifiers = append(tu.modifiers, modifiers...) + return tu +} + +func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := tu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) + if ps := tu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := tu.mutation.UpdatedAt(); ok { + _spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := tu.mutation.DeletedAt(); ok { + _spec.SetField(tag.FieldDeletedAt, field.TypeTime, value) + } + if tu.mutation.DeletedAtCleared() { + _spec.ClearField(tag.FieldDeletedAt, field.TypeTime) + } + if value, ok := tu.mutation.Name(); ok { + _spec.SetField(tag.FieldName, field.TypeString, value) + } + if tu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedModsIDs(); len(nodes) > 0 && !tu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.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 := tu.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.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 tu.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedGuidesIDs(); len(nodes) > 0 && !tu.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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 { + err = &NotFoundError{tag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + tu.mutation.done = true + return n, nil +} + +// TagUpdateOne is the builder for updating a single Tag entity. +type TagUpdateOne struct { + config + fields []string + hooks []Hook + mutation *TagMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (tuo *TagUpdateOne) SetUpdatedAt(t time.Time) *TagUpdateOne { + tuo.mutation.SetUpdatedAt(t) + return tuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (tuo *TagUpdateOne) SetDeletedAt(t time.Time) *TagUpdateOne { + tuo.mutation.SetDeletedAt(t) + return tuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (tuo *TagUpdateOne) SetNillableDeletedAt(t *time.Time) *TagUpdateOne { + if t != nil { + tuo.SetDeletedAt(*t) + } + return tuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (tuo *TagUpdateOne) ClearDeletedAt() *TagUpdateOne { + tuo.mutation.ClearDeletedAt() + return tuo +} + +// SetName sets the "name" field. +func (tuo *TagUpdateOne) SetName(s string) *TagUpdateOne { + tuo.mutation.SetName(s) + return tuo +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (tuo *TagUpdateOne) AddModIDs(ids ...string) *TagUpdateOne { + tuo.mutation.AddModIDs(ids...) + return tuo +} + +// AddMods adds the "mods" edges to the Mod entity. +func (tuo *TagUpdateOne) AddMods(m ...*Mod) *TagUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tuo.AddModIDs(ids...) +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (tuo *TagUpdateOne) AddGuideIDs(ids ...string) *TagUpdateOne { + tuo.mutation.AddGuideIDs(ids...) + return tuo +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (tuo *TagUpdateOne) AddGuides(g ...*Guide) *TagUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return tuo.AddGuideIDs(ids...) +} + +// Mutation returns the TagMutation object of the builder. +func (tuo *TagUpdateOne) Mutation() *TagMutation { + return tuo.mutation +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (tuo *TagUpdateOne) ClearMods() *TagUpdateOne { + tuo.mutation.ClearMods() + return tuo +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (tuo *TagUpdateOne) RemoveModIDs(ids ...string) *TagUpdateOne { + tuo.mutation.RemoveModIDs(ids...) + return tuo +} + +// RemoveMods removes "mods" edges to Mod entities. +func (tuo *TagUpdateOne) RemoveMods(m ...*Mod) *TagUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return tuo.RemoveModIDs(ids...) +} + +// ClearGuides clears all "guides" edges to the Guide entity. +func (tuo *TagUpdateOne) ClearGuides() *TagUpdateOne { + tuo.mutation.ClearGuides() + return tuo +} + +// RemoveGuideIDs removes the "guides" edge to Guide entities by IDs. +func (tuo *TagUpdateOne) RemoveGuideIDs(ids ...string) *TagUpdateOne { + tuo.mutation.RemoveGuideIDs(ids...) + return tuo +} + +// RemoveGuides removes "guides" edges to Guide entities. +func (tuo *TagUpdateOne) RemoveGuides(g ...*Guide) *TagUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return tuo.RemoveGuideIDs(ids...) +} + +// Where appends a list predicates to the TagUpdate builder. +func (tuo *TagUpdateOne) Where(ps ...predicate.Tag) *TagUpdateOne { + tuo.mutation.Where(ps...) + return tuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (tuo *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne { + tuo.fields = append([]string{field}, fields...) + return tuo +} + +// Save executes the query and returns the updated Tag entity. +func (tuo *TagUpdateOne) Save(ctx context.Context) (*Tag, error) { + if err := tuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (tuo *TagUpdateOne) SaveX(ctx context.Context) *Tag { + node, err := tuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (tuo *TagUpdateOne) Exec(ctx context.Context) error { + _, err := tuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tuo *TagUpdateOne) ExecX(ctx context.Context) { + if err := tuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (tuo *TagUpdateOne) defaults() error { + if _, ok := tuo.mutation.UpdatedAt(); !ok { + if tag.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized tag.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := tag.UpdateDefaultUpdatedAt() + tuo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (tuo *TagUpdateOne) check() error { + if v, ok := tuo.mutation.Name(); ok { + if err := tag.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (tuo *TagUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TagUpdateOne { + tuo.modifiers = append(tuo.modifiers, modifiers...) + return tuo +} + +func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { + if err := tuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) + id, ok := tuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Tag.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := tuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, tag.FieldID) + for _, f := range fields { + if !tag.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != tag.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := tuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := tuo.mutation.UpdatedAt(); ok { + _spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := tuo.mutation.DeletedAt(); ok { + _spec.SetField(tag.FieldDeletedAt, field.TypeTime, value) + } + if tuo.mutation.DeletedAtCleared() { + _spec.ClearField(tag.FieldDeletedAt, field.TypeTime) + } + if value, ok := tuo.mutation.Name(); ok { + _spec.SetField(tag.FieldName, field.TypeString, value) + } + if tuo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedModsIDs(); len(nodes) > 0 && !tuo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.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 := tuo.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.ModsTable, + Columns: tag.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 tuo.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedGuidesIDs(); len(nodes) > 0 && !tuo.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: tag.GuidesTable, + Columns: tag.GuidesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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 + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{tag.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + tuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/tx.go b/generated/ent/tx.go new file mode 100644 index 00000000..307aafcd --- /dev/null +++ b/generated/ent/tx.go @@ -0,0 +1,275 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + stdsql "database/sql" + "fmt" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // Announcement is the client for interacting with the Announcement builders. + Announcement *AnnouncementClient + // Guide is the client for interacting with the Guide builders. + Guide *GuideClient + // GuideTag is the client for interacting with the GuideTag builders. + GuideTag *GuideTagClient + // Mod is the client for interacting with the Mod builders. + Mod *ModClient + // ModTag is the client for interacting with the ModTag builders. + ModTag *ModTagClient + // SmlVersion is the client for interacting with the SmlVersion builders. + SmlVersion *SmlVersionClient + // SmlVersionTarget is the client for interacting with the SmlVersionTarget builders. + SmlVersionTarget *SmlVersionTargetClient + // Tag is the client for interacting with the Tag builders. + Tag *TagClient + // User is the client for interacting with the User builders. + User *UserClient + // UserGroup is the client for interacting with the UserGroup builders. + UserGroup *UserGroupClient + // UserMod is the client for interacting with the UserMod builders. + UserMod *UserModClient + // UserSession is the client for interacting with the UserSession builders. + UserSession *UserSessionClient + // Version is the client for interacting with the Version builders. + Version *VersionClient + // VersionDependency is the client for interacting with the VersionDependency builders. + VersionDependency *VersionDependencyClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.Announcement = NewAnnouncementClient(tx.config) + tx.Guide = NewGuideClient(tx.config) + tx.GuideTag = NewGuideTagClient(tx.config) + tx.Mod = NewModClient(tx.config) + tx.ModTag = NewModTagClient(tx.config) + tx.SmlVersion = NewSmlVersionClient(tx.config) + tx.SmlVersionTarget = NewSmlVersionTargetClient(tx.config) + tx.Tag = NewTagClient(tx.config) + tx.User = NewUserClient(tx.config) + tx.UserGroup = NewUserGroupClient(tx.config) + tx.UserMod = NewUserModClient(tx.config) + tx.UserSession = NewUserSessionClient(tx.config) + tx.Version = NewVersionClient(tx.config) + tx.VersionDependency = NewVersionDependencyClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: Announcement.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) + +// ExecContext allows calling the underlying ExecContext method of the transaction if it is supported by it. +// See, database/sql#Tx.ExecContext for more information. +func (tx *txDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := tx.tx.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the transaction if it is supported by it. +// See, database/sql#Tx.QueryContext for more information. +func (tx *txDriver) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := tx.tx.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/generated/ent/user.go b/generated/ent/user.go new file mode 100644 index 00000000..f94365e1 --- /dev/null +++ b/generated/ent/user.go @@ -0,0 +1,319 @@ +// 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/user" +) + +// User is the model entity for the User schema. +type User 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Email holds the value of the "email" field. + Email string `json:"email,omitempty"` + // Username holds the value of the "username" field. + Username string `json:"username,omitempty"` + // Avatar holds the value of the "avatar" field. + Avatar string `json:"avatar,omitempty"` + // JoinedFrom holds the value of the "joined_from" field. + JoinedFrom string `json:"joined_from,omitempty"` + // Banned holds the value of the "banned" field. + Banned bool `json:"banned,omitempty"` + // Rank holds the value of the "rank" field. + Rank int `json:"rank,omitempty"` + // GithubID holds the value of the "github_id" field. + GithubID string `json:"github_id,omitempty"` + // GoogleID holds the value of the "google_id" field. + GoogleID string `json:"google_id,omitempty"` + // FacebookID holds the value of the "facebook_id" field. + FacebookID string `json:"facebook_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserQuery when eager-loading is set. + Edges UserEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserEdges holds the relations/edges for other nodes in the graph. +type UserEdges struct { + // Guides holds the value of the guides edge. + Guides []*Guide `json:"guides,omitempty"` + // Sessions holds the value of the sessions edge. + Sessions []*UserSession `json:"sessions,omitempty"` + // Mods holds the value of the mods edge. + Mods []*Mod `json:"mods,omitempty"` + // Groups holds the value of the groups edge. + Groups []*UserGroup `json:"groups,omitempty"` + // UserMods holds the value of the user_mods edge. + UserMods []*UserMod `json:"user_mods,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [5]bool +} + +// GuidesOrErr returns the Guides value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) GuidesOrErr() ([]*Guide, error) { + if e.loadedTypes[0] { + return e.Guides, nil + } + return nil, &NotLoadedError{edge: "guides"} +} + +// SessionsOrErr returns the Sessions value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) SessionsOrErr() ([]*UserSession, error) { + if e.loadedTypes[1] { + return e.Sessions, nil + } + return nil, &NotLoadedError{edge: "sessions"} +} + +// ModsOrErr returns the Mods value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) ModsOrErr() ([]*Mod, error) { + if e.loadedTypes[2] { + return e.Mods, nil + } + return nil, &NotLoadedError{edge: "mods"} +} + +// GroupsOrErr returns the Groups value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) GroupsOrErr() ([]*UserGroup, error) { + if e.loadedTypes[3] { + return e.Groups, nil + } + return nil, &NotLoadedError{edge: "groups"} +} + +// UserModsOrErr returns the UserMods value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) UserModsOrErr() ([]*UserMod, error) { + if e.loadedTypes[4] { + return e.UserMods, nil + } + return nil, &NotLoadedError{edge: "user_mods"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*User) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case user.FieldBanned: + values[i] = new(sql.NullBool) + case user.FieldRank: + values[i] = new(sql.NullInt64) + case user.FieldID, user.FieldEmail, user.FieldUsername, user.FieldAvatar, user.FieldJoinedFrom, user.FieldGithubID, user.FieldGoogleID, user.FieldFacebookID: + values[i] = new(sql.NullString) + case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldDeletedAt: + 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 User fields. +func (u *User) 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 user.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + u.ID = value.String + } + case user.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 { + u.CreatedAt = value.Time + } + case user.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 { + u.UpdatedAt = value.Time + } + case user.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + u.DeletedAt = value.Time + } + case user.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + u.Email = value.String + } + case user.FieldUsername: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field username", values[i]) + } else if value.Valid { + u.Username = value.String + } + case user.FieldAvatar: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field avatar", values[i]) + } else if value.Valid { + u.Avatar = value.String + } + case user.FieldJoinedFrom: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field joined_from", values[i]) + } else if value.Valid { + u.JoinedFrom = value.String + } + case user.FieldBanned: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field banned", values[i]) + } else if value.Valid { + u.Banned = value.Bool + } + case user.FieldRank: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field rank", values[i]) + } else if value.Valid { + u.Rank = int(value.Int64) + } + case user.FieldGithubID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field github_id", values[i]) + } else if value.Valid { + u.GithubID = value.String + } + case user.FieldGoogleID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field google_id", values[i]) + } else if value.Valid { + u.GoogleID = value.String + } + case user.FieldFacebookID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field facebook_id", values[i]) + } else if value.Valid { + u.FacebookID = value.String + } + default: + u.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the User. +// This includes values selected through modifiers, order, etc. +func (u *User) Value(name string) (ent.Value, error) { + return u.selectValues.Get(name) +} + +// QueryGuides queries the "guides" edge of the User entity. +func (u *User) QueryGuides() *GuideQuery { + return NewUserClient(u.config).QueryGuides(u) +} + +// QuerySessions queries the "sessions" edge of the User entity. +func (u *User) QuerySessions() *UserSessionQuery { + return NewUserClient(u.config).QuerySessions(u) +} + +// QueryMods queries the "mods" edge of the User entity. +func (u *User) QueryMods() *ModQuery { + return NewUserClient(u.config).QueryMods(u) +} + +// QueryGroups queries the "groups" edge of the User entity. +func (u *User) QueryGroups() *UserGroupQuery { + return NewUserClient(u.config).QueryGroups(u) +} + +// QueryUserMods queries the "user_mods" edge of the User entity. +func (u *User) QueryUserMods() *UserModQuery { + return NewUserClient(u.config).QueryUserMods(u) +} + +// Update returns a builder for updating this User. +// Note that you need to call User.Unwrap() before calling this method if this User +// was returned from a transaction, and the transaction was committed or rolled back. +func (u *User) Update() *UserUpdateOne { + return NewUserClient(u.config).UpdateOne(u) +} + +// Unwrap unwraps the User 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 (u *User) Unwrap() *User { + _tx, ok := u.config.driver.(*txDriver) + if !ok { + panic("ent: User is not a transactional entity") + } + u.config.driver = _tx.drv + return u +} + +// String implements the fmt.Stringer. +func (u *User) String() string { + var builder strings.Builder + builder.WriteString("User(") + builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) + builder.WriteString("created_at=") + builder.WriteString(u.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(u.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(u.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(u.Email) + builder.WriteString(", ") + builder.WriteString("username=") + builder.WriteString(u.Username) + builder.WriteString(", ") + builder.WriteString("avatar=") + builder.WriteString(u.Avatar) + builder.WriteString(", ") + builder.WriteString("joined_from=") + builder.WriteString(u.JoinedFrom) + builder.WriteString(", ") + builder.WriteString("banned=") + builder.WriteString(fmt.Sprintf("%v", u.Banned)) + builder.WriteString(", ") + builder.WriteString("rank=") + builder.WriteString(fmt.Sprintf("%v", u.Rank)) + builder.WriteString(", ") + builder.WriteString("github_id=") + builder.WriteString(u.GithubID) + builder.WriteString(", ") + builder.WriteString("google_id=") + builder.WriteString(u.GoogleID) + builder.WriteString(", ") + builder.WriteString("facebook_id=") + builder.WriteString(u.FacebookID) + builder.WriteByte(')') + return builder.String() +} + +// Users is a parsable slice of User. +type Users []*User diff --git a/generated/ent/user/user.go b/generated/ent/user/user.go new file mode 100644 index 00000000..6ab942a7 --- /dev/null +++ b/generated/ent/user/user.go @@ -0,0 +1,325 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the user type in the database. + Label = "user" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // FieldJoinedFrom holds the string denoting the joined_from field in the database. + FieldJoinedFrom = "joined_from" + // FieldBanned holds the string denoting the banned field in the database. + FieldBanned = "banned" + // FieldRank holds the string denoting the rank field in the database. + FieldRank = "rank" + // FieldGithubID holds the string denoting the github_id field in the database. + FieldGithubID = "github_id" + // FieldGoogleID holds the string denoting the google_id field in the database. + FieldGoogleID = "google_id" + // FieldFacebookID holds the string denoting the facebook_id field in the database. + FieldFacebookID = "facebook_id" + // EdgeGuides holds the string denoting the guides edge name in mutations. + EdgeGuides = "guides" + // EdgeSessions holds the string denoting the sessions edge name in mutations. + EdgeSessions = "sessions" + // EdgeMods holds the string denoting the mods edge name in mutations. + EdgeMods = "mods" + // EdgeGroups holds the string denoting the groups edge name in mutations. + EdgeGroups = "groups" + // EdgeUserMods holds the string denoting the user_mods edge name in mutations. + EdgeUserMods = "user_mods" + // Table holds the table name of the user in the database. + Table = "users" + // GuidesTable is the table that holds the guides relation/edge. + GuidesTable = "guides" + // 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" + // GuidesColumn is the table column denoting the guides relation/edge. + GuidesColumn = "user_id" + // SessionsTable is the table that holds the sessions relation/edge. + SessionsTable = "user_sessions" + // SessionsInverseTable is the table name for the UserSession entity. + // It exists in this package in order to avoid circular dependency with the "usersession" package. + SessionsInverseTable = "user_sessions" + // SessionsColumn is the table column denoting the sessions relation/edge. + SessionsColumn = "user_id" + // ModsTable is the table that holds the mods relation/edge. The primary key declared below. + ModsTable = "user_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" + // GroupsTable is the table that holds the groups relation/edge. + GroupsTable = "user_groups" + // GroupsInverseTable is the table name for the UserGroup entity. + // It exists in this package in order to avoid circular dependency with the "usergroup" package. + GroupsInverseTable = "user_groups" + // GroupsColumn is the table column denoting the groups relation/edge. + GroupsColumn = "user_id" + // UserModsTable is the table that holds the user_mods relation/edge. + UserModsTable = "user_mods" + // UserModsInverseTable is the table name for the UserMod entity. + // It exists in this package in order to avoid circular dependency with the "usermod" package. + UserModsInverseTable = "user_mods" + // UserModsColumn is the table column denoting the user_mods relation/edge. + UserModsColumn = "user_id" +) + +// Columns holds all SQL columns for user fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldEmail, + FieldUsername, + FieldAvatar, + FieldJoinedFrom, + FieldBanned, + FieldRank, + FieldGithubID, + FieldGoogleID, + FieldFacebookID, +} + +var ( + // ModsPrimaryKey and ModsColumn2 are the table columns denoting the + // primary key for the mods relation (M2M). + ModsPrimaryKey = []string{"user_id", "mod_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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // DefaultBanned holds the default value on creation for the "banned" field. + DefaultBanned bool + // DefaultRank holds the default value on creation for the "rank" field. + DefaultRank int + // GithubIDValidator is a validator for the "github_id" field. It is called by the builders before save. + GithubIDValidator func(string) error + // GoogleIDValidator is a validator for the "google_id" field. It is called by the builders before save. + GoogleIDValidator func(string) error + // FacebookIDValidator is a validator for the "facebook_id" field. It is called by the builders before save. + FacebookIDValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the User 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, opts...).ToFunc() +} + +// ByJoinedFrom orders the results by the joined_from field. +func ByJoinedFrom(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldJoinedFrom, opts...).ToFunc() +} + +// ByBanned orders the results by the banned field. +func ByBanned(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBanned, opts...).ToFunc() +} + +// ByRank orders the results by the rank field. +func ByRank(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRank, opts...).ToFunc() +} + +// ByGithubID orders the results by the github_id field. +func ByGithubID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGithubID, opts...).ToFunc() +} + +// ByGoogleID orders the results by the google_id field. +func ByGoogleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGoogleID, opts...).ToFunc() +} + +// ByFacebookID orders the results by the facebook_id field. +func ByFacebookID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFacebookID, opts...).ToFunc() +} + +// ByGuidesCount orders the results by guides count. +func ByGuidesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newGuidesStep(), opts...) + } +} + +// ByGuides orders the results by guides terms. +func ByGuides(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGuidesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// BySessionsCount orders the results by sessions count. +func BySessionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newSessionsStep(), opts...) + } +} + +// BySessions orders the results by sessions terms. +func BySessions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSessionsStep(), 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...)...) + } +} + +// ByGroupsCount orders the results by groups count. +func ByGroupsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newGroupsStep(), opts...) + } +} + +// ByGroups orders the results by groups terms. +func ByGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newGroupsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserModsCount orders the results by user_mods count. +func ByUserModsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserModsStep(), opts...) + } +} + +// ByUserMods orders the results by user_mods terms. +func ByUserMods(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserModsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newGuidesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GuidesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, GuidesTable, GuidesColumn), + ) +} +func newSessionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SessionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn), + ) +} +func newModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ModsTable, ModsPrimaryKey...), + ) +} +func newGroupsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(GroupsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, GroupsTable, GroupsColumn), + ) +} +func newUserModsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserModsInverseTable, UserModsColumn), + sqlgraph.Edge(sqlgraph.O2M, true, UserModsTable, UserModsColumn), + ) +} diff --git a/generated/ent/user/where.go b/generated/ent/user/where.go new file mode 100644 index 00000000..fcd26021 --- /dev/null +++ b/generated/ent/user/where.go @@ -0,0 +1,941 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +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.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.User { + return predicate.User(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.User { + return predicate.User(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.User { + return predicate.User(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.User { + return predicate.User(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// JoinedFrom applies equality check predicate on the "joined_from" field. It's identical to JoinedFromEQ. +func JoinedFrom(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldJoinedFrom, v)) +} + +// Banned applies equality check predicate on the "banned" field. It's identical to BannedEQ. +func Banned(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldBanned, v)) +} + +// Rank applies equality check predicate on the "rank" field. It's identical to RankEQ. +func Rank(v int) predicate.User { + return predicate.User(sql.FieldEQ(FieldRank, v)) +} + +// GithubID applies equality check predicate on the "github_id" field. It's identical to GithubIDEQ. +func GithubID(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldGithubID, v)) +} + +// GoogleID applies equality check predicate on the "google_id" field. It's identical to GoogleIDEQ. +func GoogleID(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldGoogleID, v)) +} + +// FacebookID applies equality check predicate on the "facebook_id" field. It's identical to FacebookIDEQ. +func FacebookID(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldFacebookID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldDeletedAt)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEmail, v)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUsername, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarIsNil applies the IsNil predicate on the "avatar" field. +func AvatarIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldAvatar)) +} + +// AvatarNotNil applies the NotNil predicate on the "avatar" field. +func AvatarNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldAvatar)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) +} + +// JoinedFromEQ applies the EQ predicate on the "joined_from" field. +func JoinedFromEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldJoinedFrom, v)) +} + +// JoinedFromNEQ applies the NEQ predicate on the "joined_from" field. +func JoinedFromNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldJoinedFrom, v)) +} + +// JoinedFromIn applies the In predicate on the "joined_from" field. +func JoinedFromIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldJoinedFrom, vs...)) +} + +// JoinedFromNotIn applies the NotIn predicate on the "joined_from" field. +func JoinedFromNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldJoinedFrom, vs...)) +} + +// JoinedFromGT applies the GT predicate on the "joined_from" field. +func JoinedFromGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldJoinedFrom, v)) +} + +// JoinedFromGTE applies the GTE predicate on the "joined_from" field. +func JoinedFromGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldJoinedFrom, v)) +} + +// JoinedFromLT applies the LT predicate on the "joined_from" field. +func JoinedFromLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldJoinedFrom, v)) +} + +// JoinedFromLTE applies the LTE predicate on the "joined_from" field. +func JoinedFromLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldJoinedFrom, v)) +} + +// JoinedFromContains applies the Contains predicate on the "joined_from" field. +func JoinedFromContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldJoinedFrom, v)) +} + +// JoinedFromHasPrefix applies the HasPrefix predicate on the "joined_from" field. +func JoinedFromHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldJoinedFrom, v)) +} + +// JoinedFromHasSuffix applies the HasSuffix predicate on the "joined_from" field. +func JoinedFromHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldJoinedFrom, v)) +} + +// JoinedFromIsNil applies the IsNil predicate on the "joined_from" field. +func JoinedFromIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldJoinedFrom)) +} + +// JoinedFromNotNil applies the NotNil predicate on the "joined_from" field. +func JoinedFromNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldJoinedFrom)) +} + +// JoinedFromEqualFold applies the EqualFold predicate on the "joined_from" field. +func JoinedFromEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldJoinedFrom, v)) +} + +// JoinedFromContainsFold applies the ContainsFold predicate on the "joined_from" field. +func JoinedFromContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldJoinedFrom, v)) +} + +// BannedEQ applies the EQ predicate on the "banned" field. +func BannedEQ(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldBanned, v)) +} + +// BannedNEQ applies the NEQ predicate on the "banned" field. +func BannedNEQ(v bool) predicate.User { + return predicate.User(sql.FieldNEQ(FieldBanned, v)) +} + +// RankEQ applies the EQ predicate on the "rank" field. +func RankEQ(v int) predicate.User { + return predicate.User(sql.FieldEQ(FieldRank, v)) +} + +// RankNEQ applies the NEQ predicate on the "rank" field. +func RankNEQ(v int) predicate.User { + return predicate.User(sql.FieldNEQ(FieldRank, v)) +} + +// RankIn applies the In predicate on the "rank" field. +func RankIn(vs ...int) predicate.User { + return predicate.User(sql.FieldIn(FieldRank, vs...)) +} + +// RankNotIn applies the NotIn predicate on the "rank" field. +func RankNotIn(vs ...int) predicate.User { + return predicate.User(sql.FieldNotIn(FieldRank, vs...)) +} + +// RankGT applies the GT predicate on the "rank" field. +func RankGT(v int) predicate.User { + return predicate.User(sql.FieldGT(FieldRank, v)) +} + +// RankGTE applies the GTE predicate on the "rank" field. +func RankGTE(v int) predicate.User { + return predicate.User(sql.FieldGTE(FieldRank, v)) +} + +// RankLT applies the LT predicate on the "rank" field. +func RankLT(v int) predicate.User { + return predicate.User(sql.FieldLT(FieldRank, v)) +} + +// RankLTE applies the LTE predicate on the "rank" field. +func RankLTE(v int) predicate.User { + return predicate.User(sql.FieldLTE(FieldRank, v)) +} + +// GithubIDEQ applies the EQ predicate on the "github_id" field. +func GithubIDEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldGithubID, v)) +} + +// GithubIDNEQ applies the NEQ predicate on the "github_id" field. +func GithubIDNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldGithubID, v)) +} + +// GithubIDIn applies the In predicate on the "github_id" field. +func GithubIDIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldGithubID, vs...)) +} + +// GithubIDNotIn applies the NotIn predicate on the "github_id" field. +func GithubIDNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldGithubID, vs...)) +} + +// GithubIDGT applies the GT predicate on the "github_id" field. +func GithubIDGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldGithubID, v)) +} + +// GithubIDGTE applies the GTE predicate on the "github_id" field. +func GithubIDGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldGithubID, v)) +} + +// GithubIDLT applies the LT predicate on the "github_id" field. +func GithubIDLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldGithubID, v)) +} + +// GithubIDLTE applies the LTE predicate on the "github_id" field. +func GithubIDLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldGithubID, v)) +} + +// GithubIDContains applies the Contains predicate on the "github_id" field. +func GithubIDContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldGithubID, v)) +} + +// GithubIDHasPrefix applies the HasPrefix predicate on the "github_id" field. +func GithubIDHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldGithubID, v)) +} + +// GithubIDHasSuffix applies the HasSuffix predicate on the "github_id" field. +func GithubIDHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldGithubID, v)) +} + +// GithubIDIsNil applies the IsNil predicate on the "github_id" field. +func GithubIDIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldGithubID)) +} + +// GithubIDNotNil applies the NotNil predicate on the "github_id" field. +func GithubIDNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldGithubID)) +} + +// GithubIDEqualFold applies the EqualFold predicate on the "github_id" field. +func GithubIDEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldGithubID, v)) +} + +// GithubIDContainsFold applies the ContainsFold predicate on the "github_id" field. +func GithubIDContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldGithubID, v)) +} + +// GoogleIDEQ applies the EQ predicate on the "google_id" field. +func GoogleIDEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldGoogleID, v)) +} + +// GoogleIDNEQ applies the NEQ predicate on the "google_id" field. +func GoogleIDNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldGoogleID, v)) +} + +// GoogleIDIn applies the In predicate on the "google_id" field. +func GoogleIDIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldGoogleID, vs...)) +} + +// GoogleIDNotIn applies the NotIn predicate on the "google_id" field. +func GoogleIDNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldGoogleID, vs...)) +} + +// GoogleIDGT applies the GT predicate on the "google_id" field. +func GoogleIDGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldGoogleID, v)) +} + +// GoogleIDGTE applies the GTE predicate on the "google_id" field. +func GoogleIDGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldGoogleID, v)) +} + +// GoogleIDLT applies the LT predicate on the "google_id" field. +func GoogleIDLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldGoogleID, v)) +} + +// GoogleIDLTE applies the LTE predicate on the "google_id" field. +func GoogleIDLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldGoogleID, v)) +} + +// GoogleIDContains applies the Contains predicate on the "google_id" field. +func GoogleIDContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldGoogleID, v)) +} + +// GoogleIDHasPrefix applies the HasPrefix predicate on the "google_id" field. +func GoogleIDHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldGoogleID, v)) +} + +// GoogleIDHasSuffix applies the HasSuffix predicate on the "google_id" field. +func GoogleIDHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldGoogleID, v)) +} + +// GoogleIDIsNil applies the IsNil predicate on the "google_id" field. +func GoogleIDIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldGoogleID)) +} + +// GoogleIDNotNil applies the NotNil predicate on the "google_id" field. +func GoogleIDNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldGoogleID)) +} + +// GoogleIDEqualFold applies the EqualFold predicate on the "google_id" field. +func GoogleIDEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldGoogleID, v)) +} + +// GoogleIDContainsFold applies the ContainsFold predicate on the "google_id" field. +func GoogleIDContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldGoogleID, v)) +} + +// FacebookIDEQ applies the EQ predicate on the "facebook_id" field. +func FacebookIDEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldFacebookID, v)) +} + +// FacebookIDNEQ applies the NEQ predicate on the "facebook_id" field. +func FacebookIDNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldFacebookID, v)) +} + +// FacebookIDIn applies the In predicate on the "facebook_id" field. +func FacebookIDIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldFacebookID, vs...)) +} + +// FacebookIDNotIn applies the NotIn predicate on the "facebook_id" field. +func FacebookIDNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldFacebookID, vs...)) +} + +// FacebookIDGT applies the GT predicate on the "facebook_id" field. +func FacebookIDGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldFacebookID, v)) +} + +// FacebookIDGTE applies the GTE predicate on the "facebook_id" field. +func FacebookIDGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldFacebookID, v)) +} + +// FacebookIDLT applies the LT predicate on the "facebook_id" field. +func FacebookIDLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldFacebookID, v)) +} + +// FacebookIDLTE applies the LTE predicate on the "facebook_id" field. +func FacebookIDLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldFacebookID, v)) +} + +// FacebookIDContains applies the Contains predicate on the "facebook_id" field. +func FacebookIDContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldFacebookID, v)) +} + +// FacebookIDHasPrefix applies the HasPrefix predicate on the "facebook_id" field. +func FacebookIDHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldFacebookID, v)) +} + +// FacebookIDHasSuffix applies the HasSuffix predicate on the "facebook_id" field. +func FacebookIDHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldFacebookID, v)) +} + +// FacebookIDIsNil applies the IsNil predicate on the "facebook_id" field. +func FacebookIDIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldFacebookID)) +} + +// FacebookIDNotNil applies the NotNil predicate on the "facebook_id" field. +func FacebookIDNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldFacebookID)) +} + +// FacebookIDEqualFold applies the EqualFold predicate on the "facebook_id" field. +func FacebookIDEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldFacebookID, v)) +} + +// FacebookIDContainsFold applies the ContainsFold predicate on the "facebook_id" field. +func FacebookIDContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldFacebookID, v)) +} + +// HasGuides applies the HasEdge predicate on the "guides" edge. +func HasGuides() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, GuidesTable, GuidesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGuidesWith applies the HasEdge predicate on the "guides" edge with a given conditions (other predicates). +func HasGuidesWith(preds ...predicate.Guide) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newGuidesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasSessions applies the HasEdge predicate on the "sessions" edge. +func HasSessions() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSessionsWith applies the HasEdge predicate on the "sessions" edge with a given conditions (other predicates). +func HasSessionsWith(preds ...predicate.UserSession) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newSessionsStep() + 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.User { + return predicate.User(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.User { + return predicate.User(func(s *sql.Selector) { + step := newModsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasGroups applies the HasEdge predicate on the "groups" edge. +func HasGroups() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, GroupsTable, GroupsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGroupsWith applies the HasEdge predicate on the "groups" edge with a given conditions (other predicates). +func HasGroupsWith(preds ...predicate.UserGroup) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newGroupsStep() + 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.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserModsTable, UserModsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserModsWith applies the HasEdge predicate on the "user_mods" edge with a given conditions (other predicates). +func HasUserModsWith(preds ...predicate.UserMod) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserModsStep() + 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.User) predicate.User { + return predicate.User(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.User) predicate.User { + return predicate.User(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.User) predicate.User { + return predicate.User(sql.NotPredicates(p)) +} diff --git a/generated/ent/user_create.go b/generated/ent/user_create.go new file mode 100644 index 00000000..46b41e3f --- /dev/null +++ b/generated/ent/user_create.go @@ -0,0 +1,599 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "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/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserCreate is the builder for creating a User entity. +type UserCreate struct { + config + mutation *UserMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate { + uc.mutation.SetCreatedAt(t) + return uc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (uc *UserCreate) SetNillableCreatedAt(t *time.Time) *UserCreate { + if t != nil { + uc.SetCreatedAt(*t) + } + return uc +} + +// SetUpdatedAt sets the "updated_at" field. +func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate { + uc.mutation.SetUpdatedAt(t) + return uc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate { + if t != nil { + uc.SetUpdatedAt(*t) + } + return uc +} + +// SetDeletedAt sets the "deleted_at" field. +func (uc *UserCreate) SetDeletedAt(t time.Time) *UserCreate { + uc.mutation.SetDeletedAt(t) + return uc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (uc *UserCreate) SetNillableDeletedAt(t *time.Time) *UserCreate { + if t != nil { + uc.SetDeletedAt(*t) + } + return uc +} + +// SetEmail sets the "email" field. +func (uc *UserCreate) SetEmail(s string) *UserCreate { + uc.mutation.SetEmail(s) + return uc +} + +// SetUsername sets the "username" field. +func (uc *UserCreate) SetUsername(s string) *UserCreate { + uc.mutation.SetUsername(s) + return uc +} + +// SetAvatar sets the "avatar" field. +func (uc *UserCreate) SetAvatar(s string) *UserCreate { + uc.mutation.SetAvatar(s) + return uc +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (uc *UserCreate) SetNillableAvatar(s *string) *UserCreate { + if s != nil { + uc.SetAvatar(*s) + } + return uc +} + +// SetJoinedFrom sets the "joined_from" field. +func (uc *UserCreate) SetJoinedFrom(s string) *UserCreate { + uc.mutation.SetJoinedFrom(s) + return uc +} + +// SetNillableJoinedFrom sets the "joined_from" field if the given value is not nil. +func (uc *UserCreate) SetNillableJoinedFrom(s *string) *UserCreate { + if s != nil { + uc.SetJoinedFrom(*s) + } + return uc +} + +// SetBanned sets the "banned" field. +func (uc *UserCreate) SetBanned(b bool) *UserCreate { + uc.mutation.SetBanned(b) + return uc +} + +// SetNillableBanned sets the "banned" field if the given value is not nil. +func (uc *UserCreate) SetNillableBanned(b *bool) *UserCreate { + if b != nil { + uc.SetBanned(*b) + } + return uc +} + +// SetRank sets the "rank" field. +func (uc *UserCreate) SetRank(i int) *UserCreate { + uc.mutation.SetRank(i) + return uc +} + +// SetNillableRank sets the "rank" field if the given value is not nil. +func (uc *UserCreate) SetNillableRank(i *int) *UserCreate { + if i != nil { + uc.SetRank(*i) + } + return uc +} + +// SetGithubID sets the "github_id" field. +func (uc *UserCreate) SetGithubID(s string) *UserCreate { + uc.mutation.SetGithubID(s) + return uc +} + +// SetNillableGithubID sets the "github_id" field if the given value is not nil. +func (uc *UserCreate) SetNillableGithubID(s *string) *UserCreate { + if s != nil { + uc.SetGithubID(*s) + } + return uc +} + +// SetGoogleID sets the "google_id" field. +func (uc *UserCreate) SetGoogleID(s string) *UserCreate { + uc.mutation.SetGoogleID(s) + return uc +} + +// SetNillableGoogleID sets the "google_id" field if the given value is not nil. +func (uc *UserCreate) SetNillableGoogleID(s *string) *UserCreate { + if s != nil { + uc.SetGoogleID(*s) + } + return uc +} + +// SetFacebookID sets the "facebook_id" field. +func (uc *UserCreate) SetFacebookID(s string) *UserCreate { + uc.mutation.SetFacebookID(s) + return uc +} + +// SetNillableFacebookID sets the "facebook_id" field if the given value is not nil. +func (uc *UserCreate) SetNillableFacebookID(s *string) *UserCreate { + if s != nil { + uc.SetFacebookID(*s) + } + return uc +} + +// SetID sets the "id" field. +func (uc *UserCreate) SetID(s string) *UserCreate { + uc.mutation.SetID(s) + return uc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (uc *UserCreate) SetNillableID(s *string) *UserCreate { + if s != nil { + uc.SetID(*s) + } + return uc +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (uc *UserCreate) AddGuideIDs(ids ...string) *UserCreate { + uc.mutation.AddGuideIDs(ids...) + return uc +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (uc *UserCreate) AddGuides(g ...*Guide) *UserCreate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return uc.AddGuideIDs(ids...) +} + +// AddSessionIDs adds the "sessions" edge to the UserSession entity by IDs. +func (uc *UserCreate) AddSessionIDs(ids ...string) *UserCreate { + uc.mutation.AddSessionIDs(ids...) + return uc +} + +// AddSessions adds the "sessions" edges to the UserSession entity. +func (uc *UserCreate) AddSessions(u ...*UserSession) *UserCreate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uc.AddSessionIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (uc *UserCreate) AddModIDs(ids ...string) *UserCreate { + uc.mutation.AddModIDs(ids...) + return uc +} + +// AddMods adds the "mods" edges to the Mod entity. +func (uc *UserCreate) AddMods(m ...*Mod) *UserCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return uc.AddModIDs(ids...) +} + +// AddGroupIDs adds the "groups" edge to the UserGroup entity by IDs. +func (uc *UserCreate) AddGroupIDs(ids ...string) *UserCreate { + uc.mutation.AddGroupIDs(ids...) + return uc +} + +// AddGroups adds the "groups" edges to the UserGroup entity. +func (uc *UserCreate) AddGroups(u ...*UserGroup) *UserCreate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uc.AddGroupIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (uc *UserCreate) Mutation() *UserMutation { + return uc.mutation +} + +// Save creates the User in the database. +func (uc *UserCreate) Save(ctx context.Context) (*User, error) { + if err := uc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (uc *UserCreate) SaveX(ctx context.Context) *User { + v, err := uc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uc *UserCreate) Exec(ctx context.Context) error { + _, err := uc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uc *UserCreate) ExecX(ctx context.Context) { + if err := uc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uc *UserCreate) defaults() error { + if _, ok := uc.mutation.CreatedAt(); !ok { + if user.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized user.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := user.DefaultCreatedAt() + uc.mutation.SetCreatedAt(v) + } + if _, ok := uc.mutation.UpdatedAt(); !ok { + if user.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized user.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := user.DefaultUpdatedAt() + uc.mutation.SetUpdatedAt(v) + } + if _, ok := uc.mutation.Banned(); !ok { + v := user.DefaultBanned + uc.mutation.SetBanned(v) + } + if _, ok := uc.mutation.Rank(); !ok { + v := user.DefaultRank + uc.mutation.SetRank(v) + } + if _, ok := uc.mutation.ID(); !ok { + if user.DefaultID == nil { + return fmt.Errorf("ent: uninitialized user.DefaultID (forgotten import ent/runtime?)") + } + v := user.DefaultID() + uc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (uc *UserCreate) check() error { + if _, ok := uc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)} + } + if _, ok := uc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)} + } + if _, ok := uc.mutation.Email(); !ok { + return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} + } + if v, ok := uc.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if _, ok := uc.mutation.Username(); !ok { + return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} + } + if v, ok := uc.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if _, ok := uc.mutation.Banned(); !ok { + return &ValidationError{Name: "banned", err: errors.New(`ent: missing required field "User.banned"`)} + } + if _, ok := uc.mutation.Rank(); !ok { + return &ValidationError{Name: "rank", err: errors.New(`ent: missing required field "User.rank"`)} + } + if v, ok := uc.mutation.GithubID(); ok { + if err := user.GithubIDValidator(v); err != nil { + return &ValidationError{Name: "github_id", err: fmt.Errorf(`ent: validator failed for field "User.github_id": %w`, err)} + } + } + if v, ok := uc.mutation.GoogleID(); ok { + if err := user.GoogleIDValidator(v); err != nil { + return &ValidationError{Name: "google_id", err: fmt.Errorf(`ent: validator failed for field "User.google_id": %w`, err)} + } + } + if v, ok := uc.mutation.FacebookID(); ok { + if err := user.FacebookIDValidator(v); err != nil { + return &ValidationError{Name: "facebook_id", err: fmt.Errorf(`ent: validator failed for field "User.facebook_id": %w`, err)} + } + } + return nil +} + +func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { + if err := uc.check(); err != nil { + return nil, err + } + _node, _spec := uc.createSpec() + if err := sqlgraph.CreateNode(ctx, uc.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 User.ID type: %T", _spec.ID.Value) + } + } + uc.mutation.id = &_node.ID + uc.mutation.done = true + return _node, nil +} + +func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { + var ( + _node = &User{config: uc.config} + _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) + ) + if id, ok := uc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := uc.mutation.CreatedAt(); ok { + _spec.SetField(user.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := uc.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := uc.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := uc.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := uc.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + _node.Username = value + } + if value, ok := uc.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + _node.Avatar = value + } + if value, ok := uc.mutation.JoinedFrom(); ok { + _spec.SetField(user.FieldJoinedFrom, field.TypeString, value) + _node.JoinedFrom = value + } + if value, ok := uc.mutation.Banned(); ok { + _spec.SetField(user.FieldBanned, field.TypeBool, value) + _node.Banned = value + } + if value, ok := uc.mutation.Rank(); ok { + _spec.SetField(user.FieldRank, field.TypeInt, value) + _node.Rank = value + } + if value, ok := uc.mutation.GithubID(); ok { + _spec.SetField(user.FieldGithubID, field.TypeString, value) + _node.GithubID = value + } + if value, ok := uc.mutation.GoogleID(); ok { + _spec.SetField(user.FieldGoogleID, field.TypeString, value) + _node.GoogleID = value + } + if value, ok := uc.mutation.FacebookID(); ok { + _spec.SetField(user.FieldFacebookID, field.TypeString, value) + _node.FacebookID = value + } + if nodes := uc.mutation.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := uc.mutation.SessionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := uc.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.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 := uc.mutation.GroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// UserCreateBulk is the builder for creating many User entities in bulk. +type UserCreateBulk struct { + config + err error + builders []*UserCreate +} + +// Save creates the User entities in the database. +func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) + nodes := make([]*User, len(ucb.builders)) + mutators := make([]Mutator, len(ucb.builders)) + for i := range ucb.builders { + func(i int, root context.Context) { + builder := ucb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + 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, ucb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ucb.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, ucb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := ucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ucb *UserCreateBulk) Exec(ctx context.Context) error { + _, err := ucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ucb *UserCreateBulk) ExecX(ctx context.Context) { + if err := ucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/user_delete.go b/generated/ent/user_delete.go new file mode 100644 index 00000000..efb5d9fa --- /dev/null +++ b/generated/ent/user_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" +) + +// UserDelete is the builder for deleting a User entity. +type UserDelete struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserDelete builder. +func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { + ud.mutation.Where(ps...) + return ud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ud *UserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ud *UserDelete) ExecX(ctx context.Context) int { + n, err := ud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) + if ps := ud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ud.mutation.done = true + return affected, err +} + +// UserDeleteOne is the builder for deleting a single User entity. +type UserDeleteOne struct { + ud *UserDelete +} + +// Where appends a list predicates to the UserDelete builder. +func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { + udo.ud.mutation.Where(ps...) + return udo +} + +// Exec executes the deletion query. +func (udo *UserDeleteOne) Exec(ctx context.Context) error { + n, err := udo.ud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{user.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (udo *UserDeleteOne) ExecX(ctx context.Context) { + if err := udo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/user_query.go b/generated/ent/user_query.go new file mode 100644 index 00000000..91a9bc76 --- /dev/null +++ b/generated/ent/user_query.go @@ -0,0 +1,956 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserQuery is the builder for querying User entities. +type UserQuery struct { + config + ctx *QueryContext + order []user.OrderOption + inters []Interceptor + predicates []predicate.User + withGuides *GuideQuery + withSessions *UserSessionQuery + withMods *ModQuery + withGroups *UserGroupQuery + withUserMods *UserModQuery + 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 UserQuery builder. +func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery { + uq.predicates = append(uq.predicates, ps...) + return uq +} + +// Limit the number of records to be returned by this query. +func (uq *UserQuery) Limit(limit int) *UserQuery { + uq.ctx.Limit = &limit + return uq +} + +// Offset to start from. +func (uq *UserQuery) Offset(offset int) *UserQuery { + uq.ctx.Offset = &offset + return uq +} + +// 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 (uq *UserQuery) Unique(unique bool) *UserQuery { + uq.ctx.Unique = &unique + return uq +} + +// Order specifies how the records should be ordered. +func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery { + uq.order = append(uq.order, o...) + return uq +} + +// QueryGuides chains the current query on the "guides" edge. +func (uq *UserQuery) QueryGuides() *GuideQuery { + query := (&GuideClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(guide.Table, guide.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.GuidesTable, user.GuidesColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QuerySessions chains the current query on the "sessions" edge. +func (uq *UserQuery) QuerySessions() *UserSessionQuery { + query := (&UserSessionClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(usersession.Table, usersession.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.SessionsTable, user.SessionsColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMods chains the current query on the "mods" edge. +func (uq *UserQuery) QueryMods() *ModQuery { + query := (&ModClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, user.ModsTable, user.ModsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryGroups chains the current query on the "groups" edge. +func (uq *UserQuery) QueryGroups() *UserGroupQuery { + query := (&UserGroupClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(usergroup.Table, usergroup.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, user.GroupsTable, user.GroupsColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryUserMods chains the current query on the "user_mods" edge. +func (uq *UserQuery) QueryUserMods() *UserModQuery { + query := (&UserModClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(usermod.Table, usermod.UserColumn), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserModsTable, user.UserModsColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first User entity from the query. +// Returns a *NotFoundError when no User was found. +func (uq *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{user.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (uq *UserQuery) FirstX(ctx context.Context) *User { + node, err := uq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first User ID from the query. +// Returns a *NotFoundError when no User ID was found. +func (uq *UserQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{user.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (uq *UserQuery) FirstIDX(ctx context.Context) string { + id, err := uq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single User entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one User entity is found. +// Returns a *NotFoundError when no User entities are found. +func (uq *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{user.Label} + default: + return nil, &NotSingularError{user.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (uq *UserQuery) OnlyX(ctx context.Context) *User { + node, err := uq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only User ID in the query. +// Returns a *NotSingularError when more than one User ID is found. +// Returns a *NotFoundError when no entities are found. +func (uq *UserQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{user.Label} + default: + err = &NotSingularError{user.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (uq *UserQuery) OnlyIDX(ctx context.Context) string { + id, err := uq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Users. +func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { + ctx = setContextOp(ctx, uq.ctx, "All") + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*User, *UserQuery]() + return withInterceptors[[]*User](ctx, uq, qr, uq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (uq *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := uq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of User IDs. +func (uq *UserQuery) IDs(ctx context.Context) (ids []string, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } + ctx = setContextOp(ctx, uq.ctx, "IDs") + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (uq *UserQuery) IDsX(ctx context.Context) []string { + ids, err := uq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (uq *UserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, uq.ctx, "Count") + if err := uq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (uq *UserQuery) CountX(ctx context.Context) int { + count, err := uq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, uq.ctx, "Exist") + switch _, err := uq.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 (uq *UserQuery) ExistX(ctx context.Context) bool { + exist, err := uq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (uq *UserQuery) Clone() *UserQuery { + if uq == nil { + return nil + } + return &UserQuery{ + config: uq.config, + ctx: uq.ctx.Clone(), + order: append([]user.OrderOption{}, uq.order...), + inters: append([]Interceptor{}, uq.inters...), + predicates: append([]predicate.User{}, uq.predicates...), + withGuides: uq.withGuides.Clone(), + withSessions: uq.withSessions.Clone(), + withMods: uq.withMods.Clone(), + withGroups: uq.withGroups.Clone(), + withUserMods: uq.withUserMods.Clone(), + // clone intermediate query. + sql: uq.sql.Clone(), + path: uq.path, + } +} + +// WithGuides tells the query-builder to eager-load the nodes that are connected to +// the "guides" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithGuides(opts ...func(*GuideQuery)) *UserQuery { + query := (&GuideClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withGuides = query + return uq +} + +// WithSessions tells the query-builder to eager-load the nodes that are connected to +// the "sessions" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithSessions(opts ...func(*UserSessionQuery)) *UserQuery { + query := (&UserSessionClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withSessions = query + return uq +} + +// 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 (uq *UserQuery) WithMods(opts ...func(*ModQuery)) *UserQuery { + query := (&ModClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withMods = query + return uq +} + +// WithGroups tells the query-builder to eager-load the nodes that are connected to +// the "groups" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithGroups(opts ...func(*UserGroupQuery)) *UserQuery { + query := (&UserGroupClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withGroups = query + return uq +} + +// 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 (uq *UserQuery) WithUserMods(opts ...func(*UserModQuery)) *UserQuery { + query := (&UserModClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withUserMods = query + return uq +} + +// 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.User.Query(). +// GroupBy(user.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + uq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupBy{build: uq} + grbuild.flds = &uq.ctx.Fields + grbuild.label = user.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.User.Query(). +// Select(user.FieldCreatedAt). +// Scan(ctx, &v) +func (uq *UserQuery) Select(fields ...string) *UserSelect { + uq.ctx.Fields = append(uq.ctx.Fields, fields...) + sbuild := &UserSelect{UserQuery: uq} + sbuild.label = user.Label + sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserSelect configured with the given aggregations. +func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { + return uq.Select().Aggregate(fns...) +} + +func (uq *UserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range uq.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, uq); err != nil { + return err + } + } + } + for _, f := range uq.ctx.Fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if uq.path != nil { + prev, err := uq.path(ctx) + if err != nil { + return err + } + uq.sql = prev + } + return nil +} + +func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { + var ( + nodes = []*User{} + _spec = uq.querySpec() + loadedTypes = [5]bool{ + uq.withGuides != nil, + uq.withSessions != nil, + uq.withMods != nil, + uq.withGroups != nil, + uq.withUserMods != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*User).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &User{config: uq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(uq.modifiers) > 0 { + _spec.Modifiers = uq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := uq.withGuides; query != nil { + if err := uq.loadGuides(ctx, query, nodes, + func(n *User) { n.Edges.Guides = []*Guide{} }, + func(n *User, e *Guide) { n.Edges.Guides = append(n.Edges.Guides, e) }); err != nil { + return nil, err + } + } + if query := uq.withSessions; query != nil { + if err := uq.loadSessions(ctx, query, nodes, + func(n *User) { n.Edges.Sessions = []*UserSession{} }, + func(n *User, e *UserSession) { n.Edges.Sessions = append(n.Edges.Sessions, e) }); err != nil { + return nil, err + } + } + if query := uq.withMods; query != nil { + if err := uq.loadMods(ctx, query, nodes, + func(n *User) { n.Edges.Mods = []*Mod{} }, + func(n *User, e *Mod) { n.Edges.Mods = append(n.Edges.Mods, e) }); err != nil { + return nil, err + } + } + if query := uq.withGroups; query != nil { + if err := uq.loadGroups(ctx, query, nodes, + func(n *User) { n.Edges.Groups = []*UserGroup{} }, + func(n *User, e *UserGroup) { n.Edges.Groups = append(n.Edges.Groups, e) }); err != nil { + return nil, err + } + } + if query := uq.withUserMods; query != nil { + if err := uq.loadUserMods(ctx, query, nodes, + func(n *User) { n.Edges.UserMods = []*UserMod{} }, + func(n *User, e *UserMod) { n.Edges.UserMods = append(n.Edges.UserMods, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (uq *UserQuery) loadGuides(ctx context.Context, query *GuideQuery, nodes []*User, init func(*User), assign func(*User, *Guide)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Guide(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.GuidesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_id + if fk == nil { + return fmt.Errorf(`foreign-key "user_id" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (uq *UserQuery) loadSessions(ctx context.Context, query *UserSessionQuery, nodes []*User, init func(*User), assign func(*User, *UserSession)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.UserSession(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.SessionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.user_id + if fk == nil { + return fmt.Errorf(`foreign-key "user_id" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (uq *UserQuery) loadMods(ctx context.Context, query *ModQuery, nodes []*User, init func(*User), assign func(*User, *Mod)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*User) + nids := make(map[string]map[*User]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(user.ModsTable) + s.Join(joinT).On(s.C(mod.FieldID), joinT.C(user.ModsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(user.ModsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(user.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[*User]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 (uq *UserQuery) loadGroups(ctx context.Context, query *UserGroupQuery, nodes []*User, init func(*User), assign func(*User, *UserGroup)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + 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(usergroup.FieldUserID) + } + query.Where(predicate.UserGroup(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.GroupsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.UserID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (uq *UserQuery) loadUserMods(ctx context.Context, query *UserModQuery, nodes []*User, init func(*User), assign func(*User, *UserMod)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + 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(usermod.FieldUserID) + } + query.Where(predicate.UserMod(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.UserModsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.UserID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} + +func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := uq.querySpec() + if len(uq.modifiers) > 0 { + _spec.Modifiers = uq.modifiers + } + _spec.Node.Columns = uq.ctx.Fields + if len(uq.ctx.Fields) > 0 { + _spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, uq.driver, _spec) +} + +func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) + _spec.From = uq.sql + if unique := uq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true + } + if fields := uq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for i := range fields { + if fields[i] != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := uq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := uq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := uq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := uq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(uq.driver.Dialect()) + t1 := builder.Table(user.Table) + columns := uq.ctx.Fields + if len(columns) == 0 { + columns = user.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if uq.sql != nil { + selector = uq.sql + selector.Select(selector.Columns(columns...)...) + } + if uq.ctx.Unique != nil && *uq.ctx.Unique { + selector.Distinct() + } + for _, m := range uq.modifiers { + m(selector) + } + for _, p := range uq.predicates { + p(selector) + } + for _, p := range uq.order { + p(selector) + } + if offset := uq.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 := uq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + uq.modifiers = append(uq.modifiers, modifiers...) + return uq.Select() +} + +// UserGroupBy is the group-by builder for User entities. +type UserGroupBy struct { + selector + build *UserQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + ugb.fns = append(ugb.fns, fns...) + return ugb +} + +// Scan applies the selector query and scans the result into the given value. +func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy") + if err := ugb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v) +} + +func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ugb.fns)) + for _, fn := range ugb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns)) + for _, f := range *ugb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ugb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserSelect is the builder for selecting fields of User entities. +type UserSelect struct { + *UserQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { + us.fns = append(us.fns, fns...) + return us +} + +// Scan applies the selector query and scans the result into the given value. +func (us *UserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, us.ctx, "Select") + if err := us.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v) +} + +func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(us.fns)) + for _, fn := range us.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*us.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 := us.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 (us *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + us.modifiers = append(us.modifiers, modifiers...) + return us +} diff --git a/generated/ent/user_update.go b/generated/ent/user_update.go new file mode 100644 index 00000000..d015907e --- /dev/null +++ b/generated/ent/user_update.go @@ -0,0 +1,1394 @@ +// 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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserUpdate is the builder for updating User entities. +type UserUpdate struct { + config + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserUpdate builder. +func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + uu.mutation.Where(ps...) + return uu +} + +// SetUpdatedAt sets the "updated_at" field. +func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate { + uu.mutation.SetUpdatedAt(t) + return uu +} + +// SetDeletedAt sets the "deleted_at" field. +func (uu *UserUpdate) SetDeletedAt(t time.Time) *UserUpdate { + uu.mutation.SetDeletedAt(t) + return uu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (uu *UserUpdate) SetNillableDeletedAt(t *time.Time) *UserUpdate { + if t != nil { + uu.SetDeletedAt(*t) + } + return uu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (uu *UserUpdate) ClearDeletedAt() *UserUpdate { + uu.mutation.ClearDeletedAt() + return uu +} + +// SetEmail sets the "email" field. +func (uu *UserUpdate) SetEmail(s string) *UserUpdate { + uu.mutation.SetEmail(s) + return uu +} + +// SetUsername sets the "username" field. +func (uu *UserUpdate) SetUsername(s string) *UserUpdate { + uu.mutation.SetUsername(s) + return uu +} + +// SetAvatar sets the "avatar" field. +func (uu *UserUpdate) SetAvatar(s string) *UserUpdate { + uu.mutation.SetAvatar(s) + return uu +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (uu *UserUpdate) SetNillableAvatar(s *string) *UserUpdate { + if s != nil { + uu.SetAvatar(*s) + } + return uu +} + +// ClearAvatar clears the value of the "avatar" field. +func (uu *UserUpdate) ClearAvatar() *UserUpdate { + uu.mutation.ClearAvatar() + return uu +} + +// SetJoinedFrom sets the "joined_from" field. +func (uu *UserUpdate) SetJoinedFrom(s string) *UserUpdate { + uu.mutation.SetJoinedFrom(s) + return uu +} + +// SetNillableJoinedFrom sets the "joined_from" field if the given value is not nil. +func (uu *UserUpdate) SetNillableJoinedFrom(s *string) *UserUpdate { + if s != nil { + uu.SetJoinedFrom(*s) + } + return uu +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (uu *UserUpdate) ClearJoinedFrom() *UserUpdate { + uu.mutation.ClearJoinedFrom() + return uu +} + +// SetBanned sets the "banned" field. +func (uu *UserUpdate) SetBanned(b bool) *UserUpdate { + uu.mutation.SetBanned(b) + return uu +} + +// SetNillableBanned sets the "banned" field if the given value is not nil. +func (uu *UserUpdate) SetNillableBanned(b *bool) *UserUpdate { + if b != nil { + uu.SetBanned(*b) + } + return uu +} + +// SetRank sets the "rank" field. +func (uu *UserUpdate) SetRank(i int) *UserUpdate { + uu.mutation.ResetRank() + uu.mutation.SetRank(i) + return uu +} + +// SetNillableRank sets the "rank" field if the given value is not nil. +func (uu *UserUpdate) SetNillableRank(i *int) *UserUpdate { + if i != nil { + uu.SetRank(*i) + } + return uu +} + +// AddRank adds i to the "rank" field. +func (uu *UserUpdate) AddRank(i int) *UserUpdate { + uu.mutation.AddRank(i) + return uu +} + +// SetGithubID sets the "github_id" field. +func (uu *UserUpdate) SetGithubID(s string) *UserUpdate { + uu.mutation.SetGithubID(s) + return uu +} + +// SetNillableGithubID sets the "github_id" field if the given value is not nil. +func (uu *UserUpdate) SetNillableGithubID(s *string) *UserUpdate { + if s != nil { + uu.SetGithubID(*s) + } + return uu +} + +// ClearGithubID clears the value of the "github_id" field. +func (uu *UserUpdate) ClearGithubID() *UserUpdate { + uu.mutation.ClearGithubID() + return uu +} + +// SetGoogleID sets the "google_id" field. +func (uu *UserUpdate) SetGoogleID(s string) *UserUpdate { + uu.mutation.SetGoogleID(s) + return uu +} + +// SetNillableGoogleID sets the "google_id" field if the given value is not nil. +func (uu *UserUpdate) SetNillableGoogleID(s *string) *UserUpdate { + if s != nil { + uu.SetGoogleID(*s) + } + return uu +} + +// ClearGoogleID clears the value of the "google_id" field. +func (uu *UserUpdate) ClearGoogleID() *UserUpdate { + uu.mutation.ClearGoogleID() + return uu +} + +// SetFacebookID sets the "facebook_id" field. +func (uu *UserUpdate) SetFacebookID(s string) *UserUpdate { + uu.mutation.SetFacebookID(s) + return uu +} + +// SetNillableFacebookID sets the "facebook_id" field if the given value is not nil. +func (uu *UserUpdate) SetNillableFacebookID(s *string) *UserUpdate { + if s != nil { + uu.SetFacebookID(*s) + } + return uu +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (uu *UserUpdate) ClearFacebookID() *UserUpdate { + uu.mutation.ClearFacebookID() + return uu +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (uu *UserUpdate) AddGuideIDs(ids ...string) *UserUpdate { + uu.mutation.AddGuideIDs(ids...) + return uu +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (uu *UserUpdate) AddGuides(g ...*Guide) *UserUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return uu.AddGuideIDs(ids...) +} + +// AddSessionIDs adds the "sessions" edge to the UserSession entity by IDs. +func (uu *UserUpdate) AddSessionIDs(ids ...string) *UserUpdate { + uu.mutation.AddSessionIDs(ids...) + return uu +} + +// AddSessions adds the "sessions" edges to the UserSession entity. +func (uu *UserUpdate) AddSessions(u ...*UserSession) *UserUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.AddSessionIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (uu *UserUpdate) AddModIDs(ids ...string) *UserUpdate { + uu.mutation.AddModIDs(ids...) + return uu +} + +// AddMods adds the "mods" edges to the Mod entity. +func (uu *UserUpdate) AddMods(m ...*Mod) *UserUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return uu.AddModIDs(ids...) +} + +// AddGroupIDs adds the "groups" edge to the UserGroup entity by IDs. +func (uu *UserUpdate) AddGroupIDs(ids ...string) *UserUpdate { + uu.mutation.AddGroupIDs(ids...) + return uu +} + +// AddGroups adds the "groups" edges to the UserGroup entity. +func (uu *UserUpdate) AddGroups(u ...*UserGroup) *UserUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.AddGroupIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (uu *UserUpdate) Mutation() *UserMutation { + return uu.mutation +} + +// ClearGuides clears all "guides" edges to the Guide entity. +func (uu *UserUpdate) ClearGuides() *UserUpdate { + uu.mutation.ClearGuides() + return uu +} + +// RemoveGuideIDs removes the "guides" edge to Guide entities by IDs. +func (uu *UserUpdate) RemoveGuideIDs(ids ...string) *UserUpdate { + uu.mutation.RemoveGuideIDs(ids...) + return uu +} + +// RemoveGuides removes "guides" edges to Guide entities. +func (uu *UserUpdate) RemoveGuides(g ...*Guide) *UserUpdate { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return uu.RemoveGuideIDs(ids...) +} + +// ClearSessions clears all "sessions" edges to the UserSession entity. +func (uu *UserUpdate) ClearSessions() *UserUpdate { + uu.mutation.ClearSessions() + return uu +} + +// RemoveSessionIDs removes the "sessions" edge to UserSession entities by IDs. +func (uu *UserUpdate) RemoveSessionIDs(ids ...string) *UserUpdate { + uu.mutation.RemoveSessionIDs(ids...) + return uu +} + +// RemoveSessions removes "sessions" edges to UserSession entities. +func (uu *UserUpdate) RemoveSessions(u ...*UserSession) *UserUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.RemoveSessionIDs(ids...) +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (uu *UserUpdate) ClearMods() *UserUpdate { + uu.mutation.ClearMods() + return uu +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (uu *UserUpdate) RemoveModIDs(ids ...string) *UserUpdate { + uu.mutation.RemoveModIDs(ids...) + return uu +} + +// RemoveMods removes "mods" edges to Mod entities. +func (uu *UserUpdate) RemoveMods(m ...*Mod) *UserUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return uu.RemoveModIDs(ids...) +} + +// ClearGroups clears all "groups" edges to the UserGroup entity. +func (uu *UserUpdate) ClearGroups() *UserUpdate { + uu.mutation.ClearGroups() + return uu +} + +// RemoveGroupIDs removes the "groups" edge to UserGroup entities by IDs. +func (uu *UserUpdate) RemoveGroupIDs(ids ...string) *UserUpdate { + uu.mutation.RemoveGroupIDs(ids...) + return uu +} + +// RemoveGroups removes "groups" edges to UserGroup entities. +func (uu *UserUpdate) RemoveGroups(u ...*UserGroup) *UserUpdate { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.RemoveGroupIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (uu *UserUpdate) Save(ctx context.Context) (int, error) { + if err := uu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uu *UserUpdate) SaveX(ctx context.Context) int { + affected, err := uu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (uu *UserUpdate) Exec(ctx context.Context) error { + _, err := uu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uu *UserUpdate) ExecX(ctx context.Context) { + if err := uu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uu *UserUpdate) defaults() error { + if _, ok := uu.mutation.UpdatedAt(); !ok { + if user.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := user.UpdateDefaultUpdatedAt() + uu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (uu *UserUpdate) check() error { + if v, ok := uu.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := uu.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := uu.mutation.GithubID(); ok { + if err := user.GithubIDValidator(v); err != nil { + return &ValidationError{Name: "github_id", err: fmt.Errorf(`ent: validator failed for field "User.github_id": %w`, err)} + } + } + if v, ok := uu.mutation.GoogleID(); ok { + if err := user.GoogleIDValidator(v); err != nil { + return &ValidationError{Name: "google_id", err: fmt.Errorf(`ent: validator failed for field "User.google_id": %w`, err)} + } + } + if v, ok := uu.mutation.FacebookID(); ok { + if err := user.FacebookIDValidator(v); err != nil { + return &ValidationError{Name: "facebook_id", err: fmt.Errorf(`ent: validator failed for field "User.facebook_id": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (uu *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { + uu.modifiers = append(uu.modifiers, modifiers...) + return uu +} + +func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := uu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) + if ps := uu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uu.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := uu.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + } + if uu.mutation.DeletedAtCleared() { + _spec.ClearField(user.FieldDeletedAt, field.TypeTime) + } + if value, ok := uu.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := uu.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := uu.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if uu.mutation.AvatarCleared() { + _spec.ClearField(user.FieldAvatar, field.TypeString) + } + if value, ok := uu.mutation.JoinedFrom(); ok { + _spec.SetField(user.FieldJoinedFrom, field.TypeString, value) + } + if uu.mutation.JoinedFromCleared() { + _spec.ClearField(user.FieldJoinedFrom, field.TypeString) + } + if value, ok := uu.mutation.Banned(); ok { + _spec.SetField(user.FieldBanned, field.TypeBool, value) + } + if value, ok := uu.mutation.Rank(); ok { + _spec.SetField(user.FieldRank, field.TypeInt, value) + } + if value, ok := uu.mutation.AddedRank(); ok { + _spec.AddField(user.FieldRank, field.TypeInt, value) + } + if value, ok := uu.mutation.GithubID(); ok { + _spec.SetField(user.FieldGithubID, field.TypeString, value) + } + if uu.mutation.GithubIDCleared() { + _spec.ClearField(user.FieldGithubID, field.TypeString) + } + if value, ok := uu.mutation.GoogleID(); ok { + _spec.SetField(user.FieldGoogleID, field.TypeString, value) + } + if uu.mutation.GoogleIDCleared() { + _spec.ClearField(user.FieldGoogleID, field.TypeString) + } + if value, ok := uu.mutation.FacebookID(); ok { + _spec.SetField(user.FieldFacebookID, field.TypeString, value) + } + if uu.mutation.FacebookIDCleared() { + _spec.ClearField(user.FieldFacebookID, field.TypeString) + } + if uu.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedGuidesIDs(); len(nodes) > 0 && !uu.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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 := uu.mutation.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if uu.mutation.SessionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedSessionsIDs(); len(nodes) > 0 && !uu.mutation.SessionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.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 := uu.mutation.SessionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if uu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedModsIDs(); len(nodes) > 0 && !uu.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.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 := uu.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.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 uu.mutation.GroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !uu.mutation.GroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.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 := uu.mutation.GroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.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(uu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + uu.mutation.done = true + return n, nil +} + +// UserUpdateOne is the builder for updating a single User entity. +type UserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne { + uuo.mutation.SetUpdatedAt(t) + return uuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (uuo *UserUpdateOne) SetDeletedAt(t time.Time) *UserUpdateOne { + uuo.mutation.SetDeletedAt(t) + return uuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableDeletedAt(t *time.Time) *UserUpdateOne { + if t != nil { + uuo.SetDeletedAt(*t) + } + return uuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (uuo *UserUpdateOne) ClearDeletedAt() *UserUpdateOne { + uuo.mutation.ClearDeletedAt() + return uuo +} + +// SetEmail sets the "email" field. +func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { + uuo.mutation.SetEmail(s) + return uuo +} + +// SetUsername sets the "username" field. +func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { + uuo.mutation.SetUsername(s) + return uuo +} + +// SetAvatar sets the "avatar" field. +func (uuo *UserUpdateOne) SetAvatar(s string) *UserUpdateOne { + uuo.mutation.SetAvatar(s) + return uuo +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableAvatar(s *string) *UserUpdateOne { + if s != nil { + uuo.SetAvatar(*s) + } + return uuo +} + +// ClearAvatar clears the value of the "avatar" field. +func (uuo *UserUpdateOne) ClearAvatar() *UserUpdateOne { + uuo.mutation.ClearAvatar() + return uuo +} + +// SetJoinedFrom sets the "joined_from" field. +func (uuo *UserUpdateOne) SetJoinedFrom(s string) *UserUpdateOne { + uuo.mutation.SetJoinedFrom(s) + return uuo +} + +// SetNillableJoinedFrom sets the "joined_from" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableJoinedFrom(s *string) *UserUpdateOne { + if s != nil { + uuo.SetJoinedFrom(*s) + } + return uuo +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (uuo *UserUpdateOne) ClearJoinedFrom() *UserUpdateOne { + uuo.mutation.ClearJoinedFrom() + return uuo +} + +// SetBanned sets the "banned" field. +func (uuo *UserUpdateOne) SetBanned(b bool) *UserUpdateOne { + uuo.mutation.SetBanned(b) + return uuo +} + +// SetNillableBanned sets the "banned" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableBanned(b *bool) *UserUpdateOne { + if b != nil { + uuo.SetBanned(*b) + } + return uuo +} + +// SetRank sets the "rank" field. +func (uuo *UserUpdateOne) SetRank(i int) *UserUpdateOne { + uuo.mutation.ResetRank() + uuo.mutation.SetRank(i) + return uuo +} + +// SetNillableRank sets the "rank" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableRank(i *int) *UserUpdateOne { + if i != nil { + uuo.SetRank(*i) + } + return uuo +} + +// AddRank adds i to the "rank" field. +func (uuo *UserUpdateOne) AddRank(i int) *UserUpdateOne { + uuo.mutation.AddRank(i) + return uuo +} + +// SetGithubID sets the "github_id" field. +func (uuo *UserUpdateOne) SetGithubID(s string) *UserUpdateOne { + uuo.mutation.SetGithubID(s) + return uuo +} + +// SetNillableGithubID sets the "github_id" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableGithubID(s *string) *UserUpdateOne { + if s != nil { + uuo.SetGithubID(*s) + } + return uuo +} + +// ClearGithubID clears the value of the "github_id" field. +func (uuo *UserUpdateOne) ClearGithubID() *UserUpdateOne { + uuo.mutation.ClearGithubID() + return uuo +} + +// SetGoogleID sets the "google_id" field. +func (uuo *UserUpdateOne) SetGoogleID(s string) *UserUpdateOne { + uuo.mutation.SetGoogleID(s) + return uuo +} + +// SetNillableGoogleID sets the "google_id" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableGoogleID(s *string) *UserUpdateOne { + if s != nil { + uuo.SetGoogleID(*s) + } + return uuo +} + +// ClearGoogleID clears the value of the "google_id" field. +func (uuo *UserUpdateOne) ClearGoogleID() *UserUpdateOne { + uuo.mutation.ClearGoogleID() + return uuo +} + +// SetFacebookID sets the "facebook_id" field. +func (uuo *UserUpdateOne) SetFacebookID(s string) *UserUpdateOne { + uuo.mutation.SetFacebookID(s) + return uuo +} + +// SetNillableFacebookID sets the "facebook_id" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableFacebookID(s *string) *UserUpdateOne { + if s != nil { + uuo.SetFacebookID(*s) + } + return uuo +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (uuo *UserUpdateOne) ClearFacebookID() *UserUpdateOne { + uuo.mutation.ClearFacebookID() + return uuo +} + +// AddGuideIDs adds the "guides" edge to the Guide entity by IDs. +func (uuo *UserUpdateOne) AddGuideIDs(ids ...string) *UserUpdateOne { + uuo.mutation.AddGuideIDs(ids...) + return uuo +} + +// AddGuides adds the "guides" edges to the Guide entity. +func (uuo *UserUpdateOne) AddGuides(g ...*Guide) *UserUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return uuo.AddGuideIDs(ids...) +} + +// AddSessionIDs adds the "sessions" edge to the UserSession entity by IDs. +func (uuo *UserUpdateOne) AddSessionIDs(ids ...string) *UserUpdateOne { + uuo.mutation.AddSessionIDs(ids...) + return uuo +} + +// AddSessions adds the "sessions" edges to the UserSession entity. +func (uuo *UserUpdateOne) AddSessions(u ...*UserSession) *UserUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.AddSessionIDs(ids...) +} + +// AddModIDs adds the "mods" edge to the Mod entity by IDs. +func (uuo *UserUpdateOne) AddModIDs(ids ...string) *UserUpdateOne { + uuo.mutation.AddModIDs(ids...) + return uuo +} + +// AddMods adds the "mods" edges to the Mod entity. +func (uuo *UserUpdateOne) AddMods(m ...*Mod) *UserUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return uuo.AddModIDs(ids...) +} + +// AddGroupIDs adds the "groups" edge to the UserGroup entity by IDs. +func (uuo *UserUpdateOne) AddGroupIDs(ids ...string) *UserUpdateOne { + uuo.mutation.AddGroupIDs(ids...) + return uuo +} + +// AddGroups adds the "groups" edges to the UserGroup entity. +func (uuo *UserUpdateOne) AddGroups(u ...*UserGroup) *UserUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.AddGroupIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (uuo *UserUpdateOne) Mutation() *UserMutation { + return uuo.mutation +} + +// ClearGuides clears all "guides" edges to the Guide entity. +func (uuo *UserUpdateOne) ClearGuides() *UserUpdateOne { + uuo.mutation.ClearGuides() + return uuo +} + +// RemoveGuideIDs removes the "guides" edge to Guide entities by IDs. +func (uuo *UserUpdateOne) RemoveGuideIDs(ids ...string) *UserUpdateOne { + uuo.mutation.RemoveGuideIDs(ids...) + return uuo +} + +// RemoveGuides removes "guides" edges to Guide entities. +func (uuo *UserUpdateOne) RemoveGuides(g ...*Guide) *UserUpdateOne { + ids := make([]string, len(g)) + for i := range g { + ids[i] = g[i].ID + } + return uuo.RemoveGuideIDs(ids...) +} + +// ClearSessions clears all "sessions" edges to the UserSession entity. +func (uuo *UserUpdateOne) ClearSessions() *UserUpdateOne { + uuo.mutation.ClearSessions() + return uuo +} + +// RemoveSessionIDs removes the "sessions" edge to UserSession entities by IDs. +func (uuo *UserUpdateOne) RemoveSessionIDs(ids ...string) *UserUpdateOne { + uuo.mutation.RemoveSessionIDs(ids...) + return uuo +} + +// RemoveSessions removes "sessions" edges to UserSession entities. +func (uuo *UserUpdateOne) RemoveSessions(u ...*UserSession) *UserUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.RemoveSessionIDs(ids...) +} + +// ClearMods clears all "mods" edges to the Mod entity. +func (uuo *UserUpdateOne) ClearMods() *UserUpdateOne { + uuo.mutation.ClearMods() + return uuo +} + +// RemoveModIDs removes the "mods" edge to Mod entities by IDs. +func (uuo *UserUpdateOne) RemoveModIDs(ids ...string) *UserUpdateOne { + uuo.mutation.RemoveModIDs(ids...) + return uuo +} + +// RemoveMods removes "mods" edges to Mod entities. +func (uuo *UserUpdateOne) RemoveMods(m ...*Mod) *UserUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return uuo.RemoveModIDs(ids...) +} + +// ClearGroups clears all "groups" edges to the UserGroup entity. +func (uuo *UserUpdateOne) ClearGroups() *UserUpdateOne { + uuo.mutation.ClearGroups() + return uuo +} + +// RemoveGroupIDs removes the "groups" edge to UserGroup entities by IDs. +func (uuo *UserUpdateOne) RemoveGroupIDs(ids ...string) *UserUpdateOne { + uuo.mutation.RemoveGroupIDs(ids...) + return uuo +} + +// RemoveGroups removes "groups" edges to UserGroup entities. +func (uuo *UserUpdateOne) RemoveGroups(u ...*UserGroup) *UserUpdateOne { + ids := make([]string, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.RemoveGroupIDs(ids...) +} + +// Where appends a list predicates to the UserUpdate builder. +func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { + uuo.mutation.Where(ps...) + return uuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + uuo.fields = append([]string{field}, fields...) + return uuo +} + +// Save executes the query and returns the updated User entity. +func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { + if err := uuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := uuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uuo *UserUpdateOne) Exec(ctx context.Context) error { + _, err := uuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uuo *UserUpdateOne) ExecX(ctx context.Context) { + if err := uuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uuo *UserUpdateOne) defaults() error { + if _, ok := uuo.mutation.UpdatedAt(); !ok { + if user.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := user.UpdateDefaultUpdatedAt() + uuo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (uuo *UserUpdateOne) check() error { + if v, ok := uuo.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := uuo.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := uuo.mutation.GithubID(); ok { + if err := user.GithubIDValidator(v); err != nil { + return &ValidationError{Name: "github_id", err: fmt.Errorf(`ent: validator failed for field "User.github_id": %w`, err)} + } + } + if v, ok := uuo.mutation.GoogleID(); ok { + if err := user.GoogleIDValidator(v); err != nil { + return &ValidationError{Name: "google_id", err: fmt.Errorf(`ent: validator failed for field "User.google_id": %w`, err)} + } + } + if v, ok := uuo.mutation.FacebookID(); ok { + if err := user.FacebookIDValidator(v); err != nil { + return &ValidationError{Name: "facebook_id", err: fmt.Errorf(`ent: validator failed for field "User.facebook_id": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (uuo *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { + uuo.modifiers = append(uuo.modifiers, modifiers...) + return uuo +} + +func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + if err := uuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) + id, ok := uuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := uuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for _, f := range fields { + if !user.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := uuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uuo.mutation.UpdatedAt(); ok { + _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := uuo.mutation.DeletedAt(); ok { + _spec.SetField(user.FieldDeletedAt, field.TypeTime, value) + } + if uuo.mutation.DeletedAtCleared() { + _spec.ClearField(user.FieldDeletedAt, field.TypeTime) + } + if value, ok := uuo.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := uuo.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := uuo.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if uuo.mutation.AvatarCleared() { + _spec.ClearField(user.FieldAvatar, field.TypeString) + } + if value, ok := uuo.mutation.JoinedFrom(); ok { + _spec.SetField(user.FieldJoinedFrom, field.TypeString, value) + } + if uuo.mutation.JoinedFromCleared() { + _spec.ClearField(user.FieldJoinedFrom, field.TypeString) + } + if value, ok := uuo.mutation.Banned(); ok { + _spec.SetField(user.FieldBanned, field.TypeBool, value) + } + if value, ok := uuo.mutation.Rank(); ok { + _spec.SetField(user.FieldRank, field.TypeInt, value) + } + if value, ok := uuo.mutation.AddedRank(); ok { + _spec.AddField(user.FieldRank, field.TypeInt, value) + } + if value, ok := uuo.mutation.GithubID(); ok { + _spec.SetField(user.FieldGithubID, field.TypeString, value) + } + if uuo.mutation.GithubIDCleared() { + _spec.ClearField(user.FieldGithubID, field.TypeString) + } + if value, ok := uuo.mutation.GoogleID(); ok { + _spec.SetField(user.FieldGoogleID, field.TypeString, value) + } + if uuo.mutation.GoogleIDCleared() { + _spec.ClearField(user.FieldGoogleID, field.TypeString) + } + if value, ok := uuo.mutation.FacebookID(); ok { + _spec.SetField(user.FieldFacebookID, field.TypeString, value) + } + if uuo.mutation.FacebookIDCleared() { + _spec.ClearField(user.FieldFacebookID, field.TypeString) + } + if uuo.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedGuidesIDs(); len(nodes) > 0 && !uuo.mutation.GuidesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.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 := uuo.mutation.GuidesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GuidesTable, + Columns: []string{user.GuidesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if uuo.mutation.SessionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedSessionsIDs(); len(nodes) > 0 && !uuo.mutation.SessionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.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 := uuo.mutation.SessionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.SessionsTable, + Columns: []string{user.SessionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if uuo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.ModsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedModsIDs(); len(nodes) > 0 && !uuo.mutation.ModsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.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 := uuo.mutation.ModsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.ModsTable, + Columns: user.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 uuo.mutation.GroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !uuo.mutation.GroupsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.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 := uuo.mutation.GroupsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: user.GroupsTable, + Columns: []string{user.GroupsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usergroup.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(uuo.modifiers...) + _node = &User{config: uuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + uuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/usergroup.go b/generated/ent/usergroup.go new file mode 100644 index 00000000..6b41c6d2 --- /dev/null +++ b/generated/ent/usergroup.go @@ -0,0 +1,179 @@ +// 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/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" +) + +// UserGroup is the model entity for the UserGroup schema. +type UserGroup 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // UserID holds the value of the "user_id" field. + UserID string `json:"user_id,omitempty"` + // GroupID holds the value of the "group_id" field. + GroupID string `json:"group_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserGroupQuery when eager-loading is set. + Edges UserGroupEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserGroupEdges holds the relations/edges for other nodes in the graph. +type UserGroupEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserGroupEdges) UserOrErr() (*User, error) { + if e.loadedTypes[0] { + if e.User == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.User, nil + } + return nil, &NotLoadedError{edge: "user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserGroup) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case usergroup.FieldID, usergroup.FieldUserID, usergroup.FieldGroupID: + values[i] = new(sql.NullString) + case usergroup.FieldCreatedAt, usergroup.FieldUpdatedAt, usergroup.FieldDeletedAt: + 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 UserGroup fields. +func (ug *UserGroup) 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 usergroup.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + ug.ID = value.String + } + case usergroup.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 { + ug.CreatedAt = value.Time + } + case usergroup.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 { + ug.UpdatedAt = value.Time + } + case usergroup.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + ug.DeletedAt = value.Time + } + case usergroup.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + ug.UserID = value.String + } + case usergroup.FieldGroupID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field group_id", values[i]) + } else if value.Valid { + ug.GroupID = value.String + } + default: + ug.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserGroup. +// This includes values selected through modifiers, order, etc. +func (ug *UserGroup) Value(name string) (ent.Value, error) { + return ug.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the UserGroup entity. +func (ug *UserGroup) QueryUser() *UserQuery { + return NewUserGroupClient(ug.config).QueryUser(ug) +} + +// Update returns a builder for updating this UserGroup. +// Note that you need to call UserGroup.Unwrap() before calling this method if this UserGroup +// was returned from a transaction, and the transaction was committed or rolled back. +func (ug *UserGroup) Update() *UserGroupUpdateOne { + return NewUserGroupClient(ug.config).UpdateOne(ug) +} + +// Unwrap unwraps the UserGroup 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 (ug *UserGroup) Unwrap() *UserGroup { + _tx, ok := ug.config.driver.(*txDriver) + if !ok { + panic("ent: UserGroup is not a transactional entity") + } + ug.config.driver = _tx.drv + return ug +} + +// String implements the fmt.Stringer. +func (ug *UserGroup) String() string { + var builder strings.Builder + builder.WriteString("UserGroup(") + builder.WriteString(fmt.Sprintf("id=%v, ", ug.ID)) + builder.WriteString("created_at=") + builder.WriteString(ug.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(ug.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(ug.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(ug.UserID) + builder.WriteString(", ") + builder.WriteString("group_id=") + builder.WriteString(ug.GroupID) + builder.WriteByte(')') + return builder.String() +} + +// UserGroups is a parsable slice of UserGroup. +type UserGroups []*UserGroup diff --git a/generated/ent/usergroup/usergroup.go b/generated/ent/usergroup/usergroup.go new file mode 100644 index 00000000..3cb12eb4 --- /dev/null +++ b/generated/ent/usergroup/usergroup.go @@ -0,0 +1,128 @@ +// Code generated by ent, DO NOT EDIT. + +package usergroup + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the usergroup type in the database. + Label = "user_group" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldGroupID holds the string denoting the group_id field in the database. + FieldGroupID = "group_id" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // Table holds the table name of the usergroup in the database. + Table = "user_groups" + // UserTable is the table that holds the user relation/edge. + UserTable = "user_groups" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" +) + +// Columns holds all SQL columns for usergroup fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldUserID, + FieldGroupID, +} + +// 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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(string) error + // GroupIDValidator is a validator for the "group_id" field. It is called by the builders before save. + GroupIDValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the UserGroup 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByGroupID orders the results by the group_id field. +func ByGroupID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGroupID, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) +} diff --git a/generated/ent/usergroup/where.go b/generated/ent/usergroup/where.go new file mode 100644 index 00000000..3bd8384b --- /dev/null +++ b/generated/ent/usergroup/where.go @@ -0,0 +1,389 @@ +// Code generated by ent, DO NOT EDIT. + +package usergroup + +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.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.UserGroup { + return predicate.UserGroup(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.UserGroup { + return predicate.UserGroup(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.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldDeletedAt, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldUserID, v)) +} + +// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ. +func GroupID(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldGroupID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.UserGroup { + return predicate.UserGroup(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotNull(FieldDeletedAt)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldContainsFold(FieldUserID, v)) +} + +// GroupIDEQ applies the EQ predicate on the "group_id" field. +func GroupIDEQ(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEQ(FieldGroupID, v)) +} + +// GroupIDNEQ applies the NEQ predicate on the "group_id" field. +func GroupIDNEQ(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNEQ(FieldGroupID, v)) +} + +// GroupIDIn applies the In predicate on the "group_id" field. +func GroupIDIn(vs ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldIn(FieldGroupID, vs...)) +} + +// GroupIDNotIn applies the NotIn predicate on the "group_id" field. +func GroupIDNotIn(vs ...string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldNotIn(FieldGroupID, vs...)) +} + +// GroupIDGT applies the GT predicate on the "group_id" field. +func GroupIDGT(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGT(FieldGroupID, v)) +} + +// GroupIDGTE applies the GTE predicate on the "group_id" field. +func GroupIDGTE(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldGTE(FieldGroupID, v)) +} + +// GroupIDLT applies the LT predicate on the "group_id" field. +func GroupIDLT(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLT(FieldGroupID, v)) +} + +// GroupIDLTE applies the LTE predicate on the "group_id" field. +func GroupIDLTE(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldLTE(FieldGroupID, v)) +} + +// GroupIDContains applies the Contains predicate on the "group_id" field. +func GroupIDContains(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldContains(FieldGroupID, v)) +} + +// GroupIDHasPrefix applies the HasPrefix predicate on the "group_id" field. +func GroupIDHasPrefix(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldHasPrefix(FieldGroupID, v)) +} + +// GroupIDHasSuffix applies the HasSuffix predicate on the "group_id" field. +func GroupIDHasSuffix(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldHasSuffix(FieldGroupID, v)) +} + +// GroupIDEqualFold applies the EqualFold predicate on the "group_id" field. +func GroupIDEqualFold(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldEqualFold(FieldGroupID, v)) +} + +// GroupIDContainsFold applies the ContainsFold predicate on the "group_id" field. +func GroupIDContainsFold(v string) predicate.UserGroup { + return predicate.UserGroup(sql.FieldContainsFold(FieldGroupID, v)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserGroup { + return predicate.UserGroup(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserGroup { + return predicate.UserGroup(func(s *sql.Selector) { + step := newUserStep() + 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.UserGroup) predicate.UserGroup { + return predicate.UserGroup(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserGroup) predicate.UserGroup { + return predicate.UserGroup(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserGroup) predicate.UserGroup { + return predicate.UserGroup(sql.NotPredicates(p)) +} diff --git a/generated/ent/usergroup_create.go b/generated/ent/usergroup_create.go new file mode 100644 index 00000000..0d25586b --- /dev/null +++ b/generated/ent/usergroup_create.go @@ -0,0 +1,338 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" +) + +// UserGroupCreate is the builder for creating a UserGroup entity. +type UserGroupCreate struct { + config + mutation *UserGroupMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (ugc *UserGroupCreate) SetCreatedAt(t time.Time) *UserGroupCreate { + ugc.mutation.SetCreatedAt(t) + return ugc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (ugc *UserGroupCreate) SetNillableCreatedAt(t *time.Time) *UserGroupCreate { + if t != nil { + ugc.SetCreatedAt(*t) + } + return ugc +} + +// SetUpdatedAt sets the "updated_at" field. +func (ugc *UserGroupCreate) SetUpdatedAt(t time.Time) *UserGroupCreate { + ugc.mutation.SetUpdatedAt(t) + return ugc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (ugc *UserGroupCreate) SetNillableUpdatedAt(t *time.Time) *UserGroupCreate { + if t != nil { + ugc.SetUpdatedAt(*t) + } + return ugc +} + +// SetDeletedAt sets the "deleted_at" field. +func (ugc *UserGroupCreate) SetDeletedAt(t time.Time) *UserGroupCreate { + ugc.mutation.SetDeletedAt(t) + return ugc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ugc *UserGroupCreate) SetNillableDeletedAt(t *time.Time) *UserGroupCreate { + if t != nil { + ugc.SetDeletedAt(*t) + } + return ugc +} + +// SetUserID sets the "user_id" field. +func (ugc *UserGroupCreate) SetUserID(s string) *UserGroupCreate { + ugc.mutation.SetUserID(s) + return ugc +} + +// SetGroupID sets the "group_id" field. +func (ugc *UserGroupCreate) SetGroupID(s string) *UserGroupCreate { + ugc.mutation.SetGroupID(s) + return ugc +} + +// SetID sets the "id" field. +func (ugc *UserGroupCreate) SetID(s string) *UserGroupCreate { + ugc.mutation.SetID(s) + return ugc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (ugc *UserGroupCreate) SetNillableID(s *string) *UserGroupCreate { + if s != nil { + ugc.SetID(*s) + } + return ugc +} + +// SetUser sets the "user" edge to the User entity. +func (ugc *UserGroupCreate) SetUser(u *User) *UserGroupCreate { + return ugc.SetUserID(u.ID) +} + +// Mutation returns the UserGroupMutation object of the builder. +func (ugc *UserGroupCreate) Mutation() *UserGroupMutation { + return ugc.mutation +} + +// Save creates the UserGroup in the database. +func (ugc *UserGroupCreate) Save(ctx context.Context) (*UserGroup, error) { + if err := ugc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, ugc.sqlSave, ugc.mutation, ugc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (ugc *UserGroupCreate) SaveX(ctx context.Context) *UserGroup { + v, err := ugc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ugc *UserGroupCreate) Exec(ctx context.Context) error { + _, err := ugc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ugc *UserGroupCreate) ExecX(ctx context.Context) { + if err := ugc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ugc *UserGroupCreate) defaults() error { + if _, ok := ugc.mutation.CreatedAt(); !ok { + if usergroup.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized usergroup.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := usergroup.DefaultCreatedAt() + ugc.mutation.SetCreatedAt(v) + } + if _, ok := ugc.mutation.UpdatedAt(); !ok { + if usergroup.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usergroup.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usergroup.DefaultUpdatedAt() + ugc.mutation.SetUpdatedAt(v) + } + if _, ok := ugc.mutation.ID(); !ok { + if usergroup.DefaultID == nil { + return fmt.Errorf("ent: uninitialized usergroup.DefaultID (forgotten import ent/runtime?)") + } + v := usergroup.DefaultID() + ugc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (ugc *UserGroupCreate) check() error { + if _, ok := ugc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserGroup.created_at"`)} + } + if _, ok := ugc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserGroup.updated_at"`)} + } + if _, ok := ugc.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserGroup.user_id"`)} + } + if v, ok := ugc.mutation.UserID(); ok { + if err := usergroup.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.user_id": %w`, err)} + } + } + if _, ok := ugc.mutation.GroupID(); !ok { + return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "UserGroup.group_id"`)} + } + if v, ok := ugc.mutation.GroupID(); ok { + if err := usergroup.GroupIDValidator(v); err != nil { + return &ValidationError{Name: "group_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.group_id": %w`, err)} + } + } + if _, ok := ugc.mutation.UserID(); !ok { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserGroup.user"`)} + } + return nil +} + +func (ugc *UserGroupCreate) sqlSave(ctx context.Context) (*UserGroup, error) { + if err := ugc.check(); err != nil { + return nil, err + } + _node, _spec := ugc.createSpec() + if err := sqlgraph.CreateNode(ctx, ugc.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 UserGroup.ID type: %T", _spec.ID.Value) + } + } + ugc.mutation.id = &_node.ID + ugc.mutation.done = true + return _node, nil +} + +func (ugc *UserGroupCreate) createSpec() (*UserGroup, *sqlgraph.CreateSpec) { + var ( + _node = &UserGroup{config: ugc.config} + _spec = sqlgraph.NewCreateSpec(usergroup.Table, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) + ) + if id, ok := ugc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := ugc.mutation.CreatedAt(); ok { + _spec.SetField(usergroup.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := ugc.mutation.UpdatedAt(); ok { + _spec.SetField(usergroup.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := ugc.mutation.DeletedAt(); ok { + _spec.SetField(usergroup.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := ugc.mutation.GroupID(); ok { + _spec.SetField(usergroup.FieldGroupID, field.TypeString, value) + _node.GroupID = value + } + if nodes := ugc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usergroup.UserTable, + Columns: []string{usergroup.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.UserID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// UserGroupCreateBulk is the builder for creating many UserGroup entities in bulk. +type UserGroupCreateBulk struct { + config + err error + builders []*UserGroupCreate +} + +// Save creates the UserGroup entities in the database. +func (ugcb *UserGroupCreateBulk) Save(ctx context.Context) ([]*UserGroup, error) { + if ugcb.err != nil { + return nil, ugcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ugcb.builders)) + nodes := make([]*UserGroup, len(ugcb.builders)) + mutators := make([]Mutator, len(ugcb.builders)) + for i := range ugcb.builders { + func(i int, root context.Context) { + builder := ugcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserGroupMutation) + 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, ugcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ugcb.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, ugcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ugcb *UserGroupCreateBulk) SaveX(ctx context.Context) []*UserGroup { + v, err := ugcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ugcb *UserGroupCreateBulk) Exec(ctx context.Context) error { + _, err := ugcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ugcb *UserGroupCreateBulk) ExecX(ctx context.Context) { + if err := ugcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usergroup_delete.go b/generated/ent/usergroup_delete.go new file mode 100644 index 00000000..d7c6abda --- /dev/null +++ b/generated/ent/usergroup_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" +) + +// UserGroupDelete is the builder for deleting a UserGroup entity. +type UserGroupDelete struct { + config + hooks []Hook + mutation *UserGroupMutation +} + +// Where appends a list predicates to the UserGroupDelete builder. +func (ugd *UserGroupDelete) Where(ps ...predicate.UserGroup) *UserGroupDelete { + ugd.mutation.Where(ps...) + return ugd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ugd *UserGroupDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ugd.sqlExec, ugd.mutation, ugd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ugd *UserGroupDelete) ExecX(ctx context.Context) int { + n, err := ugd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ugd *UserGroupDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(usergroup.Table, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) + if ps := ugd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ugd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ugd.mutation.done = true + return affected, err +} + +// UserGroupDeleteOne is the builder for deleting a single UserGroup entity. +type UserGroupDeleteOne struct { + ugd *UserGroupDelete +} + +// Where appends a list predicates to the UserGroupDelete builder. +func (ugdo *UserGroupDeleteOne) Where(ps ...predicate.UserGroup) *UserGroupDeleteOne { + ugdo.ugd.mutation.Where(ps...) + return ugdo +} + +// Exec executes the deletion query. +func (ugdo *UserGroupDeleteOne) Exec(ctx context.Context) error { + n, err := ugdo.ugd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{usergroup.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ugdo *UserGroupDeleteOne) ExecX(ctx context.Context) { + if err := ugdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usergroup_query.go b/generated/ent/usergroup_query.go new file mode 100644 index 00000000..6ecb18e9 --- /dev/null +++ b/generated/ent/usergroup_query.go @@ -0,0 +1,627 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" +) + +// UserGroupQuery is the builder for querying UserGroup entities. +type UserGroupQuery struct { + config + ctx *QueryContext + order []usergroup.OrderOption + inters []Interceptor + predicates []predicate.UserGroup + withUser *UserQuery + 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 UserGroupQuery builder. +func (ugq *UserGroupQuery) Where(ps ...predicate.UserGroup) *UserGroupQuery { + ugq.predicates = append(ugq.predicates, ps...) + return ugq +} + +// Limit the number of records to be returned by this query. +func (ugq *UserGroupQuery) Limit(limit int) *UserGroupQuery { + ugq.ctx.Limit = &limit + return ugq +} + +// Offset to start from. +func (ugq *UserGroupQuery) Offset(offset int) *UserGroupQuery { + ugq.ctx.Offset = &offset + return ugq +} + +// 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 (ugq *UserGroupQuery) Unique(unique bool) *UserGroupQuery { + ugq.ctx.Unique = &unique + return ugq +} + +// Order specifies how the records should be ordered. +func (ugq *UserGroupQuery) Order(o ...usergroup.OrderOption) *UserGroupQuery { + ugq.order = append(ugq.order, o...) + return ugq +} + +// QueryUser chains the current query on the "user" edge. +func (ugq *UserGroupQuery) QueryUser() *UserQuery { + query := (&UserClient{config: ugq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := ugq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := ugq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usergroup.Table, usergroup.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, usergroup.UserTable, usergroup.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(ugq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first UserGroup entity from the query. +// Returns a *NotFoundError when no UserGroup was found. +func (ugq *UserGroupQuery) First(ctx context.Context) (*UserGroup, error) { + nodes, err := ugq.Limit(1).All(setContextOp(ctx, ugq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{usergroup.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (ugq *UserGroupQuery) FirstX(ctx context.Context) *UserGroup { + node, err := ugq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserGroup ID from the query. +// Returns a *NotFoundError when no UserGroup ID was found. +func (ugq *UserGroupQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = ugq.Limit(1).IDs(setContextOp(ctx, ugq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{usergroup.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (ugq *UserGroupQuery) FirstIDX(ctx context.Context) string { + id, err := ugq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserGroup entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserGroup entity is found. +// Returns a *NotFoundError when no UserGroup entities are found. +func (ugq *UserGroupQuery) Only(ctx context.Context) (*UserGroup, error) { + nodes, err := ugq.Limit(2).All(setContextOp(ctx, ugq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{usergroup.Label} + default: + return nil, &NotSingularError{usergroup.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (ugq *UserGroupQuery) OnlyX(ctx context.Context) *UserGroup { + node, err := ugq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserGroup ID in the query. +// Returns a *NotSingularError when more than one UserGroup ID is found. +// Returns a *NotFoundError when no entities are found. +func (ugq *UserGroupQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = ugq.Limit(2).IDs(setContextOp(ctx, ugq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{usergroup.Label} + default: + err = &NotSingularError{usergroup.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (ugq *UserGroupQuery) OnlyIDX(ctx context.Context) string { + id, err := ugq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserGroups. +func (ugq *UserGroupQuery) All(ctx context.Context) ([]*UserGroup, error) { + ctx = setContextOp(ctx, ugq.ctx, "All") + if err := ugq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserGroup, *UserGroupQuery]() + return withInterceptors[[]*UserGroup](ctx, ugq, qr, ugq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (ugq *UserGroupQuery) AllX(ctx context.Context) []*UserGroup { + nodes, err := ugq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserGroup IDs. +func (ugq *UserGroupQuery) IDs(ctx context.Context) (ids []string, err error) { + if ugq.ctx.Unique == nil && ugq.path != nil { + ugq.Unique(true) + } + ctx = setContextOp(ctx, ugq.ctx, "IDs") + if err = ugq.Select(usergroup.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (ugq *UserGroupQuery) IDsX(ctx context.Context) []string { + ids, err := ugq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (ugq *UserGroupQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, ugq.ctx, "Count") + if err := ugq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, ugq, querierCount[*UserGroupQuery](), ugq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (ugq *UserGroupQuery) CountX(ctx context.Context) int { + count, err := ugq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (ugq *UserGroupQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, ugq.ctx, "Exist") + switch _, err := ugq.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 (ugq *UserGroupQuery) ExistX(ctx context.Context) bool { + exist, err := ugq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserGroupQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (ugq *UserGroupQuery) Clone() *UserGroupQuery { + if ugq == nil { + return nil + } + return &UserGroupQuery{ + config: ugq.config, + ctx: ugq.ctx.Clone(), + order: append([]usergroup.OrderOption{}, ugq.order...), + inters: append([]Interceptor{}, ugq.inters...), + predicates: append([]predicate.UserGroup{}, ugq.predicates...), + withUser: ugq.withUser.Clone(), + // clone intermediate query. + sql: ugq.sql.Clone(), + path: ugq.path, + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (ugq *UserGroupQuery) WithUser(opts ...func(*UserQuery)) *UserGroupQuery { + query := (&UserClient{config: ugq.config}).Query() + for _, opt := range opts { + opt(query) + } + ugq.withUser = query + return ugq +} + +// 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.UserGroup.Query(). +// GroupBy(usergroup.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (ugq *UserGroupQuery) GroupBy(field string, fields ...string) *UserGroupGroupBy { + ugq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupGroupBy{build: ugq} + grbuild.flds = &ugq.ctx.Fields + grbuild.label = usergroup.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.UserGroup.Query(). +// Select(usergroup.FieldCreatedAt). +// Scan(ctx, &v) +func (ugq *UserGroupQuery) Select(fields ...string) *UserGroupSelect { + ugq.ctx.Fields = append(ugq.ctx.Fields, fields...) + sbuild := &UserGroupSelect{UserGroupQuery: ugq} + sbuild.label = usergroup.Label + sbuild.flds, sbuild.scan = &ugq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserGroupSelect configured with the given aggregations. +func (ugq *UserGroupQuery) Aggregate(fns ...AggregateFunc) *UserGroupSelect { + return ugq.Select().Aggregate(fns...) +} + +func (ugq *UserGroupQuery) prepareQuery(ctx context.Context) error { + for _, inter := range ugq.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, ugq); err != nil { + return err + } + } + } + for _, f := range ugq.ctx.Fields { + if !usergroup.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if ugq.path != nil { + prev, err := ugq.path(ctx) + if err != nil { + return err + } + ugq.sql = prev + } + return nil +} + +func (ugq *UserGroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserGroup, error) { + var ( + nodes = []*UserGroup{} + _spec = ugq.querySpec() + loadedTypes = [1]bool{ + ugq.withUser != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserGroup).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserGroup{config: ugq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(ugq.modifiers) > 0 { + _spec.Modifiers = ugq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, ugq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := ugq.withUser; query != nil { + if err := ugq.loadUser(ctx, query, nodes, nil, + func(n *UserGroup, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (ugq *UserGroupQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserGroup, init func(*UserGroup), assign func(*UserGroup, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*UserGroup) + for i := range nodes { + fk := nodes[i].UserID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (ugq *UserGroupQuery) sqlCount(ctx context.Context) (int, error) { + _spec := ugq.querySpec() + if len(ugq.modifiers) > 0 { + _spec.Modifiers = ugq.modifiers + } + _spec.Node.Columns = ugq.ctx.Fields + if len(ugq.ctx.Fields) > 0 { + _spec.Unique = ugq.ctx.Unique != nil && *ugq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, ugq.driver, _spec) +} + +func (ugq *UserGroupQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(usergroup.Table, usergroup.Columns, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) + _spec.From = ugq.sql + if unique := ugq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if ugq.path != nil { + _spec.Unique = true + } + if fields := ugq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usergroup.FieldID) + for i := range fields { + if fields[i] != usergroup.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if ugq.withUser != nil { + _spec.Node.AddColumnOnce(usergroup.FieldUserID) + } + } + if ps := ugq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := ugq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := ugq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := ugq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (ugq *UserGroupQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(ugq.driver.Dialect()) + t1 := builder.Table(usergroup.Table) + columns := ugq.ctx.Fields + if len(columns) == 0 { + columns = usergroup.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if ugq.sql != nil { + selector = ugq.sql + selector.Select(selector.Columns(columns...)...) + } + if ugq.ctx.Unique != nil && *ugq.ctx.Unique { + selector.Distinct() + } + for _, m := range ugq.modifiers { + m(selector) + } + for _, p := range ugq.predicates { + p(selector) + } + for _, p := range ugq.order { + p(selector) + } + if offset := ugq.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 := ugq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ugq *UserGroupQuery) Modify(modifiers ...func(s *sql.Selector)) *UserGroupSelect { + ugq.modifiers = append(ugq.modifiers, modifiers...) + return ugq.Select() +} + +// UserGroupGroupBy is the group-by builder for UserGroup entities. +type UserGroupGroupBy struct { + selector + build *UserGroupQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (uggb *UserGroupGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupGroupBy { + uggb.fns = append(uggb.fns, fns...) + return uggb +} + +// Scan applies the selector query and scans the result into the given value. +func (uggb *UserGroupGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, uggb.build.ctx, "GroupBy") + if err := uggb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserGroupQuery, *UserGroupGroupBy](ctx, uggb.build, uggb, uggb.build.inters, v) +} + +func (uggb *UserGroupGroupBy) sqlScan(ctx context.Context, root *UserGroupQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(uggb.fns)) + for _, fn := range uggb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*uggb.flds)+len(uggb.fns)) + for _, f := range *uggb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*uggb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := uggb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserGroupSelect is the builder for selecting fields of UserGroup entities. +type UserGroupSelect struct { + *UserGroupQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ugs *UserGroupSelect) Aggregate(fns ...AggregateFunc) *UserGroupSelect { + ugs.fns = append(ugs.fns, fns...) + return ugs +} + +// Scan applies the selector query and scans the result into the given value. +func (ugs *UserGroupSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ugs.ctx, "Select") + if err := ugs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserGroupQuery, *UserGroupSelect](ctx, ugs.UserGroupQuery, ugs, ugs.inters, v) +} + +func (ugs *UserGroupSelect) sqlScan(ctx context.Context, root *UserGroupQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ugs.fns)) + for _, fn := range ugs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ugs.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 := ugs.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 (ugs *UserGroupSelect) Modify(modifiers ...func(s *sql.Selector)) *UserGroupSelect { + ugs.modifiers = append(ugs.modifiers, modifiers...) + return ugs +} diff --git a/generated/ent/usergroup_update.go b/generated/ent/usergroup_update.go new file mode 100644 index 00000000..d5bf3f5e --- /dev/null +++ b/generated/ent/usergroup_update.go @@ -0,0 +1,445 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" +) + +// UserGroupUpdate is the builder for updating UserGroup entities. +type UserGroupUpdate struct { + config + hooks []Hook + mutation *UserGroupMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserGroupUpdate builder. +func (ugu *UserGroupUpdate) Where(ps ...predicate.UserGroup) *UserGroupUpdate { + ugu.mutation.Where(ps...) + return ugu +} + +// SetUpdatedAt sets the "updated_at" field. +func (ugu *UserGroupUpdate) SetUpdatedAt(t time.Time) *UserGroupUpdate { + ugu.mutation.SetUpdatedAt(t) + return ugu +} + +// SetDeletedAt sets the "deleted_at" field. +func (ugu *UserGroupUpdate) SetDeletedAt(t time.Time) *UserGroupUpdate { + ugu.mutation.SetDeletedAt(t) + return ugu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ugu *UserGroupUpdate) SetNillableDeletedAt(t *time.Time) *UserGroupUpdate { + if t != nil { + ugu.SetDeletedAt(*t) + } + return ugu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (ugu *UserGroupUpdate) ClearDeletedAt() *UserGroupUpdate { + ugu.mutation.ClearDeletedAt() + return ugu +} + +// SetUserID sets the "user_id" field. +func (ugu *UserGroupUpdate) SetUserID(s string) *UserGroupUpdate { + ugu.mutation.SetUserID(s) + return ugu +} + +// SetGroupID sets the "group_id" field. +func (ugu *UserGroupUpdate) SetGroupID(s string) *UserGroupUpdate { + ugu.mutation.SetGroupID(s) + return ugu +} + +// SetUser sets the "user" edge to the User entity. +func (ugu *UserGroupUpdate) SetUser(u *User) *UserGroupUpdate { + return ugu.SetUserID(u.ID) +} + +// Mutation returns the UserGroupMutation object of the builder. +func (ugu *UserGroupUpdate) Mutation() *UserGroupMutation { + return ugu.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (ugu *UserGroupUpdate) ClearUser() *UserGroupUpdate { + ugu.mutation.ClearUser() + return ugu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ugu *UserGroupUpdate) Save(ctx context.Context) (int, error) { + if err := ugu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, ugu.sqlSave, ugu.mutation, ugu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ugu *UserGroupUpdate) SaveX(ctx context.Context) int { + affected, err := ugu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ugu *UserGroupUpdate) Exec(ctx context.Context) error { + _, err := ugu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ugu *UserGroupUpdate) ExecX(ctx context.Context) { + if err := ugu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ugu *UserGroupUpdate) defaults() error { + if _, ok := ugu.mutation.UpdatedAt(); !ok { + if usergroup.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usergroup.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usergroup.UpdateDefaultUpdatedAt() + ugu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (ugu *UserGroupUpdate) check() error { + if v, ok := ugu.mutation.UserID(); ok { + if err := usergroup.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.user_id": %w`, err)} + } + } + if v, ok := ugu.mutation.GroupID(); ok { + if err := usergroup.GroupIDValidator(v); err != nil { + return &ValidationError{Name: "group_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.group_id": %w`, err)} + } + } + if _, ok := ugu.mutation.UserID(); ugu.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserGroup.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (ugu *UserGroupUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserGroupUpdate { + ugu.modifiers = append(ugu.modifiers, modifiers...) + return ugu +} + +func (ugu *UserGroupUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ugu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(usergroup.Table, usergroup.Columns, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) + if ps := ugu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ugu.mutation.UpdatedAt(); ok { + _spec.SetField(usergroup.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := ugu.mutation.DeletedAt(); ok { + _spec.SetField(usergroup.FieldDeletedAt, field.TypeTime, value) + } + if ugu.mutation.DeletedAtCleared() { + _spec.ClearField(usergroup.FieldDeletedAt, field.TypeTime) + } + if value, ok := ugu.mutation.GroupID(); ok { + _spec.SetField(usergroup.FieldGroupID, field.TypeString, value) + } + if ugu.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usergroup.UserTable, + Columns: []string{usergroup.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ugu.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usergroup.UserTable, + Columns: []string{usergroup.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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(ugu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, ugu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usergroup.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ugu.mutation.done = true + return n, nil +} + +// UserGroupUpdateOne is the builder for updating a single UserGroup entity. +type UserGroupUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserGroupMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (uguo *UserGroupUpdateOne) SetUpdatedAt(t time.Time) *UserGroupUpdateOne { + uguo.mutation.SetUpdatedAt(t) + return uguo +} + +// SetDeletedAt sets the "deleted_at" field. +func (uguo *UserGroupUpdateOne) SetDeletedAt(t time.Time) *UserGroupUpdateOne { + uguo.mutation.SetDeletedAt(t) + return uguo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (uguo *UserGroupUpdateOne) SetNillableDeletedAt(t *time.Time) *UserGroupUpdateOne { + if t != nil { + uguo.SetDeletedAt(*t) + } + return uguo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (uguo *UserGroupUpdateOne) ClearDeletedAt() *UserGroupUpdateOne { + uguo.mutation.ClearDeletedAt() + return uguo +} + +// SetUserID sets the "user_id" field. +func (uguo *UserGroupUpdateOne) SetUserID(s string) *UserGroupUpdateOne { + uguo.mutation.SetUserID(s) + return uguo +} + +// SetGroupID sets the "group_id" field. +func (uguo *UserGroupUpdateOne) SetGroupID(s string) *UserGroupUpdateOne { + uguo.mutation.SetGroupID(s) + return uguo +} + +// SetUser sets the "user" edge to the User entity. +func (uguo *UserGroupUpdateOne) SetUser(u *User) *UserGroupUpdateOne { + return uguo.SetUserID(u.ID) +} + +// Mutation returns the UserGroupMutation object of the builder. +func (uguo *UserGroupUpdateOne) Mutation() *UserGroupMutation { + return uguo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (uguo *UserGroupUpdateOne) ClearUser() *UserGroupUpdateOne { + uguo.mutation.ClearUser() + return uguo +} + +// Where appends a list predicates to the UserGroupUpdate builder. +func (uguo *UserGroupUpdateOne) Where(ps ...predicate.UserGroup) *UserGroupUpdateOne { + uguo.mutation.Where(ps...) + return uguo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (uguo *UserGroupUpdateOne) Select(field string, fields ...string) *UserGroupUpdateOne { + uguo.fields = append([]string{field}, fields...) + return uguo +} + +// Save executes the query and returns the updated UserGroup entity. +func (uguo *UserGroupUpdateOne) Save(ctx context.Context) (*UserGroup, error) { + if err := uguo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, uguo.sqlSave, uguo.mutation, uguo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uguo *UserGroupUpdateOne) SaveX(ctx context.Context) *UserGroup { + node, err := uguo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uguo *UserGroupUpdateOne) Exec(ctx context.Context) error { + _, err := uguo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uguo *UserGroupUpdateOne) ExecX(ctx context.Context) { + if err := uguo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uguo *UserGroupUpdateOne) defaults() error { + if _, ok := uguo.mutation.UpdatedAt(); !ok { + if usergroup.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usergroup.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usergroup.UpdateDefaultUpdatedAt() + uguo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (uguo *UserGroupUpdateOne) check() error { + if v, ok := uguo.mutation.UserID(); ok { + if err := usergroup.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.user_id": %w`, err)} + } + } + if v, ok := uguo.mutation.GroupID(); ok { + if err := usergroup.GroupIDValidator(v); err != nil { + return &ValidationError{Name: "group_id", err: fmt.Errorf(`ent: validator failed for field "UserGroup.group_id": %w`, err)} + } + } + if _, ok := uguo.mutation.UserID(); uguo.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserGroup.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (uguo *UserGroupUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserGroupUpdateOne { + uguo.modifiers = append(uguo.modifiers, modifiers...) + return uguo +} + +func (uguo *UserGroupUpdateOne) sqlSave(ctx context.Context) (_node *UserGroup, err error) { + if err := uguo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(usergroup.Table, usergroup.Columns, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) + id, ok := uguo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserGroup.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := uguo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usergroup.FieldID) + for _, f := range fields { + if !usergroup.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != usergroup.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := uguo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uguo.mutation.UpdatedAt(); ok { + _spec.SetField(usergroup.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := uguo.mutation.DeletedAt(); ok { + _spec.SetField(usergroup.FieldDeletedAt, field.TypeTime, value) + } + if uguo.mutation.DeletedAtCleared() { + _spec.ClearField(usergroup.FieldDeletedAt, field.TypeTime) + } + if value, ok := uguo.mutation.GroupID(); ok { + _spec.SetField(usergroup.FieldGroupID, field.TypeString, value) + } + if uguo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usergroup.UserTable, + Columns: []string{usergroup.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uguo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usergroup.UserTable, + Columns: []string{usergroup.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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(uguo.modifiers...) + _node = &UserGroup{config: uguo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, uguo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usergroup.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + uguo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/usermod.go b/generated/ent/usermod.go new file mode 100644 index 00000000..ccd0952c --- /dev/null +++ b/generated/ent/usermod.go @@ -0,0 +1,166 @@ +// 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/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" +) + +// UserMod is the model entity for the UserMod schema. +type UserMod struct { + config `json:"-"` + // UserID holds the value of the "user_id" field. + UserID string `json:"user_id,omitempty"` + // ModID holds the value of the "mod_id" field. + ModID string `json:"mod_id,omitempty"` + // Role holds the value of the "role" field. + Role string `json:"role,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserModQuery when eager-loading is set. + Edges UserModEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserModEdges holds the relations/edges for other nodes in the graph. +type UserModEdges struct { + // User holds the value of the user edge. + User *User `json:"user,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 +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserModEdges) UserOrErr() (*User, error) { + if e.loadedTypes[0] { + if e.User == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.User, nil + } + return nil, &NotLoadedError{edge: "user"} +} + +// 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 UserModEdges) ModOrErr() (*Mod, error) { + if e.loadedTypes[1] { + if e.Mod == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: mod.Label} + } + return e.Mod, nil + } + return nil, &NotLoadedError{edge: "mod"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserMod) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case usermod.FieldUserID, usermod.FieldModID, usermod.FieldRole: + 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 UserMod fields. +func (um *UserMod) 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 usermod.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + um.UserID = value.String + } + case usermod.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 { + um.ModID = value.String + } + case usermod.FieldRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role", values[i]) + } else if value.Valid { + um.Role = value.String + } + default: + um.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserMod. +// This includes values selected through modifiers, order, etc. +func (um *UserMod) Value(name string) (ent.Value, error) { + return um.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the UserMod entity. +func (um *UserMod) QueryUser() *UserQuery { + return NewUserModClient(um.config).QueryUser(um) +} + +// QueryMod queries the "mod" edge of the UserMod entity. +func (um *UserMod) QueryMod() *ModQuery { + return NewUserModClient(um.config).QueryMod(um) +} + +// Update returns a builder for updating this UserMod. +// Note that you need to call UserMod.Unwrap() before calling this method if this UserMod +// was returned from a transaction, and the transaction was committed or rolled back. +func (um *UserMod) Update() *UserModUpdateOne { + return NewUserModClient(um.config).UpdateOne(um) +} + +// Unwrap unwraps the UserMod 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 (um *UserMod) Unwrap() *UserMod { + _tx, ok := um.config.driver.(*txDriver) + if !ok { + panic("ent: UserMod is not a transactional entity") + } + um.config.driver = _tx.drv + return um +} + +// String implements the fmt.Stringer. +func (um *UserMod) String() string { + var builder strings.Builder + builder.WriteString("UserMod(") + builder.WriteString("user_id=") + builder.WriteString(um.UserID) + builder.WriteString(", ") + builder.WriteString("mod_id=") + builder.WriteString(um.ModID) + builder.WriteString(", ") + builder.WriteString("role=") + builder.WriteString(um.Role) + builder.WriteByte(')') + return builder.String() +} + +// UserMods is a parsable slice of UserMod. +type UserMods []*UserMod diff --git a/generated/ent/usermod/usermod.go b/generated/ent/usermod/usermod.go new file mode 100644 index 00000000..ab4c8028 --- /dev/null +++ b/generated/ent/usermod/usermod.go @@ -0,0 +1,106 @@ +// Code generated by ent, DO NOT EDIT. + +package usermod + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the usermod type in the database. + Label = "user_mod" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldModID holds the string denoting the mod_id field in the database. + FieldModID = "mod_id" + // FieldRole holds the string denoting the role field in the database. + FieldRole = "role" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeMod holds the string denoting the mod edge name in mutations. + EdgeMod = "mod" + // UserFieldID holds the string denoting the ID field of the User. + UserFieldID = "id" + // ModFieldID holds the string denoting the ID field of the Mod. + ModFieldID = "id" + // Table holds the table name of the usermod in the database. + Table = "user_mods" + // UserTable is the table that holds the user relation/edge. + UserTable = "user_mods" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // ModTable is the table that holds the mod relation/edge. + ModTable = "user_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 usermod fields. +var Columns = []string{ + FieldUserID, + FieldModID, + FieldRole, +} + +// 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 UserMod queries. +type OrderOption func(*sql.Selector) + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByModID orders the results by the mod_id field. +func ByModID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModID, opts...).ToFunc() +} + +// ByRole orders the results by the role field. +func ByRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRole, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), 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 newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, UserColumn), + sqlgraph.To(UserInverseTable, UserFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +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/usermod/where.go b/generated/ent/usermod/where.go new file mode 100644 index 00000000..9b7367d5 --- /dev/null +++ b/generated/ent/usermod/where.go @@ -0,0 +1,280 @@ +// Code generated by ent, DO NOT EDIT. + +package usermod + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldUserID, v)) +} + +// ModID applies equality check predicate on the "mod_id" field. It's identical to ModIDEQ. +func ModID(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldModID, v)) +} + +// Role applies equality check predicate on the "role" field. It's identical to RoleEQ. +func Role(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldRole, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContainsFold(FieldUserID, v)) +} + +// ModIDEQ applies the EQ predicate on the "mod_id" field. +func ModIDEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldModID, v)) +} + +// ModIDNEQ applies the NEQ predicate on the "mod_id" field. +func ModIDNEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldNEQ(FieldModID, v)) +} + +// ModIDIn applies the In predicate on the "mod_id" field. +func ModIDIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldIn(FieldModID, vs...)) +} + +// ModIDNotIn applies the NotIn predicate on the "mod_id" field. +func ModIDNotIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldNotIn(FieldModID, vs...)) +} + +// ModIDGT applies the GT predicate on the "mod_id" field. +func ModIDGT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGT(FieldModID, v)) +} + +// ModIDGTE applies the GTE predicate on the "mod_id" field. +func ModIDGTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGTE(FieldModID, v)) +} + +// ModIDLT applies the LT predicate on the "mod_id" field. +func ModIDLT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLT(FieldModID, v)) +} + +// ModIDLTE applies the LTE predicate on the "mod_id" field. +func ModIDLTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLTE(FieldModID, v)) +} + +// ModIDContains applies the Contains predicate on the "mod_id" field. +func ModIDContains(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContains(FieldModID, v)) +} + +// ModIDHasPrefix applies the HasPrefix predicate on the "mod_id" field. +func ModIDHasPrefix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasPrefix(FieldModID, v)) +} + +// ModIDHasSuffix applies the HasSuffix predicate on the "mod_id" field. +func ModIDHasSuffix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasSuffix(FieldModID, v)) +} + +// ModIDEqualFold applies the EqualFold predicate on the "mod_id" field. +func ModIDEqualFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEqualFold(FieldModID, v)) +} + +// ModIDContainsFold applies the ContainsFold predicate on the "mod_id" field. +func ModIDContainsFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContainsFold(FieldModID, v)) +} + +// RoleEQ applies the EQ predicate on the "role" field. +func RoleEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEQ(FieldRole, v)) +} + +// RoleNEQ applies the NEQ predicate on the "role" field. +func RoleNEQ(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldNEQ(FieldRole, v)) +} + +// RoleIn applies the In predicate on the "role" field. +func RoleIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldIn(FieldRole, vs...)) +} + +// RoleNotIn applies the NotIn predicate on the "role" field. +func RoleNotIn(vs ...string) predicate.UserMod { + return predicate.UserMod(sql.FieldNotIn(FieldRole, vs...)) +} + +// RoleGT applies the GT predicate on the "role" field. +func RoleGT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGT(FieldRole, v)) +} + +// RoleGTE applies the GTE predicate on the "role" field. +func RoleGTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldGTE(FieldRole, v)) +} + +// RoleLT applies the LT predicate on the "role" field. +func RoleLT(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLT(FieldRole, v)) +} + +// RoleLTE applies the LTE predicate on the "role" field. +func RoleLTE(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldLTE(FieldRole, v)) +} + +// RoleContains applies the Contains predicate on the "role" field. +func RoleContains(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContains(FieldRole, v)) +} + +// RoleHasPrefix applies the HasPrefix predicate on the "role" field. +func RoleHasPrefix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasPrefix(FieldRole, v)) +} + +// RoleHasSuffix applies the HasSuffix predicate on the "role" field. +func RoleHasSuffix(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldHasSuffix(FieldRole, v)) +} + +// RoleEqualFold applies the EqualFold predicate on the "role" field. +func RoleEqualFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldEqualFold(FieldRole, v)) +} + +// RoleContainsFold applies the ContainsFold predicate on the "role" field. +func RoleContainsFold(v string) predicate.UserMod { + return predicate.UserMod(sql.FieldContainsFold(FieldRole, v)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserMod { + return predicate.UserMod(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, UserColumn), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserMod { + return predicate.UserMod(func(s *sql.Selector) { + step := newUserStep() + 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.UserMod { + return predicate.UserMod(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.UserMod { + return predicate.UserMod(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.UserMod) predicate.UserMod { + return predicate.UserMod(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserMod) predicate.UserMod { + return predicate.UserMod(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserMod) predicate.UserMod { + return predicate.UserMod(sql.NotPredicates(p)) +} diff --git a/generated/ent/usermod_create.go b/generated/ent/usermod_create.go new file mode 100644 index 00000000..6c6123e6 --- /dev/null +++ b/generated/ent/usermod_create.go @@ -0,0 +1,244 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "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/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" +) + +// UserModCreate is the builder for creating a UserMod entity. +type UserModCreate struct { + config + mutation *UserModMutation + hooks []Hook +} + +// SetUserID sets the "user_id" field. +func (umc *UserModCreate) SetUserID(s string) *UserModCreate { + umc.mutation.SetUserID(s) + return umc +} + +// SetModID sets the "mod_id" field. +func (umc *UserModCreate) SetModID(s string) *UserModCreate { + umc.mutation.SetModID(s) + return umc +} + +// SetRole sets the "role" field. +func (umc *UserModCreate) SetRole(s string) *UserModCreate { + umc.mutation.SetRole(s) + return umc +} + +// SetUser sets the "user" edge to the User entity. +func (umc *UserModCreate) SetUser(u *User) *UserModCreate { + return umc.SetUserID(u.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (umc *UserModCreate) SetMod(m *Mod) *UserModCreate { + return umc.SetModID(m.ID) +} + +// Mutation returns the UserModMutation object of the builder. +func (umc *UserModCreate) Mutation() *UserModMutation { + return umc.mutation +} + +// Save creates the UserMod in the database. +func (umc *UserModCreate) Save(ctx context.Context) (*UserMod, error) { + return withHooks(ctx, umc.sqlSave, umc.mutation, umc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (umc *UserModCreate) SaveX(ctx context.Context) *UserMod { + v, err := umc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (umc *UserModCreate) Exec(ctx context.Context) error { + _, err := umc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (umc *UserModCreate) ExecX(ctx context.Context) { + if err := umc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (umc *UserModCreate) check() error { + if _, ok := umc.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserMod.user_id"`)} + } + if _, ok := umc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod_id", err: errors.New(`ent: missing required field "UserMod.mod_id"`)} + } + if _, ok := umc.mutation.Role(); !ok { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "UserMod.role"`)} + } + if _, ok := umc.mutation.UserID(); !ok { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserMod.user"`)} + } + if _, ok := umc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod", err: errors.New(`ent: missing required edge "UserMod.mod"`)} + } + return nil +} + +func (umc *UserModCreate) sqlSave(ctx context.Context) (*UserMod, error) { + if err := umc.check(); err != nil { + return nil, err + } + _node, _spec := umc.createSpec() + if err := sqlgraph.CreateNode(ctx, umc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} + +func (umc *UserModCreate) createSpec() (*UserMod, *sqlgraph.CreateSpec) { + var ( + _node = &UserMod{config: umc.config} + _spec = sqlgraph.NewCreateSpec(usermod.Table, nil) + ) + if value, ok := umc.mutation.Role(); ok { + _spec.SetField(usermod.FieldRole, field.TypeString, value) + _node.Role = value + } + if nodes := umc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.UserTable, + Columns: []string{usermod.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.UserID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := umc.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.ModTable, + Columns: []string{usermod.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 +} + +// UserModCreateBulk is the builder for creating many UserMod entities in bulk. +type UserModCreateBulk struct { + config + err error + builders []*UserModCreate +} + +// Save creates the UserMod entities in the database. +func (umcb *UserModCreateBulk) Save(ctx context.Context) ([]*UserMod, error) { + if umcb.err != nil { + return nil, umcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(umcb.builders)) + nodes := make([]*UserMod, len(umcb.builders)) + mutators := make([]Mutator, len(umcb.builders)) + for i := range umcb.builders { + func(i int, root context.Context) { + builder := umcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserModMutation) + 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, umcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, umcb.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, umcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (umcb *UserModCreateBulk) SaveX(ctx context.Context) []*UserMod { + v, err := umcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (umcb *UserModCreateBulk) Exec(ctx context.Context) error { + _, err := umcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (umcb *UserModCreateBulk) ExecX(ctx context.Context) { + if err := umcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usermod_delete.go b/generated/ent/usermod_delete.go new file mode 100644 index 00000000..7a2b0232 --- /dev/null +++ b/generated/ent/usermod_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" +) + +// UserModDelete is the builder for deleting a UserMod entity. +type UserModDelete struct { + config + hooks []Hook + mutation *UserModMutation +} + +// Where appends a list predicates to the UserModDelete builder. +func (umd *UserModDelete) Where(ps ...predicate.UserMod) *UserModDelete { + umd.mutation.Where(ps...) + return umd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (umd *UserModDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, umd.sqlExec, umd.mutation, umd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (umd *UserModDelete) ExecX(ctx context.Context) int { + n, err := umd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (umd *UserModDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(usermod.Table, nil) + if ps := umd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, umd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + umd.mutation.done = true + return affected, err +} + +// UserModDeleteOne is the builder for deleting a single UserMod entity. +type UserModDeleteOne struct { + umd *UserModDelete +} + +// Where appends a list predicates to the UserModDelete builder. +func (umdo *UserModDeleteOne) Where(ps ...predicate.UserMod) *UserModDeleteOne { + umdo.umd.mutation.Where(ps...) + return umdo +} + +// Exec executes the deletion query. +func (umdo *UserModDeleteOne) Exec(ctx context.Context) error { + n, err := umdo.umd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{usermod.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (umdo *UserModDeleteOne) ExecX(ctx context.Context) { + if err := umdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usermod_query.go b/generated/ent/usermod_query.go new file mode 100644 index 00000000..7b7d6aa2 --- /dev/null +++ b/generated/ent/usermod_query.go @@ -0,0 +1,624 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" +) + +// UserModQuery is the builder for querying UserMod entities. +type UserModQuery struct { + config + ctx *QueryContext + order []usermod.OrderOption + inters []Interceptor + predicates []predicate.UserMod + withUser *UserQuery + 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 UserModQuery builder. +func (umq *UserModQuery) Where(ps ...predicate.UserMod) *UserModQuery { + umq.predicates = append(umq.predicates, ps...) + return umq +} + +// Limit the number of records to be returned by this query. +func (umq *UserModQuery) Limit(limit int) *UserModQuery { + umq.ctx.Limit = &limit + return umq +} + +// Offset to start from. +func (umq *UserModQuery) Offset(offset int) *UserModQuery { + umq.ctx.Offset = &offset + return umq +} + +// 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 (umq *UserModQuery) Unique(unique bool) *UserModQuery { + umq.ctx.Unique = &unique + return umq +} + +// Order specifies how the records should be ordered. +func (umq *UserModQuery) Order(o ...usermod.OrderOption) *UserModQuery { + umq.order = append(umq.order, o...) + return umq +} + +// QueryUser chains the current query on the "user" edge. +func (umq *UserModQuery) QueryUser() *UserQuery { + query := (&UserClient{config: umq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := umq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := umq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usermod.Table, usermod.UserColumn, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usermod.UserTable, usermod.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(umq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMod chains the current query on the "mod" edge. +func (umq *UserModQuery) QueryMod() *ModQuery { + query := (&ModClient{config: umq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := umq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := umq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usermod.Table, usermod.ModColumn, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usermod.ModTable, usermod.ModColumn), + ) + fromU = sqlgraph.SetNeighbors(umq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first UserMod entity from the query. +// Returns a *NotFoundError when no UserMod was found. +func (umq *UserModQuery) First(ctx context.Context) (*UserMod, error) { + nodes, err := umq.Limit(1).All(setContextOp(ctx, umq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{usermod.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (umq *UserModQuery) FirstX(ctx context.Context) *UserMod { + node, err := umq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single UserMod entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserMod entity is found. +// Returns a *NotFoundError when no UserMod entities are found. +func (umq *UserModQuery) Only(ctx context.Context) (*UserMod, error) { + nodes, err := umq.Limit(2).All(setContextOp(ctx, umq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{usermod.Label} + default: + return nil, &NotSingularError{usermod.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (umq *UserModQuery) OnlyX(ctx context.Context) *UserMod { + node, err := umq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of UserMods. +func (umq *UserModQuery) All(ctx context.Context) ([]*UserMod, error) { + ctx = setContextOp(ctx, umq.ctx, "All") + if err := umq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserMod, *UserModQuery]() + return withInterceptors[[]*UserMod](ctx, umq, qr, umq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (umq *UserModQuery) AllX(ctx context.Context) []*UserMod { + nodes, err := umq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (umq *UserModQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, umq.ctx, "Count") + if err := umq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, umq, querierCount[*UserModQuery](), umq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (umq *UserModQuery) CountX(ctx context.Context) int { + count, err := umq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (umq *UserModQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, umq.ctx, "Exist") + switch _, err := umq.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 (umq *UserModQuery) ExistX(ctx context.Context) bool { + exist, err := umq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserModQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (umq *UserModQuery) Clone() *UserModQuery { + if umq == nil { + return nil + } + return &UserModQuery{ + config: umq.config, + ctx: umq.ctx.Clone(), + order: append([]usermod.OrderOption{}, umq.order...), + inters: append([]Interceptor{}, umq.inters...), + predicates: append([]predicate.UserMod{}, umq.predicates...), + withUser: umq.withUser.Clone(), + withMod: umq.withMod.Clone(), + // clone intermediate query. + sql: umq.sql.Clone(), + path: umq.path, + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (umq *UserModQuery) WithUser(opts ...func(*UserQuery)) *UserModQuery { + query := (&UserClient{config: umq.config}).Query() + for _, opt := range opts { + opt(query) + } + umq.withUser = query + return umq +} + +// 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 (umq *UserModQuery) WithMod(opts ...func(*ModQuery)) *UserModQuery { + query := (&ModClient{config: umq.config}).Query() + for _, opt := range opts { + opt(query) + } + umq.withMod = query + return umq +} + +// 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 { +// UserID string `json:"user_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserMod.Query(). +// GroupBy(usermod.FieldUserID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (umq *UserModQuery) GroupBy(field string, fields ...string) *UserModGroupBy { + umq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserModGroupBy{build: umq} + grbuild.flds = &umq.ctx.Fields + grbuild.label = usermod.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 { +// UserID string `json:"user_id,omitempty"` +// } +// +// client.UserMod.Query(). +// Select(usermod.FieldUserID). +// Scan(ctx, &v) +func (umq *UserModQuery) Select(fields ...string) *UserModSelect { + umq.ctx.Fields = append(umq.ctx.Fields, fields...) + sbuild := &UserModSelect{UserModQuery: umq} + sbuild.label = usermod.Label + sbuild.flds, sbuild.scan = &umq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserModSelect configured with the given aggregations. +func (umq *UserModQuery) Aggregate(fns ...AggregateFunc) *UserModSelect { + return umq.Select().Aggregate(fns...) +} + +func (umq *UserModQuery) prepareQuery(ctx context.Context) error { + for _, inter := range umq.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, umq); err != nil { + return err + } + } + } + for _, f := range umq.ctx.Fields { + if !usermod.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if umq.path != nil { + prev, err := umq.path(ctx) + if err != nil { + return err + } + umq.sql = prev + } + return nil +} + +func (umq *UserModQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserMod, error) { + var ( + nodes = []*UserMod{} + _spec = umq.querySpec() + loadedTypes = [2]bool{ + umq.withUser != nil, + umq.withMod != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserMod).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserMod{config: umq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(umq.modifiers) > 0 { + _spec.Modifiers = umq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, umq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := umq.withUser; query != nil { + if err := umq.loadUser(ctx, query, nodes, nil, + func(n *UserMod, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + if query := umq.withMod; query != nil { + if err := umq.loadMod(ctx, query, nodes, nil, + func(n *UserMod, e *Mod) { n.Edges.Mod = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (umq *UserModQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserMod, init func(*UserMod), assign func(*UserMod, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*UserMod) + for i := range nodes { + fk := nodes[i].UserID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (umq *UserModQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*UserMod, init func(*UserMod), assign func(*UserMod, *Mod)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*UserMod) + 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 (umq *UserModQuery) sqlCount(ctx context.Context) (int, error) { + _spec := umq.querySpec() + if len(umq.modifiers) > 0 { + _spec.Modifiers = umq.modifiers + } + _spec.Unique = false + _spec.Node.Columns = nil + return sqlgraph.CountNodes(ctx, umq.driver, _spec) +} + +func (umq *UserModQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(usermod.Table, usermod.Columns, nil) + _spec.From = umq.sql + if unique := umq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if umq.path != nil { + _spec.Unique = true + } + if fields := umq.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 umq.withUser != nil { + _spec.Node.AddColumnOnce(usermod.FieldUserID) + } + if umq.withMod != nil { + _spec.Node.AddColumnOnce(usermod.FieldModID) + } + } + if ps := umq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := umq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := umq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := umq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (umq *UserModQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(umq.driver.Dialect()) + t1 := builder.Table(usermod.Table) + columns := umq.ctx.Fields + if len(columns) == 0 { + columns = usermod.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if umq.sql != nil { + selector = umq.sql + selector.Select(selector.Columns(columns...)...) + } + if umq.ctx.Unique != nil && *umq.ctx.Unique { + selector.Distinct() + } + for _, m := range umq.modifiers { + m(selector) + } + for _, p := range umq.predicates { + p(selector) + } + for _, p := range umq.order { + p(selector) + } + if offset := umq.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 := umq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (umq *UserModQuery) Modify(modifiers ...func(s *sql.Selector)) *UserModSelect { + umq.modifiers = append(umq.modifiers, modifiers...) + return umq.Select() +} + +// UserModGroupBy is the group-by builder for UserMod entities. +type UserModGroupBy struct { + selector + build *UserModQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (umgb *UserModGroupBy) Aggregate(fns ...AggregateFunc) *UserModGroupBy { + umgb.fns = append(umgb.fns, fns...) + return umgb +} + +// Scan applies the selector query and scans the result into the given value. +func (umgb *UserModGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, umgb.build.ctx, "GroupBy") + if err := umgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserModQuery, *UserModGroupBy](ctx, umgb.build, umgb, umgb.build.inters, v) +} + +func (umgb *UserModGroupBy) sqlScan(ctx context.Context, root *UserModQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(umgb.fns)) + for _, fn := range umgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*umgb.flds)+len(umgb.fns)) + for _, f := range *umgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*umgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := umgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserModSelect is the builder for selecting fields of UserMod entities. +type UserModSelect struct { + *UserModQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ums *UserModSelect) Aggregate(fns ...AggregateFunc) *UserModSelect { + ums.fns = append(ums.fns, fns...) + return ums +} + +// Scan applies the selector query and scans the result into the given value. +func (ums *UserModSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ums.ctx, "Select") + if err := ums.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserModQuery, *UserModSelect](ctx, ums.UserModQuery, ums, ums.inters, v) +} + +func (ums *UserModSelect) sqlScan(ctx context.Context, root *UserModQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ums.fns)) + for _, fn := range ums.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ums.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 := ums.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 (ums *UserModSelect) Modify(modifiers ...func(s *sql.Selector)) *UserModSelect { + ums.modifiers = append(ums.modifiers, modifiers...) + return ums +} diff --git a/generated/ent/usermod_update.go b/generated/ent/usermod_update.go new file mode 100644 index 00000000..87177a17 --- /dev/null +++ b/generated/ent/usermod_update.go @@ -0,0 +1,425 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" +) + +// UserModUpdate is the builder for updating UserMod entities. +type UserModUpdate struct { + config + hooks []Hook + mutation *UserModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserModUpdate builder. +func (umu *UserModUpdate) Where(ps ...predicate.UserMod) *UserModUpdate { + umu.mutation.Where(ps...) + return umu +} + +// SetUserID sets the "user_id" field. +func (umu *UserModUpdate) SetUserID(s string) *UserModUpdate { + umu.mutation.SetUserID(s) + return umu +} + +// SetModID sets the "mod_id" field. +func (umu *UserModUpdate) SetModID(s string) *UserModUpdate { + umu.mutation.SetModID(s) + return umu +} + +// SetRole sets the "role" field. +func (umu *UserModUpdate) SetRole(s string) *UserModUpdate { + umu.mutation.SetRole(s) + return umu +} + +// SetUser sets the "user" edge to the User entity. +func (umu *UserModUpdate) SetUser(u *User) *UserModUpdate { + return umu.SetUserID(u.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (umu *UserModUpdate) SetMod(m *Mod) *UserModUpdate { + return umu.SetModID(m.ID) +} + +// Mutation returns the UserModMutation object of the builder. +func (umu *UserModUpdate) Mutation() *UserModMutation { + return umu.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (umu *UserModUpdate) ClearUser() *UserModUpdate { + umu.mutation.ClearUser() + return umu +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (umu *UserModUpdate) ClearMod() *UserModUpdate { + umu.mutation.ClearMod() + return umu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (umu *UserModUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, umu.sqlSave, umu.mutation, umu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (umu *UserModUpdate) SaveX(ctx context.Context) int { + affected, err := umu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (umu *UserModUpdate) Exec(ctx context.Context) error { + _, err := umu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (umu *UserModUpdate) ExecX(ctx context.Context) { + if err := umu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (umu *UserModUpdate) check() error { + if _, ok := umu.mutation.UserID(); umu.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserMod.user"`) + } + if _, ok := umu.mutation.ModID(); umu.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserMod.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (umu *UserModUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserModUpdate { + umu.modifiers = append(umu.modifiers, modifiers...) + return umu +} + +func (umu *UserModUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := umu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(usermod.Table, usermod.Columns, sqlgraph.NewFieldSpec(usermod.FieldUserID, field.TypeString), sqlgraph.NewFieldSpec(usermod.FieldModID, field.TypeString)) + if ps := umu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := umu.mutation.Role(); ok { + _spec.SetField(usermod.FieldRole, field.TypeString, value) + } + if umu.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.UserTable, + Columns: []string{usermod.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := umu.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.UserTable, + Columns: []string{usermod.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if umu.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.ModTable, + Columns: []string{usermod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := umu.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.ModTable, + Columns: []string{usermod.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(umu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, umu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usermod.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + umu.mutation.done = true + return n, nil +} + +// UserModUpdateOne is the builder for updating a single UserMod entity. +type UserModUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserModMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUserID sets the "user_id" field. +func (umuo *UserModUpdateOne) SetUserID(s string) *UserModUpdateOne { + umuo.mutation.SetUserID(s) + return umuo +} + +// SetModID sets the "mod_id" field. +func (umuo *UserModUpdateOne) SetModID(s string) *UserModUpdateOne { + umuo.mutation.SetModID(s) + return umuo +} + +// SetRole sets the "role" field. +func (umuo *UserModUpdateOne) SetRole(s string) *UserModUpdateOne { + umuo.mutation.SetRole(s) + return umuo +} + +// SetUser sets the "user" edge to the User entity. +func (umuo *UserModUpdateOne) SetUser(u *User) *UserModUpdateOne { + return umuo.SetUserID(u.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (umuo *UserModUpdateOne) SetMod(m *Mod) *UserModUpdateOne { + return umuo.SetModID(m.ID) +} + +// Mutation returns the UserModMutation object of the builder. +func (umuo *UserModUpdateOne) Mutation() *UserModMutation { + return umuo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (umuo *UserModUpdateOne) ClearUser() *UserModUpdateOne { + umuo.mutation.ClearUser() + return umuo +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (umuo *UserModUpdateOne) ClearMod() *UserModUpdateOne { + umuo.mutation.ClearMod() + return umuo +} + +// Where appends a list predicates to the UserModUpdate builder. +func (umuo *UserModUpdateOne) Where(ps ...predicate.UserMod) *UserModUpdateOne { + umuo.mutation.Where(ps...) + return umuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (umuo *UserModUpdateOne) Select(field string, fields ...string) *UserModUpdateOne { + umuo.fields = append([]string{field}, fields...) + return umuo +} + +// Save executes the query and returns the updated UserMod entity. +func (umuo *UserModUpdateOne) Save(ctx context.Context) (*UserMod, error) { + return withHooks(ctx, umuo.sqlSave, umuo.mutation, umuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (umuo *UserModUpdateOne) SaveX(ctx context.Context) *UserMod { + node, err := umuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (umuo *UserModUpdateOne) Exec(ctx context.Context) error { + _, err := umuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (umuo *UserModUpdateOne) ExecX(ctx context.Context) { + if err := umuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (umuo *UserModUpdateOne) check() error { + if _, ok := umuo.mutation.UserID(); umuo.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserMod.user"`) + } + if _, ok := umuo.mutation.ModID(); umuo.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserMod.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (umuo *UserModUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserModUpdateOne { + umuo.modifiers = append(umuo.modifiers, modifiers...) + return umuo +} + +func (umuo *UserModUpdateOne) sqlSave(ctx context.Context) (_node *UserMod, err error) { + if err := umuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(usermod.Table, usermod.Columns, sqlgraph.NewFieldSpec(usermod.FieldUserID, field.TypeString), sqlgraph.NewFieldSpec(usermod.FieldModID, field.TypeString)) + if id, ok := umuo.mutation.UserID(); !ok { + return nil, &ValidationError{Name: "user_id", err: errors.New(`ent: missing "UserMod.user_id" for update`)} + } else { + _spec.Node.CompositeID[0].Value = id + } + if id, ok := umuo.mutation.ModID(); !ok { + return nil, &ValidationError{Name: "mod_id", err: errors.New(`ent: missing "UserMod.mod_id" for update`)} + } else { + _spec.Node.CompositeID[1].Value = id + } + if fields := umuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, len(fields)) + for i, f := range fields { + if !usermod.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + _spec.Node.Columns[i] = f + } + } + if ps := umuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := umuo.mutation.Role(); ok { + _spec.SetField(usermod.FieldRole, field.TypeString, value) + } + if umuo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.UserTable, + Columns: []string{usermod.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := umuo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.UserTable, + Columns: []string{usermod.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if umuo.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.ModTable, + Columns: []string{usermod.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := umuo.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usermod.ModTable, + Columns: []string{usermod.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(umuo.modifiers...) + _node = &UserMod{config: umuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, umuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usermod.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + umuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/usersession.go b/generated/ent/usersession.go new file mode 100644 index 00000000..0da1f1fe --- /dev/null +++ b/generated/ent/usersession.go @@ -0,0 +1,189 @@ +// 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/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserSession is the model entity for the UserSession schema. +type UserSession 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Token holds the value of the "token" field. + Token string `json:"token,omitempty"` + // UserAgent holds the value of the "user_agent" field. + UserAgent string `json:"user_agent,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserSessionQuery when eager-loading is set. + Edges UserSessionEdges `json:"edges"` + user_id *string + selectValues sql.SelectValues +} + +// UserSessionEdges holds the relations/edges for other nodes in the graph. +type UserSessionEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserSessionEdges) UserOrErr() (*User, error) { + if e.loadedTypes[0] { + if e.User == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.User, nil + } + return nil, &NotLoadedError{edge: "user"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserSession) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case usersession.FieldID, usersession.FieldToken, usersession.FieldUserAgent: + values[i] = new(sql.NullString) + case usersession.FieldCreatedAt, usersession.FieldUpdatedAt, usersession.FieldDeletedAt: + values[i] = new(sql.NullTime) + case usersession.ForeignKeys[0]: // user_id + 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 UserSession fields. +func (us *UserSession) 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 usersession.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + us.ID = value.String + } + case usersession.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 { + us.CreatedAt = value.Time + } + case usersession.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 { + us.UpdatedAt = value.Time + } + case usersession.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + us.DeletedAt = value.Time + } + case usersession.FieldToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field token", values[i]) + } else if value.Valid { + us.Token = value.String + } + case usersession.FieldUserAgent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_agent", values[i]) + } else if value.Valid { + us.UserAgent = value.String + } + case usersession.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + us.user_id = new(string) + *us.user_id = value.String + } + default: + us.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserSession. +// This includes values selected through modifiers, order, etc. +func (us *UserSession) Value(name string) (ent.Value, error) { + return us.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the UserSession entity. +func (us *UserSession) QueryUser() *UserQuery { + return NewUserSessionClient(us.config).QueryUser(us) +} + +// Update returns a builder for updating this UserSession. +// Note that you need to call UserSession.Unwrap() before calling this method if this UserSession +// was returned from a transaction, and the transaction was committed or rolled back. +func (us *UserSession) Update() *UserSessionUpdateOne { + return NewUserSessionClient(us.config).UpdateOne(us) +} + +// Unwrap unwraps the UserSession 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 (us *UserSession) Unwrap() *UserSession { + _tx, ok := us.config.driver.(*txDriver) + if !ok { + panic("ent: UserSession is not a transactional entity") + } + us.config.driver = _tx.drv + return us +} + +// String implements the fmt.Stringer. +func (us *UserSession) String() string { + var builder strings.Builder + builder.WriteString("UserSession(") + builder.WriteString(fmt.Sprintf("id=%v, ", us.ID)) + builder.WriteString("created_at=") + builder.WriteString(us.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(us.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(us.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("token=") + builder.WriteString(us.Token) + builder.WriteString(", ") + builder.WriteString("user_agent=") + builder.WriteString(us.UserAgent) + builder.WriteByte(')') + return builder.String() +} + +// UserSessions is a parsable slice of UserSession. +type UserSessions []*UserSession diff --git a/generated/ent/usersession/usersession.go b/generated/ent/usersession/usersession.go new file mode 100644 index 00000000..a6b0c2b7 --- /dev/null +++ b/generated/ent/usersession/usersession.go @@ -0,0 +1,137 @@ +// Code generated by ent, DO NOT EDIT. + +package usersession + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the usersession type in the database. + Label = "user_session" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldToken holds the string denoting the token field in the database. + FieldToken = "token" + // FieldUserAgent holds the string denoting the user_agent field in the database. + FieldUserAgent = "user_agent" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // Table holds the table name of the usersession in the database. + Table = "user_sessions" + // UserTable is the table that holds the user relation/edge. + UserTable = "user_sessions" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" +) + +// Columns holds all SQL columns for usersession fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldToken, + FieldUserAgent, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "user_sessions" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "user_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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // TokenValidator is a validator for the "token" field. It is called by the builders before save. + TokenValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the UserSession 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByToken orders the results by the token field. +func ByToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldToken, opts...).ToFunc() +} + +// ByUserAgent orders the results by the user_agent field. +func ByUserAgent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserAgent, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) +} diff --git a/generated/ent/usersession/where.go b/generated/ent/usersession/where.go new file mode 100644 index 00000000..0c1c9e3d --- /dev/null +++ b/generated/ent/usersession/where.go @@ -0,0 +1,399 @@ +// Code generated by ent, DO NOT EDIT. + +package usersession + +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.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.UserSession { + return predicate.UserSession(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.UserSession { + return predicate.UserSession(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.UserSession { + return predicate.UserSession(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.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. +func Token(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldToken, v)) +} + +// UserAgent applies equality check predicate on the "user_agent" field. It's identical to UserAgentEQ. +func UserAgent(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.UserSession { + return predicate.UserSession(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.UserSession { + return predicate.UserSession(sql.FieldNotNull(FieldDeletedAt)) +} + +// TokenEQ applies the EQ predicate on the "token" field. +func TokenEQ(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldToken, v)) +} + +// TokenNEQ applies the NEQ predicate on the "token" field. +func TokenNEQ(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldToken, v)) +} + +// TokenIn applies the In predicate on the "token" field. +func TokenIn(vs ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldToken, vs...)) +} + +// TokenNotIn applies the NotIn predicate on the "token" field. +func TokenNotIn(vs ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldToken, vs...)) +} + +// TokenGT applies the GT predicate on the "token" field. +func TokenGT(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldToken, v)) +} + +// TokenGTE applies the GTE predicate on the "token" field. +func TokenGTE(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldToken, v)) +} + +// TokenLT applies the LT predicate on the "token" field. +func TokenLT(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldToken, v)) +} + +// TokenLTE applies the LTE predicate on the "token" field. +func TokenLTE(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldToken, v)) +} + +// TokenContains applies the Contains predicate on the "token" field. +func TokenContains(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldContains(FieldToken, v)) +} + +// TokenHasPrefix applies the HasPrefix predicate on the "token" field. +func TokenHasPrefix(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldHasPrefix(FieldToken, v)) +} + +// TokenHasSuffix applies the HasSuffix predicate on the "token" field. +func TokenHasSuffix(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldHasSuffix(FieldToken, v)) +} + +// TokenEqualFold applies the EqualFold predicate on the "token" field. +func TokenEqualFold(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEqualFold(FieldToken, v)) +} + +// TokenContainsFold applies the ContainsFold predicate on the "token" field. +func TokenContainsFold(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldContainsFold(FieldToken, v)) +} + +// UserAgentEQ applies the EQ predicate on the "user_agent" field. +func UserAgentEQ(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v)) +} + +// UserAgentNEQ applies the NEQ predicate on the "user_agent" field. +func UserAgentNEQ(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldNEQ(FieldUserAgent, v)) +} + +// UserAgentIn applies the In predicate on the "user_agent" field. +func UserAgentIn(vs ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldIn(FieldUserAgent, vs...)) +} + +// UserAgentNotIn applies the NotIn predicate on the "user_agent" field. +func UserAgentNotIn(vs ...string) predicate.UserSession { + return predicate.UserSession(sql.FieldNotIn(FieldUserAgent, vs...)) +} + +// UserAgentGT applies the GT predicate on the "user_agent" field. +func UserAgentGT(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldGT(FieldUserAgent, v)) +} + +// UserAgentGTE applies the GTE predicate on the "user_agent" field. +func UserAgentGTE(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldGTE(FieldUserAgent, v)) +} + +// UserAgentLT applies the LT predicate on the "user_agent" field. +func UserAgentLT(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldLT(FieldUserAgent, v)) +} + +// UserAgentLTE applies the LTE predicate on the "user_agent" field. +func UserAgentLTE(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldLTE(FieldUserAgent, v)) +} + +// UserAgentContains applies the Contains predicate on the "user_agent" field. +func UserAgentContains(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldContains(FieldUserAgent, v)) +} + +// UserAgentHasPrefix applies the HasPrefix predicate on the "user_agent" field. +func UserAgentHasPrefix(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldHasPrefix(FieldUserAgent, v)) +} + +// UserAgentHasSuffix applies the HasSuffix predicate on the "user_agent" field. +func UserAgentHasSuffix(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldHasSuffix(FieldUserAgent, v)) +} + +// UserAgentIsNil applies the IsNil predicate on the "user_agent" field. +func UserAgentIsNil() predicate.UserSession { + return predicate.UserSession(sql.FieldIsNull(FieldUserAgent)) +} + +// UserAgentNotNil applies the NotNil predicate on the "user_agent" field. +func UserAgentNotNil() predicate.UserSession { + return predicate.UserSession(sql.FieldNotNull(FieldUserAgent)) +} + +// UserAgentEqualFold applies the EqualFold predicate on the "user_agent" field. +func UserAgentEqualFold(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldEqualFold(FieldUserAgent, v)) +} + +// UserAgentContainsFold applies the ContainsFold predicate on the "user_agent" field. +func UserAgentContainsFold(v string) predicate.UserSession { + return predicate.UserSession(sql.FieldContainsFold(FieldUserAgent, v)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserSession { + return predicate.UserSession(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserSession { + return predicate.UserSession(func(s *sql.Selector) { + step := newUserStep() + 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.UserSession) predicate.UserSession { + return predicate.UserSession(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserSession) predicate.UserSession { + return predicate.UserSession(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserSession) predicate.UserSession { + return predicate.UserSession(sql.NotPredicates(p)) +} diff --git a/generated/ent/usersession_create.go b/generated/ent/usersession_create.go new file mode 100644 index 00000000..97897178 --- /dev/null +++ b/generated/ent/usersession_create.go @@ -0,0 +1,348 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserSessionCreate is the builder for creating a UserSession entity. +type UserSessionCreate struct { + config + mutation *UserSessionMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (usc *UserSessionCreate) SetCreatedAt(t time.Time) *UserSessionCreate { + usc.mutation.SetCreatedAt(t) + return usc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (usc *UserSessionCreate) SetNillableCreatedAt(t *time.Time) *UserSessionCreate { + if t != nil { + usc.SetCreatedAt(*t) + } + return usc +} + +// SetUpdatedAt sets the "updated_at" field. +func (usc *UserSessionCreate) SetUpdatedAt(t time.Time) *UserSessionCreate { + usc.mutation.SetUpdatedAt(t) + return usc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (usc *UserSessionCreate) SetNillableUpdatedAt(t *time.Time) *UserSessionCreate { + if t != nil { + usc.SetUpdatedAt(*t) + } + return usc +} + +// SetDeletedAt sets the "deleted_at" field. +func (usc *UserSessionCreate) SetDeletedAt(t time.Time) *UserSessionCreate { + usc.mutation.SetDeletedAt(t) + return usc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (usc *UserSessionCreate) SetNillableDeletedAt(t *time.Time) *UserSessionCreate { + if t != nil { + usc.SetDeletedAt(*t) + } + return usc +} + +// SetToken sets the "token" field. +func (usc *UserSessionCreate) SetToken(s string) *UserSessionCreate { + usc.mutation.SetToken(s) + return usc +} + +// SetUserAgent sets the "user_agent" field. +func (usc *UserSessionCreate) SetUserAgent(s string) *UserSessionCreate { + usc.mutation.SetUserAgent(s) + return usc +} + +// SetNillableUserAgent sets the "user_agent" field if the given value is not nil. +func (usc *UserSessionCreate) SetNillableUserAgent(s *string) *UserSessionCreate { + if s != nil { + usc.SetUserAgent(*s) + } + return usc +} + +// SetID sets the "id" field. +func (usc *UserSessionCreate) SetID(s string) *UserSessionCreate { + usc.mutation.SetID(s) + return usc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (usc *UserSessionCreate) SetNillableID(s *string) *UserSessionCreate { + if s != nil { + usc.SetID(*s) + } + return usc +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (usc *UserSessionCreate) SetUserID(id string) *UserSessionCreate { + usc.mutation.SetUserID(id) + return usc +} + +// SetUser sets the "user" edge to the User entity. +func (usc *UserSessionCreate) SetUser(u *User) *UserSessionCreate { + return usc.SetUserID(u.ID) +} + +// Mutation returns the UserSessionMutation object of the builder. +func (usc *UserSessionCreate) Mutation() *UserSessionMutation { + return usc.mutation +} + +// Save creates the UserSession in the database. +func (usc *UserSessionCreate) Save(ctx context.Context) (*UserSession, error) { + if err := usc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, usc.sqlSave, usc.mutation, usc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (usc *UserSessionCreate) SaveX(ctx context.Context) *UserSession { + v, err := usc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (usc *UserSessionCreate) Exec(ctx context.Context) error { + _, err := usc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (usc *UserSessionCreate) ExecX(ctx context.Context) { + if err := usc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (usc *UserSessionCreate) defaults() error { + if _, ok := usc.mutation.CreatedAt(); !ok { + if usersession.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized usersession.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := usersession.DefaultCreatedAt() + usc.mutation.SetCreatedAt(v) + } + if _, ok := usc.mutation.UpdatedAt(); !ok { + if usersession.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usersession.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usersession.DefaultUpdatedAt() + usc.mutation.SetUpdatedAt(v) + } + if _, ok := usc.mutation.ID(); !ok { + if usersession.DefaultID == nil { + return fmt.Errorf("ent: uninitialized usersession.DefaultID (forgotten import ent/runtime?)") + } + v := usersession.DefaultID() + usc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (usc *UserSessionCreate) check() error { + if _, ok := usc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserSession.created_at"`)} + } + if _, ok := usc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserSession.updated_at"`)} + } + if _, ok := usc.mutation.Token(); !ok { + return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "UserSession.token"`)} + } + if v, ok := usc.mutation.Token(); ok { + if err := usersession.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "UserSession.token": %w`, err)} + } + } + if _, ok := usc.mutation.UserID(); !ok { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserSession.user"`)} + } + return nil +} + +func (usc *UserSessionCreate) sqlSave(ctx context.Context) (*UserSession, error) { + if err := usc.check(); err != nil { + return nil, err + } + _node, _spec := usc.createSpec() + if err := sqlgraph.CreateNode(ctx, usc.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 UserSession.ID type: %T", _spec.ID.Value) + } + } + usc.mutation.id = &_node.ID + usc.mutation.done = true + return _node, nil +} + +func (usc *UserSessionCreate) createSpec() (*UserSession, *sqlgraph.CreateSpec) { + var ( + _node = &UserSession{config: usc.config} + _spec = sqlgraph.NewCreateSpec(usersession.Table, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) + ) + if id, ok := usc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := usc.mutation.CreatedAt(); ok { + _spec.SetField(usersession.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := usc.mutation.UpdatedAt(); ok { + _spec.SetField(usersession.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := usc.mutation.DeletedAt(); ok { + _spec.SetField(usersession.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := usc.mutation.Token(); ok { + _spec.SetField(usersession.FieldToken, field.TypeString, value) + _node.Token = value + } + if value, ok := usc.mutation.UserAgent(); ok { + _spec.SetField(usersession.FieldUserAgent, field.TypeString, value) + _node.UserAgent = value + } + if nodes := usc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usersession.UserTable, + Columns: []string{usersession.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.user_id = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// UserSessionCreateBulk is the builder for creating many UserSession entities in bulk. +type UserSessionCreateBulk struct { + config + err error + builders []*UserSessionCreate +} + +// Save creates the UserSession entities in the database. +func (uscb *UserSessionCreateBulk) Save(ctx context.Context) ([]*UserSession, error) { + if uscb.err != nil { + return nil, uscb.err + } + specs := make([]*sqlgraph.CreateSpec, len(uscb.builders)) + nodes := make([]*UserSession, len(uscb.builders)) + mutators := make([]Mutator, len(uscb.builders)) + for i := range uscb.builders { + func(i int, root context.Context) { + builder := uscb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserSessionMutation) + 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, uscb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, uscb.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, uscb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (uscb *UserSessionCreateBulk) SaveX(ctx context.Context) []*UserSession { + v, err := uscb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uscb *UserSessionCreateBulk) Exec(ctx context.Context) error { + _, err := uscb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uscb *UserSessionCreateBulk) ExecX(ctx context.Context) { + if err := uscb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usersession_delete.go b/generated/ent/usersession_delete.go new file mode 100644 index 00000000..a5339b8e --- /dev/null +++ b/generated/ent/usersession_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserSessionDelete is the builder for deleting a UserSession entity. +type UserSessionDelete struct { + config + hooks []Hook + mutation *UserSessionMutation +} + +// Where appends a list predicates to the UserSessionDelete builder. +func (usd *UserSessionDelete) Where(ps ...predicate.UserSession) *UserSessionDelete { + usd.mutation.Where(ps...) + return usd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (usd *UserSessionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, usd.sqlExec, usd.mutation, usd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (usd *UserSessionDelete) ExecX(ctx context.Context) int { + n, err := usd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (usd *UserSessionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(usersession.Table, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) + if ps := usd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, usd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + usd.mutation.done = true + return affected, err +} + +// UserSessionDeleteOne is the builder for deleting a single UserSession entity. +type UserSessionDeleteOne struct { + usd *UserSessionDelete +} + +// Where appends a list predicates to the UserSessionDelete builder. +func (usdo *UserSessionDeleteOne) Where(ps ...predicate.UserSession) *UserSessionDeleteOne { + usdo.usd.mutation.Where(ps...) + return usdo +} + +// Exec executes the deletion query. +func (usdo *UserSessionDeleteOne) Exec(ctx context.Context) error { + n, err := usdo.usd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{usersession.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (usdo *UserSessionDeleteOne) ExecX(ctx context.Context) { + if err := usdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usersession_query.go b/generated/ent/usersession_query.go new file mode 100644 index 00000000..a66dd52d --- /dev/null +++ b/generated/ent/usersession_query.go @@ -0,0 +1,635 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserSessionQuery is the builder for querying UserSession entities. +type UserSessionQuery struct { + config + ctx *QueryContext + order []usersession.OrderOption + inters []Interceptor + predicates []predicate.UserSession + withUser *UserQuery + withFKs bool + 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 UserSessionQuery builder. +func (usq *UserSessionQuery) Where(ps ...predicate.UserSession) *UserSessionQuery { + usq.predicates = append(usq.predicates, ps...) + return usq +} + +// Limit the number of records to be returned by this query. +func (usq *UserSessionQuery) Limit(limit int) *UserSessionQuery { + usq.ctx.Limit = &limit + return usq +} + +// Offset to start from. +func (usq *UserSessionQuery) Offset(offset int) *UserSessionQuery { + usq.ctx.Offset = &offset + return usq +} + +// 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 (usq *UserSessionQuery) Unique(unique bool) *UserSessionQuery { + usq.ctx.Unique = &unique + return usq +} + +// Order specifies how the records should be ordered. +func (usq *UserSessionQuery) Order(o ...usersession.OrderOption) *UserSessionQuery { + usq.order = append(usq.order, o...) + return usq +} + +// QueryUser chains the current query on the "user" edge. +func (usq *UserSessionQuery) QueryUser() *UserQuery { + query := (&UserClient{config: usq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := usq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := usq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usersession.Table, usersession.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, usersession.UserTable, usersession.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(usq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first UserSession entity from the query. +// Returns a *NotFoundError when no UserSession was found. +func (usq *UserSessionQuery) First(ctx context.Context) (*UserSession, error) { + nodes, err := usq.Limit(1).All(setContextOp(ctx, usq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{usersession.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (usq *UserSessionQuery) FirstX(ctx context.Context) *UserSession { + node, err := usq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserSession ID from the query. +// Returns a *NotFoundError when no UserSession ID was found. +func (usq *UserSessionQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = usq.Limit(1).IDs(setContextOp(ctx, usq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{usersession.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (usq *UserSessionQuery) FirstIDX(ctx context.Context) string { + id, err := usq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserSession entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserSession entity is found. +// Returns a *NotFoundError when no UserSession entities are found. +func (usq *UserSessionQuery) Only(ctx context.Context) (*UserSession, error) { + nodes, err := usq.Limit(2).All(setContextOp(ctx, usq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{usersession.Label} + default: + return nil, &NotSingularError{usersession.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (usq *UserSessionQuery) OnlyX(ctx context.Context) *UserSession { + node, err := usq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserSession ID in the query. +// Returns a *NotSingularError when more than one UserSession ID is found. +// Returns a *NotFoundError when no entities are found. +func (usq *UserSessionQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = usq.Limit(2).IDs(setContextOp(ctx, usq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{usersession.Label} + default: + err = &NotSingularError{usersession.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (usq *UserSessionQuery) OnlyIDX(ctx context.Context) string { + id, err := usq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserSessions. +func (usq *UserSessionQuery) All(ctx context.Context) ([]*UserSession, error) { + ctx = setContextOp(ctx, usq.ctx, "All") + if err := usq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserSession, *UserSessionQuery]() + return withInterceptors[[]*UserSession](ctx, usq, qr, usq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (usq *UserSessionQuery) AllX(ctx context.Context) []*UserSession { + nodes, err := usq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserSession IDs. +func (usq *UserSessionQuery) IDs(ctx context.Context) (ids []string, err error) { + if usq.ctx.Unique == nil && usq.path != nil { + usq.Unique(true) + } + ctx = setContextOp(ctx, usq.ctx, "IDs") + if err = usq.Select(usersession.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (usq *UserSessionQuery) IDsX(ctx context.Context) []string { + ids, err := usq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (usq *UserSessionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, usq.ctx, "Count") + if err := usq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, usq, querierCount[*UserSessionQuery](), usq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (usq *UserSessionQuery) CountX(ctx context.Context) int { + count, err := usq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (usq *UserSessionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, usq.ctx, "Exist") + switch _, err := usq.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 (usq *UserSessionQuery) ExistX(ctx context.Context) bool { + exist, err := usq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserSessionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (usq *UserSessionQuery) Clone() *UserSessionQuery { + if usq == nil { + return nil + } + return &UserSessionQuery{ + config: usq.config, + ctx: usq.ctx.Clone(), + order: append([]usersession.OrderOption{}, usq.order...), + inters: append([]Interceptor{}, usq.inters...), + predicates: append([]predicate.UserSession{}, usq.predicates...), + withUser: usq.withUser.Clone(), + // clone intermediate query. + sql: usq.sql.Clone(), + path: usq.path, + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (usq *UserSessionQuery) WithUser(opts ...func(*UserQuery)) *UserSessionQuery { + query := (&UserClient{config: usq.config}).Query() + for _, opt := range opts { + opt(query) + } + usq.withUser = query + return usq +} + +// 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.UserSession.Query(). +// GroupBy(usersession.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (usq *UserSessionQuery) GroupBy(field string, fields ...string) *UserSessionGroupBy { + usq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserSessionGroupBy{build: usq} + grbuild.flds = &usq.ctx.Fields + grbuild.label = usersession.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.UserSession.Query(). +// Select(usersession.FieldCreatedAt). +// Scan(ctx, &v) +func (usq *UserSessionQuery) Select(fields ...string) *UserSessionSelect { + usq.ctx.Fields = append(usq.ctx.Fields, fields...) + sbuild := &UserSessionSelect{UserSessionQuery: usq} + sbuild.label = usersession.Label + sbuild.flds, sbuild.scan = &usq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserSessionSelect configured with the given aggregations. +func (usq *UserSessionQuery) Aggregate(fns ...AggregateFunc) *UserSessionSelect { + return usq.Select().Aggregate(fns...) +} + +func (usq *UserSessionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range usq.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, usq); err != nil { + return err + } + } + } + for _, f := range usq.ctx.Fields { + if !usersession.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if usq.path != nil { + prev, err := usq.path(ctx) + if err != nil { + return err + } + usq.sql = prev + } + return nil +} + +func (usq *UserSessionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserSession, error) { + var ( + nodes = []*UserSession{} + withFKs = usq.withFKs + _spec = usq.querySpec() + loadedTypes = [1]bool{ + usq.withUser != nil, + } + ) + if usq.withUser != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, usersession.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserSession).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserSession{config: usq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(usq.modifiers) > 0 { + _spec.Modifiers = usq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, usq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := usq.withUser; query != nil { + if err := usq.loadUser(ctx, query, nodes, nil, + func(n *UserSession, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (usq *UserSessionQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserSession, init func(*UserSession), assign func(*UserSession, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*UserSession) + for i := range nodes { + if nodes[i].user_id == nil { + continue + } + fk := *nodes[i].user_id + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.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 "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (usq *UserSessionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := usq.querySpec() + if len(usq.modifiers) > 0 { + _spec.Modifiers = usq.modifiers + } + _spec.Node.Columns = usq.ctx.Fields + if len(usq.ctx.Fields) > 0 { + _spec.Unique = usq.ctx.Unique != nil && *usq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, usq.driver, _spec) +} + +func (usq *UserSessionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) + _spec.From = usq.sql + if unique := usq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if usq.path != nil { + _spec.Unique = true + } + if fields := usq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usersession.FieldID) + for i := range fields { + if fields[i] != usersession.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := usq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := usq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := usq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := usq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (usq *UserSessionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(usq.driver.Dialect()) + t1 := builder.Table(usersession.Table) + columns := usq.ctx.Fields + if len(columns) == 0 { + columns = usersession.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if usq.sql != nil { + selector = usq.sql + selector.Select(selector.Columns(columns...)...) + } + if usq.ctx.Unique != nil && *usq.ctx.Unique { + selector.Distinct() + } + for _, m := range usq.modifiers { + m(selector) + } + for _, p := range usq.predicates { + p(selector) + } + for _, p := range usq.order { + p(selector) + } + if offset := usq.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 := usq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (usq *UserSessionQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSessionSelect { + usq.modifiers = append(usq.modifiers, modifiers...) + return usq.Select() +} + +// UserSessionGroupBy is the group-by builder for UserSession entities. +type UserSessionGroupBy struct { + selector + build *UserSessionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (usgb *UserSessionGroupBy) Aggregate(fns ...AggregateFunc) *UserSessionGroupBy { + usgb.fns = append(usgb.fns, fns...) + return usgb +} + +// Scan applies the selector query and scans the result into the given value. +func (usgb *UserSessionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, usgb.build.ctx, "GroupBy") + if err := usgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserSessionQuery, *UserSessionGroupBy](ctx, usgb.build, usgb, usgb.build.inters, v) +} + +func (usgb *UserSessionGroupBy) sqlScan(ctx context.Context, root *UserSessionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(usgb.fns)) + for _, fn := range usgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*usgb.flds)+len(usgb.fns)) + for _, f := range *usgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*usgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := usgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserSessionSelect is the builder for selecting fields of UserSession entities. +type UserSessionSelect struct { + *UserSessionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (uss *UserSessionSelect) Aggregate(fns ...AggregateFunc) *UserSessionSelect { + uss.fns = append(uss.fns, fns...) + return uss +} + +// Scan applies the selector query and scans the result into the given value. +func (uss *UserSessionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, uss.ctx, "Select") + if err := uss.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserSessionQuery, *UserSessionSelect](ctx, uss.UserSessionQuery, uss, uss.inters, v) +} + +func (uss *UserSessionSelect) sqlScan(ctx context.Context, root *UserSessionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(uss.fns)) + for _, fn := range uss.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*uss.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 := uss.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 (uss *UserSessionSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSessionSelect { + uss.modifiers = append(uss.modifiers, modifiers...) + return uss +} diff --git a/generated/ent/usersession_update.go b/generated/ent/usersession_update.go new file mode 100644 index 00000000..ea7bebf8 --- /dev/null +++ b/generated/ent/usersession_update.go @@ -0,0 +1,487 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" +) + +// UserSessionUpdate is the builder for updating UserSession entities. +type UserSessionUpdate struct { + config + hooks []Hook + mutation *UserSessionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserSessionUpdate builder. +func (usu *UserSessionUpdate) Where(ps ...predicate.UserSession) *UserSessionUpdate { + usu.mutation.Where(ps...) + return usu +} + +// SetUpdatedAt sets the "updated_at" field. +func (usu *UserSessionUpdate) SetUpdatedAt(t time.Time) *UserSessionUpdate { + usu.mutation.SetUpdatedAt(t) + return usu +} + +// SetDeletedAt sets the "deleted_at" field. +func (usu *UserSessionUpdate) SetDeletedAt(t time.Time) *UserSessionUpdate { + usu.mutation.SetDeletedAt(t) + return usu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (usu *UserSessionUpdate) SetNillableDeletedAt(t *time.Time) *UserSessionUpdate { + if t != nil { + usu.SetDeletedAt(*t) + } + return usu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (usu *UserSessionUpdate) ClearDeletedAt() *UserSessionUpdate { + usu.mutation.ClearDeletedAt() + return usu +} + +// SetToken sets the "token" field. +func (usu *UserSessionUpdate) SetToken(s string) *UserSessionUpdate { + usu.mutation.SetToken(s) + return usu +} + +// SetUserAgent sets the "user_agent" field. +func (usu *UserSessionUpdate) SetUserAgent(s string) *UserSessionUpdate { + usu.mutation.SetUserAgent(s) + return usu +} + +// SetNillableUserAgent sets the "user_agent" field if the given value is not nil. +func (usu *UserSessionUpdate) SetNillableUserAgent(s *string) *UserSessionUpdate { + if s != nil { + usu.SetUserAgent(*s) + } + return usu +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (usu *UserSessionUpdate) ClearUserAgent() *UserSessionUpdate { + usu.mutation.ClearUserAgent() + return usu +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (usu *UserSessionUpdate) SetUserID(id string) *UserSessionUpdate { + usu.mutation.SetUserID(id) + return usu +} + +// SetUser sets the "user" edge to the User entity. +func (usu *UserSessionUpdate) SetUser(u *User) *UserSessionUpdate { + return usu.SetUserID(u.ID) +} + +// Mutation returns the UserSessionMutation object of the builder. +func (usu *UserSessionUpdate) Mutation() *UserSessionMutation { + return usu.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (usu *UserSessionUpdate) ClearUser() *UserSessionUpdate { + usu.mutation.ClearUser() + return usu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (usu *UserSessionUpdate) Save(ctx context.Context) (int, error) { + if err := usu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, usu.sqlSave, usu.mutation, usu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (usu *UserSessionUpdate) SaveX(ctx context.Context) int { + affected, err := usu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (usu *UserSessionUpdate) Exec(ctx context.Context) error { + _, err := usu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (usu *UserSessionUpdate) ExecX(ctx context.Context) { + if err := usu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (usu *UserSessionUpdate) defaults() error { + if _, ok := usu.mutation.UpdatedAt(); !ok { + if usersession.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usersession.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usersession.UpdateDefaultUpdatedAt() + usu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (usu *UserSessionUpdate) check() error { + if v, ok := usu.mutation.Token(); ok { + if err := usersession.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "UserSession.token": %w`, err)} + } + } + if _, ok := usu.mutation.UserID(); usu.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserSession.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (usu *UserSessionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSessionUpdate { + usu.modifiers = append(usu.modifiers, modifiers...) + return usu +} + +func (usu *UserSessionUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := usu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) + if ps := usu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := usu.mutation.UpdatedAt(); ok { + _spec.SetField(usersession.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := usu.mutation.DeletedAt(); ok { + _spec.SetField(usersession.FieldDeletedAt, field.TypeTime, value) + } + if usu.mutation.DeletedAtCleared() { + _spec.ClearField(usersession.FieldDeletedAt, field.TypeTime) + } + if value, ok := usu.mutation.Token(); ok { + _spec.SetField(usersession.FieldToken, field.TypeString, value) + } + if value, ok := usu.mutation.UserAgent(); ok { + _spec.SetField(usersession.FieldUserAgent, field.TypeString, value) + } + if usu.mutation.UserAgentCleared() { + _spec.ClearField(usersession.FieldUserAgent, field.TypeString) + } + if usu.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usersession.UserTable, + Columns: []string{usersession.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := usu.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usersession.UserTable, + Columns: []string{usersession.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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(usu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, usu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usersession.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + usu.mutation.done = true + return n, nil +} + +// UserSessionUpdateOne is the builder for updating a single UserSession entity. +type UserSessionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserSessionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (usuo *UserSessionUpdateOne) SetUpdatedAt(t time.Time) *UserSessionUpdateOne { + usuo.mutation.SetUpdatedAt(t) + return usuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (usuo *UserSessionUpdateOne) SetDeletedAt(t time.Time) *UserSessionUpdateOne { + usuo.mutation.SetDeletedAt(t) + return usuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (usuo *UserSessionUpdateOne) SetNillableDeletedAt(t *time.Time) *UserSessionUpdateOne { + if t != nil { + usuo.SetDeletedAt(*t) + } + return usuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (usuo *UserSessionUpdateOne) ClearDeletedAt() *UserSessionUpdateOne { + usuo.mutation.ClearDeletedAt() + return usuo +} + +// SetToken sets the "token" field. +func (usuo *UserSessionUpdateOne) SetToken(s string) *UserSessionUpdateOne { + usuo.mutation.SetToken(s) + return usuo +} + +// SetUserAgent sets the "user_agent" field. +func (usuo *UserSessionUpdateOne) SetUserAgent(s string) *UserSessionUpdateOne { + usuo.mutation.SetUserAgent(s) + return usuo +} + +// SetNillableUserAgent sets the "user_agent" field if the given value is not nil. +func (usuo *UserSessionUpdateOne) SetNillableUserAgent(s *string) *UserSessionUpdateOne { + if s != nil { + usuo.SetUserAgent(*s) + } + return usuo +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (usuo *UserSessionUpdateOne) ClearUserAgent() *UserSessionUpdateOne { + usuo.mutation.ClearUserAgent() + return usuo +} + +// SetUserID sets the "user" edge to the User entity by ID. +func (usuo *UserSessionUpdateOne) SetUserID(id string) *UserSessionUpdateOne { + usuo.mutation.SetUserID(id) + return usuo +} + +// SetUser sets the "user" edge to the User entity. +func (usuo *UserSessionUpdateOne) SetUser(u *User) *UserSessionUpdateOne { + return usuo.SetUserID(u.ID) +} + +// Mutation returns the UserSessionMutation object of the builder. +func (usuo *UserSessionUpdateOne) Mutation() *UserSessionMutation { + return usuo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (usuo *UserSessionUpdateOne) ClearUser() *UserSessionUpdateOne { + usuo.mutation.ClearUser() + return usuo +} + +// Where appends a list predicates to the UserSessionUpdate builder. +func (usuo *UserSessionUpdateOne) Where(ps ...predicate.UserSession) *UserSessionUpdateOne { + usuo.mutation.Where(ps...) + return usuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (usuo *UserSessionUpdateOne) Select(field string, fields ...string) *UserSessionUpdateOne { + usuo.fields = append([]string{field}, fields...) + return usuo +} + +// Save executes the query and returns the updated UserSession entity. +func (usuo *UserSessionUpdateOne) Save(ctx context.Context) (*UserSession, error) { + if err := usuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, usuo.sqlSave, usuo.mutation, usuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (usuo *UserSessionUpdateOne) SaveX(ctx context.Context) *UserSession { + node, err := usuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (usuo *UserSessionUpdateOne) Exec(ctx context.Context) error { + _, err := usuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (usuo *UserSessionUpdateOne) ExecX(ctx context.Context) { + if err := usuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (usuo *UserSessionUpdateOne) defaults() error { + if _, ok := usuo.mutation.UpdatedAt(); !ok { + if usersession.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized usersession.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := usersession.UpdateDefaultUpdatedAt() + usuo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (usuo *UserSessionUpdateOne) check() error { + if v, ok := usuo.mutation.Token(); ok { + if err := usersession.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "UserSession.token": %w`, err)} + } + } + if _, ok := usuo.mutation.UserID(); usuo.mutation.UserCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "UserSession.user"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (usuo *UserSessionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserSessionUpdateOne { + usuo.modifiers = append(usuo.modifiers, modifiers...) + return usuo +} + +func (usuo *UserSessionUpdateOne) sqlSave(ctx context.Context) (_node *UserSession, err error) { + if err := usuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) + id, ok := usuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserSession.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := usuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usersession.FieldID) + for _, f := range fields { + if !usersession.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != usersession.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := usuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := usuo.mutation.UpdatedAt(); ok { + _spec.SetField(usersession.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := usuo.mutation.DeletedAt(); ok { + _spec.SetField(usersession.FieldDeletedAt, field.TypeTime, value) + } + if usuo.mutation.DeletedAtCleared() { + _spec.ClearField(usersession.FieldDeletedAt, field.TypeTime) + } + if value, ok := usuo.mutation.Token(); ok { + _spec.SetField(usersession.FieldToken, field.TypeString, value) + } + if value, ok := usuo.mutation.UserAgent(); ok { + _spec.SetField(usersession.FieldUserAgent, field.TypeString, value) + } + if usuo.mutation.UserAgentCleared() { + _spec.ClearField(usersession.FieldUserAgent, field.TypeString) + } + if usuo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usersession.UserTable, + Columns: []string{usersession.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := usuo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: usersession.UserTable, + Columns: []string{usersession.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.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(usuo.modifiers...) + _node = &UserSession{config: usuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, usuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usersession.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + usuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/version.go b/generated/ent/version.go new file mode 100644 index 00000000..ab9245b7 --- /dev/null +++ b/generated/ent/version.go @@ -0,0 +1,379 @@ +// 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/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +// Version is the model entity for the Version schema. +type Version 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // SmlVersion holds the value of the "sml_version" field. + SmlVersion string `json:"sml_version,omitempty"` + // Changelog holds the value of the "changelog" field. + Changelog string `json:"changelog,omitempty"` + // Downloads holds the value of the "downloads" field. + Downloads uint `json:"downloads,omitempty"` + // Key holds the value of the "key" field. + Key string `json:"key,omitempty"` + // Stability holds the value of the "stability" field. + Stability version.Stability `json:"stability,omitempty"` + // Approved holds the value of the "approved" field. + Approved bool `json:"approved,omitempty"` + // Hotness holds the value of the "hotness" field. + Hotness uint `json:"hotness,omitempty"` + // Denied holds the value of the "denied" field. + Denied bool `json:"denied,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata string `json:"metadata,omitempty"` + // ModReference holds the value of the "mod_reference" field. + ModReference string `json:"mod_reference,omitempty"` + // VersionMajor holds the value of the "version_major" field. + VersionMajor int `json:"version_major,omitempty"` + // VersionMinor holds the value of the "version_minor" field. + VersionMinor int `json:"version_minor,omitempty"` + // VersionPatch holds the value of the "version_patch" field. + VersionPatch int `json:"version_patch,omitempty"` + // Size holds the value of the "size" field. + Size int64 `json:"size,omitempty"` + // Hash holds the value of the "hash" field. + Hash string `json:"hash,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the VersionQuery when eager-loading is set. + Edges VersionEdges `json:"edges"` + mod_id *string + selectValues sql.SelectValues +} + +// VersionEdges holds the relations/edges for other nodes in the graph. +type VersionEdges struct { + // Mod holds the value of the mod edge. + Mod *Mod `json:"mod,omitempty"` + // Dependencies holds the value of the dependencies edge. + Dependencies []*Mod `json:"dependencies,omitempty"` + // VersionDependencies holds the value of the version_dependencies edge. + VersionDependencies []*VersionDependency `json:"version_dependencies,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [3]bool +} + +// 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 VersionEdges) ModOrErr() (*Mod, error) { + if e.loadedTypes[0] { + if e.Mod == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: mod.Label} + } + return e.Mod, nil + } + return nil, &NotLoadedError{edge: "mod"} +} + +// DependenciesOrErr returns the Dependencies value or an error if the edge +// was not loaded in eager-loading. +func (e VersionEdges) DependenciesOrErr() ([]*Mod, error) { + if e.loadedTypes[1] { + return e.Dependencies, nil + } + return nil, &NotLoadedError{edge: "dependencies"} +} + +// VersionDependenciesOrErr returns the VersionDependencies value or an error if the edge +// was not loaded in eager-loading. +func (e VersionEdges) VersionDependenciesOrErr() ([]*VersionDependency, error) { + if e.loadedTypes[2] { + return e.VersionDependencies, nil + } + return nil, &NotLoadedError{edge: "version_dependencies"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Version) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case version.FieldApproved, version.FieldDenied: + values[i] = new(sql.NullBool) + case version.FieldDownloads, version.FieldHotness, version.FieldVersionMajor, version.FieldVersionMinor, version.FieldVersionPatch, version.FieldSize: + values[i] = new(sql.NullInt64) + case version.FieldID, version.FieldVersion, version.FieldSmlVersion, version.FieldChangelog, version.FieldKey, version.FieldStability, version.FieldMetadata, version.FieldModReference, version.FieldHash: + values[i] = new(sql.NullString) + case version.FieldCreatedAt, version.FieldUpdatedAt, version.FieldDeletedAt: + values[i] = new(sql.NullTime) + case version.ForeignKeys[0]: // mod_id + 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 Version fields. +func (v *Version) 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 version.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + v.ID = value.String + } + case version.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 { + v.CreatedAt = value.Time + } + case version.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 { + v.UpdatedAt = value.Time + } + case version.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + v.DeletedAt = value.Time + } + case version.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + v.Version = value.String + } + case version.FieldSmlVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sml_version", values[i]) + } else if value.Valid { + v.SmlVersion = value.String + } + case version.FieldChangelog: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field changelog", values[i]) + } else if value.Valid { + v.Changelog = value.String + } + case version.FieldDownloads: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field downloads", values[i]) + } else if value.Valid { + v.Downloads = uint(value.Int64) + } + case version.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + v.Key = value.String + } + case version.FieldStability: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field stability", values[i]) + } else if value.Valid { + v.Stability = version.Stability(value.String) + } + case version.FieldApproved: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field approved", values[i]) + } else if value.Valid { + v.Approved = value.Bool + } + case version.FieldHotness: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field hotness", values[i]) + } else if value.Valid { + v.Hotness = uint(value.Int64) + } + case version.FieldDenied: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field denied", values[i]) + } else if value.Valid { + v.Denied = value.Bool + } + case version.FieldMetadata: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field metadata", values[i]) + } else if value.Valid { + v.Metadata = value.String + } + case version.FieldModReference: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mod_reference", values[i]) + } else if value.Valid { + v.ModReference = value.String + } + case version.FieldVersionMajor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field version_major", values[i]) + } else if value.Valid { + v.VersionMajor = int(value.Int64) + } + case version.FieldVersionMinor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field version_minor", values[i]) + } else if value.Valid { + v.VersionMinor = int(value.Int64) + } + case version.FieldVersionPatch: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field version_patch", values[i]) + } else if value.Valid { + v.VersionPatch = int(value.Int64) + } + case version.FieldSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + v.Size = value.Int64 + } + case version.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + v.Hash = value.String + } + case version.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mod_id", values[i]) + } else if value.Valid { + v.mod_id = new(string) + *v.mod_id = value.String + } + default: + v.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Version. +// This includes values selected through modifiers, order, etc. +func (v *Version) Value(name string) (ent.Value, error) { + return v.selectValues.Get(name) +} + +// QueryMod queries the "mod" edge of the Version entity. +func (v *Version) QueryMod() *ModQuery { + return NewVersionClient(v.config).QueryMod(v) +} + +// QueryDependencies queries the "dependencies" edge of the Version entity. +func (v *Version) QueryDependencies() *ModQuery { + return NewVersionClient(v.config).QueryDependencies(v) +} + +// QueryVersionDependencies queries the "version_dependencies" edge of the Version entity. +func (v *Version) QueryVersionDependencies() *VersionDependencyQuery { + return NewVersionClient(v.config).QueryVersionDependencies(v) +} + +// Update returns a builder for updating this Version. +// Note that you need to call Version.Unwrap() before calling this method if this Version +// was returned from a transaction, and the transaction was committed or rolled back. +func (v *Version) Update() *VersionUpdateOne { + return NewVersionClient(v.config).UpdateOne(v) +} + +// Unwrap unwraps the Version 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 (v *Version) Unwrap() *Version { + _tx, ok := v.config.driver.(*txDriver) + if !ok { + panic("ent: Version is not a transactional entity") + } + v.config.driver = _tx.drv + return v +} + +// String implements the fmt.Stringer. +func (v *Version) String() string { + var builder strings.Builder + builder.WriteString("Version(") + builder.WriteString(fmt.Sprintf("id=%v, ", v.ID)) + builder.WriteString("created_at=") + builder.WriteString(v.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(v.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(v.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(v.Version) + builder.WriteString(", ") + builder.WriteString("sml_version=") + builder.WriteString(v.SmlVersion) + builder.WriteString(", ") + builder.WriteString("changelog=") + builder.WriteString(v.Changelog) + builder.WriteString(", ") + builder.WriteString("downloads=") + builder.WriteString(fmt.Sprintf("%v", v.Downloads)) + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(v.Key) + builder.WriteString(", ") + builder.WriteString("stability=") + builder.WriteString(fmt.Sprintf("%v", v.Stability)) + builder.WriteString(", ") + builder.WriteString("approved=") + builder.WriteString(fmt.Sprintf("%v", v.Approved)) + builder.WriteString(", ") + builder.WriteString("hotness=") + builder.WriteString(fmt.Sprintf("%v", v.Hotness)) + builder.WriteString(", ") + builder.WriteString("denied=") + builder.WriteString(fmt.Sprintf("%v", v.Denied)) + builder.WriteString(", ") + builder.WriteString("metadata=") + builder.WriteString(v.Metadata) + builder.WriteString(", ") + builder.WriteString("mod_reference=") + builder.WriteString(v.ModReference) + builder.WriteString(", ") + builder.WriteString("version_major=") + builder.WriteString(fmt.Sprintf("%v", v.VersionMajor)) + builder.WriteString(", ") + builder.WriteString("version_minor=") + builder.WriteString(fmt.Sprintf("%v", v.VersionMinor)) + builder.WriteString(", ") + builder.WriteString("version_patch=") + builder.WriteString(fmt.Sprintf("%v", v.VersionPatch)) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(fmt.Sprintf("%v", v.Size)) + builder.WriteString(", ") + builder.WriteString("hash=") + builder.WriteString(v.Hash) + builder.WriteByte(')') + return builder.String() +} + +// Versions is a parsable slice of Version. +type Versions []*Version diff --git a/generated/ent/version/version.go b/generated/ent/version/version.go new file mode 100644 index 00000000..00b68c98 --- /dev/null +++ b/generated/ent/version/version.go @@ -0,0 +1,348 @@ +// Code generated by ent, DO NOT EDIT. + +package version + +import ( + "fmt" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the version type in the database. + Label = "version" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldSmlVersion holds the string denoting the sml_version field in the database. + FieldSmlVersion = "sml_version" + // FieldChangelog holds the string denoting the changelog field in the database. + FieldChangelog = "changelog" + // FieldDownloads holds the string denoting the downloads field in the database. + FieldDownloads = "downloads" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldStability holds the string denoting the stability field in the database. + FieldStability = "stability" + // FieldApproved holds the string denoting the approved field in the database. + FieldApproved = "approved" + // FieldHotness holds the string denoting the hotness field in the database. + FieldHotness = "hotness" + // FieldDenied holds the string denoting the denied field in the database. + FieldDenied = "denied" + // FieldMetadata holds the string denoting the metadata field in the database. + FieldMetadata = "metadata" + // FieldModReference holds the string denoting the mod_reference field in the database. + FieldModReference = "mod_reference" + // FieldVersionMajor holds the string denoting the version_major field in the database. + FieldVersionMajor = "version_major" + // FieldVersionMinor holds the string denoting the version_minor field in the database. + FieldVersionMinor = "version_minor" + // FieldVersionPatch holds the string denoting the version_patch field in the database. + FieldVersionPatch = "version_patch" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // EdgeMod holds the string denoting the mod edge name in mutations. + EdgeMod = "mod" + // EdgeDependencies holds the string denoting the dependencies edge name in mutations. + EdgeDependencies = "dependencies" + // EdgeVersionDependencies holds the string denoting the version_dependencies edge name in mutations. + EdgeVersionDependencies = "version_dependencies" + // Table holds the table name of the version in the database. + Table = "versions" + // ModTable is the table that holds the mod relation/edge. + ModTable = "versions" + // 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" + // DependenciesTable is the table that holds the dependencies relation/edge. The primary key declared below. + DependenciesTable = "version_dependencies" + // DependenciesInverseTable is the table name for the Mod entity. + // It exists in this package in order to avoid circular dependency with the "mod" package. + DependenciesInverseTable = "mods" + // VersionDependenciesTable is the table that holds the version_dependencies relation/edge. + VersionDependenciesTable = "version_dependencies" + // VersionDependenciesInverseTable is the table name for the VersionDependency entity. + // It exists in this package in order to avoid circular dependency with the "versiondependency" package. + VersionDependenciesInverseTable = "version_dependencies" + // VersionDependenciesColumn is the table column denoting the version_dependencies relation/edge. + VersionDependenciesColumn = "version_id" +) + +// Columns holds all SQL columns for version fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldVersion, + FieldSmlVersion, + FieldChangelog, + FieldDownloads, + FieldKey, + FieldStability, + FieldApproved, + FieldHotness, + FieldDenied, + FieldMetadata, + FieldModReference, + FieldVersionMajor, + FieldVersionMinor, + FieldVersionPatch, + FieldSize, + FieldHash, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "versions" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "mod_id", +} + +var ( + // DependenciesPrimaryKey and DependenciesColumn2 are the table columns denoting the + // primary key for the dependencies relation (M2M). + DependenciesPrimaryKey = []string{"version_id", "mod_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 + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(string) error + // SmlVersionValidator is a validator for the "sml_version" field. It is called by the builders before save. + SmlVersionValidator func(string) error + // DefaultApproved holds the default value on creation for the "approved" field. + DefaultApproved bool + // DefaultDenied holds the default value on creation for the "denied" field. + DefaultDenied bool + // ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. + ModReferenceValidator func(string) error + // HashValidator is a validator for the "hash" field. It is called by the builders before save. + HashValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// Stability defines the type for the "stability" enum field. +type Stability string + +// Stability values. +const ( + StabilityAlpha Stability = "alpha" + StabilityBeta Stability = "beta" + StabilityRelease Stability = "release" +) + +func (s Stability) String() string { + return string(s) +} + +// StabilityValidator is a validator for the "stability" field enum values. It is called by the builders before save. +func StabilityValidator(s Stability) error { + switch s { + case StabilityAlpha, StabilityBeta, StabilityRelease: + return nil + default: + return fmt.Errorf("version: invalid enum value for stability field: %q", s) + } +} + +// OrderOption defines the ordering options for the Version 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// BySmlVersion orders the results by the sml_version field. +func BySmlVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSmlVersion, opts...).ToFunc() +} + +// ByChangelog orders the results by the changelog field. +func ByChangelog(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChangelog, opts...).ToFunc() +} + +// ByDownloads orders the results by the downloads field. +func ByDownloads(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDownloads, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByStability orders the results by the stability field. +func ByStability(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStability, opts...).ToFunc() +} + +// ByApproved orders the results by the approved field. +func ByApproved(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldApproved, opts...).ToFunc() +} + +// ByHotness orders the results by the hotness field. +func ByHotness(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHotness, opts...).ToFunc() +} + +// ByDenied orders the results by the denied field. +func ByDenied(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDenied, opts...).ToFunc() +} + +// ByMetadata orders the results by the metadata field. +func ByMetadata(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMetadata, opts...).ToFunc() +} + +// ByModReference orders the results by the mod_reference field. +func ByModReference(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModReference, opts...).ToFunc() +} + +// ByVersionMajor orders the results by the version_major field. +func ByVersionMajor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionMajor, opts...).ToFunc() +} + +// ByVersionMinor orders the results by the version_minor field. +func ByVersionMinor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionMinor, opts...).ToFunc() +} + +// ByVersionPatch orders the results by the version_patch field. +func ByVersionPatch(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionPatch, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// 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...)) + } +} + +// ByDependenciesCount orders the results by dependencies count. +func ByDependenciesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newDependenciesStep(), opts...) + } +} + +// ByDependencies orders the results by dependencies terms. +func ByDependencies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newDependenciesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByVersionDependenciesCount orders the results by version_dependencies count. +func ByVersionDependenciesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionDependenciesStep(), opts...) + } +} + +// ByVersionDependencies orders the results by version_dependencies terms. +func ByVersionDependencies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionDependenciesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newModStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ModInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ModTable, ModColumn), + ) +} +func newDependenciesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(DependenciesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, DependenciesTable, DependenciesPrimaryKey...), + ) +} +func newVersionDependenciesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionDependenciesInverseTable, VersionDependenciesColumn), + sqlgraph.Edge(sqlgraph.O2M, true, VersionDependenciesTable, VersionDependenciesColumn), + ) +} diff --git a/generated/ent/version/where.go b/generated/ent/version/where.go new file mode 100644 index 00000000..c4e73573 --- /dev/null +++ b/generated/ent/version/where.go @@ -0,0 +1,1105 @@ +// Code generated by ent, DO NOT EDIT. + +package version + +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.Version { + return predicate.Version(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Version { + return predicate.Version(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.Version { + return predicate.Version(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.Version { + return predicate.Version(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersion, v)) +} + +// SmlVersion applies equality check predicate on the "sml_version" field. It's identical to SmlVersionEQ. +func SmlVersion(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldSmlVersion, v)) +} + +// Changelog applies equality check predicate on the "changelog" field. It's identical to ChangelogEQ. +func Changelog(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldChangelog, v)) +} + +// Downloads applies equality check predicate on the "downloads" field. It's identical to DownloadsEQ. +func Downloads(v uint) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDownloads, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldKey, v)) +} + +// Approved applies equality check predicate on the "approved" field. It's identical to ApprovedEQ. +func Approved(v bool) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldApproved, v)) +} + +// Hotness applies equality check predicate on the "hotness" field. It's identical to HotnessEQ. +func Hotness(v uint) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldHotness, v)) +} + +// Denied applies equality check predicate on the "denied" field. It's identical to DeniedEQ. +func Denied(v bool) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDenied, v)) +} + +// Metadata applies equality check predicate on the "metadata" field. It's identical to MetadataEQ. +func Metadata(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldMetadata, v)) +} + +// ModReference applies equality check predicate on the "mod_reference" field. It's identical to ModReferenceEQ. +func ModReference(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldModReference, v)) +} + +// VersionMajor applies equality check predicate on the "version_major" field. It's identical to VersionMajorEQ. +func VersionMajor(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionMajor, v)) +} + +// VersionMinor applies equality check predicate on the "version_minor" field. It's identical to VersionMinorEQ. +func VersionMinor(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionMinor, v)) +} + +// VersionPatch applies equality check predicate on the "version_patch" field. It's identical to VersionPatchEQ. +func VersionPatch(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionPatch, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v int64) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldSize, v)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldHash, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldDeletedAt)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldVersion, v)) +} + +// SmlVersionEQ applies the EQ predicate on the "sml_version" field. +func SmlVersionEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldSmlVersion, v)) +} + +// SmlVersionNEQ applies the NEQ predicate on the "sml_version" field. +func SmlVersionNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldSmlVersion, v)) +} + +// SmlVersionIn applies the In predicate on the "sml_version" field. +func SmlVersionIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldSmlVersion, vs...)) +} + +// SmlVersionNotIn applies the NotIn predicate on the "sml_version" field. +func SmlVersionNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldSmlVersion, vs...)) +} + +// SmlVersionGT applies the GT predicate on the "sml_version" field. +func SmlVersionGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldSmlVersion, v)) +} + +// SmlVersionGTE applies the GTE predicate on the "sml_version" field. +func SmlVersionGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldSmlVersion, v)) +} + +// SmlVersionLT applies the LT predicate on the "sml_version" field. +func SmlVersionLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldSmlVersion, v)) +} + +// SmlVersionLTE applies the LTE predicate on the "sml_version" field. +func SmlVersionLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldSmlVersion, v)) +} + +// SmlVersionContains applies the Contains predicate on the "sml_version" field. +func SmlVersionContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldSmlVersion, v)) +} + +// SmlVersionHasPrefix applies the HasPrefix predicate on the "sml_version" field. +func SmlVersionHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldSmlVersion, v)) +} + +// SmlVersionHasSuffix applies the HasSuffix predicate on the "sml_version" field. +func SmlVersionHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldSmlVersion, v)) +} + +// SmlVersionEqualFold applies the EqualFold predicate on the "sml_version" field. +func SmlVersionEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldSmlVersion, v)) +} + +// SmlVersionContainsFold applies the ContainsFold predicate on the "sml_version" field. +func SmlVersionContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldSmlVersion, v)) +} + +// ChangelogEQ applies the EQ predicate on the "changelog" field. +func ChangelogEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldChangelog, v)) +} + +// ChangelogNEQ applies the NEQ predicate on the "changelog" field. +func ChangelogNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldChangelog, v)) +} + +// ChangelogIn applies the In predicate on the "changelog" field. +func ChangelogIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldChangelog, vs...)) +} + +// ChangelogNotIn applies the NotIn predicate on the "changelog" field. +func ChangelogNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldChangelog, vs...)) +} + +// ChangelogGT applies the GT predicate on the "changelog" field. +func ChangelogGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldChangelog, v)) +} + +// ChangelogGTE applies the GTE predicate on the "changelog" field. +func ChangelogGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldChangelog, v)) +} + +// ChangelogLT applies the LT predicate on the "changelog" field. +func ChangelogLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldChangelog, v)) +} + +// ChangelogLTE applies the LTE predicate on the "changelog" field. +func ChangelogLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldChangelog, v)) +} + +// ChangelogContains applies the Contains predicate on the "changelog" field. +func ChangelogContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldChangelog, v)) +} + +// ChangelogHasPrefix applies the HasPrefix predicate on the "changelog" field. +func ChangelogHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldChangelog, v)) +} + +// ChangelogHasSuffix applies the HasSuffix predicate on the "changelog" field. +func ChangelogHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldChangelog, v)) +} + +// ChangelogEqualFold applies the EqualFold predicate on the "changelog" field. +func ChangelogEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldChangelog, v)) +} + +// ChangelogContainsFold applies the ContainsFold predicate on the "changelog" field. +func ChangelogContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldChangelog, v)) +} + +// DownloadsEQ applies the EQ predicate on the "downloads" field. +func DownloadsEQ(v uint) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDownloads, v)) +} + +// DownloadsNEQ applies the NEQ predicate on the "downloads" field. +func DownloadsNEQ(v uint) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldDownloads, v)) +} + +// DownloadsIn applies the In predicate on the "downloads" field. +func DownloadsIn(vs ...uint) predicate.Version { + return predicate.Version(sql.FieldIn(FieldDownloads, vs...)) +} + +// DownloadsNotIn applies the NotIn predicate on the "downloads" field. +func DownloadsNotIn(vs ...uint) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldDownloads, vs...)) +} + +// DownloadsGT applies the GT predicate on the "downloads" field. +func DownloadsGT(v uint) predicate.Version { + return predicate.Version(sql.FieldGT(FieldDownloads, v)) +} + +// DownloadsGTE applies the GTE predicate on the "downloads" field. +func DownloadsGTE(v uint) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldDownloads, v)) +} + +// DownloadsLT applies the LT predicate on the "downloads" field. +func DownloadsLT(v uint) predicate.Version { + return predicate.Version(sql.FieldLT(FieldDownloads, v)) +} + +// DownloadsLTE applies the LTE predicate on the "downloads" field. +func DownloadsLTE(v uint) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldDownloads, v)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldKey, v)) +} + +// StabilityEQ applies the EQ predicate on the "stability" field. +func StabilityEQ(v Stability) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldStability, v)) +} + +// StabilityNEQ applies the NEQ predicate on the "stability" field. +func StabilityNEQ(v Stability) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldStability, v)) +} + +// StabilityIn applies the In predicate on the "stability" field. +func StabilityIn(vs ...Stability) predicate.Version { + return predicate.Version(sql.FieldIn(FieldStability, vs...)) +} + +// StabilityNotIn applies the NotIn predicate on the "stability" field. +func StabilityNotIn(vs ...Stability) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldStability, vs...)) +} + +// ApprovedEQ applies the EQ predicate on the "approved" field. +func ApprovedEQ(v bool) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldApproved, v)) +} + +// ApprovedNEQ applies the NEQ predicate on the "approved" field. +func ApprovedNEQ(v bool) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldApproved, v)) +} + +// HotnessEQ applies the EQ predicate on the "hotness" field. +func HotnessEQ(v uint) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldHotness, v)) +} + +// HotnessNEQ applies the NEQ predicate on the "hotness" field. +func HotnessNEQ(v uint) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldHotness, v)) +} + +// HotnessIn applies the In predicate on the "hotness" field. +func HotnessIn(vs ...uint) predicate.Version { + return predicate.Version(sql.FieldIn(FieldHotness, vs...)) +} + +// HotnessNotIn applies the NotIn predicate on the "hotness" field. +func HotnessNotIn(vs ...uint) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldHotness, vs...)) +} + +// HotnessGT applies the GT predicate on the "hotness" field. +func HotnessGT(v uint) predicate.Version { + return predicate.Version(sql.FieldGT(FieldHotness, v)) +} + +// HotnessGTE applies the GTE predicate on the "hotness" field. +func HotnessGTE(v uint) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldHotness, v)) +} + +// HotnessLT applies the LT predicate on the "hotness" field. +func HotnessLT(v uint) predicate.Version { + return predicate.Version(sql.FieldLT(FieldHotness, v)) +} + +// HotnessLTE applies the LTE predicate on the "hotness" field. +func HotnessLTE(v uint) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldHotness, v)) +} + +// DeniedEQ applies the EQ predicate on the "denied" field. +func DeniedEQ(v bool) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldDenied, v)) +} + +// DeniedNEQ applies the NEQ predicate on the "denied" field. +func DeniedNEQ(v bool) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldDenied, v)) +} + +// MetadataEQ applies the EQ predicate on the "metadata" field. +func MetadataEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldMetadata, v)) +} + +// MetadataNEQ applies the NEQ predicate on the "metadata" field. +func MetadataNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldMetadata, v)) +} + +// MetadataIn applies the In predicate on the "metadata" field. +func MetadataIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldMetadata, vs...)) +} + +// MetadataNotIn applies the NotIn predicate on the "metadata" field. +func MetadataNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldMetadata, vs...)) +} + +// MetadataGT applies the GT predicate on the "metadata" field. +func MetadataGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldMetadata, v)) +} + +// MetadataGTE applies the GTE predicate on the "metadata" field. +func MetadataGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldMetadata, v)) +} + +// MetadataLT applies the LT predicate on the "metadata" field. +func MetadataLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldMetadata, v)) +} + +// MetadataLTE applies the LTE predicate on the "metadata" field. +func MetadataLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldMetadata, v)) +} + +// MetadataContains applies the Contains predicate on the "metadata" field. +func MetadataContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldMetadata, v)) +} + +// MetadataHasPrefix applies the HasPrefix predicate on the "metadata" field. +func MetadataHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldMetadata, v)) +} + +// MetadataHasSuffix applies the HasSuffix predicate on the "metadata" field. +func MetadataHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldMetadata, v)) +} + +// MetadataEqualFold applies the EqualFold predicate on the "metadata" field. +func MetadataEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldMetadata, v)) +} + +// MetadataContainsFold applies the ContainsFold predicate on the "metadata" field. +func MetadataContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldMetadata, v)) +} + +// ModReferenceEQ applies the EQ predicate on the "mod_reference" field. +func ModReferenceEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldModReference, v)) +} + +// ModReferenceNEQ applies the NEQ predicate on the "mod_reference" field. +func ModReferenceNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldModReference, v)) +} + +// ModReferenceIn applies the In predicate on the "mod_reference" field. +func ModReferenceIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldModReference, vs...)) +} + +// ModReferenceNotIn applies the NotIn predicate on the "mod_reference" field. +func ModReferenceNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldModReference, vs...)) +} + +// ModReferenceGT applies the GT predicate on the "mod_reference" field. +func ModReferenceGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldModReference, v)) +} + +// ModReferenceGTE applies the GTE predicate on the "mod_reference" field. +func ModReferenceGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldModReference, v)) +} + +// ModReferenceLT applies the LT predicate on the "mod_reference" field. +func ModReferenceLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldModReference, v)) +} + +// ModReferenceLTE applies the LTE predicate on the "mod_reference" field. +func ModReferenceLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldModReference, v)) +} + +// ModReferenceContains applies the Contains predicate on the "mod_reference" field. +func ModReferenceContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldModReference, v)) +} + +// ModReferenceHasPrefix applies the HasPrefix predicate on the "mod_reference" field. +func ModReferenceHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldModReference, v)) +} + +// ModReferenceHasSuffix applies the HasSuffix predicate on the "mod_reference" field. +func ModReferenceHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldModReference, v)) +} + +// ModReferenceEqualFold applies the EqualFold predicate on the "mod_reference" field. +func ModReferenceEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldModReference, v)) +} + +// ModReferenceContainsFold applies the ContainsFold predicate on the "mod_reference" field. +func ModReferenceContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldModReference, v)) +} + +// VersionMajorEQ applies the EQ predicate on the "version_major" field. +func VersionMajorEQ(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionMajor, v)) +} + +// VersionMajorNEQ applies the NEQ predicate on the "version_major" field. +func VersionMajorNEQ(v int) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldVersionMajor, v)) +} + +// VersionMajorIn applies the In predicate on the "version_major" field. +func VersionMajorIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldIn(FieldVersionMajor, vs...)) +} + +// VersionMajorNotIn applies the NotIn predicate on the "version_major" field. +func VersionMajorNotIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldVersionMajor, vs...)) +} + +// VersionMajorGT applies the GT predicate on the "version_major" field. +func VersionMajorGT(v int) predicate.Version { + return predicate.Version(sql.FieldGT(FieldVersionMajor, v)) +} + +// VersionMajorGTE applies the GTE predicate on the "version_major" field. +func VersionMajorGTE(v int) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldVersionMajor, v)) +} + +// VersionMajorLT applies the LT predicate on the "version_major" field. +func VersionMajorLT(v int) predicate.Version { + return predicate.Version(sql.FieldLT(FieldVersionMajor, v)) +} + +// VersionMajorLTE applies the LTE predicate on the "version_major" field. +func VersionMajorLTE(v int) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldVersionMajor, v)) +} + +// VersionMinorEQ applies the EQ predicate on the "version_minor" field. +func VersionMinorEQ(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionMinor, v)) +} + +// VersionMinorNEQ applies the NEQ predicate on the "version_minor" field. +func VersionMinorNEQ(v int) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldVersionMinor, v)) +} + +// VersionMinorIn applies the In predicate on the "version_minor" field. +func VersionMinorIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldIn(FieldVersionMinor, vs...)) +} + +// VersionMinorNotIn applies the NotIn predicate on the "version_minor" field. +func VersionMinorNotIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldVersionMinor, vs...)) +} + +// VersionMinorGT applies the GT predicate on the "version_minor" field. +func VersionMinorGT(v int) predicate.Version { + return predicate.Version(sql.FieldGT(FieldVersionMinor, v)) +} + +// VersionMinorGTE applies the GTE predicate on the "version_minor" field. +func VersionMinorGTE(v int) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldVersionMinor, v)) +} + +// VersionMinorLT applies the LT predicate on the "version_minor" field. +func VersionMinorLT(v int) predicate.Version { + return predicate.Version(sql.FieldLT(FieldVersionMinor, v)) +} + +// VersionMinorLTE applies the LTE predicate on the "version_minor" field. +func VersionMinorLTE(v int) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldVersionMinor, v)) +} + +// VersionPatchEQ applies the EQ predicate on the "version_patch" field. +func VersionPatchEQ(v int) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldVersionPatch, v)) +} + +// VersionPatchNEQ applies the NEQ predicate on the "version_patch" field. +func VersionPatchNEQ(v int) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldVersionPatch, v)) +} + +// VersionPatchIn applies the In predicate on the "version_patch" field. +func VersionPatchIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldIn(FieldVersionPatch, vs...)) +} + +// VersionPatchNotIn applies the NotIn predicate on the "version_patch" field. +func VersionPatchNotIn(vs ...int) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldVersionPatch, vs...)) +} + +// VersionPatchGT applies the GT predicate on the "version_patch" field. +func VersionPatchGT(v int) predicate.Version { + return predicate.Version(sql.FieldGT(FieldVersionPatch, v)) +} + +// VersionPatchGTE applies the GTE predicate on the "version_patch" field. +func VersionPatchGTE(v int) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldVersionPatch, v)) +} + +// VersionPatchLT applies the LT predicate on the "version_patch" field. +func VersionPatchLT(v int) predicate.Version { + return predicate.Version(sql.FieldLT(FieldVersionPatch, v)) +} + +// VersionPatchLTE applies the LTE predicate on the "version_patch" field. +func VersionPatchLTE(v int) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldVersionPatch, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v int64) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v int64) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...int64) predicate.Version { + return predicate.Version(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...int64) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v int64) predicate.Version { + return predicate.Version(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v int64) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v int64) predicate.Version { + return predicate.Version(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v int64) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldSize, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldHash, v)) +} + +// HasMod applies the HasEdge predicate on the "mod" edge. +func HasMod() predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, 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.Version { + return predicate.Version(func(s *sql.Selector) { + step := newModStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasDependencies applies the HasEdge predicate on the "dependencies" edge. +func HasDependencies() predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, DependenciesTable, DependenciesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasDependenciesWith applies the HasEdge predicate on the "dependencies" edge with a given conditions (other predicates). +func HasDependenciesWith(preds ...predicate.Mod) predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := newDependenciesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasVersionDependencies applies the HasEdge predicate on the "version_dependencies" edge. +func HasVersionDependencies() predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, VersionDependenciesTable, VersionDependenciesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionDependenciesWith applies the HasEdge predicate on the "version_dependencies" edge with a given conditions (other predicates). +func HasVersionDependenciesWith(preds ...predicate.VersionDependency) predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := newVersionDependenciesStep() + 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.Version) predicate.Version { + return predicate.Version(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Version) predicate.Version { + return predicate.Version(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Version) predicate.Version { + return predicate.Version(sql.NotPredicates(p)) +} diff --git a/generated/ent/version_create.go b/generated/ent/version_create.go new file mode 100644 index 00000000..bb80d7fe --- /dev/null +++ b/generated/ent/version_create.go @@ -0,0 +1,604 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "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/version" +) + +// VersionCreate is the builder for creating a Version entity. +type VersionCreate struct { + config + mutation *VersionMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (vc *VersionCreate) SetCreatedAt(t time.Time) *VersionCreate { + vc.mutation.SetCreatedAt(t) + return vc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (vc *VersionCreate) SetNillableCreatedAt(t *time.Time) *VersionCreate { + if t != nil { + vc.SetCreatedAt(*t) + } + return vc +} + +// SetUpdatedAt sets the "updated_at" field. +func (vc *VersionCreate) SetUpdatedAt(t time.Time) *VersionCreate { + vc.mutation.SetUpdatedAt(t) + return vc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (vc *VersionCreate) SetNillableUpdatedAt(t *time.Time) *VersionCreate { + if t != nil { + vc.SetUpdatedAt(*t) + } + return vc +} + +// SetDeletedAt sets the "deleted_at" field. +func (vc *VersionCreate) SetDeletedAt(t time.Time) *VersionCreate { + vc.mutation.SetDeletedAt(t) + return vc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vc *VersionCreate) SetNillableDeletedAt(t *time.Time) *VersionCreate { + if t != nil { + vc.SetDeletedAt(*t) + } + return vc +} + +// SetVersion sets the "version" field. +func (vc *VersionCreate) SetVersion(s string) *VersionCreate { + vc.mutation.SetVersion(s) + return vc +} + +// SetSmlVersion sets the "sml_version" field. +func (vc *VersionCreate) SetSmlVersion(s string) *VersionCreate { + vc.mutation.SetSmlVersion(s) + return vc +} + +// SetChangelog sets the "changelog" field. +func (vc *VersionCreate) SetChangelog(s string) *VersionCreate { + vc.mutation.SetChangelog(s) + return vc +} + +// SetDownloads sets the "downloads" field. +func (vc *VersionCreate) SetDownloads(u uint) *VersionCreate { + vc.mutation.SetDownloads(u) + return vc +} + +// SetKey sets the "key" field. +func (vc *VersionCreate) SetKey(s string) *VersionCreate { + vc.mutation.SetKey(s) + return vc +} + +// SetStability sets the "stability" field. +func (vc *VersionCreate) SetStability(v version.Stability) *VersionCreate { + vc.mutation.SetStability(v) + return vc +} + +// SetApproved sets the "approved" field. +func (vc *VersionCreate) SetApproved(b bool) *VersionCreate { + vc.mutation.SetApproved(b) + return vc +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (vc *VersionCreate) SetNillableApproved(b *bool) *VersionCreate { + if b != nil { + vc.SetApproved(*b) + } + return vc +} + +// SetHotness sets the "hotness" field. +func (vc *VersionCreate) SetHotness(u uint) *VersionCreate { + vc.mutation.SetHotness(u) + return vc +} + +// SetDenied sets the "denied" field. +func (vc *VersionCreate) SetDenied(b bool) *VersionCreate { + vc.mutation.SetDenied(b) + return vc +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (vc *VersionCreate) SetNillableDenied(b *bool) *VersionCreate { + if b != nil { + vc.SetDenied(*b) + } + return vc +} + +// SetMetadata sets the "metadata" field. +func (vc *VersionCreate) SetMetadata(s string) *VersionCreate { + vc.mutation.SetMetadata(s) + return vc +} + +// SetModReference sets the "mod_reference" field. +func (vc *VersionCreate) SetModReference(s string) *VersionCreate { + vc.mutation.SetModReference(s) + return vc +} + +// SetVersionMajor sets the "version_major" field. +func (vc *VersionCreate) SetVersionMajor(i int) *VersionCreate { + vc.mutation.SetVersionMajor(i) + return vc +} + +// SetVersionMinor sets the "version_minor" field. +func (vc *VersionCreate) SetVersionMinor(i int) *VersionCreate { + vc.mutation.SetVersionMinor(i) + return vc +} + +// SetVersionPatch sets the "version_patch" field. +func (vc *VersionCreate) SetVersionPatch(i int) *VersionCreate { + vc.mutation.SetVersionPatch(i) + return vc +} + +// SetSize sets the "size" field. +func (vc *VersionCreate) SetSize(i int64) *VersionCreate { + vc.mutation.SetSize(i) + return vc +} + +// SetHash sets the "hash" field. +func (vc *VersionCreate) SetHash(s string) *VersionCreate { + vc.mutation.SetHash(s) + return vc +} + +// SetID sets the "id" field. +func (vc *VersionCreate) SetID(s string) *VersionCreate { + vc.mutation.SetID(s) + return vc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (vc *VersionCreate) SetNillableID(s *string) *VersionCreate { + if s != nil { + vc.SetID(*s) + } + return vc +} + +// SetModID sets the "mod" edge to the Mod entity by ID. +func (vc *VersionCreate) SetModID(id string) *VersionCreate { + vc.mutation.SetModID(id) + return vc +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vc *VersionCreate) SetMod(m *Mod) *VersionCreate { + return vc.SetModID(m.ID) +} + +// AddDependencyIDs adds the "dependencies" edge to the Mod entity by IDs. +func (vc *VersionCreate) AddDependencyIDs(ids ...string) *VersionCreate { + vc.mutation.AddDependencyIDs(ids...) + return vc +} + +// AddDependencies adds the "dependencies" edges to the Mod entity. +func (vc *VersionCreate) AddDependencies(m ...*Mod) *VersionCreate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return vc.AddDependencyIDs(ids...) +} + +// Mutation returns the VersionMutation object of the builder. +func (vc *VersionCreate) Mutation() *VersionMutation { + return vc.mutation +} + +// Save creates the Version in the database. +func (vc *VersionCreate) Save(ctx context.Context) (*Version, error) { + if err := vc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, vc.sqlSave, vc.mutation, vc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (vc *VersionCreate) SaveX(ctx context.Context) *Version { + v, err := vc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vc *VersionCreate) Exec(ctx context.Context) error { + _, err := vc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vc *VersionCreate) ExecX(ctx context.Context) { + if err := vc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vc *VersionCreate) defaults() error { + if _, ok := vc.mutation.CreatedAt(); !ok { + if version.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized version.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := version.DefaultCreatedAt() + vc.mutation.SetCreatedAt(v) + } + if _, ok := vc.mutation.UpdatedAt(); !ok { + if version.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized version.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := version.DefaultUpdatedAt() + vc.mutation.SetUpdatedAt(v) + } + if _, ok := vc.mutation.Approved(); !ok { + v := version.DefaultApproved + vc.mutation.SetApproved(v) + } + if _, ok := vc.mutation.Denied(); !ok { + v := version.DefaultDenied + vc.mutation.SetDenied(v) + } + if _, ok := vc.mutation.ID(); !ok { + if version.DefaultID == nil { + return fmt.Errorf("ent: uninitialized version.DefaultID (forgotten import ent/runtime?)") + } + v := version.DefaultID() + vc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vc *VersionCreate) check() error { + if _, ok := vc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Version.created_at"`)} + } + if _, ok := vc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Version.updated_at"`)} + } + if _, ok := vc.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`ent: missing required field "Version.version"`)} + } + if v, ok := vc.mutation.Version(); ok { + if err := version.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "Version.version": %w`, err)} + } + } + if _, ok := vc.mutation.SmlVersion(); !ok { + return &ValidationError{Name: "sml_version", err: errors.New(`ent: missing required field "Version.sml_version"`)} + } + if v, ok := vc.mutation.SmlVersion(); ok { + if err := version.SmlVersionValidator(v); err != nil { + return &ValidationError{Name: "sml_version", err: fmt.Errorf(`ent: validator failed for field "Version.sml_version": %w`, err)} + } + } + if _, ok := vc.mutation.Changelog(); !ok { + return &ValidationError{Name: "changelog", err: errors.New(`ent: missing required field "Version.changelog"`)} + } + if _, ok := vc.mutation.Downloads(); !ok { + return &ValidationError{Name: "downloads", err: errors.New(`ent: missing required field "Version.downloads"`)} + } + if _, ok := vc.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Version.key"`)} + } + if _, ok := vc.mutation.Stability(); !ok { + return &ValidationError{Name: "stability", err: errors.New(`ent: missing required field "Version.stability"`)} + } + if v, ok := vc.mutation.Stability(); ok { + if err := version.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "Version.stability": %w`, err)} + } + } + if _, ok := vc.mutation.Approved(); !ok { + return &ValidationError{Name: "approved", err: errors.New(`ent: missing required field "Version.approved"`)} + } + if _, ok := vc.mutation.Hotness(); !ok { + return &ValidationError{Name: "hotness", err: errors.New(`ent: missing required field "Version.hotness"`)} + } + if _, ok := vc.mutation.Denied(); !ok { + return &ValidationError{Name: "denied", err: errors.New(`ent: missing required field "Version.denied"`)} + } + if _, ok := vc.mutation.Metadata(); !ok { + return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "Version.metadata"`)} + } + if _, ok := vc.mutation.ModReference(); !ok { + return &ValidationError{Name: "mod_reference", err: errors.New(`ent: missing required field "Version.mod_reference"`)} + } + if v, ok := vc.mutation.ModReference(); ok { + if err := version.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Version.mod_reference": %w`, err)} + } + } + if _, ok := vc.mutation.VersionMajor(); !ok { + return &ValidationError{Name: "version_major", err: errors.New(`ent: missing required field "Version.version_major"`)} + } + if _, ok := vc.mutation.VersionMinor(); !ok { + return &ValidationError{Name: "version_minor", err: errors.New(`ent: missing required field "Version.version_minor"`)} + } + if _, ok := vc.mutation.VersionPatch(); !ok { + return &ValidationError{Name: "version_patch", err: errors.New(`ent: missing required field "Version.version_patch"`)} + } + if _, ok := vc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "Version.size"`)} + } + if _, ok := vc.mutation.Hash(); !ok { + return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "Version.hash"`)} + } + if v, ok := vc.mutation.Hash(); ok { + if err := version.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Version.hash": %w`, err)} + } + } + if _, ok := vc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod", err: errors.New(`ent: missing required edge "Version.mod"`)} + } + return nil +} + +func (vc *VersionCreate) sqlSave(ctx context.Context) (*Version, error) { + if err := vc.check(); err != nil { + return nil, err + } + _node, _spec := vc.createSpec() + if err := sqlgraph.CreateNode(ctx, vc.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 Version.ID type: %T", _spec.ID.Value) + } + } + vc.mutation.id = &_node.ID + vc.mutation.done = true + return _node, nil +} + +func (vc *VersionCreate) createSpec() (*Version, *sqlgraph.CreateSpec) { + var ( + _node = &Version{config: vc.config} + _spec = sqlgraph.NewCreateSpec(version.Table, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) + ) + if id, ok := vc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := vc.mutation.CreatedAt(); ok { + _spec.SetField(version.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := vc.mutation.UpdatedAt(); ok { + _spec.SetField(version.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := vc.mutation.DeletedAt(); ok { + _spec.SetField(version.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := vc.mutation.Version(); ok { + _spec.SetField(version.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := vc.mutation.SmlVersion(); ok { + _spec.SetField(version.FieldSmlVersion, field.TypeString, value) + _node.SmlVersion = value + } + if value, ok := vc.mutation.Changelog(); ok { + _spec.SetField(version.FieldChangelog, field.TypeString, value) + _node.Changelog = value + } + if value, ok := vc.mutation.Downloads(); ok { + _spec.SetField(version.FieldDownloads, field.TypeUint, value) + _node.Downloads = value + } + if value, ok := vc.mutation.Key(); ok { + _spec.SetField(version.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := vc.mutation.Stability(); ok { + _spec.SetField(version.FieldStability, field.TypeEnum, value) + _node.Stability = value + } + if value, ok := vc.mutation.Approved(); ok { + _spec.SetField(version.FieldApproved, field.TypeBool, value) + _node.Approved = value + } + if value, ok := vc.mutation.Hotness(); ok { + _spec.SetField(version.FieldHotness, field.TypeUint, value) + _node.Hotness = value + } + if value, ok := vc.mutation.Denied(); ok { + _spec.SetField(version.FieldDenied, field.TypeBool, value) + _node.Denied = value + } + if value, ok := vc.mutation.Metadata(); ok { + _spec.SetField(version.FieldMetadata, field.TypeString, value) + _node.Metadata = value + } + if value, ok := vc.mutation.ModReference(); ok { + _spec.SetField(version.FieldModReference, field.TypeString, value) + _node.ModReference = value + } + if value, ok := vc.mutation.VersionMajor(); ok { + _spec.SetField(version.FieldVersionMajor, field.TypeInt, value) + _node.VersionMajor = value + } + if value, ok := vc.mutation.VersionMinor(); ok { + _spec.SetField(version.FieldVersionMinor, field.TypeInt, value) + _node.VersionMinor = value + } + if value, ok := vc.mutation.VersionPatch(); ok { + _spec.SetField(version.FieldVersionPatch, field.TypeInt, value) + _node.VersionPatch = value + } + if value, ok := vc.mutation.Size(); ok { + _spec.SetField(version.FieldSize, field.TypeInt64, value) + _node.Size = value + } + if value, ok := vc.mutation.Hash(); ok { + _spec.SetField(version.FieldHash, field.TypeString, value) + _node.Hash = value + } + if nodes := vc.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: version.ModTable, + Columns: []string{version.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.mod_id = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := vc.mutation.DependenciesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: vc.config, mutation: newVersionDependencyMutation(vc.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// VersionCreateBulk is the builder for creating many Version entities in bulk. +type VersionCreateBulk struct { + config + err error + builders []*VersionCreate +} + +// Save creates the Version entities in the database. +func (vcb *VersionCreateBulk) Save(ctx context.Context) ([]*Version, error) { + if vcb.err != nil { + return nil, vcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(vcb.builders)) + nodes := make([]*Version, len(vcb.builders)) + mutators := make([]Mutator, len(vcb.builders)) + for i := range vcb.builders { + func(i int, root context.Context) { + builder := vcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*VersionMutation) + 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, vcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, vcb.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, vcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (vcb *VersionCreateBulk) SaveX(ctx context.Context) []*Version { + v, err := vcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vcb *VersionCreateBulk) Exec(ctx context.Context) error { + _, err := vcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vcb *VersionCreateBulk) ExecX(ctx context.Context) { + if err := vcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/version_delete.go b/generated/ent/version_delete.go new file mode 100644 index 00000000..e3cec448 --- /dev/null +++ b/generated/ent/version_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +// VersionDelete is the builder for deleting a Version entity. +type VersionDelete struct { + config + hooks []Hook + mutation *VersionMutation +} + +// Where appends a list predicates to the VersionDelete builder. +func (vd *VersionDelete) Where(ps ...predicate.Version) *VersionDelete { + vd.mutation.Where(ps...) + return vd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (vd *VersionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, vd.sqlExec, vd.mutation, vd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (vd *VersionDelete) ExecX(ctx context.Context) int { + n, err := vd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (vd *VersionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(version.Table, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) + if ps := vd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, vd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + vd.mutation.done = true + return affected, err +} + +// VersionDeleteOne is the builder for deleting a single Version entity. +type VersionDeleteOne struct { + vd *VersionDelete +} + +// Where appends a list predicates to the VersionDelete builder. +func (vdo *VersionDeleteOne) Where(ps ...predicate.Version) *VersionDeleteOne { + vdo.vd.mutation.Where(ps...) + return vdo +} + +// Exec executes the deletion query. +func (vdo *VersionDeleteOne) Exec(ctx context.Context) error { + n, err := vdo.vd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{version.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdo *VersionDeleteOne) ExecX(ctx context.Context) { + if err := vdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/version_query.go b/generated/ent/version_query.go new file mode 100644 index 00000000..ad64a835 --- /dev/null +++ b/generated/ent/version_query.go @@ -0,0 +1,816 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionQuery is the builder for querying Version entities. +type VersionQuery struct { + config + ctx *QueryContext + order []version.OrderOption + inters []Interceptor + predicates []predicate.Version + withMod *ModQuery + withDependencies *ModQuery + withVersionDependencies *VersionDependencyQuery + withFKs bool + 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 VersionQuery builder. +func (vq *VersionQuery) Where(ps ...predicate.Version) *VersionQuery { + vq.predicates = append(vq.predicates, ps...) + return vq +} + +// Limit the number of records to be returned by this query. +func (vq *VersionQuery) Limit(limit int) *VersionQuery { + vq.ctx.Limit = &limit + return vq +} + +// Offset to start from. +func (vq *VersionQuery) Offset(offset int) *VersionQuery { + vq.ctx.Offset = &offset + return vq +} + +// 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 (vq *VersionQuery) Unique(unique bool) *VersionQuery { + vq.ctx.Unique = &unique + return vq +} + +// Order specifies how the records should be ordered. +func (vq *VersionQuery) Order(o ...version.OrderOption) *VersionQuery { + vq.order = append(vq.order, o...) + return vq +} + +// QueryMod chains the current query on the "mod" edge. +func (vq *VersionQuery) QueryMod() *ModQuery { + query := (&ModClient{config: vq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, version.ModTable, version.ModColumn), + ) + fromU = sqlgraph.SetNeighbors(vq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryDependencies chains the current query on the "dependencies" edge. +func (vq *VersionQuery) QueryDependencies() *ModQuery { + query := (&ModClient{config: vq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, version.DependenciesTable, version.DependenciesPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(vq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryVersionDependencies chains the current query on the "version_dependencies" edge. +func (vq *VersionQuery) QueryVersionDependencies() *VersionDependencyQuery { + query := (&VersionDependencyClient{config: vq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, selector), + sqlgraph.To(versiondependency.Table, versiondependency.VersionColumn), + sqlgraph.Edge(sqlgraph.O2M, true, version.VersionDependenciesTable, version.VersionDependenciesColumn), + ) + fromU = sqlgraph.SetNeighbors(vq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Version entity from the query. +// Returns a *NotFoundError when no Version was found. +func (vq *VersionQuery) First(ctx context.Context) (*Version, error) { + nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{version.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (vq *VersionQuery) FirstX(ctx context.Context) *Version { + node, err := vq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Version ID from the query. +// Returns a *NotFoundError when no Version ID was found. +func (vq *VersionQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{version.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (vq *VersionQuery) FirstIDX(ctx context.Context) string { + id, err := vq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Version entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Version entity is found. +// Returns a *NotFoundError when no Version entities are found. +func (vq *VersionQuery) Only(ctx context.Context) (*Version, error) { + nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{version.Label} + default: + return nil, &NotSingularError{version.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (vq *VersionQuery) OnlyX(ctx context.Context) *Version { + node, err := vq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Version ID in the query. +// Returns a *NotSingularError when more than one Version ID is found. +// Returns a *NotFoundError when no entities are found. +func (vq *VersionQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{version.Label} + default: + err = &NotSingularError{version.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (vq *VersionQuery) OnlyIDX(ctx context.Context) string { + id, err := vq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Versions. +func (vq *VersionQuery) All(ctx context.Context) ([]*Version, error) { + ctx = setContextOp(ctx, vq.ctx, "All") + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Version, *VersionQuery]() + return withInterceptors[[]*Version](ctx, vq, qr, vq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (vq *VersionQuery) AllX(ctx context.Context) []*Version { + nodes, err := vq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Version IDs. +func (vq *VersionQuery) IDs(ctx context.Context) (ids []string, err error) { + if vq.ctx.Unique == nil && vq.path != nil { + vq.Unique(true) + } + ctx = setContextOp(ctx, vq.ctx, "IDs") + if err = vq.Select(version.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (vq *VersionQuery) IDsX(ctx context.Context) []string { + ids, err := vq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (vq *VersionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, vq.ctx, "Count") + if err := vq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, vq, querierCount[*VersionQuery](), vq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (vq *VersionQuery) CountX(ctx context.Context) int { + count, err := vq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (vq *VersionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, vq.ctx, "Exist") + switch _, err := vq.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 (vq *VersionQuery) ExistX(ctx context.Context) bool { + exist, err := vq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the VersionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (vq *VersionQuery) Clone() *VersionQuery { + if vq == nil { + return nil + } + return &VersionQuery{ + config: vq.config, + ctx: vq.ctx.Clone(), + order: append([]version.OrderOption{}, vq.order...), + inters: append([]Interceptor{}, vq.inters...), + predicates: append([]predicate.Version{}, vq.predicates...), + withMod: vq.withMod.Clone(), + withDependencies: vq.withDependencies.Clone(), + withVersionDependencies: vq.withVersionDependencies.Clone(), + // clone intermediate query. + sql: vq.sql.Clone(), + path: vq.path, + } +} + +// 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 (vq *VersionQuery) WithMod(opts ...func(*ModQuery)) *VersionQuery { + query := (&ModClient{config: vq.config}).Query() + for _, opt := range opts { + opt(query) + } + vq.withMod = query + return vq +} + +// WithDependencies tells the query-builder to eager-load the nodes that are connected to +// the "dependencies" edge. The optional arguments are used to configure the query builder of the edge. +func (vq *VersionQuery) WithDependencies(opts ...func(*ModQuery)) *VersionQuery { + query := (&ModClient{config: vq.config}).Query() + for _, opt := range opts { + opt(query) + } + vq.withDependencies = query + return vq +} + +// WithVersionDependencies tells the query-builder to eager-load the nodes that are connected to +// the "version_dependencies" edge. The optional arguments are used to configure the query builder of the edge. +func (vq *VersionQuery) WithVersionDependencies(opts ...func(*VersionDependencyQuery)) *VersionQuery { + query := (&VersionDependencyClient{config: vq.config}).Query() + for _, opt := range opts { + opt(query) + } + vq.withVersionDependencies = query + return vq +} + +// 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.Version.Query(). +// GroupBy(version.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (vq *VersionQuery) GroupBy(field string, fields ...string) *VersionGroupBy { + vq.ctx.Fields = append([]string{field}, fields...) + grbuild := &VersionGroupBy{build: vq} + grbuild.flds = &vq.ctx.Fields + grbuild.label = version.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.Version.Query(). +// Select(version.FieldCreatedAt). +// Scan(ctx, &v) +func (vq *VersionQuery) Select(fields ...string) *VersionSelect { + vq.ctx.Fields = append(vq.ctx.Fields, fields...) + sbuild := &VersionSelect{VersionQuery: vq} + sbuild.label = version.Label + sbuild.flds, sbuild.scan = &vq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a VersionSelect configured with the given aggregations. +func (vq *VersionQuery) Aggregate(fns ...AggregateFunc) *VersionSelect { + return vq.Select().Aggregate(fns...) +} + +func (vq *VersionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range vq.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, vq); err != nil { + return err + } + } + } + for _, f := range vq.ctx.Fields { + if !version.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if vq.path != nil { + prev, err := vq.path(ctx) + if err != nil { + return err + } + vq.sql = prev + } + return nil +} + +func (vq *VersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Version, error) { + var ( + nodes = []*Version{} + withFKs = vq.withFKs + _spec = vq.querySpec() + loadedTypes = [3]bool{ + vq.withMod != nil, + vq.withDependencies != nil, + vq.withVersionDependencies != nil, + } + ) + if vq.withMod != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, version.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Version).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Version{config: vq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(vq.modifiers) > 0 { + _spec.Modifiers = vq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, vq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := vq.withMod; query != nil { + if err := vq.loadMod(ctx, query, nodes, nil, + func(n *Version, e *Mod) { n.Edges.Mod = e }); err != nil { + return nil, err + } + } + if query := vq.withDependencies; query != nil { + if err := vq.loadDependencies(ctx, query, nodes, + func(n *Version) { n.Edges.Dependencies = []*Mod{} }, + func(n *Version, e *Mod) { n.Edges.Dependencies = append(n.Edges.Dependencies, e) }); err != nil { + return nil, err + } + } + if query := vq.withVersionDependencies; query != nil { + if err := vq.loadVersionDependencies(ctx, query, nodes, + func(n *Version) { n.Edges.VersionDependencies = []*VersionDependency{} }, + func(n *Version, e *VersionDependency) { + n.Edges.VersionDependencies = append(n.Edges.VersionDependencies, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (vq *VersionQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*Version, init func(*Version), assign func(*Version, *Mod)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*Version) + for i := range nodes { + if nodes[i].mod_id == nil { + continue + } + fk := *nodes[i].mod_id + 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 (vq *VersionQuery) loadDependencies(ctx context.Context, query *ModQuery, nodes []*Version, init func(*Version), assign func(*Version, *Mod)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[string]*Version) + nids := make(map[string]map[*Version]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(version.DependenciesTable) + s.Join(joinT).On(s.C(mod.FieldID), joinT.C(version.DependenciesPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(version.DependenciesPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(version.DependenciesPrimaryKey[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[*Version]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 "dependencies" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (vq *VersionQuery) loadVersionDependencies(ctx context.Context, query *VersionDependencyQuery, nodes []*Version, init func(*Version), assign func(*Version, *VersionDependency)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Version) + 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(versiondependency.FieldVersionID) + } + query.Where(predicate.VersionDependency(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(version.VersionDependenciesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.VersionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "version_id" returned %v for node %v`, fk, n) + } + assign(node, n) + } + return nil +} + +func (vq *VersionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := vq.querySpec() + if len(vq.modifiers) > 0 { + _spec.Modifiers = vq.modifiers + } + _spec.Node.Columns = vq.ctx.Fields + if len(vq.ctx.Fields) > 0 { + _spec.Unique = vq.ctx.Unique != nil && *vq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, vq.driver, _spec) +} + +func (vq *VersionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(version.Table, version.Columns, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) + _spec.From = vq.sql + if unique := vq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if vq.path != nil { + _spec.Unique = true + } + if fields := vq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, version.FieldID) + for i := range fields { + if fields[i] != version.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := vq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := vq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := vq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := vq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (vq *VersionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(vq.driver.Dialect()) + t1 := builder.Table(version.Table) + columns := vq.ctx.Fields + if len(columns) == 0 { + columns = version.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if vq.sql != nil { + selector = vq.sql + selector.Select(selector.Columns(columns...)...) + } + if vq.ctx.Unique != nil && *vq.ctx.Unique { + selector.Distinct() + } + for _, m := range vq.modifiers { + m(selector) + } + for _, p := range vq.predicates { + p(selector) + } + for _, p := range vq.order { + p(selector) + } + if offset := vq.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 := vq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (vq *VersionQuery) Modify(modifiers ...func(s *sql.Selector)) *VersionSelect { + vq.modifiers = append(vq.modifiers, modifiers...) + return vq.Select() +} + +// VersionGroupBy is the group-by builder for Version entities. +type VersionGroupBy struct { + selector + build *VersionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (vgb *VersionGroupBy) Aggregate(fns ...AggregateFunc) *VersionGroupBy { + vgb.fns = append(vgb.fns, fns...) + return vgb +} + +// Scan applies the selector query and scans the result into the given value. +func (vgb *VersionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vgb.build.ctx, "GroupBy") + if err := vgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionQuery, *VersionGroupBy](ctx, vgb.build, vgb, vgb.build.inters, v) +} + +func (vgb *VersionGroupBy) sqlScan(ctx context.Context, root *VersionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(vgb.fns)) + for _, fn := range vgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*vgb.flds)+len(vgb.fns)) + for _, f := range *vgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*vgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := vgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// VersionSelect is the builder for selecting fields of Version entities. +type VersionSelect struct { + *VersionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (vs *VersionSelect) Aggregate(fns ...AggregateFunc) *VersionSelect { + vs.fns = append(vs.fns, fns...) + return vs +} + +// Scan applies the selector query and scans the result into the given value. +func (vs *VersionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vs.ctx, "Select") + if err := vs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionQuery, *VersionSelect](ctx, vs.VersionQuery, vs, vs.inters, v) +} + +func (vs *VersionSelect) sqlScan(ctx context.Context, root *VersionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(vs.fns)) + for _, fn := range vs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*vs.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 := vs.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 (vs *VersionSelect) Modify(modifiers ...func(s *sql.Selector)) *VersionSelect { + vs.modifiers = append(vs.modifiers, modifiers...) + return vs +} diff --git a/generated/ent/version_update.go b/generated/ent/version_update.go new file mode 100644 index 00000000..cc6365b9 --- /dev/null +++ b/generated/ent/version_update.go @@ -0,0 +1,1083 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +// VersionUpdate is the builder for updating Version entities. +type VersionUpdate struct { + config + hooks []Hook + mutation *VersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the VersionUpdate builder. +func (vu *VersionUpdate) Where(ps ...predicate.Version) *VersionUpdate { + vu.mutation.Where(ps...) + return vu +} + +// SetUpdatedAt sets the "updated_at" field. +func (vu *VersionUpdate) SetUpdatedAt(t time.Time) *VersionUpdate { + vu.mutation.SetUpdatedAt(t) + return vu +} + +// SetDeletedAt sets the "deleted_at" field. +func (vu *VersionUpdate) SetDeletedAt(t time.Time) *VersionUpdate { + vu.mutation.SetDeletedAt(t) + return vu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableDeletedAt(t *time.Time) *VersionUpdate { + if t != nil { + vu.SetDeletedAt(*t) + } + return vu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (vu *VersionUpdate) ClearDeletedAt() *VersionUpdate { + vu.mutation.ClearDeletedAt() + return vu +} + +// SetVersion sets the "version" field. +func (vu *VersionUpdate) SetVersion(s string) *VersionUpdate { + vu.mutation.SetVersion(s) + return vu +} + +// SetSmlVersion sets the "sml_version" field. +func (vu *VersionUpdate) SetSmlVersion(s string) *VersionUpdate { + vu.mutation.SetSmlVersion(s) + return vu +} + +// SetChangelog sets the "changelog" field. +func (vu *VersionUpdate) SetChangelog(s string) *VersionUpdate { + vu.mutation.SetChangelog(s) + return vu +} + +// SetDownloads sets the "downloads" field. +func (vu *VersionUpdate) SetDownloads(u uint) *VersionUpdate { + vu.mutation.ResetDownloads() + vu.mutation.SetDownloads(u) + return vu +} + +// AddDownloads adds u to the "downloads" field. +func (vu *VersionUpdate) AddDownloads(u int) *VersionUpdate { + vu.mutation.AddDownloads(u) + return vu +} + +// SetKey sets the "key" field. +func (vu *VersionUpdate) SetKey(s string) *VersionUpdate { + vu.mutation.SetKey(s) + return vu +} + +// SetStability sets the "stability" field. +func (vu *VersionUpdate) SetStability(v version.Stability) *VersionUpdate { + vu.mutation.SetStability(v) + return vu +} + +// SetApproved sets the "approved" field. +func (vu *VersionUpdate) SetApproved(b bool) *VersionUpdate { + vu.mutation.SetApproved(b) + return vu +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableApproved(b *bool) *VersionUpdate { + if b != nil { + vu.SetApproved(*b) + } + return vu +} + +// SetHotness sets the "hotness" field. +func (vu *VersionUpdate) SetHotness(u uint) *VersionUpdate { + vu.mutation.ResetHotness() + vu.mutation.SetHotness(u) + return vu +} + +// AddHotness adds u to the "hotness" field. +func (vu *VersionUpdate) AddHotness(u int) *VersionUpdate { + vu.mutation.AddHotness(u) + return vu +} + +// SetDenied sets the "denied" field. +func (vu *VersionUpdate) SetDenied(b bool) *VersionUpdate { + vu.mutation.SetDenied(b) + return vu +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableDenied(b *bool) *VersionUpdate { + if b != nil { + vu.SetDenied(*b) + } + return vu +} + +// SetMetadata sets the "metadata" field. +func (vu *VersionUpdate) SetMetadata(s string) *VersionUpdate { + vu.mutation.SetMetadata(s) + return vu +} + +// SetModReference sets the "mod_reference" field. +func (vu *VersionUpdate) SetModReference(s string) *VersionUpdate { + vu.mutation.SetModReference(s) + return vu +} + +// SetVersionMajor sets the "version_major" field. +func (vu *VersionUpdate) SetVersionMajor(i int) *VersionUpdate { + vu.mutation.ResetVersionMajor() + vu.mutation.SetVersionMajor(i) + return vu +} + +// AddVersionMajor adds i to the "version_major" field. +func (vu *VersionUpdate) AddVersionMajor(i int) *VersionUpdate { + vu.mutation.AddVersionMajor(i) + return vu +} + +// SetVersionMinor sets the "version_minor" field. +func (vu *VersionUpdate) SetVersionMinor(i int) *VersionUpdate { + vu.mutation.ResetVersionMinor() + vu.mutation.SetVersionMinor(i) + return vu +} + +// AddVersionMinor adds i to the "version_minor" field. +func (vu *VersionUpdate) AddVersionMinor(i int) *VersionUpdate { + vu.mutation.AddVersionMinor(i) + return vu +} + +// SetVersionPatch sets the "version_patch" field. +func (vu *VersionUpdate) SetVersionPatch(i int) *VersionUpdate { + vu.mutation.ResetVersionPatch() + vu.mutation.SetVersionPatch(i) + return vu +} + +// AddVersionPatch adds i to the "version_patch" field. +func (vu *VersionUpdate) AddVersionPatch(i int) *VersionUpdate { + vu.mutation.AddVersionPatch(i) + return vu +} + +// SetSize sets the "size" field. +func (vu *VersionUpdate) SetSize(i int64) *VersionUpdate { + vu.mutation.ResetSize() + vu.mutation.SetSize(i) + return vu +} + +// AddSize adds i to the "size" field. +func (vu *VersionUpdate) AddSize(i int64) *VersionUpdate { + vu.mutation.AddSize(i) + return vu +} + +// SetHash sets the "hash" field. +func (vu *VersionUpdate) SetHash(s string) *VersionUpdate { + vu.mutation.SetHash(s) + return vu +} + +// SetModID sets the "mod" edge to the Mod entity by ID. +func (vu *VersionUpdate) SetModID(id string) *VersionUpdate { + vu.mutation.SetModID(id) + return vu +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vu *VersionUpdate) SetMod(m *Mod) *VersionUpdate { + return vu.SetModID(m.ID) +} + +// AddDependencyIDs adds the "dependencies" edge to the Mod entity by IDs. +func (vu *VersionUpdate) AddDependencyIDs(ids ...string) *VersionUpdate { + vu.mutation.AddDependencyIDs(ids...) + return vu +} + +// AddDependencies adds the "dependencies" edges to the Mod entity. +func (vu *VersionUpdate) AddDependencies(m ...*Mod) *VersionUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return vu.AddDependencyIDs(ids...) +} + +// Mutation returns the VersionMutation object of the builder. +func (vu *VersionUpdate) Mutation() *VersionMutation { + return vu.mutation +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (vu *VersionUpdate) ClearMod() *VersionUpdate { + vu.mutation.ClearMod() + return vu +} + +// ClearDependencies clears all "dependencies" edges to the Mod entity. +func (vu *VersionUpdate) ClearDependencies() *VersionUpdate { + vu.mutation.ClearDependencies() + return vu +} + +// RemoveDependencyIDs removes the "dependencies" edge to Mod entities by IDs. +func (vu *VersionUpdate) RemoveDependencyIDs(ids ...string) *VersionUpdate { + vu.mutation.RemoveDependencyIDs(ids...) + return vu +} + +// RemoveDependencies removes "dependencies" edges to Mod entities. +func (vu *VersionUpdate) RemoveDependencies(m ...*Mod) *VersionUpdate { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return vu.RemoveDependencyIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (vu *VersionUpdate) Save(ctx context.Context) (int, error) { + if err := vu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, vu.sqlSave, vu.mutation, vu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vu *VersionUpdate) SaveX(ctx context.Context) int { + affected, err := vu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (vu *VersionUpdate) Exec(ctx context.Context) error { + _, err := vu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vu *VersionUpdate) ExecX(ctx context.Context) { + if err := vu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vu *VersionUpdate) defaults() error { + if _, ok := vu.mutation.UpdatedAt(); !ok { + if version.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized version.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := version.UpdateDefaultUpdatedAt() + vu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vu *VersionUpdate) check() error { + if v, ok := vu.mutation.Version(); ok { + if err := version.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "Version.version": %w`, err)} + } + } + if v, ok := vu.mutation.SmlVersion(); ok { + if err := version.SmlVersionValidator(v); err != nil { + return &ValidationError{Name: "sml_version", err: fmt.Errorf(`ent: validator failed for field "Version.sml_version": %w`, err)} + } + } + if v, ok := vu.mutation.Stability(); ok { + if err := version.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "Version.stability": %w`, err)} + } + } + if v, ok := vu.mutation.ModReference(); ok { + if err := version.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Version.mod_reference": %w`, err)} + } + } + if v, ok := vu.mutation.Hash(); ok { + if err := version.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Version.hash": %w`, err)} + } + } + if _, ok := vu.mutation.ModID(); vu.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Version.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vu *VersionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionUpdate { + vu.modifiers = append(vu.modifiers, modifiers...) + return vu +} + +func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := vu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(version.Table, version.Columns, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) + if ps := vu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vu.mutation.UpdatedAt(); ok { + _spec.SetField(version.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := vu.mutation.DeletedAt(); ok { + _spec.SetField(version.FieldDeletedAt, field.TypeTime, value) + } + if vu.mutation.DeletedAtCleared() { + _spec.ClearField(version.FieldDeletedAt, field.TypeTime) + } + if value, ok := vu.mutation.Version(); ok { + _spec.SetField(version.FieldVersion, field.TypeString, value) + } + if value, ok := vu.mutation.SmlVersion(); ok { + _spec.SetField(version.FieldSmlVersion, field.TypeString, value) + } + if value, ok := vu.mutation.Changelog(); ok { + _spec.SetField(version.FieldChangelog, field.TypeString, value) + } + if value, ok := vu.mutation.Downloads(); ok { + _spec.SetField(version.FieldDownloads, field.TypeUint, value) + } + if value, ok := vu.mutation.AddedDownloads(); ok { + _spec.AddField(version.FieldDownloads, field.TypeUint, value) + } + if value, ok := vu.mutation.Key(); ok { + _spec.SetField(version.FieldKey, field.TypeString, value) + } + if value, ok := vu.mutation.Stability(); ok { + _spec.SetField(version.FieldStability, field.TypeEnum, value) + } + if value, ok := vu.mutation.Approved(); ok { + _spec.SetField(version.FieldApproved, field.TypeBool, value) + } + if value, ok := vu.mutation.Hotness(); ok { + _spec.SetField(version.FieldHotness, field.TypeUint, value) + } + if value, ok := vu.mutation.AddedHotness(); ok { + _spec.AddField(version.FieldHotness, field.TypeUint, value) + } + if value, ok := vu.mutation.Denied(); ok { + _spec.SetField(version.FieldDenied, field.TypeBool, value) + } + if value, ok := vu.mutation.Metadata(); ok { + _spec.SetField(version.FieldMetadata, field.TypeString, value) + } + if value, ok := vu.mutation.ModReference(); ok { + _spec.SetField(version.FieldModReference, field.TypeString, value) + } + if value, ok := vu.mutation.VersionMajor(); ok { + _spec.SetField(version.FieldVersionMajor, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedVersionMajor(); ok { + _spec.AddField(version.FieldVersionMajor, field.TypeInt, value) + } + if value, ok := vu.mutation.VersionMinor(); ok { + _spec.SetField(version.FieldVersionMinor, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedVersionMinor(); ok { + _spec.AddField(version.FieldVersionMinor, field.TypeInt, value) + } + if value, ok := vu.mutation.VersionPatch(); ok { + _spec.SetField(version.FieldVersionPatch, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedVersionPatch(); ok { + _spec.AddField(version.FieldVersionPatch, field.TypeInt, value) + } + if value, ok := vu.mutation.Size(); ok { + _spec.SetField(version.FieldSize, field.TypeInt64, value) + } + if value, ok := vu.mutation.AddedSize(); ok { + _spec.AddField(version.FieldSize, field.TypeInt64, value) + } + if value, ok := vu.mutation.Hash(); ok { + _spec.SetField(version.FieldHash, field.TypeString, value) + } + if vu.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: version.ModTable, + Columns: []string{version.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: version.ModTable, + Columns: []string{version.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) + } + if vu.mutation.DependenciesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + createE := &VersionDependencyCreate{config: vu.config, mutation: newVersionDependencyMutation(vu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.RemovedDependenciesIDs(); len(nodes) > 0 && !vu.mutation.DependenciesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: vu.config, mutation: newVersionDependencyMutation(vu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.DependenciesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: vu.config, mutation: newVersionDependencyMutation(vu.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(vu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, vu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{version.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + vu.mutation.done = true + return n, nil +} + +// VersionUpdateOne is the builder for updating a single Version entity. +type VersionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *VersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (vuo *VersionUpdateOne) SetUpdatedAt(t time.Time) *VersionUpdateOne { + vuo.mutation.SetUpdatedAt(t) + return vuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (vuo *VersionUpdateOne) SetDeletedAt(t time.Time) *VersionUpdateOne { + vuo.mutation.SetDeletedAt(t) + return vuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableDeletedAt(t *time.Time) *VersionUpdateOne { + if t != nil { + vuo.SetDeletedAt(*t) + } + return vuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (vuo *VersionUpdateOne) ClearDeletedAt() *VersionUpdateOne { + vuo.mutation.ClearDeletedAt() + return vuo +} + +// SetVersion sets the "version" field. +func (vuo *VersionUpdateOne) SetVersion(s string) *VersionUpdateOne { + vuo.mutation.SetVersion(s) + return vuo +} + +// SetSmlVersion sets the "sml_version" field. +func (vuo *VersionUpdateOne) SetSmlVersion(s string) *VersionUpdateOne { + vuo.mutation.SetSmlVersion(s) + return vuo +} + +// SetChangelog sets the "changelog" field. +func (vuo *VersionUpdateOne) SetChangelog(s string) *VersionUpdateOne { + vuo.mutation.SetChangelog(s) + return vuo +} + +// SetDownloads sets the "downloads" field. +func (vuo *VersionUpdateOne) SetDownloads(u uint) *VersionUpdateOne { + vuo.mutation.ResetDownloads() + vuo.mutation.SetDownloads(u) + return vuo +} + +// AddDownloads adds u to the "downloads" field. +func (vuo *VersionUpdateOne) AddDownloads(u int) *VersionUpdateOne { + vuo.mutation.AddDownloads(u) + return vuo +} + +// SetKey sets the "key" field. +func (vuo *VersionUpdateOne) SetKey(s string) *VersionUpdateOne { + vuo.mutation.SetKey(s) + return vuo +} + +// SetStability sets the "stability" field. +func (vuo *VersionUpdateOne) SetStability(v version.Stability) *VersionUpdateOne { + vuo.mutation.SetStability(v) + return vuo +} + +// SetApproved sets the "approved" field. +func (vuo *VersionUpdateOne) SetApproved(b bool) *VersionUpdateOne { + vuo.mutation.SetApproved(b) + return vuo +} + +// SetNillableApproved sets the "approved" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableApproved(b *bool) *VersionUpdateOne { + if b != nil { + vuo.SetApproved(*b) + } + return vuo +} + +// SetHotness sets the "hotness" field. +func (vuo *VersionUpdateOne) SetHotness(u uint) *VersionUpdateOne { + vuo.mutation.ResetHotness() + vuo.mutation.SetHotness(u) + return vuo +} + +// AddHotness adds u to the "hotness" field. +func (vuo *VersionUpdateOne) AddHotness(u int) *VersionUpdateOne { + vuo.mutation.AddHotness(u) + return vuo +} + +// SetDenied sets the "denied" field. +func (vuo *VersionUpdateOne) SetDenied(b bool) *VersionUpdateOne { + vuo.mutation.SetDenied(b) + return vuo +} + +// SetNillableDenied sets the "denied" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableDenied(b *bool) *VersionUpdateOne { + if b != nil { + vuo.SetDenied(*b) + } + return vuo +} + +// SetMetadata sets the "metadata" field. +func (vuo *VersionUpdateOne) SetMetadata(s string) *VersionUpdateOne { + vuo.mutation.SetMetadata(s) + return vuo +} + +// SetModReference sets the "mod_reference" field. +func (vuo *VersionUpdateOne) SetModReference(s string) *VersionUpdateOne { + vuo.mutation.SetModReference(s) + return vuo +} + +// SetVersionMajor sets the "version_major" field. +func (vuo *VersionUpdateOne) SetVersionMajor(i int) *VersionUpdateOne { + vuo.mutation.ResetVersionMajor() + vuo.mutation.SetVersionMajor(i) + return vuo +} + +// AddVersionMajor adds i to the "version_major" field. +func (vuo *VersionUpdateOne) AddVersionMajor(i int) *VersionUpdateOne { + vuo.mutation.AddVersionMajor(i) + return vuo +} + +// SetVersionMinor sets the "version_minor" field. +func (vuo *VersionUpdateOne) SetVersionMinor(i int) *VersionUpdateOne { + vuo.mutation.ResetVersionMinor() + vuo.mutation.SetVersionMinor(i) + return vuo +} + +// AddVersionMinor adds i to the "version_minor" field. +func (vuo *VersionUpdateOne) AddVersionMinor(i int) *VersionUpdateOne { + vuo.mutation.AddVersionMinor(i) + return vuo +} + +// SetVersionPatch sets the "version_patch" field. +func (vuo *VersionUpdateOne) SetVersionPatch(i int) *VersionUpdateOne { + vuo.mutation.ResetVersionPatch() + vuo.mutation.SetVersionPatch(i) + return vuo +} + +// AddVersionPatch adds i to the "version_patch" field. +func (vuo *VersionUpdateOne) AddVersionPatch(i int) *VersionUpdateOne { + vuo.mutation.AddVersionPatch(i) + return vuo +} + +// SetSize sets the "size" field. +func (vuo *VersionUpdateOne) SetSize(i int64) *VersionUpdateOne { + vuo.mutation.ResetSize() + vuo.mutation.SetSize(i) + return vuo +} + +// AddSize adds i to the "size" field. +func (vuo *VersionUpdateOne) AddSize(i int64) *VersionUpdateOne { + vuo.mutation.AddSize(i) + return vuo +} + +// SetHash sets the "hash" field. +func (vuo *VersionUpdateOne) SetHash(s string) *VersionUpdateOne { + vuo.mutation.SetHash(s) + return vuo +} + +// SetModID sets the "mod" edge to the Mod entity by ID. +func (vuo *VersionUpdateOne) SetModID(id string) *VersionUpdateOne { + vuo.mutation.SetModID(id) + return vuo +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vuo *VersionUpdateOne) SetMod(m *Mod) *VersionUpdateOne { + return vuo.SetModID(m.ID) +} + +// AddDependencyIDs adds the "dependencies" edge to the Mod entity by IDs. +func (vuo *VersionUpdateOne) AddDependencyIDs(ids ...string) *VersionUpdateOne { + vuo.mutation.AddDependencyIDs(ids...) + return vuo +} + +// AddDependencies adds the "dependencies" edges to the Mod entity. +func (vuo *VersionUpdateOne) AddDependencies(m ...*Mod) *VersionUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return vuo.AddDependencyIDs(ids...) +} + +// Mutation returns the VersionMutation object of the builder. +func (vuo *VersionUpdateOne) Mutation() *VersionMutation { + return vuo.mutation +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (vuo *VersionUpdateOne) ClearMod() *VersionUpdateOne { + vuo.mutation.ClearMod() + return vuo +} + +// ClearDependencies clears all "dependencies" edges to the Mod entity. +func (vuo *VersionUpdateOne) ClearDependencies() *VersionUpdateOne { + vuo.mutation.ClearDependencies() + return vuo +} + +// RemoveDependencyIDs removes the "dependencies" edge to Mod entities by IDs. +func (vuo *VersionUpdateOne) RemoveDependencyIDs(ids ...string) *VersionUpdateOne { + vuo.mutation.RemoveDependencyIDs(ids...) + return vuo +} + +// RemoveDependencies removes "dependencies" edges to Mod entities. +func (vuo *VersionUpdateOne) RemoveDependencies(m ...*Mod) *VersionUpdateOne { + ids := make([]string, len(m)) + for i := range m { + ids[i] = m[i].ID + } + return vuo.RemoveDependencyIDs(ids...) +} + +// Where appends a list predicates to the VersionUpdate builder. +func (vuo *VersionUpdateOne) Where(ps ...predicate.Version) *VersionUpdateOne { + vuo.mutation.Where(ps...) + return vuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (vuo *VersionUpdateOne) Select(field string, fields ...string) *VersionUpdateOne { + vuo.fields = append([]string{field}, fields...) + return vuo +} + +// Save executes the query and returns the updated Version entity. +func (vuo *VersionUpdateOne) Save(ctx context.Context) (*Version, error) { + if err := vuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, vuo.sqlSave, vuo.mutation, vuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vuo *VersionUpdateOne) SaveX(ctx context.Context) *Version { + node, err := vuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (vuo *VersionUpdateOne) Exec(ctx context.Context) error { + _, err := vuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vuo *VersionUpdateOne) ExecX(ctx context.Context) { + if err := vuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vuo *VersionUpdateOne) defaults() error { + if _, ok := vuo.mutation.UpdatedAt(); !ok { + if version.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized version.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := version.UpdateDefaultUpdatedAt() + vuo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vuo *VersionUpdateOne) check() error { + if v, ok := vuo.mutation.Version(); ok { + if err := version.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`ent: validator failed for field "Version.version": %w`, err)} + } + } + if v, ok := vuo.mutation.SmlVersion(); ok { + if err := version.SmlVersionValidator(v); err != nil { + return &ValidationError{Name: "sml_version", err: fmt.Errorf(`ent: validator failed for field "Version.sml_version": %w`, err)} + } + } + if v, ok := vuo.mutation.Stability(); ok { + if err := version.StabilityValidator(v); err != nil { + return &ValidationError{Name: "stability", err: fmt.Errorf(`ent: validator failed for field "Version.stability": %w`, err)} + } + } + if v, ok := vuo.mutation.ModReference(); ok { + if err := version.ModReferenceValidator(v); err != nil { + return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Version.mod_reference": %w`, err)} + } + } + if v, ok := vuo.mutation.Hash(); ok { + if err := version.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Version.hash": %w`, err)} + } + } + if _, ok := vuo.mutation.ModID(); vuo.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "Version.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vuo *VersionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionUpdateOne { + vuo.modifiers = append(vuo.modifiers, modifiers...) + return vuo +} + +func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err error) { + if err := vuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(version.Table, version.Columns, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) + id, ok := vuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Version.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := vuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, version.FieldID) + for _, f := range fields { + if !version.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != version.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := vuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vuo.mutation.UpdatedAt(); ok { + _spec.SetField(version.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := vuo.mutation.DeletedAt(); ok { + _spec.SetField(version.FieldDeletedAt, field.TypeTime, value) + } + if vuo.mutation.DeletedAtCleared() { + _spec.ClearField(version.FieldDeletedAt, field.TypeTime) + } + if value, ok := vuo.mutation.Version(); ok { + _spec.SetField(version.FieldVersion, field.TypeString, value) + } + if value, ok := vuo.mutation.SmlVersion(); ok { + _spec.SetField(version.FieldSmlVersion, field.TypeString, value) + } + if value, ok := vuo.mutation.Changelog(); ok { + _spec.SetField(version.FieldChangelog, field.TypeString, value) + } + if value, ok := vuo.mutation.Downloads(); ok { + _spec.SetField(version.FieldDownloads, field.TypeUint, value) + } + if value, ok := vuo.mutation.AddedDownloads(); ok { + _spec.AddField(version.FieldDownloads, field.TypeUint, value) + } + if value, ok := vuo.mutation.Key(); ok { + _spec.SetField(version.FieldKey, field.TypeString, value) + } + if value, ok := vuo.mutation.Stability(); ok { + _spec.SetField(version.FieldStability, field.TypeEnum, value) + } + if value, ok := vuo.mutation.Approved(); ok { + _spec.SetField(version.FieldApproved, field.TypeBool, value) + } + if value, ok := vuo.mutation.Hotness(); ok { + _spec.SetField(version.FieldHotness, field.TypeUint, value) + } + if value, ok := vuo.mutation.AddedHotness(); ok { + _spec.AddField(version.FieldHotness, field.TypeUint, value) + } + if value, ok := vuo.mutation.Denied(); ok { + _spec.SetField(version.FieldDenied, field.TypeBool, value) + } + if value, ok := vuo.mutation.Metadata(); ok { + _spec.SetField(version.FieldMetadata, field.TypeString, value) + } + if value, ok := vuo.mutation.ModReference(); ok { + _spec.SetField(version.FieldModReference, field.TypeString, value) + } + if value, ok := vuo.mutation.VersionMajor(); ok { + _spec.SetField(version.FieldVersionMajor, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedVersionMajor(); ok { + _spec.AddField(version.FieldVersionMajor, field.TypeInt, value) + } + if value, ok := vuo.mutation.VersionMinor(); ok { + _spec.SetField(version.FieldVersionMinor, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedVersionMinor(); ok { + _spec.AddField(version.FieldVersionMinor, field.TypeInt, value) + } + if value, ok := vuo.mutation.VersionPatch(); ok { + _spec.SetField(version.FieldVersionPatch, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedVersionPatch(); ok { + _spec.AddField(version.FieldVersionPatch, field.TypeInt, value) + } + if value, ok := vuo.mutation.Size(); ok { + _spec.SetField(version.FieldSize, field.TypeInt64, value) + } + if value, ok := vuo.mutation.AddedSize(); ok { + _spec.AddField(version.FieldSize, field.TypeInt64, value) + } + if value, ok := vuo.mutation.Hash(); ok { + _spec.SetField(version.FieldHash, field.TypeString, value) + } + if vuo.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: version.ModTable, + Columns: []string{version.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: version.ModTable, + Columns: []string{version.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) + } + if vuo.mutation.DependenciesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + createE := &VersionDependencyCreate{config: vuo.config, mutation: newVersionDependencyMutation(vuo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.RemovedDependenciesIDs(); len(nodes) > 0 && !vuo.mutation.DependenciesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: vuo.config, mutation: newVersionDependencyMutation(vuo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.DependenciesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: version.DependenciesTable, + Columns: version.DependenciesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + createE := &VersionDependencyCreate{config: vuo.config, mutation: newVersionDependencyMutation(vuo.config, OpCreate)} + _ = createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(vuo.modifiers...) + _node = &Version{config: vuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, vuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{version.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + vuo.mutation.done = true + return _node, nil +} diff --git a/generated/ent/versiondependency.go b/generated/ent/versiondependency.go new file mode 100644 index 00000000..589b6cc0 --- /dev/null +++ b/generated/ent/versiondependency.go @@ -0,0 +1,215 @@ +// 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/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionDependency is the model entity for the VersionDependency schema. +type VersionDependency struct { + config `json:"-"` + // 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"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt time.Time `json:"deleted_at,omitempty"` + // VersionID holds the value of the "version_id" field. + VersionID string `json:"version_id,omitempty"` + // ModID holds the value of the "mod_id" field. + ModID string `json:"mod_id,omitempty"` + // Condition holds the value of the "condition" field. + Condition string `json:"condition,omitempty"` + // Optional holds the value of the "optional" field. + Optional bool `json:"optional,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the VersionDependencyQuery when eager-loading is set. + Edges VersionDependencyEdges `json:"edges"` + selectValues sql.SelectValues +} + +// VersionDependencyEdges holds the relations/edges for other nodes in the graph. +type VersionDependencyEdges struct { + // Version holds the value of the version edge. + Version *Version `json:"version,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 +} + +// VersionOrErr returns the Version value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e VersionDependencyEdges) VersionOrErr() (*Version, error) { + if e.loadedTypes[0] { + if e.Version == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: version.Label} + } + return e.Version, nil + } + return nil, &NotLoadedError{edge: "version"} +} + +// 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 VersionDependencyEdges) ModOrErr() (*Mod, error) { + if e.loadedTypes[1] { + if e.Mod == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: mod.Label} + } + return e.Mod, nil + } + return nil, &NotLoadedError{edge: "mod"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*VersionDependency) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case versiondependency.FieldOptional: + values[i] = new(sql.NullBool) + case versiondependency.FieldVersionID, versiondependency.FieldModID, versiondependency.FieldCondition: + values[i] = new(sql.NullString) + case versiondependency.FieldCreatedAt, versiondependency.FieldUpdatedAt, versiondependency.FieldDeletedAt: + 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 VersionDependency fields. +func (vd *VersionDependency) 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 versiondependency.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 { + vd.CreatedAt = value.Time + } + case versiondependency.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 { + vd.UpdatedAt = value.Time + } + case versiondependency.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + vd.DeletedAt = value.Time + } + case versiondependency.FieldVersionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version_id", values[i]) + } else if value.Valid { + vd.VersionID = value.String + } + case versiondependency.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 { + vd.ModID = value.String + } + case versiondependency.FieldCondition: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field condition", values[i]) + } else if value.Valid { + vd.Condition = value.String + } + case versiondependency.FieldOptional: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field optional", values[i]) + } else if value.Valid { + vd.Optional = value.Bool + } + default: + vd.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the VersionDependency. +// This includes values selected through modifiers, order, etc. +func (vd *VersionDependency) Value(name string) (ent.Value, error) { + return vd.selectValues.Get(name) +} + +// QueryVersion queries the "version" edge of the VersionDependency entity. +func (vd *VersionDependency) QueryVersion() *VersionQuery { + return NewVersionDependencyClient(vd.config).QueryVersion(vd) +} + +// QueryMod queries the "mod" edge of the VersionDependency entity. +func (vd *VersionDependency) QueryMod() *ModQuery { + return NewVersionDependencyClient(vd.config).QueryMod(vd) +} + +// Update returns a builder for updating this VersionDependency. +// Note that you need to call VersionDependency.Unwrap() before calling this method if this VersionDependency +// was returned from a transaction, and the transaction was committed or rolled back. +func (vd *VersionDependency) Update() *VersionDependencyUpdateOne { + return NewVersionDependencyClient(vd.config).UpdateOne(vd) +} + +// Unwrap unwraps the VersionDependency 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 (vd *VersionDependency) Unwrap() *VersionDependency { + _tx, ok := vd.config.driver.(*txDriver) + if !ok { + panic("ent: VersionDependency is not a transactional entity") + } + vd.config.driver = _tx.drv + return vd +} + +// String implements the fmt.Stringer. +func (vd *VersionDependency) String() string { + var builder strings.Builder + builder.WriteString("VersionDependency(") + builder.WriteString("created_at=") + builder.WriteString(vd.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(vd.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(vd.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("version_id=") + builder.WriteString(vd.VersionID) + builder.WriteString(", ") + builder.WriteString("mod_id=") + builder.WriteString(vd.ModID) + builder.WriteString(", ") + builder.WriteString("condition=") + builder.WriteString(vd.Condition) + builder.WriteString(", ") + builder.WriteString("optional=") + builder.WriteString(fmt.Sprintf("%v", vd.Optional)) + builder.WriteByte(')') + return builder.String() +} + +// VersionDependencies is a parsable slice of VersionDependency. +type VersionDependencies []*VersionDependency diff --git a/generated/ent/versiondependency/versiondependency.go b/generated/ent/versiondependency/versiondependency.go new file mode 100644 index 00000000..cc6da2c9 --- /dev/null +++ b/generated/ent/versiondependency/versiondependency.go @@ -0,0 +1,159 @@ +// Code generated by ent, DO NOT EDIT. + +package versiondependency + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the versiondependency type in the database. + Label = "version_dependency" + // 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" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldVersionID holds the string denoting the version_id field in the database. + FieldVersionID = "version_id" + // FieldModID holds the string denoting the mod_id field in the database. + FieldModID = "mod_id" + // FieldCondition holds the string denoting the condition field in the database. + FieldCondition = "condition" + // FieldOptional holds the string denoting the optional field in the database. + FieldOptional = "optional" + // EdgeVersion holds the string denoting the version edge name in mutations. + EdgeVersion = "version" + // EdgeMod holds the string denoting the mod edge name in mutations. + EdgeMod = "mod" + // VersionFieldID holds the string denoting the ID field of the Version. + VersionFieldID = "id" + // ModFieldID holds the string denoting the ID field of the Mod. + ModFieldID = "id" + // Table holds the table name of the versiondependency in the database. + Table = "version_dependencies" + // VersionTable is the table that holds the version relation/edge. + VersionTable = "version_dependencies" + // VersionInverseTable is the table name for the Version entity. + // It exists in this package in order to avoid circular dependency with the "version" package. + VersionInverseTable = "versions" + // VersionColumn is the table column denoting the version relation/edge. + VersionColumn = "version_id" + // ModTable is the table that holds the mod relation/edge. + ModTable = "version_dependencies" + // 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 versiondependency fields. +var Columns = []string{ + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldVersionID, + FieldModID, + FieldCondition, + FieldOptional, +} + +// 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 +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "github.com/satisfactorymodding/smr-api/generated/ent/runtime" +var ( + Hooks [1]ent.Hook + Interceptors [1]ent.Interceptor + // 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 + // ConditionValidator is a validator for the "condition" field. It is called by the builders before save. + ConditionValidator func(string) error +) + +// OrderOption defines the ordering options for the VersionDependency queries. +type OrderOption func(*sql.Selector) + +// 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() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByVersionID orders the results by the version_id field. +func ByVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionID, opts...).ToFunc() +} + +// ByModID orders the results by the mod_id field. +func ByModID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModID, opts...).ToFunc() +} + +// ByCondition orders the results by the condition field. +func ByCondition(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCondition, opts...).ToFunc() +} + +// ByOptional orders the results by the optional field. +func ByOptional(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOptional, opts...).ToFunc() +} + +// ByVersionField orders the results by version field. +func ByVersionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionStep(), 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 newVersionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, VersionColumn), + sqlgraph.To(VersionInverseTable, VersionFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, VersionTable, VersionColumn), + ) +} +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/versiondependency/where.go b/generated/ent/versiondependency/where.go new file mode 100644 index 00000000..ee037202 --- /dev/null +++ b/generated/ent/versiondependency/where.go @@ -0,0 +1,442 @@ +// Code generated by ent, DO NOT EDIT. + +package versiondependency + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" +) + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(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.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldDeletedAt, v)) +} + +// VersionID applies equality check predicate on the "version_id" field. It's identical to VersionIDEQ. +func VersionID(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldVersionID, v)) +} + +// ModID applies equality check predicate on the "mod_id" field. It's identical to ModIDEQ. +func ModID(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldModID, v)) +} + +// Condition applies equality check predicate on the "condition" field. It's identical to ConditionEQ. +func Condition(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldCondition, v)) +} + +// Optional applies equality check predicate on the "optional" field. It's identical to OptionalEQ. +func Optional(v bool) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldOptional, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotNull(FieldDeletedAt)) +} + +// VersionIDEQ applies the EQ predicate on the "version_id" field. +func VersionIDEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldVersionID, v)) +} + +// VersionIDNEQ applies the NEQ predicate on the "version_id" field. +func VersionIDNEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldVersionID, v)) +} + +// VersionIDIn applies the In predicate on the "version_id" field. +func VersionIDIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldVersionID, vs...)) +} + +// VersionIDNotIn applies the NotIn predicate on the "version_id" field. +func VersionIDNotIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldVersionID, vs...)) +} + +// VersionIDGT applies the GT predicate on the "version_id" field. +func VersionIDGT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldVersionID, v)) +} + +// VersionIDGTE applies the GTE predicate on the "version_id" field. +func VersionIDGTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldVersionID, v)) +} + +// VersionIDLT applies the LT predicate on the "version_id" field. +func VersionIDLT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldVersionID, v)) +} + +// VersionIDLTE applies the LTE predicate on the "version_id" field. +func VersionIDLTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldVersionID, v)) +} + +// VersionIDContains applies the Contains predicate on the "version_id" field. +func VersionIDContains(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContains(FieldVersionID, v)) +} + +// VersionIDHasPrefix applies the HasPrefix predicate on the "version_id" field. +func VersionIDHasPrefix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasPrefix(FieldVersionID, v)) +} + +// VersionIDHasSuffix applies the HasSuffix predicate on the "version_id" field. +func VersionIDHasSuffix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasSuffix(FieldVersionID, v)) +} + +// VersionIDEqualFold applies the EqualFold predicate on the "version_id" field. +func VersionIDEqualFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEqualFold(FieldVersionID, v)) +} + +// VersionIDContainsFold applies the ContainsFold predicate on the "version_id" field. +func VersionIDContainsFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContainsFold(FieldVersionID, v)) +} + +// ModIDEQ applies the EQ predicate on the "mod_id" field. +func ModIDEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldModID, v)) +} + +// ModIDNEQ applies the NEQ predicate on the "mod_id" field. +func ModIDNEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldModID, v)) +} + +// ModIDIn applies the In predicate on the "mod_id" field. +func ModIDIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldModID, vs...)) +} + +// ModIDNotIn applies the NotIn predicate on the "mod_id" field. +func ModIDNotIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldModID, vs...)) +} + +// ModIDGT applies the GT predicate on the "mod_id" field. +func ModIDGT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldModID, v)) +} + +// ModIDGTE applies the GTE predicate on the "mod_id" field. +func ModIDGTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldModID, v)) +} + +// ModIDLT applies the LT predicate on the "mod_id" field. +func ModIDLT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldModID, v)) +} + +// ModIDLTE applies the LTE predicate on the "mod_id" field. +func ModIDLTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldModID, v)) +} + +// ModIDContains applies the Contains predicate on the "mod_id" field. +func ModIDContains(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContains(FieldModID, v)) +} + +// ModIDHasPrefix applies the HasPrefix predicate on the "mod_id" field. +func ModIDHasPrefix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasPrefix(FieldModID, v)) +} + +// ModIDHasSuffix applies the HasSuffix predicate on the "mod_id" field. +func ModIDHasSuffix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasSuffix(FieldModID, v)) +} + +// ModIDEqualFold applies the EqualFold predicate on the "mod_id" field. +func ModIDEqualFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEqualFold(FieldModID, v)) +} + +// ModIDContainsFold applies the ContainsFold predicate on the "mod_id" field. +func ModIDContainsFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContainsFold(FieldModID, v)) +} + +// ConditionEQ applies the EQ predicate on the "condition" field. +func ConditionEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldCondition, v)) +} + +// ConditionNEQ applies the NEQ predicate on the "condition" field. +func ConditionNEQ(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldCondition, v)) +} + +// ConditionIn applies the In predicate on the "condition" field. +func ConditionIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldIn(FieldCondition, vs...)) +} + +// ConditionNotIn applies the NotIn predicate on the "condition" field. +func ConditionNotIn(vs ...string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNotIn(FieldCondition, vs...)) +} + +// ConditionGT applies the GT predicate on the "condition" field. +func ConditionGT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGT(FieldCondition, v)) +} + +// ConditionGTE applies the GTE predicate on the "condition" field. +func ConditionGTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldGTE(FieldCondition, v)) +} + +// ConditionLT applies the LT predicate on the "condition" field. +func ConditionLT(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLT(FieldCondition, v)) +} + +// ConditionLTE applies the LTE predicate on the "condition" field. +func ConditionLTE(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldLTE(FieldCondition, v)) +} + +// ConditionContains applies the Contains predicate on the "condition" field. +func ConditionContains(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContains(FieldCondition, v)) +} + +// ConditionHasPrefix applies the HasPrefix predicate on the "condition" field. +func ConditionHasPrefix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasPrefix(FieldCondition, v)) +} + +// ConditionHasSuffix applies the HasSuffix predicate on the "condition" field. +func ConditionHasSuffix(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldHasSuffix(FieldCondition, v)) +} + +// ConditionEqualFold applies the EqualFold predicate on the "condition" field. +func ConditionEqualFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEqualFold(FieldCondition, v)) +} + +// ConditionContainsFold applies the ContainsFold predicate on the "condition" field. +func ConditionContainsFold(v string) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldContainsFold(FieldCondition, v)) +} + +// OptionalEQ applies the EQ predicate on the "optional" field. +func OptionalEQ(v bool) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldEQ(FieldOptional, v)) +} + +// OptionalNEQ applies the NEQ predicate on the "optional" field. +func OptionalNEQ(v bool) predicate.VersionDependency { + return predicate.VersionDependency(sql.FieldNEQ(FieldOptional, v)) +} + +// HasVersion applies the HasEdge predicate on the "version" edge. +func HasVersion() predicate.VersionDependency { + return predicate.VersionDependency(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, VersionColumn), + sqlgraph.Edge(sqlgraph.M2O, false, VersionTable, VersionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionWith applies the HasEdge predicate on the "version" edge with a given conditions (other predicates). +func HasVersionWith(preds ...predicate.Version) predicate.VersionDependency { + return predicate.VersionDependency(func(s *sql.Selector) { + step := newVersionStep() + 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.VersionDependency { + return predicate.VersionDependency(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.VersionDependency { + return predicate.VersionDependency(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.VersionDependency) predicate.VersionDependency { + return predicate.VersionDependency(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.VersionDependency) predicate.VersionDependency { + return predicate.VersionDependency(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.VersionDependency) predicate.VersionDependency { + return predicate.VersionDependency(sql.NotPredicates(p)) +} diff --git a/generated/ent/versiondependency_create.go b/generated/ent/versiondependency_create.go new file mode 100644 index 00000000..849c7657 --- /dev/null +++ b/generated/ent/versiondependency_create.go @@ -0,0 +1,346 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "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/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionDependencyCreate is the builder for creating a VersionDependency entity. +type VersionDependencyCreate struct { + config + mutation *VersionDependencyMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (vdc *VersionDependencyCreate) SetCreatedAt(t time.Time) *VersionDependencyCreate { + vdc.mutation.SetCreatedAt(t) + return vdc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (vdc *VersionDependencyCreate) SetNillableCreatedAt(t *time.Time) *VersionDependencyCreate { + if t != nil { + vdc.SetCreatedAt(*t) + } + return vdc +} + +// SetUpdatedAt sets the "updated_at" field. +func (vdc *VersionDependencyCreate) SetUpdatedAt(t time.Time) *VersionDependencyCreate { + vdc.mutation.SetUpdatedAt(t) + return vdc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (vdc *VersionDependencyCreate) SetNillableUpdatedAt(t *time.Time) *VersionDependencyCreate { + if t != nil { + vdc.SetUpdatedAt(*t) + } + return vdc +} + +// SetDeletedAt sets the "deleted_at" field. +func (vdc *VersionDependencyCreate) SetDeletedAt(t time.Time) *VersionDependencyCreate { + vdc.mutation.SetDeletedAt(t) + return vdc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vdc *VersionDependencyCreate) SetNillableDeletedAt(t *time.Time) *VersionDependencyCreate { + if t != nil { + vdc.SetDeletedAt(*t) + } + return vdc +} + +// SetVersionID sets the "version_id" field. +func (vdc *VersionDependencyCreate) SetVersionID(s string) *VersionDependencyCreate { + vdc.mutation.SetVersionID(s) + return vdc +} + +// SetModID sets the "mod_id" field. +func (vdc *VersionDependencyCreate) SetModID(s string) *VersionDependencyCreate { + vdc.mutation.SetModID(s) + return vdc +} + +// SetCondition sets the "condition" field. +func (vdc *VersionDependencyCreate) SetCondition(s string) *VersionDependencyCreate { + vdc.mutation.SetCondition(s) + return vdc +} + +// SetOptional sets the "optional" field. +func (vdc *VersionDependencyCreate) SetOptional(b bool) *VersionDependencyCreate { + vdc.mutation.SetOptional(b) + return vdc +} + +// SetVersion sets the "version" edge to the Version entity. +func (vdc *VersionDependencyCreate) SetVersion(v *Version) *VersionDependencyCreate { + return vdc.SetVersionID(v.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vdc *VersionDependencyCreate) SetMod(m *Mod) *VersionDependencyCreate { + return vdc.SetModID(m.ID) +} + +// Mutation returns the VersionDependencyMutation object of the builder. +func (vdc *VersionDependencyCreate) Mutation() *VersionDependencyMutation { + return vdc.mutation +} + +// Save creates the VersionDependency in the database. +func (vdc *VersionDependencyCreate) Save(ctx context.Context) (*VersionDependency, error) { + if err := vdc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, vdc.sqlSave, vdc.mutation, vdc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (vdc *VersionDependencyCreate) SaveX(ctx context.Context) *VersionDependency { + v, err := vdc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vdc *VersionDependencyCreate) Exec(ctx context.Context) error { + _, err := vdc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdc *VersionDependencyCreate) ExecX(ctx context.Context) { + if err := vdc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vdc *VersionDependencyCreate) defaults() error { + if _, ok := vdc.mutation.CreatedAt(); !ok { + if versiondependency.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized versiondependency.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := versiondependency.DefaultCreatedAt() + vdc.mutation.SetCreatedAt(v) + } + if _, ok := vdc.mutation.UpdatedAt(); !ok { + if versiondependency.DefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized versiondependency.DefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := versiondependency.DefaultUpdatedAt() + vdc.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vdc *VersionDependencyCreate) check() error { + if _, ok := vdc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "VersionDependency.created_at"`)} + } + if _, ok := vdc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "VersionDependency.updated_at"`)} + } + if _, ok := vdc.mutation.VersionID(); !ok { + return &ValidationError{Name: "version_id", err: errors.New(`ent: missing required field "VersionDependency.version_id"`)} + } + if _, ok := vdc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod_id", err: errors.New(`ent: missing required field "VersionDependency.mod_id"`)} + } + if _, ok := vdc.mutation.Condition(); !ok { + return &ValidationError{Name: "condition", err: errors.New(`ent: missing required field "VersionDependency.condition"`)} + } + if v, ok := vdc.mutation.Condition(); ok { + if err := versiondependency.ConditionValidator(v); err != nil { + return &ValidationError{Name: "condition", err: fmt.Errorf(`ent: validator failed for field "VersionDependency.condition": %w`, err)} + } + } + if _, ok := vdc.mutation.Optional(); !ok { + return &ValidationError{Name: "optional", err: errors.New(`ent: missing required field "VersionDependency.optional"`)} + } + if _, ok := vdc.mutation.VersionID(); !ok { + return &ValidationError{Name: "version", err: errors.New(`ent: missing required edge "VersionDependency.version"`)} + } + if _, ok := vdc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod", err: errors.New(`ent: missing required edge "VersionDependency.mod"`)} + } + return nil +} + +func (vdc *VersionDependencyCreate) sqlSave(ctx context.Context) (*VersionDependency, error) { + if err := vdc.check(); err != nil { + return nil, err + } + _node, _spec := vdc.createSpec() + if err := sqlgraph.CreateNode(ctx, vdc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} + +func (vdc *VersionDependencyCreate) createSpec() (*VersionDependency, *sqlgraph.CreateSpec) { + var ( + _node = &VersionDependency{config: vdc.config} + _spec = sqlgraph.NewCreateSpec(versiondependency.Table, nil) + ) + if value, ok := vdc.mutation.CreatedAt(); ok { + _spec.SetField(versiondependency.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := vdc.mutation.UpdatedAt(); ok { + _spec.SetField(versiondependency.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := vdc.mutation.DeletedAt(); ok { + _spec.SetField(versiondependency.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := vdc.mutation.Condition(); ok { + _spec.SetField(versiondependency.FieldCondition, field.TypeString, value) + _node.Condition = value + } + if value, ok := vdc.mutation.Optional(); ok { + _spec.SetField(versiondependency.FieldOptional, field.TypeBool, value) + _node.Optional = value + } + if nodes := vdc.mutation.VersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.VersionTable, + Columns: []string{versiondependency.VersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.VersionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := vdc.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.ModTable, + Columns: []string{versiondependency.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 +} + +// VersionDependencyCreateBulk is the builder for creating many VersionDependency entities in bulk. +type VersionDependencyCreateBulk struct { + config + err error + builders []*VersionDependencyCreate +} + +// Save creates the VersionDependency entities in the database. +func (vdcb *VersionDependencyCreateBulk) Save(ctx context.Context) ([]*VersionDependency, error) { + if vdcb.err != nil { + return nil, vdcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(vdcb.builders)) + nodes := make([]*VersionDependency, len(vdcb.builders)) + mutators := make([]Mutator, len(vdcb.builders)) + for i := range vdcb.builders { + func(i int, root context.Context) { + builder := vdcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*VersionDependencyMutation) + 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, vdcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, vdcb.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, vdcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (vdcb *VersionDependencyCreateBulk) SaveX(ctx context.Context) []*VersionDependency { + v, err := vdcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vdcb *VersionDependencyCreateBulk) Exec(ctx context.Context) error { + _, err := vdcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdcb *VersionDependencyCreateBulk) ExecX(ctx context.Context) { + if err := vdcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/versiondependency_delete.go b/generated/ent/versiondependency_delete.go new file mode 100644 index 00000000..90addcf8 --- /dev/null +++ b/generated/ent/versiondependency_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionDependencyDelete is the builder for deleting a VersionDependency entity. +type VersionDependencyDelete struct { + config + hooks []Hook + mutation *VersionDependencyMutation +} + +// Where appends a list predicates to the VersionDependencyDelete builder. +func (vdd *VersionDependencyDelete) Where(ps ...predicate.VersionDependency) *VersionDependencyDelete { + vdd.mutation.Where(ps...) + return vdd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (vdd *VersionDependencyDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, vdd.sqlExec, vdd.mutation, vdd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdd *VersionDependencyDelete) ExecX(ctx context.Context) int { + n, err := vdd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (vdd *VersionDependencyDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(versiondependency.Table, nil) + if ps := vdd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, vdd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + vdd.mutation.done = true + return affected, err +} + +// VersionDependencyDeleteOne is the builder for deleting a single VersionDependency entity. +type VersionDependencyDeleteOne struct { + vdd *VersionDependencyDelete +} + +// Where appends a list predicates to the VersionDependencyDelete builder. +func (vddo *VersionDependencyDeleteOne) Where(ps ...predicate.VersionDependency) *VersionDependencyDeleteOne { + vddo.vdd.mutation.Where(ps...) + return vddo +} + +// Exec executes the deletion query. +func (vddo *VersionDependencyDeleteOne) Exec(ctx context.Context) error { + n, err := vddo.vdd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{versiondependency.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (vddo *VersionDependencyDeleteOne) ExecX(ctx context.Context) { + if err := vddo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/versiondependency_query.go b/generated/ent/versiondependency_query.go new file mode 100644 index 00000000..9b69363d --- /dev/null +++ b/generated/ent/versiondependency_query.go @@ -0,0 +1,624 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionDependencyQuery is the builder for querying VersionDependency entities. +type VersionDependencyQuery struct { + config + ctx *QueryContext + order []versiondependency.OrderOption + inters []Interceptor + predicates []predicate.VersionDependency + withVersion *VersionQuery + 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 VersionDependencyQuery builder. +func (vdq *VersionDependencyQuery) Where(ps ...predicate.VersionDependency) *VersionDependencyQuery { + vdq.predicates = append(vdq.predicates, ps...) + return vdq +} + +// Limit the number of records to be returned by this query. +func (vdq *VersionDependencyQuery) Limit(limit int) *VersionDependencyQuery { + vdq.ctx.Limit = &limit + return vdq +} + +// Offset to start from. +func (vdq *VersionDependencyQuery) Offset(offset int) *VersionDependencyQuery { + vdq.ctx.Offset = &offset + return vdq +} + +// 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 (vdq *VersionDependencyQuery) Unique(unique bool) *VersionDependencyQuery { + vdq.ctx.Unique = &unique + return vdq +} + +// Order specifies how the records should be ordered. +func (vdq *VersionDependencyQuery) Order(o ...versiondependency.OrderOption) *VersionDependencyQuery { + vdq.order = append(vdq.order, o...) + return vdq +} + +// QueryVersion chains the current query on the "version" edge. +func (vdq *VersionDependencyQuery) QueryVersion() *VersionQuery { + query := (&VersionClient{config: vdq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vdq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vdq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(versiondependency.Table, versiondependency.VersionColumn, selector), + sqlgraph.To(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, versiondependency.VersionTable, versiondependency.VersionColumn), + ) + fromU = sqlgraph.SetNeighbors(vdq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMod chains the current query on the "mod" edge. +func (vdq *VersionDependencyQuery) QueryMod() *ModQuery { + query := (&ModClient{config: vdq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vdq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vdq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(versiondependency.Table, versiondependency.ModColumn, selector), + sqlgraph.To(mod.Table, mod.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, versiondependency.ModTable, versiondependency.ModColumn), + ) + fromU = sqlgraph.SetNeighbors(vdq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first VersionDependency entity from the query. +// Returns a *NotFoundError when no VersionDependency was found. +func (vdq *VersionDependencyQuery) First(ctx context.Context) (*VersionDependency, error) { + nodes, err := vdq.Limit(1).All(setContextOp(ctx, vdq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{versiondependency.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (vdq *VersionDependencyQuery) FirstX(ctx context.Context) *VersionDependency { + node, err := vdq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// Only returns a single VersionDependency entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one VersionDependency entity is found. +// Returns a *NotFoundError when no VersionDependency entities are found. +func (vdq *VersionDependencyQuery) Only(ctx context.Context) (*VersionDependency, error) { + nodes, err := vdq.Limit(2).All(setContextOp(ctx, vdq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{versiondependency.Label} + default: + return nil, &NotSingularError{versiondependency.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (vdq *VersionDependencyQuery) OnlyX(ctx context.Context) *VersionDependency { + node, err := vdq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// All executes the query and returns a list of VersionDependencies. +func (vdq *VersionDependencyQuery) All(ctx context.Context) ([]*VersionDependency, error) { + ctx = setContextOp(ctx, vdq.ctx, "All") + if err := vdq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*VersionDependency, *VersionDependencyQuery]() + return withInterceptors[[]*VersionDependency](ctx, vdq, qr, vdq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (vdq *VersionDependencyQuery) AllX(ctx context.Context) []*VersionDependency { + nodes, err := vdq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// Count returns the count of the given query. +func (vdq *VersionDependencyQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, vdq.ctx, "Count") + if err := vdq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, vdq, querierCount[*VersionDependencyQuery](), vdq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (vdq *VersionDependencyQuery) CountX(ctx context.Context) int { + count, err := vdq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (vdq *VersionDependencyQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, vdq.ctx, "Exist") + switch _, err := vdq.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 (vdq *VersionDependencyQuery) ExistX(ctx context.Context) bool { + exist, err := vdq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the VersionDependencyQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (vdq *VersionDependencyQuery) Clone() *VersionDependencyQuery { + if vdq == nil { + return nil + } + return &VersionDependencyQuery{ + config: vdq.config, + ctx: vdq.ctx.Clone(), + order: append([]versiondependency.OrderOption{}, vdq.order...), + inters: append([]Interceptor{}, vdq.inters...), + predicates: append([]predicate.VersionDependency{}, vdq.predicates...), + withVersion: vdq.withVersion.Clone(), + withMod: vdq.withMod.Clone(), + // clone intermediate query. + sql: vdq.sql.Clone(), + path: vdq.path, + } +} + +// WithVersion tells the query-builder to eager-load the nodes that are connected to +// the "version" edge. The optional arguments are used to configure the query builder of the edge. +func (vdq *VersionDependencyQuery) WithVersion(opts ...func(*VersionQuery)) *VersionDependencyQuery { + query := (&VersionClient{config: vdq.config}).Query() + for _, opt := range opts { + opt(query) + } + vdq.withVersion = query + return vdq +} + +// 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 (vdq *VersionDependencyQuery) WithMod(opts ...func(*ModQuery)) *VersionDependencyQuery { + query := (&ModClient{config: vdq.config}).Query() + for _, opt := range opts { + opt(query) + } + vdq.withMod = query + return vdq +} + +// 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.VersionDependency.Query(). +// GroupBy(versiondependency.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (vdq *VersionDependencyQuery) GroupBy(field string, fields ...string) *VersionDependencyGroupBy { + vdq.ctx.Fields = append([]string{field}, fields...) + grbuild := &VersionDependencyGroupBy{build: vdq} + grbuild.flds = &vdq.ctx.Fields + grbuild.label = versiondependency.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.VersionDependency.Query(). +// Select(versiondependency.FieldCreatedAt). +// Scan(ctx, &v) +func (vdq *VersionDependencyQuery) Select(fields ...string) *VersionDependencySelect { + vdq.ctx.Fields = append(vdq.ctx.Fields, fields...) + sbuild := &VersionDependencySelect{VersionDependencyQuery: vdq} + sbuild.label = versiondependency.Label + sbuild.flds, sbuild.scan = &vdq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a VersionDependencySelect configured with the given aggregations. +func (vdq *VersionDependencyQuery) Aggregate(fns ...AggregateFunc) *VersionDependencySelect { + return vdq.Select().Aggregate(fns...) +} + +func (vdq *VersionDependencyQuery) prepareQuery(ctx context.Context) error { + for _, inter := range vdq.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, vdq); err != nil { + return err + } + } + } + for _, f := range vdq.ctx.Fields { + if !versiondependency.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if vdq.path != nil { + prev, err := vdq.path(ctx) + if err != nil { + return err + } + vdq.sql = prev + } + return nil +} + +func (vdq *VersionDependencyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*VersionDependency, error) { + var ( + nodes = []*VersionDependency{} + _spec = vdq.querySpec() + loadedTypes = [2]bool{ + vdq.withVersion != nil, + vdq.withMod != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*VersionDependency).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &VersionDependency{config: vdq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(vdq.modifiers) > 0 { + _spec.Modifiers = vdq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, vdq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := vdq.withVersion; query != nil { + if err := vdq.loadVersion(ctx, query, nodes, nil, + func(n *VersionDependency, e *Version) { n.Edges.Version = e }); err != nil { + return nil, err + } + } + if query := vdq.withMod; query != nil { + if err := vdq.loadMod(ctx, query, nodes, nil, + func(n *VersionDependency, e *Mod) { n.Edges.Mod = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (vdq *VersionDependencyQuery) loadVersion(ctx context.Context, query *VersionQuery, nodes []*VersionDependency, init func(*VersionDependency), assign func(*VersionDependency, *Version)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*VersionDependency) + for i := range nodes { + fk := nodes[i].VersionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(version.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 "version_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (vdq *VersionDependencyQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*VersionDependency, init func(*VersionDependency), assign func(*VersionDependency, *Mod)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*VersionDependency) + 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 (vdq *VersionDependencyQuery) sqlCount(ctx context.Context) (int, error) { + _spec := vdq.querySpec() + if len(vdq.modifiers) > 0 { + _spec.Modifiers = vdq.modifiers + } + _spec.Unique = false + _spec.Node.Columns = nil + return sqlgraph.CountNodes(ctx, vdq.driver, _spec) +} + +func (vdq *VersionDependencyQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(versiondependency.Table, versiondependency.Columns, nil) + _spec.From = vdq.sql + if unique := vdq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if vdq.path != nil { + _spec.Unique = true + } + if fields := vdq.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 vdq.withVersion != nil { + _spec.Node.AddColumnOnce(versiondependency.FieldVersionID) + } + if vdq.withMod != nil { + _spec.Node.AddColumnOnce(versiondependency.FieldModID) + } + } + if ps := vdq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := vdq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := vdq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := vdq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (vdq *VersionDependencyQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(vdq.driver.Dialect()) + t1 := builder.Table(versiondependency.Table) + columns := vdq.ctx.Fields + if len(columns) == 0 { + columns = versiondependency.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if vdq.sql != nil { + selector = vdq.sql + selector.Select(selector.Columns(columns...)...) + } + if vdq.ctx.Unique != nil && *vdq.ctx.Unique { + selector.Distinct() + } + for _, m := range vdq.modifiers { + m(selector) + } + for _, p := range vdq.predicates { + p(selector) + } + for _, p := range vdq.order { + p(selector) + } + if offset := vdq.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 := vdq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (vdq *VersionDependencyQuery) Modify(modifiers ...func(s *sql.Selector)) *VersionDependencySelect { + vdq.modifiers = append(vdq.modifiers, modifiers...) + return vdq.Select() +} + +// VersionDependencyGroupBy is the group-by builder for VersionDependency entities. +type VersionDependencyGroupBy struct { + selector + build *VersionDependencyQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (vdgb *VersionDependencyGroupBy) Aggregate(fns ...AggregateFunc) *VersionDependencyGroupBy { + vdgb.fns = append(vdgb.fns, fns...) + return vdgb +} + +// Scan applies the selector query and scans the result into the given value. +func (vdgb *VersionDependencyGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vdgb.build.ctx, "GroupBy") + if err := vdgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionDependencyQuery, *VersionDependencyGroupBy](ctx, vdgb.build, vdgb, vdgb.build.inters, v) +} + +func (vdgb *VersionDependencyGroupBy) sqlScan(ctx context.Context, root *VersionDependencyQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(vdgb.fns)) + for _, fn := range vdgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*vdgb.flds)+len(vdgb.fns)) + for _, f := range *vdgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*vdgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := vdgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// VersionDependencySelect is the builder for selecting fields of VersionDependency entities. +type VersionDependencySelect struct { + *VersionDependencyQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (vds *VersionDependencySelect) Aggregate(fns ...AggregateFunc) *VersionDependencySelect { + vds.fns = append(vds.fns, fns...) + return vds +} + +// Scan applies the selector query and scans the result into the given value. +func (vds *VersionDependencySelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vds.ctx, "Select") + if err := vds.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionDependencyQuery, *VersionDependencySelect](ctx, vds.VersionDependencyQuery, vds, vds.inters, v) +} + +func (vds *VersionDependencySelect) sqlScan(ctx context.Context, root *VersionDependencyQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(vds.fns)) + for _, fn := range vds.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*vds.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 := vds.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 (vds *VersionDependencySelect) Modify(modifiers ...func(s *sql.Selector)) *VersionDependencySelect { + vds.modifiers = append(vds.modifiers, modifiers...) + return vds +} diff --git a/generated/ent/versiondependency_update.go b/generated/ent/versiondependency_update.go new file mode 100644 index 00000000..80e77220 --- /dev/null +++ b/generated/ent/versiondependency_update.go @@ -0,0 +1,554 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" +) + +// VersionDependencyUpdate is the builder for updating VersionDependency entities. +type VersionDependencyUpdate struct { + config + hooks []Hook + mutation *VersionDependencyMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the VersionDependencyUpdate builder. +func (vdu *VersionDependencyUpdate) Where(ps ...predicate.VersionDependency) *VersionDependencyUpdate { + vdu.mutation.Where(ps...) + return vdu +} + +// SetUpdatedAt sets the "updated_at" field. +func (vdu *VersionDependencyUpdate) SetUpdatedAt(t time.Time) *VersionDependencyUpdate { + vdu.mutation.SetUpdatedAt(t) + return vdu +} + +// SetDeletedAt sets the "deleted_at" field. +func (vdu *VersionDependencyUpdate) SetDeletedAt(t time.Time) *VersionDependencyUpdate { + vdu.mutation.SetDeletedAt(t) + return vdu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vdu *VersionDependencyUpdate) SetNillableDeletedAt(t *time.Time) *VersionDependencyUpdate { + if t != nil { + vdu.SetDeletedAt(*t) + } + return vdu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (vdu *VersionDependencyUpdate) ClearDeletedAt() *VersionDependencyUpdate { + vdu.mutation.ClearDeletedAt() + return vdu +} + +// SetVersionID sets the "version_id" field. +func (vdu *VersionDependencyUpdate) SetVersionID(s string) *VersionDependencyUpdate { + vdu.mutation.SetVersionID(s) + return vdu +} + +// SetModID sets the "mod_id" field. +func (vdu *VersionDependencyUpdate) SetModID(s string) *VersionDependencyUpdate { + vdu.mutation.SetModID(s) + return vdu +} + +// SetCondition sets the "condition" field. +func (vdu *VersionDependencyUpdate) SetCondition(s string) *VersionDependencyUpdate { + vdu.mutation.SetCondition(s) + return vdu +} + +// SetOptional sets the "optional" field. +func (vdu *VersionDependencyUpdate) SetOptional(b bool) *VersionDependencyUpdate { + vdu.mutation.SetOptional(b) + return vdu +} + +// SetVersion sets the "version" edge to the Version entity. +func (vdu *VersionDependencyUpdate) SetVersion(v *Version) *VersionDependencyUpdate { + return vdu.SetVersionID(v.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vdu *VersionDependencyUpdate) SetMod(m *Mod) *VersionDependencyUpdate { + return vdu.SetModID(m.ID) +} + +// Mutation returns the VersionDependencyMutation object of the builder. +func (vdu *VersionDependencyUpdate) Mutation() *VersionDependencyMutation { + return vdu.mutation +} + +// ClearVersion clears the "version" edge to the Version entity. +func (vdu *VersionDependencyUpdate) ClearVersion() *VersionDependencyUpdate { + vdu.mutation.ClearVersion() + return vdu +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (vdu *VersionDependencyUpdate) ClearMod() *VersionDependencyUpdate { + vdu.mutation.ClearMod() + return vdu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (vdu *VersionDependencyUpdate) Save(ctx context.Context) (int, error) { + if err := vdu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, vdu.sqlSave, vdu.mutation, vdu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vdu *VersionDependencyUpdate) SaveX(ctx context.Context) int { + affected, err := vdu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (vdu *VersionDependencyUpdate) Exec(ctx context.Context) error { + _, err := vdu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdu *VersionDependencyUpdate) ExecX(ctx context.Context) { + if err := vdu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vdu *VersionDependencyUpdate) defaults() error { + if _, ok := vdu.mutation.UpdatedAt(); !ok { + if versiondependency.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized versiondependency.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := versiondependency.UpdateDefaultUpdatedAt() + vdu.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vdu *VersionDependencyUpdate) check() error { + if v, ok := vdu.mutation.Condition(); ok { + if err := versiondependency.ConditionValidator(v); err != nil { + return &ValidationError{Name: "condition", err: fmt.Errorf(`ent: validator failed for field "VersionDependency.condition": %w`, err)} + } + } + if _, ok := vdu.mutation.VersionID(); vdu.mutation.VersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionDependency.version"`) + } + if _, ok := vdu.mutation.ModID(); vdu.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionDependency.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vdu *VersionDependencyUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionDependencyUpdate { + vdu.modifiers = append(vdu.modifiers, modifiers...) + return vdu +} + +func (vdu *VersionDependencyUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := vdu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(versiondependency.Table, versiondependency.Columns, sqlgraph.NewFieldSpec(versiondependency.FieldVersionID, field.TypeString), sqlgraph.NewFieldSpec(versiondependency.FieldModID, field.TypeString)) + if ps := vdu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vdu.mutation.UpdatedAt(); ok { + _spec.SetField(versiondependency.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := vdu.mutation.DeletedAt(); ok { + _spec.SetField(versiondependency.FieldDeletedAt, field.TypeTime, value) + } + if vdu.mutation.DeletedAtCleared() { + _spec.ClearField(versiondependency.FieldDeletedAt, field.TypeTime) + } + if value, ok := vdu.mutation.Condition(); ok { + _spec.SetField(versiondependency.FieldCondition, field.TypeString, value) + } + if value, ok := vdu.mutation.Optional(); ok { + _spec.SetField(versiondependency.FieldOptional, field.TypeBool, value) + } + if vdu.mutation.VersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.VersionTable, + Columns: []string{versiondependency.VersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vdu.mutation.VersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.VersionTable, + Columns: []string{versiondependency.VersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if vdu.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.ModTable, + Columns: []string{versiondependency.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vdu.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.ModTable, + Columns: []string{versiondependency.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(vdu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, vdu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{versiondependency.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + vdu.mutation.done = true + return n, nil +} + +// VersionDependencyUpdateOne is the builder for updating a single VersionDependency entity. +type VersionDependencyUpdateOne struct { + config + fields []string + hooks []Hook + mutation *VersionDependencyMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdatedAt sets the "updated_at" field. +func (vduo *VersionDependencyUpdateOne) SetUpdatedAt(t time.Time) *VersionDependencyUpdateOne { + vduo.mutation.SetUpdatedAt(t) + return vduo +} + +// SetDeletedAt sets the "deleted_at" field. +func (vduo *VersionDependencyUpdateOne) SetDeletedAt(t time.Time) *VersionDependencyUpdateOne { + vduo.mutation.SetDeletedAt(t) + return vduo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (vduo *VersionDependencyUpdateOne) SetNillableDeletedAt(t *time.Time) *VersionDependencyUpdateOne { + if t != nil { + vduo.SetDeletedAt(*t) + } + return vduo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (vduo *VersionDependencyUpdateOne) ClearDeletedAt() *VersionDependencyUpdateOne { + vduo.mutation.ClearDeletedAt() + return vduo +} + +// SetVersionID sets the "version_id" field. +func (vduo *VersionDependencyUpdateOne) SetVersionID(s string) *VersionDependencyUpdateOne { + vduo.mutation.SetVersionID(s) + return vduo +} + +// SetModID sets the "mod_id" field. +func (vduo *VersionDependencyUpdateOne) SetModID(s string) *VersionDependencyUpdateOne { + vduo.mutation.SetModID(s) + return vduo +} + +// SetCondition sets the "condition" field. +func (vduo *VersionDependencyUpdateOne) SetCondition(s string) *VersionDependencyUpdateOne { + vduo.mutation.SetCondition(s) + return vduo +} + +// SetOptional sets the "optional" field. +func (vduo *VersionDependencyUpdateOne) SetOptional(b bool) *VersionDependencyUpdateOne { + vduo.mutation.SetOptional(b) + return vduo +} + +// SetVersion sets the "version" edge to the Version entity. +func (vduo *VersionDependencyUpdateOne) SetVersion(v *Version) *VersionDependencyUpdateOne { + return vduo.SetVersionID(v.ID) +} + +// SetMod sets the "mod" edge to the Mod entity. +func (vduo *VersionDependencyUpdateOne) SetMod(m *Mod) *VersionDependencyUpdateOne { + return vduo.SetModID(m.ID) +} + +// Mutation returns the VersionDependencyMutation object of the builder. +func (vduo *VersionDependencyUpdateOne) Mutation() *VersionDependencyMutation { + return vduo.mutation +} + +// ClearVersion clears the "version" edge to the Version entity. +func (vduo *VersionDependencyUpdateOne) ClearVersion() *VersionDependencyUpdateOne { + vduo.mutation.ClearVersion() + return vduo +} + +// ClearMod clears the "mod" edge to the Mod entity. +func (vduo *VersionDependencyUpdateOne) ClearMod() *VersionDependencyUpdateOne { + vduo.mutation.ClearMod() + return vduo +} + +// Where appends a list predicates to the VersionDependencyUpdate builder. +func (vduo *VersionDependencyUpdateOne) Where(ps ...predicate.VersionDependency) *VersionDependencyUpdateOne { + vduo.mutation.Where(ps...) + return vduo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (vduo *VersionDependencyUpdateOne) Select(field string, fields ...string) *VersionDependencyUpdateOne { + vduo.fields = append([]string{field}, fields...) + return vduo +} + +// Save executes the query and returns the updated VersionDependency entity. +func (vduo *VersionDependencyUpdateOne) Save(ctx context.Context) (*VersionDependency, error) { + if err := vduo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, vduo.sqlSave, vduo.mutation, vduo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vduo *VersionDependencyUpdateOne) SaveX(ctx context.Context) *VersionDependency { + node, err := vduo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (vduo *VersionDependencyUpdateOne) Exec(ctx context.Context) error { + _, err := vduo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vduo *VersionDependencyUpdateOne) ExecX(ctx context.Context) { + if err := vduo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vduo *VersionDependencyUpdateOne) defaults() error { + if _, ok := vduo.mutation.UpdatedAt(); !ok { + if versiondependency.UpdateDefaultUpdatedAt == nil { + return fmt.Errorf("ent: uninitialized versiondependency.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") + } + v := versiondependency.UpdateDefaultUpdatedAt() + vduo.mutation.SetUpdatedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (vduo *VersionDependencyUpdateOne) check() error { + if v, ok := vduo.mutation.Condition(); ok { + if err := versiondependency.ConditionValidator(v); err != nil { + return &ValidationError{Name: "condition", err: fmt.Errorf(`ent: validator failed for field "VersionDependency.condition": %w`, err)} + } + } + if _, ok := vduo.mutation.VersionID(); vduo.mutation.VersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionDependency.version"`) + } + if _, ok := vduo.mutation.ModID(); vduo.mutation.ModCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionDependency.mod"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vduo *VersionDependencyUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionDependencyUpdateOne { + vduo.modifiers = append(vduo.modifiers, modifiers...) + return vduo +} + +func (vduo *VersionDependencyUpdateOne) sqlSave(ctx context.Context) (_node *VersionDependency, err error) { + if err := vduo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(versiondependency.Table, versiondependency.Columns, sqlgraph.NewFieldSpec(versiondependency.FieldVersionID, field.TypeString), sqlgraph.NewFieldSpec(versiondependency.FieldModID, field.TypeString)) + if id, ok := vduo.mutation.VersionID(); !ok { + return nil, &ValidationError{Name: "version_id", err: errors.New(`ent: missing "VersionDependency.version_id" for update`)} + } else { + _spec.Node.CompositeID[0].Value = id + } + if id, ok := vduo.mutation.ModID(); !ok { + return nil, &ValidationError{Name: "mod_id", err: errors.New(`ent: missing "VersionDependency.mod_id" for update`)} + } else { + _spec.Node.CompositeID[1].Value = id + } + if fields := vduo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, len(fields)) + for i, f := range fields { + if !versiondependency.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + _spec.Node.Columns[i] = f + } + } + if ps := vduo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vduo.mutation.UpdatedAt(); ok { + _spec.SetField(versiondependency.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := vduo.mutation.DeletedAt(); ok { + _spec.SetField(versiondependency.FieldDeletedAt, field.TypeTime, value) + } + if vduo.mutation.DeletedAtCleared() { + _spec.ClearField(versiondependency.FieldDeletedAt, field.TypeTime) + } + if value, ok := vduo.mutation.Condition(); ok { + _spec.SetField(versiondependency.FieldCondition, field.TypeString, value) + } + if value, ok := vduo.mutation.Optional(); ok { + _spec.SetField(versiondependency.FieldOptional, field.TypeBool, value) + } + if vduo.mutation.VersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.VersionTable, + Columns: []string{versiondependency.VersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vduo.mutation.VersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.VersionTable, + Columns: []string{versiondependency.VersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if vduo.mutation.ModCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.ModTable, + Columns: []string{versiondependency.ModColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vduo.mutation.ModIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: versiondependency.ModTable, + Columns: []string{versiondependency.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(vduo.modifiers...) + _node = &VersionDependency{config: vduo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, vduo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{versiondependency.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + vduo.mutation.done = true + return _node, nil +} diff --git a/generated/generated.go b/generated/generated.go new file mode 100644 index 00000000..dd6be213 --- /dev/null +++ b/generated/generated.go @@ -0,0 +1,24841 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + GetGuides() GetGuidesResolver + GetMods() GetModsResolver + GetMyMods() GetMyModsResolver + GetMyVersions() GetMyVersionsResolver + GetSMLVersions() GetSMLVersionsResolver + GetVersions() GetVersionsResolver + Guide() GuideResolver + Mod() ModResolver + Mutation() MutationResolver + Query() QueryResolver + User() UserResolver + UserMod() UserModResolver + Version() VersionResolver + VersionTarget() VersionTargetResolver +} + +type DirectiveRoot struct { + CanApproveMods func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanApproveVersions func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanEditAnnouncements func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanEditBootstrapVersions func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanEditGuide func(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (res interface{}, err error) + CanEditMod func(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (res interface{}, err error) + CanEditModCompatibility func(ctx context.Context, obj interface{}, next graphql.Resolver, field *string) (res interface{}, err error) + CanEditSMLVersions func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanEditUser func(ctx context.Context, obj interface{}, next graphql.Resolver, field string, object bool) (res interface{}, err error) + CanEditUsers func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + CanEditVersion func(ctx context.Context, obj interface{}, next graphql.Resolver, field string) (res interface{}, err error) + CanManageTags func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + IsLoggedIn func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + IsNotLoggedIn func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) +} + +type ComplexityRoot struct { + Announcement struct { + ID func(childComplexity int) int + Importance func(childComplexity int) int + Message func(childComplexity int) int + } + + Compatibility struct { + Note func(childComplexity int) int + State func(childComplexity int) int + } + + CompatibilityInfo struct { + Ea func(childComplexity int) int + Exp func(childComplexity int) int + } + + CreateVersionResponse struct { + AutoApproved func(childComplexity int) int + Version func(childComplexity int) int + } + + GetGuides struct { + Count func(childComplexity int) int + Guides func(childComplexity int) int + } + + GetMods struct { + Count func(childComplexity int) int + Mods func(childComplexity int) int + } + + GetMyMods struct { + Count func(childComplexity int) int + Mods func(childComplexity int) int + } + + GetMyVersions struct { + Count func(childComplexity int) int + Versions func(childComplexity int) int + } + + GetSMLVersions struct { + Count func(childComplexity int) int + SmlVersions func(childComplexity int) int + } + + GetVersions struct { + Count func(childComplexity int) int + Versions func(childComplexity int) int + } + + Group struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + Guide struct { + CreatedAt func(childComplexity int) int + Guide func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + ShortDescription func(childComplexity int) int + Tags func(childComplexity int) int + UpdatedAt func(childComplexity int) int + User func(childComplexity int) int + UserID func(childComplexity int) int + Views func(childComplexity int) int + } + + LatestVersions struct { + Alpha func(childComplexity int) int + Beta func(childComplexity int) int + Release func(childComplexity int) int + } + + Mod struct { + Approved func(childComplexity int) int + Authors func(childComplexity int) int + Compatibility func(childComplexity int) int + CreatedAt func(childComplexity int) int + CreatorID func(childComplexity int) int + Downloads func(childComplexity int) int + FullDescription func(childComplexity int) int + Hidden func(childComplexity int) int + Hotness func(childComplexity int) int + ID func(childComplexity int) int + LastVersionDate func(childComplexity int) int + LatestVersions func(childComplexity int) int + Logo func(childComplexity int) int + ModReference func(childComplexity int) int + Name func(childComplexity int) int + Popularity func(childComplexity int) int + ShortDescription func(childComplexity int) int + SourceURL func(childComplexity int) int + Tags func(childComplexity int) int + UpdatedAt func(childComplexity int) int + Version func(childComplexity int, version string) int + Versions func(childComplexity int, filter map[string]interface{}) int + Views func(childComplexity int) int + } + + ModVersion struct { + ID func(childComplexity int) int + ModReference func(childComplexity int) int + Versions 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 + CreateMultipleTags func(childComplexity int, tagNames []string) int + CreateSMLVersion func(childComplexity int, smlVersion NewSMLVersion) int + CreateTag func(childComplexity int, tagName string) int + CreateVersion func(childComplexity int, modID string) int + DeleteAnnouncement func(childComplexity int, announcementID string) int + DeleteGuide func(childComplexity int, guideID string) int + DeleteMod func(childComplexity int, modID string) int + DeleteSMLVersion func(childComplexity int, smlVersionID string) int + DeleteTag func(childComplexity int, tagID string) int + DeleteVersion func(childComplexity int, versionID string) int + DenyMod func(childComplexity int, modID string) int + DenyVersion func(childComplexity int, versionID string) int + DiscourseSso func(childComplexity int, sso string, sig string) int + FinalizeCreateVersion func(childComplexity int, modID string, versionID string, version NewVersion) int + Logout func(childComplexity int) int + 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 + 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 + UpdateMultipleModCompatibilities func(childComplexity int, modIDs []string, compatibility CompatibilityInfoInput) int + UpdateSMLVersion func(childComplexity int, smlVersionID string, smlVersion UpdateSMLVersion) int + UpdateTag func(childComplexity int, tagID string, newName string) int + UpdateUser func(childComplexity int, userID string, input UpdateUser) int + UpdateVersion func(childComplexity int, versionID string, version UpdateVersion) int + UploadVersionPart func(childComplexity int, modID string, versionID string, part int, file graphql.Upload) int + } + + OAuthOptions struct { + Facebook func(childComplexity int) int + Github func(childComplexity int) int + Google func(childComplexity int) int + } + + Query struct { + CheckVersionUploadState func(childComplexity int, modID string, versionID string) int + GetAnnouncement func(childComplexity int, announcementID string) int + GetAnnouncements func(childComplexity int) int + GetAnnouncementsByImportance func(childComplexity int, importance AnnouncementImportance) int + GetGuide func(childComplexity int, guideID string) int + GetGuides func(childComplexity int, filter map[string]interface{}) int + GetMe func(childComplexity int) int + GetMod func(childComplexity int, modID string) int + GetModByIDOrReference func(childComplexity int, modIDOrReference string) int + GetModByReference func(childComplexity int, modReference string) 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 + GetMyUnapprovedVersions func(childComplexity int, filter map[string]interface{}) int + GetMyVersions func(childComplexity int, filter map[string]interface{}) int + GetOAuthOptions func(childComplexity int, callbackURL string) int + GetSMLVersion func(childComplexity int, smlVersionID string) int + GetSMLVersions func(childComplexity int, filter map[string]interface{}) int + GetTag func(childComplexity int, tagID string) int + GetTags func(childComplexity int, filter *TagFilter) int + GetUnapprovedMods func(childComplexity int, filter map[string]interface{}) int + GetUnapprovedVersions func(childComplexity int, filter map[string]interface{}) int + GetUser func(childComplexity int, userID string) int + GetUsers func(childComplexity int, userIds []string) int + GetVersion func(childComplexity int, versionID string) int + GetVersions func(childComplexity int, filter map[string]interface{}) int + ResolveModVersions func(childComplexity int, filter []*ModVersionConstraint) int + } + + SMLVersion struct { + BootstrapVersion func(childComplexity int) int + Changelog func(childComplexity int) int + CreatedAt func(childComplexity int) int + Date func(childComplexity int) int + EngineVersion func(childComplexity int) int + ID func(childComplexity int) int + Link func(childComplexity int) int + SatisfactoryVersion func(childComplexity int) int + Stability func(childComplexity int) int + Targets func(childComplexity int) int + UpdatedAt func(childComplexity int) int + Version func(childComplexity int) int + } + + SMLVersionTarget struct { + Link func(childComplexity int) int + TargetName func(childComplexity int) int + VersionID func(childComplexity int) int + } + + Tag struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + User struct { + Avatar func(childComplexity int) int + CreatedAt func(childComplexity int) int + Email func(childComplexity int) int + FacebookID func(childComplexity int) int + GithubID func(childComplexity int) int + GoogleID func(childComplexity int) int + Groups func(childComplexity int) int + Guides func(childComplexity int) int + ID func(childComplexity int) int + Mods func(childComplexity int) int + Roles func(childComplexity int) int + Username func(childComplexity int) int + } + + UserMod struct { + Mod func(childComplexity int) int + ModID func(childComplexity int) int + Role func(childComplexity int) int + User func(childComplexity int) int + UserID func(childComplexity int) int + } + + UserRoles struct { + ApproveMods func(childComplexity int) int + ApproveVersions func(childComplexity int) int + DeleteContent func(childComplexity int) int + EditAnyModCompatibility func(childComplexity int) int + EditBootstrapVersions func(childComplexity int) int + EditContent func(childComplexity int) int + EditSMLVersions func(childComplexity int) int + EditUsers func(childComplexity int) int + } + + UserSession struct { + Token func(childComplexity int) int + } + + Version struct { + Approved func(childComplexity int) int + Changelog func(childComplexity int) int + CreatedAt func(childComplexity int) int + Dependencies func(childComplexity int) int + Downloads func(childComplexity int) int + Hash func(childComplexity int) int + ID func(childComplexity int) int + Link func(childComplexity int) int + Metadata func(childComplexity int) int + Mod func(childComplexity int) int + ModID func(childComplexity int) int + Size func(childComplexity int) int + SmlVersion func(childComplexity int) int + Stability func(childComplexity int) int + Targets func(childComplexity int) int + UpdatedAt func(childComplexity int) int + Version func(childComplexity int) int + } + + VersionDependency struct { + Condition func(childComplexity int) int + Mod func(childComplexity int) int + ModID func(childComplexity int) int + Optional func(childComplexity int) int + Version func(childComplexity int) int + VersionID func(childComplexity int) int + } + + VersionTarget struct { + Hash func(childComplexity int) int + Link func(childComplexity int) int + Size func(childComplexity int) int + TargetName func(childComplexity int) int + VersionID func(childComplexity int) int + } +} + +type GetGuidesResolver interface { + Guides(ctx context.Context, obj *GetGuides) ([]*Guide, error) + Count(ctx context.Context, obj *GetGuides) (int, error) +} +type GetModsResolver interface { + Mods(ctx context.Context, obj *GetMods) ([]*Mod, error) + Count(ctx context.Context, obj *GetMods) (int, error) +} +type GetMyModsResolver interface { + Mods(ctx context.Context, obj *GetMyMods) ([]*Mod, error) + Count(ctx context.Context, obj *GetMyMods) (int, error) +} +type GetMyVersionsResolver interface { + Versions(ctx context.Context, obj *GetMyVersions) ([]*Version, error) + Count(ctx context.Context, obj *GetMyVersions) (int, error) +} +type GetSMLVersionsResolver interface { + SmlVersions(ctx context.Context, obj *GetSMLVersions) ([]*SMLVersion, error) + Count(ctx context.Context, obj *GetSMLVersions) (int, error) +} +type GetVersionsResolver interface { + Versions(ctx context.Context, obj *GetVersions) ([]*Version, error) + Count(ctx context.Context, obj *GetVersions) (int, error) +} +type GuideResolver interface { + User(ctx context.Context, obj *Guide) (*User, error) +} +type ModResolver interface { + Authors(ctx context.Context, obj *Mod) ([]*UserMod, error) + Version(ctx context.Context, obj *Mod, version string) (*Version, error) + Versions(ctx context.Context, obj *Mod, filter map[string]interface{}) ([]*Version, error) + LatestVersions(ctx context.Context, obj *Mod) (*LatestVersions, error) +} +type MutationResolver interface { + DiscourseSso(ctx context.Context, sso string, sig string) (*string, error) + CreateAnnouncement(ctx context.Context, announcement NewAnnouncement) (*Announcement, error) + UpdateAnnouncement(ctx context.Context, announcementID string, announcement UpdateAnnouncement) (*Announcement, error) + DeleteAnnouncement(ctx context.Context, announcementID string) (bool, error) + UpdateModCompatibility(ctx context.Context, modID string, compatibility CompatibilityInfoInput) (bool, error) + UpdateMultipleModCompatibilities(ctx context.Context, modIDs []string, compatibility CompatibilityInfoInput) (bool, error) + CreateGuide(ctx context.Context, guide NewGuide) (*Guide, error) + UpdateGuide(ctx context.Context, guideID string, guide UpdateGuide) (*Guide, error) + DeleteGuide(ctx context.Context, guideID string) (bool, error) + CreateMod(ctx context.Context, mod NewMod) (*Mod, error) + UpdateMod(ctx context.Context, modID string, mod UpdateMod) (*Mod, error) + DeleteMod(ctx context.Context, modID string) (bool, error) + ApproveMod(ctx context.Context, modID string) (bool, error) + DenyMod(ctx context.Context, modID string) (bool, error) + CreateSMLVersion(ctx context.Context, smlVersion NewSMLVersion) (*SMLVersion, error) + UpdateSMLVersion(ctx context.Context, smlVersionID string, smlVersion UpdateSMLVersion) (*SMLVersion, error) + DeleteSMLVersion(ctx context.Context, smlVersionID string) (bool, error) + CreateTag(ctx context.Context, tagName string) (*Tag, error) + CreateMultipleTags(ctx context.Context, tagNames []string) ([]*Tag, error) + UpdateTag(ctx context.Context, tagID string, newName string) (*Tag, error) + DeleteTag(ctx context.Context, tagID string) (bool, error) + UpdateUser(ctx context.Context, userID string, input UpdateUser) (*User, error) + Logout(ctx context.Context) (bool, error) + OAuthGithub(ctx context.Context, code string, state string) (*UserSession, error) + OAuthGoogle(ctx context.Context, code string, state string) (*UserSession, error) + OAuthFacebook(ctx context.Context, code string, state string) (*UserSession, error) + CreateVersion(ctx context.Context, modID string) (string, error) + UploadVersionPart(ctx context.Context, modID string, versionID string, part int, file graphql.Upload) (bool, error) + FinalizeCreateVersion(ctx context.Context, modID string, versionID string, version NewVersion) (bool, error) + UpdateVersion(ctx context.Context, versionID string, version UpdateVersion) (*Version, error) + DeleteVersion(ctx context.Context, versionID string) (bool, error) + ApproveVersion(ctx context.Context, versionID string) (bool, error) + DenyVersion(ctx context.Context, versionID string) (bool, error) +} +type QueryResolver interface { + GetOAuthOptions(ctx context.Context, callbackURL string) (*OAuthOptions, error) + GetAnnouncement(ctx context.Context, announcementID string) (*Announcement, error) + GetAnnouncements(ctx context.Context) ([]*Announcement, error) + GetAnnouncementsByImportance(ctx context.Context, importance AnnouncementImportance) ([]*Announcement, error) + GetGuide(ctx context.Context, guideID string) (*Guide, error) + GetGuides(ctx context.Context, filter map[string]interface{}) (*GetGuides, error) + GetMod(ctx context.Context, modID string) (*Mod, error) + GetModByReference(ctx context.Context, modReference string) (*Mod, error) + GetModByIDOrReference(ctx context.Context, modIDOrReference string) (*Mod, error) + GetMods(ctx context.Context, filter map[string]interface{}) (*GetMods, error) + GetUnapprovedMods(ctx context.Context, filter map[string]interface{}) (*GetMods, error) + GetMyMods(ctx context.Context, filter map[string]interface{}) (*GetMyMods, error) + GetMyUnapprovedMods(ctx context.Context, filter map[string]interface{}) (*GetMyMods, error) + ResolveModVersions(ctx context.Context, filter []*ModVersionConstraint) ([]*ModVersion, error) + GetSMLVersion(ctx context.Context, smlVersionID string) (*SMLVersion, error) + GetSMLVersions(ctx context.Context, filter map[string]interface{}) (*GetSMLVersions, error) + GetTag(ctx context.Context, tagID string) (*Tag, error) + GetTags(ctx context.Context, filter *TagFilter) ([]*Tag, error) + GetMe(ctx context.Context) (*User, error) + GetUser(ctx context.Context, userID string) (*User, error) + GetUsers(ctx context.Context, userIds []string) ([]*User, error) + GetVersion(ctx context.Context, versionID string) (*Version, error) + GetVersions(ctx context.Context, filter map[string]interface{}) (*GetVersions, error) + GetUnapprovedVersions(ctx context.Context, filter map[string]interface{}) (*GetVersions, error) + CheckVersionUploadState(ctx context.Context, modID string, versionID string) (*CreateVersionResponse, error) + GetMyVersions(ctx context.Context, filter map[string]interface{}) (*GetMyVersions, error) + GetMyUnapprovedVersions(ctx context.Context, filter map[string]interface{}) (*GetMyVersions, error) +} +type UserResolver interface { + Roles(ctx context.Context, obj *User) (*UserRoles, error) + Groups(ctx context.Context, obj *User) ([]*Group, error) + Mods(ctx context.Context, obj *User) ([]*UserMod, error) + Guides(ctx context.Context, obj *User) ([]*Guide, error) +} +type UserModResolver interface { + User(ctx context.Context, obj *UserMod) (*User, error) + Mod(ctx context.Context, obj *UserMod) (*Mod, error) +} +type VersionResolver interface { + Link(ctx context.Context, obj *Version) (string, error) + + Size(ctx context.Context, obj *Version) (*int, error) + Hash(ctx context.Context, obj *Version) (*string, error) + Mod(ctx context.Context, obj *Version) (*Mod, error) + Dependencies(ctx context.Context, obj *Version) ([]*VersionDependency, error) +} +type VersionTargetResolver interface { + Link(ctx context.Context, obj *VersionTarget) (string, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Announcement.id": + if e.complexity.Announcement.ID == nil { + break + } + + return e.complexity.Announcement.ID(childComplexity), true + + case "Announcement.importance": + if e.complexity.Announcement.Importance == nil { + break + } + + return e.complexity.Announcement.Importance(childComplexity), true + + case "Announcement.message": + if e.complexity.Announcement.Message == nil { + break + } + + return e.complexity.Announcement.Message(childComplexity), true + + case "Compatibility.note": + if e.complexity.Compatibility.Note == nil { + break + } + + return e.complexity.Compatibility.Note(childComplexity), true + + case "Compatibility.state": + if e.complexity.Compatibility.State == nil { + break + } + + return e.complexity.Compatibility.State(childComplexity), true + + case "CompatibilityInfo.EA": + if e.complexity.CompatibilityInfo.Ea == nil { + break + } + + return e.complexity.CompatibilityInfo.Ea(childComplexity), true + + case "CompatibilityInfo.EXP": + if e.complexity.CompatibilityInfo.Exp == nil { + break + } + + return e.complexity.CompatibilityInfo.Exp(childComplexity), true + + case "CreateVersionResponse.auto_approved": + if e.complexity.CreateVersionResponse.AutoApproved == nil { + break + } + + return e.complexity.CreateVersionResponse.AutoApproved(childComplexity), true + + case "CreateVersionResponse.version": + if e.complexity.CreateVersionResponse.Version == nil { + break + } + + return e.complexity.CreateVersionResponse.Version(childComplexity), true + + case "GetGuides.count": + if e.complexity.GetGuides.Count == nil { + break + } + + return e.complexity.GetGuides.Count(childComplexity), true + + case "GetGuides.guides": + if e.complexity.GetGuides.Guides == nil { + break + } + + return e.complexity.GetGuides.Guides(childComplexity), true + + case "GetMods.count": + if e.complexity.GetMods.Count == nil { + break + } + + return e.complexity.GetMods.Count(childComplexity), true + + case "GetMods.mods": + if e.complexity.GetMods.Mods == nil { + break + } + + return e.complexity.GetMods.Mods(childComplexity), true + + case "GetMyMods.count": + if e.complexity.GetMyMods.Count == nil { + break + } + + return e.complexity.GetMyMods.Count(childComplexity), true + + case "GetMyMods.mods": + if e.complexity.GetMyMods.Mods == nil { + break + } + + return e.complexity.GetMyMods.Mods(childComplexity), true + + case "GetMyVersions.count": + if e.complexity.GetMyVersions.Count == nil { + break + } + + return e.complexity.GetMyVersions.Count(childComplexity), true + + case "GetMyVersions.versions": + if e.complexity.GetMyVersions.Versions == nil { + break + } + + return e.complexity.GetMyVersions.Versions(childComplexity), true + + case "GetSMLVersions.count": + if e.complexity.GetSMLVersions.Count == nil { + break + } + + return e.complexity.GetSMLVersions.Count(childComplexity), true + + case "GetSMLVersions.sml_versions": + if e.complexity.GetSMLVersions.SmlVersions == nil { + break + } + + return e.complexity.GetSMLVersions.SmlVersions(childComplexity), true + + case "GetVersions.count": + if e.complexity.GetVersions.Count == nil { + break + } + + return e.complexity.GetVersions.Count(childComplexity), true + + case "GetVersions.versions": + if e.complexity.GetVersions.Versions == nil { + break + } + + return e.complexity.GetVersions.Versions(childComplexity), true + + case "Group.id": + if e.complexity.Group.ID == nil { + break + } + + return e.complexity.Group.ID(childComplexity), true + + case "Group.name": + if e.complexity.Group.Name == nil { + break + } + + return e.complexity.Group.Name(childComplexity), true + + case "Guide.created_at": + if e.complexity.Guide.CreatedAt == nil { + break + } + + return e.complexity.Guide.CreatedAt(childComplexity), true + + case "Guide.guide": + if e.complexity.Guide.Guide == nil { + break + } + + return e.complexity.Guide.Guide(childComplexity), true + + case "Guide.id": + if e.complexity.Guide.ID == nil { + break + } + + return e.complexity.Guide.ID(childComplexity), true + + case "Guide.name": + if e.complexity.Guide.Name == nil { + break + } + + return e.complexity.Guide.Name(childComplexity), true + + case "Guide.short_description": + if e.complexity.Guide.ShortDescription == nil { + break + } + + return e.complexity.Guide.ShortDescription(childComplexity), true + + case "Guide.tags": + if e.complexity.Guide.Tags == nil { + break + } + + return e.complexity.Guide.Tags(childComplexity), true + + case "Guide.updated_at": + if e.complexity.Guide.UpdatedAt == nil { + break + } + + return e.complexity.Guide.UpdatedAt(childComplexity), true + + case "Guide.user": + if e.complexity.Guide.User == nil { + break + } + + return e.complexity.Guide.User(childComplexity), true + + case "Guide.user_id": + if e.complexity.Guide.UserID == nil { + break + } + + return e.complexity.Guide.UserID(childComplexity), true + + case "Guide.views": + if e.complexity.Guide.Views == nil { + break + } + + return e.complexity.Guide.Views(childComplexity), true + + case "LatestVersions.alpha": + if e.complexity.LatestVersions.Alpha == nil { + break + } + + return e.complexity.LatestVersions.Alpha(childComplexity), true + + case "LatestVersions.beta": + if e.complexity.LatestVersions.Beta == nil { + break + } + + return e.complexity.LatestVersions.Beta(childComplexity), true + + case "LatestVersions.release": + if e.complexity.LatestVersions.Release == nil { + break + } + + return e.complexity.LatestVersions.Release(childComplexity), true + + case "Mod.approved": + if e.complexity.Mod.Approved == nil { + break + } + + return e.complexity.Mod.Approved(childComplexity), true + + case "Mod.authors": + if e.complexity.Mod.Authors == nil { + break + } + + return e.complexity.Mod.Authors(childComplexity), true + + case "Mod.compatibility": + if e.complexity.Mod.Compatibility == nil { + break + } + + return e.complexity.Mod.Compatibility(childComplexity), true + + case "Mod.created_at": + if e.complexity.Mod.CreatedAt == nil { + break + } + + return e.complexity.Mod.CreatedAt(childComplexity), true + + case "Mod.creator_id": + if e.complexity.Mod.CreatorID == nil { + break + } + + return e.complexity.Mod.CreatorID(childComplexity), true + + case "Mod.downloads": + if e.complexity.Mod.Downloads == nil { + break + } + + return e.complexity.Mod.Downloads(childComplexity), true + + case "Mod.full_description": + if e.complexity.Mod.FullDescription == nil { + break + } + + return e.complexity.Mod.FullDescription(childComplexity), true + + case "Mod.hidden": + if e.complexity.Mod.Hidden == nil { + break + } + + return e.complexity.Mod.Hidden(childComplexity), true + + case "Mod.hotness": + if e.complexity.Mod.Hotness == nil { + break + } + + return e.complexity.Mod.Hotness(childComplexity), true + + case "Mod.id": + if e.complexity.Mod.ID == nil { + break + } + + return e.complexity.Mod.ID(childComplexity), true + + case "Mod.last_version_date": + if e.complexity.Mod.LastVersionDate == nil { + break + } + + return e.complexity.Mod.LastVersionDate(childComplexity), true + + case "Mod.latestVersions": + if e.complexity.Mod.LatestVersions == nil { + break + } + + return e.complexity.Mod.LatestVersions(childComplexity), true + + case "Mod.logo": + if e.complexity.Mod.Logo == nil { + break + } + + return e.complexity.Mod.Logo(childComplexity), true + + case "Mod.mod_reference": + if e.complexity.Mod.ModReference == nil { + break + } + + return e.complexity.Mod.ModReference(childComplexity), true + + case "Mod.name": + if e.complexity.Mod.Name == nil { + break + } + + return e.complexity.Mod.Name(childComplexity), true + + case "Mod.popularity": + if e.complexity.Mod.Popularity == nil { + break + } + + return e.complexity.Mod.Popularity(childComplexity), true + + case "Mod.short_description": + if e.complexity.Mod.ShortDescription == nil { + break + } + + return e.complexity.Mod.ShortDescription(childComplexity), true + + case "Mod.source_url": + if e.complexity.Mod.SourceURL == nil { + break + } + + return e.complexity.Mod.SourceURL(childComplexity), true + + case "Mod.tags": + if e.complexity.Mod.Tags == nil { + break + } + + return e.complexity.Mod.Tags(childComplexity), true + + case "Mod.updated_at": + if e.complexity.Mod.UpdatedAt == nil { + break + } + + return e.complexity.Mod.UpdatedAt(childComplexity), true + + case "Mod.version": + if e.complexity.Mod.Version == nil { + break + } + + args, err := ec.field_Mod_version_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mod.Version(childComplexity, args["version"].(string)), true + + case "Mod.versions": + if e.complexity.Mod.Versions == nil { + break + } + + args, err := ec.field_Mod_versions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mod.Versions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Mod.views": + if e.complexity.Mod.Views == nil { + break + } + + return e.complexity.Mod.Views(childComplexity), true + + case "ModVersion.id": + if e.complexity.ModVersion.ID == nil { + break + } + + return e.complexity.ModVersion.ID(childComplexity), true + + case "ModVersion.mod_reference": + if e.complexity.ModVersion.ModReference == nil { + break + } + + return e.complexity.ModVersion.ModReference(childComplexity), true + + case "ModVersion.versions": + if e.complexity.ModVersion.Versions == nil { + break + } + + return e.complexity.ModVersion.Versions(childComplexity), true + + case "Mutation.approveMod": + if e.complexity.Mutation.ApproveMod == nil { + break + } + + args, err := ec.field_Mutation_approveMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.ApproveMod(childComplexity, args["modId"].(string)), true + + case "Mutation.approveVersion": + if e.complexity.Mutation.ApproveVersion == nil { + break + } + + args, err := ec.field_Mutation_approveVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.ApproveVersion(childComplexity, args["versionId"].(string)), true + + case "Mutation.createAnnouncement": + if e.complexity.Mutation.CreateAnnouncement == nil { + break + } + + args, err := ec.field_Mutation_createAnnouncement_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateAnnouncement(childComplexity, args["announcement"].(NewAnnouncement)), true + + case "Mutation.createGuide": + if e.complexity.Mutation.CreateGuide == nil { + break + } + + args, err := ec.field_Mutation_createGuide_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateGuide(childComplexity, args["guide"].(NewGuide)), true + + case "Mutation.createMod": + if e.complexity.Mutation.CreateMod == nil { + break + } + + args, err := ec.field_Mutation_createMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateMod(childComplexity, args["mod"].(NewMod)), true + + case "Mutation.createMultipleTags": + if e.complexity.Mutation.CreateMultipleTags == nil { + break + } + + args, err := ec.field_Mutation_createMultipleTags_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateMultipleTags(childComplexity, args["tagNames"].([]string)), true + + case "Mutation.createSMLVersion": + if e.complexity.Mutation.CreateSMLVersion == nil { + break + } + + args, err := ec.field_Mutation_createSMLVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateSMLVersion(childComplexity, args["smlVersion"].(NewSMLVersion)), true + + case "Mutation.createTag": + if e.complexity.Mutation.CreateTag == nil { + break + } + + args, err := ec.field_Mutation_createTag_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateTag(childComplexity, args["tagName"].(string)), true + + case "Mutation.createVersion": + if e.complexity.Mutation.CreateVersion == nil { + break + } + + args, err := ec.field_Mutation_createVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateVersion(childComplexity, args["modId"].(string)), true + + case "Mutation.deleteAnnouncement": + if e.complexity.Mutation.DeleteAnnouncement == nil { + break + } + + args, err := ec.field_Mutation_deleteAnnouncement_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteAnnouncement(childComplexity, args["announcementId"].(string)), true + + case "Mutation.deleteGuide": + if e.complexity.Mutation.DeleteGuide == nil { + break + } + + args, err := ec.field_Mutation_deleteGuide_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteGuide(childComplexity, args["guideId"].(string)), true + + case "Mutation.deleteMod": + if e.complexity.Mutation.DeleteMod == nil { + break + } + + args, err := ec.field_Mutation_deleteMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteMod(childComplexity, args["modId"].(string)), true + + case "Mutation.deleteSMLVersion": + if e.complexity.Mutation.DeleteSMLVersion == nil { + break + } + + args, err := ec.field_Mutation_deleteSMLVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteSMLVersion(childComplexity, args["smlVersionId"].(string)), true + + case "Mutation.deleteTag": + if e.complexity.Mutation.DeleteTag == nil { + break + } + + args, err := ec.field_Mutation_deleteTag_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteTag(childComplexity, args["tagID"].(string)), true + + case "Mutation.deleteVersion": + if e.complexity.Mutation.DeleteVersion == nil { + break + } + + args, err := ec.field_Mutation_deleteVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteVersion(childComplexity, args["versionId"].(string)), true + + case "Mutation.denyMod": + if e.complexity.Mutation.DenyMod == nil { + break + } + + args, err := ec.field_Mutation_denyMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DenyMod(childComplexity, args["modId"].(string)), true + + case "Mutation.denyVersion": + if e.complexity.Mutation.DenyVersion == nil { + break + } + + args, err := ec.field_Mutation_denyVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DenyVersion(childComplexity, args["versionId"].(string)), true + + case "Mutation.discourseSSO": + if e.complexity.Mutation.DiscourseSso == nil { + break + } + + args, err := ec.field_Mutation_discourseSSO_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DiscourseSso(childComplexity, args["sso"].(string), args["sig"].(string)), true + + case "Mutation.finalizeCreateVersion": + if e.complexity.Mutation.FinalizeCreateVersion == nil { + break + } + + args, err := ec.field_Mutation_finalizeCreateVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.FinalizeCreateVersion(childComplexity, args["modId"].(string), args["versionId"].(string), args["version"].(NewVersion)), true + + case "Mutation.logout": + if e.complexity.Mutation.Logout == nil { + break + } + + return e.complexity.Mutation.Logout(childComplexity), true + + case "Mutation.oAuthFacebook": + if e.complexity.Mutation.OAuthFacebook == nil { + break + } + + args, err := ec.field_Mutation_oAuthFacebook_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.OAuthFacebook(childComplexity, args["code"].(string), args["state"].(string)), true + + case "Mutation.oAuthGithub": + if e.complexity.Mutation.OAuthGithub == nil { + break + } + + args, err := ec.field_Mutation_oAuthGithub_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.OAuthGithub(childComplexity, args["code"].(string), args["state"].(string)), true + + case "Mutation.oAuthGoogle": + if e.complexity.Mutation.OAuthGoogle == nil { + break + } + + args, err := ec.field_Mutation_oAuthGoogle_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.OAuthGoogle(childComplexity, args["code"].(string), args["state"].(string)), true + + case "Mutation.updateAnnouncement": + if e.complexity.Mutation.UpdateAnnouncement == nil { + break + } + + args, err := ec.field_Mutation_updateAnnouncement_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateAnnouncement(childComplexity, args["announcementId"].(string), args["announcement"].(UpdateAnnouncement)), true + + case "Mutation.updateGuide": + if e.complexity.Mutation.UpdateGuide == nil { + break + } + + args, err := ec.field_Mutation_updateGuide_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateGuide(childComplexity, args["guideId"].(string), args["guide"].(UpdateGuide)), true + + case "Mutation.updateMod": + if e.complexity.Mutation.UpdateMod == nil { + break + } + + args, err := ec.field_Mutation_updateMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateMod(childComplexity, args["modId"].(string), args["mod"].(UpdateMod)), true + + case "Mutation.updateModCompatibility": + if e.complexity.Mutation.UpdateModCompatibility == nil { + break + } + + args, err := ec.field_Mutation_updateModCompatibility_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateModCompatibility(childComplexity, args["modId"].(string), args["compatibility"].(CompatibilityInfoInput)), true + + case "Mutation.updateMultipleModCompatibilities": + if e.complexity.Mutation.UpdateMultipleModCompatibilities == nil { + break + } + + args, err := ec.field_Mutation_updateMultipleModCompatibilities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateMultipleModCompatibilities(childComplexity, args["modIDs"].([]string), args["compatibility"].(CompatibilityInfoInput)), true + + case "Mutation.updateSMLVersion": + if e.complexity.Mutation.UpdateSMLVersion == nil { + break + } + + args, err := ec.field_Mutation_updateSMLVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateSMLVersion(childComplexity, args["smlVersionId"].(string), args["smlVersion"].(UpdateSMLVersion)), true + + case "Mutation.updateTag": + if e.complexity.Mutation.UpdateTag == nil { + break + } + + args, err := ec.field_Mutation_updateTag_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateTag(childComplexity, args["tagID"].(string), args["NewName"].(string)), true + + case "Mutation.updateUser": + if e.complexity.Mutation.UpdateUser == nil { + break + } + + args, err := ec.field_Mutation_updateUser_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateUser(childComplexity, args["userId"].(string), args["input"].(UpdateUser)), true + + case "Mutation.updateVersion": + if e.complexity.Mutation.UpdateVersion == nil { + break + } + + args, err := ec.field_Mutation_updateVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateVersion(childComplexity, args["versionId"].(string), args["version"].(UpdateVersion)), true + + case "Mutation.uploadVersionPart": + if e.complexity.Mutation.UploadVersionPart == nil { + break + } + + args, err := ec.field_Mutation_uploadVersionPart_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UploadVersionPart(childComplexity, args["modId"].(string), args["versionId"].(string), args["part"].(int), args["file"].(graphql.Upload)), true + + case "OAuthOptions.facebook": + if e.complexity.OAuthOptions.Facebook == nil { + break + } + + return e.complexity.OAuthOptions.Facebook(childComplexity), true + + case "OAuthOptions.github": + if e.complexity.OAuthOptions.Github == nil { + break + } + + return e.complexity.OAuthOptions.Github(childComplexity), true + + case "OAuthOptions.google": + if e.complexity.OAuthOptions.Google == nil { + break + } + + return e.complexity.OAuthOptions.Google(childComplexity), true + + case "Query.checkVersionUploadState": + if e.complexity.Query.CheckVersionUploadState == nil { + break + } + + args, err := ec.field_Query_checkVersionUploadState_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CheckVersionUploadState(childComplexity, args["modId"].(string), args["versionId"].(string)), true + + case "Query.getAnnouncement": + if e.complexity.Query.GetAnnouncement == nil { + break + } + + args, err := ec.field_Query_getAnnouncement_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetAnnouncement(childComplexity, args["announcementId"].(string)), true + + case "Query.getAnnouncements": + if e.complexity.Query.GetAnnouncements == nil { + break + } + + return e.complexity.Query.GetAnnouncements(childComplexity), true + + case "Query.getAnnouncementsByImportance": + if e.complexity.Query.GetAnnouncementsByImportance == nil { + break + } + + args, err := ec.field_Query_getAnnouncementsByImportance_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetAnnouncementsByImportance(childComplexity, args["importance"].(AnnouncementImportance)), true + + case "Query.getGuide": + if e.complexity.Query.GetGuide == nil { + break + } + + args, err := ec.field_Query_getGuide_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetGuide(childComplexity, args["guideId"].(string)), true + + case "Query.getGuides": + if e.complexity.Query.GetGuides == nil { + break + } + + args, err := ec.field_Query_getGuides_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetGuides(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getMe": + if e.complexity.Query.GetMe == nil { + break + } + + return e.complexity.Query.GetMe(childComplexity), true + + case "Query.getMod": + if e.complexity.Query.GetMod == nil { + break + } + + args, err := ec.field_Query_getMod_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMod(childComplexity, args["modId"].(string)), true + + case "Query.getModByIdOrReference": + if e.complexity.Query.GetModByIDOrReference == nil { + break + } + + args, err := ec.field_Query_getModByIdOrReference_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModByIDOrReference(childComplexity, args["modIdOrReference"].(string)), true + + case "Query.getModByReference": + if e.complexity.Query.GetModByReference == nil { + break + } + + args, err := ec.field_Query_getModByReference_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModByReference(childComplexity, args["modReference"].(string)), true + + case "Query.getMods": + if e.complexity.Query.GetMods == nil { + break + } + + args, err := ec.field_Query_getMods_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMods(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getMyMods": + if e.complexity.Query.GetMyMods == nil { + break + } + + args, err := ec.field_Query_getMyMods_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMyMods(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getMyUnapprovedMods": + if e.complexity.Query.GetMyUnapprovedMods == nil { + break + } + + args, err := ec.field_Query_getMyUnapprovedMods_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMyUnapprovedMods(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getMyUnapprovedVersions": + if e.complexity.Query.GetMyUnapprovedVersions == nil { + break + } + + args, err := ec.field_Query_getMyUnapprovedVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMyUnapprovedVersions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getMyVersions": + if e.complexity.Query.GetMyVersions == nil { + break + } + + args, err := ec.field_Query_getMyVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetMyVersions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getOAuthOptions": + if e.complexity.Query.GetOAuthOptions == nil { + break + } + + args, err := ec.field_Query_getOAuthOptions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetOAuthOptions(childComplexity, args["callback_url"].(string)), true + + case "Query.getSMLVersion": + if e.complexity.Query.GetSMLVersion == nil { + break + } + + args, err := ec.field_Query_getSMLVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetSMLVersion(childComplexity, args["smlVersionID"].(string)), true + + case "Query.getSMLVersions": + if e.complexity.Query.GetSMLVersions == nil { + break + } + + args, err := ec.field_Query_getSMLVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetSMLVersions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getTag": + if e.complexity.Query.GetTag == nil { + break + } + + args, err := ec.field_Query_getTag_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetTag(childComplexity, args["tagID"].(string)), true + + case "Query.getTags": + if e.complexity.Query.GetTags == nil { + break + } + + args, err := ec.field_Query_getTags_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetTags(childComplexity, args["filter"].(*TagFilter)), true + + case "Query.getUnapprovedMods": + if e.complexity.Query.GetUnapprovedMods == nil { + break + } + + args, err := ec.field_Query_getUnapprovedMods_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetUnapprovedMods(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getUnapprovedVersions": + if e.complexity.Query.GetUnapprovedVersions == nil { + break + } + + args, err := ec.field_Query_getUnapprovedVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetUnapprovedVersions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.getUser": + if e.complexity.Query.GetUser == nil { + break + } + + args, err := ec.field_Query_getUser_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetUser(childComplexity, args["userId"].(string)), true + + case "Query.getUsers": + if e.complexity.Query.GetUsers == nil { + break + } + + args, err := ec.field_Query_getUsers_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetUsers(childComplexity, args["userIds"].([]string)), true + + case "Query.getVersion": + if e.complexity.Query.GetVersion == nil { + break + } + + args, err := ec.field_Query_getVersion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetVersion(childComplexity, args["versionId"].(string)), true + + case "Query.getVersions": + if e.complexity.Query.GetVersions == nil { + break + } + + args, err := ec.field_Query_getVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetVersions(childComplexity, args["filter"].(map[string]interface{})), true + + case "Query.resolveModVersions": + if e.complexity.Query.ResolveModVersions == nil { + break + } + + args, err := ec.field_Query_resolveModVersions_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.ResolveModVersions(childComplexity, args["filter"].([]*ModVersionConstraint)), true + + case "SMLVersion.bootstrap_version": + if e.complexity.SMLVersion.BootstrapVersion == nil { + break + } + + return e.complexity.SMLVersion.BootstrapVersion(childComplexity), true + + case "SMLVersion.changelog": + if e.complexity.SMLVersion.Changelog == nil { + break + } + + return e.complexity.SMLVersion.Changelog(childComplexity), true + + case "SMLVersion.created_at": + if e.complexity.SMLVersion.CreatedAt == nil { + break + } + + return e.complexity.SMLVersion.CreatedAt(childComplexity), true + + case "SMLVersion.date": + if e.complexity.SMLVersion.Date == nil { + break + } + + return e.complexity.SMLVersion.Date(childComplexity), true + + case "SMLVersion.engine_version": + if e.complexity.SMLVersion.EngineVersion == nil { + break + } + + return e.complexity.SMLVersion.EngineVersion(childComplexity), true + + case "SMLVersion.id": + if e.complexity.SMLVersion.ID == nil { + break + } + + return e.complexity.SMLVersion.ID(childComplexity), true + + case "SMLVersion.link": + if e.complexity.SMLVersion.Link == nil { + break + } + + return e.complexity.SMLVersion.Link(childComplexity), true + + case "SMLVersion.satisfactory_version": + if e.complexity.SMLVersion.SatisfactoryVersion == nil { + break + } + + return e.complexity.SMLVersion.SatisfactoryVersion(childComplexity), true + + case "SMLVersion.stability": + if e.complexity.SMLVersion.Stability == nil { + break + } + + return e.complexity.SMLVersion.Stability(childComplexity), true + + case "SMLVersion.targets": + if e.complexity.SMLVersion.Targets == nil { + break + } + + return e.complexity.SMLVersion.Targets(childComplexity), true + + case "SMLVersion.updated_at": + if e.complexity.SMLVersion.UpdatedAt == nil { + break + } + + return e.complexity.SMLVersion.UpdatedAt(childComplexity), true + + case "SMLVersion.version": + if e.complexity.SMLVersion.Version == nil { + break + } + + return e.complexity.SMLVersion.Version(childComplexity), true + + case "SMLVersionTarget.link": + if e.complexity.SMLVersionTarget.Link == nil { + break + } + + return e.complexity.SMLVersionTarget.Link(childComplexity), true + + case "SMLVersionTarget.targetName": + if e.complexity.SMLVersionTarget.TargetName == nil { + break + } + + return e.complexity.SMLVersionTarget.TargetName(childComplexity), true + + case "SMLVersionTarget.VersionID": + if e.complexity.SMLVersionTarget.VersionID == nil { + break + } + + return e.complexity.SMLVersionTarget.VersionID(childComplexity), true + + case "Tag.id": + if e.complexity.Tag.ID == nil { + break + } + + return e.complexity.Tag.ID(childComplexity), true + + case "Tag.name": + if e.complexity.Tag.Name == nil { + break + } + + return e.complexity.Tag.Name(childComplexity), true + + case "User.avatar": + if e.complexity.User.Avatar == nil { + break + } + + return e.complexity.User.Avatar(childComplexity), true + + case "User.created_at": + if e.complexity.User.CreatedAt == nil { + break + } + + return e.complexity.User.CreatedAt(childComplexity), true + + case "User.email": + if e.complexity.User.Email == nil { + break + } + + return e.complexity.User.Email(childComplexity), true + + case "User.facebook_id": + if e.complexity.User.FacebookID == nil { + break + } + + return e.complexity.User.FacebookID(childComplexity), true + + case "User.github_id": + if e.complexity.User.GithubID == nil { + break + } + + return e.complexity.User.GithubID(childComplexity), true + + case "User.google_id": + if e.complexity.User.GoogleID == nil { + break + } + + return e.complexity.User.GoogleID(childComplexity), true + + case "User.groups": + if e.complexity.User.Groups == nil { + break + } + + return e.complexity.User.Groups(childComplexity), true + + case "User.guides": + if e.complexity.User.Guides == nil { + break + } + + return e.complexity.User.Guides(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + + case "User.mods": + if e.complexity.User.Mods == nil { + break + } + + return e.complexity.User.Mods(childComplexity), true + + case "User.roles": + if e.complexity.User.Roles == nil { + break + } + + return e.complexity.User.Roles(childComplexity), true + + case "User.username": + if e.complexity.User.Username == nil { + break + } + + return e.complexity.User.Username(childComplexity), true + + case "UserMod.mod": + if e.complexity.UserMod.Mod == nil { + break + } + + return e.complexity.UserMod.Mod(childComplexity), true + + case "UserMod.mod_id": + if e.complexity.UserMod.ModID == nil { + break + } + + return e.complexity.UserMod.ModID(childComplexity), true + + case "UserMod.role": + if e.complexity.UserMod.Role == nil { + break + } + + return e.complexity.UserMod.Role(childComplexity), true + + case "UserMod.user": + if e.complexity.UserMod.User == nil { + break + } + + return e.complexity.UserMod.User(childComplexity), true + + case "UserMod.user_id": + if e.complexity.UserMod.UserID == nil { + break + } + + return e.complexity.UserMod.UserID(childComplexity), true + + case "UserRoles.approveMods": + if e.complexity.UserRoles.ApproveMods == nil { + break + } + + return e.complexity.UserRoles.ApproveMods(childComplexity), true + + case "UserRoles.approveVersions": + if e.complexity.UserRoles.ApproveVersions == nil { + break + } + + return e.complexity.UserRoles.ApproveVersions(childComplexity), true + + case "UserRoles.deleteContent": + if e.complexity.UserRoles.DeleteContent == nil { + break + } + + return e.complexity.UserRoles.DeleteContent(childComplexity), true + + case "UserRoles.editAnyModCompatibility": + if e.complexity.UserRoles.EditAnyModCompatibility == nil { + break + } + + return e.complexity.UserRoles.EditAnyModCompatibility(childComplexity), true + + case "UserRoles.editBootstrapVersions": + if e.complexity.UserRoles.EditBootstrapVersions == nil { + break + } + + return e.complexity.UserRoles.EditBootstrapVersions(childComplexity), true + + case "UserRoles.editContent": + if e.complexity.UserRoles.EditContent == nil { + break + } + + return e.complexity.UserRoles.EditContent(childComplexity), true + + case "UserRoles.editSMLVersions": + if e.complexity.UserRoles.EditSMLVersions == nil { + break + } + + return e.complexity.UserRoles.EditSMLVersions(childComplexity), true + + case "UserRoles.editUsers": + if e.complexity.UserRoles.EditUsers == nil { + break + } + + return e.complexity.UserRoles.EditUsers(childComplexity), true + + case "UserSession.token": + if e.complexity.UserSession.Token == nil { + break + } + + return e.complexity.UserSession.Token(childComplexity), true + + case "Version.approved": + if e.complexity.Version.Approved == nil { + break + } + + return e.complexity.Version.Approved(childComplexity), true + + case "Version.changelog": + if e.complexity.Version.Changelog == nil { + break + } + + return e.complexity.Version.Changelog(childComplexity), true + + case "Version.created_at": + if e.complexity.Version.CreatedAt == nil { + break + } + + return e.complexity.Version.CreatedAt(childComplexity), true + + case "Version.dependencies": + if e.complexity.Version.Dependencies == nil { + break + } + + return e.complexity.Version.Dependencies(childComplexity), true + + case "Version.downloads": + if e.complexity.Version.Downloads == nil { + break + } + + return e.complexity.Version.Downloads(childComplexity), true + + case "Version.hash": + if e.complexity.Version.Hash == nil { + break + } + + return e.complexity.Version.Hash(childComplexity), true + + case "Version.id": + if e.complexity.Version.ID == nil { + break + } + + return e.complexity.Version.ID(childComplexity), true + + case "Version.link": + if e.complexity.Version.Link == nil { + break + } + + return e.complexity.Version.Link(childComplexity), true + + case "Version.metadata": + if e.complexity.Version.Metadata == nil { + break + } + + return e.complexity.Version.Metadata(childComplexity), true + + case "Version.mod": + if e.complexity.Version.Mod == nil { + break + } + + return e.complexity.Version.Mod(childComplexity), true + + case "Version.mod_id": + if e.complexity.Version.ModID == nil { + break + } + + return e.complexity.Version.ModID(childComplexity), true + + case "Version.size": + if e.complexity.Version.Size == nil { + break + } + + return e.complexity.Version.Size(childComplexity), true + + case "Version.sml_version": + if e.complexity.Version.SmlVersion == nil { + break + } + + return e.complexity.Version.SmlVersion(childComplexity), true + + case "Version.stability": + if e.complexity.Version.Stability == nil { + break + } + + return e.complexity.Version.Stability(childComplexity), true + + case "Version.targets": + if e.complexity.Version.Targets == nil { + break + } + + return e.complexity.Version.Targets(childComplexity), true + + case "Version.updated_at": + if e.complexity.Version.UpdatedAt == nil { + break + } + + return e.complexity.Version.UpdatedAt(childComplexity), true + + case "Version.version": + if e.complexity.Version.Version == nil { + break + } + + return e.complexity.Version.Version(childComplexity), true + + case "VersionDependency.condition": + if e.complexity.VersionDependency.Condition == nil { + break + } + + return e.complexity.VersionDependency.Condition(childComplexity), true + + case "VersionDependency.mod": + if e.complexity.VersionDependency.Mod == nil { + break + } + + return e.complexity.VersionDependency.Mod(childComplexity), true + + case "VersionDependency.mod_id": + if e.complexity.VersionDependency.ModID == nil { + break + } + + return e.complexity.VersionDependency.ModID(childComplexity), true + + case "VersionDependency.optional": + if e.complexity.VersionDependency.Optional == nil { + break + } + + return e.complexity.VersionDependency.Optional(childComplexity), true + + case "VersionDependency.version": + if e.complexity.VersionDependency.Version == nil { + break + } + + return e.complexity.VersionDependency.Version(childComplexity), true + + case "VersionDependency.version_id": + if e.complexity.VersionDependency.VersionID == nil { + break + } + + return e.complexity.VersionDependency.VersionID(childComplexity), true + + case "VersionTarget.hash": + if e.complexity.VersionTarget.Hash == nil { + break + } + + return e.complexity.VersionTarget.Hash(childComplexity), true + + case "VersionTarget.link": + if e.complexity.VersionTarget.Link == nil { + break + } + + return e.complexity.VersionTarget.Link(childComplexity), true + + case "VersionTarget.size": + if e.complexity.VersionTarget.Size == nil { + break + } + + return e.complexity.VersionTarget.Size(childComplexity), true + + case "VersionTarget.targetName": + if e.complexity.VersionTarget.TargetName == nil { + break + } + + return e.complexity.VersionTarget.TargetName(childComplexity), true + + case "VersionTarget.VersionID": + if e.complexity.VersionTarget.VersionID == nil { + break + } + + return e.complexity.VersionTarget.VersionID(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputCompatibilityInfoInput, + ec.unmarshalInputCompatibilityInput, + ec.unmarshalInputModVersionConstraint, + ec.unmarshalInputNewAnnouncement, + ec.unmarshalInputNewGuide, + ec.unmarshalInputNewMod, + ec.unmarshalInputNewSMLVersion, + ec.unmarshalInputNewSMLVersionTarget, + ec.unmarshalInputNewVersion, + ec.unmarshalInputTagFilter, + ec.unmarshalInputUpdateAnnouncement, + ec.unmarshalInputUpdateGuide, + ec.unmarshalInputUpdateMod, + ec.unmarshalInputUpdateSMLVersion, + ec.unmarshalInputUpdateSMLVersionTarget, + ec.unmarshalInputUpdateUser, + ec.unmarshalInputUpdateUserMod, + ec.unmarshalInputUpdateVersion, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + + return &graphql.Response{ + Data: buf.Bytes(), + } + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schemas/announcements.graphql", Input: `### Types + +scalar AnnouncementID + +enum AnnouncementImportance { + Fix + Info + Warning + Alert +} + +type Announcement { + id: AnnouncementID! + message: String! + importance: AnnouncementImportance! +} + +### Inputs + +input NewAnnouncement { + message: String! + importance: AnnouncementImportance! +} + +input UpdateAnnouncement { + message: String + importance: AnnouncementImportance +} + +### Queries + +extend type Query { + getAnnouncement(announcementId: AnnouncementID!): Announcement + getAnnouncements: [Announcement!]! + getAnnouncementsByImportance(importance: AnnouncementImportance!): [Announcement!]! +} + +### Mutations + +extend type Mutation { + createAnnouncement(announcement: NewAnnouncement!): Announcement @canEditAnnouncements @isLoggedIn + updateAnnouncement(announcementId: AnnouncementID!, announcement: UpdateAnnouncement!): Announcement! @canEditAnnouncements @isLoggedIn + deleteAnnouncement(announcementId: AnnouncementID!): Boolean! @canEditAnnouncements @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/base.graphql", Input: `scalar Upload + +scalar Date + +enum Order { + asc + desc +} + +type OAuthOptions { + github: String! + google: String! + facebook: String! +} + +type Query { + getOAuthOptions(callback_url: String!): OAuthOptions! +} + +type Mutation { + discourseSSO(sso: String!, sig: String!): String @isLoggedIn +} +`, BuiltIn: false}, + {Name: "../schemas/compatibility.graphql", Input: `enum CompatibilityState { + Works + Damaged + Broken +} + +type Compatibility { + state: CompatibilityState! + note: String +} + +input CompatibilityInput { + state: CompatibilityState! + note: String +} + +type CompatibilityInfo { + EA: Compatibility! + EXP: Compatibility! +} + +input CompatibilityInfoInput { + EA: CompatibilityInput! + EXP: CompatibilityInput! +} + +extend type Mutation { + updateModCompatibility(modId: ModID!, compatibility: CompatibilityInfoInput!): Boolean! @canEditModCompatibility(field: "modId") @isLoggedIn + updateMultipleModCompatibilities(modIDs: [ModID!]!, compatibility: CompatibilityInfoInput!): Boolean! @canEditModCompatibility @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/directives.graphql", Input: `directive @isLoggedIn on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @isNotLoggedIn on FIELD_DEFINITION | INPUT_FIELD_DEFINITION + +directive @canEditMod(field: String!) on FIELD_DEFINITION +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 @canApproveMods on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canApproveVersions on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canEditUsers on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canEditSMLVersions on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canEditBootstrapVersions on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canEditAnnouncements on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @canManageTags on FIELD_DEFINITION | INPUT_FIELD_DEFINITION`, BuiltIn: false}, + {Name: "../schemas/guide.graphql", Input: `### Types + +scalar GuideID + +enum GuideFields { + name + created_at + updated_at + views +} + +type Guide { + id: GuideID! + name: String! + short_description: String! + guide: String! + views: Int! + user_id: UserID! + updated_at: Date! + created_at: Date! + tags: [Tag!]! + + user: User! +} + +type GetGuides { + guides: [Guide!]! + count: Int! +} + +### Inputs + +input NewGuide { + name: String! + short_description: String! + guide: String! + tagIDs: [TagID!] +} + +input UpdateGuide { + name: String + short_description: String + guide: String + tagIDs: [TagID!] +} + +input GuideFilter { + limit: Int + offset: Int + order_by: GuideFields + order: Order + search: String + ids: [String!] + tagIDs: [TagID!] +} + +### Queries + +extend type Query { + getGuide(guideId: GuideID!): Guide + getGuides(filter: GuideFilter): GetGuides! +} + +### Mutations + +extend type Mutation { + createGuide(guide: NewGuide!): Guide @isLoggedIn + updateGuide(guideId: GuideID!, guide: UpdateGuide!): Guide! @canEditGuide(field: "guideId") @isLoggedIn + deleteGuide(guideId: GuideID!): Boolean! @canEditGuide(field: "guideId") @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/mod.graphql", Input: `### Types + +scalar ModID +scalar ModReference + +enum ModFields { + created_at + updated_at + name + views + downloads + hotness + popularity + last_version_date + search +} + +type Mod { + id: ModID! + name: String! + short_description: String! + full_description: String + logo: String + source_url: String + creator_id: UserID! + approved: Boolean! + views: Int! + downloads: Int! + hotness: Int! + popularity: Int! + updated_at: Date! + created_at: Date! + last_version_date: Date + mod_reference: ModReference! + hidden: Boolean! + tags: [Tag!] + compatibility: CompatibilityInfo + + authors: [UserMod!]! + version(version: String!): Version + versions(filter: VersionFilter): [Version!]! + latestVersions: LatestVersions! +} + +type GetMods { + mods: [Mod!]! + count: Int! +} + +type GetMyMods { + mods: [Mod!]! + count: Int! +} + +type ModVersion { + id: ModID! + mod_reference: ModReference! + versions: [Version!]! +} + +### Inputs + +input ModFilter { + limit: Int + offset: Int + order_by: ModFields + order: Order + search: String + ids: [String!] + references: [String!] + hidden: Boolean + tagIDs: [TagID!] +} + +input NewMod { + name: String! + short_description: String! + full_description: String + logo: Upload + source_url: String + mod_reference: ModReference! + hidden: Boolean + tagIDs: [TagID!] +} + +input UpdateMod { + name: String + short_description: String + full_description: String + logo: Upload + source_url: String + mod_reference: ModReference + authors: [UpdateUserMod!] + hidden: Boolean + tagIDs: [TagID!] + compatibility: CompatibilityInfoInput +} + +input UpdateUserMod { + user_id: UserID! + role: String! +} + +input ModVersionConstraint { + modIdOrReference: String! + version: String! +} + +### Queries + +extend type Query { + getMod(modId: ModID!): Mod + getModByReference(modReference: ModReference!): Mod + getModByIdOrReference(modIdOrReference: String!): Mod + getMods(filter: ModFilter): GetMods! + getUnapprovedMods(filter: ModFilter): GetMods! @canApproveMods @isLoggedIn + + getMyMods(filter: ModFilter): GetMyMods! @isLoggedIn + getMyUnapprovedMods(filter: ModFilter): GetMyMods! @isLoggedIn + + resolveModVersions(filter: [ModVersionConstraint!]!): [ModVersion!]! +} + +### Mutations + +extend type Mutation { + createMod(mod: NewMod!): Mod @isLoggedIn + updateMod(modId: ModID!, mod: UpdateMod!): Mod! @canEditMod(field: "modId") @isLoggedIn + deleteMod(modId: ModID!): Boolean! @canEditMod(field: "modId") @isLoggedIn + + approveMod(modId: ModID!): Boolean! @canApproveMods @isLoggedIn + denyMod(modId: ModID!): Boolean! @canApproveMods @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/sml_version.graphql", Input: `### Types + +scalar SMLVersionID + +type SMLVersion { + id: SMLVersionID! + version: String! + satisfactory_version: Int! + stability: VersionStabilities! + link: String! + targets: [SMLVersionTarget]! + changelog: String! + date: Date! + bootstrap_version: String + engine_version: String! + + updated_at: Date! + created_at: Date! +} + +type SMLVersionTarget { + VersionID: SMLVersionID! + targetName: TargetName! + link: String! +} + +type GetSMLVersions { + sml_versions: [SMLVersion!]! + count: Int! +} + +enum SMLVersionFields { + name + created_at + updated_at + satisfactory_version + date +} + +### Inputs + +input NewSMLVersion { + version: String! + satisfactory_version: Int! + stability: VersionStabilities! + link: String! + targets: [NewSMLVersionTarget!]! + changelog: String! + date: Date! + bootstrap_version: String + engine_version: String! +} + +input UpdateSMLVersion { + version: String + satisfactory_version: Int + stability: VersionStabilities + link: String + targets: [UpdateSMLVersionTarget]! + changelog: String + date: Date + bootstrap_version: String + engine_version: String +} + +input NewSMLVersionTarget { + targetName: TargetName! + link: String! +} + +input UpdateSMLVersionTarget { + targetName: TargetName! + link: String! +} + +input SMLVersionFilter { + limit: Int + offset: Int + order_by: SMLVersionFields + order: Order + search: String + ids: [String!] +} + +### Queries + +extend type Query { + getSMLVersion(smlVersionID: SMLVersionID!): SMLVersion + getSMLVersions(filter: SMLVersionFilter): GetSMLVersions! +} + +### Mutations + +extend type Mutation { + createSMLVersion(smlVersion: NewSMLVersion!): SMLVersion @isLoggedIn + updateSMLVersion(smlVersionId: SMLVersionID!, smlVersion: UpdateSMLVersion!): SMLVersion! @canEditSMLVersions @isLoggedIn + deleteSMLVersion(smlVersionId: SMLVersionID!): Boolean! @canEditSMLVersions @isLoggedIn +} +`, BuiltIn: false}, + {Name: "../schemas/tags.graphql", Input: `scalar TagID +scalar TagName + +type Tag { + id: TagID! + name: TagName! +} + +input TagFilter { + limit: Int + offset: Int + order: Order + search: String + ids: [TagID!] +} + +extend type Query { + getTag(tagID: TagID!): Tag + getTags(filter: TagFilter): [Tag!]! +} + +### Mutations + +extend type Mutation { + createTag(tagName: TagName!): Tag @isLoggedIn + createMultipleTags(tagNames: [TagName!]!): [Tag!]! @canManageTags @isLoggedIn + updateTag(tagID: TagID!, NewName: TagName!): Tag! @canManageTags @isLoggedIn + deleteTag(tagID: TagID!): Boolean! @canManageTags @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/user.graphql", Input: `### Types + +scalar UserID + +type UserRoles { + approveMods: Boolean! + approveVersions: Boolean! + deleteContent: Boolean! + editContent: Boolean! + editUsers: Boolean! + editSMLVersions: Boolean! + editBootstrapVersions: Boolean! + editAnyModCompatibility: Boolean! +} + +type Group { + id: String! + name: String! +} + +type User { + id: UserID! + email: String @canEditUser(field: "ID", object: true) @isLoggedIn + username: String! + avatar: String + created_at: Date! + + github_id: String @canEditUser(field: "ID", object: true) @isLoggedIn + google_id: String @canEditUser(field: "ID", object: true) @isLoggedIn + facebook_id: String @canEditUser(field: "ID", object: true) @isLoggedIn + + roles: UserRoles! @canEditUser(field: "ID", object: true) @isLoggedIn + groups: [Group!]! @canEditUser(field: "ID", object: true) @isLoggedIn + + mods: [UserMod!]! + guides: [Guide!]! +} + +type UserSession { + token: String! +} + +type UserMod { + user_id: UserID! + mod_id: ModID! + role: String! + + user: User! + mod: Mod! +} + +### Inputs + +input UpdateUser { + avatar: Upload + groups: [String!] @canEditUsers @isLoggedIn + username: String +} + +### Queries + +extend type Query { + getMe: User @isLoggedIn + getUser(userId: UserID!): User + getUsers(userIds: [UserID!]!): [User]! +} + +### Mutations + +extend type Mutation { + updateUser(userId: UserID!, input: UpdateUser!): User! @canEditUser(field: "userId", object: false) @isLoggedIn + logout: Boolean! @isLoggedIn + + oAuthGithub(code: String!, state: String!): UserSession @isNotLoggedIn + oAuthGoogle(code: String!, state: String!): UserSession @isNotLoggedIn + oAuthFacebook(code: String!, state: String!): UserSession @isNotLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/version.graphql", Input: `### Types + +scalar VersionID + +type LatestVersions { + alpha: Version + beta: Version + release: Version +} + +enum VersionFields { + created_at + updated_at + downloads +} + +enum VersionStabilities { + alpha + beta + release +} + +type Version { + id: VersionID! + mod_id: ModID! + version: String! + sml_version: String! + changelog: String! + downloads: Int! + stability: VersionStabilities! + approved: Boolean! + updated_at: Date! + created_at: Date! + link: String! + targets: [VersionTarget]! + metadata: String + size: Int + hash: String + + mod: Mod! + dependencies: [VersionDependency!]! +} + +type VersionTarget { + VersionID: VersionID! + targetName: TargetName! + link: String! + size: Int + hash: String +} + +type CreateVersionResponse { + auto_approved: Boolean! + version: Version +} + +type GetVersions { + versions: [Version!]! + count: Int! +} + +type GetMyVersions { + versions: [Version!]! + count: Int! +} + +type VersionDependency { + version_id: VersionID! + mod_id: ModID! + condition: String! + optional: Boolean! + + mod: Mod + version: Version +} + +### Inputs + +input VersionFilter { + limit: Int + offset: Int + order_by: VersionFields + order: Order + search: String + ids: [String!] +} + +input NewVersion { + changelog: String! + stability: VersionStabilities! +} + +input UpdateVersion { + changelog: String + stability: VersionStabilities +} + +### Queries + +extend type Query { + getVersion(versionId: VersionID!): Version + getVersions(filter: VersionFilter): GetVersions! + getUnapprovedVersions(filter: VersionFilter): GetVersions! @canApproveVersions @isLoggedIn + + checkVersionUploadState(modId: ModID!, versionId: VersionID!): CreateVersionResponse @canEditMod(field: "modId") @isLoggedIn + + getMyVersions(filter: VersionFilter): GetMyVersions! @isLoggedIn + getMyUnapprovedVersions(filter: VersionFilter): GetMyVersions! @isLoggedIn +} + +### Mutations + +extend type Mutation { + createVersion(modId: ModID!): VersionID! @canEditMod(field: "modId") @isLoggedIn + uploadVersionPart(modId: ModID!, versionId: VersionID!, part: Int!, file: Upload!): Boolean! @canEditMod(field: "modId") @isLoggedIn + finalizeCreateVersion(modId: ModID!, versionId: VersionID!, version: NewVersion!): Boolean! @canEditMod(field: "modId") @isLoggedIn + + updateVersion(versionId: VersionID!, version: UpdateVersion!): Version! @canEditVersion(field: "versionId") @isLoggedIn + deleteVersion(versionId: VersionID!): Boolean! @canEditVersion(field: "versionId") @isLoggedIn + + approveVersion(versionId: VersionID!): Boolean! @canApproveVersions @isLoggedIn + denyVersion(versionId: VersionID!): Boolean! @canApproveVersions @isLoggedIn +}`, BuiltIn: false}, + {Name: "../schemas/version_target.graphql", Input: `enum TargetName { + Windows, + WindowsServer, + LinuxServer +}`, BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_canEditGuide_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["field"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["field"] = arg0 + return args, nil +} + +func (ec *executionContext) dir_canEditModCompatibility_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *string + if tmp, ok := rawArgs["field"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + arg0, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["field"] = arg0 + return args, nil +} + +func (ec *executionContext) dir_canEditMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["field"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["field"] = arg0 + return args, nil +} + +func (ec *executionContext) dir_canEditUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["field"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["field"] = arg0 + var arg1 bool + if tmp, ok := rawArgs["object"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("object")) + arg1, err = ec.unmarshalNBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["object"] = arg1 + return args, nil +} + +func (ec *executionContext) dir_canEditVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["field"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["field"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mod_version_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["version"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["version"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mod_versions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_approveMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_approveVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg0, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createAnnouncement_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 NewAnnouncement + if tmp, ok := rawArgs["announcement"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("announcement")) + arg0, err = ec.unmarshalNNewAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewAnnouncement(ctx, tmp) + if err != nil { + return nil, err + } + } + args["announcement"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createGuide_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 NewGuide + if tmp, ok := rawArgs["guide"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) + arg0, err = ec.unmarshalNNewGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewGuide(ctx, tmp) + if err != nil { + return nil, err + } + } + args["guide"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 NewMod + if tmp, ok := rawArgs["mod"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod")) + arg0, err = ec.unmarshalNNewMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewMod(ctx, tmp) + if err != nil { + return nil, err + } + } + args["mod"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createMultipleTags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []string + if tmp, ok := rawArgs["tagNames"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagNames")) + arg0, err = ec.unmarshalNTagName2ᚕstringᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tagNames"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createSMLVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 NewSMLVersion + if tmp, ok := rawArgs["smlVersion"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("smlVersion")) + arg0, err = ec.unmarshalNNewSMLVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersion(ctx, tmp) + if err != nil { + return nil, err + } + } + args["smlVersion"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createTag_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["tagName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagName")) + arg0, err = ec.unmarshalNTagName2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tagName"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteAnnouncement_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["announcementId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("announcementId")) + arg0, err = ec.unmarshalNAnnouncementID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["announcementId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteGuide_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["guideId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guideId")) + arg0, err = ec.unmarshalNGuideID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["guideId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteSMLVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["smlVersionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("smlVersionId")) + arg0, err = ec.unmarshalNSMLVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["smlVersionId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteTag_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["tagID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagID")) + arg0, err = ec.unmarshalNTagID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tagID"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_deleteVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg0, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_denyMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_denyVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg0, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_discourseSSO_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["sso"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sso")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["sso"] = arg0 + var arg1 string + if tmp, ok := rawArgs["sig"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sig")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["sig"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_finalizeCreateVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg1, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg1 + var arg2 NewVersion + if tmp, ok := rawArgs["version"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + arg2, err = ec.unmarshalNNewVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewVersion(ctx, tmp) + if err != nil { + return nil, err + } + } + args["version"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Mutation_oAuthFacebook_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["code"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("code")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["code"] = arg0 + var arg1 string + if tmp, ok := rawArgs["state"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["state"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_oAuthGithub_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["code"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("code")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["code"] = arg0 + var arg1 string + if tmp, ok := rawArgs["state"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["state"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_oAuthGoogle_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["code"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("code")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["code"] = arg0 + var arg1 string + if tmp, ok := rawArgs["state"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["state"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateAnnouncement_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["announcementId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("announcementId")) + arg0, err = ec.unmarshalNAnnouncementID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["announcementId"] = arg0 + var arg1 UpdateAnnouncement + if tmp, ok := rawArgs["announcement"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("announcement")) + arg1, err = ec.unmarshalNUpdateAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateAnnouncement(ctx, tmp) + if err != nil { + return nil, err + } + } + args["announcement"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateGuide_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["guideId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guideId")) + arg0, err = ec.unmarshalNGuideID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["guideId"] = arg0 + var arg1 UpdateGuide + if tmp, ok := rawArgs["guide"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) + arg1, err = ec.unmarshalNUpdateGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateGuide(ctx, tmp) + if err != nil { + return nil, err + } + } + args["guide"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateModCompatibility_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + var arg1 CompatibilityInfoInput + if tmp, ok := rawArgs["compatibility"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("compatibility")) + arg1, err = ec.unmarshalNCompatibilityInfoInput2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["compatibility"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + var arg1 UpdateMod + if tmp, ok := rawArgs["mod"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod")) + arg1, err = ec.unmarshalNUpdateMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateMod(ctx, tmp) + if err != nil { + return nil, err + } + } + args["mod"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateMultipleModCompatibilities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []string + if tmp, ok := rawArgs["modIDs"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIDs")) + arg0, err = ec.unmarshalNModID2ᚕstringᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modIDs"] = arg0 + var arg1 CompatibilityInfoInput + if tmp, ok := rawArgs["compatibility"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("compatibility")) + arg1, err = ec.unmarshalNCompatibilityInfoInput2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["compatibility"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateSMLVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["smlVersionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("smlVersionId")) + arg0, err = ec.unmarshalNSMLVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["smlVersionId"] = arg0 + var arg1 UpdateSMLVersion + if tmp, ok := rawArgs["smlVersion"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("smlVersion")) + arg1, err = ec.unmarshalNUpdateSMLVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersion(ctx, tmp) + if err != nil { + return nil, err + } + } + args["smlVersion"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateTag_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["tagID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagID")) + arg0, err = ec.unmarshalNTagID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tagID"] = arg0 + var arg1 string + if tmp, ok := rawArgs["NewName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("NewName")) + arg1, err = ec.unmarshalNTagName2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["NewName"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg0, err = ec.unmarshalNUserID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg0 + var arg1 UpdateUser + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg1, err = ec.unmarshalNUpdateUser2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUser(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_updateVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg0, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg0 + var arg1 UpdateVersion + if tmp, ok := rawArgs["version"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + arg1, err = ec.unmarshalNUpdateVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateVersion(ctx, tmp) + if err != nil { + return nil, err + } + } + args["version"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Mutation_uploadVersionPart_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg1, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg1 + var arg2 int + if tmp, ok := rawArgs["part"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("part")) + arg2, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["part"] = arg2 + var arg3 graphql.Upload + if tmp, ok := rawArgs["file"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("file")) + arg3, err = ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, tmp) + if err != nil { + return nil, err + } + } + args["file"] = arg3 + return args, nil +} + +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_checkVersionUploadState_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + var arg1 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg1, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Query_getAnnouncement_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["announcementId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("announcementId")) + arg0, err = ec.unmarshalNAnnouncementID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["announcementId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getAnnouncementsByImportance_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 AnnouncementImportance + if tmp, ok := rawArgs["importance"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("importance")) + arg0, err = ec.unmarshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, tmp) + if err != nil { + return nil, err + } + } + args["importance"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getGuide_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["guideId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guideId")) + arg0, err = ec.unmarshalNGuideID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["guideId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getGuides_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOGuideFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getModByIdOrReference_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modIdOrReference"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIdOrReference")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modIdOrReference"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getModByReference_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modReference"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modReference")) + arg0, err = ec.unmarshalNModReference2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modReference"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMod_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modId")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMods_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOModFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMyMods_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOModFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMyUnapprovedMods_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOModFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMyUnapprovedVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getMyVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getOAuthOptions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["callback_url"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("callback_url")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["callback_url"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getSMLVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["smlVersionID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("smlVersionID")) + arg0, err = ec.unmarshalNSMLVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["smlVersionID"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getSMLVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOSMLVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getTag_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["tagID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagID")) + arg0, err = ec.unmarshalNTagID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tagID"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getTags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *TagFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOTagFilter2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getUnapprovedMods_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOModFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getUnapprovedVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["userId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + arg0, err = ec.unmarshalNUserID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getUsers_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []string + if tmp, ok := rawArgs["userIds"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userIds")) + arg0, err = ec.unmarshalNUserID2ᚕstringᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["userIds"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getVersion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["versionId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("versionId")) + arg0, err = ec.unmarshalNVersionID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["versionId"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOVersionFilter2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_resolveModVersions_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*ModVersionConstraint + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNModVersionConstraint2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraintᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _Announcement_id(ctx context.Context, field graphql.CollectedField, obj *Announcement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Announcement_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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNAnnouncementID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Announcement_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Announcement", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type AnnouncementID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Announcement_message(ctx context.Context, field graphql.CollectedField, obj *Announcement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Announcement_message(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Message, 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_Announcement_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Announcement", + 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) _Announcement_importance(ctx context.Context, field graphql.CollectedField, obj *Announcement) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Announcement_importance(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Importance, 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.(AnnouncementImportance) + fc.Result = res + return ec.marshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Announcement_importance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Announcement", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type AnnouncementImportance does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Compatibility_state(ctx context.Context, field graphql.CollectedField, obj *Compatibility) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Compatibility_state(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.State, 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.(CompatibilityState) + fc.Result = res + return ec.marshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Compatibility_state(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Compatibility", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CompatibilityState does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Compatibility_note(ctx context.Context, field graphql.CollectedField, obj *Compatibility) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Compatibility_note(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Note, 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_Compatibility_note(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Compatibility", + 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) _CompatibilityInfo_EA(ctx context.Context, field graphql.CollectedField, obj *CompatibilityInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CompatibilityInfo_EA(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Ea, 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.(*Compatibility) + fc.Result = res + return ec.marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CompatibilityInfo_EA(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CompatibilityInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "state": + return ec.fieldContext_Compatibility_state(ctx, field) + case "note": + return ec.fieldContext_Compatibility_note(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Compatibility", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CompatibilityInfo_EXP(ctx context.Context, field graphql.CollectedField, obj *CompatibilityInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CompatibilityInfo_EXP(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Exp, 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.(*Compatibility) + fc.Result = res + return ec.marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CompatibilityInfo_EXP(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CompatibilityInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "state": + return ec.fieldContext_Compatibility_state(ctx, field) + case "note": + return ec.fieldContext_Compatibility_note(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Compatibility", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CreateVersionResponse_auto_approved(ctx context.Context, field graphql.CollectedField, obj *CreateVersionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateVersionResponse_auto_approved(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AutoApproved, 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_CreateVersionResponse_auto_approved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CreateVersionResponse", + 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) _CreateVersionResponse_version(ctx context.Context, field graphql.CollectedField, obj *CreateVersionResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateVersionResponse_version(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) (interface{}, error) { + 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 { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CreateVersionResponse_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CreateVersionResponse", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _GetGuides_guides(ctx context.Context, field graphql.CollectedField, obj *GetGuides) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetGuides_guides(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetGuides().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.([]*Guide) + fc.Result = res + return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetGuides_guides(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetGuides", + 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 fc, nil +} + +func (ec *executionContext) _GetGuides_count(ctx context.Context, field graphql.CollectedField, obj *GetGuides) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetGuides_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetGuides().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_GetGuides_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetGuides", + 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 { + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMods().Mods(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.([]*Mod) + fc.Result = res + return ec.marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetMods_mods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMods", + 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 "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 "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) _GetMods_count(ctx context.Context, field graphql.CollectedField, obj *GetMods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetMods_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMods().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_GetMods_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMods", + 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) _GetMyMods_mods(ctx context.Context, field graphql.CollectedField, obj *GetMyMods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetMyMods_mods(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMyMods().Mods(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.([]*Mod) + fc.Result = res + return ec.marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetMyMods_mods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMyMods", + 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 "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 "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) _GetMyMods_count(ctx context.Context, field graphql.CollectedField, obj *GetMyMods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetMyMods_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMyMods().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_GetMyMods_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMyMods", + 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) _GetMyVersions_versions(ctx context.Context, field graphql.CollectedField, obj *GetMyVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetMyVersions_versions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMyVersions().Versions(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.([]*Version) + fc.Result = res + return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetMyVersions_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMyVersions", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _GetMyVersions_count(ctx context.Context, field graphql.CollectedField, obj *GetMyVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetMyVersions_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetMyVersions().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_GetMyVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetMyVersions", + 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) _GetSMLVersions_sml_versions(ctx context.Context, field graphql.CollectedField, obj *GetSMLVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetSMLVersions_sml_versions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetSMLVersions().SmlVersions(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.([]*SMLVersion) + fc.Result = res + return ec.marshalNSMLVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetSMLVersions_sml_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetSMLVersions", + 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 nil, fmt.Errorf("no field named %q was found under type SMLVersion", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _GetSMLVersions_count(ctx context.Context, field graphql.CollectedField, obj *GetSMLVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetSMLVersions_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetSMLVersions().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_GetSMLVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetSMLVersions", + 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) _GetVersions_versions(ctx context.Context, field graphql.CollectedField, obj *GetVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetVersions_versions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetVersions().Versions(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.([]*Version) + fc.Result = res + return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GetVersions_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetVersions", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _GetVersions_count(ctx context.Context, field graphql.CollectedField, obj *GetVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetVersions_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.GetVersions().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_GetVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GetVersions", + 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) _Group_id(ctx context.Context, field graphql.CollectedField, obj *Group) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Group_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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Group_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Group", + 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) _Group_name(ctx context.Context, field graphql.CollectedField, obj *Group) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Group_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) (interface{}, 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_Group_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Group", + 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) _Guide_id(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNGuideID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Guide_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type GuideID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Guide_name(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_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) (interface{}, 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_Guide_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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) _Guide_short_description(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_short_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ShortDescription, 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_Guide_short_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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) _Guide_guide(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_guide(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Guide, 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_Guide_guide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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) _Guide_views(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_views(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Views, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Guide_views(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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 fc, nil +} + +func (ec *executionContext) _Guide_user_id(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_user_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNUserID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Guide_user_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + Field: field, + IsMethod: false, + IsResolver: false, + 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 fc, nil +} + +func (ec *executionContext) _Guide_updated_at(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_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) (interface{}, 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 { + 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_Guide_updated_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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) _Guide_created_at(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_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) (interface{}, 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_Guide_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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) _Guide_tags(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_tags(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tags, 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) + fc.Result = res + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Guide_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Guide_user(ctx context.Context, field graphql.CollectedField, obj *Guide) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Guide_user(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Guide().User(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.(*User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Guide_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Guide", + 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 "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) _LatestVersions_alpha(ctx context.Context, field graphql.CollectedField, obj *LatestVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LatestVersions_alpha(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Alpha, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LatestVersions_alpha(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LatestVersions", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LatestVersions_beta(ctx context.Context, field graphql.CollectedField, obj *LatestVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LatestVersions_beta(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Beta, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LatestVersions_beta(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LatestVersions", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LatestVersions_release(ctx context.Context, field graphql.CollectedField, obj *LatestVersions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LatestVersions_release(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Release, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LatestVersions_release(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LatestVersions", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mod_id(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNModID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 fc, nil +} + +func (ec *executionContext) _Mod_name(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_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) (interface{}, 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_Mod_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_short_description(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_short_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ShortDescription, 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_Mod_short_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_full_description(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_full_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FullDescription, 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_Mod_full_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_logo(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_logo(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) (interface{}, error) { + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_logo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_source_url(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_source_url(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SourceURL, 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_Mod_source_url(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_creator_id(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_creator_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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatorID, 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.marshalNUserID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_creator_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + Field: field, + IsMethod: false, + IsResolver: false, + 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 fc, nil +} + +func (ec *executionContext) _Mod_approved(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_approved(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Approved, 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_Mod_approved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_views(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_views(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Views, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_views(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 fc, nil +} + +func (ec *executionContext) _Mod_downloads(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_downloads(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Downloads, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_downloads(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 fc, nil +} + +func (ec *executionContext) _Mod_hotness(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_hotness(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) (interface{}, error) { + 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_hotness(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 fc, nil +} + +func (ec *executionContext) _Mod_popularity(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_popularity(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Popularity, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_popularity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 fc, nil +} + +func (ec *executionContext) _Mod_updated_at(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_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) (interface{}, 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 { + 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_Mod_updated_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_created_at(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_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) (interface{}, 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_Mod_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_last_version_date(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_last_version_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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastVersionDate, 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_Mod_last_version_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_mod_reference(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_mod_reference(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNModReference2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_mod_reference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ModReference does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Mod_hidden(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_hidden(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hidden, 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_Mod_hidden(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) _Mod_tags(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_tags(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tags, nil + }) + 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) +} + +func (ec *executionContext) fieldContext_Mod_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mod_compatibility(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_compatibility(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Compatibility, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CompatibilityInfo) + fc.Result = res + return ec.marshalOCompatibilityInfo2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_compatibility(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "EA": + return ec.fieldContext_CompatibilityInfo_EA(ctx, field) + case "EXP": + return ec.fieldContext_CompatibilityInfo_EXP(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CompatibilityInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mod_authors(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_authors(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mod().Authors(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.([]*UserMod) + fc.Result = res + return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_authors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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) + } + return nil, fmt.Errorf("no field named %q was found under type UserMod", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mod_version(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_version(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mod().Version(rctx, obj, fc.Args["version"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 "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) + } + 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_Mod_version_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mod_versions(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_versions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mod().Versions(rctx, obj, 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.([]*Version) + fc.Result = res + return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + 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 "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) + } + 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_Mod_versions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mod_latestVersions(ctx context.Context, field graphql.CollectedField, obj *Mod) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mod_latestVersions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mod().LatestVersions(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.(*LatestVersions) + fc.Result = res + return ec.marshalNLatestVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mod_latestVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mod", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "alpha": + return ec.fieldContext_LatestVersions_alpha(ctx, field) + case "beta": + return ec.fieldContext_LatestVersions_beta(ctx, field) + case "release": + return ec.fieldContext_LatestVersions_release(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LatestVersions", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ModVersion_id(ctx context.Context, field graphql.CollectedField, obj *ModVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModVersion_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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNModID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ModVersion_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModVersion", + 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 fc, nil +} + +func (ec *executionContext) _ModVersion_mod_reference(ctx context.Context, field graphql.CollectedField, obj *ModVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModVersion_mod_reference(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNModReference2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ModVersion_mod_reference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModVersion", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ModReference does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModVersion_versions(ctx context.Context, field graphql.CollectedField, obj *ModVersion) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModVersion_versions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Versions, 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.([]*Version) + fc.Result = res + return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ModVersion_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModVersion", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + 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_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 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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanEditAnnouncements == nil { + return nil, errors.New("directive canEditAnnouncements is not implemented") + } + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Announcement) + fc.Result = res + return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) +} + +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) { + 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() { + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanEditAnnouncements == nil { + return nil, errors.New("directive canEditAnnouncements is not implemented") + } + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + 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) + fc.Result = res + return ec.marshalNAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateAnnouncement(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) { + 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() { + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanEditAnnouncements == nil { + return nil, errors.New("directive canEditAnnouncements is not implemented") + } + return ec.directives.CanEditAnnouncements(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteAnnouncement(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") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalOString2ᚖstring(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditModCompatibility == nil { + return nil, errors.New("directive canEditModCompatibility is not implemented") + } + return ec.directives.CanEditModCompatibility(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateModCompatibility(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") + }, + } + 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_updateModCompatibility_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanEditModCompatibility == nil { + return nil, errors.New("directive canEditModCompatibility is not implemented") + } + return ec.directives.CanEditModCompatibility(ctx, nil, directive0, nil) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateMultipleModCompatibilities(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") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*Guide) + fc.Result = res + return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createGuide(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) { + 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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "guideId") + if err != nil { + return nil, err + } + if ec.directives.CanEditGuide == nil { + return nil, errors.New("directive canEditGuide is not implemented") + } + return ec.directives.CanEditGuide(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Guide) + fc.Result = res + return ec.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateGuide(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) { + 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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "guideId") + if err != nil { + return nil, err + } + if ec.directives.CanEditGuide == nil { + return nil, errors.New("directive canEditGuide is not implemented") + } + return ec.directives.CanEditGuide(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteGuide(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") + }, + } + 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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*Mod) + fc.Result = res + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createMod(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) { + 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 "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 "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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*Mod) + fc.Result = res + return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateMod(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) { + 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 "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 "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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteMod(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") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanApproveMods == nil { + return nil, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_approveMod(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") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanApproveMods == nil { + return nil, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_denyMod(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") + }, + } + 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_denyMod_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createSMLVersion(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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateSMLVersion(rctx, fc.Args["smlVersion"].(NewSMLVersion)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*SMLVersion); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SMLVersion`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*SMLVersion) + fc.Result = res + return ec.marshalOSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createSMLVersion(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) { + 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_Mutation_createSMLVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateSMLVersion(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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateSMLVersion(rctx, fc.Args["smlVersionId"].(string), fc.Args["smlVersion"].(UpdateSMLVersion)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanEditSMLVersions == nil { + return nil, errors.New("directive canEditSMLVersions is not implemented") + } + return ec.directives.CanEditSMLVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*SMLVersion); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/satisfactorymodding/smr-api/generated.SMLVersion`, 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) + fc.Result = res + return ec.marshalNSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateSMLVersion(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) { + 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_Mutation_updateSMLVersion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteSMLVersion(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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteSMLVersion(rctx, fc.Args["smlVersionId"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanEditSMLVersions == nil { + return nil, errors.New("directive canEditSMLVersions is not implemented") + } + return ec.directives.CanEditSMLVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteSMLVersion(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") + }, + } + 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_deleteSMLVersion_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*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 { + return graphql.Null + } + res := resTmp.(*Tag) + fc.Result = res + return ec.marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createTag(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) { + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateMultipleTags(rctx, fc.Args["tagNames"].([]string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanManageTags == nil { + return nil, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.([]*Tag) + fc.Result = res + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createMultipleTags(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) { + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["tagID"].(string), fc.Args["NewName"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanManageTags == nil { + return nil, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*Tag) + fc.Result = res + return ec.marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateTag(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) { + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(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_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanManageTags == nil { + return nil, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteTag(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") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "userId") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, nil, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + 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) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateUser(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) { + 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 "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) + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().Logout(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + 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_Mutation_logout(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 fc, nil +} + +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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsNotLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*UserSession) + fc.Result = res + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_oAuthGithub(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) { + 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) + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsNotLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*UserSession) + fc.Result = res + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_oAuthGoogle(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) { + 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) + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsNotLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*UserSession) + fc.Result = res + return ec.marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_oAuthFacebook(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) { + 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) + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + }) + 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.marshalNVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createVersion(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 VersionID 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_uploadVersionPart(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") + }, + } + 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_uploadVersionPart_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_finalizeCreateVersion(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") + }, + } + 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_finalizeCreateVersion_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateVersion(rctx, fc.Args["versionId"].(string), fc.Args["version"].(UpdateVersion)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "versionId") + if err != nil { + return nil, err + } + if ec.directives.CanEditVersion == nil { + return nil, errors.New("directive canEditVersion is not implemented") + } + return ec.directives.CanEditVersion(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*Version); ok { + return data, nil + } + 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalNVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updateVersion(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) { + 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 "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) + } + 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_Mutation_updateVersion_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "versionId") + if err != nil { + return nil, err + } + if ec.directives.CanEditVersion == nil { + return nil, errors.New("directive canEditVersion is not implemented") + } + return ec.directives.CanEditVersion(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteVersion(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") + }, + } + 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_deleteVersion_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().ApproveVersion(rctx, fc.Args["versionId"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanApproveVersions == nil { + return nil, errors.New("directive canApproveVersions is not implemented") + } + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_approveVersion(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") + }, + } + 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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanApproveVersions == nil { + return nil, errors.New("directive canApproveVersions is not implemented") + } + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_denyVersion(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") + }, + } + 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Github, 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_OAuthOptions_github(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Google, 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_OAuthOptions_google(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Facebook, 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_OAuthOptions_facebook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetOAuthOptions(rctx, fc.Args["callback_url"].(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.(*OAuthOptions) + fc.Result = res + return ec.marshalNOAuthOptions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOAuthOptions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getOAuthOptions(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 "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 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetAnnouncement(rctx, fc.Args["announcementId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Announcement) + fc.Result = res + return ec.marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getAnnouncement(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_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() { + 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_getAnnouncement_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) + 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) (interface{}, 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") + } + 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(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_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) _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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetAnnouncementsByImportance(rctx, fc.Args["importance"].(AnnouncementImportance)) + }) + 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) + fc.Result = res + return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getAnnouncementsByImportance(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_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() { + 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_getAnnouncementsByImportance_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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetGuide(rctx, fc.Args["guideId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Guide) + fc.Result = res + return ec.marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getGuide(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_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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetGuides(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.(*GetGuides) + fc.Result = res + return ec.marshalNGetGuides2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetGuides(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getGuides(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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMod(rctx, fc.Args["modId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Mod) + fc.Result = res + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMod(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_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 "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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetModByReference(rctx, fc.Args["modReference"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Mod) + fc.Result = res + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getModByReference(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_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 "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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetModByIDOrReference(rctx, fc.Args["modIdOrReference"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Mod) + fc.Result = res + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getModByIdOrReference(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_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 "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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMods(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.(*GetMods) + fc.Result = res + return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMods(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 "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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanApproveMods == nil { + return nil, errors.New("directive canApproveMods is not implemented") + } + return ec.directives.CanApproveMods(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetMods) + fc.Result = res + return ec.marshalNGetMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getUnapprovedMods(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 "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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetMyMods) + fc.Result = res + return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMyMods(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 "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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetMyMods) + fc.Result = res + return ec.marshalNGetMyMods2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyMods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMyUnapprovedMods(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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ResolveModVersions(rctx, fc.Args["filter"].([]*ModVersionConstraint)) + }) + 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.([]*ModVersion) + fc.Result = res + return ec.marshalNModVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_resolveModVersions(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_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) _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 + } + 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) (interface{}, error) { + 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) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*SMLVersion) + fc.Result = res + return ec.marshalOSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getSMLVersion(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_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) _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 + } + 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) (interface{}, error) { + 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.(*GetSMLVersions) + fc.Result = res + return ec.marshalNGetSMLVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetSMLVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getSMLVersions(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 "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) _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 + } + 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) (interface{}, 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) +} + +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) + } + 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) _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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*Tag) + fc.Result = res + return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getTags(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) + } + 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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetMe(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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.(*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) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMe(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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetUser(rctx, fc.Args["userId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getUser(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 "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) + }, + } + 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) _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 + } + 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) (interface{}, 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") + } + 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 "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) + }, + } + 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) _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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetVersion(rctx, fc.Args["versionId"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getVersion(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_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 "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) + } + 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetVersions(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.(*GetVersions) + fc.Result = res + return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getVersions(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 "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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.CanApproveVersions == nil { + return nil, errors.New("directive canApproveVersions is not implemented") + } + return ec.directives.CanApproveVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetVersions) + fc.Result = res + return ec.marshalNGetVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getUnapprovedVersions(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 "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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "modId") + if err != nil { + return nil, err + } + if ec.directives.CanEditMod == nil { + return nil, errors.New("directive canEditMod is not implemented") + } + return ec.directives.CanEditMod(ctx, nil, directive0, field) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*CreateVersionResponse) + fc.Result = res + return ec.marshalOCreateVersionResponse2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCreateVersionResponse(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_checkVersionUploadState(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 "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) + }, + } + 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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetMyVersions) + fc.Result = res + return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMyVersions(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 "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_getMyVersions_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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, 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) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*GetMyVersions) + fc.Result = res + return ec.marshalNGetMyVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGetMyVersions(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getMyUnapprovedVersions(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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + 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_Query___type(ctx 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 "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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", 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___type_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) + 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) (interface{}, 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) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx 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) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersion_id(ctx 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 SMLVersionID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + 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.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersion_version(ctx 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SatisfactoryVersion, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersion_satisfactory_version(ctx 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 Int 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Stability, 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.(VersionStabilities) + fc.Result = res + return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersion_stability(ctx 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 VersionStabilities 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Link, 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_SMLVersion_link(ctx 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + 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.([]*SMLVersionTarget) + fc.Result = res + return ec.marshalNSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersion_targets(ctx 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) { + 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Changelog, 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_SMLVersion_changelog(ctx 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 String does not have child fields") + }, + } + 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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Date, 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_SMLVersion_date(ctx 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, 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.BootstrapVersion, 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_SMLVersion_bootstrap_version(ctx 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EngineVersion, 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_SMLVersion_engine_version(ctx 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 String does not have child fields") + }, + } + 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 + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, 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 { + 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(ctx 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, 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) + 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) (interface{}, 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_SMLVersion_created_at(ctx 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, 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) + 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) (interface{}, 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.marshalNSMLVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersionTarget_VersionID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 SMLVersionID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.(TargetName) + fc.Result = res + return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SMLVersionTarget_targetName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 TargetName does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Link, 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_SMLVersionTarget_link(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNTagID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 TagID does not have child fields") + }, + } + 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) + 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) (interface{}, 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.marshalNTagName2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 TagName does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNUserID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 UserID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Email, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Username, 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_User_username(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Avatar, 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_User_avatar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, 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_User_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Date does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GithubID, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_github_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.GoogleID, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_google_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FacebookID, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_facebook_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Roles(rctx, obj) + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*UserRoles) + fc.Result = res + return ec.marshalNUserRoles2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_roles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + 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 "editSMLVersions": + return ec.fieldContext_UserRoles_editSMLVersions(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) _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 + } + 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) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Groups(rctx, obj) + } + directive1 := func(ctx context.Context) (interface{}, error) { + field, err := ec.unmarshalNString2string(ctx, "ID") + if err != nil { + return nil, err + } + object, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.CanEditUser == nil { + return nil, errors.New("directive canEditUser is not implemented") + } + return ec.directives.CanEditUser(ctx, obj, directive0, field, object) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, 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) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*Group) + fc.Result = res + return ec.marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + 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 nil, fmt.Errorf("no field named %q was found under type Group", 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Mods(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.([]*UserMod) + fc.Result = res + return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_mods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + 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) + } + return nil, fmt.Errorf("no field named %q was found under type UserMod", field.Name) + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.([]*Guide) + fc.Result = res + return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_guides(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNUserID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserMod_user_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 UserID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ModID, 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.marshalNModID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserMod_mod_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 ModID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Role, 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_UserMod_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.UserMod().User(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.(*User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserMod_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserMod", + 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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.UserMod().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") + } + 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_UserMod_mod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserMod", + 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 "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 "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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ApproveMods, 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_UserRoles_approveMods(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ApproveVersions, 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_UserRoles_approveVersions(ctx 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") + }, + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserRoles_deleteContent(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EditContent, 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_UserRoles_editContent(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserRoles_editUsers(ctx 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") + }, + } + return fc, nil +} + +func (ec *executionContext) _UserRoles_editSMLVersions(ctx context.Context, field graphql.CollectedField, obj *UserRoles) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserRoles_editSMLVersions(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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EditSMLVersions, 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_UserRoles_editSMLVersions(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EditBootstrapVersions, 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_UserRoles_editBootstrapVersions(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EditAnyModCompatibility, 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_UserRoles_editAnyModCompatibility(ctx 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") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Token, 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_UserSession_token(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserSession", + 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) _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 + } + 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) (interface{}, error) { + 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) + fc.Result = res + return ec.marshalNVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 VersionID does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ModID, 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.marshalNModID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_mod_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 ModID 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) + 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) (interface{}, error) { + 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.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SmlVersion, 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_Version_sml_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Changelog, 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_Version_changelog(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Downloads, 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) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_downloads(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Int 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Stability, 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.(VersionStabilities) + fc.Result = res + return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_stability(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 VersionStabilities 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Approved, 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_Version_approved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Boolean 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) + 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) (interface{}, 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 { + 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_Version_updated_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Date 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) + 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) (interface{}, 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_Version_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Date 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_link(ctx 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) { + return nil, errors.New("field of type String does not have child fields") + }, + } + 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) + 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) (interface{}, error) { + 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.([]*VersionTarget) + fc.Result = res + return ec.marshalNVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_targets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Version", + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Metadata, 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_Version_metadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Version().Size(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int) + fc.Result = res + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Version_size(ctx 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) { + return nil, errors.New("field of type Int 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Version().Hash(rctx, obj) + }) + 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_Version_hash(ctx 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) { + return nil, errors.New("field of type String 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) + 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) (interface{}, 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") + } + 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(ctx 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 "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 "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) _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) (interface{}, 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") + } + 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(ctx 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": + 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 VersionDependency", field.Name) + }, + } + 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) + 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) (interface{}, 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.marshalNVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_version_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ModID, 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.marshalNModID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_mod_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_condition(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_optional(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Mod, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Mod) + fc.Result = res + return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_mod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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_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 "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 "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) _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 + } + 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) (interface{}, error) { + 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 { + return graphql.Null + } + res := resTmp.(*Version) + fc.Result = res + return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionDependency_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionDependency", + 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 "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) + } + return nil, fmt.Errorf("no field named %q was found under type Version", field.Name) + }, + } + 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) + 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) (interface{}, 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.marshalNVersionID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionTarget_VersionID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionTarget", + 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 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + 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.(TargetName) + fc.Result = res + return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionTarget_targetName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionTarget", + Field: field, + IsMethod: false, + IsResolver: false, + 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 +} + +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 { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, 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 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(ctx 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) _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 + } + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int) + fc.Result = res + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionTarget_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionTarget", + 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 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) + 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) (interface{}, 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionTarget_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionTarget", + 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_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) (interface{}, 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(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) { + 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) (interface{}, 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(ctx 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_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) (interface{}, 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(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) { + 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) (interface{}, 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) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + 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) (interface{}, 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(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) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(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) { + 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) (interface{}, 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(ctx 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) (interface{}, 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) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + 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) (interface{}, 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(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 "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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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) ___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) (interface{}, 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(ctx 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) (interface{}, 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(ctx 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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(ctx 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 "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(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) (interface{}, 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(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) { + 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) (interface{}, 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(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) { + 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) (interface{}, 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(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) { + 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) (interface{}, 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) (interface{}, 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(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 "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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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(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 "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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(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) (interface{}, 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) (interface{}, 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(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___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) + } + 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) (interface{}, 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(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 "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 "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 "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + 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) (interface{}, 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(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) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputCompatibilityInfoInput(ctx context.Context, obj interface{}) (CompatibilityInfoInput, error) { + var it CompatibilityInfoInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"EA", "EXP"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "EA": + var err error + + 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": + var err error + + 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 interface{}) (CompatibilityInput, error) { + var it CompatibilityInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"state", "note"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "state": + var err error + + 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": + var err error + + 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) unmarshalInputModVersionConstraint(ctx context.Context, obj interface{}) (ModVersionConstraint, error) { + var it ModVersionConstraint + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"modIdOrReference", "version"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "modIdOrReference": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIdOrReference")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.ModIDOrReference = data + case "version": + var err error + + 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) unmarshalInputNewAnnouncement(ctx context.Context, obj interface{}) (NewAnnouncement, error) { + var it NewAnnouncement + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"message", "importance"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "message": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Message = data + case "importance": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("importance")) + data, err := ec.unmarshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, v) + if err != nil { + return it, err + } + it.Importance = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputNewGuide(ctx context.Context, obj interface{}) (NewGuide, error) { + var it NewGuide + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "guide", "tagIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + 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": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.ShortDescription = data + case "guide": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Guide = data + case "tagIDs": + var err error + + 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) unmarshalInputNewMod(ctx context.Context, obj interface{}) (NewMod, error) { + var it NewMod + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "full_description", "logo", "source_url", "mod_reference", "hidden", "tagIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + 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": + var err error + + 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": + var err error + + 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": + var err error + + 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 "source_url": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("source_url")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SourceURL = data + case "mod_reference": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod_reference")) + data, err := ec.unmarshalNModReference2string(ctx, v) + if err != nil { + return it, err + } + it.ModReference = data + case "hidden": + var err error + + 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": + var err error + + 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) unmarshalInputNewSMLVersion(ctx context.Context, obj interface{}) (NewSMLVersion, error) { + var it NewSMLVersion + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"version", "satisfactory_version", "stability", "link", "targets", "changelog", "date", "bootstrap_version", "engine_version"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Version = data + case "satisfactory_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfactory_version")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.SatisfactoryVersion = data + case "stability": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) + data, err := ec.unmarshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) + if err != nil { + return it, err + } + it.Stability = data + case "link": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Link = data + case "targets": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) + data, err := ec.unmarshalNNewSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersionTargetᚄ(ctx, v) + if err != nil { + return it, err + } + it.Targets = data + case "changelog": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Changelog = data + case "date": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("date")) + data, err := ec.unmarshalNDate2string(ctx, v) + if err != nil { + return it, err + } + it.Date = data + case "bootstrap_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bootstrap_version")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BootstrapVersion = data + case "engine_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("engine_version")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.EngineVersion = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputNewSMLVersionTarget(ctx context.Context, obj interface{}) (NewSMLVersionTarget, error) { + var it NewSMLVersionTarget + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"targetName", "link"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "targetName": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetName")) + data, err := ec.unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, v) + if err != nil { + return it, err + } + it.TargetName = data + case "link": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Link = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputNewVersion(ctx context.Context, obj interface{}) (NewVersion, error) { + var it NewVersion + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"changelog", "stability"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "changelog": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Changelog = data + case "stability": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) + data, err := ec.unmarshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) + if err != nil { + return it, err + } + it.Stability = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj interface{}) (TagFilter, error) { + var it TagFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order", "search", "ids"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "limit": + var err error + + 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": + var err error + + 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": + var err error + + 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": + var err error + + 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": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) + data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Ids = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateAnnouncement(ctx context.Context, obj interface{}) (UpdateAnnouncement, error) { + var it UpdateAnnouncement + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"message", "importance"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "message": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Message = data + case "importance": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("importance")) + data, err := ec.unmarshalOAnnouncementImportance2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, v) + if err != nil { + return it, err + } + it.Importance = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateGuide(ctx context.Context, obj interface{}) (UpdateGuide, error) { + var it UpdateGuide + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "guide", "tagIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + 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": + var err error + + 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 "guide": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Guide = data + case "tagIDs": + var err error + + 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) unmarshalInputUpdateMod(ctx context.Context, obj interface{}) (UpdateMod, error) { + var it UpdateMod + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "short_description", "full_description", "logo", "source_url", "mod_reference", "authors", "hidden", "tagIDs", "compatibility"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + 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": + var err error + + 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": + var err error + + 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": + var err error + + 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 "source_url": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("source_url")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SourceURL = data + case "mod_reference": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod_reference")) + data, err := ec.unmarshalOModReference2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ModReference = data + case "authors": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authors")) + data, err := ec.unmarshalOUpdateUserMod2ᚕgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUserModᚄ(ctx, v) + if err != nil { + return it, err + } + it.Authors = data + case "hidden": + var err error + + 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": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) + data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.TagIDs = data + case "compatibility": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("compatibility")) + data, err := ec.unmarshalOCompatibilityInfoInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx, v) + if err != nil { + return it, err + } + it.Compatibility = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, obj interface{}) (UpdateSMLVersion, error) { + var it UpdateSMLVersion + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"version", "satisfactory_version", "stability", "link", "targets", "changelog", "date", "bootstrap_version", "engine_version"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Version = data + case "satisfactory_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfactory_version")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SatisfactoryVersion = data + case "stability": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) + data, err := ec.unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) + if err != nil { + return it, err + } + it.Stability = data + case "link": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Link = data + case "targets": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) + data, err := ec.unmarshalNUpdateSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersionTarget(ctx, v) + if err != nil { + return it, err + } + it.Targets = data + case "changelog": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Changelog = data + case "date": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("date")) + data, err := ec.unmarshalODate2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Date = data + case "bootstrap_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bootstrap_version")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.BootstrapVersion = data + case "engine_version": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("engine_version")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EngineVersion = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateSMLVersionTarget(ctx context.Context, obj interface{}) (UpdateSMLVersionTarget, error) { + var it UpdateSMLVersionTarget + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"targetName", "link"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "targetName": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetName")) + data, err := ec.unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, v) + if err != nil { + return it, err + } + it.TargetName = data + case "link": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Link = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateUser(ctx context.Context, obj interface{}) (UpdateUser, error) { + var it UpdateUser + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"avatar", "groups", "username"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "avatar": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("avatar")) + data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) + if err != nil { + return it, err + } + it.Avatar = data + case "groups": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groups")) + directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanEditUsers == nil { + return nil, errors.New("directive canEditUsers is not implemented") + } + return ec.directives.CanEditUsers(ctx, obj, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedIn == nil { + return nil, errors.New("directive isLoggedIn is not implemented") + } + return ec.directives.IsLoggedIn(ctx, obj, directive1) + } + + tmp, err := directive2(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.Groups = data + } else if tmp == nil { + it.Groups = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "username": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Username = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateUserMod(ctx context.Context, obj interface{}) (UpdateUserMod, error) { + var it UpdateUserMod + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"user_id", "role"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "user_id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("user_id")) + data, err := ec.unmarshalNUserID2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "role": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Role = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateVersion(ctx context.Context, obj interface{}) (UpdateVersion, error) { + var it UpdateVersion + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"changelog", "stability"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "changelog": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Changelog = data + case "stability": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) + data, err := ec.unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) + if err != nil { + return it, err + } + it.Stability = 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 + } + + 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 compatibilityInfoImplementors = []string{"CompatibilityInfo"} + +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("CompatibilityInfo") + case "EA": + out.Values[i] = ec._CompatibilityInfo_EA(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "EXP": + out.Values[i] = ec._CompatibilityInfo_EXP(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 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)) + } + } + 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 getGuidesImplementors = []string{"GetGuides"} + +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 getModsImplementors = []string{"GetMods"} + +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("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 + } + + 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)) + } + } + 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 getMyModsImplementors = []string{"GetMyMods"} + +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("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 + } + + 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)) + } + } + 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 getMyVersionsImplementors = []string{"GetMyVersions"} + +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("GetMyVersions") + 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._GetMyVersions_versions(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._GetMyVersions_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 getSMLVersionsImplementors = []string{"GetSMLVersions"} + +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("GetSMLVersions") + case "sml_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._GetSMLVersions_sml_versions(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._GetSMLVersions_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 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 + + 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._GetVersions_versions(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._GetVersions_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 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)) + } + } + 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) + 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.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)) + } + } + 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 modImplementors = []string{"Mod"} + +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("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 "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 "authors": + 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_authors(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 "version": + 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_version(ctx, field, obj) + 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 "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 + } + + 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 "latestVersions": + 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_latestVersions(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 modVersionImplementors = []string{"ModVersion"} + +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("ModVersion") + case "id": + out.Values[i] = ec._ModVersion_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) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "versions": + out.Values[i] = ec._ModVersion_versions(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 mutationImplementors = []string{"Mutation"} + +func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Mutation", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Mutation") + case "discourseSSO": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_discourseSSO(ctx, field) + }) + case "createAnnouncement": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createAnnouncement(ctx, field) + }) + case "updateAnnouncement": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateAnnouncement(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteAnnouncement": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteAnnouncement(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateModCompatibility": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateModCompatibility(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateMultipleModCompatibilities": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateMultipleModCompatibilities(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createGuide": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createGuide(ctx, field) + }) + case "updateGuide": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateGuide(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteGuide": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteGuide(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createMod": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createMod(ctx, field) + }) + case "updateMod": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateMod(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteMod": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteMod(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "approveMod": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_approveMod(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "denyMod": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_denyMod(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createSMLVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createSMLVersion(ctx, field) + }) + case "updateSMLVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateSMLVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteSMLVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteSMLVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createTag": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createTag(ctx, field) + }) + case "createMultipleTags": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createMultipleTags(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateTag": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateTag(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteTag": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteTag(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateUser": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateUser(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "logout": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_logout(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "oAuthGithub": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_oAuthGithub(ctx, field) + }) + case "oAuthGoogle": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_oAuthGoogle(ctx, field) + }) + case "oAuthFacebook": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_oAuthFacebook(ctx, field) + }) + case "createVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "uploadVersionPart": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_uploadVersionPart(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "finalizeCreateVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_finalizeCreateVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "approveVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_approveVersion(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "denyVersion": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_denyVersion(ctx, field) + }) + 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 oAuthOptionsImplementors = []string{"OAuthOptions"} + +func (ec *executionContext) _OAuthOptions(ctx context.Context, sel ast.SelectionSet, obj *OAuthOptions) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, oAuthOptionsImplementors) + + 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("OAuthOptions") + case "github": + out.Values[i] = ec._OAuthOptions_github(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "google": + out.Values[i] = ec._OAuthOptions_google(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "facebook": + out.Values[i] = ec._OAuthOptions_facebook(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 queryImplementors = []string{"Query"} + +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "getOAuthOptions": + 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_getOAuthOptions(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 "getAnnouncement": + 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_getAnnouncement(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 "getAnnouncements": + 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_getAnnouncements(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 "getAnnouncementsByImportance": + 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_getAnnouncementsByImportance(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 "getGuide": + 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_getGuide(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 "getGuides": + 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_getGuides(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 "getMod": + 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_getMod(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 "getModByReference": + 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_getModByReference(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 "getModByIdOrReference": + 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_getModByIdOrReference(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 "getMods": + 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_getMods(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 "getUnapprovedMods": + 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_getUnapprovedMods(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 "getMyMods": + 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_getMyMods(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 "getMyUnapprovedMods": + 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_getMyUnapprovedMods(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 "resolveModVersions": + 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_resolveModVersions(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 "getSMLVersion": + 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_getSMLVersion(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 "getSMLVersions": + 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_getSMLVersions(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 "getTag": + 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_getTag(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 "getTags": + 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_getTags(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 "getMe": + 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_getMe(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 "getUser": + 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_getUser(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 "getUsers": + 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_getUsers(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 "getVersion": + 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_getVersion(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 "getVersions": + 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_getVersions(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 "getUnapprovedVersions": + 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_getUnapprovedVersions(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 "checkVersionUploadState": + 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_checkVersionUploadState(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 "getMyVersions": + 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_getMyVersions(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 "getMyUnapprovedVersions": + 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_getMyUnapprovedVersions(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 "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + 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 sMLVersionImplementors = []string{"SMLVersion"} + +func (ec *executionContext) _SMLVersion(ctx context.Context, sel ast.SelectionSet, obj *SMLVersion) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sMLVersionImplementors) + + 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("SMLVersion") + case "id": + out.Values[i] = ec._SMLVersion_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "version": + out.Values[i] = ec._SMLVersion_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "satisfactory_version": + out.Values[i] = ec._SMLVersion_satisfactory_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "stability": + out.Values[i] = ec._SMLVersion_stability(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "link": + out.Values[i] = ec._SMLVersion_link(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "targets": + out.Values[i] = ec._SMLVersion_targets(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "changelog": + out.Values[i] = ec._SMLVersion_changelog(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "date": + out.Values[i] = ec._SMLVersion_date(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "bootstrap_version": + out.Values[i] = ec._SMLVersion_bootstrap_version(ctx, field, obj) + case "engine_version": + out.Values[i] = ec._SMLVersion_engine_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updated_at": + out.Values[i] = ec._SMLVersion_updated_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "created_at": + out.Values[i] = ec._SMLVersion_created_at(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 sMLVersionTargetImplementors = []string{"SMLVersionTarget"} + +func (ec *executionContext) _SMLVersionTarget(ctx context.Context, sel ast.SelectionSet, obj *SMLVersionTarget) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sMLVersionTargetImplementors) + + 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("SMLVersionTarget") + case "VersionID": + out.Values[i] = ec._SMLVersionTarget_VersionID(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "targetName": + out.Values[i] = ec._SMLVersionTarget_targetName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "link": + out.Values[i] = ec._SMLVersionTarget_link(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 tagImplementors = []string{"Tag"} + +func (ec *executionContext) _Tag(ctx context.Context, sel ast.SelectionSet, obj *Tag) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, tagImplementors) + + 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("Tag") + case "id": + out.Values[i] = ec._Tag_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._Tag_name(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 userImplementors = []string{"User"} + +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + + 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("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "email": + out.Values[i] = ec._User_email(ctx, field, obj) + case "username": + out.Values[i] = ec._User_username(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "avatar": + out.Values[i] = ec._User_avatar(ctx, field, obj) + case "created_at": + out.Values[i] = ec._User_created_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "github_id": + out.Values[i] = ec._User_github_id(ctx, field, obj) + case "google_id": + out.Values[i] = ec._User_google_id(ctx, field, obj) + case "facebook_id": + out.Values[i] = ec._User_facebook_id(ctx, field, obj) + case "roles": + 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._User_roles(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 "groups": + 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._User_groups(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 "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._User_mods(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 "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._User_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) }) + 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 userModImplementors = []string{"UserMod"} + +func (ec *executionContext) _UserMod(ctx context.Context, sel ast.SelectionSet, obj *UserMod) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, userModImplementors) + + 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("UserMod") + case "user_id": + out.Values[i] = ec._UserMod_user_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mod_id": + out.Values[i] = ec._UserMod_mod_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "role": + out.Values[i] = ec._UserMod_role(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._UserMod_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.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "mod": + 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._UserMod_mod(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 userRolesImplementors = []string{"UserRoles"} + +func (ec *executionContext) _UserRoles(ctx context.Context, sel ast.SelectionSet, obj *UserRoles) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, userRolesImplementors) + + 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("UserRoles") + case "approveMods": + out.Values[i] = ec._UserRoles_approveMods(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "approveVersions": + out.Values[i] = ec._UserRoles_approveVersions(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteContent": + out.Values[i] = ec._UserRoles_deleteContent(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "editContent": + out.Values[i] = ec._UserRoles_editContent(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "editUsers": + out.Values[i] = ec._UserRoles_editUsers(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "editSMLVersions": + out.Values[i] = ec._UserRoles_editSMLVersions(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "editBootstrapVersions": + out.Values[i] = ec._UserRoles_editBootstrapVersions(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "editAnyModCompatibility": + out.Values[i] = ec._UserRoles_editAnyModCompatibility(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 userSessionImplementors = []string{"UserSession"} + +func (ec *executionContext) _UserSession(ctx context.Context, sel ast.SelectionSet, obj *UserSession) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, userSessionImplementors) + + 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("UserSession") + case "token": + out.Values[i] = ec._UserSession_token(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 versionImplementors = []string{"Version"} + +func (ec *executionContext) _Version(ctx context.Context, sel ast.SelectionSet, obj *Version) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, versionImplementors) + + 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("Version") + case "id": + out.Values[i] = ec._Version_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mod_id": + out.Values[i] = ec._Version_mod_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "version": + out.Values[i] = ec._Version_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "sml_version": + out.Values[i] = ec._Version_sml_version(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "changelog": + out.Values[i] = ec._Version_changelog(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "downloads": + out.Values[i] = ec._Version_downloads(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "stability": + out.Values[i] = ec._Version_stability(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "approved": + out.Values[i] = ec._Version_approved(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updated_at": + out.Values[i] = ec._Version_updated_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "created_at": + out.Values[i] = ec._Version_created_at(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "link": + 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._Version_link(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 "targets": + out.Values[i] = ec._Version_targets(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "metadata": + out.Values[i] = ec._Version_metadata(ctx, field, obj) + case "size": + 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._Version_size(ctx, field, obj) + 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 "hash": + 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._Version_hash(ctx, field, obj) + 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 "mod": + 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._Version_mod(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 "dependencies": + 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._Version_dependencies(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 versionDependencyImplementors = []string{"VersionDependency"} + +func (ec *executionContext) _VersionDependency(ctx context.Context, sel ast.SelectionSet, obj *VersionDependency) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, versionDependencyImplementors) + + 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("VersionDependency") + case "version_id": + out.Values[i] = ec._VersionDependency_version_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mod_id": + out.Values[i] = ec._VersionDependency_mod_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "condition": + out.Values[i] = ec._VersionDependency_condition(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "optional": + out.Values[i] = ec._VersionDependency_optional(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mod": + out.Values[i] = ec._VersionDependency_mod(ctx, field, obj) + case "version": + out.Values[i] = ec._VersionDependency_version(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 versionTargetImplementors = []string{"VersionTarget"} + +func (ec *executionContext) _VersionTarget(ctx context.Context, sel ast.SelectionSet, obj *VersionTarget) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, versionTargetImplementors) + + 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("VersionTarget") + case "VersionID": + out.Values[i] = ec._VersionTarget_VersionID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "targetName": + out.Values[i] = ec._VersionTarget_targetName(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "link": + 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._VersionTarget_link(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 "size": + out.Values[i] = ec._VersionTarget_size(ctx, field, obj) + case "hash": + out.Values[i] = ec._VersionTarget_hash(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 __DirectiveImplementors = []string{"__Directive"} + +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + + 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("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(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 __EnumValueImplementors = []string{"__EnumValue"} + +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + + 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("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(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 __FieldImplementors = []string{"__Field"} + +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + + 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("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(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 __InputValueImplementors = []string{"__InputValue"} + +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + + 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("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(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 __SchemaImplementors = []string{"__Schema"} + +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + + 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("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(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 __TypeImplementors = []string{"__Type"} + +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + + 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("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(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 +} + +// 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 interface{}) (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 { + 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 interface{}) (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 interface{}) (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 { + 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 interface{}) (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 interface{}) (*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 interface{}) (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 interface{}) (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 { + 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) 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) +} + +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) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +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) 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) 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 + 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.marshalNGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(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) 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._Guide(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNGuideID2string(ctx context.Context, v interface{}) (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 { + 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) unmarshalNInt2int(ctx context.Context, v interface{}) (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 { + 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 { + 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.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(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) 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._Mod(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNModID2string(ctx context.Context, v interface{}) (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 { + 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) unmarshalNModID2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + 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 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 interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNModReference2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) 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 + 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.marshalNModVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersion(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) 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._ModVersion(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNModVersionConstraint2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModVersionConstraintᚄ(ctx context.Context, v interface{}) ([]*ModVersionConstraint, error) { + var vSlice []interface{} + if v != nil { + 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 interface{}) (*ModVersionConstraint, error) { + res, err := ec.unmarshalInputModVersionConstraint(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewAnnouncement(ctx context.Context, v interface{}) (NewAnnouncement, error) { + res, err := ec.unmarshalInputNewAnnouncement(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewGuide(ctx context.Context, v interface{}) (NewGuide, error) { + res, err := ec.unmarshalInputNewGuide(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewMod(ctx context.Context, v interface{}) (NewMod, error) { + res, err := ec.unmarshalInputNewMod(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewSMLVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersion(ctx context.Context, v interface{}) (NewSMLVersion, error) { + res, err := ec.unmarshalInputNewSMLVersion(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersionTargetᚄ(ctx context.Context, v interface{}) ([]*NewSMLVersionTarget, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*NewSMLVersionTarget, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNNewSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersionTarget(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNNewSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersionTarget(ctx context.Context, v interface{}) (*NewSMLVersionTarget, error) { + res, err := ec.unmarshalInputNewSMLVersionTarget(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNNewVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewVersion(ctx context.Context, v interface{}) (NewVersion, error) { + res, err := ec.unmarshalInputNewVersion(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNOAuthOptions2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOAuthOptions(ctx context.Context, sel ast.SelectionSet, v OAuthOptions) graphql.Marshaler { + return ec._OAuthOptions(ctx, sel, &v) +} + +func (ec *executionContext) marshalNOAuthOptions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOAuthOptions(ctx context.Context, sel ast.SelectionSet, v *OAuthOptions) 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._OAuthOptions(ctx, sel, v) +} + +func (ec *executionContext) marshalNSMLVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx context.Context, sel ast.SelectionSet, v SMLVersion) graphql.Marshaler { + return ec._SMLVersion(ctx, sel, &v) +} + +func (ec *executionContext) marshalNSMLVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionᚄ(ctx context.Context, sel ast.SelectionSet, v []*SMLVersion) 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.marshalNSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(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) marshalNSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx context.Context, sel ast.SelectionSet, v *SMLVersion) 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._SMLVersion(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNSMLVersionID2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNSMLVersionID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) marshalNSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx context.Context, sel ast.SelectionSet, v []*SMLVersionTarget) 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.marshalOSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) marshalNTag2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx context.Context, sel ast.SelectionSet, v Tag) graphql.Marshaler { + return ec._Tag(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx context.Context, sel ast.SelectionSet, v []*Tag) 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.marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(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) marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx context.Context, sel ast.SelectionSet, v *Tag) 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._Tag(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNTagID2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTagID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) unmarshalNTagName2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTagName2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) unmarshalNTagName2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + 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.unmarshalNTagName2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNTagName2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNTagName2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx context.Context, v interface{}) (TargetName, error) { + var res TargetName + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx context.Context, sel ast.SelectionSet, v TargetName) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNUpdateAnnouncement2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateAnnouncement(ctx context.Context, v interface{}) (UpdateAnnouncement, error) { + res, err := ec.unmarshalInputUpdateAnnouncement(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateGuide2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateGuide(ctx context.Context, v interface{}) (UpdateGuide, error) { + res, err := ec.unmarshalInputUpdateGuide(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateMod(ctx context.Context, v interface{}) (UpdateMod, error) { + res, err := ec.unmarshalInputUpdateMod(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateSMLVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersion(ctx context.Context, v interface{}) (UpdateSMLVersion, error) { + res, err := ec.unmarshalInputUpdateSMLVersion(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersionTarget(ctx context.Context, v interface{}) ([]*UpdateSMLVersionTarget, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*UpdateSMLVersionTarget, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOUpdateSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersionTarget(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNUpdateUser2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUser(ctx context.Context, v interface{}) (UpdateUser, error) { + res, err := ec.unmarshalInputUpdateUser(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateUserMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUserMod(ctx context.Context, v interface{}) (UpdateUserMod, error) { + res, err := ec.unmarshalInputUpdateUserMod(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpdateVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateVersion(ctx context.Context, v interface{}) (UpdateVersion, error) { + res, err := ec.unmarshalInputUpdateVersion(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (graphql.Upload, error) { + res, err := graphql.UnmarshalUpload(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { + res := graphql.MarshalUpload(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) marshalNUser2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx context.Context, sel ast.SelectionSet, v []*User) 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.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) 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._User(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNUserID2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUserID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) unmarshalNUserID2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + 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.unmarshalNUserID2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNUserID2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNUserID2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx context.Context, sel ast.SelectionSet, v []*UserMod) 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.marshalNUserMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserMod(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) marshalNUserMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserMod(ctx context.Context, sel ast.SelectionSet, v *UserMod) 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._UserMod(ctx, sel, v) +} + +func (ec *executionContext) marshalNUserRoles2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx context.Context, sel ast.SelectionSet, v UserRoles) graphql.Marshaler { + return ec._UserRoles(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUserRoles2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx context.Context, sel ast.SelectionSet, v *UserRoles) 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._UserRoles(ctx, sel, v) +} + +func (ec *executionContext) marshalNVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx context.Context, sel ast.SelectionSet, v Version) graphql.Marshaler { + return ec._Version(ctx, sel, &v) +} + +func (ec *executionContext) marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx context.Context, sel ast.SelectionSet, v []*Version) 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.marshalNVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(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) marshalNVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx context.Context, sel ast.SelectionSet, v *Version) 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._Version(ctx, sel, v) +} + +func (ec *executionContext) marshalNVersionDependency2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependencyᚄ(ctx context.Context, sel ast.SelectionSet, v []*VersionDependency) 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.marshalNVersionDependency2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependency(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) marshalNVersionDependency2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependency(ctx context.Context, sel ast.SelectionSet, v *VersionDependency) 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._VersionDependency(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNVersionID2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNVersionID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) unmarshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx context.Context, v interface{}) (VersionStabilities, error) { + var res VersionStabilities + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx context.Context, sel ast.SelectionSet, v VersionStabilities) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx context.Context, sel ast.SelectionSet, v []*VersionTarget) 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.marshalOVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) 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.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(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) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + 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.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) 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.marshalN__DirectiveLocation2string(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) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) 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.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(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) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) 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.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(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) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) 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.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + 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) marshalOAnnouncement2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncement(ctx context.Context, sel ast.SelectionSet, v *Announcement) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Announcement(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOAnnouncementImportance2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, v interface{}) (*AnnouncementImportance, error) { + if v == nil { + return nil, nil + } + var res = new(AnnouncementImportance) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOAnnouncementImportance2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx context.Context, sel ast.SelectionSet, v *AnnouncementImportance) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + return res +} + +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalBoolean(*v) + return res +} + +func (ec *executionContext) marshalOCompatibilityInfo2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfo(ctx context.Context, sel ast.SelectionSet, v *CompatibilityInfo) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CompatibilityInfo(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOCompatibilityInfoInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx context.Context, v interface{}) (*CompatibilityInfoInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputCompatibilityInfoInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOCreateVersionResponse2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCreateVersionResponse(ctx context.Context, sel ast.SelectionSet, v *CreateVersionResponse) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CreateVersionResponse(ctx, sel, v) +} + +func (ec *executionContext) unmarshalODate2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalODate2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) marshalOGuide2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuide(ctx context.Context, sel ast.SelectionSet, v *Guide) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Guide(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOGuideFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideFields(ctx context.Context, v interface{}) (*GuideFields, error) { + if v == nil { + return nil, nil + } + var res = new(GuideFields) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOGuideFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideFields(ctx context.Context, sel ast.SelectionSet, v *GuideFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOGuideFilter2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalInt(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalInt(*v) + return res +} + +func (ec *executionContext) marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx context.Context, sel ast.SelectionSet, v *Mod) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Mod(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOModFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModFields(ctx context.Context, v interface{}) (*ModFields, error) { + if v == nil { + return nil, nil + } + var res = new(ModFields) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOModFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModFields(ctx context.Context, sel ast.SelectionSet, v *ModFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOModFilter2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) unmarshalOModReference2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOModReference2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) unmarshalOOrder2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOrder(ctx context.Context, v interface{}) (*Order, error) { + if v == nil { + return nil, nil + } + var res = new(Order) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOOrder2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOrder(ctx context.Context, sel ast.SelectionSet, v *Order) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOSMLVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersion(ctx context.Context, sel ast.SelectionSet, v *SMLVersion) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._SMLVersion(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOSMLVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionFields(ctx context.Context, v interface{}) (*SMLVersionFields, error) { + if v == nil { + return nil, nil + } + var res = new(SMLVersionFields) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOSMLVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionFields(ctx context.Context, sel ast.SelectionSet, v *SMLVersionFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOSMLVersionFilter2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) marshalOSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx context.Context, sel ast.SelectionSet, v *SMLVersionTarget) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._SMLVersionTarget(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + 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.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕ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.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) marshalOTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx context.Context, sel ast.SelectionSet, v []*Tag) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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.marshalNTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(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) marshalOTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx context.Context, sel ast.SelectionSet, v *Tag) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Tag(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOTagFilter2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagFilter(ctx context.Context, v interface{}) (*TagFilter, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputTagFilter(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOTagID2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + 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.unmarshalNTagID2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOTagID2ᚕ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.marshalNTagID2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOUpdateSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersionTarget(ctx context.Context, v interface{}) (*UpdateSMLVersionTarget, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputUpdateSMLVersionTarget(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOUpdateUserMod2ᚕgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUserModᚄ(ctx context.Context, v interface{}) ([]UpdateUserMod, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]UpdateUserMod, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNUpdateUserMod2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUserMod(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (*graphql.Upload, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalUpload(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalUpload(*v) + return res +} + +func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalOUserSession2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserSession(ctx context.Context, sel ast.SelectionSet, v *UserSession) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._UserSession(ctx, sel, v) +} + +func (ec *executionContext) marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx context.Context, sel ast.SelectionSet, v *Version) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Version(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionFields(ctx context.Context, v interface{}) (*VersionFields, error) { + if v == nil { + return nil, nil + } + var res = new(VersionFields) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionFields(ctx context.Context, sel ast.SelectionSet, v *VersionFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOVersionFilter2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx context.Context, v interface{}) (*VersionStabilities, error) { + if v == nil { + return nil, nil + } + var res = new(VersionStabilities) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx context.Context, sel ast.SelectionSet, v *VersionStabilities) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx context.Context, sel ast.SelectionSet, v *VersionTarget) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VersionTarget(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(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) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(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) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(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) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + 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.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(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) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/generated/models_gen.go b/generated/models_gen.go new file mode 100644 index 00000000..87189878 --- /dev/null +++ b/generated/models_gen.go @@ -0,0 +1,732 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "fmt" + "io" + "strconv" + + "github.com/99designs/gqlgen/graphql" +) + +type Announcement struct { + ID string `json:"id"` + Message string `json:"message"` + Importance AnnouncementImportance `json:"importance"` +} + +type Compatibility struct { + State CompatibilityState `json:"state"` + Note *string `json:"note,omitempty"` +} + +type CompatibilityInfo struct { + Ea *Compatibility `json:"EA"` + Exp *Compatibility `json:"EXP"` +} + +type CompatibilityInfoInput struct { + Ea *CompatibilityInput `json:"EA"` + Exp *CompatibilityInput `json:"EXP"` +} + +type CompatibilityInput struct { + State CompatibilityState `json:"state"` + Note *string `json:"note,omitempty"` +} + +type CreateVersionResponse struct { + AutoApproved bool `json:"auto_approved"` + Version *Version `json:"version,omitempty"` +} + +type GetGuides struct { + Guides []*Guide `json:"guides"` + Count int `json:"count"` +} + +type GetMods struct { + Mods []*Mod `json:"mods"` + Count int `json:"count"` +} + +type GetMyMods struct { + Mods []*Mod `json:"mods"` + Count int `json:"count"` +} + +type GetMyVersions struct { + Versions []*Version `json:"versions"` + Count int `json:"count"` +} + +type GetSMLVersions struct { + SmlVersions []*SMLVersion `json:"sml_versions"` + Count int `json:"count"` +} + +type GetVersions struct { + Versions []*Version `json:"versions"` + Count int `json:"count"` +} + +type Group struct { + ID string `json:"id"` + Name string `json:"name"` +} + +type Guide struct { + ID string `json:"id"` + Name string `json:"name"` + ShortDescription string `json:"short_description"` + Guide string `json:"guide"` + Views int `json:"views"` + UserID string `json:"user_id"` + UpdatedAt string `json:"updated_at"` + CreatedAt string `json:"created_at"` + Tags []*Tag `json:"tags"` + User *User `json:"user"` +} + +type LatestVersions struct { + Alpha *Version `json:"alpha,omitempty"` + Beta *Version `json:"beta,omitempty"` + Release *Version `json:"release,omitempty"` +} + +type Mod struct { + ID string `json:"id"` + Name string `json:"name"` + ShortDescription string `json:"short_description"` + FullDescription *string `json:"full_description,omitempty"` + Logo *string `json:"logo,omitempty"` + SourceURL *string `json:"source_url,omitempty"` + CreatorID string `json:"creator_id"` + Approved bool `json:"approved"` + Views int `json:"views"` + Downloads int `json:"downloads"` + Hotness int `json:"hotness"` + Popularity int `json:"popularity"` + UpdatedAt string `json:"updated_at"` + CreatedAt string `json:"created_at"` + LastVersionDate *string `json:"last_version_date,omitempty"` + ModReference string `json:"mod_reference"` + Hidden bool `json:"hidden"` + Tags []*Tag `json:"tags,omitempty"` + Compatibility *CompatibilityInfo `json:"compatibility,omitempty"` + Authors []*UserMod `json:"authors"` + Version *Version `json:"version,omitempty"` + Versions []*Version `json:"versions"` + LatestVersions *LatestVersions `json:"latestVersions"` +} + +type ModVersion struct { + ID string `json:"id"` + ModReference string `json:"mod_reference"` + Versions []*Version `json:"versions"` +} + +type ModVersionConstraint struct { + ModIDOrReference string `json:"modIdOrReference"` + Version string `json:"version"` +} + +type NewAnnouncement struct { + Message string `json:"message"` + Importance AnnouncementImportance `json:"importance"` +} + +type NewGuide struct { + Name string `json:"name"` + ShortDescription string `json:"short_description"` + Guide string `json:"guide"` + TagIDs []string `json:"tagIDs,omitempty"` +} + +type NewSMLVersion struct { + Version string `json:"version"` + SatisfactoryVersion int `json:"satisfactory_version"` + Stability VersionStabilities `json:"stability"` + Link string `json:"link"` + Targets []*NewSMLVersionTarget `json:"targets"` + Changelog string `json:"changelog"` + Date string `json:"date"` + BootstrapVersion *string `json:"bootstrap_version,omitempty"` + EngineVersion string `json:"engine_version"` +} + +type NewSMLVersionTarget struct { + TargetName TargetName `json:"targetName"` + Link string `json:"link"` +} + +type NewVersion struct { + Changelog string `json:"changelog"` + Stability VersionStabilities `json:"stability"` +} + +type OAuthOptions struct { + Github string `json:"github"` + Google string `json:"google"` + Facebook string `json:"facebook"` +} + +type SMLVersion struct { + ID string `json:"id"` + Version string `json:"version"` + SatisfactoryVersion int `json:"satisfactory_version"` + Stability VersionStabilities `json:"stability"` + Link string `json:"link"` + Targets []*SMLVersionTarget `json:"targets"` + Changelog string `json:"changelog"` + Date string `json:"date"` + BootstrapVersion *string `json:"bootstrap_version,omitempty"` + EngineVersion string `json:"engine_version"` + UpdatedAt string `json:"updated_at"` + CreatedAt string `json:"created_at"` +} + +type SMLVersionTarget struct { + VersionID string `json:"VersionID"` + TargetName TargetName `json:"targetName"` + Link string `json:"link"` +} + +type Tag struct { + ID string `json:"id"` + Name string `json:"name"` +} + +type TagFilter struct { + Limit *int `json:"limit,omitempty"` + Offset *int `json:"offset,omitempty"` + Order *Order `json:"order,omitempty"` + Search *string `json:"search,omitempty"` + Ids []string `json:"ids,omitempty"` +} + +type UpdateAnnouncement struct { + Message *string `json:"message,omitempty"` + Importance *AnnouncementImportance `json:"importance,omitempty"` +} + +type UpdateGuide struct { + Name *string `json:"name,omitempty"` + ShortDescription *string `json:"short_description,omitempty"` + Guide *string `json:"guide,omitempty"` + TagIDs []string `json:"tagIDs,omitempty"` +} + +type UpdateSMLVersion struct { + Version *string `json:"version,omitempty"` + SatisfactoryVersion *int `json:"satisfactory_version,omitempty"` + Stability *VersionStabilities `json:"stability,omitempty"` + Link *string `json:"link,omitempty"` + Targets []*UpdateSMLVersionTarget `json:"targets"` + Changelog *string `json:"changelog,omitempty"` + Date *string `json:"date,omitempty"` + BootstrapVersion *string `json:"bootstrap_version,omitempty"` + EngineVersion *string `json:"engine_version,omitempty"` +} + +type UpdateSMLVersionTarget struct { + TargetName TargetName `json:"targetName"` + Link string `json:"link"` +} + +type UpdateUser struct { + Avatar *graphql.Upload `json:"avatar,omitempty"` + Groups []string `json:"groups,omitempty"` + Username *string `json:"username,omitempty"` +} + +type UpdateUserMod struct { + UserID string `json:"user_id"` + Role string `json:"role"` +} + +type UpdateVersion struct { + Changelog *string `json:"changelog,omitempty"` + Stability *VersionStabilities `json:"stability,omitempty"` +} + +type User struct { + ID string `json:"id"` + Email *string `json:"email,omitempty"` + Username string `json:"username"` + Avatar *string `json:"avatar,omitempty"` + CreatedAt string `json:"created_at"` + GithubID *string `json:"github_id,omitempty"` + GoogleID *string `json:"google_id,omitempty"` + FacebookID *string `json:"facebook_id,omitempty"` + Roles *UserRoles `json:"roles"` + Groups []*Group `json:"groups"` + Mods []*UserMod `json:"mods"` + Guides []*Guide `json:"guides"` +} + +type UserMod struct { + UserID string `json:"user_id"` + ModID string `json:"mod_id"` + Role string `json:"role"` + User *User `json:"user"` + Mod *Mod `json:"mod"` +} + +type UserRoles struct { + ApproveMods bool `json:"approveMods"` + ApproveVersions bool `json:"approveVersions"` + DeleteContent bool `json:"deleteContent"` + EditContent bool `json:"editContent"` + EditUsers bool `json:"editUsers"` + EditSMLVersions bool `json:"editSMLVersions"` + EditBootstrapVersions bool `json:"editBootstrapVersions"` + EditAnyModCompatibility bool `json:"editAnyModCompatibility"` +} + +type UserSession struct { + Token string `json:"token"` +} + +type Version struct { + ID string `json:"id"` + ModID string `json:"mod_id"` + Version string `json:"version"` + SmlVersion string `json:"sml_version"` + Changelog string `json:"changelog"` + Downloads int `json:"downloads"` + Stability VersionStabilities `json:"stability"` + Approved bool `json:"approved"` + UpdatedAt string `json:"updated_at"` + CreatedAt string `json:"created_at"` + Link string `json:"link"` + Targets []*VersionTarget `json:"targets"` + Metadata *string `json:"metadata,omitempty"` + Size *int `json:"size,omitempty"` + Hash *string `json:"hash,omitempty"` + Mod *Mod `json:"mod"` + Dependencies []*VersionDependency `json:"dependencies"` +} + +type VersionDependency struct { + VersionID string `json:"version_id"` + ModID string `json:"mod_id"` + Condition string `json:"condition"` + Optional bool `json:"optional"` + Mod *Mod `json:"mod,omitempty"` + Version *Version `json:"version,omitempty"` +} + +type VersionTarget struct { + VersionID string `json:"VersionID"` + TargetName TargetName `json:"targetName"` + Link string `json:"link"` + Size *int `json:"size,omitempty"` + Hash *string `json:"hash,omitempty"` +} + +type AnnouncementImportance string + +const ( + AnnouncementImportanceFix AnnouncementImportance = "Fix" + AnnouncementImportanceInfo AnnouncementImportance = "Info" + AnnouncementImportanceWarning AnnouncementImportance = "Warning" + AnnouncementImportanceAlert AnnouncementImportance = "Alert" +) + +var AllAnnouncementImportance = []AnnouncementImportance{ + AnnouncementImportanceFix, + AnnouncementImportanceInfo, + AnnouncementImportanceWarning, + AnnouncementImportanceAlert, +} + +func (e AnnouncementImportance) IsValid() bool { + switch e { + case AnnouncementImportanceFix, AnnouncementImportanceInfo, AnnouncementImportanceWarning, AnnouncementImportanceAlert: + return true + } + return false +} + +func (e AnnouncementImportance) String() string { + return string(e) +} + +func (e *AnnouncementImportance) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = AnnouncementImportance(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid AnnouncementImportance", str) + } + return nil +} + +func (e AnnouncementImportance) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type CompatibilityState string + +const ( + CompatibilityStateWorks CompatibilityState = "Works" + CompatibilityStateDamaged CompatibilityState = "Damaged" + CompatibilityStateBroken CompatibilityState = "Broken" +) + +var AllCompatibilityState = []CompatibilityState{ + CompatibilityStateWorks, + CompatibilityStateDamaged, + CompatibilityStateBroken, +} + +func (e CompatibilityState) IsValid() bool { + switch e { + case CompatibilityStateWorks, CompatibilityStateDamaged, CompatibilityStateBroken: + return true + } + return false +} + +func (e CompatibilityState) String() string { + return string(e) +} + +func (e *CompatibilityState) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = CompatibilityState(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid CompatibilityState", str) + } + return nil +} + +func (e CompatibilityState) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type GuideFields string + +const ( + GuideFieldsName GuideFields = "name" + GuideFieldsCreatedAt GuideFields = "created_at" + GuideFieldsUpdatedAt GuideFields = "updated_at" + GuideFieldsViews GuideFields = "views" +) + +var AllGuideFields = []GuideFields{ + GuideFieldsName, + GuideFieldsCreatedAt, + GuideFieldsUpdatedAt, + GuideFieldsViews, +} + +func (e GuideFields) IsValid() bool { + switch e { + case GuideFieldsName, GuideFieldsCreatedAt, GuideFieldsUpdatedAt, GuideFieldsViews: + return true + } + return false +} + +func (e GuideFields) String() string { + return string(e) +} + +func (e *GuideFields) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = GuideFields(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid GuideFields", str) + } + return nil +} + +func (e GuideFields) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type ModFields string + +const ( + ModFieldsCreatedAt ModFields = "created_at" + ModFieldsUpdatedAt ModFields = "updated_at" + ModFieldsName ModFields = "name" + ModFieldsViews ModFields = "views" + ModFieldsDownloads ModFields = "downloads" + ModFieldsHotness ModFields = "hotness" + ModFieldsPopularity ModFields = "popularity" + ModFieldsLastVersionDate ModFields = "last_version_date" + ModFieldsSearch ModFields = "search" +) + +var AllModFields = []ModFields{ + ModFieldsCreatedAt, + ModFieldsUpdatedAt, + ModFieldsName, + ModFieldsViews, + ModFieldsDownloads, + ModFieldsHotness, + ModFieldsPopularity, + ModFieldsLastVersionDate, + ModFieldsSearch, +} + +func (e ModFields) IsValid() bool { + switch e { + case ModFieldsCreatedAt, ModFieldsUpdatedAt, ModFieldsName, ModFieldsViews, ModFieldsDownloads, ModFieldsHotness, ModFieldsPopularity, ModFieldsLastVersionDate, ModFieldsSearch: + return true + } + return false +} + +func (e ModFields) String() string { + return string(e) +} + +func (e *ModFields) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ModFields(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ModFields", str) + } + return nil +} + +func (e ModFields) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type Order string + +const ( + OrderAsc Order = "asc" + OrderDesc Order = "desc" +) + +var AllOrder = []Order{ + OrderAsc, + OrderDesc, +} + +func (e Order) IsValid() bool { + switch e { + case OrderAsc, OrderDesc: + return true + } + return false +} + +func (e Order) String() string { + return string(e) +} + +func (e *Order) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Order(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Order", str) + } + return nil +} + +func (e Order) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type SMLVersionFields string + +const ( + SMLVersionFieldsName SMLVersionFields = "name" + SMLVersionFieldsCreatedAt SMLVersionFields = "created_at" + SMLVersionFieldsUpdatedAt SMLVersionFields = "updated_at" + SMLVersionFieldsSatisfactoryVersion SMLVersionFields = "satisfactory_version" + SMLVersionFieldsDate SMLVersionFields = "date" +) + +var AllSMLVersionFields = []SMLVersionFields{ + SMLVersionFieldsName, + SMLVersionFieldsCreatedAt, + SMLVersionFieldsUpdatedAt, + SMLVersionFieldsSatisfactoryVersion, + SMLVersionFieldsDate, +} + +func (e SMLVersionFields) IsValid() bool { + switch e { + case SMLVersionFieldsName, SMLVersionFieldsCreatedAt, SMLVersionFieldsUpdatedAt, SMLVersionFieldsSatisfactoryVersion, SMLVersionFieldsDate: + return true + } + return false +} + +func (e SMLVersionFields) String() string { + return string(e) +} + +func (e *SMLVersionFields) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = SMLVersionFields(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid SMLVersionFields", str) + } + return nil +} + +func (e SMLVersionFields) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type TargetName string + +const ( + TargetNameWindows TargetName = "Windows" + TargetNameWindowsServer TargetName = "WindowsServer" + TargetNameLinuxServer TargetName = "LinuxServer" +) + +var AllTargetName = []TargetName{ + TargetNameWindows, + TargetNameWindowsServer, + TargetNameLinuxServer, +} + +func (e TargetName) IsValid() bool { + switch e { + case TargetNameWindows, TargetNameWindowsServer, TargetNameLinuxServer: + return true + } + return false +} + +func (e TargetName) String() string { + return string(e) +} + +func (e *TargetName) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = TargetName(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid TargetName", str) + } + return nil +} + +func (e TargetName) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type VersionFields string + +const ( + VersionFieldsCreatedAt VersionFields = "created_at" + VersionFieldsUpdatedAt VersionFields = "updated_at" + VersionFieldsDownloads VersionFields = "downloads" +) + +var AllVersionFields = []VersionFields{ + VersionFieldsCreatedAt, + VersionFieldsUpdatedAt, + VersionFieldsDownloads, +} + +func (e VersionFields) IsValid() bool { + switch e { + case VersionFieldsCreatedAt, VersionFieldsUpdatedAt, VersionFieldsDownloads: + return true + } + return false +} + +func (e VersionFields) String() string { + return string(e) +} + +func (e *VersionFields) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = VersionFields(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid VersionFields", str) + } + return nil +} + +func (e VersionFields) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type VersionStabilities string + +const ( + VersionStabilitiesAlpha VersionStabilities = "alpha" + VersionStabilitiesBeta VersionStabilities = "beta" + VersionStabilitiesRelease VersionStabilities = "release" +) + +var AllVersionStabilities = []VersionStabilities{ + VersionStabilitiesAlpha, + VersionStabilitiesBeta, + VersionStabilitiesRelease, +} + +func (e VersionStabilities) IsValid() bool { + switch e { + case VersionStabilitiesAlpha, VersionStabilitiesBeta, VersionStabilitiesRelease: + return true + } + return false +} + +func (e VersionStabilities) String() string { + return string(e) +} + +func (e *VersionStabilities) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = VersionStabilities(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid VersionStabilities", str) + } + return nil +} + +func (e VersionStabilities) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/go.mod b/go.mod index d03fb7ff..1691ee10 100755 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/satisfactorymodding/smr-api go 1.21 require ( + ariga.io/entcache v0.1.0 entgo.io/ent v0.12.4 github.com/99designs/gqlgen v0.17.39 github.com/MarvinJWendt/testza v0.5.2 @@ -101,6 +102,7 @@ require ( github.com/go-redis/redis_rate/v9 v9.1.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/glog v1.1.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect @@ -135,6 +137,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/mitchellh/hashstructure v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/pterm/pterm v0.12.69 // indirect github.com/rivo/uniseg v0.4.4 // indirect diff --git a/go.sum b/go.sum index ea6cbb21..f46a23fc 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 h1:JnYs/y8RJ3+MiIUp+3RgyyeO48VHLAZimqiaZYnMKk8= ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935/go.mod h1:isZrlzJ5cpoCoKFoY9knZug7Lq4pP1cm8g3XciLZ0Pw= +ariga.io/entcache v0.1.0 h1:nfJXzjB5CEvAK6SmjupHREMJrKLakeqU5tG3s4TO6JA= +ariga.io/entcache v0.1.0/go.mod h1:3Z1Sql5bcqPA1YV/jvMlZyh9T+ntSFOclaASAm1TiKQ= atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg= atomicgo.dev/assert v0.0.2/go.mod h1:ut4NcI3QDdJtlmAxQULOmA13Gz6e2DWbSAS8RUOmNYQ= atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw= @@ -243,6 +245,8 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-redis/redis_rate/v9 v9.1.2 h1:H0l5VzoAtOE6ydd38j8MCq3ABlGLnvvbA1xDSVVCHgQ= github.com/go-redis/redis_rate/v9 v9.1.2/go.mod h1:oam2de2apSgRG8aJzwJddXbNu91Iyz1m8IKJE2vpvlQ= +github.com/go-redis/redismock/v8 v8.0.6 h1:rtuijPgGynsRB2Y7KDACm09WvjHWS4RaG44Nm7rcj4Y= +github.com/go-redis/redismock/v8 v8.0.6/go.mod h1:sDIF73OVsmaKzYe/1FJXGiCQ4+oHYbzjpaL9Vor0sS4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= @@ -258,6 +262,8 @@ github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -445,6 +451,8 @@ github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3r github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= 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= +github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= diff --git a/gql/directive.go b/gql/directive.go index 4eb404a7..405b4c2a 100644 --- a/gql/directive.go +++ b/gql/directive.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "github.com/satisfactorymodding/smr-api/auth" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/util" @@ -38,7 +39,10 @@ type Directive struct { } func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } dbMod := postgres.GetModByID(ctx, getArgument(ctx, field).(string)) @@ -46,11 +50,11 @@ func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field return nil, errors.New("mod not found") } - if postgres.UserCanUploadModVersions(ctx, user, dbMod.ID) { + if db.UserCanUploadModVersions(ctx, user, dbMod.ID) { return next(ctx) } - if user.Has(ctx, auth.RoleEditAnyContent) { + if db.UserHas(ctx, auth.RoleEditAnyContent, user) { return next(ctx) } @@ -58,9 +62,12 @@ func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field } func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Resolver, field *string) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleEditAnyModCompatibility) || user.Has(ctx, auth.RoleEditAnyContent) { + if db.UserHas(ctx, auth.RoleEditAnyModCompatibility, user) || db.UserHas(ctx, auth.RoleEditAnyContent, user) { return next(ctx) } @@ -74,7 +81,7 @@ func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Re return nil, errors.New("mod not found") } - if postgres.UserCanUploadModVersions(ctx, user, dbMod.ID) { + if db.UserCanUploadModVersions(ctx, user, dbMod.ID) { return next(ctx) } @@ -82,7 +89,10 @@ func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Re } func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } dbVersion := postgres.GetVersion(ctx, getArgument(ctx, field).(string)) @@ -90,11 +100,11 @@ func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, f return nil, errors.New("version not found") } - if postgres.UserCanUploadModVersions(ctx, user, dbVersion.ModID) { + if db.UserCanUploadModVersions(ctx, user, dbVersion.ModID) { return next(ctx) } - if user.Has(ctx, auth.RoleEditAnyContent) { + if db.UserHas(ctx, auth.RoleEditAnyContent, user) { return next(ctx) } @@ -102,7 +112,10 @@ func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, f } func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, field string, object bool) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } var userID string if object { @@ -121,7 +134,7 @@ func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, fi return next(ctx) } - if user.Has(ctx, auth.RoleEditUsers) { + if db.UserHas(ctx, auth.RoleEditUsers, user) { return next(ctx) } @@ -129,7 +142,10 @@ func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, fi } func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } dbGuide := postgres.GetGuideByID(ctx, getArgument(ctx, field).(string)) @@ -141,7 +157,7 @@ func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, fie return next(ctx) } - if user.Has(ctx, auth.RoleEditAnyContent) { + if db.UserHas(ctx, auth.RoleEditAnyContent, user) { return next(ctx) } @@ -149,26 +165,16 @@ func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, fie } func isLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - header := ctx.Value(util.ContextHeader{}).(http.Header) - authorization := header.Get("Authorization") - - if authorization == "" { - return nil, errors.New("user not logged in") - } - - user := postgres.GetUserByToken(ctx, authorization) - - if user == nil { - return nil, errors.New("user not logged in") + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err } if user.Banned { return nil, errors.New("user banned") } - userCtx := context.WithValue(ctx, postgres.UserKey{}, user) - - return next(userCtx) + return next(ctx) } func isNotLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { @@ -191,9 +197,12 @@ func getArgument(ctx context.Context, key string) interface{} { } func canApproveMods(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleApproveMods) { + if db.UserHas(ctx, auth.RoleApproveMods, user) { return next(ctx) } @@ -201,9 +210,12 @@ func canApproveMods(ctx context.Context, _ interface{}, next graphql.Resolver) ( } func canApproveVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleApproveVersions) { + if db.UserHas(ctx, auth.RoleApproveVersions, user) { return next(ctx) } @@ -211,9 +223,12 @@ func canApproveVersions(ctx context.Context, _ interface{}, next graphql.Resolve } func canEditUsers(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleEditUsers) { + if db.UserHas(ctx, auth.RoleEditUsers, user) { return next(ctx) } @@ -221,9 +236,12 @@ func canEditUsers(ctx context.Context, _ interface{}, next graphql.Resolver) (in } func canEditSMLVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleEditSMLVersions) { + if db.UserHas(ctx, auth.RoleEditSMLVersions, user) { return next(ctx) } @@ -231,9 +249,12 @@ func canEditSMLVersions(ctx context.Context, _ interface{}, next graphql.Resolve } func canEditBootstrapVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleEditBootstrapVersions) { + if db.UserHas(ctx, auth.RoleEditBootstrapVersions, user) { return next(ctx) } @@ -241,9 +262,12 @@ func canEditBootstrapVersions(ctx context.Context, _ interface{}, next graphql.R } func canEditAnnouncements(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleEditAnnouncements) { + if db.UserHas(ctx, auth.RoleEditAnnouncements, user) { return next(ctx) } @@ -251,9 +275,12 @@ func canEditAnnouncements(ctx context.Context, _ interface{}, next graphql.Resol } func canManageTags(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user.Has(ctx, auth.RoleManageTags) { + if db.UserHas(ctx, auth.RoleManageTags, user) { return next(ctx) } diff --git a/gql/gql_types.go b/gql/gql_types.go index 43dc7191..3dd3a367 100644 --- a/gql/gql_types.go +++ b/gql/gql_types.go @@ -143,24 +143,6 @@ func DBSMLVersionToGenerated(smlVersion *postgres.SMLVersion) *generated.SMLVers } } -func DBBootstrapVersionToGenerated(bootstrapVersion *postgres.BootstrapVersion) *generated.BootstrapVersion { - if bootstrapVersion == nil { - return nil - } - - return &generated.BootstrapVersion{ - ID: bootstrapVersion.ID, - Version: bootstrapVersion.Version, - SatisfactoryVersion: bootstrapVersion.SatisfactoryVersion, - Stability: generated.VersionStabilities(bootstrapVersion.Stability), - Link: bootstrapVersion.Link, - Changelog: bootstrapVersion.Changelog, - Date: bootstrapVersion.Date.Format(time.RFC3339Nano), - UpdatedAt: bootstrapVersion.UpdatedAt.Format(time.RFC3339Nano), - CreatedAt: bootstrapVersion.CreatedAt.Format(time.RFC3339Nano), - } -} - func DBVersionDependencyToGenerated(versionDependency *postgres.VersionDependency) *generated.VersionDependency { if versionDependency == nil { return nil @@ -174,26 +156,6 @@ func DBVersionDependencyToGenerated(versionDependency *postgres.VersionDependenc } } -func DBAnnouncementToGenerated(announcement *postgres.Announcement) *generated.Announcement { - if announcement == nil { - return nil - } - - return &generated.Announcement{ - ID: announcement.ID, - Message: announcement.Message, - Importance: generated.AnnouncementImportance(announcement.Importance), - } -} - -func DBAnnouncementsToGeneratedSlice(announcements []postgres.Announcement) []*generated.Announcement { - converted := make([]*generated.Announcement, len(announcements)) - for i, announcement := range announcements { - converted[i] = DBAnnouncementToGenerated(&announcement) - } - return converted -} - func DBTagToGenerated(tag *postgres.Tag) *generated.Tag { if tag == nil { return nil diff --git a/gql/gql_utils.go b/gql/gql_utils.go index 5dbe22cf..a563621d 100644 --- a/gql/gql_utils.go +++ b/gql/gql_utils.go @@ -14,6 +14,7 @@ import ( "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" "github.com/satisfactorymodding/smr-api/util" ) @@ -88,6 +89,31 @@ func SetCompatibilityINN(value *generated.CompatibilityInfoInput, target **postg *target = toDB } +func SetINNF[T any, B any](value *T, target func(T) B) { + if value != nil { + target(*value) + } +} + +func SetINNOEF[T comparable, B any](value *T, target func(T) B) { + if value != nil && *value != *(new(T)) { + target(*value) + } +} + +func SetStabilityINNF[B any](value *generated.VersionStabilities, target func(smlversion.Stability) B) { + if value != nil { + target(smlversion.Stability(*value)) + } +} + +func SetDateINNF[B any](value *string, target func(time.Time) B) { + if value != nil { + t, _ := time.Parse(time.RFC3339Nano, *value) + target(t) + } +} + func RealIP(ctx context.Context) string { header := ctx.Value(util.ContextHeader{}).(http.Header) diff --git a/gql/resolver.go b/gql/resolver.go index 43547809..eb8a6fb7 100755 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -62,10 +62,6 @@ func (r *Resolver) GetSMLVersions() generated.GetSMLVersionsResolver { return &getSMLVersionsResolver{r} } -func (r *Resolver) GetBootstrapVersions() generated.GetBootstrapVersionsResolver { - return &getBootstrapVersionsResolver{r} -} - type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } diff --git a/gql/resolver_announcements.go b/gql/resolver_announcements.go index 7e5e0b54..206d3d3b 100644 --- a/gql/resolver_announcements.go +++ b/gql/resolver_announcements.go @@ -3,17 +3,19 @@ package gql import ( "context" "fmt" + "log/slog" - "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" - "github.com/satisfactorymodding/smr-api/db/postgres" + "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/announcement" "github.com/satisfactorymodding/smr-api/util" ) func (r *mutationResolver) CreateAnnouncement(ctx context.Context, announcement generated.NewAnnouncement) (*generated.Announcement, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createAnnouncement") + wrapper, ctx := WrapMutationTrace(ctx, "createAnnouncement") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -21,35 +23,33 @@ func (r *mutationResolver) CreateAnnouncement(ctx context.Context, announcement return nil, fmt.Errorf("validation failed: %w", err) } - dbAnnouncement := &postgres.Announcement{ - Message: announcement.Message, - Importance: string(announcement.Importance), - } - - resultAnnouncement, err := postgres.CreateAnnouncement(newCtx, dbAnnouncement) + result, err := db.From(ctx).Announcement. + Create(). + SetMessage(announcement.Message). + SetImportance(string(announcement.Importance)). + Save(ctx) if err != nil { return nil, err } - return DBAnnouncementToGenerated(resultAnnouncement), nil + + return (*conv.AnnouncementImpl)(nil).Convert(result), nil } func (r *mutationResolver) DeleteAnnouncement(ctx context.Context, announcementID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteAnnouncement") + wrapper, ctx := WrapMutationTrace(ctx, "deleteAnnouncement") defer wrapper.end() - dbAnnouncement := postgres.GetAnnouncementByID(newCtx, announcementID) + slog.Info("deleting announcement", slog.String("id", announcementID)) - if dbAnnouncement == nil { - return false, errors.New("announcement not found") + if err := db.From(ctx).Announcement.DeleteOneID(announcementID).Exec(ctx); err != nil { + return false, err } - postgres.Delete(newCtx, &dbAnnouncement) - return true, nil } func (r *mutationResolver) UpdateAnnouncement(ctx context.Context, announcementID string, announcement generated.UpdateAnnouncement) (*generated.Announcement, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateAnnouncement") + wrapper, ctx := WrapMutationTrace(ctx, "updateAnnouncement") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -57,43 +57,53 @@ func (r *mutationResolver) UpdateAnnouncement(ctx context.Context, announcementI return nil, fmt.Errorf("validation failed: %w", err) } - dbAnnouncement := postgres.GetAnnouncementByID(newCtx, announcementID) + update := db.From(ctx).Announcement.UpdateOneID(announcementID) + SetINNOEF(announcement.Message, update.SetMessage) + SetINNOEF((*string)(announcement.Importance), update.SetImportance) - if dbAnnouncement == nil { - return nil, errors.New("guide not found") + result, err := update.Save(ctx) + if err != nil { + return nil, err } - SetStringINNOE(announcement.Message, &dbAnnouncement.Message) - SetStringINNOE((*string)(announcement.Importance), &dbAnnouncement.Importance) - - postgres.Save(newCtx, &dbAnnouncement) - - return DBAnnouncementToGenerated(dbAnnouncement), nil + return (*conv.AnnouncementImpl)(nil).Convert(result), nil } func (r *queryResolver) GetAnnouncement(ctx context.Context, announcementID string) (*generated.Announcement, error) { wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncement") defer wrapper.end() - announcement := postgres.GetAnnouncementByID(newCtx, announcementID) + result, err := db.From(newCtx).Announcement.Get(newCtx, announcementID) + if err != nil { + return nil, err + } - return DBAnnouncementToGenerated(announcement), nil + return (*conv.AnnouncementImpl)(nil).Convert(result), nil } func (r *queryResolver) GetAnnouncements(ctx context.Context) ([]*generated.Announcement, error) { wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncements") defer wrapper.end() - announcements := postgres.GetAnnouncements(newCtx) + result, err := db.From(newCtx).Debug().Announcement.Query().All(newCtx) + if err != nil { + return nil, err + } - return DBAnnouncementsToGeneratedSlice(announcements), nil + return (*conv.AnnouncementImpl)(nil).ConvertSlice(result), nil } func (r *queryResolver) GetAnnouncementsByImportance(ctx context.Context, importance generated.AnnouncementImportance) ([]*generated.Announcement, error) { wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncementsByImportance") defer wrapper.end() - announcements := postgres.GetAnnouncementsByImportance(newCtx, string(importance)) + result, err := db.From(newCtx).Announcement. + Query(). + Where(announcement.ImportanceEQ(string(importance))). + All(newCtx) + if err != nil { + return nil, err + } - return DBAnnouncementsToGeneratedSlice(announcements), nil + return (*conv.AnnouncementImpl)(nil).ConvertSlice(result), nil } diff --git a/gql/resolver_bootstrap_versions.go b/gql/resolver_bootstrap_versions.go deleted file mode 100644 index e011e072..00000000 --- a/gql/resolver_bootstrap_versions.go +++ /dev/null @@ -1,151 +0,0 @@ -package gql - -import ( - "context" - "fmt" - "time" - - "github.com/99designs/gqlgen/graphql" - "github.com/pkg/errors" - "gopkg.in/go-playground/validator.v9" - - "github.com/satisfactorymodding/smr-api/db/postgres" - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" -) - -func (r *mutationResolver) CreateBootstrapVersion(ctx context.Context, bootstrapVersion generated.NewBootstrapVersion) (*generated.BootstrapVersion, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createBootstrapVersion") - defer wrapper.end() - - val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&bootstrapVersion); err != nil { - return nil, fmt.Errorf("validation failed: %w", err) - } - - date, err := time.Parse(time.RFC3339Nano, bootstrapVersion.Date) - if err != nil { - return nil, fmt.Errorf("failed to parse date: %w", err) - } - - dbBootstrapVersion := &postgres.BootstrapVersion{ - Version: bootstrapVersion.Version, - SatisfactoryVersion: bootstrapVersion.SatisfactoryVersion, - Stability: string(bootstrapVersion.Stability), - Link: bootstrapVersion.Link, - Changelog: bootstrapVersion.Changelog, - Date: date, - } - - resultBootstrapVersion, err := postgres.CreateBootstrapVersion(newCtx, dbBootstrapVersion) - if err != nil { - return nil, fmt.Errorf("failed to create bootstrap version: %w", err) - } - - return DBBootstrapVersionToGenerated(resultBootstrapVersion), nil -} - -func (r *mutationResolver) UpdateBootstrapVersion(ctx context.Context, bootstrapVersionID string, bootstrapVersion generated.UpdateBootstrapVersion) (*generated.BootstrapVersion, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateBootstrapVersion") - defer wrapper.end() - - val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&bootstrapVersion); err != nil { - return nil, fmt.Errorf("validation failed: %w", err) - } - - dbBootstrapVersion := postgres.GetBootstrapVersionByID(newCtx, bootstrapVersionID) - - if dbBootstrapVersion == nil { - return nil, errors.New("bootstrapVersion not found") - } - - SetStringINNOE(bootstrapVersion.Version, &dbBootstrapVersion.Version) - SetINN(bootstrapVersion.SatisfactoryVersion, &dbBootstrapVersion.SatisfactoryVersion) - SetStabilityINN(bootstrapVersion.Stability, &dbBootstrapVersion.Stability) - SetStringINNOE(bootstrapVersion.Link, &dbBootstrapVersion.Link) - SetStringINNOE(bootstrapVersion.Changelog, &dbBootstrapVersion.Changelog) - SetDateINN(bootstrapVersion.Date, &dbBootstrapVersion.Date) - - postgres.Save(newCtx, &dbBootstrapVersion) - - return DBBootstrapVersionToGenerated(dbBootstrapVersion), nil -} - -func (r *mutationResolver) DeleteBootstrapVersion(ctx context.Context, bootstrapVersionID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteBootstrapVersion") - defer wrapper.end() - - dbBootstrapVersion := postgres.GetBootstrapVersionByID(newCtx, bootstrapVersionID) - - if dbBootstrapVersion == nil { - return false, errors.New("bootstrapVersion not found") - } - - postgres.Delete(newCtx, &dbBootstrapVersion) - - return true, nil -} - -func (r *queryResolver) GetBootstrapVersion(ctx context.Context, bootstrapVersionID string) (*generated.BootstrapVersion, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getBootstrapVersion") - defer wrapper.end() - - return DBBootstrapVersionToGenerated(postgres.GetBootstrapVersionByID(newCtx, bootstrapVersionID)), nil -} - -func (r *queryResolver) GetBootstrapVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetBootstrapVersions, error) { - wrapper, _ := WrapQueryTrace(ctx, "getBootstrapVersions") - defer wrapper.end() - return &generated.GetBootstrapVersions{}, nil -} - -type getBootstrapVersionsResolver struct{ *Resolver } - -func (r *getBootstrapVersionsResolver) BootstrapVersions(ctx context.Context, _ *generated.GetBootstrapVersions) ([]*generated.BootstrapVersion, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetBootstrapVersions.bootstrapVersions") - defer wrapper.end() - - resolverContext := graphql.GetFieldContext(ctx) - bootstrapVersionFilter, err := models.ProcessBootstrapVersionFilter(resolverContext.Parent.Args["filter"].(map[string]interface{})) - if err != nil { - return nil, err - } - - var bootstrapVersions []postgres.BootstrapVersion - - if bootstrapVersionFilter.Ids == nil || len(bootstrapVersionFilter.Ids) == 0 { - bootstrapVersions = postgres.GetBootstrapVersions(newCtx, bootstrapVersionFilter) - } else { - bootstrapVersions = postgres.GetBootstrapVersionsByID(newCtx, bootstrapVersionFilter.Ids) - } - - if bootstrapVersions == nil { - return nil, errors.New("bootstrap releases not found") - } - - converted := make([]*generated.BootstrapVersion, len(bootstrapVersions)) - for k, v := range bootstrapVersions { - converted[k] = DBBootstrapVersionToGenerated(&v) - } - - return converted, nil -} - -func (r *getBootstrapVersionsResolver) Count(ctx context.Context, _ *generated.GetBootstrapVersions) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetBootstrapVersions.count") - defer wrapper.end() - - resolverContext := graphql.GetFieldContext(ctx) - bootstrapVersionFilter, err := models.ProcessBootstrapVersionFilter(resolverContext.Parent.Args["filter"].(map[string]interface{})) - if err != nil { - return 0, err - } - - if bootstrapVersionFilter.Ids != nil && len(bootstrapVersionFilter.Ids) != 0 { - return len(bootstrapVersionFilter.Ids), nil - } - - return int(postgres.GetBootstrapVersionCount(newCtx, bootstrapVersionFilter)), nil -} diff --git a/gql/resolver_guides.go b/gql/resolver_guides.go index 481ab6e2..e72f6d7d 100644 --- a/gql/resolver_guides.go +++ b/gql/resolver_guides.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/models" @@ -31,7 +32,10 @@ func (r *mutationResolver) CreateGuide(ctx context.Context, guide generated.NewG Guide: guide.Guide, } - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } dbGuide.UserID = user.ID diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index fc73f1f9..171a0e90 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -14,6 +14,7 @@ import ( "gopkg.in/go-playground/validator.v9" "github.com/satisfactorymodding/smr-api/dataloader" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/integrations" @@ -61,7 +62,10 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) SetINN(mod.FullDescription, &dbMod.FullDescription) SetINN(mod.Hidden, &dbMod.Hidden) - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } dbMod.CreatorID = user.ID @@ -253,7 +257,7 @@ func (r *mutationResolver) ApproveMod(ctx context.Context, modID string) (bool, postgres.Save(newCtx, &dbMod) - go integrations.NewMod(util.ReWrapCtx(ctx), dbMod) + go integrations.NewMod(db.ReWrapCtx(ctx), dbMod) return true, nil } diff --git a/gql/resolver_sml_versions.go b/gql/resolver_sml_versions.go index 72e0d14a..b6d7d37d 100644 --- a/gql/resolver_sml_versions.go +++ b/gql/resolver_sml_versions.go @@ -3,20 +3,25 @@ package gql import ( "context" "fmt" + "strings" "time" + "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" - "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" - "github.com/satisfactorymodding/smr-api/db/postgres" + "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/smlversion" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/util" ) func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion generated.NewSMLVersion) (*generated.SMLVersion, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createSMLVersion") + wrapper, ctx := WrapMutationTrace(ctx, "createSMLVersion") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -29,36 +34,56 @@ func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion gene return nil, fmt.Errorf("failed to parse date: %w", err) } - dbSMLVersion := &postgres.SMLVersion{ - Version: smlVersion.Version, - SatisfactoryVersion: smlVersion.SatisfactoryVersion, - BootstrapVersion: smlVersion.BootstrapVersion, - Stability: string(smlVersion.Stability), - Link: smlVersion.Link, - Changelog: smlVersion.Changelog, - Date: date, - EngineVersion: smlVersion.EngineVersion, - } + var result *ent.SmlVersion + if err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + result, err = db.From(ctx).SmlVersion. + Create(). + SetVersion(smlVersion.Version). + SetSatisfactoryVersion(smlVersion.SatisfactoryVersion). + SetNillableBootstrapVersion(smlVersion.BootstrapVersion). + SetStability(smlversion.Stability(smlVersion.Stability)). + SetLink(smlVersion.Link). + SetChangelog(smlVersion.Changelog). + SetDate(date). + SetEngineVersion(smlVersion.EngineVersion). + Save(ctx) + if err != nil { + return err + } - resultSMLVersion, err := postgres.CreateSMLVersion(newCtx, dbSMLVersion) + println(result.ID) + + for _, smlVersionTarget := range smlVersion.Targets { + if _, err := db.From(ctx).SmlVersionTarget. + Create(). + SetVersionID(result.ID). + SetTargetName(string(smlVersionTarget.TargetName)). + SetLink(smlVersionTarget.Link). + Save(ctx); err != nil { + println("HERE") + return err + } + } - for _, smlVersionTarget := range smlVersion.Targets { - postgres.Save(newCtx, &postgres.SMLVersionTarget{ - VersionID: resultSMLVersion.ID, - TargetName: string(smlVersionTarget.TargetName), - Link: smlVersionTarget.Link, - }) + return nil + }, nil); err != nil { + return nil, err } + result, err = db.From(ctx).SmlVersion. + Query(). + WithTargets(). + Where(smlversion.ID(result.ID)). + First(ctx) if err != nil { return nil, err } - return DBSMLVersionToGenerated(resultSMLVersion), nil + return (*conv.SMLVersionImpl)(nil).Convert(result), nil } func (r *mutationResolver) UpdateSMLVersion(ctx context.Context, smlVersionID string, smlVersion generated.UpdateSMLVersion) (*generated.SMLVersion, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateSMLVersion") + wrapper, ctx := WrapMutationTrace(ctx, "updateSMLVersion") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -66,76 +91,105 @@ func (r *mutationResolver) UpdateSMLVersion(ctx context.Context, smlVersionID st return nil, fmt.Errorf("validation failed: %w", err) } - dbSMLTargets := postgres.GetSMLVersionTargets(newCtx, smlVersionID) + err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + dbSMLVersion, err := tx.SmlVersion.Get(ctx, smlVersionID) + if err != nil { + return err + } + + update := dbSMLVersion.Update() - for _, dbSMLTarget := range dbSMLTargets { - found := false + SetINNOEF(smlVersion.Version, update.SetVersion) + SetINNF(smlVersion.SatisfactoryVersion, update.SetSatisfactoryVersion) + SetINNOEF(smlVersion.BootstrapVersion, update.SetBootstrapVersion) + SetStabilityINNF(smlVersion.Stability, update.SetStability) + SetINNOEF(smlVersion.Link, update.SetLink) + SetINNOEF(smlVersion.Changelog, update.SetChangelog) + SetDateINNF(smlVersion.Date, update.SetDate) + SetINNOEF(smlVersion.EngineVersion, update.SetEngineVersion) - for _, smlTarget := range smlVersion.Targets { - if dbSMLTarget.TargetName == string(smlTarget.TargetName) { - found = true - } + if err := update.Exec(ctx); err != nil { + return err } - if !found { - postgres.Delete(newCtx, &dbSMLTarget) + dbSMLTargets, err := dbSMLVersion.QueryTargets().All(ctx) + if err != nil { + return err } - } - for _, smlTarget := range smlVersion.Targets { - postgres.Save(newCtx, &postgres.SMLVersionTarget{ - VersionID: smlVersionID, - TargetName: string(smlTarget.TargetName), - Link: smlTarget.Link, - }) - } + for _, dbSMLTarget := range dbSMLTargets { + found := false + + for _, smlTarget := range smlVersion.Targets { + if dbSMLTarget.TargetName == string(smlTarget.TargetName) { + found = true + } + } - dbSMLVersion := postgres.GetSMLVersionByID(newCtx, smlVersionID) + if !found { + tx.SmlVersionTarget.DeleteOneID(dbSMLTarget.ID) + } + } - if dbSMLVersion == nil { - return nil, errors.New("smlVersion not found") - } + for _, smlTarget := range smlVersion.Targets { + if err := tx.SmlVersionTarget.Update().Where( + smlversiontarget.VersionID(dbSMLVersion.ID), + smlversiontarget.TargetName(string(smlTarget.TargetName)), + ).SetLink(smlTarget.Link).Exec(ctx); err != nil { + return err + } + } - SetStringINNOE(smlVersion.Version, &dbSMLVersion.Version) - SetINN(smlVersion.SatisfactoryVersion, &dbSMLVersion.SatisfactoryVersion) - SetStringINNOE(smlVersion.BootstrapVersion, dbSMLVersion.BootstrapVersion) - SetStabilityINN(smlVersion.Stability, &dbSMLVersion.Stability) - SetStringINNOE(smlVersion.Link, &dbSMLVersion.Link) - SetStringINNOE(smlVersion.Changelog, &dbSMLVersion.Changelog) - SetDateINN(smlVersion.Date, &dbSMLVersion.Date) - SetStringINNOE(smlVersion.EngineVersion, &dbSMLVersion.EngineVersion) + return nil + }, nil) + if err != nil { + return nil, err + } - postgres.Save(newCtx, &dbSMLVersion) + result, err := db.From(ctx).SmlVersion. + Query(). + WithTargets(). + Where(smlversion.ID(smlVersionID)). + First(ctx) + if err != nil { + return nil, err + } - return DBSMLVersionToGenerated(dbSMLVersion), nil + return (*conv.SMLVersionImpl)(nil).Convert(result), nil } func (r *mutationResolver) DeleteSMLVersion(ctx context.Context, smlVersionID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteSMLVersion") + wrapper, ctx := WrapMutationTrace(ctx, "deleteSMLVersion") defer wrapper.end() - dbSMLVersion := postgres.GetSMLVersionByID(newCtx, smlVersionID) - - if dbSMLVersion == nil { - return false, errors.New("smlVersion not found") - } - - dbSMLVersionTargets := postgres.GetSMLVersionTargets(newCtx, smlVersionID) + err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + if _, err := tx.SmlVersionTarget.Delete().Where(smlversiontarget.VersionID(smlVersionID)).Exec(ctx); err != nil { + return err + } - for _, dbSMLVersionTarget := range dbSMLVersionTargets { - postgres.Delete(newCtx, &dbSMLVersionTarget) + return tx.SmlVersion.DeleteOneID(smlVersionID).Exec(ctx) + }, nil) + if err != nil { + return false, err } - postgres.Delete(newCtx, &dbSMLVersion) - return true, nil } func (r *queryResolver) GetSMLVersion(ctx context.Context, smlVersionID string) (*generated.SMLVersion, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getSMLVersion") + wrapper, ctx := WrapQueryTrace(ctx, "getSMLVersion") defer wrapper.end() - return DBSMLVersionToGenerated(postgres.GetSMLVersionByID(newCtx, smlVersionID)), nil + result, err := db.From(ctx).SmlVersion. + Query(). + WithTargets(). + Where(smlversion.ID(smlVersionID)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.SMLVersionImpl)(nil).Convert(result), nil } func (r *queryResolver) GetSMLVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetSMLVersions, error) { @@ -147,7 +201,7 @@ func (r *queryResolver) GetSMLVersions(ctx context.Context, _ map[string]interfa type getSMLVersionsResolver struct{ *Resolver } func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, _ *generated.GetSMLVersions) ([]*generated.SMLVersion, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetSMLVersions.smlVersions") + wrapper, ctx := WrapQueryTrace(ctx, "GetSMLVersions.smlVersions") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -156,28 +210,19 @@ func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, _ *generated.G return nil, err } - var smlVersions []postgres.SMLVersion - - if smlVersionFilter.Ids == nil || len(smlVersionFilter.Ids) == 0 { - smlVersions = postgres.GetSMLVersions(newCtx, smlVersionFilter) - } else { - smlVersions = postgres.GetSMLVersionsByID(newCtx, smlVersionFilter.Ids) - } - - if smlVersions == nil { - return nil, errors.New("sml releases not found") - } + query := db.From(ctx).SmlVersion.Query().WithTargets() + query = convertFilter(query, smlVersionFilter) - converted := make([]*generated.SMLVersion, len(smlVersions)) - for k, v := range smlVersions { - converted[k] = DBSMLVersionToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.SMLVersionImpl)(nil).ConvertSlice(result), nil } func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLVersions) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetSMLVersions.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetSMLVersions.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -186,9 +231,33 @@ func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLV return 0, err } - if smlVersionFilter.Ids != nil && len(smlVersionFilter.Ids) != 0 { - return len(smlVersionFilter.Ids), nil + query := db.From(ctx).SmlVersion.Query().WithTargets() + query = convertFilter(query, smlVersionFilter) + + result, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetSMLVersionCount(newCtx, smlVersionFilter)), nil + return result, nil +} + +func convertFilter(query *ent.SmlVersionQuery, filter *models.SMLVersionFilter) *ent.SmlVersionQuery { + if len(filter.Ids) > 0 { + query = query.Where(smlversion.IDIn(filter.Ids...)) + } else if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset). + Order(sql.OrderByField( + filter.OrderBy.String(), + db.OrderToOrder(filter.Order.String()), + ).ToFunc()) + if filter.Search != nil && *filter.Search != "" { + query = query.Modify(func(s *sql.Selector) { + s.Where(sql.ExprP("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & "))) + }).Clone() + } + } + return query } diff --git a/gql/resolver_users.go b/gql/resolver_users.go index ef28edf7..30489e04 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -17,8 +17,10 @@ import ( "github.com/satisfactorymodding/smr-api/auth" "github.com/satisfactorymodding/smr-api/dataloader" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/conv" "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/util" "github.com/satisfactorymodding/smr-api/util/converter" @@ -83,9 +85,15 @@ func (r *mutationResolver) Logout(ctx context.Context) (bool, error) { } func (r *queryResolver) GetMe(ctx context.Context) (*generated.User, error) { - wrapper, _ := WrapQueryTrace(ctx, "getMe") + wrapper, ctx := WrapQueryTrace(ctx, "getMe") defer wrapper.end() - return DBUserToGenerated(ctx.Value(postgres.UserKey{}).(*postgres.User)), nil + + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + return (*conv.UserImpl)(nil).Convert(user), nil } func (r *queryResolver) GetUser(ctx context.Context, userID string) (*generated.User, error) { @@ -155,18 +163,25 @@ func (r *userResolver) Guides(ctx context.Context, obj *generated.User) ([]*gene } func (r *userResolver) Groups(ctx context.Context, _ *generated.User) ([]*generated.Group, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "User.guides") + wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - groups := user.GetGroups(newCtx) + groups, err := user.QueryGroups().All(ctx) + if err != nil { + return nil, err + } converted := make([]*generated.Group, len(groups)) for k, v := range groups { + g := auth.GetGroupByID(v.GroupID) converted[k] = &generated.Group{ - ID: v.ID, - Name: v.Name, + ID: g.ID, + Name: g.Name, } } @@ -174,12 +189,27 @@ func (r *userResolver) Groups(ctx context.Context, _ *generated.User) ([]*genera } func (r *userResolver) Roles(ctx context.Context, _ *generated.User) (*generated.UserRoles, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "User.guides") + wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } + + groups, err := user.QueryGroups().All(ctx) + if err != nil { + return nil, err + } - roles := user.GetRoles(newCtx) + roles := make(map[*auth.Role]bool) + + for _, group := range groups { + gr := auth.GetGroupByID(group.GroupID) + for _, role := range gr.Roles { + roles[role] = true + } + } userRoles := &generated.UserRoles{} @@ -265,7 +295,10 @@ func (r *mutationResolver) DiscourseSso(ctx context.Context, sso string, sig str return nil, fmt.Errorf("failed to decode sso: %w", err) } - user := ctx.Value(postgres.UserKey{}).(*postgres.User) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } if user == nil { return nil, errors.New("user not logged in") diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index c460e50f..b71cc793 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "github.com/satisfactorymodding/smr-api/dataloader" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/integrations" @@ -130,7 +131,7 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri } else { slox.Info(ctx, "completed version upload") } - }(util.ReWrapCtx(ctx), mod, versionID, version) + }(db.ReWrapCtx(ctx), mod, versionID, version) return true, nil } @@ -187,7 +188,7 @@ func (r *mutationResolver) ApproveVersion(ctx context.Context, versionID string) mod.LastVersionDate = &now postgres.Save(newCtx, &mod) - go integrations.NewVersion(util.ReWrapCtx(ctx), dbVersion) + go integrations.NewVersion(db.ReWrapCtx(ctx), dbVersion) return true, nil } diff --git a/gql/versions.go b/gql/versions.go index 14ec5ba7..34138cda 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -11,6 +11,7 @@ import ( "github.com/Vilsol/slox" "github.com/pkg/errors" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/integrations" @@ -199,7 +200,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI mod.LastVersionDate = &now postgres.Save(ctx, &mod) - go integrations.NewVersion(util.ReWrapCtx(ctx), dbVersion) + go integrations.NewVersion(db.ReWrapCtx(ctx), dbVersion) } else { slox.Info(ctx, "Submitting version job for virus scan") jobs.SubmitJobScanModOnVirusTotalTask(ctx, mod.ID, dbVersion.ID, true) diff --git a/migrations/sql/000025_add_rng.down.sql b/migrations/sql/000025_add_rng.down.sql new file mode 100644 index 00000000..a0729f43 --- /dev/null +++ b/migrations/sql/000025_add_rng.down.sql @@ -0,0 +1 @@ +DROP FUNCTION generate_random_id(length integer); diff --git a/migrations/sql/000025_add_rng.up.sql b/migrations/sql/000025_add_rng.up.sql new file mode 100644 index 00000000..606ac908 --- /dev/null +++ b/migrations/sql/000025_add_rng.up.sql @@ -0,0 +1,16 @@ +Create or replace function generate_random_id(length integer) returns text as +$$ +declare + chars text[] := '{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}'; + result text := ''; + i integer := 0; +begin + if length < 0 then + raise exception 'Given length cannot be less than 0'; + end if; + for i in 1..length loop + result := result || chars[1+random()*(array_length(chars, 1)-1)]; + end loop; + return result; +end; +$$ language plpgsql; \ No newline at end of file diff --git a/migrations/sql/000026_add_id_columns.down.sql b/migrations/sql/000026_add_id_columns.down.sql new file mode 100644 index 00000000..9270f460 --- /dev/null +++ b/migrations/sql/000026_add_id_columns.down.sql @@ -0,0 +1,8 @@ +ALTER TABLE user_groups + DROP COLUMN id; + +ALTER TABLE sml_version_targets + DROP COLUMN id; + +ALTER TABLE version_targets + DROP COLUMN id; \ No newline at end of file diff --git a/migrations/sql/000026_add_id_columns.up.sql b/migrations/sql/000026_add_id_columns.up.sql new file mode 100644 index 00000000..406b75cc --- /dev/null +++ b/migrations/sql/000026_add_id_columns.up.sql @@ -0,0 +1,26 @@ +-- user_groups + +ALTER TABLE user_groups + ADD COLUMN IF NOT EXISTS id varchar(14) default generate_random_id(14); + +create unique index if not exists uix_user_groups_id on user_groups (id); + +UPDATE user_groups SET id = generate_random_id(14) WHERE true; + +-- sml_version_targets + +ALTER TABLE sml_version_targets + ADD COLUMN IF NOT EXISTS id varchar(14) default generate_random_id(14); + +create unique index if not exists uix_sml_version_targets_id on sml_version_targets (id); + +UPDATE sml_version_targets SET id = generate_random_id(14) WHERE true; + +-- version_targets + +ALTER TABLE version_targets + ADD COLUMN IF NOT EXISTS id varchar(14) default generate_random_id(14); + +create unique index if not exists uix_version_targets_id on version_targets (id); + +UPDATE version_targets SET id = generate_random_id(14) WHERE true; \ No newline at end of file diff --git a/models/filters.go b/models/filters.go index 72d1be24..2a384999 100644 --- a/models/filters.go +++ b/models/filters.go @@ -291,44 +291,3 @@ func ApplyChanges(changes interface{}, to interface{}) error { return nil } - -type BootstrapVersionFilter struct { - Limit *int `json:"limit" validate:"omitempty,min=1,max=100"` - Offset *int `json:"offset" validate:"omitempty,min=0"` - OrderBy *generated.BootstrapVersionFields `json:"order_by"` - Order *generated.Order `json:"order"` - Search *string `json:"search" validate:"omitempty,min=3"` - Ids []string `json:"ids" validate:"omitempty,max=100"` -} - -func DefaultBootstrapVersionFilter() *BootstrapVersionFilter { - limit := 10 - offset := 0 - order := generated.OrderDesc - orderBy := generated.BootstrapVersionFieldsCreatedAt - return &BootstrapVersionFilter{ - Limit: &limit, - Offset: &offset, - Ids: nil, - Order: &order, - OrderBy: &orderBy, - } -} - -func ProcessBootstrapVersionFilter(filter map[string]interface{}) (*BootstrapVersionFilter, error) { - base := DefaultBootstrapVersionFilter() - - 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 BootstrapVersionFilter: %w", err) - } - - return base, nil -} diff --git a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go index 28759521..7906c56b 100644 --- a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go +++ b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go @@ -15,11 +15,11 @@ import ( "github.com/Vilsol/slox" "github.com/vmihailenco/taskq/v3" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" "github.com/satisfactorymodding/smr-api/storage" - "github.com/satisfactorymodding/smr-api/util" "github.com/satisfactorymodding/smr-api/validation" ) @@ -93,7 +93,7 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { mod.LastVersionDate = &now postgres.Save(ctx, &mod) - go integrations.NewVersion(util.ReWrapCtx(ctx), version) + go integrations.NewVersion(db.ReWrapCtx(ctx), version) } return nil diff --git a/schemas/bootstrap_version.graphql b/schemas/bootstrap_version.graphql deleted file mode 100755 index be3c4f41..00000000 --- a/schemas/bootstrap_version.graphql +++ /dev/null @@ -1,73 +0,0 @@ -### Types - -scalar BootstrapVersionID - -type BootstrapVersion { - id: BootstrapVersionID! - version: String! - satisfactory_version: Int! - stability: VersionStabilities! - link: String! - changelog: String! - date: Date! - - updated_at: Date! - created_at: Date! -} - -type GetBootstrapVersions { - bootstrap_versions: [BootstrapVersion!]! - count: Int! -} - -enum BootstrapVersionFields { - name - created_at - updated_at - satisfactory_version - date -} - -### Inputs - -input NewBootstrapVersion { - version: String! - satisfactory_version: Int! - stability: VersionStabilities! - link: String! - changelog: String! - date: Date! -} - -input UpdateBootstrapVersion { - version: String - satisfactory_version: Int - stability: VersionStabilities - link: String - changelog: String - date: Date -} - -input BootstrapVersionFilter { - limit: Int - offset: Int - order_by: BootstrapVersionFields - order: Order - search: String - ids: [String!] -} - -### Queries - -extend type Query { - getBootstrapVersion(bootstrapVersionID: BootstrapVersionID!): BootstrapVersion - getBootstrapVersions(filter: BootstrapVersionFilter): GetBootstrapVersions! -} - -### Mutations - -extend type Mutation { - createBootstrapVersion(bootstrapVersion: NewBootstrapVersion!): BootstrapVersion @canEditBootstrapVersions @isLoggedIn - updateBootstrapVersion(bootstrapVersionId: BootstrapVersionID!, bootstrapVersion: UpdateBootstrapVersion!): BootstrapVersion! @canEditBootstrapVersions @isLoggedIn - deleteBootstrapVersion(bootstrapVersionId: BootstrapVersionID!): Boolean! @canEditBootstrapVersions @isLoggedIn -} diff --git a/shell.nix b/shell.nix index 90d31232..79a57276 100644 --- a/shell.nix +++ b/shell.nix @@ -12,5 +12,6 @@ pkgs.mkShell { protoc-gen-go-grpc minio-client unstable.golangci-lint + unstable.delve ]; } diff --git a/storage/storage.go b/storage/storage.go index 8451dfb7..33421a4d 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -81,8 +81,6 @@ func configToStorage(ctx context.Context, config Config) Storage { } panic("Unknown storage type: " + viper.GetString("storage.type")) - - return nil } func StartUploadMultipartMod(ctx context.Context, modID string, name string, versionID string) (bool, string) { diff --git a/tests/announcements_test.go b/tests/announcements_test.go index 7a7d30e7..cbe31a0d 100644 --- a/tests/announcements_test.go +++ b/tests/announcements_test.go @@ -1,11 +1,13 @@ 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/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" @@ -15,6 +17,7 @@ func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") postgres.EnableDebug() + db.EnableDebug() } func TestAnnouncements(t *testing.T) { @@ -26,102 +29,114 @@ func TestAnnouncements(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - // Create - createAnnouncement := authRequest(`mutation { - createAnnouncement(announcement: { - importance: Alert, - message: "Hello World" - }) { - id - } - }`, token) - - var createAnnouncementResponse struct { - CreateAnnouncement generated.Announcement - } - testza.AssertNoError(t, client.Run(ctx, createAnnouncement, &createAnnouncementResponse)) - testza.AssertNotEqual(t, "", createAnnouncementResponse.CreateAnnouncement.ID) - - // Query One - queryAnnouncement := authRequest(`query ($id: AnnouncementID!) { - getAnnouncement(announcementId: $id) { - id - message - importance - } - }`, token) - queryAnnouncement.Var("id", createAnnouncementResponse.CreateAnnouncement.ID) - - var queryAnnouncementResponse struct { - GetAnnouncement generated.Announcement - } - testza.AssertNoError(t, client.Run(ctx, queryAnnouncement, &queryAnnouncementResponse)) - testza.AssertEqual(t, createAnnouncementResponse.CreateAnnouncement.ID, queryAnnouncementResponse.GetAnnouncement.ID) - testza.AssertEqual(t, "Hello World", queryAnnouncementResponse.GetAnnouncement.Message) - testza.AssertEqual(t, generated.AnnouncementImportanceAlert, queryAnnouncementResponse.GetAnnouncement.Importance) - - // Update - updateAnnouncement := authRequest(`mutation ($id: AnnouncementID!) { - updateAnnouncement( - announcementId: $id, - announcement: { - importance: Fix, - message: "Foo Bar" + t.Run(strconv.Itoa(i), func(t *testing.T) { + var announcementID string + + t.Run("Create", func(t *testing.T) { + createAnnouncement := authRequest(`mutation { + createAnnouncement(announcement: { + importance: Alert, + message: "Hello World" + }) { + id + } + }`, token) + + var createAnnouncementResponse struct { + CreateAnnouncement generated.Announcement } - ) { - id - } - }`, token) - updateAnnouncement.Var("id", createAnnouncementResponse.CreateAnnouncement.ID) - - var updateAnnouncementResponse struct { - UpdateAnnouncement generated.Announcement - } - testza.AssertNoError(t, client.Run(ctx, updateAnnouncement, &updateAnnouncementResponse)) - - // Query Many - queryAnnouncements := authRequest(`query { - getAnnouncements { - id - message - importance - } - }`, token) - - var queryAnnouncementsResponse struct { - GetAnnouncements []generated.Announcement - } - testza.AssertNoError(t, client.Run(ctx, queryAnnouncements, &queryAnnouncementsResponse)) - testza.AssertEqual(t, 1, len(queryAnnouncementsResponse.GetAnnouncements)) - testza.AssertEqual(t, createAnnouncementResponse.CreateAnnouncement.ID, queryAnnouncementsResponse.GetAnnouncements[0].ID) - testza.AssertEqual(t, "Foo Bar", queryAnnouncementsResponse.GetAnnouncements[0].Message) - testza.AssertEqual(t, generated.AnnouncementImportanceFix, queryAnnouncementsResponse.GetAnnouncements[0].Importance) - - // Query By Importance - getAnnouncementsByImportance := authRequest(`query { - getAnnouncementsByImportance(importance: Info) { - id - message - importance - } - }`, token) - - var getAnnouncementsByImportanceResponse struct { - GetAnnouncements []generated.Announcement - } - testza.AssertNoError(t, client.Run(ctx, getAnnouncementsByImportance, &getAnnouncementsByImportanceResponse)) - testza.AssertEqual(t, 0, len(getAnnouncementsByImportanceResponse.GetAnnouncements)) - - // Delete - deleteAnnouncement := authRequest(`mutation ($id: AnnouncementID!) { - deleteAnnouncement(announcementId: $id) - }`, token) - deleteAnnouncement.Var("id", createAnnouncementResponse.CreateAnnouncement.ID) - - var deleteAnnouncementResponse struct { - DeleteAnnouncement bool - } - testza.AssertNoError(t, client.Run(ctx, deleteAnnouncement, &deleteAnnouncementResponse)) - testza.AssertTrue(t, deleteAnnouncementResponse.DeleteAnnouncement) + testza.AssertNoError(t, client.Run(ctx, createAnnouncement, &createAnnouncementResponse)) + testza.AssertNotEqual(t, "", createAnnouncementResponse.CreateAnnouncement.ID) + + announcementID = createAnnouncementResponse.CreateAnnouncement.ID + }) + + t.Run("Query One", func(t *testing.T) { + queryAnnouncement := authRequest(`query ($id: AnnouncementID!) { + getAnnouncement(announcementId: $id) { + id + message + importance + } + }`, token) + queryAnnouncement.Var("id", announcementID) + + var queryAnnouncementResponse struct { + GetAnnouncement generated.Announcement + } + testza.AssertNoError(t, client.Run(ctx, queryAnnouncement, &queryAnnouncementResponse)) + testza.AssertEqual(t, announcementID, queryAnnouncementResponse.GetAnnouncement.ID) + testza.AssertEqual(t, "Hello World", queryAnnouncementResponse.GetAnnouncement.Message) + testza.AssertEqual(t, generated.AnnouncementImportanceAlert, queryAnnouncementResponse.GetAnnouncement.Importance) + }) + + t.Run("Update", func(t *testing.T) { + updateAnnouncement := authRequest(`mutation ($id: AnnouncementID!) { + updateAnnouncement( + announcementId: $id, + announcement: { + importance: Fix, + message: "Foo Bar" + } + ) { + id + } + }`, token) + updateAnnouncement.Var("id", announcementID) + + var updateAnnouncementResponse struct { + UpdateAnnouncement generated.Announcement + } + testza.AssertNoError(t, client.Run(ctx, updateAnnouncement, &updateAnnouncementResponse)) + }) + + t.Run("Query Many", func(t *testing.T) { + queryAnnouncements := authRequest(`query { + getAnnouncements { + id + message + importance + } + }`, token) + + var queryAnnouncementsResponse struct { + GetAnnouncements []generated.Announcement + } + testza.AssertNoError(t, client.Run(ctx, queryAnnouncements, &queryAnnouncementsResponse)) + testza.AssertEqual(t, 1, len(queryAnnouncementsResponse.GetAnnouncements)) + testza.AssertEqual(t, announcementID, queryAnnouncementsResponse.GetAnnouncements[0].ID) + testza.AssertEqual(t, "Foo Bar", queryAnnouncementsResponse.GetAnnouncements[0].Message) + testza.AssertEqual(t, generated.AnnouncementImportanceFix, queryAnnouncementsResponse.GetAnnouncements[0].Importance) + }) + + t.Run("Query By Importance", func(t *testing.T) { + getAnnouncementsByImportance := authRequest(`query { + getAnnouncementsByImportance(importance: Info) { + id + message + importance + } + }`, token) + + var getAnnouncementsByImportanceResponse struct { + GetAnnouncements []generated.Announcement + } + testza.AssertNoError(t, client.Run(ctx, getAnnouncementsByImportance, &getAnnouncementsByImportanceResponse)) + testza.AssertEqual(t, 0, len(getAnnouncementsByImportanceResponse.GetAnnouncements)) + }) + + t.Run("Delete", func(t *testing.T) { + deleteAnnouncement := authRequest(`mutation ($id: AnnouncementID!) { + deleteAnnouncement(announcementId: $id) + }`, token) + deleteAnnouncement.Var("id", announcementID) + + var deleteAnnouncementResponse struct { + DeleteAnnouncement bool + } + testza.AssertNoError(t, client.Run(ctx, deleteAnnouncement, &deleteAnnouncementResponse)) + testza.AssertTrue(t, deleteAnnouncementResponse.DeleteAnnouncement) + }) + }) } } diff --git a/tests/bootstrap_versions_test.go b/tests/bootstrap_versions_test.go deleted file mode 100644 index 8c565814..00000000 --- a/tests/bootstrap_versions_test.go +++ /dev/null @@ -1,137 +0,0 @@ -package tests - -import ( - "strconv" - "testing" - - "github.com/MarvinJWendt/testza" - - "github.com/satisfactorymodding/smr-api/config" - "github.com/satisfactorymodding/smr-api/db/postgres" - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/migrations" -) - -func init() { - migrations.SetMigrationDir("../migrations") - config.SetConfigDir("../") - postgres.EnableDebug() -} - -func TestBootstrapVersions(t *testing.T) { - ctx, client, stop := setup() - defer stop() - - token, _, err := makeUser(ctx) - testza.AssertNoError(t, err) - - // Run Twice to detect any cache issues - for i := 0; i < 2; i++ { - version := strconv.Itoa(i+1) + ".0.0" - - // Create - createBootstrapVersion := authRequest(`mutation ($version: String!) { - createBootstrapVersion(bootstrapVersion: { - version: $version, - satisfactory_version: 12345, - stability: beta, - link: "example.com", - changelog: "Hello World", - date: "2006-01-02T15:04:05Z" - }) { - id - } - }`, token) - createBootstrapVersion.Var("version", version) - - var createBootstrapVersionResponse struct { - CreateBootstrapVersion generated.BootstrapVersion - } - testza.AssertNoError(t, client.Run(ctx, createBootstrapVersion, &createBootstrapVersionResponse)) - testza.AssertNotEqual(t, "", createBootstrapVersionResponse.CreateBootstrapVersion.ID) - - // Query One - queryBootstrapVersion := authRequest(`query ($id: BootstrapVersionID!) { - getBootstrapVersion(bootstrapVersionID: $id) { - id - version - satisfactory_version - stability - link - changelog - date - } - }`, token) - queryBootstrapVersion.Var("id", createBootstrapVersionResponse.CreateBootstrapVersion.ID) - - var queryBootstrapVersionResponse struct { - GetBootstrapVersion generated.BootstrapVersion - } - testza.AssertNoError(t, client.Run(ctx, queryBootstrapVersion, &queryBootstrapVersionResponse)) - testza.AssertEqual(t, createBootstrapVersionResponse.CreateBootstrapVersion.ID, queryBootstrapVersionResponse.GetBootstrapVersion.ID) - testza.AssertEqual(t, version, queryBootstrapVersionResponse.GetBootstrapVersion.Version) - testza.AssertEqual(t, 12345, queryBootstrapVersionResponse.GetBootstrapVersion.SatisfactoryVersion) - testza.AssertEqual(t, generated.VersionStabilitiesBeta, queryBootstrapVersionResponse.GetBootstrapVersion.Stability) - testza.AssertEqual(t, "example.com", queryBootstrapVersionResponse.GetBootstrapVersion.Link) - testza.AssertEqual(t, "Hello World", queryBootstrapVersionResponse.GetBootstrapVersion.Changelog) - - // Update - updateBootstrapVersion := authRequest(`mutation ($id: BootstrapVersionID!) { - updateBootstrapVersion( - bootstrapVersionId: $id, - bootstrapVersion: { - changelog: "Foo Bar", - } - ) { - id - } - }`, token) - updateBootstrapVersion.Var("id", createBootstrapVersionResponse.CreateBootstrapVersion.ID) - - var updateBootstrapVersionResponse struct { - UpdateBootstrapVersion generated.BootstrapVersion - } - testza.AssertNoError(t, client.Run(ctx, updateBootstrapVersion, &updateBootstrapVersionResponse)) - - // Query Many - queryBootstrapVersions := authRequest(`query { - getBootstrapVersions { - count - bootstrap_versions { - id - version - satisfactory_version - stability - link - changelog - date - } - } - }`, token) - - var queryBootstrapVersionsResponse struct { - GetBootstrapVersions generated.GetBootstrapVersions - } - testza.AssertNoError(t, client.Run(ctx, queryBootstrapVersions, &queryBootstrapVersionsResponse)) - testza.AssertEqual(t, 1, queryBootstrapVersionsResponse.GetBootstrapVersions.Count) - testza.AssertEqual(t, 1, len(queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions)) - testza.AssertEqual(t, createBootstrapVersionResponse.CreateBootstrapVersion.ID, queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].ID) - testza.AssertEqual(t, version, queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].Version) - testza.AssertEqual(t, 12345, queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].SatisfactoryVersion) - testza.AssertEqual(t, generated.VersionStabilitiesBeta, queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].Stability) - testza.AssertEqual(t, "example.com", queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].Link) - testza.AssertEqual(t, "Foo Bar", queryBootstrapVersionsResponse.GetBootstrapVersions.BootstrapVersions[0].Changelog) - - // Delete - deleteBootstrapVersion := authRequest(`mutation ($id: BootstrapVersionID!) { - deleteBootstrapVersion(bootstrapVersionId: $id) - }`, token) - deleteBootstrapVersion.Var("id", createBootstrapVersionResponse.CreateBootstrapVersion.ID) - - var deleteBootstrapVersionResponse struct { - DeleteBootstrapVersion bool - } - testza.AssertNoError(t, client.Run(ctx, deleteBootstrapVersion, &deleteBootstrapVersionResponse)) - testza.AssertTrue(t, deleteBootstrapVersionResponse.DeleteBootstrapVersion) - } -} diff --git a/tests/guides_test.go b/tests/guides_test.go index 5faa88b1..96da84a9 100644 --- a/tests/guides_test.go +++ b/tests/guides_test.go @@ -1,11 +1,13 @@ 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/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" @@ -15,6 +17,7 @@ func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") postgres.EnableDebug() + db.EnableDebug() } func TestGuides(t *testing.T) { @@ -26,103 +29,114 @@ func TestGuides(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - // Create - createGuide := authRequest(`mutation { - createGuide(guide: { - name: "Hello World", - short_description: "Short description about the guide", - guide: "The full guide text goes here." - }) { - id - } - }`, token) - - var createGuideResponse struct { - CreateGuide generated.Guide - } - testza.AssertNoError(t, client.Run(ctx, createGuide, &createGuideResponse)) - testza.AssertNotEqual(t, "", createGuideResponse.CreateGuide.ID) - - // Query One - queryGuide := authRequest(`query ($id: GuideID!) { - getGuide(guideId: $id) { - id - name - short_description - guide - user { - id + t.Run(strconv.Itoa(i), func(t *testing.T) { + var guideID string + + t.Run("Create", func(t *testing.T) { + createGuide := authRequest(`mutation { + createGuide(guide: { + name: "Hello World", + short_description: "Short description about the guide", + guide: "The full guide text goes here." + }) { + id + } + }`, token) + + var createGuideResponse struct { + CreateGuide generated.Guide } - } - }`, token) - queryGuide.Var("id", createGuideResponse.CreateGuide.ID) - - var queryGuideResponse struct { - GetGuide generated.Guide - } - testza.AssertNoError(t, client.Run(ctx, queryGuide, &queryGuideResponse)) - testza.AssertEqual(t, createGuideResponse.CreateGuide.ID, queryGuideResponse.GetGuide.ID) - testza.AssertEqual(t, "Hello World", queryGuideResponse.GetGuide.Name) - testza.AssertEqual(t, "Short description about the guide", queryGuideResponse.GetGuide.ShortDescription) - testza.AssertEqual(t, "The full guide text goes here.", queryGuideResponse.GetGuide.Guide) - testza.AssertEqual(t, userID, queryGuideResponse.GetGuide.User.ID) - - // Update - updateGuide := authRequest(`mutation ($id: GuideID!) { - updateGuide( - guideId: $id, - guide: { - name: "Foo Bar" + testza.AssertNoError(t, client.Run(ctx, createGuide, &createGuideResponse)) + testza.AssertNotEqual(t, "", createGuideResponse.CreateGuide.ID) + + guideID = createGuideResponse.CreateGuide.ID + }) + + t.Run("Query One", func(t *testing.T) { + queryGuide := authRequest(`query ($id: GuideID!) { + getGuide(guideId: $id) { + id + name + short_description + guide + user { + id + } + } + }`, token) + queryGuide.Var("id", guideID) + + var queryGuideResponse struct { + GetGuide generated.Guide } - ) { - id - } - }`, token) - updateGuide.Var("id", createGuideResponse.CreateGuide.ID) - - var updateGuideResponse struct { - UpdateGuide generated.Guide - } - testza.AssertNoError(t, client.Run(ctx, updateGuide, &updateGuideResponse)) - - // Query Many - queryGuides := authRequest(`query { - getGuides { - count - guides { - id - name - short_description - guide - user { + testza.AssertNoError(t, client.Run(ctx, queryGuide, &queryGuideResponse)) + testza.AssertEqual(t, guideID, queryGuideResponse.GetGuide.ID) + testza.AssertEqual(t, "Hello World", queryGuideResponse.GetGuide.Name) + testza.AssertEqual(t, "Short description about the guide", queryGuideResponse.GetGuide.ShortDescription) + testza.AssertEqual(t, "The full guide text goes here.", queryGuideResponse.GetGuide.Guide) + testza.AssertEqual(t, userID, queryGuideResponse.GetGuide.User.ID) + }) + + t.Run("Update", func(t *testing.T) { + updateGuide := authRequest(`mutation ($id: GuideID!) { + updateGuide( + guideId: $id, + guide: { + name: "Foo Bar" + } + ) { id - } + } + }`, token) + updateGuide.Var("id", guideID) + + var updateGuideResponse struct { + UpdateGuide generated.Guide + } + testza.AssertNoError(t, client.Run(ctx, updateGuide, &updateGuideResponse)) + }) + + t.Run("Query Many", func(t *testing.T) { + queryGuides := authRequest(`query { + getGuides { + count + guides { + id + name + short_description + guide + user { + id + } + } + } + }`, token) + + var queryGuidesResponse struct { + GetGuides generated.GetGuides + } + testza.AssertNoError(t, client.Run(ctx, queryGuides, &queryGuidesResponse)) + testza.AssertEqual(t, 1, queryGuidesResponse.GetGuides.Count) + testza.AssertEqual(t, 1, len(queryGuidesResponse.GetGuides.Guides)) + testza.AssertEqual(t, guideID, queryGuidesResponse.GetGuides.Guides[0].ID) + testza.AssertEqual(t, "Foo Bar", queryGuidesResponse.GetGuides.Guides[0].Name) + testza.AssertEqual(t, "Short description about the guide", queryGuidesResponse.GetGuides.Guides[0].ShortDescription) + testza.AssertEqual(t, "The full guide text goes here.", queryGuidesResponse.GetGuides.Guides[0].Guide) + testza.AssertEqual(t, userID, queryGuidesResponse.GetGuides.Guides[0].User.ID) + }) + + t.Run("Delete", func(t *testing.T) { + deleteGuide := authRequest(`mutation ($id: GuideID!) { + deleteGuide(guideId: $id) + }`, token) + deleteGuide.Var("id", guideID) + + var deleteGuideResponse struct { + DeleteGuide bool } - } - }`, token) - - var queryGuidesResponse struct { - GetGuides generated.GetGuides - } - testza.AssertNoError(t, client.Run(ctx, queryGuides, &queryGuidesResponse)) - testza.AssertEqual(t, 1, queryGuidesResponse.GetGuides.Count) - testza.AssertEqual(t, 1, len(queryGuidesResponse.GetGuides.Guides)) - testza.AssertEqual(t, createGuideResponse.CreateGuide.ID, queryGuidesResponse.GetGuides.Guides[0].ID) - testza.AssertEqual(t, "Foo Bar", queryGuidesResponse.GetGuides.Guides[0].Name) - testza.AssertEqual(t, "Short description about the guide", queryGuidesResponse.GetGuides.Guides[0].ShortDescription) - testza.AssertEqual(t, "The full guide text goes here.", queryGuidesResponse.GetGuides.Guides[0].Guide) - testza.AssertEqual(t, userID, queryGuidesResponse.GetGuides.Guides[0].User.ID) - - // Delete - deleteGuide := authRequest(`mutation ($id: GuideID!) { - deleteGuide(guideId: $id) - }`, token) - deleteGuide.Var("id", createGuideResponse.CreateGuide.ID) - - var deleteGuideResponse struct { - DeleteGuide bool - } - testza.AssertNoError(t, client.Run(ctx, deleteGuide, &deleteGuideResponse)) - testza.AssertTrue(t, deleteGuideResponse.DeleteGuide) + testza.AssertNoError(t, client.Run(ctx, deleteGuide, &deleteGuideResponse)) + testza.AssertTrue(t, deleteGuideResponse.DeleteGuide) + }) + }) } } diff --git a/tests/paks/.gitignore b/tests/paks/.gitignore new file mode 100644 index 00000000..35838c50 --- /dev/null +++ b/tests/paks/.gitignore @@ -0,0 +1 @@ +!*.smod \ No newline at end of file diff --git a/tests/paks/Test_mod_for_Vilsol-1.0.1.smod b/tests/paks/Test_mod_for_Vilsol-1.0.1.smod new file mode 100644 index 0000000000000000000000000000000000000000..fd7dceff1c3d221c9a01c00ab3b49e236f106615 GIT binary patch literal 90686 zcmV(>K-j-fO9KQH000080M&{!S7B-Sc=iAQ0O<h$02KfL09I*ib8l=^Wpi{*Z)7fY zaBOvFX>M(h!D_=W3_#B*^dE-LBP^6%c5KqZpc!M?dKnwIi5A2h+t>~)l>Yl<Cn5FN zMMm#QLe_b`O4uF+9Kl#rl0DpPZarJ_>^gtq9S~z#dY5J_m<qb3_*(1@f^5Vv_Z(4J zC0@b0QZ-{q0k$@%-PAn7oI7Zh89brN24y=51EiX5Fcq2t+tctzy}cZkNrkFy1WInc z!D+#3h<Md&t&EFU&SkEo;}{;0j+8S!1o>#U;P~?IFD~qCc0U>ncGSVezZKGw5zs{R zS@bPROYEJ}<m^Mj=G#@}A#6n`zW3)Qy`K(FZYTL^9PBss>_XvVy}JAYP)h>@6aWAK z2mp#@NK_7S$TfmI0RVG60RR;M002^Db8mHWV`XzMNn>wrF)}zVaBgRGn$=&_T@%26 zyRg90-QC^Y-QC>{(y1a#hcrkDNJ>kGAh5J_2`G(7cQ?GxKk&}QnKKtNS94}Q=Q|Up zt*L~8N{R{q0EUXPye<HM|GR<#6omg&|5y5-{~5H}>iP=*ng36aAdvq~1TYu`0`W1@ zprAmRIe4w@op}U=4GfIEgWf7Ct7>UzOUcN3_yycOJ{#J*nYnn13kk~W8ecy=E9jdm zNQlaa2n%p<&@!?bI(vu+3d;QFp{Xg(%Oj_xBEUqWqHiQGD=Q@^pl5AwXyvG-tEVa_ zBPAwkXy>41X)hxwEvKa~#LKH=;%#DPW$EE%ZfT`sX`^fJswyFDYVW2ZEqQkTJic<E zY+|Kr?P6eMrD<p`sidZ%s$ymDsGzBRdH-zW<TLzd&&tK4d+uM~!VU!m<<`;F-r0?^ zp~dm#o!i?`Q7O5Ln+J0@KM_uLH8VRU6;)LuQ)x-@*^MK1ZeB5Q32S%XrJb|&{fmz2 zzua_Gdb-*g=GI1TKAOr3dWMG5a`MVbicW6sa)JVCI)*wXHZuHNx*Dq5rWQ6{{w8K- z2F4}}TPM2q9!v}jrcN%LY-}wP8`ieAX4VddCKjIW!n9<?%{~3-Nr+^4Sn5Ys^_8Ug zSXgA#4O{}=ncCU%i%2?p_}cirb8vPtRhReh^l&uR<Pi|@4G3`b4sr;9d4<IUhJSST z@we1f#UmhoV`UJLlpgp#G&(-s#8BVU$=cHWU2uFxYJT~9PX}8w!_-eXuJ2>RA|m>S z#|ld;n|};C*jPXykZ(=xYI@ESGYerECGUg%m)17F)O4~+so{8x$o`iH#D2P(dH@&& zm!6m#lTw*YT6n{7ZEbaJy?iaY{~eVj8UPa6Q<0a^4_Z3<C4&j0Mwi$5%Gv&!_$C30 zV;>f$vlrTAjX{z7Unogxd=@Z`GX*`*vy4k3C5m@j7<N12LE|O00cNW#^kmrb+di`C zw!e6ziP-e>wR%Woo`x}KKH>ExPn^#mw%H?F0A=MCd~&}Z{p;X%vd-{lY7su^K~f5! z_erM^m)*a9T$ZDucgGjsu8*KfA@Obsaeo&3hpt)V3&s@|4`2|Jg+fU<@O~eZ->O+d zC~mFaypk9{(-L&>!*;?F458A`oL|<sRB$4Z?3-DDy}-w^w`Pj0){uR!6h`RL6~g_F zI=Eq<rWBQwQTuS}V)Y@EZ=3ynPJ^vwxeaxVu4))<X0hSOK@NnG{v$)luCmFWCj`-; zghq$61>a137MZ@9=a~0_rR}xh(z3<xPX{GKC6@!co6>K0B=0%j4U#dmPla7E20g7K z@P*!#@0D*b#Te$bo}IJQ2RHn2w_E`xkZt?3tLUes_e2D87%I&jHO#}$T=pZ&e^<_@ zSzV|dEoVRiMPL>$RFX(UP~R9Sh}DX5qY{_ZQGn;o<1-=gW5a2uo<+<{xM+ffP{6fT zo~DfJxA0%nMAqzQ!KA-G6~66d78mvKR!eAW*)Us-(z{!+zy_;BS5H$j-crw$>nt^) zh%@F~%2^d~z$o4}y?aIvt~VZ?`92ZmuL_zBQ*wZhOTFJM#=0~*8b(T8_ju&8>dt$7 zK~D(BMo>MXktap*r$P=rTO=+mWh*W|C#87Hk`xLht$#7boQqFUdUYxs>A+FJu-Vw* zMn59Sqv^O-WK8~0C@C@>MNAh~j$=0Wr9s20lVf%x$9?TevRx$%iuD~~XDamJs7Lgn z`r7vSY0#tR82g^@-DoTiitXOnRxM9!m5)=co2*dw=u%Y!`m_ebm?c{XI{_=}JUmTa z*&Lq+ClvNgUjyS3b97YIK-%u76#sn8sGx>jwT!xTVO-idRGkj-O8=v9aW5&=4<iQi zvGi^NCN|OEd0)4|C68e|`T^2gvWd?m!PCdLolaweZ~gtTN<G7d%i!ZZPpAD{Gocsn zBQ}sF&-A!QiO<OnjrB}?wl+}96J`Y8)>1%pRY}I8sHZT-MtQ@KEn=mnbQXDZP2^BP zh($@#BM{@T8rUKN>dY`5JCQc7qGDvDtYMJ_i<`zb^&J^Xdzt2JeiO#%%?4-IPiCLw z=ED(K=EE`sXrpxX>PZ`;P$`XYN-)Eitt(f)_uJnW)(6D>@o9&LoI5$5IdGo@e%=*U zlG39NK^5N<NcsCZcGmxU+qUJ;o1OwX0S+<K%dd2MzcT4z$_yraK^Glo4OdG8zxUY3 z%)f%RQ*hB8{dVA@+HwQ!nZ$3@*w1Rrq5V-;=T~}M@s(m65-Q;Mf@0;b+MIlvA~Dv% z6V<doI1x6n7F-j*I$q*`E^S8;5WeQod+>^kl^;p)pCrvEQU4T|^vN8(5!F-PQrPK2 zD`EznO47L`k4xpj%^CHM6|Uj6c4Emvv`^aJ19|aA8mD~i?C&v_T0XY9j~$y!A%9A9 zj@LX)F7TFTkhzGW)5;K#ubM{x^G~+tQwo~E`6<EF)(DkOic_<ax<XL4vl(|qxw$pi zLN)@q)IMidxb+x^5X!KhPVhicw~spJNHEuEqN9(4IvlUTW)4DCWp2l+gvwoaf;kxI z;%jUu0=>)bCOhYwm31R*{GSznFn7}9`$H`w&#klNW{NPObjsO!G?Cm{A_hs}At)hf zlKVxToo`K|eBd}-jT=~3!E5@<Nn69c7VDMC`u?IS+rbwf43Y^aZSbw?*b_jth@a&I zDk!gF4_%GpemtYU{aA%TRs&Y{y4)%Wv<kWZB&D~JLGrXt?6v;z@h}wm1(~bs;iRNo zno6tCpS`WkIEhKh<4+&K(x`Xvig-8nrdXwyFul5Jq5V5Td2=xn56rf#x~yZv_NL*$ z*5%=3DlT_CGR;I|v?;R%m+*(*rN1@DzJ#dTAm{oVozv|Tv?0oS^eTRMOD%(dyfZ0G zN;pN1`lN_KXorNs?ol=sH0LpExis4+MQ*Qd-HXfqMQPBFS#SVX2W^>B+`emlevX4( zRu54~NE@LJ1)|vvAHjUmN`gOcYu$amkm`MX=)Xk_!K94!h?AsxA0`%=pSBbb(zQ-_ zXiMBSR{Xc|mwQu-pd7o}rv4;*@S^D-%-K-^GIQnfNQBd~emCuZq8y7AL(67{s~$v0 z$oR%`nq%RI$2Of>XlyAdi!>3=N8CyYC=*s(V=vy>O^OmLCV7yWy9mUS3R3Wtc%1N7 z<Emt(^WgC&y6xFHyw^q>tsPo$kbE&@kgpsaB1mmDO48h5PZ5iB62A0{*vltr2j;r* z94L>r(t_}s3VL0A>_L7N5}NA1C&a|4eX%{nGl}RykU|$_IC?A^2-hq4F-1x>V}&WH zcOWT}xAUarqR(9uo&N?yxZGy_>5}2N?zR$r5xUI~hwj6UCPN8FwnK}NmH~OZH&HGg z!0;h%RBq7&&Rp1Tv6do&+f${90%wpKahrI2hl)nreS>k|)wQ}dI;w5>axN3H3?Lp9 zHUGk%6Ocp<)@%Lu^}>>BS{XdS{Oe6AvII$X#FSyEH1pYpJ#r-IwVdRR@1cA<H2ig$ z3KQjIVEL;H#y&Jd;0)QYAtN%PSA_{yr}igCynSset+7t>ojVC!SZgHjNfA*^@#=eX zmCA5Y251*Ff$}SY&=mvH2bQ$-jG%9CsaWHK{~M$p9+McNwpkL$+2?ieLEieqc$a!N ze>8KRA>gGW_=R4WjXYlqanN}p;LxkpLoB5N*)H>NOn$WXmj;C2I!s+4B;>~`SMOtx z_8OrHl09z=UjFA2o<dw~RPpzZWjmM!;$cEBTonJkfiIa-7E<unRjil?fyQ934jMI{ zuoF(A4`I%6`OMLqtJd+Cif&wp+>BqrPmeCSvhgfe-B1I>R&`0l{-BYJ-fY~G%xny2 zSCpjaMbcXbp+1zWs=JobH>Z4Jrebq_atRUrsxv10)VG;3U7QF?<YQp3orTW1X~Ueq zO#ItpltL=Ny)C}Q&Ld#WmDuD`N3-vv{ExX4pb(jrkNd~k+uE9IBZFq6;!IC~%P`Xs zN1mGko*;bky1d%_%#{veLVdF8g+pH-$EfJu-uL#GYhmg9y{dyek1F*3iD;KeNtN!% zrPx?RvUN)cxIk~a*V%idWIjY;=7V}|lCd)1vZpFA;5eB)N3HkMB>e;5%wUJ;B2u8E zZ`qOSuU{K(W7Z}-ecSLvjigKSlRG;K2X?|#!Fy#AaBa?dGe60QoNr#*e9SJpEKFP8 z4L*FOn>B%=hMRa8>I3b}SqS<d@5O)mtokbd!j9g>e5fq}ljx#U64x^@qWB{^EU!3? zGn>m+g_R4PcBzSZ>4JZOxC%f_Pp5+)U{p)5wMzBR2^F3URirxxfxd>1oO?6Cktto| zOk>|Tn^9sFZ&SMwPftD;6<&TUEzv7|yOGo7FEsH;Ho|QuHw4#Ok&-?^Xe&)=B4H}Z z&o?oKoi%&wB)AYS6g(Po^cG#I;M6rN6*6?b!NQCQqL4%UE-lOBnEdN!15BPjlbi<8 zh=~fhv=@g6FuD%K42y4z|Nfoy8P>eWBsXZ&w5*XKj~9x&Xo@L8j4RgRramYGIAZ}C zo`4ufm>1wOuT<CV7X#uFC2UWYnt#pTe!Y1dx8n`4==c51VyS)9Nlq~HjX;>}$h=e_ zhBWabjvF5W^2hB{)n1PB;?p0_`ageF77cXoMlCk58eoVF?zcIs?b|9gQ`)I5ZHyOF z9*#z*XzaaBpJu9U`UL;jVw{CPo2rlZB;bno3t#GJhuT7vy68cY$n~P4hIGR<`UB?l zeY%4=%rk&SguGOBX4d;gT3ab3Y*;TMn}Hm}3x!uVBj58v+^kEYKI$ZkdIz-2*phx@ zaQ-m9GBkrJ4gKMBf%t-e@KW;Px$tG|b(QK%NG7hXr1^8gx4%($o^Rs*ZP5BUL}DU4 zq3+Ds>4Zb$N4pQhD<y($v+b*KU^cqK&%%D+23R?QKcr7X-ov#Tljt+Z604I$%Q_lz z8(c^tpco>^dm*qbk=nkBNk(FfvP4!}Htog7s$;}@HAoY<P(Po`jN&bu$H2ysgC4Pp zUmJQ%o}U^$Tl4kk)gR|GOyqzsXBII$3^5Ip_3}`PeVG-)+Nhjgj>9fs4C@aAp#)+v z9TVBd{^4fKZ-Mkq#i%I{%C37<l(RPUpx(RxD#6+AMd%GW>W0@H`Uoas=c8P>P5Gb5 ze?SKt0mcSW2R&$dm!C{yyilW@gevk#j4W(vk{Mv<ouG&3Bn|p^v1^+!>4-Jb{rg~X zEtZJDWNGkC!aPjAtbN?WmPfq>X5msli@F;i-=b65@Y5Be1s|Il!69F66waPidW&#p zl2JT7`t37bwQX@&2Q^5arxPWdz8pP-$eU%TLdel`1UqWxEpel%dU)}ypGG8rpjwe# z6GVW|N*1m37i$Kj(4}U9D~J*vJ_IT?_>3ELXpi(lOMKUJR(|=qpcRz=(U~BOil5+u zp-eEj{nGp~C=-<ha@U?;rF!rCx7dJvplj+E7J=S-!i?g0p=Q)IB-lac8pC*O83YI@ zS^(UyBMH+Q8-IQOs=oc8g!Su0pEln4OCaF{sS~d0xK6sTamyopM#4;3#GiyGMX2pb zqPL|B=Gsv&X&l=_jw{$Jv3cd)XYUnt34`ebXBt`ghPjSQS+d%PWNARk!rAy0COH*f zKb(!Dk*4@IWe@VLq^&S`Itx`!J(_gL%Z?)m(`_0JiG3V{yDemlsPYVvvK4lgLHJ`B zMwBG=5Q;GQn!fBACWUvR{)0i$E2nzhu<*!LAp7Vjf=vhA<7E_?z@MKpoxUieN>P28 zQGPyLA-_}m--LOg+Z&`g8{A~hFs+$@HEonmx4Qj*Q50Mal{or9pig3r0%R7VKP~EO z-0S!yF@<Sc1y!^$gvO-pduuy$Wg7Oo#LqUsyRdxF=(jOxra}11sdLj@f5jfG<|_pj z++V_F7)kD@=p+RSpiLL46~i03hZzBSeQs89vDQL5Ycu_AtY_T!mPaOY9&_bGocUPO z=NPQDpvPqNpsgf=poY7-C!y=tz5Nedb>CB3sUPH2WHQ}=0<ez3@5iK|>?(cq1>&~| z-jb(2^SS2JeyHX?3rHx<<$OaBFMC5Vf<$DHGlqD@);l%NB4S#warIVib#r%BRM@Zi z`FCa?4RPtLr3DB|{Mf%E-)+(vlobo+YuNG0r}-4l6=h0)NggG!o)WhBO|ETmHy;?! zm}^4Ol{_uqbmuYSEzIB{$tX5ZG1o9)R}J|o3f04S{YT*wPihN0QZ(RpuOrDH=TyKP zQYLSjg~$qg&5`VK6sG<o^EC<^<A*F#3Ybe3d1d%j^9uR;Rf8vn>;BszT)gvZH`3A? zX|O;?)lPVfJU8}T(1gV>NV^Ij+N_s}*f45eas2JGJ52NEf-raA{J{vbDzi#c_86(! zXt9!u0K_zkTJl3>o?}VgOw{+G?1BEB!s36a&d$`oxRG$3<G2RACYJuWXh^E3lmGFZ zO?~*SO99{p6pvi1{3O+=NG+VmRKbvPsE6_{yYDsXV;VP`@vt)xs?u}l=1)JAl_uhI zKt6jm$eTTz)}XP{cS~-PF+h=>k-9^le*(omQ&>T%hdo_4A$M1;^#1J*du^oyDt~L< zLC>mu8Vu=Xdg$KMzwP~`3owh#Y0>QFkmQ#51dc)!?-bBvg%enr-z6PwaPhBy7v}2w zq`{BzXRre-<w)65Q$p*(&({#``lHRng_h$3vK&&CTL%6qWUNl6(aZXV>ANtYI}gV> zGk0Hj6V?{{(3(SvsgRu=w>A2pCI?W!BN@=(El<%oM1>gBN0vtH^yXV6Az5q*j+!am zko>GNp#^Q^*kOn-B*h&Wp+F*}x(uQP4cqmAB%Q7IzaAski9emE=++=de;7-<!xk&c z>qjsIj>#hez?0-wF;d-Pl{((r`O8aQ<sQQEfhE4+&P}0UM38bSIYsT24oVca^iCGN z9v$PNAg6;HMM$X1SwN8>3N#Rr2Vt-nwRa|7hj|E)DdXZ4pUM!I<5l54Kgb?j$Ysqv zY<tVT3fu6;ZxlE#4%kx^+nh0&;>^JQM2lZaLoH=OC}GV{MI7~0QJ@;bIVD@^Yr+Wb z(JTX9Uo-nSdTSoM$q5CCT8ZuKDG|P26Z-dcV`d_Z?Jdnqr8Ei(k9TB}JU278_S;KA zuc}U8$4lPyh$6awEAlg_IE;tcJjKdl27{v2Fjfz&$9f-Y)W0`zt1*SxP#9)Da$`5s zvMWoANWixXL}oU(xWxLLkQuHgumR10m7y4x3Fe<PiF{AqIlGi7wr)v(zkzz&eK8)| zf9(5%yGf9V<vqy&`^Y^eS4^V2@0KOv40IlERQHHz{HSN1R5O0Y7Lp*EGX|K9!eYJF zaU<H&aDr}cjRtNnK~qGpLMI!qLlH_nYr6k^ARN9#&eNjKeweY-p99UrE=sa;HR$<w z%dBfCLEsKTIFOa5NtRwK=7ALLvYFcjX9ifSbM2_#;!nIv>FSz2_e!2=<3dg9+6Db? z6c=3gNZi`vZ~m=^<y%0KTi2V*qs}_XJNri8CI~o$o^*wW7}9j4$QNTANbII}6J??~ z!g7p4yGO+;QpDX?J&9lo#go#7w+j#q?rhmF(AQJe%OR0c1h70fUVFG;-}DnYZa^aq zH}<DayZx>ZPWUz;-(D9fSKq&LyYp>BNDRekOTrpUJm?&)(cg0QUX4tfHNUJ@H=3(@ zOjgQ^1byI-U&0r+W=;{SYnJ=@CS$T|<J9GzOhwVJz9Zx6EFzkP`!8SP8pU^OZ0tsp zyLW5q;5>CK6BsFx(IFZ7QR^$>tce&J0;5sxOi||0chPV6eQr_3l@qis(L#JpS>zj& z0$TGVPR*y^WM@>i`?B@&eyAnvW#92|#FrvDvuu?%xMW5mGpC3%W4t%|-6-n^`Lg=s z`XU5LJQTdL`1+*Ly2T}V6PHtKN*A!D9FZK>jZIsH4Yi7mS00)5B)pxxT4zCQD1Yi8 zLFfj7jVWD}>01S(ILL<Zwtmw4Cj1S)Hu;qd{b$6bXwk~Z=zSv>j{a_o$uQNNF9Y^- zaL^BO{Uz>uOY7@F_2ruBtc@a_YC_Q146h$g1CIZ{3&k+m<iYomNFlLwT>0b`v#Qny zRoQTBsqd4=Ewj1tmWT=>v#rerR02^{_08Q~q|UfY)%L%`N(k=GYmF?i5ng&<e4ptq zJsn@Fc6f2qSPQ6du-B76N3XWVyL9S6g>s9SUIG;sdh&8o1IJUwrr7oiHNv0%*|y+8 z3)Rdnzu9`=&xh))RVP2NB-2@FnUaUSMoJDi6HT*bhO+i&8pun^w;8bq`TVt=ln$N5 z&x9i-hxau8dffUg9>(mIs4rKYKFmSNgP@m%Py&)eV@3t~nA#Z9kTzuayKtu=CLFp8 zd)B2@R9D7`AJ)ipa5w1Y!$~+(i#6X%z^QUWqcf%_<`%60gcC6UiyHm)^ULebNSO~! z>6^ce#ulwNd?wh|`e{x6MyvAZV%09V=$X6%p8c=!PAs*WFnsC>{K9dPNIOq*w&lGF zi!hh6LnW}hL-uuYrs0>I#Z;MyvvEB`3NQ4L!KRY*!HrzeSJ#dXQw!+~rUoz{VhUcM zP51;lq#L^;gAsvNT37fim{{*G`@@?IlpbEE(t!5AOIao~FMj4;lkaCcutbVj)2Hps z*2U#nP7wES<m55ZI9w=4g5N?S=+khaDXqx=qFf*zYwxam<3LmSKy8;)&FdoU_1F;S zb(@=hHbYD0?)zufIq(yo&A&CsmT^CGANwtH;~k>E<vDd8>}Nj7@oceK$LnsF%pCg+ zGWW!dUcX|N8CteotuVF|JBT4wQ&5`zF@@hr;sD0_{A)<|Iy4Ny7+l~ENZh!~KpsU< z>w!#SmcIkWT9Nfhza6USBO-HtlN&@8N5YcL=TunJfcMSj3@1)*X$7+0EBiVg8`iWZ z$9w3c`YFfEC6v0Cl-tOP$y9tC%;@k}%NGsqyZ0Edr^Vs1WRC*t?4TdVX}B0!;~lO& zSw?-x%wf{mi|EM@#^?R2QfEomF;AA3bTTJC=#2UTfwo8;oFx{>{Jzc-@^XsDifpLz zxB)iDLkX1Q7q|3Ib^K9>lee@+6LfDzX+t^PEC)OUn?b*8r%Ea#%@ewV-uXZTo56uB zGs42dWCrKtRq4s^UsJ;d*q{AA_a;mrCh(u&5V@zFZ!@Tlzn1BkEKYOjd_01)8S>cT zaL!#DzO;n9Y<|AA3MROyQ{3ng1D>vjAEl&h-rLPLI%t}uI3Hl<!Q-4_DB!hY7PNiv zCqQQBX7lY0hTChA^ywg_kf~q6+%g#1J_dnlk!84)OlZHQcvIbh)2b!fG|pVSUt)CL zLW=rPo1bSO@=M51&C<X=F1Y!7Ose|0Pu4IdN(zJAY!S+&n=cyP3AX!gm|0>-<rTDt zmW*W`$%8i&3&Ig+SXg;8TaE%J(UhV8vT;@Z;J)Gq>jcO!NZ)=*@g-xx@{Yr`lC`w7 zvXa_amU-d2oWgqj4}}DR^A@DeLxV2+v-IU%9);toWz~+T1=>|_n)YO4C-L-|Pf1ID zqY%Ae!qe0?x_!JI)H-WGWBjp6F*xo=GubuQ(z;T|4x*f9+Z9E+zow?c@S}4rdi#C5 zp;4l1v_xHmu;cv6XWio3h#dM1+{9Mhjp~5jcc)%D_P<Zrmi~E2(Xdvuo9}9~H~fR1 zr}&^#qe+Esm^w05Kqr5NhRes7k2}pY;Vz)Gmw_kCiMCxhyC_Oc(NSbbwxH0skZN30 z4yjvnr`que3uJ{(P2uH>3OT8S?MC$o!|Hzc_rKn6N?9LA6;{d0L$U3hm7S_$eS$F8 zKVSv;Emce`k9M+k@4whF!#Prv6@7lLHAWrSHykg4<v(VOrX)P9&oQ{KW_%Y5PvVo7 zv>d;Br7!s+_yrvN<ZTz|MlHRlRrqC*81B(N=7}H{Dwy=GYs3!;lIzj3JYwDa`Rj@7 zFSOgtp(^ndNNJ)dUS_b4G3X($j>$+#x-mptphOD4qrfpG*?zvwNZx_^?ns0F)8Vl! z5**_{z;@skNbE%mzZ?N-?xcdAAD!0EgkGP9qh+4zJ0xuf7idBKja%Qd0O|SZHRy(G zRCm~FZR$Gfp}_4Vo6@--4bypJHVJ8<dDlR0I9(WV#d%Hu8ZJS0lgAo1kJP!B>Irh! z3nnpA;j;TfwcW1t4jA1UQ(2H3E{p6gm<V-xiSUgL^y5K~<e40fSH~_@@>X!TyHc;$ z2|vQe8<0+l&l&oftIs2wnF-zTwjb@;hGpL))0tAkSlg-5ydaqLADVPFbg{-!Hn$5S z!O2M?o5)iUAf~(1jn^HrWRLEr6TbUED!t~}K`3b9H3L683SiuLu%pOjNH*`9H$FwG znH1~Go3MheGTo-;PEK{cyyu;GFl_GQ9_RlTCIdgtpUj{8#XBxVvU|KCUmMFH@&~ZU zEl~JGjx=BEQQ?jq3FEl2(vu;vq#hIWqw+KI9i;WJ{psAcRWb@mRc|e68}m|%o2J=T z;;a#Q!!3sb@4_nM_m}dLroA)QJa6Aq`o(>P#~j_q?HfV@wS#f><C(YGB5ok9{7@6J z_D4L$-uO-eh{A-XU!RVxHpvV{-x0{JC%-a{^c}F{Ny8AG&thrBvXKaidlOZDbQBDy za~2u}*@B-Ck#Z(QJ|pNmwQgym!01cp5GtJFf&kPjnTMP@+uFy(7B`pFg4p7X$0#y| zO6*1#$rNdaRNB3i6ot`P-f>oD+{PS(@4kf==v~;}*DM`){zc)as3%V`1->4G0q@xr zyQ~6r_bYQe9t%2dSCj_v3`?Ye)!h~?sV^i&&h$q32kEMu?*9t$w*eBc^zI0)^cf6a z{c8(|G-O#29Jbe0k>pUSfJJnszf)_Ni&z^iqZhMuY2i=<Zs8Kbt{b%DxGz`lfrPyi zlwMT#-I2g7M3<LX%?hYJDwB@{6YXKaFksNT&74Qkutz-Dt_(1J|2(*RlqE}BAQ=)~ z&iG80mz0T4ULxMN*_ubY!X(k0erV{`uEuhGm{K;m_<3<r2^{sCBS5dPjHEr|m%U<0 zlSZ=K9*w>ZgB)YjaH??ify2U*Q3{QWmA3h6r@8NA#v2;EQUGAteH}pX9)RKl%o~y$ zt&k#5Gbb>7tl}}avHPS$@ta8Fruw((@z60W^Ec0H<Xf|X$B$YS{veo^>HF>bd46~r zRt^o-0s1am?x+ZOBHL3ttOHmY0s#SW&leYTf$G3^C>X8@P(JP~CV$vbyv15e^y-93 zlos0>I|}{9bGiB%`tKf-%~72-@~^H{e~0pQpnO&!?m+gk{GOEiFwI|NT8MtDJ0{;0 zU5{?;Pr(*)<<A`G$kVf$?RVpw8{GKoB_>u!GJ1lhFcOwR5ekJTXn4qOxfgr}V?2cl zX}w)0I%I?LBD!8K65N1gp1_7Ky*WwS?(QI=(dB?D8~yi(yl~)1ncw)YQ|4RG7Ykvy ziV}HyuQG@GIE3Pt<v1NeSm5_CbW3T?jnqfsuty~rHSqg7ZkhEx0HkzeEez5S#6GbQ zBs4UD$DaH^&ou4>_D%kNcc-x?tD&h;Sp7<V130uJFaH*FxnkAXYFec~auXAWtr8{( zVM5aJR7}>xs#&~krqZv^)Lvs`eP0|$1Js3}eg0Zn*pUFaUTnzTJ1ndX(u(FN6r_^n zj+$qORD{^+y7YulL}?6^ppZRUM_}5RrK=ipobd-Hf-pAB79DBs2aj8lJTF^s`?#Si z=OOSNZmEkOqkx!-`vDcDeU9vm3RH*-_W)8rcL#Lxz}|~orjcwC<?kmvx?gXE+qZKp zQ?S_MQ6)t++>AzVwYtc5nnv5imdXnn$(S41^U>n&e^qfB-DAf%1$5G9HVz`^Qk8{y zp{5I*YZOUDCc0Sxdtp5tx!KKH-rJo&jXSyLo~QW7SrJyRgs5NV=z&-a#i%ghpHN{e z$4AG*oRhSdYW*B+;O5JE(i3Mh{z@eW0Ap<_&!ns;#?Nzi)k_sHa(iHq4}O*C-b%Tr z8Tl5}I22()aU&QWPAnY?n826SQMya*;h_ScKwntrOD{JusPAP<5!zg#FB$p%nUGgI zuPi*MD7G->;}3(OZ)aB!R*d}P*9$ClIPHK3ZI%Zu>pm)Dpx_%B8gJkeN`UeAh`%#` zQ(PIA+1unzsQqNl=!&e}f^b~%F+YJvYo$~C3rrqu9*B~qAF^s;Lmef^8C=83dTtM= zszRDR2o{59$WnNRMEw02?21x0_f&<Usxzotf6EDPsBS2v!7zoVa1eWUXERCE)dx)i z8%d?_p7xPMcX#hHqJARu-0#HYBfk(4dX*yu1pvu~h<AJoueW>U^`fGWKSotesL`IL z{$-^~VbZ(3Pn>xC5I>n0{U^Lf8z%m(>E)bXvdDbn2osg(=7*S4xy;5aLyq8tD^4GA z_0iKUFIU#%c0Io|&TV?k{Ikobw<DXfDk6O8GZ~7+mP~D^GM;UOFl<1xH6(np{}%^@ zZ>^pxwZW#}uJ!ptKh{CpnrIT_`xXmw6wA3p8`+7T;gXdEZ~$t;kco=cuf3zb_NXW3 zP|b*u*7vf_<v!(xuLejqR84=p<p$l_z~X^lVED~C7N>^7wqF?KXPKe8iFu&o0}7uM zI#RH9z4C>m`bExHbG=KeIBBTmq+O!iMz|`4aDd5v^@NXbmURYotLg-0=6&L5t@E>x zLip3iLX-!M?`vXuj@iI>SWdT;25m&Iy@6;7%2}GQwSiui-l74w9Q2nxEe53pxo1gs z-Cq3yf|*Jhn`U{sUGQ(h%fV*ncWIf;CU^O(bFI6W4c_Gb&}*MQg5%dR%NcjyNa5<> zf210=^&nLwakr?=*FNw|5{MRZ^$RT?=#~ayPZ$MbAa7fG`g*b7Pz}z}X<5J1S)y7o zkLNk<=oteQqNaB&j0~xQI%uY67eI$>$kF=3RDQfVVVlkI)Xd&L{*gw^JUTQvNFono zl1CTOetFCgK{MXuX+W%3ExabCCqeDHrQx2Nc_`ANG5Cq0iF}IHK$244Xk6Oc8x*$< zeD5}6$3WLa9(5UzVJUH)=gnLz(@_JM{|VhV6$&4l#npa#lC79_R}hzm3Z)dWU-2A< zuZJV|AwIR4!z~c3AEwZ;NdS-6-nBZ5nC<>g-dP}OQ3X(9vGjFh`$4bxs6aw>P!{!B z8+f_?U(w_>BmBzRU;9<mJ{AXwbxhm-Wq4B%PC&$pAOt;47yDQdL>bh_xE}F+w>Ss4 z-2FOuv=lW_7chS9H4i;VL|OXep|{gjPLxe49yD!G`PqJHWy#-N-sOEM$hrmvWS1f2 z?n1WNuFYQvNu!9dvHs*9V7gw96=N~Bz>B)FN6?3Kv$ljCoSA)dnb0TtvF;mJeXu@9 zxYX0t)gQzsWZ>x&Nb-CY>nAV*T5+Y=MK*b`PWTdEE~`(W&yU}k#3M_-{Yw3zSWf6H zZ%(q2G0e?y@usA4AYGTqb-j^Qo^VVH_Nn4)I{WI7R9)bV(|HX@xrdmUb-LCZtgRx( zE&cYhtPL&-x%M?x+y&h9vGYnAmK-TP7O1usb@F@mcT8G~E37(o`;sG$O%kmjLi%Is zOkYIi5ktvs7>!?hH>c)#tJmm*%<|B+2U_KIiVG0)pn%T*S8eGVJ5B@)r@h<JK$#r| z1RbqE!V<E?Fk$F`$VPHK2>meh=L6eyA&VgJbL;ec9ovPF69<B+iZ)#%GbE>9<|~#C zkCIz^*-i3<tsO3{F`Q8p<6^w)PE~~Eg>!9vjv%o71dt}uHa%lGeqoT@dW)x}HZ_oH zVx|er?Hm5l2PsuKhP7V2^L-7%#Z*T;x|bHJ31jODRr_;byt5}5%mDlJ!<k|emYSqW zN?t#mpAl5-@#hbI3XRohc49|KH&4Lyn>D$Y0v6&PIL{!wemE|Go*vZ?r5g=Mfjm7N zZ3X&(ZUsQEDG2Xx%Bg+=J@AE$og@w`+5|WL9lMSs{jrqJ$kF(xidomcA;Jx6x`*9) ze@A-?ZLr^FzULT}6NCXgGC6r#MKg<Tr@Yp}ie}d1h++4En}`$YH=IGxTdHd1GeN0o z+zR@P7jDQ~`yD|olkXJje_n%C4MEl>!X`$<inbu0yWel0BC_ZJLejfRHV3Fn&D-65 zC&i$6q!Ra5A4g`Pq_YAC50yB2ea0yS9CvixW2KG4c&-FI%k1DFBDeRasNXwy1Gp_a zcw!Q=o=Sd1z&;^bzP&h|3wxaelwW@%UHna^>PjS?z9w)rrZGG1GI2^wYQ|#Ibvn2H z>SAXt1heC<#^>x;=UkeWkT^Dg~tZhxup>c$5MOgVIcP{-6!hg|X2${hNkF9HaQ zA;v<D3T=+3vVW1^O$C~+bRs_l+fXOzW--1QJJlOHl<k7;GXkImWLFdF+V>SyX`pFt zrk@#BTm6Z*A!rXWI7kB!l5+uSL`#;f%q;Ra+^S6VBYo*LLA*?Lue^#-CNXMJ?onOg zO0!NKUOaBU6q22n0q<s_JKsGigpI|zf?##_4X)IUXONd8F!dZsPOS?&GU~R#FUxtb zx1Eq&mvsjODL=|3*f^RP8S*woKOJdjf4ujh-A+>9ff|yqie8LrYa__nP#=DT5$9v7 zEHnx)P|q4pwy6`%Y@9+YYwI^VP>#gpz9myc>lwMk7X*)Te02}#Z<AzOCzY-AOO?U+ z2Zn_+%D%rMw*H-!=E|ppP41vQx~Eq~34W#%%MNzi#APBCfuOYcklHUc@!GJ;gGIiM z1`7iCZ60;dE%#m+<~W-4^sy!>3ZXRK85M1B4-{k%e0aW~6NY_E291=ZAE=jC!K!_# ze{(g-)KO~c@Mf?2UK<rZ=xqLdQ4-B3+D1gj`_-Pb9liCkjJD3W)EV?dHndIi82!(E zb4JJqZRRCMqt~^I4b~K;TZ^eT*;TPD2@&x3d?!<jUEwIrhHT7DO@Bpcw;r?b$gC*L z&y76MH`Sf?d)CgMfH3se=<U~sXiOayo2_!22$QC0A)bu+FE<O*IvJiBTpNEU{{Swl z@u9RR!hezx$>L}>4py-w$0Rql%L_!BU}8XfAbL9)zzuLqp8!g8TbVkZ4_}=3kVJNf z=W!$1wC(nW6x5(rUr*41xZT8j%L&Hi4~`F6!I{ro6Awn>B&cuQga$kBP+TOsUr#pi z4L)xxRj6Ly$_R?QAaZWUw=fc^=lR63jEZ~3KS17PEP!xD6X||&W@$l%uP?x&-7lmV z0A;GMGpV`4-F-JQ_+T$B1m1W^a<8tjJcRU-60d}~(LW{Tzg?c`E{BNCqHpuR3xNjM z{**mDe<&T?qr*Ps17z8@--R(m*09a%_UFk^-VH9IAQD4OCGWWS&tCA)#)0lg<U8P) zZDj-JqVeC?<fQA<%p=z#pJu8^prX1Zx9PAG|6FLA{WFUgY={LX!#Bd|&^p)XhKbDB zVnHGnf5D5C_7Cx*b;(`P)mg`A&ymL0g}=!>zZp<&c|q7~F7aLgfvDMr+07509zP*G z;^BAIq<}7LOCv?#OcBzBr5&P=xOaZEkpE!=+xlsCM2zW$sw5%Q@4)G^TLr}=l@bNv z9eSnFy;^X9?};+;cL~0Bq7QL6weMXirKgGa;Al)cSt%GD?UHkFrk6MLL2c;m|8)dp z*gK#I<*s1q-Ebuyq9fu8=pkvc7OOK3fJX#bQ56&TDYsLaHA<RMldBMZ#g-ch!%S<s z@vm<%rqQ(6$9dp#K!)4w2S3>Cg3^MNL8qapeC9BFvs%Oo4r0`H>K|<C)OYTx;V*wM z_}x@<v%%SOiP<onP)A7flLClF)Os%m&;3D|TY<zvFF<b@HNJ(|+d}RZ+iCwCDe{vX zxmJkEDjCE^j#U=7Y9)6W)#=ZNk7qGQBuDZ~r;51`cs!f#T$KbE?It6+s^98N2%h#z z>OO?X@SoK&ZoJ@g^TD#L0XQH7`iO9U>pEb>aT*U)p2G_2*0-+9J|ctqG_d$C&7My+ zUf6890?5Cp^}Q?fGVFRT4iD3qHdRHpJuO1lB7{k8iqG+I)ED*?iJs}l*>cbc)(ZPW zYVV?)E9UXbS%P-YNj>^JP<g3*`C{?&>rWC1zfubPMF$mrrUz!xD-Soejkj;S6bZM^ zE*YukJAW&-D-Q2}7tjw;doZU5fbep{`)S;mo|so^qR76Ml~r$6b!*CT(u6GnC1%Pw zMSIe0wULc5ckGrE_^<=`1r_$F2Oo|tBkC>!wRgA6QW1(tE?`>u8;#((VU>G4x8@EF z?;&5sLx?D-48g|W&kl6M#bfH@oa6;jimyMe0*SF{YY+*pHjDZ?zj6FF5)-UUc1G~_ z8)_ah{ZLt?pn(Pn%M^`b+av6VNS#Gi*`VSdHjT{-7sn;uP-la`PvK7ag|9jcKYS4o z30nk-D<EsXLElEG>dyB<<uSy9NYjp|KMCPrnf5OXE8bJj*DgpXB|5#IN?j27c7O*^ zlPVLFXWVsx{j%_Q2m46}ZhY>Lv(JXv2~|!nNF5QTiBg)vxFjA1_;&T-IfzeU2xohj zQXx>_ee!W^>t8I#*)ZU()u#~^u(9vpA58}zd_F?Ak|fJiWDx9TQ?LLk>7as#l%_eg zitbfk7Mt;<|Dm#zV}Q|pdxuO3%zg33SiS&3so#0bOak^J)VgYiK=fmR;06BffGU5~ zx{YzEYYT++vOnSt#-TT6JVNegRH~}2uio4-%^K|&l$w=l-VQ_kS3NDNFTuY*;P&D; z7V0opV6k3&SN9|O@h0V`mFA^sgQ_1a1j9zI`8P80N1yafqc#!8S=EgoQJyz|cT_Ab z0w^0;l{s1@qI|cb^&gc%*l-65f-`tFmfMk6{EOD8h&nZ0ZJ#`8s425NzzknTV>ZA~ ztwgK#+rPcfn-c0A()AcirLu}~A7=Hnm_}wtg&H=4S3dckf-4+YsWN?^3)O0!ih@4x z*B^dUwahoQw@@;3YVu&<QM9bV3!T8qo^?iD6Vb8>e3YG_`U5RhmUh^jZ-kG`N~c^T z#!LrvZPd4@zZh94-!W3^Uty#NH;F1NR=Ll>YT6rIg2S1Kor&M3)zDi7a~$YASxr!R z;8T@8D{bg&ZhVW6I0)9q!WN=%EBk`IB2151r};zI>N_k#dLuo#2LQV75BAGn2%zn5 zKmgX+fYB9T4V;F9glo41ZiL|6iR6^3lXcn$SK5Z4It_{_H_kOyo9Y18#xwE<n&7(C z5{67B10U$vvVR~!9UBTJF`#<=csKDT<gV~DDUwOZpRTgN%CssEPNubm**v%|=QnHC z*mPW}oUhFv3ZcKH2fo%8q*`2;CjRL1R=ylPfzwehN(5<B+8}vYq7_gZS0`xzNz+dI zb!~{d{X(LSC{?qrCNm_!UXC%LD|Iupc(^xr=IhxvuC2kaNei<)&2lv-1(`8OB94iw zcolY*NWBMhLf$XqSfw?dq)iWGzmF?{QjgT;0I-Ab!iafi#IsSt^&I(Gx(Vw_qIFYY zk0n8yH)_XP+iGp0;i#!5{B2}}(`;LGZX%65ul$>I&Ray?_OATi65r0y3UodZH};#* z8xS}Q>L+TH*o2f1U-<B&<<GUG#m>;@@3vo&r+fmk_(AmxPsZ6kz!G(K<7VJ_&Ca=m zkerW1kfvUrYbcy-pi}~JgHN#1)OH1c?fpP|s;98%!?$5pW=U-+taf!iA;(|G^g}?j zEb;r)5nheY6@0k#RoF$38>6EP95V;X63+XU=ach;!*ai_Pgz5(g^$OwJ~1wP&$M{Q zuaRFjtTx<(LQ=;FzV(`d*3knB+Bwe(eZGIw3^KRq8XhE%^<gEk6URp!`1H2A&pIww z;&whsZLnsdHxTWDeKeILQ>Jiwo9S6fA<u`!EIZ)(kR5SvHk$F`nZwR|Dq7~7kX3X; z;>;U{qad%6nd8xumy~w8CTQ%!^D4`e2&Hft{}kTU7h_y{AZfps%+voG^+k);ni)Qa zC8>`k{ULhKVnrEB>8Dl*o8NzK7bNcjFmZ_C;*MC^!tt6%^n^y!OXk729b>Wqp?>tC zh!J9`toZP`6?cb@y)n>l?IdLfTlMiMn9v|HK8>s1{@u<XvK=ad%ZAoF>N_c5qtdD8 zar0QK`#<RD_Dqbb?U}i<ToY2?d0*s5nm30gp3{)HJxc3s;N7ARjIQCS251ewrB%4j zmkip)F`E~|s^P_I&fR!KgbQx@c$iM{yCW1F|M|L_P)V+M8vdJp9Ir(Nunt+a{1;b) zB^mp?y($@nX2@vW*NY7R<jLx&e?L+3P}g~)Bgo9&9m^o+Zb`IpNWPCv4r-pIxfR6I z{uBcJ_MCDaN0!rSilb9iE`M9*GZ;j=iT2z=5Lz0L?Q;+2mEB!)_`dDsoxAXnpYJ|8 zj`gwN*Zk;Akig#>8y;NjyXrxIsi>(GG+byQRyz~)jtuK8K^(564&LlCIP%-3Ct#y? zw%_y}l1zF#q7a1ymNl{Y8(A@f8>3$xt@t{>$24BiQgV(V9+KIH0>)#*{E_UZtpOy^ z85%m1)rD$|S&NGhp%9jterKt`MQr`SZjpC^-*J$u*V;iyw@y7Qk1~#T+_Mysw6Dxg zukwX^66H)X?xyXR6avkZmyNASj;BSnuxLUnY98Vd=094VKZOY~<ZpwFO|69If2#1F zZOQof=W-v*F86)4HrrIn4PC~&dR&m9G~fKphO9V|;nh?27tJsB)t5Txl^)Kg)%BEk z0ORJhhH+GT>|Lwb3o9bz(gu9hLz1iR{6v(p)o<Pi)Q1SBeo5~pcW$>dwL|vCMrJ?y z&NkJU>^Ay%YJ{~`QMpBiuPecKtlM*2R2SET63M_!5gmS#&S>&l#i4!ui2p`h`*bsN zyVhu}D){S;(<(bZ#cm=1FOe$92lC9()<CF$(R5!G4QsY6F_!llwSmGJ&fW*Vi>Cpg zDLCR7iqBY`+4(%1Skl7u$rsau`qW>1q~Kkq@fj`0qr82>Pl7yR=K7{1dc=|Yeu@O6 zIq)i-Ejg!o3x(wCIB-@Boc-=nhFbvt=;3x#T>uvB5nf^e75!qJ-Bw>=k;RLRY+zYV z>#dGBTX$&?$J*N8Tz-Esws2X-#lk9?GU06QS#^3Rt|vWuvytENmw2H_O!TWgsAXRJ z!ixjmp=hPoX^69=K3YXWv4x>df^>SrG8?MV)dT6cH4LYKkH#<vQ-T0g8tyGb^jHx6 zSr^%<S>5ZH9fGnab8s2_v2`&1`nihbsqbNa<>>H>=4Xoi`yC@6Q0-Q@KQil@jW{d0 zA4F4}Nl~Ef0H^&5&x+xk=sFM|q)`0|U)eAp!lE_PeQ@#q5k>zVZY0%}&@yJf(FL;Z z1Wh7I^8mNt*=6~x4|c~(R-c(lxc@>tV+&&|Y5q3b$*0-a{`!Mm%HywtH0S(@lb6eS zkcDI1Z4m86KR@36pwt}?|A4bu)9F>}%Wj_E>dFs&39BCS2Y-flQ<nvod1H?sEJ#iq zO92#}2OQhFO9DDF{a(CwG&Vd>>>=?xYsOruWjuHUR@a=d^Hz|+ZSOui1i;!2?-j3@ z+9gB})0G)UFkG^6hAhda8J+cazfrB#%Hv^@(u|`|E!&}{>UFxN3kS6T*km0@h(3Gd z$axo$qeL`Bh)O(Tjzby<=F^zRir&_zO{@lUgxie2b~<wUH}4REG+q2RpfTPQa}X2` z8jNDF^h<d{&;uHF7dL!*V+?v*O5drfu(wEY#^5QzonfB%kBFPt4aa3JM*aQ?AYKqE zEZ@w79?Y2rbCCe-0K~8r^gU?YGw<XCx?sK6s*N6hau!wf+eBS4<%#;4ZH(<7C&5LI zfThTgy*BFzSQndm%J)06GlNVBXVI*)i<x2l+W8Uxn|5hQ$wEVk^x9oSFdmO8x^XV5 zE;$O$J<1eqJ>c8oXW^-gVuKC<gviXU2n#l=xPmciW+}UkJM)w8SrTOPzbkD0^C@@c z<F5A_!lo%n|5aN<rpQL{1zpnaM=fw&IU=zdooh}d3F)$F?;D$vK`+78mVL)1mW)jt zoe8_1Zgv^H`|`=~99}ln!)Cl;kkts^M-4-q;gI4+i&gb9hv;Hh#RiPuI2AqcM9{Ur z9ghgC{>s5&x$$=Nrny&%ivSoTaN<C1=%XbzYup#z`#Y>Jf1h5HB3)=Hl+Ny1+34-Z z`jmkGF{oNLS;_@fl^9H)CjS+h{hog6V>5*$hWb3Uui!6C+q?6bUa#E={wN86f_p4j z&pKssG=S_N6eYx3Q|wZlg|n}ynd}4Ef6SrpnO-=(|61|a`6~0l-jNZyyvQMyElLXg zd=!V4yc#0<NS8Jcec8CnVgjlKd2RI>5bIu8$zEisfOB4Tg$x(#^+D+^Y<K39f)Nl1 zJb>!D@YNpVC-75X(XwrV`fP$Ii!ddyHbqf|_y`x^iMn5OHNut7VXpbP?Yukxukggm zx^R}WL7A4oE~2vELziOtWg`!S0>DZQ>lRH_I2WwbC`y@sHvXu8{B`ylF}6da(-hkB zI-RNFiC2CA35p2<RKB!aJak|@_gwy@OBN3iUois{7{|P+??nIs%_ZWdso^Q7;-(F( zls?)RhR-F+XxMqfq<~^03yR0uHV$oI&Phf_zsnucs?=3-E7s;qw9?{~TWf?e3lOfg zb!W?TnN^U^n;Ju%!aURMSV_>t^Q-r?W%9p?m*P`h`BXG09OeSzhJx$9<9@Op0*v*) zcxO*=VgOyNRv9V5Uh)eKWF{8Ve2h1};R(bD9II4LgrMaEG<;;4i2ev$&MT@+^NgD= z*?k#r(h>lZx_0qEK+MJaMNhpCSZB)0d{WnREdL;po`gl_w7KI*J*_7;Lu*t2sR@m& znML`L{%%X+`KPgF(nBW{fFHp8V!2t4)TCg`qdXAuk&7711|o1XF)CpHN<81GN{{A9 zd@_>BYWkaC*;C%{fbtxHdM`$#S_Q4hE&?OefXziw_txQFD>Icn^-<*nd4r{44fR@1 zCTBae`>J>->?g$1ccKRg{s|9Qd7ztvp>c6~l_R5yt^Zunhgatdt7c<j^j=l%tt;AM zv4jc#{=Jg7FO%tHD5U65sKs#&EoYFiS`xE!Ok?97ZTO5fh)>0hQziVRdU3&YM4Vr< zb_TbZJr1KK<R|N*8vxe#!~=iIFG=5`nuj~3f6%Y8v{tUYjAuf@bjG5=jZV%>4+H=q zK;FN?D`pt6s2|;=B69(EX?G)+?*Q=E$Q@7udsg66Toj}MI366&-@ff4d^(V~8Q8Ff zE|w{n+q@!<zh8~zF0R*1u&y?=vaqx~nMhDvQKULJnU>gi-Lqbbp|S!eCB!#b7eccR zsTy#2JHsUn0dpw@i9Il+-H-)7A@&m-^86P(t7BI;d85jdAu666`;!k5$z)IDX|+-Z z@ncKQ8ql%6^80t5$;r79GjeY`pE^Px&|g7QqOG<<(^d?<@pb|{5CNGkOD#OtS_mKf zPu)3yIm?42WT~}SOQ<31`?%+zvmT~#&6I%d-XdYkf5#exsE>6veZO0Go;aw)IXZ?M zvz%|=wTJQHN@qCnIS)f+oSihm9HT0VWJB3WBBpc?QrZ#kAXDCn)=S{k9g{bPREjr) zIWP*P$(ujh!)Ri}Ly<GCOBQr8RC2EDy)7XcfR2C>%{L%>h%$z708n?5>4SMnt|^cQ zN!aHKpA{n)zWk3uvuud6(W2-xLwA>SNJw|XP|~S12nZr6-8D2wigXKtNH<6h-2&3x z-JQeS_x^<Q<(#wEUQYA<zW5yIdxf=+^mc9;fs8;H>V3F|Ws7^pKb*40NlFfuR=Au} zkkj3Un6}B;S9-1xaG>_!2i%J35o;ij=K_R+XH%pGP68$WcrX!E)J#MI+6Vw-0Fr?) zSfJ@}FKt~@BgIpgl+{duTt0boHirEXr@F7*n__(6Z3(`*obGZG&toA01MM==)O8nY z&PCgwy$klEj)J$}NK`~PBN43yd!}3}N<8V61k(1tPm;d>(<&~HzgGBG&imGLwZf4D z&$r?N|1`*O6&cywQI)4pohhQ9QvIK;dpZ?%MXait6e61na9J0eGaCl~Dg^Y`8sWQH z>(FsY88!U{Jd3Z3OwG*mTLn>BdRW_X2<rgr>gSd7b(^Tq`U`Kk?}QXhUk9TQIeZ<$ zu7k)$P_cPj$<pA5WPBjPgxT?EB{GE|y*igIVm6?9SiDW7`ocgvC4F8<EQ^xnZyOvO zA+M`RE`z}8OEAR@{S_Z6J}z)VtZB@f4owdG^(%wJNn*oN@-l=-@^WFcoMCqfnBGe2 z($UziIYo=}qc4#@0ruR`29nHH=hG>!S4AYm!&--Itb8nx0?Uouv5zoapUIoBuhm11 z2Rmx$a(+x9t-E46FE!NwfB>pd(>&_l12Vut-zI%zFC&93L3TG0Bu;*VN=uzhg&m2^ zZIy7jV(nBn%lQ>JOd5&;l@_0(8V(wQCpOKD{MF7Id>2U1@>m8jo9=}Nv?&LFBR<PN z?TvX=@(0w$D?7>rqu9p+vo0s@r|aYOL8%m;v($;w#l$E8-;AW(Rfp?W$;eY$MMk@& zj2XM5e>{zD3WgD8^WR1kGUL!A6&@6;<aqGWiZrwauAQjiF6d1m-*j=yk$0RYf`$lM z2|7v{<38z;=!K0SHJf4s&Y|FSBNSlA3|K!j&OiYGm4Dl>gfn?(Mq{bpn^|*>b6;z! zKzi1_ejwU^Y2e}lW>TFJFE6Jrfj&M0hw*HH?%$U;WuVn}8-9<OQKs4Z#~WZM2p=9M z=0JajNjwqA;`8-vcw~(_*QB_*a5_2nm8yGrG33DVZ__b<Ql(?gJE<xzx$f`c&_HyS zeV3&YE!<MSA4vb)h`-Y~lksNV{7_5doHBSaq%;&)UG|cn*$N?)xu9O~38BchvUKyQ zMr`-dKhJcb4;NT(<Ij_3)-M+QV~~JE5hFFx$m+FJ1GM(c`=wZt^zXcZ_aR?Sf}XMO z!gPvNJ<9^~7W`sX8Y9ZwHL{Sji|P*BS2w265-p{qgFpe#D{yz~>61e%T6+^x2e&8m z08KpKY2qs9_V++_s;rZ1-q8@UpJFiU8XRY_)1)ypd98pZ)B%J>QrcORMhCsBs1Ni% z5H>;Xnp2;pr(zB>eH*&?aHb>?>O-flT+5P-)S22)CK@G4FZ*|{3u7Ljj*`^4bMe(| z0R-N}E-%_SO$0sOZ{oi^9`%$lejma~c*0Dk0cW_RrUJQ1J?Trg=bgixZPByND6ogu zA^Oi)fJvyz1ix9ewyA6o*|r$~6@{vttu)iQ5Q#-X2QN&de~)25YDT{#XlleKp!8Ys zwi+873(`UOL78on)Fe!rLK@R{xGo&2hd~t|nnnoG(u*~g)yjiNPzp2=CQsMPN5S)e zDhP5}a=2&DP(k+}?X6{rln(Ez9+Ukk_xGqpjPoM}Y2!dkHb#6UQhiw<iYY`L3?mBp zbp&O~j)_81zIR(B!j{--f1P!ONTS~+51e5DL&B*nZHELo-~Y%#DJE&&94*hcKNGbI zu>p0oV*px&JU9R=5w7=)$I{XuIG<YN5Tg6@7<WNB$R*4H?30b8NDV#ugX3m--akZ3 z6Ud5w?{QSdEvy#}{rG}5v~oY3XyTj1n_IG~hoq(PPA!PPCIh{8uM0}pe?oDS_U{tW zK=qT&68oz)&iJ7u+q6@bt%z?D%C3}(Bu@-{XmHynjq1IyJVXOBWEY8-C&NkN_ zS;O0We@HZGA<!$fj_F?f@?%gl5@wDGRX05gK}59_<|uI^N11mvX2z%QI@M~jUikF5 z$Qb!3>8L=mYA7_zQwx(Amz)AO@KYy2O9zsppZc|$UOMIo{;T^(=?>Y9I3p({ywP7l zkK6E_J9*zbY`mQVY430#o#XNApMSY7TcS%rzQuETcX)Epa+9R4n_oMwaenp4x4+Wt z5C=obR%mP`3?@)?w(V#|)e2xH@9&Ap?dvqlH+#heyv5=k2Qr1YGnf^TDrg@=Rh*zF z!3C|<xVcKb&YInF?XNMNA*kQNs);dBb9wa9_!S4hP!`S80}{FW7v~bWd!Zy*jd%PR z$bf<MKPJ&y_6Y=`5}h6f8PLpuoz928PXvtfF1teynZ=I$*Y@1Uht*zO9J8ANHq7dW z!09D%axgH!(i9{rl2V2H=;!~~bXaD3G`)Z}#+pjLh{;McL&mZh2B7m1HZ>T5)6Aq( zHhkK*JhTHOTG&Eml&RUmwWw@pAa23(un{uJmvFD^N4jch*8?0$R<le5UEkYoLSknV zI!;>!NV7hWU-;!i<)(p2XMTZ5{s@r{pE=OjFL!@rg-+X#e`<-|S(Q;0xRq7zzkYC| zK$Ld>nuLQea2EjrrT};X2yh12oDFu~U_;ONo|_gv_n|txy>Oh3E~9G=^eXoBX4MRO znl!%&_oL%pc0>5J_t5_rerel;Vhm;_Ql>4MiN$^Tam32s-D$R1+r>wA<nhv)KtzXp z6y*&X9yb^fTJa-csdnvjDZZaCn7nNN+-@-<4C0R(V7s2$e{GlamE7p&)Ep<t&2yXF zJo^$_Wvy6p3Lqs~FxmjD|0=^%9&#kT!}ghv=y{SfZTi?7SY@F-jOoxSQZv8fmAnof z_0l|a&sgSr^%<{)j|^qKhBz$%v@-$B#f8!G0dzh#XVw|jf{fL*gWZ`q4SG{K60epw zmfP_q13!7p4jb_Ih#Fw=&7&<}HX9r^zs=VK+9X?f`L6i?<Tlc`*HPikNpPno0m;D} zSTxYzQpsNFM0O1)EpdPD@pcsNv2_2a#BjIs`J{vZ^|_g-0L0={%nEe9U+}0U6z;l% zo4$)v3GWqVzWPumyEs?q7vKNQ2(R=*w8apA8rgu{{cr~TaXW<lE4{xYeABdEho_@{ zRHzX>Cg2wPyW-{ZrWpvzr+^O?faDcHm_m9)WC-yMUog|9TJP`)$di!kKPvC{knoJ~ zFD{?mJzO{4q1{!*<prMP$^@}$O8X(u-5t8`LfST7F^plYKpRm|c0kr0TEUsN4f8eO zw&DL^{}>S_q=QIUaQ<q1zWIVj5>go>N{tH-7E1HiY()Mf&X9z%Z^=86nP5x`b{}ly zqM7eu&_S(6eGxE?w{>LoDi4j74~({A7@vlEO^T|Ghobul?MYEAtg3KiF^Y-uYq(>9 zzo8obW-m&JSrEN8EC>xI2*9|<^C_)<BbTczlO~s;MrXYZxkfBwt%ieKTX;}rjH)`C z1_q=>4L|5zzX?p!kA$yO(F8i)egI(G_SwhEV{fUNK)YZdXr7T73m<MM`glfg-7tt) z(j^RzES@wd{g7|NRdDEWhGDWrLkg_jj_(xV(B(T&DjivL)G;xS0Ka|YgL6l}kSXU> zmw-3c-n-}8KYTV}ofQYEVv{Qr^_LXOc|UL4Io%%PcL*P20jK_VUFF2DuRrIIJ;Yfh z0SPQe|K&;!g4OnHB(35oFba_O4-8ltrj^lIDf8IU#alS2oLRr+Tl=EB{`zoaX!V6A z_hm;Iwa%U>Ba71CqxmTU49jn+HQVM_8R+pAOU75tu;`EOo(%mtQ*oL$jT^G!-H zd^o~Z#k``5OoKKk1z9H_(Xb%^cpCx}3a0rX%2j%1enzj~;D4vf4K@l)n>%wI-ufQC z`5Lb3s8~<Ukb`@ZKxqIqi9EORs&+lILO(O5@aI|HqiWe&$$K@qqW(qToy-Qlkk!Q( z7oZ!Yh5g76s5yZuTRb9F!Po<L2dDgHF}dD+fwz4_n6?#5%8^`$jLKg1&7F7vEfwx* zM!VPP`_mlLlarIqi}UB<9FPB?(^fxiy~MofYBrhi6)d{m8Db>b4e=KNfrXB^H4E!B zDTMSG=4eI^m<2d{Q+QaW2ETg{+gybI=4{PBlurZjUwM=~DILoovo%Jul42=b;t{yL z#KcUr1iEIE?R%@84-_ii-33DnEu3zi@xR>O-mTIBnbLi9G0Z(_<smKj#^HmY<{ES% z%m*;nde8>I$}-dscp0aX?|+$5T0bCYZp9@x$JW_z;+#EW&zIyuQf}paJfAa_3P7}{ z{Hd$0y?uFkNpl*jlE4G9Q|RuBn6lF?8S|ZvP*@xaIx^o$tMY{b(+mCmL+`)Oa<Eix z7+6+~OC`w~9V}y^y#uWuyi&Q|;X3rsiPEMsGn)T7tBtWfOj1>d@nMcpoen#H9Tz`; zaaWZt_^u)2Klj$eLgLXOO-@82+wePY_TW>ipOZu{z5h9e<<O^Bj3Z-hn<;I~lpGoA z$beKvF0u|68f<K7+`nbQ3a$$PeO2FYM@W_T`xJR7>w?VaKJ?-1E5>ww*|@;NyVckK zJB0NV@L2Wd=@2p{pDynz%bYy>4uH}GSIUHw1hI2Aad-!cZ}{d2iOYdoW0%h_-m8e$ zQb}8I@O(?{2ys8XQY`-NPGkY7&3>MsYtYo~*TM8$jyi*B=q?Sl5U5ZpN!((W-fU87 zKS;!f%4Q-hhnc3yp|iK#!Du6#@0{%k<f25ww7MG-$wrF$XJFh(Bu6Nzsei4&zkZ{c zDIu`}9r1~9)zUwsW2Ib!V^E|uWwpGk4#Gqffl>-mEOIUm*z9ao@7d%tyzcY%LnPi^ zIC$A*7JU9MQWAr}@crK|SuE85v|s5dgyFy8Idy?RWYR@x2pG5c-J*uL>dc)cCa8ED zIwELp`vyZ#2K<jszklx_UW;((aJAvfcR@vdVObvj(DDpD+LsTea^)N_Mv=kiBG!G6 zYcb4LsR(DUPH746qwqR8Z^Tlh-%r5JYnqZbByj%I7^+}qe9R^xR&)-oC(cWZJpQMz z5)*=R%g?_zTzgJqOAncA9D0ZQm2O>H1yGdr$+JJPG`n?c*WRRTHU-@t=%20}IdOIf zw$^%%?|*h<pd)qQNw{bjyUchy@i9h=-`<uz>J!1S8c1-CvknVzpi%!-|BFG0OYJ#G zH4bPST0Uibry>g^Bbi-7TWE>-ccv?gk;IRfW8L^ay57rKYR~5^0^T6oVtOAkDXn`T zVIO!S789`()JOl5Ho#(s1GvR)T9@YyYw)5Rd?j<Ev$M(P792kyiHr_C%LQRP-~LxY z9Y&+vPrF%Fa2i5{-2@Nhx`yr^(kNN~;JPh~L>4aUKi)?w#@yxk+`C{qBai?HPxNg_ ze%Bkq4v$&}`F}$G4IF=iO4_rTSiv4gAhI*VD>k57EL+EZ;NR%Gu;7YK%(Jl>&0-WN zJHQiuQ%8VH*q2*eCn4sqe_5vyX&bn#(|5=$>r@jeEbz)?n<7kwy&FYI>>iP_N{+Xo z&pkRG|LJ6;C*VKqF0JL)bjXWKtd~sr`q1n<h!E8uo+A%JpaEan9*+KHIi-HgdrTAj z&>?_S^4I@2g4`j9l@KXHu(VTK;^o}=i)TmT!ov#<Ie-nr!i#+sWFBl|b&g&6!-<_w zz+_MNuPhK@1SGyL=9nKUCkEzCB(wD#1A6_o-a`%2Q<c%6Zzk$%nE(Tpu9zB@a{BiW ziQqjIdM%jA!TE<j^gi+K-~3{pt64Zh@F%2bL=Xq$?nHD)p;PqPIoKNxoro1Qr*TX4 zGtAX769AId3`O>JU^t(nAo5I2g@B~s30x5VE-)}1QY{>&sUX<wpEX5=<_w|Tg+4%N zGxy#Oi}bsA)jtH&L8TmyrjbV-yFf7Cv6Z0l(ghLYvl@}L5xxEQ{<~lwuQwd<<R1cM z4z*+)!OlaupHeZPFVntm?*`dW!sbDxQ1&R6U&-Srz@HHkPP+xcTQ7;z4CqngjEz3| z?6<2a7JQ0FwuS#1-~s1{$137Xux3xUennHqH2pHgX=M&|H@646@Yq|T>WzP-6`vN! ziEHbv(JF$m=z_=pJ1Sgb$YyR^oZ{pDj}Lp_wD{0kW=(YjiNe^;PJP&ZgV2nb%Nti& zX*$<}{9Xiym#*;6P68j!CCcZp@Ei={AlF|?iK)YZBwAu%UEA({Li$zXYp1krWQch1 zcB29GWZ+kdWj-6pt|lgo=-TW^TB^aH1%Mgx>I7Xpjsjv_ND|RcY?JB7Slan;GH7om zO&DWhJ?M-TB`O{LKBvts$ffY>rU*lc^rIzF9f<bZC#$zgv00~sbggcdZw<Bd^`jYY zg5&S$kO~V33ir9~8^2ELJ%wU6+BC2)>O3JH9&)n;Zs1?J4tX=wm|f!BI_|R1e3t#B zDR<9ITf&c)Wrr%b1Kto;7<<E4`B`#*peS8ot3P#2=A=cmPI|^Cq8JbYmGJ#BFCO6e z##BTa(@FJ2`_<NIIPwoVLW=b$S}2RjvY*pA&0C1{8kX)Tx3qTxE#lcNVddwk=Y=?% zckXFQ_YX2PF(Wz%8Ue89;6i?|f|NfG0GuMQtRNGY&*A@Rj~snJg`meT(l1_8yZ|fb zt1PlKLKG;kAV3wYiRCu{pgCMoKPnZuoDquD_ymgW@XO1sZ7O~^I_vmnK#LBh{qHP^ zTJ+w9DkBn{vCJrQrQfB21_|1rpOjKQ?EP%)qj6PC;6?-VF#sXnYRkG~jK|Gt=7s@= z;6$l!pxhds;IJGnK*aUPuL@5hL>c38EztEm32`xJmdtCY_Grul5=s>qvL=%A#<sn6 zq>upP1dL7a0p+Lp2+H_1_`uG&-CS0XIO<2>Gom+-0O0#vw;kf$p-e>stxZU$tL!3@ z6W@`;)h?-||LwC%_HpmynWwsWx=+;jDMd>aob$ar{C8*g75(+Rz29ez_ErVjc;Oef zNuD7?eI0fM0#q(6pc(KDS;`#L=bs(F<e`JS<eumBvpT`W31QXj$R;L1IeAW<W|uEd z+}N{bfs299C-tG{P1gL7J^wY-z()J;p?ik|sSaV4npb#EUR%wz;n{s)>fB(%&x%Rn zh~`}`cT=?vi`@U{@6YEHX^uQFln#g8p3}pKP$&tn8Z+Ntl7&ZV=S~4$PEVCG{wRxz zK?;pDg|aZM_sGd+g9Id=7x>50%!1%IeVh^xFIZ<4oncr3xU`Q(SI-$g&E+2jmCN76 zzPK&2eHANE=m~;>Djy_)=1npHqRHBjKfr#nOu30{qnaRx6F>oqkid@;zImm<tCV>7 zNaiJFW=4j5j(pZG><zzJ9l=KE9v}o&f`!i2AJYDFc4A)I4^PCLs8!GEnf&{wmuuzk zBzCagR>K(89qwpTtIWR{?%rsk&$rxkuLQ|TNx8-vvRY)>X{~t39hk*Ii?tI_96DAF zA87;2a+u$XWaoc5LR1q5&p0Jf5VDd-gVk70F8I$rEc@98VtL@11qB4SU_Di}E!Ctp zI{tZaOaKd+Tio9AC?f-IAXP9_rz;)$iYCAK=9}}Bx<H(}FK?vQ-r={|K2~e|vs>;D z$I|fQ5$=mlXxsI_k#WLq39zSA3*7exJgPf-1V%ObGN4)<GaricQr<H@JoC?<un=C$ zTK3W4k9O0{nt1J1Z=Tjl4w)1V-`uL0@8$P|j_2!<gh@nRB6s}pCjc-`V*2~TTD~Q_ z)X?Aoz^F2zssF@cleyI*(UB3=)rJ+zSUssKuwhO%ge)=D++1ip-|CK)r^j_7bd5Ot z>%31k;dSWVR193783<7wWmk9p%%geU#REC-<TU};NYla~N*r^Uk@}x~z9~0b3)%uU z!}>bSdP;^pyL~a@UTlFRJ^@CHze@j1An<;@T+~N`AZXl%m9XkjBgl`ejk2sF7SQnl zGAA*{vYb!Q+tb!_<i;)Tp#{mze{YWI7MH9HMo_ixyKtR1^X$lxfDMu4w59#@I45?_ z?eDVDpTQCVc~OAXMS(^x#Uf{0hH;bx{JLUUc2t`9@We?|Kp6eO>H-G{UbC3A#t^(} z`LFsffEIz)x3+HL?Hytxj~i9Rp|;Wbvs(p^RsGe?X^$)KVL+ziPWh-ZtMka!d+ubU z-Ct|2l%4S6qfdyes~bi>TsK>l3klMHcJ2;WjSeI$SNQ}YX*kZ|ZX`429I%>pH!s>` z0Loz=sVq&Qce~avX>AUWE`FB>0fZN^p<mAqI8VF&K}dOg4+lot6nn=>-W3e0w6Da7 zH!XKlXRpalBj(ksq&x;5_*WcJ`UP^#4s9JhO-)T|hmRJahb7^`s$f_HUaeZRy|h|^ z@)U&MsZl+%1RZs-hLKkBqrY*U-NL?p1lipe-|N)9FWS;bi;D23&bPq+OcmOd2dS>v z1)M|fWVIXJj7vrQ6BQa9y9*Br(od<}-dGk2M16HXvx4?|O&bT-gkljHgYwv7zd<@* zEqCxfYgkUloi^yA7*jfzB~y2P8%Z>PC=Z9Keg=;(oh7Ux4OMg|N72c6S+={g=}seC z`X-}4sIGm66r-NaDHGpHk4fFfV(7e31%(?6@cvGAlrSg!FlP6Z6=UE#^56^o*KHt| zJm0WWXpjZZX!>A#Ea|y&BAj9VTqW&Ub5UXI-vxM`v<F)|{0)W77SlRy?QVJ#ZPr&{ z0CeVLM2YPt1enQA)fY!4Woi>I|DWMlGEFeM);tRgXd2MA(Gsg^xeoh`B|LI-?H|z- zHYi-mt?Pt7`o#@#ocF(z`Rj1Q)1l`@%5ipjY~nTLkzmSl_OMu1b-Ln$312HT#6j@^ z>Rytv`#k+WTA1U2B6&f;`u8FL)(yGE{Au}PN??aG)?;MBC}2@snXRDvS;WdkT(dxb zRq_gxh&*a8e%XDhMpEO`%WJGVr*?BAJJFvsQKhEp%Ebk+8i)F9lvEUeXJkD9MkxZV z?*)?s9j#CKRzV3mi7|yj^LMgpqXCJ-17HZwN7#(!_*e&Rge(RhH+g}BIR6ZuwdqGO z`I?aa2SUu&p4nA(;r83bZ&{w1XSvcrhrPz*)mq#U(v=BissVp})UUn<DB=U&GO7w( zcz`@e0A-+Z!BnZoE!cwmsU9DLXDgIa-f73$)*jW8KuSF5a5RITC1R|hVWVkH1(Ajl z$OnjdQcqzgevvzjG#IYihOcNH3FveFTym0mqAX&~FUtpy!2svS)6k><6Mz&p+dLIP z_x5?Rnt9Zwd<rd$S^Cd*q28@+#-^Ke%3w=WMZAqK8Dh#XB++Psi^-=4oyN_{%qRTy zsF|qS%k#t3-gutqg<1gBS2!An;D?79KB%(AZ+WM8s6W98_P*!;M1VS3OU|PJ<%gtE zK&!DRh?W3?wjW<4!?EUWNQ2he3Xk)W7I)dj79YDptPcd;4X8pso_$if5hgVj>|uEY zw@z-Y%_lVd#PK4>2c@eneeOZ&cvbJJb(sPH7}#UCOKRG-dcU$<Z!D(+{DVHx(*c`% zhCeRgO2Z-2kIRYPOoZZ{Ttf8tTFRx&Wmu|+U*u2NKfTskwAn36#Zl9zKY}30u-6@V z-XRY^$ZaxUJKtbi^f!S7Kt+<H!%8)b{j>X}fuq;-N-7cbgb;o3ok1I<M5l!#bgheQ z_d#+CA*Oi$>Y>Pn5ml*ibd?I&`BKL3AX-sN{fjFqYx+YE7&Yo;<UX!+L01m;I|V7J zbsPkIw75}FPTQxwa*BuD=cR8fpy>tDodZ}{I6#U1D>)Yv*(Z~dxvAx|KBWzNhxV6G zQ0MReD(cC8wZGr(5p3*(_kp{C4fVp45zJ7Tf3rID+zuI72Co1++iwytqs8B82=D-! zZdsy2Zrc;j%@8PLhpyXm<oxSFq3-iNgF7JeGTI8TGWHXWu1kJ&X2$SfHIkVRx9s1k zE(K(oXx&u+7$vn(NQ7>v9<B;9kjZ=DYqQqtiORFeg57H-QFCeez#K1UCfK{h<_Hts zk+uE<``g&xXkGQ)f%b}xapYJWkyBtR`q}5@js1C_$rou|46PWezEYOK?+#y4X3gk` zyj=~M@B#UQ{@tFN<s*Nu)Z!bl>DQ*bLion=-UDw{$&MEm^*VtA86UsU@JjBacFa30 z$kZ_!!B!`094J4C6_VTJ*`$Cz>1}e`S`vWHmWZRJY|aEwnToQCdO7?ObT#lm4zE&u z5(s-W&dB|8A=+`pkB<KPl>udq6X9pEArWj6G+f_Ta2<ZlS(y5WM0Kji@3rDl?WT28 zmfyQs#jyiFjyo5k@QKXr$D`3^(<#7!lnE&?&r$hut|xi@Hg8L_Isf17ysT|y7|cE= zC?H`^$e5edw%Gul5<~IXS4ZvFAJsWf`&7~yIS41H86ZI;KrruNKUq{QaEoCFvYhCn zSn-@;0+Vv=XiQ}ByqcV}1uiX+9X}S*b>l8+_&IyW1r~ag9kZnw{PVNr*@)8C;@&lW zadN_xT4im`hE`CmXnd$ODbKlTL$D0+WvuU!VFa`g63xc|1)SA?B?6p8jS{%$TozDL zI@mW=&Z~mBcI#D&ZATLEkE%HOFO1auPzYfsbv>UGmv_3sKNdX3xKzUMrA$?T4j1RG zHY;Y$5@t29*vI(=nKx5k!616QbP&lN(_y*ORf`V*g872y12s>!agy=GS`Z`C8<c|@ zHVv{P;CD!)j(@gf-?nGCRci=NQ?yEy3^J&r5p6K-$6J50LemlWWfUCxeWdy{RYDn= z4TD2#X%Jyc81;+~oH0lKu+8!1EWg}kz=CDyT+4=~`&$(o$K|xF6Gdcr;Zm!Jx!Kce z+nGfId-z8F<r|$RfGh_penh*@KK*$iYV4|GCobjvFv^iipX9u#YY$EQEp(ebJh(Dc zvB`8ZK!~*$$cF1`<&yL>E@`R+2AQ}|(s&8-#3VQm)(tOW+0wq<()Jq`{w=~R7>wGx z9jC2q{f+tj&G*|+$hFIuF`FrGP#2gtgJw}o;EX^Ue>{cHq=>A|lgq2D+v@3@GP=m0 z$SJ7nv<xW!B^WpSiAz=J=Ttf0yNM0mFc^>@2>t>2KH8n28AKdj0Nmag8=4f)yfu_X zevj$Ci(Fr17OvO}rfRKrHFr(@OUMXnRByY^E6zE`f)}jG0w7qbJ@Y6@lqcnh!1+Iu z(f2Ka7xc2Sy0Embev)hN|7mP~(V!Bb8Kg=MQC%<Wwo4=@npXK1`3VHTTsdGd$ZQ-6 zDm3KLRI@8sEWOVA?AXM3Z(dV5377G?t`7SpZVS#}l|+#E9^FVI!M@;o`qL2DzPk^& z3fZ4IU~(YSk=|((dAn9K-+BAxpJk6|MyP)nUjBcp*xB`TtT^V=ogjr40fdV3?nxcl z=0}Rah~O~ApCP)$ohCueJy(09xm)F-Fify-6GK;V0qQ>q<n0@ciAL*9jUIcm6M#f! z-JCCfk_s1MTx|zZtpyTjr33GITIn)gD2Dmbd5S5s8tF470-6};4NAlaRfnt@ufxdf zcwaj%2#_s+w~$nd-(V%%A;Jq98a8)2oK~q$OE;2WvNL(IL(-!i)L5&!RBwlosl_1x z-P1sknniy9kGmoL&T;qT#u%5s&CI_>{>AI28GPw5h{nwhH@0A;QoCv5g<Iot#FV>! z3?XqAnqR^%TfpQ65jzvAqxL3DgI`o=fCpvG^_YaYS6tdhWT2H(Y!HN=lvVcgSqYAc zMUJ?u{YEB5unwmj#BvE8)V$u;yE=LLniAjWkR|An5ASKRG7JCRN8lrBfG$I2E%k~B z84#idG&}7;c78Z5QnNp~kj0-NzU+bU+8FVY$h~MBV!vz56-ZD^fJNNs8!d#sMd_*e z1V`H`MC)dkRW4;l_<wK|?>GS<0uu#SLejlDU8;3}Kv<g`Z^{0bGOfDFH$tYc^)yYq zdNOt?s+EGEX$s=a^S@%=)^b!vy?Qvf)*_n7%6zm$smX0(-!2E+o1LYp#>oECB*bh` zve9~{Acd#TeVw);A=?GtN|}n9i(YS&O_1LxCfz-)xTaFzACzF=#3RMRsbj{tpWk)~ z{j6I}<;I@|0AFgQyW7A-fgfQ$nKqQkF3UDkY12#H4A>6c59ztpg&brZOjr<JbYR*w z@{M+7&(!Z%10Vff_kTE;n9uU~0i|x>J<uI_4o#EbvR$i*GDn4m6En&Fc;0@eeI?8; zofLU1{Tg_GI35CR-g^60_&Cn(4cgn~Yot^;_Pq}8i}<Zy2y#kE)3*einmZzgcAY9y zZJJ;~8K|Ocyx^}tkgIT!ETsqf+qGvL)XsfyPOofY%Lp+FvlgmWe*6A`S12-943drS z{adXW2PtT-ixr7@(aWnc(+bi(B<XHXRaC9{vF6RH2BGX#tGewfMVQ1lt?6@o3FjMW z<GDZ1Vjv`iz8_8POR|rqfB`=0#}87H-ta65=QY|<MQSnkOvis^R&BaE3cM>>w`5Y# z!SguYFzz4k63x5(r8m~8iDNGSTT)G=q>y(38s$)=YLpVSex$D;Ma^6$g8HAV(8Ssb z+x@@0LHT|=hwpy|!|DtK>O}df&X&pBlMvIVuQHB-->|Wg<=x(`uAe*bP~<k&`=B1U zjvgWq-9m;=%QJ%xY84-mC{oN;-PC!>oyzTNq-eFS*t&Z|j)qU%{E>mIs)OLeZe0uq z7t<p<--+*gqxtdCE!LRt2gz<e7)s`~pLW)Z454Irod&qna$Fsu*m0gd`=dYIJNoB_ zIo`wyZQ=UW*>=;tT|2y2AjX;DUY}?w3L>RS^it|+3(I;|x!qnK_z~mwhAtKnsAXio z-+!B?S@~SHgH?vJc}2Dr^pg=nj)D3>J<I$?J7Zus-sm!l;oq&2Ldb9v(HgIF7r8!c z+bViCMq0uN!#D}0WX8G2XKseP442cvOYQvywQqy(_gwwp=~b&)XWJ{uMi<i5weWrs zrw8~p9#a$u1G;WDPYQY#^x4e%&I7p#-hLfzNf6?s_i}QH(&bWbP>IfTpK|1kY4^aP z9YjgO-W-Gd-z!%jRUp&)`{2azN6aBRTTgI~L5z%J=5!w@l?(-d;@_&rU?NvDMoM45 zHl8~c7G{HU%0EcOs|TnAn1~j*k}JySbMD~oEDhd8=2N4#;zSBN?NF{!J#s!AP8Fzu zf@{IyPutx;f;#=nB^~xi0^C5ie?OqN2#;NBvNW(g(8_`g?}8gheg$t^E1D~zyxC|u zmg^;Yi!NWUK_!mHH4cuIL(RMS(wq5vO6&5M`}^+quse4%Utzg?#j=g3uo02h+yG0j zpT1+-Cw@x0yvgAi4Jupf3(uFnvp;5J8cyGEnFZWW%U7$OM-U)T&NSYWIsG|+_f?A~ z$GuZzUEWQN5fk(s1E+6mI(?J1;>Y<IvMsx~06$S!#4O2k7n<r8F!0^eXwn}WhqarE z2oEK4g_l%3>Ox#cu9VP-FTc+RzaI=84GOESH=!W8RiN<?cS;LfJHzFDVd<<KS9L|a zu*6rur6oR_A@BwjYkvEEK^3rw!`cqpztAe&7FkTjsBR=s#ZV+deH7WYmr<6StZZUI ziouWNR<Qy(g8*|wQYeO*Mg>O+yA{$isehZOyqk**$3(UV#t$#Q6;A~=?U00PZ<%3O zaGI9FPoFdB@Z)rVPojip=u;3}$P_ok?deGe5!3}Phwj((^}Ep|>TF_TBL!AS3^eyw zl?`U=J2qe&Pa4`n?HFz}84O>dHxWYJKV`dQ?EAPfkmThWe@!xM^pr-eLYD`$qsb=J z+CRkarl9=O7NQdffxMz+%fwlmz}Yh<4#gnyzid)$pye^S_i%h6MrnI;GJwj_dg-@X zC~rl2cE-MU#%p<tRH%Ya{-;r$^0+3M0k_k-V%Ks0J>%jlB9O)b3U&%3A9?IRTbb>w zMUKe%HlZj)T;oGIk|cxwCgN?Gf|tgR3);v}+(O^Edbj|a6(ue&%r_8T-mXu|d8)W{ z1H7y`(3JeWsT0~q#4uR}hlA#n-Oo|)?CN78BU%)zN3?Ha5}#Xn<Lu_biAyi6VEGC1 z<l;kCZekM-mS(R*I0lPd3j}~VxinkQA~ldWE&J{KuMh{1PM%)Zx#EI`7!CvlM1#p) zv?6kXT^Q1Jb`XpL@4%kMG>H*JwN&u1Fp@dYq<y3v3BA_7E)WtsVYtR<%g#_uS7Qmy zP5p6#ihMr}_X>?J2n>NKZ?*t*Zqb|aWn_xYU*kjN-9vfnbl&4K6Ww?H<A4pJ$Hc=e z+6qL_0E5C04L+hE4=C)B;)w#knj+`qM9-33%#3$)VR%pdr`mbJ=~*%*dJjW+2@vSI zAH=cuXn5-TNq(Qyo%ibGCrcpNdt%T&jJ>IV8RY{VWGgbYP}cdeOQ`~;n>BAf%fuJu z;I~4@{u^zQs-y4kH^4laDxZTS$^B#fhnD<?#l?B~CvxO4Lvaf<r1eNYlskJUfrp1D z`+zO}049MC6hD!u$f5+0so8!D50*n%icSr`<%*O0^JVm-mHlX>w&rRsQBvEad@q-w zCX2T}<q?uPXZ3B**jThTy=?)$d=x)&XxLc-Q3YAx<=Bn_NPECh@(UNxDY=ZDyhVZ* z*4=|*vNl7d@2?{QX$pSy;YIqC-e38?i*6*A;UlQr5x_Jk>1lOFgopjjONBR>szE+| zs~z?|<k+;L%PI6VwzdJ!IBBBIKOQjch~?GJ?URR<sE9ymot3A)r7#!q{Nzq(GGGYv z0p)SUA;Gu~=W}s4l~6|((C$NB(b1j3H9CmZ;i*2wDd_mqzy=SoiWq2L3pFZ;L${nM zcvR8D9QpjmlLL2S!0pGSrjs!)31yB)yb+|k@`iNFTzw*U4j~pk*r1|TtA;xbU-2Y= zcQi&G42$@BL3j{%0r#gRN?cN~QFnY2#<ROJ>ADT4`&h`A-eS3<noY6ZzSuAF>TRMl zkZP?29*{YkdR2V&#o;zDo_UH)FdZxq$RYHqm3e!Xml`=Ab9X#Io74RHMA3Ep^Jk45 z>x9&xiPt$FjF*<W(B98`MQ~kzFzQEEdb&I@0L9l05WATle#ZHMp7ZOSPWU~F4RB^B z5_RifDm#W7h6F%0Q{UtK>=(BhX3!N^lljuC!MNhRUQ%Ph2_ZfCTrCZvOY8svznXC# z<s^jMV|(IWJhO-)2g{0)FWP^qgKnpz8`cv2q{QH3(xD+(_V#c~@v=)$UHnV6<RlLo z-eRmCPn6DbI|&l;A!A8Kx0AdtPqv)}udy*5h?|e7{wo$}pBCV#BR%h)Bx`!3<}ah3 zAABjO+oY00TB;>}m_vb*MJv#I^rXY1N?!US(kEy2^?AE4tHtM%K(xVaX(d4W<$&M5 z(^%^1zO|DU`SWatBp7HBZ4*giZ~CpkO2m29(f>M1W<Rb2pC{wfQ?mmGy@-X8XqMP^ zwh@x`j0|X<)o*}{9W$TpdOIevDVyZXIH{I+j{OJVB6m1P^tDO{LV&AmQAv1rF{A4& z+m)a1{@a}H4N@&gfr?PXCb}W$D<E|}vyd?RQk^Z*iD-I(1yBL@IF&*Y0QoExLC`w& z=jd2O@=xgj7n338bPu|R!c{!sVLlqenJ-rPbO#Dq{<K2Q_ZMXIJm%4o!Dmz}V%cHT zkq#mfK{FF-I3T(&jr(YuL*!`a1wb-p%MWi_vPT&a4!@HmDo}HjY|{vt3RnUEeB26} zZhgLx@cxMttIB32iBa)O;<@i}x+ky*zg?mYxSD?X9{IxTv!C10PXJ6{zKQ5Hxznzf z%DHIE%;%|jt?0*gK%J($H6&k2kBsv8m$hze{H;UrsJ(9NTlz#0U=?EK9TZJ1L)+0T z$cYs)qgBs6YX|b(3AdEE6oM`LN4y@C3660^0_H5?XKYIOND^+_!hX-<;j8{0`)6rb zpEaK$H?0Ar>FxTip=o|j01B22W2>}$*FezJco-<8tz8O0@2MYaSD#Yy^nYU}RWpgl z)y<?#vF(yYx>?)5gAp&2g5aV0S$JyGcmu*8d}YWRfq|VL(G2~L3jH*O-93f=VZXvK zlbCvLCyG<a@|puT%3X8=8(x<|9<ny)Gr68D42HZaK!~tpEWleq&;x0YKbOXS!ufZ3 zg9Jo9U0{^B5iRG<)}2<cCG<JXzzPgpYt>T$j}5-G$kLO1;IPQ-qEgJ2Ol>-HwdjX` zN>p0kw#bq1hnR3;0lcD!6m%Wtb5_9M17|*&_%Oi**LX<RnzO}%oeLdd$wW(>hh+$( zQP(3*Y-sz4yF&fs_#3@<wr|iTKw2xaX^}5_K9{ZIT$B&eIvvxT6^sK0ZujXqqxtJQ z2Awr9n2*ZDNJ_$N#|-!Uk9D$`!#f6-7am<q^UTYS8eNyrAD(}Qm97UwP^4m$DP*UH zDSr3{ys`r5RMED9L5A1BdU)YTESTA1!_{#WVxUi~)x45#&+lbA!LyPTh!R%434L)h zJ*Ra}4oI|gZp^np|GvI=`!v#4ChbUTWYZaht=c&OSJP@u9!E`lw(M?I6**7MuQ5j& zY0x+80v_<FjK@O03f<j4`pV~WC%H}?5Fh5<jxwkf9mA^Z&(6<6knwppI4~M^YqVg6 zqU377Y}PhmWaY1qzrQww%Bbvpz<@-rtnIr$C5lV0zs5ZGsEqj}{>w@F>nPy8BD{+u z$6QKEVi0DWF*Dh==cL-9497Y#BYami_h{nz$SlrZV~_O?8rKmPoREqh94TdNzrT0P zhSMv78FLy?Ev&GWeF5ovr;6yzmbqcY!kv9b*fk{+@@?G`ZfrTH@Q`BW$xc0DV-tw~ zd;Pn67>E4_*reyMf!8xbNf6a_R;4}qee|});4kf=y;Rf^m2iygf}ovXdF&AjuZFd` zc<!}IxO#Lx3)k<?n!TI9M3Yg%MdR{zc@_Rxv9z`~`o=Vv);L@i`8Oy3=$-YjCq6<; zkHaThbb#Vp8F9gpasKRrPvu=qzlo0o7l}}UYvJ>lDIuR2k`gD{UbTHQMAObBSN=&4 zWj(+D4^#tDW41j&H7J-$h9>=NqaZpcczr}N*4i_e+fwi&7>q1tgPyO$WLz_{{j$=~ z(8);hJmHmw+NqyU=5(U|h>kwnwVbr{S5P>#m}-lkKh&85mFrK)JF-+cO><~BBcL=H z^tBl7y$4B77!}z__L`Derv5aFvMrZ~kuC45?!D1nq6<Pzn{-Lp$rLGGV0wdA=d}C_ zkBbe{X5==ZrF8o@!L;oHmm`UcffM$Gs{V-Afz^ySGUm!358-()&l7u;oZhzT1<amU z@s?+$^)e#<o3rKfQd_gHbMG?K%5U}I+_zUcrCLYnB(@4hM65R7Xg17A@JElK+OiXN zu8$qBpZnkOK$4(JofdA)|7^49@B=@yLD|x<(Y}L{rL+4pWds}d0W0i5azB_&GYeyy z&8I_xzdt|Ymu@hv|3?|Lu#Jp3^9k3kFjjGN@3V#c;&X}+?d2brbAa{NjA+Cuuhg>{ zRmg@EwIug%^*!7u0IStA<Jv1}!FLFn#k9xvU7yUycE^G@7+gN-E6dg?WHXyHU2QcM zR~l|h8dTUOx!iVRwY^V4?KtwHFvf_%nVB}n?YylP+J$~}t3w>D-@cFrhAJhq^h(Y4 z2BmG5Sr(qid9iL(+wvDJl;B~eX$&M}XweuprXyc*as{=2c2D?!Hm%OdC`NMfi>z=H zDr@U;BIBi89$En^h!pvl@1+6uePxPYbq3+(cBA^F)7d#fp~zTi>NDzc43?*?6v2&S z7Uy14sbD*Z=1~WQ#Dad4XoH<llljDITbZQk{$u|NkPPa{*=9|du1DW2bSM!!3geGI z{z?`*kbYlr0q(9n@bGjgSOt52snG*GUu0y=wSMtkHJfZgLzM*>CGm*{TdzZo<B7<A z_Xwwp`w?^xA0IR54Vt4Y!FO+!p0v*Pi)E`))A6P5CYSHIQKft1-7`MUijXgS>22t7 zXzHYH_Gfgy36sea7Vf5eO?0!$ckG}-)b~cB$_vF!)7h#YrQ@NDbtmEC=-vf0L*V&$ zc^3+!41Ee>P8XN&(gYKYsIrucSck3GF#pK?a0=AG78%?vSBN%cqoO(QH;P>oO|SYD z%mAW0KX?fr)D{X|I6w7j$Tpj44kOUt1W2*FoHv!gw{`WA-%ge!C2Q4QoyW~-AZo8W zIEdfReEM^;&x;I<ZRo)-e*T8vX3~$nJCVS%mwAZwG~sN0n3W7<A=8>*Kd|Y+MhClT zR^L?!gEe0SQElk+Z{<#I|7lUX>Xhnq8fk<Q#eihd>4kE}t<D&IP;srkiq;j>RK3c0 zo!-VJZVpE>di}9HwHhxq1q}dHkWnskc9)CJbg7k4bq;ezJPmF95=8f$#8i>T`YO@f ziHIc!8QvO3r&G!!=b7Nv-L7^9XIeKRM0I~;{beJMOI(b*$y^Tf_by{$sz$?HYU-~z zyq8>R=rIPMMMg=!I-TE;Cf()5<v<VZ6hd_9-dxpNt*9>&4$>ctiOTBX&L9|siY^&1 zu|Nh%s*4ZwLjvBy7hJp;7K6TJYEb=_K>nowRSB798jn&Q)shpxdNe}@6Nxw9M)2zE zF@x)YRrnq-e}bm4zl$tBW%1)#;paptv2vq)m4n(%nmp3q0MCr8rY<~8#V^HyU-AV< zsAiL<H#T~d6-}d6+SbTPhbDd1u^i@(PDF0X%3m*TtB<8w7>X41jQWL)z+nf{<AB#a zV}z#gp?JRtz(f3#>Rm)fJIUO@g_{Q^lmBn>sGmoZz9qCmahnqyAtbS96BszXuE^i` zf)hFsU4(OJN>kk^jbj~TWhgBnAi{V$zOoM^7uCm$L(dm-XzNXI7Z<JpJLIJj-B7<j z9Jftn8`5|16*^~KJMpV|Ot{$c{kg?<KjqPJ71o6%<G4-iE^Qzd!1K$f`#Q5_(aupi zEjfVCY_`8>VMot={8#vk3E&nYgn!&gzHal%qt0XGL{U<JTCo7s#+yZFT>baWPZ7WJ z=P>(S%85VJp9Gi-!ucqDqoiN4GpYXkI5G4|56Q2{{tf1NFLz$@dBDlbKu$)&-Avm% z&pqBXwc0+_-4h7e&61yV!IyLSbHCZYRSn;+Ft^MKUzwOqHxRtDM%Ga`vn4g1=dbK# zu*sSxXtXFKePd~9ZC)RN$v|S}NF|tTns%(vSp8oSi<*>tf_8i+dS)|oJN)<W!sPSR zym~<HUH0Cy&zjHL;9+5qZcmUSJRv=xl7vH5K-o=A+G3DrJgF<LEbVb&oUNQO=k1+I zH9)w$8$Ai7j(owTkzLUImq(j@k=cR}23K`H1<LRE+|Vwlk+yr=+g7ao=9AL#i5&!| z>#VKFRAKuGa8#@<a`GzjMJe#zGu_P63pV|i#L@JyO1SZ=zcR31Fk_Ni_X*rFK`%OI zYZk-b{QmN2A9$F71{4^3PMR>nqSlx0+z>%`t3j4<3i#)D%(MqMU&}Bg1#aJFc~0DH zWd{gHk*@&I&;9d3?>a%S^&g>Pr=$$l+G3J)IJLph&)_w*=FV=lZ%7PS?)6>~zGFL< zvlVpyOO`Cg=5NkKErYO+nc{waIGCM7|Ff=goEZ2#%_nzCv^i)DO>$i^{{UmXzn)3+ z_yk6QYE?R`zck4@-8+8XG83yfuTe06ZLBpD`i64j?gIzxRsdjeRvUsxo_&Arf@fKh z+}s_K-Kb7*<~S4vzR$Ped`CFXN``Eck>SQzBq^Cr0rWGTRx11wK{D<)izXk7q;mxg zp3$B6b_WL`)`LTSUrO1Lw}=Q%<uL5~6Nt;U3Z(j(0jOtKTAX+*U~DOWOUBN~rNl0@ zoM{Y)cmup0OUl?+#TFvu4I`d84N!MwVsj$#c7ZHPcBiK?wmQ=kLflAop!$Jk=O}c) zM4>w3nfJlCLm1~iG6Uh&W9EXOaI`-^Sg#a^Rw(`Z87Bxis|B(8OW3j;b}4&WmqinV zMt5M$$JJYM$5%tq?n#nNEl6B+vg{epM@!awDDuHDM&014UjIK1Py&eZ;#Sy*rzU%G z%wo)*_^I<Inq+ge2vA~v!7p1!s$`(WvOPiX*Oqd$W4DtXP0wvNjKq=6D6Yc09;EI+ z^|wi>?tSUa9Ewh<pg*Syl0Em#7Mo2lt7)vd?c&;{q%CaD`laIV9S$OvSsXr;^s=&| zgrig$?08nmY?Dzl<|%cE3CzzvILw~ZuACPgP=6ucrvL%C6HRjvMPETKQ(UI%Q9Oe$ z=XblP9scID=_DYo$Ulof`Hr}36PvF`jmF|CW%bbLuS8ivbjqEr5Jn_w`+NcD85Oph z=xpyUp@EzQ!eQPn%_rk}2x;0HRFK39+l4!9iYmWrlN#o^r}WE5*e?)&&)WAa@?H+T zBi<nf8%~({)~_v?ih~M4XW!tWj|vKi{VLeKeeXzTG2?XUZ4}8Hnz(wGY@Qd<=;D2W zT`U`L!UK+7V!aP8JAwHNJoEInn1#>d*$4|g(_Z*|IV3oNCK<__i+={W=r@(0!mfz2 zB)-E(pwQ&kZ#Sv#IsPcmg2=ZZe?w=Qu2EGT_fNi9Dcg+>A(U}n%c<ax3XY@zFrRr# z>DKv;k#pDN6H=zb7{{C6RE6lW@-(Z?AXA40|9^v<eXb)Wc74A;1YHN*Bs?jS>!*3^ zaY}v^$h?U(X_0Lw^0a!Z{;<-JbN2U@ogU8VJ>j1Wbugx^__Cz^IJ3lO;{1xf#T4^z z!a_8`1U5L4ij)ihSjry&%%SJf_DIT>SMUPpW<f~?bsx>EZc;W6={=pk+fyOWj@vYq zhZ1VDGfWVwMB}ZjH^3To4u)V%K@WeUGGC=}0}#^;NaW1w+BV4De-F1CjPAhS&z|vx zf1)8uEvd?4LxCPP**HVEBOg)Jj`VzKPy-_k@LJPH<iWcmI>nC1RU$g?N~ui6HpA1( zhOFFCkm-E0QAjT_Fed+sMAabpfeF)!-L|}w>M_i)xP=*H6>^&tsacaN3ZwAl$MzwN z$}&NR4`35|uO|zkb;>Qa-jccBC@)~>_db25Uq7qdH0re+@UZBuSw50?Jz1TdC>JM2 zRs=}c#>+-*oX{~t*vM9ySuG~aCJ3iZXAE#mIEP({tv(=%#gkjU09Qb$za<85L?}{5 zoY{w2WEz7!kpOY-k40G1^yoFXyd`PRY;mamSMX<P=~1(kPWwRS6Gr7jLLh%Ke9!5+ z%IamZR!urmg}H12ms^eqsMK3A<oQ%w)~4Un!Q@$gV3;bGnoFLS&8!6~BdUyp@zbxb z@{UI4>7uS1ajj+Gt;=gj9u6|NJ15i_qSWCwjbdm3X2-tZ=v=d2){jc^Lf7odH)H}U z_S`4N4iH&<TqM9Qi}Ie2Q&IowrGxgby}Iz6;+WIx*CsA6g@+xhmnmITK7mA>vZxUm z8ZcFt5XG^E-6s6=02|m`?n_y1#KT-x(RbX*fXE!G#@hBcT?xTZsZuIf*cHZJFg{Nn zO(hS0F70B$>*JQK8vKcbSB{o?)Bp@~$W~V8Z=e%~^IaAq4%)feNfwK5F5<v>kaBqt zbSxCs*JmQXOH4Rtyr0=d$LhRO@fu`>l#Ho_7UOSIwKDPzALyk%uG7RpM~YvILa7df zF8YG2lFS8PC6}TI&fp)C{0}!k$iG~Lf*dr?mEhC%-_ZcEm_yx_SeB6Ib@ch<10t)O zSz<T=PXj)DX#5AM7XKsoV?ZQHY$_^*1Js{LqO8ACvRBHN(!Kc~n?aZ~rj5Hfm=F(` z-7@@nA4zaG(wCFCLl~$xn#u}r1PQE+Z@xvQYp5u;Lcl}ZS4$Pjv%+;Er>t(6Yl)a1 z@tau!=c3eM>J15ek%VaqKt%im04^3SO|mapd(-IuFjHA@(8gW(Nd*EzLjYLa0f1lE z)DJMaqku*=*v3B_!hRzLgS8MS>7j6`YAQI{fI{kLU!{w)WvLn?G{C0>pFJ?9dh5r( zv8pCkH7wOBV+#`4Snec+jp)(JyZ>?5#{s}VA~VqGbi2uDW?-20%Y^@+#%uxrpp6|_ z0Br!^a81HHiIG8k1<3V5jBgeC=e@1g@sR>mj6F!Yy&j$pV_y!EFK}1^3kM?h5J5N0 z+6A6M-J#+kutKZJHp70KmBlz47VVglp`bw;5YnhXqOW3rTtHntfnR)jH)~^Wo*B*8 zP5>~<kC$gJ(_ZO#{iP>{YP<X&*#O`uRJ|Qiog1lsFb(+SYd`*<TVF+<rD5KP2MKQ; zV~Da9kzZG~-R)i}_8X1I>p;*$fV|MOJ&UHK3nh1i1?545i!o?f5e_yY{>6#}MZg~U znOdAe-h_bg9Ri*`q(@}H+-l9IO2q1Sck{NwJ>e^r0gx$osj#5dz+vmQgGmq{R6z)e ze}<)tqqAW)hY4iPsZk6cpkjhzhxV<Gi`%&X@ae0%qJS@6-t|M(0=xxBHg<r6Az<VD z&B15b|9!)VRemb>&rUyKx0}o#LX=<7%YPn913vmSPy1<Hm&4(9mPXSs8o7{GMX|Xg z<&%_HfWgW%PHsmDz^=(ncQo#z<mr5#bav3WBwz{hcxL`!JXtjo-UIr`N=S`{7H9(q zhlT*?yXM7bR7aX?1U#Ux<vW=Bb>YPGZt0&&3GYy9<b(&ri5iLrx)^WoZsqvRK3HKO zWbC*>Iw+Tmgh|1Gf|$@kN&9J@mAhb#7_$JiWdi^5>k&CHh$reZ{WUiudgB53PJ13w ze=zx&vyG$J5P_jpR#gz*H;$Mo$E-i3Xut!K>#F~W|4IKjBs6LyET66laFO8w000P( z$i-U>*!A(>1ob1q<H_uimMcsev+=|n!odffn_1WV0pGzSA2lL!fS>>jSXS0vamTRh zBrcg+5bGK2@3$V%*Yb)qaN(pa=^qO&R$pr1NA8wAw=@BO`^_+xq#fe~IfPlZGrDyc zrUkZu2vNkq(KV2o5dlmT610$%MFF&h*JJ@!X+{s_rvG=>^lcx%gM(G}z>fQ+jAXf` zZv+W5```uuokdPr0C+5SnwCZQAQYkUG~izkNC13B_>cc52+0!MrusZf<A77mTIQ$~ ztsBJtjQ4XZ_Lv8lj00GnSOK{ro}VjEsN7GK1?ZnA6c)(WGufVD&pv8M3*3SPuuCun zg;7C|0Pnv3e$Qa=EdWTR=ZsW{(mgq*H5)`CfYP)%`_wIpU2p-#6E9Gp0A1h*Gt{m` z7nD3tDFQkBG294HaKb2|Bgs#Zz)xS)#Q|1nQi`p48dn*4WD^a@25i`#9wOK21OSwe zcv~U;W0r?U!)#i*5VUYwsNwt_4Y(%&zO($FWmSh;HodmZYW87D;nxVjiP67^eE<MZ zxv>Bg4-u5MmHNLLsn9C`00%bi=sQatt^#qrh;l1+peQ!s=o5m3m)sP>&i)4hU)^_g zP$u#^N|AZ9l}0%H-10df!9qbx_@aLtKnTb0S*s9QEpja-)DAHkLWl}#0N%Mz23%WV zQPT!Eg9#c5WMV*F7T_wPA;>Hc@(uuOjA0FI(=DGhBKT<b*Os0=-JpU8!cJD49X%@) zAta%0Z5`lFeKtUh{_FcLuSH{}mDP5!|ES+yq8rZ@29;CUe(h2^mSg}_?h^+T2MER# zey(&j!~e@*v}Y@?cpl=>$pjL}cX3;u_mOE_inr3erE9scOhcLqyStk_#@F{n0Drb3 zj)wbARUo>85XXP{Q?3Do0zcPJ1&c+m2O3Bat3o_b+}IixY5@*4TTDL)`?b(7CWWld z@yHs6d=yYyE#MC$nx$2DG!lphmzesc>-A+*U)YU`>=_i;HiBJHw>1<>93csZTpr*n zlv*<<@ce$6fWKN>g_YI9uvD&YL4Q3Jur>-xr>P?nEENQ}qBEMzl-hv<iU{1GdCLm{ zfSpL`!hTl;LB5)K7_j5JuD((Vn5MB9olE1wf+g!r@YZ6n+v`~1vj<Svf4o_}c-g&` z@pj7=@iqEXv>!Pi2c(!Z;=Mh$aJOwmfd-6N-(@X`Ar1ibs}S7cB!*6=N)%bkcuI$` z@&MuhbwvS$fvc-gwwVNE3YJSZ2nZJz4cg_VV65BK<vK~Ec%AsHM5x-NbekhSuVMq~ z&3y>~lk27bU0+p++v<i+@R3T?rTlIVR+BEX;xHhz4<t8q18SHX6xdMmd~!!F7!f^G zU2wL#;y4Q;96i~Ywjb>5NeG(t=iDrSb(1JByv_(6Kdim=qhGycsY2GQ`{!3*zIpZX zYK2FlK#YhWxYEo5I_J9Q6e$8gbie31Opo-xFC&nX7tCzVSgM{8iwAmY3-4al83nBR z3zvj@8yk-_5q5T_2?AO~d?WsTg_NT;Qy405fSRxXBvh}jGZUd8%$q{M+xupKo`?Y0 z@)`x<kzSk6@;D_yz?3H6od^(=ymdZ_$qO75?Gbi87>|SKAQAoZwqO!;I-|Rp48Ta^ zK9J(Ag={>VH4=;Yu_$=!L%sZ13W&tXWs`B(zUlywu>qHcfcKj0`oj-@3n2bsfcWY! zZ$8b2NOtS2T%<`LmLAYR$M%p+-lG&G2}8q)_<zh(ks~hD#DH4!0I!^Ng|7|3#^~F* zX;(8rx87y^%^Xy+o+-elt^hr3#f;tX8YLAn1-1aqJ^=Xqp3AEd0C)n}D*b#)Y9=a& z5)T|?dUyULDP7Vjqq|81I*?5p0m1*xD9buB@`M4Hd4hnXf&Yi|`RKn}*?`IH4s2lf zMaC4J83BygVE+P!)$Dj8#@@)KDU7W$S#N8b<66qYW6_P^DM#!KfKKLsZ}yf8Fv8K} z1ZcQ;aLaQl2-xh<7cT~H>Z%2})KZ^_(Yq$XS=Art<Nq*qxsF3VY@2l9#{O^00Qx1v zGBW@yuQO!?0rcf(U*FRKJd^&(skX8t73uM_C*pbh!P!9;uex`mjBHR+GC$^SRF;jM z%-tx!Ykbh@zBU6e8O=~KVZE9~j0IN4|7!Aj)}5QBNAsXS24L;_xy$gkNTZ?woKBfS zrrsv{TI!tY_*U*cRA`q7htX{h?OMeryO!?5{$OdIfF1fLT7WS!92O}PLk6M%Blqf6 zO;JD^$w>Rges9m4IuRC7swQ9Ib1?v$l)ps+|C=h}NxSgi*~e3_MP?vZa`;{;U<iN( z0GDFG0N$D*ZAtB5GS9X@*p6naL8kZ1Ml00X*h=rl)OaP2whxr~zqw&IJDj3sa(_Ie z?_~Vh!3g@1ib*kgHg6BFbg54QahEP}ZWd04SqXcHM(GjoqfI8Ou6If7wUpXL?@lz3 zP(M*{BHd@ht>l(H*?^WzK(Dt@E086saRHxvLR)Y$sI4QYmnvzOuM_<OfB^wzss{%u zbdhsgUzh{Xu_+mHqDR?PN9ms5gYOmqy!~fWBzXL{dqx1yjR3-amQin^DboGErc3Bm zIdc+seFD9P`gulb_M1o4_xcly@dM_~PPiwYKek8usuS@XcULPJ|Lz>UD?BvPkBY4~ zKQWHZT>-&i98&*f;tEH|!JE;or1|^pI-LOOZS_*8C4?+L<dC)k02Y_V^Aq(gEfBy9 zP$ljuuPBb9xnZ|qwsh%>FKglepSq<Hb<`<6Rz84@PYBrtgWR<=u}6k3{8;A;IKYNH zvX}D30j2p$GK3{VetEwd@R8}Cn#whUqAeMSuGyTfnRG6DKAWM??hPp*ZjEPF5Y&8` zuFnYDBW%7M=w^c805JZk?<p||NOaW5PZ)f<nfRE%ai!A&13|-ZI8;5uvH^ds%?Hp> z6UGj^9`&_um{C9%n$J(Q@AXPNKrSB;x)Ku#Gj+F+AyyH}F31qCYO?^T%UZc=K~(|J zaL_yj1e}3>#58Y^Fb2pYTqBh!-~>6fo6XRx-tYWA!~ndy-`x6d-vt26Li6Sts(`3N z8m5Op_HHbmN960V_+u!)%0E|J>J~do3G+exS+_F&UdQx+$^%$Yx%24IR_hilumy-7 zQf3(EY%>m)Wts1b23Rau+uCP;%4xVo=T<Yp%`VfFP;76Hys-e#ilf2;LGBnCTs9Jg zf{ti_rcj3`sEq@}uFP6A1$*~j0YGX-q;cKR4Sh`S?1hI407d|+q>&wXK3{7;GZzrz z7rwjq%&N~WNhp-Qii&PzjCo<A0RUA?m7JJTO~E$t!z)}j5q-5jL3m&`GvkjwvF{uW z3Ea^5w<)`A-Ave=b{%s7YT^SIDr#1pO+*5Jt_uKvIlatNxAe($+m|8)`Dr!?rEqH> zw0vMb%v*v*jJVz{fnc0H?cEOE)YKDrB^2gf|EAjNu<Hl3K8VMHVZf`JyBxW%uRR<* zEztd3x<{6p!(e5V(S2rCJ!S%^Z>z(`r8Y2=KwVxV&Hc2-?n=2UoVo&g6mI~StgC`p z2tA{Xd;Y*4<8RhqA36X$4@kuP+D`XW3aDBR?IKoRKcc_7O@tX*HsFae!u7~MFOTz- z>Q57G=hg`*BEaYmIcLs#N%GfW{=onZyL(~0a1!DHGJ)x`myYV|3Qnp#fa%%DA0I#P zIj_`@cwMi@``TFy%_LNQz=LH!L(Z~tDI?&UL%+G-@@jGbm%Hd+r4Nc_(P&1ncQ?Ti zfPq3C9V>jlSe-1s+`-s14i$Jjme=RPqd~)72q6$?VD5c4&Y_04S9t1~f9lq%=Nj&B zR>F#RJS29;P8`Xy+4KiJ{-`DvNS`YVTdL1{gBJT#nc|_BCZ)ub2BGry0yx->OtDF< z&fvk-g0|C_wQ+#BkOdG4M5Ih@@5cN3+PL4E33{k#v*)CJZHRvdJlePTujF71v;62@ zA)udGwWka~YU5w}zZx}6J5&HCGY#;WAL1w%0006ukpq>0ZUUe3H|=-ZebovE>oG3p zF7-N_1`;de=fkGNfZ$;_ZLgnz7hpHooa#dFoB&X+Lw<EhqzeERX{nOo-sxGJ;T;aW zgiAPKTB@$hcLW0rB`Y1LmIoTS>%ptqEC5k}tr6Aq>Rx}m4Om|^&FFj0>#QONK3nW_ z2;Kx30k}r}yanIJzq*35xA&h}rM~LI*$irhdV@YHsCau<sa+X)75T;gx`@F*3Kuex z_ROe)-H4`S1G_;fW3Mgsfu89&HD|#7k#=104L1!aAmET&NQxwUmdi6b+&>l%tjz>` z-n1Dc5q55Gh$L1kZ0*}<SAs|}f{Rs8q+UP@2r(l8|GOHbFKg=w1OU>JDG^=kBk?@I zfA(@A!0dsy_mvqij_|H($lml{$nY1Tvch?hT=2`^+(-YvGzR!F060rxD}hG+*&W>~ z;_LKq&L=ji5%~dc>}}*v*aFno{o@WZf8dE4|9s|Js^8OkgOEtSck!s2L7&*(=I&We z2!43jk?%k002HAC=-qN7b&j$S2rv^+S2pNN>L%j;PD}uC@;{*^fARGTIVY!DVVS45 zJmeGC+@mFAL=yBxeHI`U0EYYC?X$PRjhL==FLW7u)4#sszKN9Y0|&dRyg-=B{+F5e z6YkYl-+cGWdoHlLr3m0y2q^jkt&_vtpSy0KMCoWIrJM2<*w1b@b3VPj*UX<s4V(Ex zKln&#{~&8q^^@Su`LH+Qhv+g+w9^H<3Kf_L?+Z}Am&C#WS0Yt9=y_cx;2XVA2>y+! zzb*G^5EBxIdyK^8t(BwEzY4_7e8DkMLRchlajS^|Y6z)|19TlEM<lRn_3)bW16;>p zwhVXea$^JxCw3uO`vj{ECFcJLokw5%^Xs=CJ>)HGT3G@8D+5~6`33--*xtm_c&m5R zex?h%Qaoq?Q0o6gGk*>q!T+X#=pP-yFXvPAsZ9Vt|2p;2fa>x--0QIEmXN~Tgi5h2 zgG7L-oB)yX-mW=;?V19Cw*Vka!=rqORd@R|zAm3$?-~Q-+NBOL2AIcOMK<~!2S|V# z0_vO_C;;S|<n4#G#Pb1dSoHnMBdp^-Q@5uC9tuN$O8{Z)UtGQU>g(@*`{0Ry&;0tD zOfjcPIlL(8+fN5~mh_tm0W#|v_cP`CmG8s$i{={^k`4k*Bt(dcfN<bZnvx|><i>4y z+qka4fbACy*r&P~o0_451`dOTc!vQ(`-DSrea)o7pW+0b|LoWG_<+_a)Q&%0?ou1v z(sNj%^zfP}k1Ot<;zpOLQ#A-aATT;VGiX&`KLCj!0HBP6>E7%39SX?o?qAxOuMbtn zrb$&5I9*@u?!Wx%pZ{RkKU{wJ`e#Z3$l?G1I>0imVD8-NZnhe!jH?U~<9&vBPhdvi zQ7{7pM1r@|4j5qUkGhYh0fl0e-o2ZkN3T<xnPvKASM5#5hKu!;tt4uqnt^n0Vk><t z!<KgfTQx0y_@a5r-#jP(Q!JeW15rYPFUhZa`LN~U1TWAI_pW9CfdkTW)*CeF0|0XY zbyWjp0i^#*^XnX-jsI&DQTc<7Z$Rv^>dKg5`a<6R`-jDz0jT_l{=;p$z!O@`lJ?yy zZm+H|_m%D^YyI14(h2;{26a0z0ELBVzkw}iM?Bw1%;5_F+S1D03k;m<JdW*{2nc@1 zCemmKFz?GPj-`0uu}nZs6@kAU)AW#G*-bKz(ZaR%(nY4o|5}`14Wm7<XV0YO30N*h z7NEwSz*TAuA*ZKC?6tj9^6^k@IN@5))(7aVzemH+XAPHc<n7;+6B`5Imr($LlV)3C zGVeQRd~jQi?#$myxv~L3LBn43V3c%5tAH~t2r#voKXm-er_)Zm+fHZ|ohLH++5mw* zF?#jG-Vk7wKiBd1(7Qo`ue9l=Ge<xZs`yx#dlT?&J*!{-<N5Khb)9sUJ>e_QC=6x$ zVeb>CNFZmtbHm9E_2mEcL3-i<^;&=xBrsS1q0a?ZA3@==d0~rdbFscx9qq8L5q$Y! z9c%2H0XRA~1CVF^G7qT$`KI~ROtGG&`EFJ-&-*RVXZBAt3))Hq?Mzt!Kv^Q|1(*{) zP|$OoLo{t^zlsJ}L|}y=MSVK>Bj2#oLv|{&!Hp`2G%dKKyvV%?_^h5t@VCcJ5<F!g z0<i3bLt(6>{U@U&RK)HnKEG1D0HRN%T0pv9FTOSokS>h^_)=i?@e0mcc7I(XTAPUK z!3q$s>RAZf=GGqrfE)mnjX_3XJT}i9yj-pGeyeJ7m!iN4W}tBp%sP>x!ay^BZhSpR zMdH~N>O_gLJb1+cQ{CVo6?3gq?PUhc8rW{FdG4|U0M7X;(Q+vhaA_vsbuB(%&?M)1 zy~NHS*TXWg`5#M||6Xqa08+#VqEQ5M2~O3Z!RL^``Ygc9tI0f}9ECc)_>)U%SVuk^ z1F+fKT}drH5`X^I41g{F%p?#^(hG~WPvBfJ)CmShD@p*q5{Nli>9A@i-S+fwEZ>l1 zJ0yc`UVyTN^!{7g-*@_(h|;Ul%WV^m0)+la=@mn?b3`$LKXZ5@0iakyl`I={Tu)W_ z4ar~t;FvPts0k#A<G2WS_x75@>z*sBW+C!{Pi2IjF1P^#=nKaMd|I0Y_<|RQj?#P$ z0MqS8))$+4@H-pe3qtuvwY+EV*pk4ROSfn#EgK!of03F2Xit;?=A(Ro&jssJb3D6A zqB?H1KEMq!CM19#a0CF-IUk?%#Sc^ipUv35j_hnRkC2#j*ra|wiP?ix0I=R2EgfN1 zK^Bm!r64#|6SWe)@iI@MrILNiz2V-^Pfss;74Jj!Pr*o{OY;YGg#v&-)n@^|Sg}6D zAjZI<&`OS_YA;X&t|`&mnBNo!Ot9Hk^}J@uszC6+gYC1hY}hIai4=zic+IF63qWY> z6Btze1p;^7ju~wRzU73^ca#?5Tr{zP@++#JdZn8|LDD2<C&lZqK8g=$!lBo@EJMNG zrvtPh_{x^A2|asV2kgK5X>%{k((6`^Zz<b;=1_h*JUwkab;Y&R{nQ75sr-<xW2*&x z{<(30m-SeHm#ItVi`0?A-$Jt*huOZT0bCq!D@%lD&U|v$f3e=k+q|m913a@%P~{Rs znt!ZDXU3Zo41mi1XrG;BgRI?)v(=6d>CN*qFW@8+F{qdz{J(8OosYALKWmOBy?Sfl zhdDbP?F*j`FbuHc1B|%qlp!dR;#wv^ufwS&74YHk5)uHa_V&p4FFoViYo4}BLIA~n zPkZb5&uD-oig5uW0pJw?sD}e&t?Pcg^nJYhR4By!RsKX^26@)XkTUZzpZ;xl0?TQA zRmV`UPSB5!n>0U6G5*q5+bnpZB|wb!!33mNU+Y~71*@yJrEJT9&Vci7&^bArtV@Jr z0YJjMDk+clLesd90=%+Q=iNYcOf4#`G=Gw$g&q_%5-&hw-69MPti=cX>2ePe;81hV ztGP_GW~*8+#&SbNzO*l(pijAF#UK(vq=M_S0I&FcgT*o}GO0Rbt$+~GfIrU5On0`q zNn58>zF`SQ5NVS5rj8gubHP5t+b}6s3-u5HN>A30(a_Y6F;4$VtsSV}w|!iVneHc* zp;v{0sJ#IIUduZeKWI#&q?G@c^_D-uBd7pmc#vjg+dJ|x{<zjOUx^e-IO+KA08bQL zQ5XyO_{o!9)<3SHH~jKcEO05NU&8;D4+<Bt^VXiU0NLk^ZxGJ_WCyfL6cnIF4)AgX z08#+3Z3qbUvOV^@@&!4l(BjOtIv^~)iUzChK@7n2I&9$=yFYsJF@0prE1$;Fh_eZL zX1mL%Katl509_*k+S@!YvOi1{Jrwy1lp=a`&|zMH*n$8MXliIh=F_WLKTah+u!}i( z5hglz<ViowE8$9N*TJJmP+{#DO9qh*d|OjN5CCX+FPA>nN88K9J=IwYI=I*3>{{ty zp~LC}QCk4O0@T$H@aE;!;1ep&EE1p)yyeY6NYE=ZZ08^#qg=^_B87FXP{(6+N!1V# z{SptLMzE}i58M2y2lJ>%7?aY7-d5HL)BtE>dnfA34yYys+i#pib7|bx2^%vnK##ET zB`X7_%nxGJMhUBh&F=03bN}|+%f!d{@u&^c(=jSa-8xAm6&5z<K5t~J6J^^z8T9Qp zH5CL~7t1t3{YbfV{6p7L`j90f5VuHMLn8<5Tu<9AEU?Zzz?(m%F{Rg5o(TZ0mUi1= zF7>yB0CNJ_bt}6lavT5a000N@@$=(f)sPdV6Udg>F03-&Cf(C-Cr(A#KB^%Ri!NuX z{Vj?jP;n4NqyKT|;E<_aY75nF^gr_gf`nf~_Q1&eh>}v@#`3g%XTLpC8j#z;Jh9_r zj!xPR0uUpmqjSXf5m!#3ObR8<1c0Mj>H$mIpIB2Uk=jx1l7s-85kAI0ePY?71qcKH zy9rfK(7*YB7jNpy1Ee9pF>CIT_ebxo`~v%*x3UTVs?1fMp{4B5#t7Ie0WRvOiaa9% zpgW>admfn@YJYcqT_n-uZWUPCK1SixfCYfDh@hTn@J`Uf^U3+S76s~x2W;jAC>`hv zNGuSW72VmDi`qrOZ|Bxsf2#FhIsukphO((1a-6E|@R0wNo%rNLx`!6PNGus35a?Jg z%W&U(z+)2N?=7z`PxrDCy{AdxOo;jM2+H|ip8^3$K#Ms-Pc1EoV?bg6U>4v_T^1mA zqfvP}EKoB3zQt!7tIs*QmsL1BYhB<IK!mw~$^&=`_~i3CD8MlQ;7uiE)aYvopcplp z-7Wi?(jRB@KQ^+!nt(dl{LWg#G`gjxlaqiYf`T9zR{*d@LkuIFX)<tEFW<z1u!ao3 zJt-Q*58m+?1-JWUXIcb0nz84{;2Dh*W*=HWSW$(tuw$eK;mQYmS4%4BluUpCfX)l~ zeyAX#>sUoWr1cc_KNT@BYH-^#7x1z^3-E^GlDd(>c9=`=TVci-Jdk77LjRhf2qe_! zvndu*E5ZXjc~uJqAOv82k)+X|%?p&uq7O#S(uuTQ7PGs<hOYugiIxVntPl)9uLbVx zjL|;giNKhz3<{nza7AAscu^T?au@L1ivS;xSPkF=a}db&M;tBupObWeLC{^uFK@(C z-)7RE?Zk$IQMXZKzAfNc9VFnpOGp4=zfb%7OaSrTGIAR8!=F<YA}iz&uJI5)I9$|g z0muY86x=*g1Srps7r+$=1u_Xa*ID!OC(T{HE1R39u}fQ6|En4(z?KTZ`=Jbg-ukk$ zGrG~B#;ec9s5BVk=l%T8)fMSrKPL<$kKsROI}gs!dFuS}Sil&mN8Ct(PaB9aa^%8a z^TRwg5<c{te!`AC51ACB)H%}*wcg01qyPa^3<ZQ^I&I6V#6A^p{I5DvLF$3Oc)An> zF#dRcSbriG$d+E5qW>1ReI3}MMFGIOfck0yE0;3`jXaOWe=Ac%jsT#4cE)Y&y_$Tt z@-+ptERX<D!#Mc&ktjf(C2=3EO9AK7pRNC@6L|h(jcc|mU+yyvUyb<c=KL`rK>s{< zZlS=W8=zA($j^&5C~^b?YAh2akomAEl5<YS!h~skERx9wNbtX{J8VGU1XFNG;gOXl z&3H_lmObNrvwyAw03RQp{_bK~lp6hv?=(NXrXl_*p`m)h2?Q=sx)H!~xvUnNS^xm@ z05w_w#=2G`5&y^L>%|O6&gKyS6WBfG=H=z4F66U7KYsG0hBUyxj-P+5S;fTdtonH# zOi(4$d^8P=fr^^Bw&99`5sLv3jsI>S_kYgd2Lg!Z1&kg8BP|_>ilxRYju-&|fZRYG zz=Jpfism08cfl!2SH;;wK`;{trTBw`4<6l2`m9QEkacIHGW0Cq+u!`)z2)m4U!LMz zmGw;}E>t4;8cmnjdzUwdjCnLKTHw?&#xwDNT(B<&)s+WG^AN0snPhl*dD#qE<9FN4 z|Jnu&kGI0g_OsKW0zeH^=<m-}2n=ceng=7r^wRxUhY{LG!;c@U1C&ATC;EBI@L1j= z;0-|nz_>xk5NKXN<K{8nYMV&dUs*SiiH{5X1zH9I$VeFAfH^QENbP(Ap@CaB0gDne zIBPUmQ!MC?8;Jse&wljm{jvYc!yiKe!fToTr^fMH1plf98y<SC<}j6S;2cMA?W=)3 zivs>sUso`Rplj%+I=u4y^q86)3;nmY^SxHftU`_ejPR^#17X_)0iXTq{r?KzS|ynG z(KiAF4HMTf-QR4%WB&3ZnS(%19dJMd<*YeH9tR^nk9WqSw%!QRU@hrGngY%ZIOrV^ zY3z$VzMe?wh|zq02_JJbmBH6M!?8Bb(LX14n-dVjO^gtL5cGn6d&)Y(PmaHNZ}Ri{ z+aE&$LXv@=0xlO9r|2I**p<6z?yYS@!N+-T;5k5zd4Sbbru9KiN$p_e*|a)4Q=t?K z7#AQA01Q?Q(pHI4fMyL$*k=I_Ix!XiF#^yv7@*z2)XC{N8p1Q6J+U?jAl~9}(3b_^ zp`DYHldPO-UVyH5#2_^<Tw1n-&{)RbLtso2!NWl_OU%jmC8lpG*FVt>Ap^DF7$S5} zHw}1=h*dCox7gp_Q~i1!{_~H2vKP`8RLaozo-VNfp`yJdZU86H0t*`cq=z{X3s9M$ z=6--zFGsdQP{r@5{W5LwETj^!jRmmMz%CSxXz(X%{gV)CdH`J1;0MV9T#^Q)1T^0X zcJTk`dq;*{*4<pd#2bJcC>+JX2FCv}cNGF~WaDWP0#ky*LboI%e2CVMQ1_7J1{C1> zHTK0F6&~7&xf~o1Vv05y@$oUGsKB{BI7T>CRMJlVL*2Rkv{FT3Jn<5ZiTYwpdZIkE zNE(Pt;z6y|%mYw`kS51Vkyw+`m?&v&ASrDGgET%_sDwb##)#%<;x*p=1O0t#br`@) zk=6%SXJ+qNGlj$XzP;AkYwy{U!v~Z;9uj`!r=wLRgX{CV>&1!nfIi>E?ljK8@mI*# z1bih36$TIpX6zNj<^o383&>8Yr|*&7;zp2LuQDM74nR#LAoFE`;W~Fj0{%vTg%NZD z_ALY;^Y>0loj}=Tt@Wn=Z8dI?q~)*44Qy);__KA^gjh>0-AD=RHQ^0a9#_Zxwb@kJ zY(ie&QHmJEg(M7MoRGuq_wgsUZ_}_r*BZIpzqM|3@Wrfv_dei`)Gi{5M;9s978e1M zOGCnsEFalu0N_@FMLk{-WU}5Jkn68E8jAg!>K|%Gn%Mvz4$F>qEZ{U#VNMFuP%OV6 zXb_00kL~~_ZTQpDJ`-B#C+#O}eF7YhU`&)bc4_qic-?;<H1&UOg>axj^WP2upak>2 zZ@wSCHv2eDdkw0r8Tb$(bz^B|niVN$XP;ZihXe*_`BuKaOf(guf2gA#p4sx-Wia=S zCK@74{Wj>Ld&+zO9^scLy<}d%!a}V=%?}T!Z}PH~<x=j&q2NcJFO9FJNdz>N`^&(B zijM`*=0V$}-T?FlC%fpC6NCWt14lU@ptjp=VgOk88BiB<LcO@Gk>E*c>kRpkA250S z$!gWnH?cg>r^6HABj$p@0MdX2fziwV6ac6IN-VI#eF%V&e-=Og8gOwz2EZkSop>&n zV_vWbA@bO_IvsTzi~>#o;09Y7_-&9!z*)-*oA_uF!u>8<ds4S6zfdOngmR>Z^a~Pm zZxICSKlbx*@bfzS()cn2U?G)VL=%6(BC}y<pxxA{U_<azAwsCjFYsVUOn{MCfIN?f zV*xC>uTJCyI`~f_416gj)W4A%z@4S-)}s)RL@>R;?}jJ94ZRnHRV9c3F#kZUwr%GB z8BBW~9hjEEc<!~E<nkG+Gj43BgoV%!m)24@o_pExPlYLc>xQ*-i};o2A&}SGg6Qh` zYysju1h9RLaakI=gYQE#E_fmloer97fN-C&P7Fv91&%?0<!^_Be=Dh(&_#bpybjtN zY52wh_IV=(EXbm3NL!z8pvdeg4^SK7a{;@%L4XJH5MVMWR;y2rts}w2GW~)nbqv^< z7rGuy2I7HxfSJ|((g+fPujE7kUQ0KYNTpWF2I>lkA_lM5@+ialYnGXZ4X!~#0g}Q7 zB*q?@U0Mr6siXr-kpMS9GX`;lChpk*kLjgck@Vj>Pml=>=nOzOx{~0I^@l^$-5srY zhB*~NfY%8E_P-wr{;jPN24JelNE^*ut$Vjl3(u&6LhzFj!~|qBjK!md29_+y?uGeL z_5zM`%?i^JEeHhUNj<MP8JH}h0DRDAb|C1J8sZcNNM);Ne?R>5G0&GY7RbVIcmQSj z1+D;$A^{G9l+l5@UKa6I0^m}4zb$eBIR4jOPC$jwHTstPHMhyk^9^)@(O3W@mYe}f zH{1Yol-yvpLF6FCXl6k_M4vn-P*DM?ln@}d2myW^3VvS^KV6)F005ow&|fYeV?fPL z?KqK6SCk!Yhyb{NJ?jOGZZxnqAFONG$qA5S<fq7ZknkoNoC0r!27x7o15!m*jSFzl zSYUGaY}jx6J|FmzZG#$&@=F5Oai{Jg>&xt**;()>Fw95J-~B*{U1kr%Fu{o_JyBR* zd!GmbJ8msqoyxLmp8w$lr9m4-o!m#iPx!CN3Wyi*hl5j5YmP&J#Lb*01$=jH-|z5` zuU6BF0W0;U4FOyCPv##-AZt$rbx<TeuVfo2unZaS-y3-*kO$M$3jkD>c}#1nPdZpf z>Wfu#4C!VceN7uO^sDI^TRQQ#;qyR8;IB7L3eK_(0H}sFRtpx$v|<#1K?pEAz2ab@ zSLrkm^lXU)JN51DFlD%@tFQ#46xE~g4rN)XA00RouRQ2v%Y(ZO0lB}|WfepP`W4Pc z84F&p!P?0X;H&Gwe`_lV{NO(`lV;MNhS{5H_z<8jJHW|2XNJFq1Q`>QXRZ(-C>v<c zhK+J8;Ivk&@g!amHWKkqE><n>%UK`bd7?AU7ArPY467glNL8I06#>3wB;c{vc|orH zw~zCY-&Ipw0vth;C*z~?nYr27n=3SCYxlHUsl^r~l=X)J7>AIv5G~)zmnrgCl^cnh z2^zSZKEQk54;CpM;2}l|@X=VZN9-ahbR#4px?kZ3qOvH1;ed5=fgfMj_`h4yB={Lk z26$5|DO!tf()PhVvs<xIKdmL6AsbwL!5C1T@IXPC;Zf%SScmOk2a;g{Fz$lC3K4i* zfhixH>4`m`9S~IH6{eQWEBLEa-WUM^_LrZ0B>m*gL?Q(OHoOxFD7jd<^7vRz==+&c zGQ!>^1pyMTJ?mkiOKd5meJ;fb8$Tuz>d+|`7~o$)bV!-s@rrjj;blldiYPFrZotRa zGyZ~qANY%!^cz%wosEWHsn`1+01Hq_7hlj50ux1q04;EbfN9v<!37M}3%KX93pn7{ zJ~@%I{ymTbFP}%`3!D(}VbLXx;1Q%+HVg3L@B}FBYjMiASPC@8T~K&)L*kHsE_}vM zVsT)!g}Jef5TSmF1Hu-vsNzDb2Z2yu_=Vct)jMgT>o8KPIP6S>(;Ff{>)#uHe7`w= zT7MDr-y{I206tNmpjXAbLA?=hJzcC!3V)v!#1&o2GAC@?yMevY5a8p(20cE<R#Jrp z^78B8Oa(K5PAwjLz-9vhRBSLfIf9{p(lV<8@It7Bqb=*~&92?Po%jE8Q1xpLLM*BC z7GPscBLV$;m!cbEBjN{-<@#ESH!j|3xgI$k#~x>3o<@Pj8R_~2C|o7PIR}5zegFQd zf`4oMxm?rX$GEFduFr_jm{_drDmh!^z_gGIYB>rBz#1`sH6P%f>l2_xHxO%NJ$%3g zc98a#5Ae|(AZpy8BimHu0)88w07rzJIhN{8Y;S|3p^_J*<pQ!PTI4rl!>$2f2aEC| z59Y>lVc%3o{^M`Ndk6~c<7VzCb9%{K$ZuS-IP?QIlnU%#0snLGZ}s7y>BFC^eBR8_ z;Kc#uc@XvgH20_8Bq<!w^n+$V7ae8)t}F&Xd7z8kz`KVdK(7%P0g7hd)!GedY9`dt zrzy2L1E?&oiU3c4IqZy(9~laI<aH)~huewR;wQkM4FOhAg|`dsO_Z@$pzvmY!5Pfu za$$s#1?+0ijxg0rfdxfWM!(a$`xi;!S1w7Izyk1eK<5f;-^Ios{2hLE{T7*MX@=jS zCCf*Qhct-;V1;r(6K`YrH8RM?-mrOMo(Mi*N*Dy_jfwy}it&9;h(!Tu!Oms}bO5hH zm1Ro;y{$NL9|COYrK-RGHlzh$3d*xL!%laFw?dedyG+BGOMF;phly0;MjI+bUSZQA zbM)7uR%sf#f9L&zC3k#_F<g=!a)=+Xp6-F}Mj0W0mVY$GpBcb_@bZ3dFuUW>kG|jd zs*JzKehxpP5Ws^#C4n&i(t`Cw8s`r?sI##*8fO3J7mx#ABx)oCAPCIoL;w#19B3ft z7_SNDbcojlktJAl0!Y62{>5Pkz|b=UXm{JP`244b-9ooa8n#<F>1rXE!bxE>bguvv zs5%22(Q}cU^r2PU*|X<4kBtDkbe`YwgW+#+M<g-kF-I=?A1A=`S0KQb=Q@7xzB^tO z`~d>$f*nk$sDXq12CbcnCV#7f2UyQ&YM^)hEKk5l(2gdA(F+_Q0Y2{ZG67<*rm(QX za=o(jh}FE}yKB@BG#Aj9rC+{%_1Xkjd}NH50Cr$NKGDbdq=1~9P<Yuz?Ovf(jxZ)x z`wMp;8+dQfV5>ufe!uR?U9M3zMcfPU5_+t0_-hjozPF)ifyY;P3;Gf8zYF~PtE;Qy zGet)qyf<X=K|3?eSP!7fx`T8!1KKDvWPF;`vsqoq=&Gu`H`LlcG2m!o00axrtI@%y zCm<04(vetH5LGV<gF*HZ6`25+6T*ROE|yl$z0QJg&vbia@`wf7H1v~p`{aZ|Wx=ZD zxp(FgT)L4s7t*VU47Z`_S6sYT2f($nCQr?hd0s*Wsy<9)UqXA<^dln?D_lah=?q!& zD-hs|{iM16BeVU*^wb3C>){TN&SKC7dW11288)<toeTd+boq%rEWnQ8&$RFnS%AA9 z`mERK9aPpu0XG6gMFSkv0rCAYm5XeYTtY+v4F_-CDm@l+;Nu^EyT*$XAOMTwY=^aO zx2w5&-2#H&M@|rdZy&Ce(eiNTnUhy;&fs<2QAIm}vLKFu^}2QQUDMx9@AU|AZl>^i zRgEl;O8if_Z3IYPVR4j#8UJy?kK?b*S7>6D?806~i0%;4X*Ym(<~iqtv-kG0hV<Sv zDwK%btMG3D{6zp<z^|jR0QW+G!&)uh6afMV@T3kfVWOx5B1TX{VHc!-fn(7|gCO{= z<Pon`jpWnsU;3A00s9O!P3LPiSsQ%+Mqq)7d4)}I@YX8$U9bkVo;P%^pr+!;_qs+7 zyT+#bHjOsuxadYe1ChN=3VnqWl$7ys<hH&XnVImtdCi&_JR9b{q~Is%2mEy61iCfi z_k{1ld++V+Q3AKhg`K`+sR8uD-W~@j1iQq{KlsZ69FHUhxK9N5w0GF4)iMDD4FV1L zsE-2D4maYy0hRM1K*6;aiZ&<g-L0)#w{9i(A33AI(pTU9yJzGfK!&$rf<U($F`yM6 zW06PbtGiLW)@!vp0#NX@KWeqRLfzG%D0QdRDzs%II&>j)QTG+NPhaVr>Y|x}`0MD+ zAW%dBglQap$->@zkX{}*8u(~V_)isS{EXuQEdcUCtcc}+%_}OrbiD1>Gs)M4K0*j^ zdWiscT$cb?fL?DQn5-WhK!OS+nB*ga5Q~(Y$0srt3Jj{_yj9mYP<sAcIPl%oUBQdh zYEa3N+~g5X@V}b0T5VZlP%C`Y`lw)_fnclkQOm=+LJQa(*K!NB2vY!dK#cE;FLGn7 zR=wM5Z@M2aqQDfW;ou7cmedJ~GXv)Xy!7N#t21dDe*^S)3_xqa?0I(8*${_UrPciy z)oK^S;RpX;hqVA=KtzB;$jJ}S2F(f*Xv^iS;s+2{)g@<|MgFWDlZHxkaBPSpncT+} z#Nogd$BAAo&hY$WRzADa9f*AUi~{X;Hw4VhmdIcrg@UlREx5wXR-x5Hsd|T7sCHYj z9c8Hsc3*svsy6?6UiGeitgD?|-A#)cwNQHpi@A_(PE@}iJlTc7pVpr>%N;`)Rrti` zg0@4I(p9cT8L8MM$A<suzq0_yrQzVa&j@gg1z_v(8_6~ir79<>LtIuW)7d7~-3Fak zjaQSZTsUB1p<rrt_2{Ybqw%As#Do&AAPxt<y;3-kS*3H7>F{zW5IDn^Pkj6<k6;Le z<P1QKm4OKjSxXdMS+!>brd6LoO}$Ha;a}>|zR&LSi}r%?=<BRcFJg4XHb9TkNL)51 zlsi4-u(rT(&9{Ty8<T#U*&UDD4L!cgZZ$rx@>+a@wrKBv1B{Skut%)@4?%!?E)#&C z%O<JKTi2rzcSty&=3%5xp{CA?i`{W}T*E<C-ew9RIcsJJjvpO8_3l>b=$tFK{pA&0 zK@THYIpCLf!Y<DFBFJ(55((T206e7O(~5Q-y-FGFv7XJ&<0=yA*!;$4^2Qgb2^KDn zA{YccOh8clZSYEvRi5+H^qs-->v663H&@OVr;=a!I03+aunYLJ4`A>xCcszUoRc1Z z8+85kIJQ`vo__WXYL{4fdU||%xHI4UTycZ?1q1{~;=%q0F$V_c20lwqG#21EOG5Wr z=V9*`|6l`Lyy7*qarN>IF&W}(UcGc@Y=%^q^^c_s2FJ&T2e`{u26l1z(+&=QJ>@_4 zv%ipw%Hv-zUGd7_%U9os0QWH%I1B;qeki95g|7l^>0ieAG!RJM8qq<$SSCUHX(T9Y zu!v{mN=PzE9Qa8r$>$>m3=9Rn+PeS#2mgO^f3i3@%Xte){+*QK469zeyiZJh1@YVr zLU-(p0C)aN0^D<s01pG5ON5}6eFaqxu2j`kuDmGc3Gf4-Pf8vVemQW!#C})u|0Vis zD}%eZpZw$B_Q|!y(Mg_n0hjT=x&<JcGqhZy5F!fPQb_pqKu7t>{}BHqf9e&MN2>mZ ze;ao9fqSn`0OZdEfB{Z`QgVbWIBy3^PcOYRs2`{=`VSc4{^v@(4?Yb3K7ZyP)ScaH z`&1ameSg1D6cKfZ;ts*WqEe;i!mG_@LP2HDi!v+-y+~UoY61#vucvbqH+2`zqT<h2 zeE$Ree4nQ=TeY;#-S|z;OHPyDZ^`$2p7WfOljQpq#<@)Z3r_Cx)N648&;mIBRWCpS zSbZR1kp+0k*J^ty`@VpSZNX#9-N4`%iEwo_bm8B<i1YdF#mB4E1hC40=TGdo@YEI* zuX4d%0JmR40P_O@H%b6=HsGbjf64qsbDb<S17LUQaLL34aD_Gi%w?*uqJkD3PgI`g zN~0XVgvDmWeps;n{l_^2FeiY@2VB_#_+YREVE?G1t7{+yw*ikW^#ZT`|9k+QVYKSo zKp(qmR2JZ7@&Dfi09;odUj-@+y!7SLhVuW%zs~P?<ynufUm@$hXq^+l4XZkVb6(&L z_y5DWu^M~}`~$gVTJ1Z3o-+k3{nql1CQNhq|7P)%Gaqnm=>mRl{PWrQg?pD!fzA1> za<*Iq7i~@eU?l<ES_(i4xcR;~nukVrqg{pF`fj9WQ|i0*3Z42kWqN?H&90rc!wkts zwm6t8U=mngI%0aHfuMW-PtZWnYBxMx0-wG94|u#80GCdYvQ1*mx*+l*VqaNQei3ne z`_0w~oD;xx3t<Ad*bTVtj(g9zQ8ka>zCAl;$l2x}kok5(1`Is@?d*7>tc?br5;@p! zmK;xx+2<(lHfvG+nWf(H_i=9TKL_0KSab(?LFpBv94)py;TuAUgHJv+FmIss^Z>)Q zI)3^5Tf^~Sa7=Ppd|oC#6nxjb0Ipw60Jm1%fZJ~3;m~0|&J+83T`o+s1ePZ(o7&8h z$z-T$tGPoH75M=aDL1OLpRFDyhIBJe8*vB`_Tq&<mO23;AL@Bm$H78w=C`z#L9v$r zFL3w{4ky=AqN+eE8IOcY03Q<^%75YlU|zw-wSW0G#A`N>Z!$EYbBT!9bj_bmSSM^# z0F)`gL9_A_zp?0c;BVjF3w_=KtTGM+|MO0O3xN7MNbMCQ)4b4~{vs*3htZ<G7jaf( z@o;dI$5~cP*)WhdWZfSJ!pt<JsUqc>TQKdi8|_5B)A@C633l>0PdLzUc))bPiXb+e zlWMMzCnZS>Wm4@~<_=gYu;E3lzUhhoj}BKr^#fBz%mDDw;vd%j4QL8}I#LBmtg@WP ze8IpYj}_+O`j7zbxOrhGV0kyd+W-kb;ycQOSo6Xf!=p6OOf*74Ns*>$7I(WbP_j=@ zP8;1sV27a{K*o~RFzMz)qNr2vyuR%FN^5K11{A<?;Q8lU>2t3#HORvu3>}`5d5+8p zIf`Z#_~eAl9H|x0(B*k$Z7p#^sBr2rrJfota)0hvH!yr;>HYB=oYm@B<1BwUrh;UN z&GsSkn&VpvKv7jxma#g{PYMAp0QkSO05AbJ(*&Fz@?SKJ;xHbiL#8c`Y$iJEraoi4 znZ!XLu22><A&*1Yf9S^$jd5YJVUic&p$>0Vewixp+5@jWuppvx*tD5p`aA*{rB6TK zdhfx5=bnD>)x+nXe&?XI`QE|dd&<1`^n(XhbO;mArLBX*6KAM07py`l3nTUP<b?I) zxxtAh9XKdFEum6{iRX0;)F1d$2{W0TRL3%dmgeo4TK(GUi#da@TpJFvsZIAo>?DL? z%C>=`AIVl*{Nhlqf(e0!<AMO-f3<OdstKqBFp=ca*nCciR|7wG<awjWatiomhV5oE zY?Fw23vppDu+woIsI(FH``r+8Xx4xH@y?^`zpRPre~1Wc3cn+O&5aS&9|Ztq-h0nJ zXP2g<jZw>fd9MZ17V?l9*r}C1II{{^3Y#ok3P99-Y&j=xpd$rl<$0#1sa*)4tE+FZ zliIbF5|E4w=wr7e`af)s5+f#sf4}ycpTUYTXUVz#lw^e}*pEYjlsxl-6_HDcwWcG* zLdqUWQX-dzOTgLze1Lxv09eR>WdUwIFMx?IN*;quPb?L*^{nxh;^OU$#GV)Fw*d)R zhl;WWNAS^;teX`xj6)QU#~Ik(eZ2Gdqq{$t0brev%4O}?1t9*VfcGQ-_)U3o25b-# z!e|76FzNf59LPL)a;T>Q53m_2#FZdxRlj6k7qtPfPxdNCrnJfVMeGgyj|AzO72~Np zaAG1VYrm>J1SKQ55jMv0_U}5U>RguRefi~dGm#hVe~MylC`TzNK@lH`S7Jp!s(6^V zR(?bVu7G0~K<NYCy1D>_3j)9ZVE2W5oWZ)NkHP*EM6~&F7Dqxas##j=>sj#<K|<LI zwOY*X>>BntxS))!?Woq_6+mCDnGu|is%7mb8In|ZehBqiAPt^mQX25YDrv&fjChjK z1~DnYz(E!J6?HP%!f+%FB=%1^@p*$(AaO2+Ns*_mQy>KpPMCEzKtT<g*vk$mY1Amf zplkp<TAud>hxb~M<7}%BHO(7j60!;D*bJ{W6#-Ly?jS`cK&B&g6L3)g&i@htEbsx~ z9|7o3qS_lEeP63y9!5Tn>b0IgY>7v;8j>K#)D#{R3s2ZV?VkCE`++C~#)%jg`s&3O zF@UUdQMJ4g_6uHu4NL?U8bu-gH>{rIj>1GRN;NY-&k&7lf+(h1$U0EtOZFkp_-|=8 zwtJ^2N_EYVD@uqR=ED@pG=^pdB`_Z4zajl_WHKu9AreXvNvLy5eimZYBPEOTWp?ew zpE58liYew**hC3R5rwotN^Yu?w_=3Brh;@}&kS)!QouO@VA59?fG{tBk%WiKFVcyi z&Yll)>~F)bR)WWMVo)X;GK}CG+S~PdAlIf)PDQ`d;lY6)>>{xIJyOuGXL05Nc>X;X zKmu9$7@llSvXnq|B`FLrr<O^f(SX?jXt5mP>>+{=Pfn@*a3||eNDJ)*yD~IFf)Xs# z4F#I;%GM2``&O>n@P5j_1o@H>_64&$&WGbrsKZ0g2wDHmUtXRCiG{`a3)!__PBYg4 zAyfYvOs7!JHp$d`+yxt%k}ZPiA}eGIFalBl0ytY>098P$zX8Ci7J#E~GXW$?QNTa1 zhd%G^^LQW;Bb2+KUMD!J)N*^#e$<I<|A%XQ1Sdqhot}?m);oHU%*&koi-do`nuiyE z2=SOk7Aua8RbN1)Ao#*u(-<X)o&uHT1bbM)5yzA;Nxd}?sPYIv!Ppx(7|+mdaZ}H^ z#fkV2!MZDPo8i|?C5_N*>ePSaYC!pL;1VjE4}9Ti1{yZJ)tmSUtr1FdW?^x@3>^33 z&b1h1nSxdjx}@bcvM7{M8G)=K3V|8|^&Bu#-yYv}<D394<pcaSP<=yYRR3p!aV`X= z9j+^FhW6gBqXX$e9dt|+%G7yw&;-DdFWAq#S5&+;BVL8accm(_|F)LcX~c5IDo`!e z7{>i($kbj>`~3jbus>E)RicQY4|9Ngjw%VvYOgj`mUQKtge(gYnjXV9Cl}*r7yS^( za#1M>Lg8asW>dV!XJ8~OV5_s4XVd%XoPsZdAM_}uI^F;+K+?ZYbmR7uYDfFsjJDG~ zuP!NDAnPIqZGjm7OlrqNlp8=3FuDEK%lZHp1%L&h7Hvt0<<p>e_)U^#8#S!AJ3bwl z2mug$LpDI~ykPG@8=z~s9q|UF+P2VUv-9}l;(zgFs)TTDf2)DCON{uFz$P^}QEM<} zV1aFWrIOqvhcXR80?r{#pp#G4HH?l1ScWvtvD<}gy}a2r-{Ioi^hM5TKiC}GoD$BW ziCq}T%?2E24Tw67xFfM7lVh5tq*}aFRqQ!EFW8tD{qM)vSrOe0^?D5*_JSzyQbZw* zOg7bzvD*cT+h!uvTqKAwksJ8i<jx!E1}^CZEFTB>jXppFE9&&ac+|9Kz}F+ymu6TG zeG@<j<}3OE{OcXBA*^HdJG}Q=7qRyO+nmn}&tL#L@c+YVb>jCpvp3;8NZ}g5uP|<g zhFs-Bn3^*%`^7v&i{b>vB!Cip3#p}&JWeOW#xNN*-cMqXzYn2YOrCh5qIpSD#Aa#J z){&ugWS(V99ste(X!dD}>?*Zu*IxVYxTXe2d^fqqMO<%ZVqUC6b-Ny><jAW`zw}VZ zl)n&Rgl@B$&;*>h0N`<n0G5pe9x?EjXa1rnnfx}q!+o?K!Dk0jJ8=J$S$+>4_^(A2 zb?PDTyGDg186EG>mG?Tkk?g_ad*7{kLC&z^;@>eGZxu88MRn0l&?v;)dlX6G+>x*< zV8+D$OaLAaa}_1iJmonKAWuKxA#LkpZzh(G?3sLW%I3+y*f$lxJvqCl#cHO4?yY&a zxPbo|oN$0#5NCv1Eg(TM1Q@T?-69Z75usM!>u0>Hv*^|`#@MIU1XKc8&Oi7k3vioR z0KQ7;PxsL5uX_XFfa!XTh#`FmKvsa9wzfk=F;!pu10s`6yC1~=9?l?bNBCvs>+zjB zb<d}c#C>D+|Dna*cH<o@;Gn1+)yYL|>O<?mAKyGAPR6an0S^3TYcg;FDB5V82Srsb zPyMcz8v$^XxQo^X@Q?c`7vSu*tH5{LVP^D&rrH3q+6rve>rJ;#r~w6pcC%j#TeJb) zkR*Tk0P_MU`Colbm<wQ-Ab^s8D0NVSJ7(-917-H=byAC<dK+Iq*lvPiCXwv7J2m+4 zJXI%cH~vjk89XsgW-izJ#=k-=A6>9f62+T2i7UX#b6Rsobq6J6{}Dk7p~)DhZ{Py( z+ZDD})O(~-fQV%N9e59$G05V!As)*W!z!ZcE5PqoaY_MX-Qcxf5nDZ(1Z~VB?0+v( zuV7l_UnfHe;7kHo{cd12C5U~`3*dO5VIT=_d)*AVQQyX>!=(6^r?0BNN5X0jAao-S zTCcWYz1`eKIGBWpL!=V*1XK9mS$X;4iK1ac0Sw4&6%KVJ;&I9KSj-~;VBgSHnFnH{ zzib626RZH|r9t1}urbk4u0sd-fn@@cAz9nfy*EK|O7(w2-glvPE{gqTd58w;wfy(x z_ZmGMYCGs^u^Z@8f=XobYwiaC5)k#e(|9Tc$OK#z!0Ho1<}HAHfXyt#VD^Tnb_B?< zLbvMj9(3+`ua873s0AojTR|KmYJZbs&0y?u#GXDU@>Fl|hA!0VILaEEDbUyl&_GXw zW1f{C)`$OuglrCPW0g7gwwM4)`X}lO;M>q?I+~1fjRILCFKo_4;|VKixw1dpvoai* zU~soI*rYF~@l|Er^RO1+JDt{l$M^N99lVwsn*C<8$py9kAVl}~LZ)(e4ne>6q%<M{ z{74%>6JS%qRu(|Te>Eo%+&w|n{aSl}=IBI<)+GZv^=9%r0A4@X-P_&kuxjk5_X4%w z8vse>1@r&dlih7DA%~p4vh(loL;N--pw-~}2{Qr6`6`?y$bQp>z)CRsO7;Q7IS#S+ zhEvu0BedYvU8~jf#)coGZA+@0H8sNlQ>1*>3)E*@px}-E@Q*U-p$&Gf2CaIp-`w`j zAT;9!)*h+X_WE5RmLe#3D8(-b{eS_;?6w5&3jJ+f0AK|HRGk3h|Bkzl)y?VmOaA+2 z(j#jJ+~;F8kVpt}0v>;y4Q>eGF|r1n#hQHodcPmhvejq>qBG9%-`T{S!PeV&0lX{M z=_k-b8#y^3$z}Jk1Z15v4`LA7DjX`p3rOBSVnWT4?LA6164v+UtUsNB3u4lJnfFsh zT^$G@+cF{WIUig=4R(LWd0oNs%g-G%0b%C(ac?DpfqrntDWqbWOXwvk&{lI=a8F1r z)R_cOy(|1*JsNgv`CI@3I7>7g)qFtux<XV&)MF~Vk-ul`TLZ918A{Rk6}!0=pikIq zTUQ{e$z-%YzeJt*VQce!-2xI^0sdA+Bgrei+x}?`=#_hU0_5ja?7JV>qH~A<(%k4B znv(SW-3_ErzKw4dR}F&3l}q+DGJpasukI%<SlB+@xf*=+^Ru0v1OU09zgO$Ug=LL> zOF^0OGC~iD*yOz<1h8yc`0_`?WC5hHBIDekvhVMNbY8;?A9RFWLES%3$*7axL@?}U zyN3RryhYs}A_doWE`!rJwl67D$&r8r5J3DyF>V-p?h7QjO_hfK#0rc)>UxDk8xBn6 z*5m)Vc_+3E$%ZL{#Mv+5FGsQ4&OX{q+i(0ktPdEXU#^D#SH5`o*@x;<Ko>uNNX@X_ zM|H+y!3}{n2ws+jUccXOcBen$1YYvVpj*!i;Fi0O<@yvDH@NJ(0IVt4CfBE$%j#Dv z!8?Se6F?fmpR}FZYco|8#a{$Pd=OtFh!R8SfYZuo!#oH=`%Q}!Y>~c%SZN_(G7_mI zQcIFoX`zTB`k>YeUOrp2Uj9ITYwt5T)@yCY-I+6IX5uAT>+IXvXXc)+!GRU-V>M2} z|2A^fZ7uP<Y!Sd1puA+LMjMC&f?NNyQdo1>*%fxt3Ec7|{+1rYXZ4DCgxJODgxFzh znqT7arO;<mE<6s)O@QM+noPRiy;6_dU)|knCT$Ub&4SG&D?wXe$H6aAj~kV*&<6hT z)S`gft__SnAOuht$ZX081t8?_wF9mu8fin}E&*62cyvPg+Mq`Va3td=VmSCn^ZVQW zEZ=RWXaEWDK!8op!m-1IiNUXC(s9r^SwM?pRB=GqKf|k4$SBXa75snf|JNP)fI#j? zBt#L24s#=b1n(dF&(1apLV4_@wO<nfe)^G>A(`2L!;ldiCQp>$ZFH!-{}w&l7J8w? zU9+MP2%zT!T=xS1^YZ~9z|X`ybI$|%vtq~vnGR4o_@1eBiv$4w^c46dL;!{H#2Ena z?Kb6KE~nssOWALYmW%<wzs{S}LhY&kQjRJSh!Fs-j^juHa|F)RjnfLQByb;}nJ&l@ z555Nx_6~or{lL$LLeNRNzA+o{)oPK0m!3Y}YxWpNd^h*=T0`Q1p=<lYk{}B)D-b6I zXuEu<57{FDt~mk!`3WJ?0GbOL_>&*OU(X6R0^kog+6MkgQ2$~;BZC=&UY~NY7$B4j z{a`lkR@*DzQ&IL7@DGG{pC$?yI*S~D>u$Qh7VQ8OU;>~cUw;Mz-r4Y4o+{@zjlkP6 zp6K35PTfVopAF>Q2%rKu*M_TUU#*7iV)gywC!3jKrxa0(xy1+s0`NQbx`Qf9q}Id5 za}vV+a}og%;AbZQ%lrQGBVyt+f*zIzn5~(A^E7yR+27M@IK!r2lU}9iX(;>%AHz`7 zN@PV^7kt6n|2A)IGR`NkQCk1n!)ga0Epf~}fWsk(-W|l4uWiWDN2CDW5d-EE?!gF? z3iIgqBh#^}VOa#x3gh2}!4LX&WDbZUe#e!4wHmgMempuR3NRnQ7+`gGSy#jt<`5t$ z&O-vgHu(yWAn9VHV7e3F0oMR`B><1T^cfF-D!eNK?P{`s{Nk|dP4iUuB|#7PS?j*x zf9s#-YLj<V3UlK?lyuEd4sPIDWeDOp_M3XIj#+?ETDY}=MX@_E<}-;WsuV&<wom3h z`UQ62K}ZDXzz>9PTMq+%S=|)@G9!R67rx0d0Mkc2`UzQ}QSb|m86{LaS1!0BKuiSO z<}q;);Ia44rX7m{Hw9)y)H+mkH7eAx0xRYT;PCe}GZ@0awxh2sLOHnFxubl8QwjEI zz}@yjQ$ke@0IfxYLeJ?S@jllPYyfrTCTGuR64|ct@b!~8{GB?Q1X)llCjsQ?ctiwP zw=>j$cUtr9otos=)xBdqM!JN1KFm4#x1}}FHTMnV77pwZo!1M}fzkkHfdDZKxZR^- zod9D9ARoX{cTABIh%+$vQQrtQVAw8k5W<L85lCq~&~$L;mz_JytgYW*<QgErBb}e7 z%<O?MeXr(qAZY`jUhY3<#Pe!}nU@!zam`4vR!s(6#-I@ReZ+anc{)9(3-loY<l6r& zaucC$@BU7ZSMGE`K79NL0=NQjPtRahUz;>R#Q^$onh-<LOZpS@0d7fvm<EU@U^<ot z2yr0Tf`5f>H_^~v@$lcIk+q88|A{c9f)PDl5*Y{lU%A7!b7cuq1BHX<eB{2R-MNkN zah%CfE3u;!0GDlJw*D6BWKzoOvp4eaDsG2gf+BG3A4Wfo;m^5^cg>B;B;p0y!pM9H zJ_!GB>OkMWA{Jl|3sCAmZ)iKjz}+qn`%VBZYNwAJ_U&p)6o3MV1i0Jd;++5=oaJ8+ zQt4T6v<SfQ*XFUE@R#B@OVCj1S0ynDD98ZM_jl@$?=`)+U;v`J;QoZ4!aaXB36{Xl zV<exeU}&ZyE{3kwsl2td1p)M0UKB!=6Ih!KQa&6<zk~%_=Y{>`c!M@0osKm3*TI{} zF#_B;+o?^yT760ufUIr^aDA{NWkwl*!1k71sB_;>kpW4n{PNPmz#85c@bDv#K>$?* z+PK#9Voe3G(eXGiicXy*kU%?9gkC$@sLMot+SZ~&_l>;hS0ivzjdb=kj|J7wgIMnb z+o<)GByl^lXH+IMeoONTCtIrapSc21c7Z&ykGmGTTtL=?q?IOs0UG$s0MFLmWGT|b zXo7aDNw&Xu_sFvVg;@ZB-1h{K2;ii&%N*^p^P!p;^e6xV)bYlUN6-M6fb%|@wp4o0 zz^5madzgJC0HQ!!2oS79q7Q<-+koNKPEB$!#|lW&&7z-2G4xUBMEtJ)V@lVFAowL) zZ!LAUBxh&yb-i|Pi|aWU&!qlM@4Dr6p?|34fyGz0(p?l-e{K$K5PP9g_hP3uxmZ0t zRt!)U5Wq9RH0A^*$+7}}i4lPIu(Y9XB=BmXfjNOSm;ms10_3(5C<JvSNgnUsdu^rR znE*0?r-HwsEHIyOu?~AduN=;yc1?d*-OcEmOCr?BIOgwSR6q6LAD|_wEO9DymL_W| z8P&y!eQrd!AI20rVjO^IGgJO{nA*n$K066u9Dw@1-OeW@0YVz^@G#gp8gPaHB{0)7 z@J;<MXGPz{149o3^FR9l58j0UX@a3O%#);Ba&Ru}HXF^?PMbdV<^Lz82mhw@OFOB? z|L_gCUDGeL^Mm<;wvq9Va69DjEZ(vAZN;ME_%fb3=6`Peeo9_gXl_hH{dKI#q|_20 z0qC_^{J;URL!PdGS|9$~Z?E1X3DA%Ns6yRpeB(*AT@@ha6mlsk{C~8n45;z|pVmcy z4a%bBk5~|xBs7RygG?jd27fkeSHV6X(ru2Vv;lnxz!dS@+co_{$T!_Z9$?amP>&Zu zA2Rd4pDNB1fG+L{n6NhFB<*NKw+0(IZEG-_4q6rTG@;sJ3Q;<){;vzB<Ku(v+VJ20 zVRi55$>vI8b}q*LLbu465p3b|2ljI@K`8`V6><i6fwdCgQ~3ZzuS5k{{?A0i8)2BM zFlcB!_YDEOP^;x5iFlxYXqadYc)J$yU+FV{Yh6mql94!<zs4~R{_97;^C_T{pakCW z_jBbVseoq`;dMq9+Ra-5e4lAE>9BlgDvAFNBLkHrXTNOMD5Qaz2k0^8K-4L4NOK6h zrK8PN2ix+4N#c0{r-c!qGrg?M1U&X03?H*VNxA(@P?y3v36&x2hO&#!N<aE-CrNt< z{>|054Zb^XE+2ayNI~GH1$;4+k0I~)NtMm_<H^jTJ+SjPEH13TQs)f&FzyrRQ++>1 z8vr=ZItocvEefI;@Mx@%K;$_!v@WbDy3+U3UdQ(0>aJUWu3=w|f5W_dqL%=CyvmhC zHh?qd3N#3DU~L4*`&N?J%k(bLhGXl%27OR2u9QJ3l!_O^=ubGYw}`&K`qg%gvcKUP zQt6#*fj}7SY6JLMFlt3#Q}^T8_=~c>v@s*mJ5|Uv&K2oFfGC4SI}Mz9!5`712K(5# z*sfE)k7;0&0QaG(_@YgZD=x4z@lc^3;y@>W5<&G5fZwINT$YydBhTlcCpI&f1pJ8$ z5+T3LnWu>$ffRruLfuHR=JDR@>Z{u|$}hRS!E_{u-4SHdU%=fDnmI(qI!AlM0)gky z1wUY#j?V@VASaVFJ?oh2Us{a(!BRzm(IntMjqMEI@`vqOMQPyYn>}pkp{ag0iRJo) zZv}m7AwuCLAz{XV#+QanH)<rnpkH8nvYtEpyIlb;*tsbDOKODaxEJ7nbEcLq!o4KZ zb08i^1=Py`TXL3$_)nWW06z_SU=UI!d3c77$8bU3aTAa;>@o4wJ?V6OedHs3b=gN9 z2oS~J-TG|Z_)`n^)Sg)Y2q3hDusWXZ4f_AO9sr+0Iw18p5CUA*Nr3Zy@j7ETvrw<m z%!~n0p!BQ|&wQ}rufk#kU4suU9td)-C&5SsyvR2^xZ_{!T#dVC1frWSv9l9b1e!Bi zC;+{OxANO7_+KD3ux2BDEMlAx0O+h5^Tq@9tpfPj$Q#!Hz~A|P`^MiX$UlGPC(^*g z0F?!h7U&nA3#J9-3VK>21h=0^o+v_DXb1zZ&jmbmCjwlav-FwK-UEHY{$_L7b%eVP zGV=i${UmD)Wf@Axz0j?KPKgXN5#Z?E)t~h3?<A1{Y*#rdfGMD`0=)A1qd*GE8C4(r zj5z^%4%D9_Ie*jXxLS5<p!*iOPJodo{+LLPl6QXf|DBu2i@$#L>&3;@tN-}vgGCxR z40LTl`qfdL)Q@V+4b;h@Rfj@==mf@sfSVEk`2zuz1x^yF@kYaveMu6)cW+>~(a5;j z+;vibzmDp-UQia`wE5&yM^XU?HHb4n$6q$Osn=^Fv@t8_T49Rnr<lvezgz(JOUytO zz;Br=r{z?G{@8hu^AmdDH}b>Mz`OuhG7Ao1bONyd2RD{qUkWeJ{^Hv&fBOE1i>nv+ z|Kd~Bf<b^rQdSz^Fb!d#S|kmPut#W$48_aHM-wdD>Y#H>04m_q+Y;cxzaYRe_#-Qg zQyGH9&<&P9Yho8L4p}!U1w-Ba0&E5KOQr!{Mg<7BJN~(N=hdy$Rs@dS4;1pz4Oo=> zvg}8FOXIu#kHQLXNq-XVn))B98T8EtfWHW^G;#a`{9aCeVgDmH+J0UAlZXi@h5IOl zO0K?88u<Ab12EHjXhS=kMFK3G!34=*0ILO;my;)wz6d}CbbT5iZK1`@2?S~<K(a^* zW({J4UY1b!vGN)g-%WsStA^ZlMMAbv?+18_H-#S5EBl{XDQGqS8|(Wk^gR)vzFa`x z4S06WY^^z<&$(!`LG%G%&61L@9HaoWu`X>30vLm6PfoV(AKX~(ul~KjgpZ5~_t6rb z2BsdosN%oE!h3UOU7$oIMK^650eWNzGxnlY9LBkTdNjbGRmca___sKqkyt3`VL;Ms zHdYc#|L#JKd-Pl!`$Ss;0Z;)?Nd<g)P`7-Nj;nQH2DbYHGX9-u$JY){Z6<)>{Z}er zCI>*5+(ZPlCE*z5&6$sXC&0)5fy{4zA)tT!arIwi@2TS^iS<(G`l5ge^w?ILW&+wQ z8676eRDu<W8HICXoY&|BDA?*60l;5PJGpmnsCgj~pbG;iS5+m*X_KlDu9Thwj1Gb7 z*?Z0R>sJ9TUv(M4)v$MM5Xw1NBcvL67J1Cj1fB%a9#I6*XGUp$W*2j*2QZ(Q5kLb> zrk(W=4p8|!;wgE?6wm*DisHVpd<puedfCq2`@6eOKmPYj`0?c<rGeXkAH|`kp>-h^ z2o``L&$8iVsR)7vxq<Ql^2_=(z}eT71EehOSYh;^Hk;IbsYD$DgqmMQKGJA<jF5%# zU+P}v6C}8S<^?=06|i6P-vy5^8i2Wxz>prN)ug_bHMS<RscJss`2T%7p`4qpME+r_ zfN-Lu;L<3Uf-p}|^8|A%2<=!PI9>bZ;O1XM4#1DV@1hs%9zC@O6`p?gPfU3KWwJmR z)MBCN{a`5{^$V`hL?QCSN4Kbu4>$wR0H4>T0UrJN@-m+cx~~amHY9WFuT;RW_ga#1 z2}eL70&9dkJBV~~{(?IIVU!BuHAqMGs{nAgdV~7p!NLcar;Gf#Hwpu$3sEXRrgU<d z`}JH5u=BzAjBY*|G2qwvWM?#z3J~tNi=AiE2??N+*$+bY#{YjH8}L6mqKRTUfoG|` z`#4OHmU#K-SZQFwCkWt33)t(*z(^29?q9KR5HJGc@#UWhaQo@tscNo@*CZO~?+@Fo zN&wR~Z96+<<Xd5oyu-3h%D|?KfV_uM=p|MSp0u$6$H%CEd#fMq{}1vBRmas+0)oTr z@QVj)0E$c()A<4G+1lD$sCc$?X)U)zKi-0TL7U{?d~S1H6N4itpcsMf<c$reFg^L; z{yzBMSa1MN1wI=>PhCH#6Z(4^ArJryKo-zdK()s-fH)y`2zQzgEV62_y5A2zKwVLQ z2=Fy)Lw}?0{95Cv!Z7|Fyj@{7vc@F?W{w;-;!RkvT?MsX<z_ue5DAPsr4We$i&gMO ztB5GtDr#D5qjpRDLq4Ft=Y7vQMnz3JB6)Y_%$YOOG}-4l@82`KO_T;;k5jb2;E(Le z0%%1L4Ogc#m9ZfLLTKpmA^IW`*2b-^tB+ij7oaz<>+R*ESC{S4P+z;5r+!{GYngz& zlqYXW<UakXD|h_-75l7MF1WDxgW}*@uU&Zk`V-gQdW$8*Pr(hIkGb}t<rWSN)_?uW z{k*pJuCTw##w0*8<R*UJjx14j^Q9mH-~4}9{0jnTw?9%ULc)PmkavAS0BpW>xg!mL z3Gijm({cvlJ=u8SPj;93V52C&fhIbb$r#WHI!Jn=0s9PUKmh%z8*AUa{9njVpX}}F znNh0|(`a`BynY|}uM1apOW-3s?6hLfb%DQFK&B7l&vn0x7!rygPg6oR!oUey&YrqF zKizM3glY%es{(&%G+N@|!oVZ>q#YUAV$cjHilEtb!0Dfi0yUWRgCzs2Yz|}s_#3*@ z06Z6Ppn!8qdbi9@J&k;UrsNQm8!$5<C$R_g?hp_dK!rZN_seNXzvtf+xVC0*VE1zT z%##PZd5s7SJw$Zy>acKCM+*V2zs`r(3;jiq&z*Fivg{tPbKCW6So$ZZAU}TXI-^=M zjEhK0>C5ryeyvOH0HE6uy<1nIfMjX3wY9XwNh|380qU}v;@caxt5qVz+gT7oqh=f& zdYU|3pk-}16W}fc=qd`}6EqH#2iS--7<1dE()a{|sQUo)PJn?rylj0aFUSzAd}OtR zGU5fCLIv#a)0|3v`g$^LzpW^X7=Ug7JNE;x+w5n`=kLB~3;rvz^xP$jA)P_ofJbl* zff2F+N-5ktEqnLB!vPTdBzQ)n6k~5>vb8iYGf7ukVF@xwIrLJA0+2Y?O;M(D5e2fj zE@-m?zE{P%2!Ox<)r0SMrvV<i%YT8(mqL&_FH4d@fXPHJIVLH4pZj<MqJg488=&Kf zgU}ERz?!r%y1IoIAQiCxH!oy7KmO+S?QiD1f2Vk%ZJ)`YF9_hP>FtRw!b20_cl=k` zU#ASP0s&V1u0^N_1ElkT-qw;bjP4iyhnxILr+OW`0|5Gi*c+6kbm4%FeLKaJG=T;X zV1S?xr~*(2@)@tDE=qkeSnK#_>=&y-eFT!=28tW#0EK~84C<~HFewpf^uY#H&}{CR z0bsG8a0YBZ_X$teb_R?9&><Ix(H|qU+&`*-7v^_vP&YC8`Bak)3T)n4&9ffKk5ao_ zS$TC&M&KY<_q~yL7@$v=z;<$n<~x9s>%|3BZs>`pq(4vq-{ZfYR=!*N5nmsD--{GX zo2n^$rZBMuqo8#b3=fErLqa!bhE4PA&-xynAr)ZreoE^o(>C4%e<cJ{qVJ&r1i0I6 zHE@C^iYaS%J(-Rbh$Mv7vCyE0(1;aw*(iWmawvK}V0Lka4KO3{<Jx@xFNKN!B^uMk z8L)p^`RV(~avK5S+GSbM+0)m--7t6P(E%$f7wj^gKgQwdC*|nj0@C0GJT6B7FMtq& z)Zcvn^s;$-ZA<1KY~wHm707ujQ((ioH`qoty^RD*VIX3ZHLhQ2fu5MqY^T(30GAUr z%hQw^R6Pg3M-;$Na6(7vASb}B%ingU0r-ilv+WQ9aK5ilz|#O1<qQV$zo5+(yO>LX zabUhd&>zH5fC0)L4n7{?2%-W$-N(YWo8*O~J2!5($hQnQg}!A&e)uXsIHvuiIQlCP zU@`l_-x#nW)4wNr=!+>J1F$3DFQ<_8C7&GaBd1gU+`f5xgWzsyGzgj_#Y9g@;u`lu z(M*7|sVCD3Th%M8Iu7(Er&RA2n$O_RExS!w7~<IxoTL;hS%50ky2ZLNO=Kmw%S`}2 z;73rPBOl=4%{{(NCk69a($LUHhBJ(T!apN`nf%yrQ957}(F+<5B0!m@{()jq)((&O z$F-vq6aR<fpFjO0@(*upysP7#{nN|*t7VtGwp+)R05k|qO9B)H+Trzut>C$#r(cB_ z)DQ>;<pu!%8Ra|h$HL<=CBPNl)NK1DovBUQNi3M=DU_2*<)62m&;>O}>jmuY=V|tv zTTm8L^8i+-#X1DAt1=|qgXm#Gs|P)G|KR?I-Dm(ldwNgBW()x9I-*q{XS_@RUSi6g z3??Ir66gdQ+-}15u!(~hjW%V10eAuLuiYN+yI}FZ`Qya@@!j{gJWcxW*%$x?Zmd2l z1<-ndh=IP-5&-v4v4AeMmIC3y-&_N_ashRK@(2F2%DoqbKLzuE0JCEJ3AH{zpD}-H z6nqK(Nme}s2%xoB&90z#m)~>0ocU==5CE&Z+7#O*;ENkoA_!2A%{2hc-CG}aqX8%d z9O&85lC<tjM*bqzN2WOf)|&e=07x=5FM_E2V+7!!bg{06DHWmETS5iM3%ETWZ!+<} z`_sg~__1frUEVz-1Mme7pV?_=zJNERckB#N1c1D>0NxuNT0W>Au=@1Z*#5K2cuOmM zLfq~b{eDVA6uzc*Y`~JWRsArTq)?U72tYVrltn1PTO#mHfFH5*8s|^Fx(M6!*q}qI zcB{rShfV;BLASb!0zRS^z_LK3QSmnp4SO2)ylMW+2q-|Pss{Z(i{iv=n4<Ay8ZBy= z#h^SGDnP3s{ygzFlng&9SqE&M<#qH`p8qsz{pbwHLN?H*J=+x>vaCGuBqY%3<vTyg zm3x5KO&NfM_UrXy8Is<PNnH-WY<HHDy8_H%Aa2q+mEEFW<RDO2Xob63d*_2e0q)H( z+kGjMYIT)v&E?h!?5-L}6>LWz5f!)b@3H<FcRGk%zH9_&Q2-U^E*pyf%Tf=DM6L~o zRuqH)cmaR1_)PpS+QP_-k9daM?>yc-qx^8^BdLM>DSEE{)i*}~fRzmt>}Y&3z*-$H z@c7V$E6-m0`e^fkWiA3x;6=~JNzn@lrC&5LBoK9g4MO$HVjXK<RLdE0LC)}$Q+x+A z1hkCnI^swE8UF@vF^T{?nE>}M|8lvbYT*5yX6Ime7(K@$@LTxR6W)qz?J|H5Bb}6b z(Uy|35%TyIgj|4t{rKd>fAI_C_w_NQ#o<89fHTcL$^7tU)&WieHw1D4uCS9JdUfRr z6kwMQFue~4@c%#f@@Tw?>_6aZb9vNLK6g@uq!_M9N%~)U-tlcJT)U`~rYI6yWk8#N zys@CR7I6aj_3R*`Gzb)Ebc>1spIbHXR#$m|j}9hE<pQE-0zuvzpidl|z%Zhg>v9ax z_x=^aUJ9}{@-vXZmU2Oaf<EydW#Sw5Z8^+y;v976gX#d+1NXjvbG3B=@CGKU`Wj68 z25bZdtgLWdU;E$;xbXHJe3Xvl5CY6fO?=hHH8U)}x7NU{Vod86_LKCR!~j_uF621S zXi(H(OW&17Rs-JF1=vdm?7HEwM9^Ib&}AmD0_zY!Itlg}qOw5DVd1uCHZwu0a%14y z!JPx?1<1qrl>8CNZ@|^!s0}Q>V}AmE>La7kRl!ew{3>G)&H!XQzxVa?QvIj^+Ud~p zzbXfr3An-wG5q(wIy`!1vqO2IhXyG6nEysGKS8l)c<OBBHHQiQ1*aB+13n^X{a}Wm zNIpQ<N6ie_q3SDJTtEP_fDk~%AP7J$;8sU@00>~ug#-e9kiE!moA3{GR1$IlZ%$#z zMUN3uFOQU=*EFz(STKfx&Fog*@q@fWtC!};a+}J*7L<SkV!-^tk@(^0&i5bfDG$VY zCBguC{hZL6T)6Pe+h5+BU)t<iF5?4Kq=6?>wyA?Csp$%J;UCHtUJY{a)<=u5p4~wP zTO%On00n^GP{4tm-RK_|V;Z0%AAm)nMu1qPZRv3b9~U5kzf}au@|B?<G|x$73<dMh z?<qx$vceY7#NhRV7=zpZmpuQy7A{%xByx-d3|I?9_db#tFn)m7W^OP2aCGnR##c9Q z+V{Rb@dn>C{=s{neRFv4c>V&{UB;chjv+up?p&r+X+PU*?H0%3`T=6X%X9pv8D*Vh zWl*P382&<@S~0hBJ1;qo#0?d_8l{}DHRPG9gZl~tFL#s&;C}|cLIu824|oArP4pTN zOo&06z%s-Y2Z7I4+4_(;Y>+ryEF3lFjFb(^*#92=rKONUl=zPy^&o*UKw%^BJQ(`+ z16mo6pSyJF(s+Dgtn-)tpCOt4ULX68(4Yl`ojdsKpj%c+%cd&b(kcOt*26S3ex9$k zrl1L_@Otr1nWEeQ2CK<aMu3id0N5tYZ4iPqvvUZFO8W^?7n|HBRxacYx{Ccs14Vdw z5%u9-qTGix0N8dFOa@=tKg2SMUHb8o-!ou7KCg0vzbga)uCo%5PF=4umX_YP3IXAP zP_;Rp{Q$2B&8pTcAoh>AMvLmV&xhcw(mPjF3Ilf!AV6n60RLZ870K#;vhY#hR&oMP z5Wqu1eU1P<ECCxUL3>RcDS0$Pt$QUrqDmwq)`&U!EQK&(P!Y3C3V9O!AG&wTqQNcl zLF3JH`kMEGa^WuM0Q9$O?g?Fa0U^rFGkF&<>j+&ICuL~dEVR)dn^C9emr@UsMwX<6 z0C<5)1l{VW79bN)DUF{L0K^%)qb(o5RRD}J7#SSuqJ&4sM<EU9g~1G6kV6Gq4`Xm| z`OIhIN+@Sg!^-C7JX*0ldg2HMK!9^Ad%d*4U&gu-mSp^Da|H_m#C4!8N)5L%Wp_mn z&JAh4_Odd7Vg!IE+beylbWJZc?gWwu>P`dfLVzNYy);Df4!p5d04Rr$1f9CWC`D1) zJ^*Ms`T%KNWRr{xbG*F~BDZhDDhRSPwz42pl^hE5G?sGE@c#UNpUG!^jSscbvu+UD zI)sMEKBTEZ*;jyQy@dx*FHrVmAoz#AUjlW%?5+VElA!nl&7|xXB$%B5Xn^i~0JKrX z?>KPmy$lf11fb*5AFozMp<3KW6U{o{3Rc|PimQCdMs!`VknLW-4*?opI^)*NfJdGi zpIdohI}|qi#RBDn%V^1=vO;Z#ZS;HA^Z-adgPc`<iEW5YJ8G?hfK=2`@UIg_&?&US ztoFwPod8{}2!a4boJ<{auxInb%<I8<m*Q40*n!I;f%JZ=n9$PhF27@e-G@{PUYrQS z7)X{C@`zCakw9SN1*Esexb5fih1^t%w5F0*lMGT!Eax4sFC<Bsv99nGGsLa3U++b8 z``VZ=UnoMovo0N=3ZfliP=VM8&|x+3F8DVTD5Rim^6TKJd2o+>?8e<Nh7=>~nh}Uv zH>#Us&KCD+TgD&>)b+yzcaRInok}pe5$MTVw8ir`#^+d$SuLR`z_dWKTMB>8*}xXd zP#Nqj?sae9mI>uBFZB{5Edg)^GBNsu|CNBp2av3@SBeJ@{K=5c)&#=2s$8B5rh?s) zK!1({=^5?@I~4H8#^wBp5Ge)?7z3OMeGdzf;O?UZeUCvK?jn42jy2J|MnwY0%%yW_ z1?<;ew)NiN&jttZ`%DX1@wZZnpf-PSU0%MVag@uxio@Qwwk{OrOG^BI?ylFxB{oSS z2&^m901%)%AE0KnK{M2JmfnvXO~P-`yBhddtyPFAbX$}d@d)_46WoY|hxh?PpG`++ zfcl|tKQg$5hzUP1`vtQmrZNR$!L3W<b7})jzE(w0;FpP}0k04Ouq7PA^^k-<nPSc1 zs`(A=CT;iQWOwQV-tu<DW#dLDyj0}SyBer>IBjqOJIw=3>Pl%$OYk!H@%`9^zd@Nz zfEoszBZ4mm8F@6H`SOgS;xq6LzHbt*CkJ;Qf)<o`UMY*MCA?<npHmJzH=YlIdjZCP zWodtwhN1^bkfab`2y?C9?=L(6^t%^{EN48eT`xeKX!(LNP3%%_=AR@|zi^vSm9@ga zTb<<rb_fDuIkoD(Nw)FcoDj`-cNHz58}uuK-(i%+$msVo=<M{pr-58IRv@VAv6PN> z)djvhuh9R>-MO?#QbbYsSGWo>qov0ZY8DYtlq<=d4}7$%0g<3<F$@$_wou@r(S;zb z!U&2YJ`hH22f_A1L;pa(b8c2=D?X;QK*!sYk&#)MHB6s#pK&v1FayujSz!%|FhEIe ztIppseL&iB!JrHCE@xnk@_-=ji0Whju0#M+nR{4)SzfPQL$c~;4P0Cp%lht4Ex;|s z0M&IF$wI;V?||=P8iN)5Z@h%pj?92EREaDBJ>s31QiBW=j?`GJSW<+msqz<A?mN7A z{=t@0`+&z$<W^Hv1|UiOnik>G)iiS&*z374r;ETYXr~~(ypsDpriy>f1>2vOiW}Qy z5QwvM;ehs?U0MKE1LXo*9SwjpxQ*@qZ4hXi@6G{42?GEog23B2H}{T2%8*7br0W|> zXeZ_rG6&sR@e9M#X15QXf3W4n+fDtFpvk{4)vk1@tzPLm76Df4f+qm*l*s~=DWJ$0 zfST1U4$R;>kYF`6+<C@w!K@=mF!CBq0xonCaPRdUt_Io#K!7A|G^8k{Nx*hhz^;iI zQ$j!X$&7JQDB+O#==w(!;whq&+-2clBQ>dP^uqHGx_q3(fF%Od;NA61%9Q=ayjMLf zGK7B#qpLV!hTiKAd;7I6Y50l4S(sDGV$p3Rv-#ekD|lxXAkx6ri0M8;uOkJdt~(hy z5b@t_?0jcX=Uy}n+kZQ9g-K<FzY5j?aBr#~$Axhmub<)2H`Vy`wkiQ%KL4Q0PkYs+ z0K{+>?X}SFtWR2A@{}<MP;;^aa4@iD0RMNW6lEfY`na1!VS^4`1H=(f5$u=icrbuQ z{vUQ614K*U9yuCuK4JN&!IR{X3?5POb}pY@`l-3HQTg0YZ%1{>gi{+Jt>I&a@%w z=PFSlWY%aABLp~jz<(ZVod^KfKyUQ10I6Lm{Sn0n13+47ViPaS7jF~+kV=1``$dNQ zFV=%r(IgZEc<k<S&BLKz?W_`L3xEPgyGA!dCygarjDWtFOY0r!NmQbq&g2bDm4G&V z6nDg_puntbEIxE#-mYh_GjlLhiHSP)76%W$d^z|4IeA8g6)s>f@3sNN@AmlaAhup3 zF7N_vtQ81<ra)3kXYqAS_QcZlcW;%lW-VZctAWcxPiP6{41o^|I50}WY|qf#9P2;! z6$<`qTon<4d&I6fe$Sj9IyjuJM3`AAGm-%lU}X!C_MYJv_^+$*Km0ktqdN@LB8L=v z>GmK_gb2bIAx6%s6C+r8>I4PpXYL*JMdW+e^H>68$d$HGkncL+DtLe$)&bT<PC2r> z5WxaqS7a`NB(3dosR`ig%I(40&!gfy98J8Nw!~;#ay62aH_It8LpVyT27P((Kaf}J z3?u`1!>Fa9@Cj0H?H~ps0#Gc@Vc;t>tgk`N!r!+(-G}xE`UHkOQ6-BCo&Ju`@9nZD za4pVKXA&A45iDai=&_Om#HlJEBVAyqO*hv0+-3eWVD5Io*=P=~dzV^?=y9QgGAuaJ zLHN_b|3FTY84x}oLO+CkVe4~o!<f$z57r^H4^L2v7&Gm>TiSj&A}|YjE~q{CuxmX; zD7Suq0lSL<mbdhlD9pbJa6?0>f&EAT55q!mjH9`*r1`iE*tp!Q1)ItsW7v(rpB#u| zCb$*FfYXEjj+~r+`sw-E-?@`=aAzN2Q5=6oYL4(QEPPQ8U_i47prT)J#`Z%@VVbL# z03==);D#xYV(H6zmz6*hfVGFve+G;351APIQB=oCl=OvVt-izlyhg>}2shaS6Tl{6 zbO06>x`+YH4UWhwUOjm6Kk;+$;>D*=SWXYNzxn(9>|ziiBQWgk^p~^LamLE6VWlJ> zXB+{jBBc~NjtC(KCPYE`$xh<NaIRVF@emVWhZbN>n<???B?T7h>;}7#bjgJ<?u%JJ zbwvj!0Cp<m_%^46(M(8?C#;LpJ>l%dBu$(Dg1kS^#SGw}(HDAt@Sl*g^YMx1Z$NZQ zd4YF;p$p4G<R_q4j0_ecKEO4|L)S=`p#XzaT(in;z>afp<;b#XrUxJC>s&6-t3oLR z?6xP6*8}iGGopI42#`qbMwxpHN`w+;j<DTn^C|EP&uA7H8hyzBGS&YmCB&^s1R&o` zIaRJ}Nz0Cq>5a1&|9v?*{q@TXJ~`R${)1EgKR~Ss3i+jVxk%Rwh<ima$ROQjhKu)t zv0{M?`icp|0Thnos)z$J3|R_$pCmsR9uC}DSFj1-Ds<$340Y4c7kh6S)V_s@k1KS} z7o?~RVkxrFPidv9!c<*i8I|a87XsTsVEi4j0uc>xz<0j#;=e8z-&}c|`MsaDf9_(d zZ#aKK{~ugJfsH=lzk#;imz1UexH2pBys$p&>;$SKfy(@7x^nrrhZpJ~m-krrt_(%) z;4x~!JMIU-uZREx1#UEVbdC%#0X9c7OAV8dl)g+Can(>MB1o_wfFuj;3r9YWB+-ZJ zCNkh(7i59&zxeOURn!0QM|z^|&=fe`!hT>r9y#8lKqeo6A&pQV<mnlhx(|&07x5u? z1p?&kBoHUS$05BU!6wkB5fhRZ!j`ZN7DoZ<2-;;ofRk6@6vg?pHz+)Vp*41zry)#C zf`6zN=r&#R(Lxk*C@4xNF(QyIx~LnXK$o@|%r>M#fb+kjvghX)JMtXoqw?Q)bbNJ* z1A+S#|Bq4Ej^9XK)IBRQmB!}Ps$Z3q0UMQ`q4UJ>Y8jx>W9%C0R2HbUL}j?wYBHZV zAaMDYv!(;&S`P&HfjYnrD}fz-?LZZ}SqGJ$$ixpz!sbDB*>2Jx0Qi^A2uj_nyg@6{ zdxiZIsFJEmJ^Ua&@6Jhsk!Z%h`2!7=rJ(JBJPUvQ^*5&%Cp*Lc+M$$xBTwnncPID% z6+gcr7cedOJ?U^JXj30Zx8FEG<lL)}?aPeMR?##n$)drNe4rvQi^samRv{<l2T;bg zUwJ_%2H*mAS_g1LNDXavXlK8U7<CCV!{=gPQh1MckHTq}gFD-X3HY}t^A8Mw7Fc>D z^;0ZfL;<a7x1bl~S$>5#xB5AIVwC5;!xY?%uh{+v<sD4_od91CtiS!XW_KbG`0Fpm z{0IIJ0FRgpO(0cCI|!CuTmb28_*>OX$$TkK=Bx}rLlA-R!4+g~^-W>`e{!ll{(o)% zU$}W}2-%edDBzO!K|d#u4;hXBd@?Zw;vm_hXUF~_D)?IVxbE_zt`nVfZO_P;$bxj) z+TQ@*Qd@NhaC1xj$Ka0g4^6>0S55yh0+4>I!TkmTn1AFN_hJARP+z7yWeHW0KwfwP zsJ3i>%c)5Ikj4~ozV`uv|530Zx1!!~9i&{85Xb?{^77W_xPYBnfK}gvVg?M08@2bP z%Q4qDoW3joa$>JCkC=haf+W7(p#lU5nReXcez44Mqb=}xK>!i1r3eAG)Bopw|G((^ z^z84Lflr?J`B2!S_j;7s8!`q0=YRgK;X&@a6fX=0|3dIbv!8>%tU`apcty|P%Low9 zcjH=+Kl6egGyJ~wpUc?kZGt6iL-2(Jqvz9Q!~oy!(gMr^{lGhPKN(Me4T+PNM!y<o z6j%uFD~(0T(|qC=%?zyr9(u6$5;B)p<%6|0#03ySA7z$jTUmgc#{Zh$Li5p$hkwli z?Ddv%^W=$#jXvAvNp_FHfNOsd2;3aZ|D$h*0jRBW^xt>t^0-X(`!ZApu(X}30w#cv z4)bq(E#g67UWRf(RV~m_fiEW{7znV#egHYDNa>W_S%ygfZx(pIn1y6=dz*+fBy^1O z@opGEbdKHS*b<k@97_2a*~>&UC4rCK+)7S_|3{Z^A3D5q?FtFbZf+|VKM$r~0M7L^ zv)=FTr`5!YJ9aQ<e|Y!THvjS7Gww{JK&vGMAc3wPZ!9?zsyK*>11$1Uc8B@ZkRsk~ zq5w`0i@>$45%rYRs-|MmLT%<`1)t*r?(H%L@aqAxQ0(S=)_d7=Mq$p+)v{2)&u=J4 zK<KWpFy~y3zemQBvL|jb5?7#qLj%}cZ)!-z0DQJR{>s(A2(>kQn1Ud{`PKwDy<zmE z`154CBc?zw;4qd3e(%=N{J)L8fIo7D%I1LEF(4K)X9ad5fD1X^@DMrhN4p&ex`kZH zvpYidfwG2Dh|ZZ~Re-2w-Nj?%q=7rm0&ejfI$@hoF#$j_DBx^he9||pe#7U}CMF2$ zJ{W7Fso4=u-?#@4GMiEYC5pO3rG^%UK={i8ytOs{cLv-&3Z*aw@1d((6X4TBVTb1H zZO9GJ#y($9^Ou7GZ}S49KVsI27mgf39ESmLqhreba#?sn#93b~0!HmmZ;$tqPH6(% zQrT<j)Zg}>iBRWzJgu-q&7`d$N(4TD06Vn+ckkV0EpX*EI$^yh%)JHhqceyY5b%3Y z?Ka*(zdFAWq7CXk#(zRQ7=Xi&kC9HO7HAfzERyDLytY055wd|0!rX#WKwB@iCBWCm z#vj~KKZsfv3&DoVf&rqyWgzhT=KsCm;PLT1sq!TpwbFsAJIGIUwS)lP7`wW%LEw05 zpzS0~0S|&(?!glcu~g76)d{p#93dC5YYXuC-CI1K;u3(MKD-jo?_0t&`p<%4v!=)5 zry2=;Evg;h*X9&3M;Or9LUg6oK6Brt0Z9952)%#&zaH>EHf)GM8foz8);{3u;lMuu zgPvhuAy`}G!$Tl|-1xmf;MC?n9Ee=VKK76=s1m*|Vs|78!o@LwqCcevuJR|aw+Ls$ zoQ-#?K?OSkoe*hC?oFI`T)5wH4Db$*91?4Q>%!0*{L%4`;)93>Q?_+qu!%JpoUQj3 zfy)rFpwD+2TJ##q5SR#!Hw2+)cdWK={`H?XNBm{8ZLL5Fxn#h#uep*-@B7aM`MdE4 zekAJmSz5e#b;TG6Tx@O<6~77d|8|6b@A4ha^jZ~a3<>NK6CwgNiM->-1`}{z@5G0) z6x=luerq}B9T7^N<g+JrGE76y1rXpBz6DvMv3GZ80Uo-ymRTujA|IYBeoz1h+@6Ju z`GHUF5&pZ#PrQ>76+Q~XL4q!`N$-jENH3?HVvlq!9LJ4XGas_0iU&BpfqlLBYp_QB zm%d@9F8LW8K!lXOX$uCN-vK_AsNyvixM|Q*hGy%uNe0G1V7PHK|0d%cbCFcD4g8(@ zy8@(9+TZK(kYau21XB1*jxq({zVBy!QGt(TpQA1xX_eq8^uH9-<LC%Fr73wOf(^K} z+brORd-qrlp6<hd3IU|25e#3c2aec#@VrNh{a!GBOY@4w+_zsyRe(>2NPtZ{uLjuy zxaN_WfqzYDf}?e&_08E|qICs-h1(1Kt56b9@k%nkru<yj-Y5S2e0OLA00t7pYEsT5 z1hdvOL@kGz@43`;!Y!lucP9FVUV^pg@<jb$Iiuk%33!nxyPS{a*Tk}3m*m}3St}as zGO=BqOkP&LflR0!wMo}qSN^X8VCKSix+7*>ig4cM2^X;2wSW(QxQ7RLrMk|uxIQu7 z-bNC5iz5od8upTu_oXj>9OMg9q5YPJDqzlG^<6ebVrHwLEH{Dy0$mf}c*x*R-uyEe z?Z5FSVuwvrg69P^P!#$LYggOaNEJqZg`Y;8nG!o{hHU~dmO>r;kXq4dzBCXdB!UrY z+;n$^g-~f)qRo~R#JHL^CcZRU(HceQ5A>Y#%w&AGLY_`0cP7a=d(XMg+kNh6Pp7PW z^TGd-k6s0xSkVmh;i|KTS;GYgIeNn|191Ch2Fww-!H*L4&(na;=kU))%%l|ZD0`*m zCx9{}UK_}P6mC1ry0Q*dH<;zx3fJ%S<_j4&n;i%Ipr@BR#w04xcB7LVf3YVqC(wL= zC1nCd091sjW(9+|QLGxuiUtHf4<rlU(B3*_-t@{~>*=TYSZK6+oxaq7jeABFsxQhz zr~?RkfmLv7C>uyE+o6S3=gvOBnEZ#o-{a4K9XWTSmt8DR{`zJE@a5b7eQ^CG0Ms<+ zdvpMDD&s?UN1WuQBjA`B=q((9%U`W{;K`10(U&{oMNvGVh9Ey=#-EO)3O;gh{an-i z7WRP-Ip809MZsSlJb&+AX@6^oJ{<c27fj@=c+`Z|z^F1iInj|Au-qu%YnTA$g0iiK z@8nUSSNyBsq@Xu4*suWP!xullyc~^2M@NtEY^_iYbbPN+(bI9H|GjMF6q#0VVHAK9 zoebqb0h(#qVjqfo<xyOPb@T7zzmn*G*4{~4+{JYTj&C;L|7d{O7A-(Sk9p)vWgGxN zQ?H!SW;p1lj=)0F^pWpZy#oD*_Xr)}*3fUu8E~PU+{m)HJVb+^wKt)=9KVbndwO>= znT$r$qoduoO2hHI83rNskgYRjEs)xhlat)Z39`c%%Z&oQ{q8FfAXm^(b$mnGa)N(H z26|oO?r`+uYy$LmPai{0&z>(+3D7%4me4CmI77h15}m&qb{=0^6afNIMVjI+*Okem zH~6pkYs>*KBGzJmV^2|p(Ww7_8z3JL7JwQ+L7?`)GDm$a0tC_lsUsj68vZ`X=(%(r zOwcNL5Qcc%L-?jsc(p-*C@1j_(1ieBK%l?R&u-L(N9e+{v&WC`49C5GHAf|sBl39$ zjgt7>2|f1Ji;JcD0Pq1H;PR0owfq8T|IfHn0__ht{Ex1Go?RJxPtPBp;i23+gZUVp z(vS&|4#?Z@m_Vf1(671JT*ZNmwk_5k598r=`O$xjf4FQU00m%4tPrJ0oMZ!TFXjWP zlzjnVb}z>@x)dT8I?@42MnLL+MO1_UVmGqqokd&}V&<KezD=+d5<uBQ540UHrOhM= z^Mcv1-<yvo*Eh4PtI3z6>2w!eco%*6JThE?tWZw1gkdgTTb6TUGCWWixHJtQ0+0c4 z(-{L|QvdH6U<6p;Kc4;YBP6B386M7l_tAKa{$#+Xq(DfQkzRUe56uGslBqz&fpp?6 z*0#=-ygK{0@ehy9!EI(Ef=&+D3l)vZDg93y@X-sT6udEA$2h=|76G3-V8lgGhy{(> zyc`v?0;Z~dsf-i+`CG<uxf}yE<Pz~a_yG7-NcY{ND6f;(COhCn$O6<b{#S0UlP-iE z1qIITZXfR4E6;mHWe;=A|At_cd{bO;^CV_~X@GB+sR2X)6lfBCzW$B`><5181OM{P z^$a(E^W#hu(CzQw_Q3#XXrde!4X8{gpSOu0Y5)oP0W2UR(pVcdmN{3s+JA!SGvbf0 zSp4t70l=tBMAkqQ$jhE={SO;(^N5rJR3Ows0f+<?xCOwEl9&PBCifyhrw{X%2jo=h zP!v!WVKx_`*$zGI+HL8O0P!Drz(YEKt^+gS1OK0`3)4On1GY=$aWlY0^{inyl$7kt zNCeRYNJxM$K!D|GfD2AkWG$&Dhy`^@2B=+O={P)~@tR%FboW2JeSQ5i{|yr|;Bfs; zW!&?jqG^&Fd6a}(>6izl4|7nX<Hs~Wjk-|*+=2lT^9EB_;3LC7wf}X-|1<y*2Y$qS z1H=*yOe`v<P^fmRzgdM*oa4oVUvG&bU{(kyD9B7*!QNu>xbOR3<Pv=OAhPnCxt!Fz zgoQo8-DLvEOO%1tcKBteP{aS{w_pE3eK@<CauBVrKN|O*4OIbvilC55rBDwD+cP<V z7r4wQKqg=nPH%+#4Lv|^eqC<{z8_TCQof%jI`jEs;Ln@?VRAI36L@xb4hG!a-YD(Y z$DItb#Pocb7-9_wT6`?Huf%o%BoO{JWlPeWyE?a?xB}M+O6mC5d>gFC;;B?@$o8ti zMP_CLi2tqRa;P#M!kAq^Z*5QjX<PNbmoT8&=~&_)(ys=^5T@c7UyYnN`$yBku}%xX zc#oh*doDhXdEsu-Gpu3=o&Fqm;dFib@Xnok_g=X(nW761yZeK2(+@qWA$TL+CVs`p zQSpE*z{kst0#X7%T?z11|7&ItCsF7rPfi{{c|L&F;@!V7n=fQEp$h1(Zk2mJyNyyS zs0c8tX2JJaFP=<xX;-s(w}b*|Ev6-g{xtrHl`TD71c5pd8K?vtngG~<k8Z01K3h>5 z$QAlfDCPkqqB(s6NtNzc%GuEO?O7;*#RTa-kCVuD5G2k6f<a)0QOx)+Bn3i9+k*pG ziM#N%-*w^R*)CK-_xYz+di?;ypMC(S6S@co!ed@K$pb9U2T&OJ-Nl1d{IdfeQWfsn znRt5gF>63Pbg(Ia-K#6y{mu0o^?5m#d1E%E0(<@$s(`qVjoiiP$FDuS03WYpRZ<=k zxgMLEb+Nupy+KP1(Mm7yCsY|*drG_oSe#>Y?PP-($p+jK|BrqtivZ9e5_yxUH$YFU z;7ETbN<agI`L4Xj88MoCi6dVj<3>2)hM|+^j%i_L_CxssW+Ng51fg{y@xOk(KJTnZ zI^*)y2r6KG|CvFrSq*V55I_kek|^T%myiI<%mjY@6P!RiC)Bft{39Qjj(;B;6gogc z(<@+~f%`I;j3&JMm!|XKU?>^X=Z~*+_gm1`MS$)p)Gyc*E~ybXf26orFPBYaye-`Z z3jEa-_-3SvyRF#lGEW7t63Gd6t2)zJy6a{GKDwR22kfwrlNvx!>YWV}c076N<bffR z<W-+>3#3TAG4AyXSqo7<2s{yh&_|I650Mli0o)MZ=i|Qs>HXe(co}!$?mRO{WL}zm zdZsR1=~dxD*eyU4Vfv_z7mr{FmYfNE;**Q-NB}pm44acl9KqNF0B#OjVcww)J{ZsM zjiz5-!2!G;mm9-aD&v)_X?*wP0~mUb34aiuPG6ycbeLaE%s(k07eGP|=s%ijfiy8B z{7wI3^OgUn5OwXWt&?uv97@`N+bMuwD{uh<3|Fdv*bgKDQpq!>*TjH40ToLrPzKUW z^z%E=Ly0Dcyb!^DAj^-)&4p!!c~FU0C?k-4FY?@=H!raZXNxW@a%*(Pmy@#{c3~ZE zU^^$oA$UK@i2!_tgfze>-+i$ZA3y}yLvHaw6b4R%(=&1bs@SXH^Iz-1p+}Ibd4f!T zUOqdWlD}`P&nvk3jQ+si?p1R4eV|Ie&(c0M0FN-;&!|S)GY0S_AxHEK0czL<1IBS; zD8=7b*_PaYJ*`&Q$A{VwXYlUL2HZ{qjFbk_#5P2ZpOU$1vXzwgiv%3<#NG)o2MUC1 z4sj-7qSS17UI0di;sdY->J$tA-7t^g9JtkadFT9SG`afm^%A=<!wpiIS7zrsFaece zuNk@oTpU<z2us7`*a!GxdG!E$NCii*Us$N=Wqe@oYy6u9(3^wt40gcn@j-z4V>00C z=h?hoN%U7{Sm}&MQxRZTZbG%2wMRfmzu&EKd5Q4GCiK-#R6)b>$bpmstof{@_|sRX z>*d!BZB&}GVPbU&WPoLsJ7xnu`0wo-UKlz)8Neif1q5~w1zs$9_<;^%7D)gHhG4fH zpd{3>6h4ZM`Ahh0S>lfkVAJQL83zYY8ji@GbA|r6es*?_LG<%g+J%`xrcs}tPmBPa z=KZXpZemSLPrC8~m*)d$ap+esqXK~@H4g;n3L5sN3YZkAhWN~ie=?o<;B4o7cQm;f zj$6EO{Xtse%9lHc0&w>or(l^r#_XPE>$tKsALqtvnit{Fw@rdiGcw|ud=mp!ww`=c zkMlpA^2ePxLYy&$B1=8m4670mXJl1knn~h-+sO4(BtQVWM?K;dOy~bD7eMG$pzEmR z5`Tcnqb#w;5x?w(_{%HF&y%jS36CPM!iF&-L0vE#p{Ij!<E@>u-Rb1Vy1Gz3NNJTj zqqFrjBftXq<Cq4zid6(C75weee1N@(F*~%Bz^_{<xKIS*1ItBhT|j@nwX+TW&d%n8 z%3#n~{8j4Xo%8N$t1>)jW-u&cP2T`qDga4v=J{F-I~9w)lN<!l+`%%1b>G-^;`pzo z&uZvzJ$#_hs?~WY<HAB@Bp5}2m0R0@8!YGT!v~BaIRE&!61iH@<KR`I$s#vb@aKiG zgOSXG(B)U)(QBTMoCp#AGgpT%N5VcGw{cpDCqvTUfjchjY~MXUy4pn-Hhw3S#`w-D z#*hdAsFSN4BObA<c@f};1`q+3<pXeSsH-Rkn_(|Qpu=Kd@qnGFI@#iQYkM2~os5RV zKi>VYa=ue~r8R&CXk<M-^wj2jJ*$<q(N4=L2T&(O2k}A&at3@(?5ASmUnQlk(*Uy~ z*W7+os5*MAX|X8$^9^$YF?oNxIDk`uRR#eV`ys1B`50T;@2q+DxKl-|GUBiSas$xv z-~pJC2P4P{@Fb$|&x$|C6>P_`SD}N148eV@8v+4(g%=NZ&dx`Z)p~`nFaCzle7f^+ zwKX6C_T-P)50w;>Noac!mj}ZKSe6D50i@grv@sw}1KPf5dve3^$6GHRg1^(*wBD%v zP8ylrqxH2nD}y28K*3t`1h8A+vNP&^q1b3R`YcrEDq#|rPckK&*E-|G7fka%oK4X5 zuWHO~MWWM^CTMBNVwT<}E7SV0Ah)vtHWdgu@}X$B`X1+l^PwZmKm#d!X7w$T%e{`h zTCD9wU(N>UD0C<uf6I;dSyV~zL@Fe732QK}ytsib+`XC%2Y=|o!O?VsU0Cll!x;XA zNYDW%hz5=kd1yB9i=}FSh~x&wRcife6|EqMvmVvN99T>cbmo=AJ5T|qqgkoms#FT` zUu)PM!3BW*g4y<!H{|>ulYzV_+O+-zyrJHdN0q0jn>E&;iSrqX6?+SQ;;%Iu3iVWI z6yc5QlAIP4FdIIcLq27@!6=<7;C43PRVMU91%asOlmC}v#t-iW95BwaBp^XIGDxK2 zU3d+dFsvmQS^V$h0d@8`XB-lO`Z9zdO0l&4Ug6HV4WjLOrI2=EeLd;IgJ(m08HgKu zAPJ#xB@p0~C1wJ@I{`~!$O0;RlUM-=e2x3~g*Z59&IgCMdl`X2rPZp~AN1Gs6zpv^ zhV>o@z{sIM8%anINxB^9BtTn9pc*&fPu~luqW}2V3|8Sl<O)JK{ZrI>E0%x}Z6=n5 ze>T#RS|IO1y|7<c&>ZK2Ze;^*uq41Q0@pa0*9+73$*h2;c+KSt`9{ieW9XL;LNG+R z;D};bBN7{@V^5H0HT)3`B!-2tAo2j2^{xid<z#DszB6exT1gkK9DLZ0&A;|qRAMZ^ zB;(0f7oRLM6NqdDYZe1x%)dI{6%OdVsGVQ;t6biR7-qdI{vKT&4qIe^Uc>FtHrYF< zO9MC@ktmA@%yr1yYDi*E{1cH8h~DJPYk>vSHvQ`5nQiNX1Gd_V%&{s$C4S*nS}ce& zi^5Y|c@3LfWUcD0Y{2D~$_qWPkLW}Okt{*%b4x@38UpOe0x0=H$V9C|KD-;wS&kwI zIpHDvOU~mP5uJ#{k%y-cH2r(sco01vwiYtjNxE>Q`D}Os^lA2g??vD*JU-rp30Ue} zzy%*dsRCHj`X*{sty$E*8n9%nS1vv5Zjb?^(N<+^tEIon>hx~c6u?TkS<RTE&)PVu z4GvBna%bXcQwAONGz9=30#n5T*lc#dx5v-Zj=;v-!$!2z5)*E&Na5O(wup~PjBXVN z{Q82H1VBkqolw$za0IvA2{?6w+ky~T?$yRgHwKr-t{HllU)9%=2fOHn1l#=(r2wuW z=-y{ZV6(ShG6qa1`;BL|B+sN>NCF^>s9)Ir_&9E2squr&=p8wMOREV)D%cIFJcYB~ zZ2Vg!sLehA0len;nR_t<COgAM;=kNIU0-{pRms%ron8~^V~;`&Z_hf`Ot6f-W`QAS z8wF_lSw6-}LdVoZjR{FmAfu19RskG{fVGzg0~GeVI7=Sb^=ocIfZ~B{!1w>6`!V_c zD<+xh<qjeVuDl@uvPtw#V_-=f!ykh>_5lHSn`1m{W8N5$fUT4-KMq1B2q`XegbEbz z+xMXh^5JIKoHy>p3>cjb6be?byL+xK1pWul_QN>2oG1K=7Emzo@yEFbN(3#fDwvsI z*J0Yn27DD8hoBL{;O9rSSgb$x@2z#$$$-;ox74MS_Pb|?C221x091y0VUZEP)G~p0 zE$81>T%a8{d4Oy(I^z0N3l%AuObwHJ@#h@yVt||Vih!SO7ua(lA_?Z|@=`J6ai2Ee zh0DKzefI0+_n&?9YWzqrXbNAEJheY0j{l4bhQ6d7r-Izr7^n(J7GB`u1*CDn6EH&3 z|B!;b3zJQJE(1WCgwKvU@2@?Kb-?!ep`^QUwvlvU@7Vyvla5iYQ7=mfacR)SQu6?) z3g^;5+<G$pMFZ`0Xo(>ltAT>R@oK3g2JD<qrz6Vr^lW1dH&5-=>Gh2|PL1nqB{k*J z1IEy32xc71;ZsBZOci;`OCWD**!V?F$P@DT$s~RepeO$u6>ge(X8nmpl5rr2BL2}0 zMX>*Rxd1+uM<BofeN}nrLR1uxxIvHs1&js`_VfbG$U6-6DVwtNEc%oVAdMofc5*x( zd4Xf6lZhfU%$kILZ`>-80UM~JJesNpQ4F%4cHy(KH=FGsOcP4S);!_bu!|+;0WS8w zx}bR}05lux+*|lZG3PKb1OY3;4!W>mcKdhFAgBiH+RcN#Tqvy{1hq8N%cVjYU#o6~ zJ)jD?<FPjL<qDosM(HGh%K}2Z6-*0ce1`vAU}EZD&)V3e6QHy$p)wVKxuky)DF8^b z2nE8h52~6t!66imk&S;=_a$C{6Iy8int2+GD7+5>kO3luezi$YFa)2O7jn&{nCQBm z8I*R=9Cu3lV1P!^T?l$`y}R}byHE<C%927{!SiC^BSopge~$!Mq6WBl@YMy%!fTn- z_p`kWLDfjXQ$hSmb3AXA_Di^Z-2dVB;l_IR;o9n(@y#OyfaR`M10S%(<C)_)6WF8@ zL?n>K&cuF!-a^ORDCG)hJM`Nmf#k~P<Krgj5>#+T^9?nq8IPklO)dlq1S|gm|I@1O z>IXHC@VR=d1wd>8D?(KS=s|1-1iHLGy))~Nzc!d-?t>e<5X3){UqCwmyvV9!DHj(n zs~6@q?)$x-^Bfrf3T$k!2fJ(N!WOb<b$S4>0PRgOXb<qGV_$pOfMw+YWC9okL~TZU zsTY`7{seT2PHIumeEjDAD(?T`!|ua}rL{G}AKyIku>DMf<|NZt1bV<%ss(tbQ!9B# zpSiNIHa27scy{3=)Ko{#hNlGu4LyL4jT&^yV%3F>O*1&5EnF%8^0&A@`Dlw_mXb`= zRdN9e3Inh+M<9s+K>)rHGfKOShDt*aHvneAVZnnm0!1GLQW~35`lNxrL~(JmGAlv9 z*DJj8%Kq9~>EXk7-(6eVUwt#}!Vf=$0#H0@Vho7G0WJ>tm?mI(d4TV}+JoLg9w-G{ zj=+Kd!Qw=fTOZ4U%B`(u-dtT>UBe6L<K7!~^W`3jrD^bs097VHXqrCZ(02qgTI$vW zLL2+3YOq29ip7qW1OVi|6R$8PGqCX&p|Q-gixGhJyOm#JdGg6ePqS}VR>}*}Q@vPY zBo6{pxiJBRRF-z15(<A&KrR5m^K|EIa9m3?_FZij4m!d8z&pmVVSl_C9g|oJ8%ZM+ z-#puFRJNXZWtAfIThgGoN&iDC0N6A`{lrpAXyAH#QULG*mzf730YG`JR8EpX0*r9$ z*o=YBvMAy=*3Mo>dK!$vS3xy}1Bzr;q}Y*Ax@d2KHU)xa3k0$hI<(aYv{O(Z=nxGJ z9T&-S&anwU?Yv*sv7MiZa*p3Wd*;K$@|8wXS07tG`Fg;w@&7t^qaRF^_}7X_-R<Jp zo<_l@*<UAFLxNZWrvYdLc6r!dQ>2;#!J<`(+G7mjBOsk3G6dm|odBLh6N(Y`)CcxH zBK$>wsVGv*;N>r|`(>@Q8b@h!iHAR%3;;z8R@t^(H{{cz8HAZjbZxnrRiA*r2&Ow@ z)=QItXr(^Au6l<E;476n=M}y_;Q>IzTarh@-uv78R+o}>!H>-Z^1XoP#81I|KS|)0 zB|8P>(&xP1@4xtw$zZ1dK;PWu;mHCAKLT@uDnJoX+3O{vJEKdgUU9)<#2vxUi+Uxd z1hC^pBp{gBggTbx^GLwwUS0DK&Pa8O0m2!i*~X5J2<Ur`nLH4A3IN9eHT+bR5=4c~ zA;2uK?Ep>-MYA6eJs>B~W8SXANrDXXn#17-JcujMQ-M?E*MiIO^!mnP$}cTHj#v1Z z@ONrKDF({yoKkLlniB!P`Ue6YrvZopAnbpVfM4ML1@)5)f8(>>??n4w{L<x%Jp1>r zPv5^y#Vm=QZ$&PjhcT40DK$cK48bDw;|8+P$$p+qARn+JX!P^{YB23b6e!`2zBQNG z{r7!i1a$xLEe>H04=mrE;wdIl&37DCPcO^%hXBsqfiQm;L0y5`L})EZA)6`<;^HeL z+b1Uj1a_%NNlsDbfxig0ybMIQ?Ra{+zkTt=`39vy!M}Pj*i^-_wn(}bh*uB-JWvDt z_Uo@-m4@XU>OcF~d&I@c4$pp0YK}3>w<NSwM-QH7N5_7@Kizj=&Ah&&ydwYq0#*yR zS>mb3u*So>s&L0_G$W_^N1_9!qA+FF*MHCjrLQgawH&j{IL-zfyny?dQ8ot<p&sl> zamkhaP~nJuKz_pJ+1i@g%X$I9gPT-m0jdoawO}zJRtwEOgZ;cPVMux2VB{9Zk1`c_ zaP!I2aTNF8%J#$k>FMpGj|Td0ui*bfoxW1Uuq~FzcC+pX14spGN!a7^0Po6Zc`k@8 zke~Z>rF3#|_D~gq_gA}8kyo@oDs^9_xii%Z?DGV*Jd$-Yj>V(u?{qfg)aj$$b-xg_ zrqG6X{1Z^>`IHXQ6rlP{4`1b_reR8Fm>F=_WASeYu(LUoQM&NMEL@kT_Nk%y)G%Jw z<@u%J#MK@MC?OO#V36P<3ZVG`+iF0TUsX4PxFp=**hammWu;KA<G^ie?FU@`S81o$ zAC4!6|G~@f<r~@t$0KqO71BfG@r@G!iUNLn*m?j@2Sb4Me?dT&2cNEhe=fu@U9Nhz z^$zfQ?C<VR2PV~V!?m>F2=1wrYfmy%VM|vv*umc(Rbl`MS5XO~6Ag@d(g-UueJYHL z!+)<J(|ts%Fo%1W7#W8&_d8miKT6~d`m+Vb34eQ*LX4nJ+BLCy;nJen(RH>{g4hwT zAJ`HQm<L7I+QbW7NU)u%V3Shmxj~nla<eCZsu}Y{Zf=qvUU`M>z5Q@>jsF#Dq#foP z;UKpzxJzwnTeEcl|6hNG01x|>FsN8~XEnoK_J6Qor#REY8Z%!SCB%xl5fdP*^Pl~s zsDBP(3T(IYErZH^0<zPou35EG3*<l@a!rE*vFoCM^N@3yGWfMpGZO~>@SHl*&UPwi z@%ewUDq-L-VTVjm2@rq^gf5j8z*6X+<Cs1tlUwBn$RD(V>Mo$4zD<Hfi#${aN-}m~ zKnV?s8-ba!6dlf?kr$8(NH4E{+r%NhMO3H4v2FWG1c>4Bxms=Z%utO9@bASxEED+E z`>j|5fOiIZFjph3AsS|m-zXf)CE8P%CQ9U_#qW6j(#z*~?C2B8eC?R4WSeRlkiZ4c zfQpD_h$0wy;b}!`RZ^(%sU-hG5c<}-aNOO9I)xX^V66Y=EAI2EXtL;LRg(+oTJ2s6 zreI&!Pd%qUSD_?TpoEU+qhs?g!asp4m5S@o|L0G+fH?MutpbH?3WsSRHvAVS8o*od z4w?-AA!#1V%TcszrTYM4nnJ*+jT`%SektZBX@H020e<GQ#jmx70La)GyOR+;Rwtg9 zBk$oX{DelMfeNU$0pi81@fncb#3ipVpKSd*0od2HwJFxxaUr?tf>3HG8`H{qu!|YM zM=2PvXfT&$g#e6DccY%-J(Sp(TK7t^t`ywVyhXPbajd*#MhTRPFq7s_;C7+>gb^+C zFA8{nF&3vINDr5>3S}z@?!dB^APV54f_2z7ZqHtPK~CtCI&^v{2R!iQ7Hkav_qJ@C z6;AMfNfMY^pA4`Gc-(q`Z&3hp0xjpb5AbJewx><C8YScx@1(k?1$0W1g^K>l<iOs{ zcr&pm!XS&^srFUD-@03&aB+s%e90$Fwh61U%3hs}u95N&2kHtjWCE~E>25rQJb{>) z1vXY5q7FjohP?Mr<->jo$^{W#xRrG3PBb+A!Y-;G=J;77sl`EEK7aA}2Vr)fz@Ov= zRb-IcH~=U2e=f(t;cgJNTTFlxgs!r+dMsBt3eWF_EWvO!VO)U;Vu!~+JI8@`0w1^{ zNMY$R6#u!4=cmGzxM(x4wdws{(CD2268%_o-EC-N&zbv2Y0Km4GYafxPK&!A?2)SG zedm2o^}aV#<lk<<)y4z-FQfqN6DA1ciLOdt(4F}uHg4Y>VJ@D3sN63e2AtB4^`F<7 zHwyuzu{YD;b4L8E<ll~ieysv8<{tru&@~cVtN`ryBbx*Ng_^p~e1K)!sFdYsoU4|z zLMDPOJ#>gksLeM~N3GlB7`aCss&nKy6hQP_p+EopC?6mTLRfzEsnI**fDZhd_lW|q zqOt(@W$K{E2zXS39<Jan`~`>oIkZ1o!{hi|U#we1W~*td+4Y{!xD4ySUs6H3p47QA zK=L%m0HoL5JFF1?J!IeyD-^UUp4$Fl(_*0^i;8DQj<ukAH>H3)P(Ro2p&*N9q}RqG zaUM(JXVeqMA7hsa61)rkn?k6gw>I`e7~o=u=8ZX=9-}WCla|dp9i^#if8kiTU0s6y zIR&}+ybu5d@asdr8T8XnUn%wY@2u|^X2JhuC)5v0$>>~$!&Y~j47`8G0J69<^r;sm z?LQnc5BM2M#$QgK%@2`T6pIf=0VKOuE_xQPDR*{(uF<_$YHaRC<P!L;Rf~Dz^ga8r z>2xmvU{GcR*AKlUTGRacVIy=C*jEH=q5Ih$#TT?>KY_mU2-{JcM!Rk`oB;QuV}LD( zpK~}fM&3by$UmkH3tWK&6(h79rZKc@t<m79Y`{BV;Dhr3(na!Q604sicpI5PwN6>{ zZQj9xsBGnXlLheTRj0a%{;U)h#*+CYz;h*=#+=&h_B$8*wrGgxh7lA}6dodr0@Rma zZ*<Ef^loYA!frt-pDf*wEJL2DP}mNPMfUdMH#DyB=Qld_7M>feqfZ8{&Iv0YJO_2| zbGS08T}mjl>`i!Yo7+ZtBXLKcWNWnnFo}TJjYNJb)$3CdBT$q~AfoW6!@7)Ua6*GL zS~rD_kRZPj^~b|}fZthojH3|*2gok({~q}&fY{(WABfaGk<%IAKEcsr1WISp@dahY zIUM{0JFXe0u=n)MJyTKlYMgTa331v12Ouj8xnb)IKPcB-P9HeB8@L^!OSK?<>LGXF zUJ;WOA*UdvD@Ps+!zQZ$A&BT={$~@EO$<mdpo-blOoyXHUZxKx8TcZvKPam>hAAk! zvjjmsQNM{%{1<JI98!F}?S_=*Wku2hBEZ(#t*4V62LAEDDB#!I&FcZKw#2dg=Nv$4 zDS&BwPjH$}n5a9gi=7teg>H7T1<B1z^5!Fp6n!+S)T~wQEW%mp_3ylJz@~<_Up^O~ zbX!Zh>)yMYx?x^|bunPqu-*x6tp(_++C_vUWBwW<T&(7%VtuZwLZ2ErmNgp0e-`bk zOtox)E}|tEO@PfxK}`;)wh$s9IUJ=x_=)Ij@Gc1nqvNG2*z(gLO9Om+9PiQ(>3{#} z+bjtA?Lkq%&$n$t%`hN^J4tl@PSCTzCy#b&26+I>@aMb6C*cnj3_-$sa1{LA5=S9K zz+MWV+iFk0tEvwS0TKf`xYVuq!2XS5f2i!bK4zyoWS|j)(PwX!*Rs^9G@ZXFE@+Ml zB!KMPk|-kAl=#By!xxA%gikj+H3ktqBGqR907xgu!RY6@1OYuW=z&d9>d{`*&SB3S z>xe2Q$VMHZc+UQLDoaV8_~r}s!C`<rge`vHO_{)-$pbtt3i$Q~$*%(-N}ESc2Kax( z2;3m210Lm`jJJ)vYJ?HSW$ex_bxKZRi0s|Bldewi=do`Bga)F6!uC0~HZmKpBHeP8 zIQz(sn>MQ)ZaBK5b6RLNxs-CBimd`ioy{!{Ev<tjJ_&EZ3c#{-@a+oDgojrB5Ww-J zADNqKa5ut+B56ymo`OBH-3ngy0_5NetP#U#5~wg2M3>U2+gV&H1mGD}KVoyB7c_8` zkQt<y0DOQ4X@C!Y<Hy2T70fF3n1Hx{YxY6^&Y+LumI=Fg7RDz^9+O@NnCuNZ;OLP8 z%__zqQ5wz8zfC_I8J<9)i6)NP^LEe<iZhjEvI_w2Q6~=UY#rR)-09xd@^ifL*liTd zzh<kzW)p$%imd|-nxYFz<P(of8vqJR7{C)D9*bcI2rCAV2yi78<4_`r3<1_IVMclB z?q9rsLLrXa09~G8tC|*41_1q14n#adG#@~&5H%ng+c+o=U{NS400KNH3iyKs0WXkv z(&&%&kKAcS_S#=-{5B8G0TZK^y%g+y#ZjAM4kYZFNFopN0D&{6W{+ePuE;P1i3+Fv zZ53WauG~Uzz%a(<q@deyy08^kgo>&@C1ij}juF*mHNa*0NRRoDM_&Es&#K5-&BGw^ z0vZ3J0u3tzp&S9>|B02moy#b8;I^0!J{+}B06(%c*UBM}&-iEft7tL^=^P29cO?Qa z0guZAuqF^4J;e_T0ZwlaQICK@Y8_6Tvoj8>Xa$Z{OFlSA*?V}kh4;7b&H`s*Wel)2 zJ6@~dVC$BEZiNIZypqI=uVdxVU`4R4QtpyGi99n+^Ewk?8enhAB1_Rl985s7GyQ2m zJ>}5z`<_r1FW1XzQW_2mjthklGH(KBM0iRG==%!jZ)5Ln?>8T&&Vmy!LA3HWIdu5; zQj4pbK8wxqKjK}Mm$z0Ld=XEq0dNBTc;I?~uQo!}z<$bpj}hR{j-f{qm`&07%Fr66 zfro;<T0IVFq?;b40u^2uy;<hWZhz-eJ!Aqr+%*5repU#-+vosWB<Oh<tD!A-M-mq# z^*~FsbT?QTQ<Y>X8T0e_?bh8=cln%DJbhJKPG-FZ^TYBoY9y>YR&(<>qNxsRej9-) zT!?t!BlIBuq{k+2fFf+@5kqDo2oh`xumnrX_~$QjNc(IrnFpZQRPVEa4_XtL1tFz@ z#NJ)}0H5Nd1&@;Seb)0CCiM>rjBn5QwWrT3$Knv`POC6SYOE~%@d7FRV!?kEL-zX< z!KS$pd*hHo_bILMK)Fl0LEYU|-F&c?o~^AU^=D6@HGsYY^a^<+U<m9ICpPz5uDT6U zg^1^Jm$1?*LeHWi`18C6=xf_#J}lQj%@)XAZfVe(ihVzKB?O@AV+j&7V?fi;Q>d)b z20t_sbvhw|pctSq;IS)$N|P_#L-COXJkhrbpJ!t^3p((3N<ivcZNtId8?Su8<gwR0 z_*X_6*#d@m)W43;6lcWkfp+i+`ypkLNj#A3(u8U4pjioA|JBWyCP~?jDE6L%YBFw5 z`y973S|iJqJpA*g6yadNq@Ok~Q?-NuF$Txzfd<915?g}-PW}0-Nfu}!wA~WmE)jPC zeMUW%#DRE^q?4S7+msm=_7Q7?xCHhVZ<dX{a={_MpO4Z2?|OnW?|<rnQ{EEXNo(8w zbG+i$(e{A>lPd!yVgeCGcvNTS1ZdQNNmJvBISyFIE8bu4tF`d~Jyy|*Rzgl)K35Ol zDl0#w+jgOM+uyHM!<|F0x*a^p(Ygb<%=v#DF0?s`ZP%3NGFB>H@=0e5km{PoNdpKV z{1XU>1(MHW4^F-BV@VK4B^dw2fb^faL!1BRnSfdide1yiv<YxHN9sS5Nw@9<J}wG) zzli|6HjV%P(%@~-!S4Hr(dqG!39eKJN(+buB`%?p1We|LyFLHg{tsu+yAcQM755J} zFzqEtShmFNZJNFIKrX32YIG;)glb6xw&ug&4<GjXN{>4G%0soT8UA&bpy-m?_q6L7 z>xTd*_<Q*3vI$(L4u&(p7D)s^>A_ChsDqw6dtqX@j5}ZlK-H$pmO~d+>6&%}bt-Zm zfvG!zkBtH#z{a3B>Yljolr$o;;CA9YbHZD_2<W(cd3i|zElqKp*6?~H+ah%6RqDl3 zTwE+k19$7cl8}FWy01&+gN=gDM->1Gm-iGeULG=y51cbw3N6%44e$-Jl75SFQ}Rpw z;2QiK^`E)74}si^eOza#{jo>_lY=b{Z9|sQz+S~94n$5K^ztR8m4LQ{gnj3eX$XJ1 z+M%?f4SlK0v*@Dn&#~KPb+Gv4+s$6!gMEN^e1KX{&3}TQE)5bT`Q`wLnqZb}&DX^8 z-V(SBSCBo|lhjvprmbz(3EXLnc0s5CroY)rfFTC{^nCc8g8?{@86y+GfVWG?c%>`e z<=L$zXJJW5!Kl`$&>)HHskpQCX*{M9<2Y1bC}pNd4+hvC=_Y+H;6$ENv#Z6!9+DwN z;I|I?zm&nKy~GL_ej12dqpcep$VOY<VC|M+qDP!)94bpQlW+v^0X!S@=qO<SxAwn> z4yUZMLNx}kf;zB!+v9;PqCw!8GuWopmohAEp_7=EevJb+R|FJvuCcE}vo8E<o7QfU zjo3MY_<t|eY4Rtaf+P4f9)Ye`H?^IJw0CD>fbOdBZ<S8C@7HT{#F#j+u`fq=0xjz- z$jzqO&6Gz!;-ZuG6cH(NQiUzBixXX@|EPg9JK9tc9iU_<Lr}74!2Vu2N|e13XPUUx z?b(r{Pw<KmGJ%hb0;Fz2fP3bG{^blL58z^!j+{}@03wh9CSD*oO|xO5QSSoUt|1+B z@Zhqs9AM;uYb4Tto6y0<{guy$YjOj@pWF87d0QfCha(K?z~*ky(z=hnh)WAlfs^3S z_DAeJvhLW==egrx@6Ti>4Y%0G(US;%>wys9lpkQLyhj(;q@P<Ew%rnRhh%anC-|H= zhb=Al_te04$jqAz$KTB8CoR7E#z6J@;K%y_JcXRVfGzCp3%D6s-3{>p8Wjmx=mODX zgaI>~BLp!2i?wstxf%w7aD{jb4iZv?v;{Qj@*sWyT1%!wr$Ra+B{dxl@5whaHsMlo zmc;Qjz(2F=_1Xc{QHm5Z4IT!dLjdMu`4H=vKy3`F3BQx`<P(W|(^61Y#+6_!KuXW~ z2D1pSFI0kwsUBmxmp<HVh4zkc43hm*ZsCvFHtw50dN%V3V`Xo$hKRMa-nVm#8!l-K z)z{*^I%|Qx-2dbKZA}1q#zo8&U~eJkMew+2Fs6d|H%nki9hWx?LJ!xggblz2c=9Sh zCxXT{|JRP_zEj;U+}}uj=Q&A$6h6!Wr;ptxqMKE=3@EJevS8Hw4Ae{_%W<%HZCj&S zGQn3s!9L)pw;w(b1=`NH_w(&e6<qt(=S}56*%B6gt{(Z~<PFHlEGUpHfHe7J8#|6e zF?61=)6@EI&O@}eXA{D6|3%5jxImBC51t+X4_3XeB1{RF*`G#1{#`3F5%!P;=r%ey zD-ghqq<v<x+*6@@YuT4t^S0yps{jaq`tZZB?kicy#~_>y<gJj#^KN=5V1GaDq{UiR z2@g%jK7>0AvSR9|yhsrM_}#CmW~a5*?4KzB^ko9h(2t&T=}_`Jb{=*_!AO-RWK(t1 zi)RR;+7>^d$iL=I%5Hw0zdy}4zrEJv&oi&HTf!ydzX(v<C4!$z2`I<*BO(Y*6+d9g z!Q3zj&`0$_dl&XTGg?FIyhmB#1Nvt_vtIBiAYNQphmr>hn?elCfyRt}5#VWYfL9KT z2ylU$r-Vmhg9Q*Xct@obOP14)TLS;Kud<|dX41}lYy%8~yaLD@V2)?{qL3&+IM9H; zH5l-rQ3du$CVvXvPFAlFLN?y#z8j_e%zJB^1yAkz3!U>YGd26Zbf1U3!=NuB%4~Tx zA`4Op^^)%SsAO>OVSq^hmVp=b=dvAn0C6z1z5ksHVu)kNHtneydVfXh4g1yI!Qj5N zhuep`GSF19f52xgqdtF3B=C7(2Y(S$n-M>eSOTSip8{}tWiIW7&pyFdp7rC5Bf|g0 zF)I6MmzgeU84lWpq0L<3_wug2Rg{bt<b12J+=d-^9a_lO$OaL!j>kIgz__e2G%eX* zYpO5f-@=YYkq9sfB(nNANL)ZrBit(o07)_xy-K5209dHC)C+tr$)mMGS32nHK?<Ht zzlJA!?rQ;<sIMvTFafOOLfE8O=AIE`(k%A0u9INGd&mITjC>|>Ao!gok9S{X0e(C) z5_rg%>F03|1J0O&bNT|!Ye4i}epmvz%|BK_0!-9MS$7m&3fV}Im}xed{WF${i28yE z7f$r+)~h_fb29@(T6_EUt$^`K5#K>t9(r4W38wuwr>l)t%mUCCGYztpiuOb3E9+GL z<C2CalB7{<No%ytGeT6_>*bBNnEp@zC=*q*2S9o-3`C864h1bNsS4n25UBEM-**Ss z?ri!cAm{?Am;8s$fALmDp^kS|U?1;LW9<Wk0MCmA@|${_90J_u6hP+W4k+h+Kkqpq z#RU=2V=sn;5_Z+$6FNhO>e2scrr&tH@;Udnn^^hoxJ`wNthf_88*%wMk%*zV>M1uj z?bHLA7cs`tZ3PjuG?~Cb5{hzIO9&f!1}{;c(&8aRQdq%$NF3o<{uMS>A))10JgWEF zl)X&@uH2jrmS$IhTxx@PU*4hn^Fdh38ekt02LXNWkCEA<hAe>HK_3)3*bJQK0iH;J zUSq=mNcGnw;LM3kcL1dA@;O$|giM3+A_YCr$!cnuX_{lE^P`U9k_ttN9&79|^-<-( z`<CYW{jF!A;C+c-gE%#h_*1sowk05Bt`VSukq$WntEMd*9V1LBL-YtWX>C>j&m~$S zUO^&f%`h^udo}82<hu+DOyEl51^xtnP3gJ+CdE~Z-g^RZfS@q_p80{_7bX0G95sgv zRjdQS-^;+K6F|Cd@xidn1u7^bC30j=Av|dpHX&H3|Gr#^mas~2kC|?{S4tl{mL@>y zBDZe_FK}OSUP$Fl>2jHd^-7o!wVs6g^-1p=<M>bt%7i<ht~y=_pBq>@BCJ7O1zP_U zeWdwbqv`<Xj;GVPsyqv5h<0)M`w6bURsLgrmmPx(eR9sM)W2YYrK0&eNu<&ThR7Ur zEXbFC;{Y%JhX6PM>)#1nJ^)hy;vcq2u&V>|ra9f^JTDuewb;$b=n83;nZ9IJO38h~ zNNVSU;nv;S4dy~n1Pq>wOv$%6aO$OW_vgRqm=RNL0djc%#{(DOoDKu#Ab;8aph&eM z`~uZ;$*=YY+0hxP<4}j!fBEN&stao2K|=0k^``_8RxFrCgfb*3absegR81>unU5Ms zj-fi66Xf)Q6MiE`;P*qJFaC=F-@bm~-S&Ls1zPbD!EZcuf%x=})fPznZ?gKQtG3!P z#&+RC8s9)IyZJkkr*Jl(ZX2G(ejDfJ^E;k1qMPm^t7{nr?k(E>cCeIl4+8qMXOHg} zAu<>lw;f*++wS6Ohb_0hx%_Z<tNp>LMNvQ<2Jjv|psS-EDm+H{wTki=j1gio`E&-_ z<RQR>`(|9<d!=aQjg0FYar(Ku^2-x&suc*F^IT9NfN}5OpY7mpKb}Sa0zu3H1>^FQ z3hL6*2$os_`MEN)caUm4KNg4}vNcV&Q_nLVxek>syBw=M%I+XX{7fQZIaNb39|xS= zQG=!108`vs)ObSpin3#k2ubH1X%zUQM{QwUmfJT2Zm<zWY@A&Vo%Q}kEk}uL>H%@6 zI>>9{4;Os=<?YrFn4;f$Q~(q56gzlBh0D4t<&9{p>I@-+gMQ2g8CP5(;3HC-)nD<U z%7K8@`0g0pE}(pXClY`;K#_paBmpo8`Z{+l{z?aYbVO(F7s*%K;DWaPnw8jEzmUq{ z<-$ki&%EcjUeuRS=bLN|#FyH$0;IhDRiB=~t&u3%XaL{vmNNBraC*FMkKkMwT7K#( zNUQnjl6|xVwXKz`x+~%BuKF#(eDu6-V?*>x`{2o&Mh}5S-vZVy9equ%CfGM&IhA*5 zc-PH~+Gd*q9mpU{=lOa23C`6i;`&qP_#ak}8mT1)hP472i8g`{F9MM#6W~xJVA%ix zjN}<#Uj*>94blz=@RKx8T2yw|R^6JdeH-mO870Y4?Cwv=rPYij1(BT6l4E`7AA1!q zq*{6zh!>55QGjjoR+UpICZV{wV{agbfRx!~50EB0<w&n#xMcq`$nQukpbF!I%9h%I zFIVg_gil8cqnpD(i)G}3c2@l1fRZ3BY^!VFfp#(0W?q`jDW6Q|ZUgVqq^}DYlxOEJ zn0xZ)p)<i4e-mI?fbUNvfEZ9Y{Tvb``K7xkR?yYtt2KUUI^Ct}Edw+?Gy}Cq;UfH4 zh3<PW)QcST9oj0ig+{yIA05cDvOeDP@pTsksBwUeI@~WE(v)5UDXotdx7c3+(JrC$ zK41qFn5x)GyW+Nj%vd6UHZ>`77d2|N&Z;h+wt$J~M1EHoF2$Zx{0CTdHtdXIp6uru zHZD~uJ=9`2YaH{--*I~f%#42b8R0ob6-h51&UUIdl1tbIHcr4l1A*V4X92>1GWj-( z71+-`PSsEL&Rxf8AdJEiHvt6|qJ<8vM8OMKlsp3kB?XNo?;DJ;rnR<=(xiZniYMed z=gcrt!Y!}`NP9A#%YU=;pWkr;Ht+{-8dpi4i(#c2T3^IkO~peda}KR^0eOA<4CA&= zap=+pcj$5*?bl8&(75sm;EzvYA%xs#uNL$5B4jVJWJ4KnAI;oup+g>+7)<6yG-&T` z$y{0YLm2K!KP-uk{_#umv$-fB3QUkD!?3HT^{0iAox_esHbyb-C%AZDrOK|@;uTR1 z(p*(*6a+EKGN0l_N)YeLCNuG`<p%Nru)ppCm|cKkw5QD3V)SVnNdsKuIcQ4Wwr+HG z_2xh=7$12STOX~yOc#B}$$fB>cK(dBgfE-(OEBq#AlG;TvL%`pJxCA7WU`%T=4NvC zMHY!?Mwf?aA!Nc!&ZLyh<4nq*GJ*)_v{#jI(_AXK#$Q)ln@~##%M?~Lm)QhZD|zOI z*?a#ZZgFRmnmQ=bTAEfArql^vpfQ-S&mya>7Hshx*gE|xfWtLh0v@^mwoSF=GpFSw z_oRbG2@{zMcdZ)M<|@^FFhLSeZzj`q91lvJq$h5~G-8*h&nH*6!z>6LV<M3-N)^oI z{Y%K24XOx2fzw+&W7HaZ(hoIwhCjsNq36@@t<M;8=%7~QQZd~^U&kQhsc7qg;GwHf z0G`(_5GICLyw<?xcU2m3?g4w)3i7(+-E7+>i({0CHtz+aj-6gY_`i-z00r<c1)vHj zc}K~RGw!TR&VQ1nE`yBws$;hIQ!7U5)YXymf$WG=hU67;|FU#PrH<#{l-kR043^D; z_lT6sfK*?4aak1tftoEPjKy?{(kFO9MTb1>orDi-=%8!dR4tsZqQx;&yUrG}EZ~hT zBaruQS6v(q<SygDmI!qh;)5%*&liB}D}Z|{fUOEXfPU#b$<}}iI7P!W-B2kAom=#2 z%rvG8lFXVsT`E1bbf?-g#{$R(^c)LS@*1%mYi4MJJ`#VxK4XFpU?w3U;#DnXKFqhP zt+XYe&!k1*Fz^{H2`2pn(G%{fMR$x7Sc)NGv6N4!4`Bc70su#U9qbB70T|wCwsu?| zOS<$n(3oQq3EiAF47w!i$fAfeAgu~gDqW!EP+G8I9c)+&2<d1Er9+QCI=zM+i>OaQ z(cl8Qh3e4f*XAJ#(?Gx9w*8Ks#WhVUOapsnI7MiS1>H^yq8T;aF)Bu)#(w)m__Svg z91h3d0dD<q0jO99>S(+KEtqvNXc>-8TDJ6KWH?2nd2ixr&ydtHb6TQBYWWB$*<MZ_ zcd6U1Rvc2~-c8|2nRUF>2Z<IBfCU-wG9n$4j|Qm)6vp9df50$t?2t(q`Rtwk3<((S zAYbI-Z4k_j2}568VJDqR#ZGZO(1MRHfQM%l05~oH{=<l?0gmhh<DBc*v+u(};=jT{ zVcfL__Pe3&>a54E_tKIOt&`90@dF&XGfgiAm19?Hk|j#_0(RLUaB#V61GZ#__;-Ql zn97wsg8h#mJL89Y`SOth5dZBGa83b?-+^}?mswcOz+~X^cbL9|rT<88KeNVu=E&P} zZo@bbF9J;lVzJ6%*qtJw)|IgtKVRgQ!+O4=8%JIUX^ZJMfkz9~!mrQgv0N?r_R>Py zlT?*-C8+iM0yzDHfZI>ji+90?cOPgs_%8ro7Z;E2j{<;y(D*;&XTaUZ%Z2ey9bxGh z)ZO48#Kpk6wgR~OJ2wP@<GVst0V#ktygIJ=czYk*l+|^y4`u86;C}xO`0GyqaP$d~ zYrt(4z<P0m{|E1&U!1uB?(`o4=U)PH4R8Sv@CN@CRyGRY?kIrp|9b^6eg@oe0lZN; z-4wyscFh>6ffxvaE*<5=_L1@%9>pL0a8{ZXgK)AUVO5@XaS)MoGm<H<Le*7$)d2XJ z;5`sPqb&e00lNi&->L?dpo&5S2!L0B*d>s+Kukcf0PaZ2e=)w4LmFtLPj&m&0x*Ln zk^>M4fD?cKKJH>QKJmP4HUQHBjMu>Z{Y|XOZL=Fd_yk}8JOkQ2@Y+5ZbR0M1B2sg! z9LL$HZvdMAcmTWwmYuf%{729mXsCpAG$)Yn`eCjQKs*4R0scn7^&iHdUJ0b3tN5LO z!2t*a(9Zx)fWbom4T#))>!*JXKqvs-0=NMf0VJRdGIBKYZlC@UK*&D>-~{j@h!J1} z=R+g}hM*sR|L%W}1i&)@AOI`C6X*v49wH$a|E}Nnp92sH0B{04ftSV=oJCTao)_pJ z{f`3>y#=5Et^g_!X{mmwpBKO#{=)(A8h~S<Cm@o80;nJU$17kw0FD3~PzJeq1=P>| zcTVvFxB*B25s2J$QCs)_cmtf@03;w*VFUd8pAUc+!Qv~R4Ax+KwEyToUH}siYv9`t z{XYNnAHwyI2^h*?4Vo#FHq8HY07#%XttR3zD2e}vCP>va%zvT(XaS6X4e&eWMWg{b zT+-kl8tH$!04BiWz+WN_&|zPA5c5a>6HtG9h&6#j`u|%3c&dV>=-LAMBLx)ysb~$- zL+i9p|I-PO8kJat64oDI0jKDd`bAp-{gDL3;=rRKcuGzkRq%ZLl&27$hm#OO2q8p( zFY2vgXTcb8>i_@%07*qoM6N<$f>28X1QY-O00;ouiZfSI7GDJhBLD!unE(Je0000( zZ*FvDZgekDVQX_QS7~l!Z+CMqR%vW=Z){X$b97B_WJY0QbZ>HbM`3McEmvu7WN&wK zE^uLM?L7&2RJGQb?k$v-wm=J&LIF$J%2Ku>TT3@AZS8`{VwrX>Wn?;2W~P*)BFHK# zi;5^BAc!m?3aABrD4>W>@E1W5MWF}^K2R3fWRXATPI8-@$(>Gl_@3YY_dt5@<Rm92 z`^m{kE<z5N8mfK*9Nj#_)_&doy));0@yzMB$35vgE!sy$oLu_Y_=NPge(Abk^K9R# zy_yAMKOJ`cvAgC8Aq+d<um5`^g4S-Vs9ZBG_s2O8PyO}Q^iv^M?z@zFE3Qxe>mQ)^ zD|-eW9JA}a!Qn6LdpTiR-i7c+PmCD&QRCk>9y4zFa`i9!*S~scR?74bD-TB=crt0& zY|j<(Z4y=_ymWfqyT3gU-D83Gr>4R8cx}6UYWv7Hj%1`+&C<k;)6;yicbBEa_j@w> zdRo6%7SA1Mne@ZlhOe}m@kfJIr&lNbzG3LF`!-JYS@G66li|4@m)kYzX4vw=sje&A z4a&K4G~=<rFYey*+~IAd_e~x5arx2vUs@k@{o=#Ta-JxfIA!0(s!v|H8Xp=xam!<! zJv+Bru<v@{_ys@v7e*exFL++-lbgK!9_YCA`tE1uFGw6YtvGYUYdOJlvf>X1dcDy; z;c@f3hsU*xj+#03ldm!!eyttaG`+I<yKm@T475DD#BgqI{<{5*1OI96Klk*Z!skmz z4jP<r_1m`-miz2^y#M>hU*56$+pkKuo36Z{JGLNT>xDP&-ZMi#^16NgYSUwd<A2C$ z95M9p{E$h%Jbm0SIXSkqpVtqMR5ZKsP-x-mCS$j+-~Z{<1DE~dEn5>a&JOQ$bWz&c zyDz?Yx5@lK<m}O5ReK&g^3j+5Hm)^9l}<U)>xn@BjqCHm6Z@{pnEmqT3wuAjSwGnK z>rYSi{BiUC<l!IIo0m7a;9`TEgZVEeH+b#kn-4~Hcz5%I315VbIhzsC`@xDHqrx7_ zUwH&I!2kSF81hC<kgxpoMd7Hq{AB++FpW{9{ER?R^0OWa#m^A@48pin94ZtAqxzUu zZ~PXB|J6eQIE4`WHyAa<{_wjIe)pYyRZtx;x9-Lrio3f@vEov!xVvxM-Q8NOxVyVk z+}(;hY~0;8QsnU8^Kj3ZxlcD)nU%?`e3O@CR<gdy8e!qJFPjB6rrlCy`u!aGlBx^j zN?F@Wm>QC7OtNH1{8260n2p4#1VR110+>?e-2s&5II-i#*NhvKkW~x$+C6E>af~FN zQ1U^>)tVPq1&d2Qzp#zPA%mjuL{vVi#jwihtNJ;>-(p#%R?tEi<q3&Qp^gG0Ltl=V zqM?;A#BgANEkuRAdO#q(m@0i@o~iG^lEBu+k)@2m;UNu6cGaRK4+|&B5*18^glf;s z*q~b_KJ3;PEmqcwCFrR(dbMaK>ASb!wEI0&Ma9gpu+1|LnE0(ui=GkrCTYR7LrsMk z+9gF-!?Lo@*icHly^oC9HKTx80Z-kkNhT#hB}$uP-7Zq|4@gMkIbKtl0sByk$zAH( z7)++g9Pau;wIH!-{Vr*G8k}x<w{%1CI_$~C3sYk`1*Ya4bU7dS$dzpu_D3A0Mas@= zaz?a-2+O)PeR7q1A<$He7XxmWmpoA|_>Eee@7<Ib$||`iGfK`3R&U+;j~%s_%Iu0j zA#mysf$aTKWDs{IFk<E0VN`o)=IIL>hgV<L_xx{O{w&k-@PY%|m;Ee}lZK#`K4iE) z9iwH84$E^LcF%xwUwmI1RMMaNf`=Z2=a=UGP=+XJPwXqrX4h;V+`#L4qHcC~W8`k) zRDad;{`9Sj`m^5G@P?njT`BYzfRejERg5{6LvJoghsin9N>}(M!8x~)=C4hSeX`4t zO{4RM`pn;(cPn;7(87b49_JWN`6b3YFdgYDQzMu7=X{i2mJ+{Kz0iQPxImpMYH!T( z#uS+{*=2(p!4B70DLd16Bei3ymSQ|}tmAzF$w4wNpybWXrq9shr7{xVq$5U%H@TN* z3Dbj^{zl%Q>%IbTCa~W8CrB@Ry{&7KLEAJ=AZ?3;eGwijWWTR_DQO`@4LP9{df`v? z9PvME)o7f=$wkGuq~lq3VwLKbx%xldc8jV`rNEHrUNz`>RoZ6<u}dx4^f3T5d-nRz zTzZ*sfl81qVaWR8MZEOTUMY~6D*1<b2#}?pQrlI|)|TnVY^H5O=EX1Kf2Nm~JCKxs z<{FO?0gRA+1ia!>S{&dHOe)4x9h)EHlf)r>2|-1e_|m(hfy?R0KlDd?=dt-&&)ehs zXmhqZ5}yR6vvT%5SkF(t-qU4+sEDhtnS{GIpYTPV5GsRmIb;2)My3J%imbRhLAkd5 z(`+p7mi<yTC_=*+?Zrf!sE~YJ2!7Sqwrz4)`-O}$>*`)|JIA0xWfDyNP>biZ>b{XY zf~U0U*{PXr(?3zyOr)&v<CssQ11u072Sma)tuJ0tg~BQ#XvenXzFpfCBooW-F}Lgs zN<z8LuJQy2jhhmlDZl;neAjX>AcbCxJbo^?VUH}+vt&!voymsA`LDph&z;E6dGPp8 zP+8$%L%TsA$qbY1<589<Wg(L+_H@Z;k#eLwwZfl?hKk`uiEZSa$wH4E61YO)wLeI| zR1;ri7<b96h^W|e&BBm#{#=lecO|!Fvts0$wUZtv8$xME`PJ)_OL%~^=R$dY=~3uA z@bioAKAlZzojhLqi~?nyk95cu4f3WVg;A>2^?GzZp$rZ#8vnTV*D4+aBs=5SLX>Y| z#TUtN$7tu6+abAsx^8#+ZY8UAfo42^g<ka@y<GAt$v7#NYgkj9sXK^q5(*)q*3dZd zqTLIJs(8$FCZF5rL!vbVR&}eihEFmnSDDN-Ith?M5i3LZ%0fN{jA+D>{UCka2Zey5 zUZhxrzU<%J+AacE@+YEzgRxc@DF$6`XDK-3cqI~u8eU8xZ9BLao-~U~MuD12$WQ1W zSbcdGn`}FS*BbKSwv70;VDO7A53x;93IFv{1B7t@SIl{EU{ESVTB1vxu;*Uq7~n4F zhe!A+kMAMfWZf^Es9(o_7?kRkbzO`i%{gr>U*>&iAZ12=V5*<Oz9A>wh%n|y<#a$A zM`Bbp%`D!>z8UFg)T+%+LVTS&z*c&wz_9CPTo7+88#vEbR!aKr6x06lC=+}lE8Y`h zV#sg-Ul6;O+U2_onU)17V|s5!<0A?|-FOx7N398nu5<5d=z57W2J5;sl~;p_oX+-! zr1WPzo|{fcg<-C%=ah_R^`*ec6GQyZ!fFhWk20z#+BTY=u@V=S<y){4v?I!1i2gRY ze;|@T(-T=u-{%H=f(?FBitWtB$vKokQk;j*^E=`@`86Z(1wBP{Z`8xWBWSMc*9nM> z7y>;gS!init&QOL3@;<8299xq&3{?O`#QAAA%2S!nJH<7_A@UPVt@Cf%(|QL(`;YJ z?`A=@r!@#m*Tr8q2q##pq=9}Gi7G)`uJ^RV=$rM3ooQ-ig=D{p8H#C;GyAbl^HAR> zzKBcWyg+N+MP4B}_-AmE(eg3bZ1Jc2g%{JJ)jGYyK?ci=<%dN)_rQGpFf``FzF)}^ zifto$t*tX94~oB;pEE_fpVqrOd-?pxBctCxgb2;D9je0~>`9o@!ge8&rid44JT<?3 z13dZ&(x~hfOFy08;<N8;RDn=3eHh@rf7#)lA~TVBh^6-)zWk;`EeuVcSeUTgJCOMS zvo88~{pYiJVzDI=NOF?Jv6HW<$8vGsPwInDbWr)oPJ>vFLWB>DuQSZriNsJFUTu=J zbg{6kWC+Y8ZVuQVrsb0PIuqB5yqAWr8cqcF19(OlmX*~x6t*Fb`Fiy4_ok!nrLuA! zLbi?5-3`0}nF)9L%%zt&rW*Sgi1*aBXam$q5U(4m8p^F6myxB-=4zzy(mNOpY%;#R z=ltT}*+6=QqKk}QvH+IUo2(LT2)0gDRd)AM)@jYpBcYAc8x#yp?(}+viFP=L3_#rz z*WaEt@ugZ8hp@~@m40zuD(=^$6DMur!76ivV<y@5i0+wyA$f8*h72It6O9rNLNuDf z6W~-CM2L)+d#8ZDKXK>Ev|tustc$#El54(B`cHo*@>(>w$w(F-5Xw7~qMXOEYR2K# zTP6adu|mClMCuWU&1C$eJ(yV9=9*uNtd6BJs5>_PTo0j&j9KhmK-!;7-_wBlWWa#{ zY`B4G^jNT0Y3L0+Xe=LS@6sn~z5(r5a9xeU`!5wXCUNMVNS}f(p`me3h$gC<5ptN3 zz}aR7+2N_3KQIv9x*?U*F4Eiz9Elf1|Bv)-p{o4Klg$OJFM$oXFV${+Y$hZX&z@zq z!J4aK2wXKEL7#!#8s;1`d4QJtt3ts6M=*;tTbt*%&ETh_1|40<E9SrN?VCZg5lkD} zYqht1I{~NC0(mE>gAeZtI8%0MU_rGn)PN<VgT7eX)+Ok``>1L~W(i3xKuHQd%JBoc zY7S)PRR2DLw<<n3W!YpEC$n=tgUcNGkGee1(J^D4whlVzr-Xz9lOPgfWItz@T^R_- zNu|xSM+KF(USMYR*o9c3XYmhIRPXIlZ(^VuZ%<+>x-JY)Oi+l5l9a^zeF)V&M8x-M zgLZvMEEz(;x!fGj&YhFy{-ja~b+KyfY?~#(;4d1m>nfRHrh5Z5reAxS$=2DNi-4+A zphXMicz}EQAhhmD0D%yGPwcy4brcBU40T!i<+ZPgmJm^6{Fqdc`N5t_1gL|I@naMO z#w<+=qSpIioiG%NO#y3WBi0Zzq@Al36inm&FX)wd*;57FTwhlt%VWwfT1ZUL)^C^r zvSl-_<TJgC$rX8NI3NKzkXE!1kdtY#7k0Nm+KVZFlgp5a7xwRSsN+W@)p9jUHpLDt zT%ly*N6aJTMO+96z27B@lmSO=AFPF{RC@6E)a_MjA`?aZ#Z8PQGHjqbY=?%4c=RIv zz=btWTanwq0RzI~|5}crj6zT!9wSUEzM~>L>7{RaOcF;;^`ki9dxw1P6#wxXjj7X^ zEMcfV;5hM~-w%{KGsn7Yd+tEub_p8h>k{>-m@?Op!d~DNDlvu#)X4J3CAXT5Emk;! ztFzV;K2P}K@6xWdI+`xLCh?=-;f(yMjcL=~jjr&5esVO0OViV1N$KQZYyCrK=u^C# z9polTW~Uk*blTrXv8wFHHmWUx_Geo<Wss4HKBs$8^XhBd87kAuTYOvL60N7p7by-; zOj#(C<x`0KIWJN_5p$Dt$<X*l4o}adD%o`WSUR7s0gnp-cKWe8r`MG{3VLwkwMlAo zlaAx&G72pjZ#;kX?yZMm$KxXHtofh}NE*u!NQ*N1Q%V)^h_D)%4`w#9Fu$$cpJQ8s zPY&led@Q&gvNvy2ApXv3Ew&1-Yoz6We)mH-6*mUC&O1i6`at7W2g?W|89w39hXW?B zW+!&=n<!Hn;3F<F-m%=3qJH!>T(fc}6_ZWVC2t<|zU${9Oi>d-b}aU_JWL{lQWE`K zZ550$Lrt5YzkUiZ_SMCGGGyz{MtYTrF4f4c`Wst<5J_1FDiZO~TI2Bi;zB2~1#LM} zgtk<Gl~+#bOa!xyHT>un1ouu?tK+HR!PIZ+gPH2tNqT@mdII_JwUiL{OfE27?%5T0 z+lS3Ff~`8{injOB<XRBs34}~i#r6DxW_AmwaqauQ4bQqo({z1alL@c59*UFmVzom* zt@E@LTnCl@I?~bm(RWhfC6J_u3n3KW=YhRViSNq;A@pkpt*SsfnUSkiWbg-RZ?0C_ zoy}MDIzDSs1&?ae+nAqWY=HfE@LnU=j1;n>e>4}@CS$%2NgR&dKj!)=He$H`P0o4i z$!odiQXg0gc)veaKA2PPk(u`=@6oj4q~L_!E8cv?b<`vjeSeTFkH2+bO4bgN><9Gf z*E~B`oGVVH7fR@Rx8QcWfh3e-G#{tHf9S#oF)F)PBTczZ_P2^7yeUHG$w6D}Dnjwd zerx_>ZEj6CGfolJh8}<yxF$oo2}~ei|L=R^c2X!G>!Y9O=y<-O#F{%twJUFu{ZDb6 zA7rk_k_b)4YyN`x!j?Wwo3rgj7lY!xxKDj^DE{JIGkiDH2htO9{iH>hv$VZ%jfGoj zhNtUq=b++RR-1?2`3`Wdf*J~&tEuX0)Qzck7$%0nO0|}ew%VY<$_fG}KV(c4Ms77X z=@fBJiB8p%W7Uiuy}zkKDWXKsCMyi@cSM!dkwx~PvZEi_cjje?ugz&;r?s_V_dxJ> zE0xAk)p<)Hy(j`T1mbjp8y_!M;F8nWtoIzz^ZVlH2S_Sh%B(6?Xl?#9>W`gOI;?Z( z@jGKrWf|a;NrHUs@e8tCfZb9DVGif2lTjA`AosQ7xW(Mfz*#-}-qp2w+(UaIC%E-| zccGcQa1W!yjfkW~Jp={16V|GJcLJuWk*F%92M0EuL^>Bx_;)?`X6!C8qi5|Vq*^yX zTDm<xpiJ^j_={tCnKO|m+*^Q)<Ok_haSr;eFHs1|Qv`x7cPyvizAi}Ee>6I;dpY(} z;1w!6NoyTTvyQCkmP~+>{i3q_?|>AN;fUPO=|?v9LDmwUWE2K<DXQPXa2F+7A5bYF z)J<(jOE`EbYyIma@sxeL5@C7PTkM45h;Rj0k~o!1`d&;CFw{pp0TH+fW9_~-M*KnS zRzw(M>@zy{%*LZ?UyoCx+~17a%wN-MgEXM_qt|+Tb~*sl)hETbDqJay4EHt<HoN1m zDW@9@OhFWZl4#WG-NyWpXbRoMS55A2sKm&){Yuj5+@0YR3A=|7t~7+mM{Le}V>Okk zX}O`Qq>~W@nsYVg{t&Xw8JPFZVJj3qG{b!?fWW)QB`3n~o;+hcyul*UT``)VCu2x~ zWHe(@OmgX5E?%JB(09*xKh3Ww=?bA1F=!G`0Neu7>#b3kcZO1<4oMtkSF<@Sqs|cp z1qvfv_0F4|*hV`fGb}PkHGHGQ%;5+S<eoSV8EG8q{x23(hc5#n#1@8d%YZt?z*>KO z|LT9`GH)mY!;clVm@Zw9Z)b7}&YX+;KcnxB9x5w$IuUzr-3|J^99Pv<B04>-$;lH9 z2pZ0qg7XvuAFAKBwC_hIzIymb27G9TBzCK6nz@%Nj{_iCXmLi&c<(#OlQ~kHj!;tL z@4~kY$+U`Az$87FUYDy?s}Y8lSB*9S26oeg=AHGJQGD>&rfXd=M<^q0ZlJhC4kI-N zd|=Z~%nhQ~vit4^kEuE&Oz3DLjYbqEDeVg5M`B}7;e8K_FsVVuw~Y(0wsP+jbwiU- z&<Q$eO-A0BpeNmy{WmE1QamT|J9iQBJP1af+;7K+H{t;$!VQS94)$>ieEy>(hWDS5 zlHa(um~-m({jZh3NpDA>LZG3z*QXskdP_zKPk<X?^|x*Nhc}YkTLlohuIEZ4MJU%S zkI*ZQc{W4y{4IEl2CtiYt1F8~nj0JYWsr(3s5stZA;p$?;LhrxwWzIDh)_A<?^f&Q zy?xHwr6x}SC>Ju1#fpHd2y?1X`wjLBYrQ$p?)2k*R??%9NX*x-UuFa@VeXuS4_~*W zCIcx6qjvfzqn}z#;P@dc6<MAyE8U;18hteVON4ct6{L3S`HO3|cN`?;f{)(Pz|acG z$oxW-1ibE=mn+Z0C<DB9gf09gU9j^?4XgImqkoK0XEO&*n}f}yZoik8O|l%|{#Y_; z1^;#8M0swymkCv_#6v?6r>;aHw8)$5?e`rS^L@YNZ<^z-2^j~YP`T|0<{Xb+k#=6q zomO{4m1C_|KncQ%H*c(CH)zBOKp-b-b@O%2<#nh6GW~-wwtp%2WMQt&i58dJLw!H2 zV=d_@j0hsqsym1XN($aY9}ai_mul;-6|t?7Qssq1r~NF}hsC(h<}f4}6@+X1YBgPV zjM8w<d6237TSc*TLJ^$RG2`<sN#c*X3S{iDZ~*0vYX5;SfeB;}(U^fbm#NJx2SRm| z)HHhSAUTyT_f}Red8Kv*tNQoc+*MVl4%mS0se{%wC*#^L$sXz2CE?y%FE_OLVcWzw zvYP@KI({!$I$i~{K!&E{>P7eB<JGI$e+yI{?Lv|-SGhRq__6fVZM#!}5HZ@wKAw0} z)1I~aSEg~Ww=5oJ)Te5-4@`0B$;jHQwtkQq;S8kc5W>Js5WPCtfziUO`D|BA$+UaJ zaC_$ZS$FR$V;>V>CSDn?9?VVQ>wx=&lqHw~ujn<~-w4*C5U^3C?r(7nf^$<x!}VNI zy`t`Y1l~@sVJh?28_2z~1V2@wU_H!#+8TY@veNdqV9%TmBq?f&zWQ)3_;LCh!hWWY zcj(*J_9;3Wtl3WK1zD8-)y8od0gWiudAHNmJ<?NM^+dWq!}QhwPE<m2>S4H;izGB_ z8oZ;Zat=xamCJgU!b%l2m#*Kby%ddO0`){Fd5#+eW&~ep?AInZokE1v&-(v8?)#Nz z-k0Z{?gaaX2EJ4ATsTo|=548o1eA@6hy#@EXB=qqwvsO#S;*E<UX+7h?0QN5dO+Ag zKOn6Uc?wUgcGQDSkT#1*DeG_x*YxXj5vlf&9j2QZUcnb_$G0(ST+LrrTu^pm>@MpB zQ{h=K`I+%r1b*F8#g%c3XrYmr5_j1x=9bMH3%~?EEs&t@o=NL@&(kzt6mT2mgyQ(Y zW!!J(cFq&ZT6N``4O6w-iJp}U(d+8eU^V<C_$>tCAJ8tb;V=&>=Y3Gy4=xk@UBcq+ zy9v2iB>Jzm-~bWGB$FN2%fVkDqWrX|<l6L8$5~${!fR%>WFz>tP$`0-;3^5rEC>t? zFkc8{Yho9@ZQ6NZ6Z{&8A9kYuhcmz^1-AX0#>c3A(J?Qq*O_$vTC_D*V_nC9N5j0c z?bwCCRjj4)1~^Uiq9N$XV-U;hODct3tH|-UqZLs|sILS>R&W-q>h6@D;w8B4GMkm| z3xYOMn~k5!T52<9JATk#P!-<|oj5(OQ0?QUBDFG;f~+@CVL&?3eVd-IbR~u}xU%{+ zX?x~T2mS1Uj2IKmId#}angp^#PzTl2F+47}%F#Lf(<kT6CkoEoy};6qaBXpIAO6f- zm*`cXOzx`7N?S{?dTmtE>~+zu8tBt!Jd_-gEjr?gq0LxpI(MH>9{l_TLhdKlbr%wz zB@=Fa#MTy*Lry{GbAy*^7`%}f?=24aaVj%{&cWXnq(%;z_9eDc;??gi{JYnk#a#)a zXyT3LEzY(%=+dzz0%+Qq)tR?$VOhUZ&h-|YbyOTyH9{m=@KuNz*IiZv=D@G<yzgy` zsLpyLgSz_k!z<X{LunndxU3VV^To1WB^ODnrCJltP3b>Uv+c%FI78bD$}Fx`G{AUN z{YQGg$<1ZMRXKf~K+bjf0R^Eo*#6>OW(x;6d%q)i1ZeJltA)5>#od6?0|y^HiC1c% z88}|8p%RbtWR)a9`IxL?XW{jT8>k9~TOGO3W{OCr9qy&cloJC+^Ppsz%siv4s+lSB zxy>OqmO3p*2nXTnq$uf$CVI~P0d@~os5h{<=g4&5iZi3?5B{JFb^N;RS$zYHYEkdQ zqPjj6uN+>UTiDnh^(&0o1q5PU9LI5=asP4N6d>9zsW*<fupjCEo$~R?i^+h4RD-`A z(_5f=RtYQ#D`1e1Q5-6mJCc&$orW8oKuG8>9-(!uDVCs2iq>!*a0i)fQ>)E%|GJDc zyE;N~34$ZG3q=w*r*AksR5QdKr{ks6-#&TkeHEh%mdV|u$fxl6O5>+tJd&HfKjed+ zBPd4J-zcd-A<zLs*AIu}Y4vvjtwRD}g9m8mnNu^WAB+7s=4R$T(FdqKK>gc&`~v*W zEPsB2??>|KcKqc^AVs_<YK`52GJ=xH6@th(l6$dpI`*jM0m`lLIy^AyZw1_xfKE1` zHuDxa8gcz_f;W+i!}jva!_6K3!qCww4yECJ>CUn+kw0>Kt}QH!endYy8FId4oguTi zJ@6QLYCnl&C4PKEM|7K5|9lnwZwY{67_0h`3sB?|zOlPpE=Dsv&RY8S&s6?3fZ&U7 z_wd7~OL`Q=k_QPeZHl4-*-M%L(iyO2af}Ch(z0(6ssiY^-z)ovL%5RzRG+8iS-a$8 zxV0$7HQ9UzU*tU3*zC|0WYEOizJbv`WYqv<!?c+bKa$cO{qAl7ad(NyVhM%AaM^mR z8)N+B<llH|jegFCBH`e?4CF9+!X(JEYu_&-y_{A4-srSbhx%zrEwds-jFRSfqrBrJ zE?p08Pc-_6fLVjGgv9Ceg4N6oTHC2`6ReLUu5QS#VlP6sa5R;A^?fuka`+IRno+0j z;)vrJ94cV?E6D;P${-P#I<reMbYbSckD=Yxc{1Wmu<s*D=YIOI`4K)Y?y1la5l%9A z^KGNmwreqVk=&b~`?2h22xTbDKAg^$TR^u~RDY9yH|KUr_(oCiT-CosmzlD{O4e7Y z?(O~YP!Kb7WCy8T``d5M%@UH5bcQ@kvw<kPv&!?mRf54MMHSFhd3n86k&s&j5RXfK zOgr!Sgl16!t8EciSwMKL6RRR(Z#%mBNVAgyuAL*(pwjm0Tk~s4qVIJf-;E}i#;&kE z5huDkq*?js2A7x6fdq|vpILvq&%P!Z>9sZsMPN~}33%M-A*3QG&uMB38iRRfvVfZ2 z>#K-aGlo*yl;JP&)gpAOu&|oGo?a_c6_key_m3uf;}y;LydE3U^fzki{JgFbk`J|b zu%ZyC^ugH4MDo0tY$65!)q3fosfa(On~|!&m6m^@1B*-XNfwG+K@>f540C|n?I1S_ z<u4?(lTjT^6+bCb@D1T)5gpGD_ugE`9e}*ghr7{fbrt(<IH%(ivkc7&%)P4!=urxU z&vR%1D%C$EJVpoPsChWHM=u<ZGxu>TkB@%1<dI)80XspVk7tu`qFu-mT_J8YtMZUg zP_h``*<c&yxJE%B6HoWtVNs^i5;OnJ>e#<RyE@N%24$|HEwG`aUAv;xbn?CA9_<kC z&Sc(9k-N^Cd#E)hgP<`-ZK`CIAF?UU>>*v@Rpi%ff?Zj5Aq14zW;rcd5HsR^mqPX~ z(T6q!TxxR+Cf$A{am&#VWzu#Fk_-dY>MyG!|Mywm?vA&$L_##wxhox^Ml(Z^H*hCZ zKz!&rXQSzL(XAk>A}b4gyYGdksJF?Oz=-_k_4HlN4On`r|4J3nT9HQ|S4*o|9j(^Q zrw7xB{Vc7&IEr^rXs^yT9*^W*NrGRdcc>jUm*itp!O)Q8V^A>+WL&0HlQ?2rMpVl; z9`DPom>r7j^Tghmkxsf(S5L&2aL3N5Mov(-z)|zCrt9bsKKHG<VL5Sm`aHtUGMOK# zo<vA_O})z>=w-LyEicep!hN3)FLf`BO$7PZ0}d$?sR>}uWsXLO=BoMGaZyF6QGG7n zTXIgFg?&kP_ABAK2L5=Qq(*F&`Wfyt=U=rTT>FKm_uWyX>aAh{a2J6FV0r6y$6Lf! zHRtcIYubuK_WHcUJv^glW?OY`zW<(|y0qPI`y_q~{9DC%HDEj4!B(Co_}kwX9tf^q z#t9HKXZJ0A2x3Mre3Wu)bKv(k3@DeGSA69D){@G}^n6`BBrvQ+MB9Q=)^DqdpW^89 z85nYB;K!emY@6_*b4mJrD=QUgnKwnV>QZDv3A(H}R<m@S<ZmXsyn?qL@o8}4@WVsc zuPydq7~m)erj8_eFXqe*s;p|s39+Jz42YI5SAs(wA7@-{0Gu1X7_pvWt<<4X<I)d@ zW&H`hUij4UlG0xk$siu+Yvmv;dCOKl=YRS8y?^XqB<IHW|Jd`EU4<jdx+0LL29PB? z&<Ama0&buoX8`?pkdwD!`SFM%Rw9fL1cR8CBBoBkrsOF*Uuu%@gbBvz>cNviEDwcu zrXE>mo-e5+_!b5q=M%rb-+U-s_bACiKw<&@n_jc{Nv|=sdiDf=(rQj1008Vy{lClq z;?=OYIoi5eSlRzih)6SOHB_fju3!NOfXiq5-w^blpeklA4sOn-W-hEUrVjS(9K0-! o_7?vW;{QeR`M;|G2}1n;Q+||WVPO9Q1@&1kJ~hAb=YjzL1+QCWVE_OC literal 0 HcmV?d00001 diff --git a/tests/sml_versions_test.go b/tests/sml_versions_test.go new file mode 100644 index 00000000..0bb5e80c --- /dev/null +++ b/tests/sml_versions_test.go @@ -0,0 +1,252 @@ +package tests + +import ( + "strconv" + "testing" + "time" + + "github.com/MarvinJWendt/testza" + + "github.com/satisfactorymodding/smr-api/config" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/migrations" +) + +func init() { + migrations.SetMigrationDir("../migrations") + config.SetConfigDir("../") + postgres.EnableDebug() + db.EnableDebug() +} + +func TestSMLVersions(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + token, _, err := makeUser(ctx) + testza.AssertNoError(t, err) + + secondaryVersions := [2]string{ + "2.3.4", + "3.4.5", + } + + // Run Twice to detect any cache issues + for i := 0; i < 2; i++ { + t.Run(strconv.Itoa(i), func(t *testing.T) { + var objID string + + t.Run("Create", func(t *testing.T) { + createRequest := authRequest(`mutation { + createSMLVersion(smlVersion: { + version: "1.2.3", + satisfactory_version: 123, + stability: release, + link: "https://google.com", + targets: [ + { + targetName: Windows, + link: "https://this-is-windows.com" + }, + { + targetName: WindowsServer, + link: "https://this-is-windows-server.com" + }, + { + targetName: LinuxServer, + link: "https://this-is-linux-server.com" + } + ], + changelog: "Hello World", + date: "2023-10-27T01:00:51+00:00", + bootstrap_version: "0.0.0", + engine_version: "5.1" + }) { + id + } + }`, token) + + var createResponse struct { + CreateSMLVersion generated.SMLVersion + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + + testza.AssertNotEqual(t, "", createResponse.CreateSMLVersion.ID) + + objID = createResponse.CreateSMLVersion.ID + }) + + t.Run("Query One", func(t *testing.T) { + queryRequest := authRequest(`query ($id: SMLVersionID!) { + getSMLVersion(smlVersionID: $id) { + id + version + satisfactory_version + stability + link + targets { + targetName + link + } + changelog + date + bootstrap_version + engine_version + } + }`, token) + queryRequest.Var("id", objID) + + var queryResponse struct { + GetSMLVersion generated.SMLVersion + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + + testza.AssertEqual(t, objID, queryResponse.GetSMLVersion.ID) + testza.AssertEqual(t, "1.2.3", queryResponse.GetSMLVersion.Version) + testza.AssertEqual(t, 123, queryResponse.GetSMLVersion.SatisfactoryVersion) + testza.AssertEqual(t, generated.VersionStabilitiesRelease, queryResponse.GetSMLVersion.Stability) + testza.AssertEqual(t, "https://google.com", queryResponse.GetSMLVersion.Link) + testza.AssertEqual(t, "Hello World", queryResponse.GetSMLVersion.Changelog) + testza.AssertEqual(t, "0.0.0", *queryResponse.GetSMLVersion.BootstrapVersion) + testza.AssertEqual(t, "5.1", queryResponse.GetSMLVersion.EngineVersion) + + date, err := time.Parse(time.RFC3339, queryResponse.GetSMLVersion.Date) + testza.AssertNoError(t, err) + + realDate, _ := time.Parse(time.RFC3339, "2023-10-27T01:00:51+00:00") + testza.AssertEqual(t, realDate.Unix(), date.Unix()) + + testza.AssertEqual(t, []*generated.SMLVersionTarget{ + { + TargetName: generated.TargetNameWindows, + Link: "https://this-is-windows.com", + }, + { + TargetName: generated.TargetNameWindowsServer, + Link: "https://this-is-windows-server.com", + }, + { + TargetName: generated.TargetNameLinuxServer, + Link: "https://this-is-linux-server.com", + }, + }, queryResponse.GetSMLVersion.Targets) + }) + + t.Run("Update", func(t *testing.T) { + updateRequest := authRequest(`mutation ($id: SMLVersionID!, $version: String!) { + updateSMLVersion( + smlVersionId: $id, + smlVersion: { + version: $version, + satisfactory_version: 234, + stability: alpha, + link: "https://ficsit.app", + targets: [ + { + targetName: Windows, + link: "https://this-is-windows-2.com" + }, + { + targetName: WindowsServer, + link: "https://this-is-windows-server-2.com" + }, + { + targetName: LinuxServer, + link: "https://this-is-linux-server-2.com" + } + ], + changelog: "Foo Bar", + date: "2000-10-27T01:00:51+00:00", + bootstrap_version: "0.0.0", + engine_version: "5.2" + } + ) { + id + } + }`, token) + updateRequest.Var("id", objID) + updateRequest.Var("version", secondaryVersions[i]) + + var updateResponse struct { + UpdateSMLVersion generated.SMLVersion + } + testza.AssertNoError(t, client.Run(ctx, updateRequest, &updateResponse)) + }) + + t.Run("Query Many", func(t *testing.T) { + queryRequest := authRequest(`{ + getSMLVersions { + count + sml_versions { + id + version + satisfactory_version + stability + link + targets { + targetName + link + } + changelog + date + bootstrap_version + engine_version + } + } + }`, token) + + var queryResponse struct { + GetSMLVersions generated.GetSMLVersions + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + + testza.AssertEqual(t, 1, queryResponse.GetSMLVersions.Count) + testza.AssertEqual(t, objID, queryResponse.GetSMLVersions.SmlVersions[0].ID) + testza.AssertEqual(t, secondaryVersions[i], queryResponse.GetSMLVersions.SmlVersions[0].Version) + testza.AssertEqual(t, 234, queryResponse.GetSMLVersions.SmlVersions[0].SatisfactoryVersion) + testza.AssertEqual(t, generated.VersionStabilitiesAlpha, queryResponse.GetSMLVersions.SmlVersions[0].Stability) + testza.AssertEqual(t, "https://ficsit.app", queryResponse.GetSMLVersions.SmlVersions[0].Link) + testza.AssertEqual(t, "Foo Bar", queryResponse.GetSMLVersions.SmlVersions[0].Changelog) + testza.AssertEqual(t, "0.0.0", *queryResponse.GetSMLVersions.SmlVersions[0].BootstrapVersion) + testza.AssertEqual(t, "5.2", queryResponse.GetSMLVersions.SmlVersions[0].EngineVersion) + + date, err := time.Parse(time.RFC3339, queryResponse.GetSMLVersions.SmlVersions[0].Date) + testza.AssertNoError(t, err) + + realDate, _ := time.Parse(time.RFC3339, "2000-10-27T01:00:51+00:00") + testza.AssertEqual(t, realDate.Unix(), date.Unix()) + + testza.AssertEqual(t, []*generated.SMLVersionTarget{ + { + TargetName: generated.TargetNameWindows, + Link: "https://this-is-windows-2.com", + }, + { + TargetName: generated.TargetNameWindowsServer, + Link: "https://this-is-windows-server-2.com", + }, + { + TargetName: generated.TargetNameLinuxServer, + Link: "https://this-is-linux-server-2.com", + }, + }, queryResponse.GetSMLVersions.SmlVersions[0].Targets) + }) + + t.Run("Delete", func(t *testing.T) { + deleteRequest := authRequest(`mutation ($id: SMLVersionID!) { + deleteSMLVersion(smlVersionId: $id) + }`, token) + deleteRequest.Var("id", objID) + + var deleteResponse struct { + DeleteSMLVersion bool + } + testza.AssertNoError(t, client.Run(ctx, deleteRequest, &deleteResponse)) + + testza.AssertTrue(t, deleteResponse.DeleteSMLVersion) + }) + }) + } +} diff --git a/tests/utils.go b/tests/utils.go index 8b40f4b2..760f7c6e 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -10,6 +10,7 @@ import ( smr "github.com/satisfactorymodding/smr-api/api" "github.com/satisfactorymodding/smr-api/auth" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/util" @@ -26,6 +27,7 @@ func setup() (context.Context, *graphql.Client, func()) { TableName string } + // TODO Replace with ENT err := postgres.DBCtx(ctx).Raw(`SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'`).Scan(&out).Error if err != nil { panic(err) @@ -54,52 +56,30 @@ func setup() (context.Context, *graphql.Client, func()) { } }() - return context.Background(), client, func() { + return ctx, client, func() { stopChannel <- true wg.Wait() } } func makeUser(ctx context.Context) (string, string, error) { - user := postgres.User{ - SMRModel: postgres.SMRModel{ - ID: util.GenerateUniqueID(), - }, - Email: "test_user@ficsit.app", - Username: "test_user", - } - - err := postgres.DBCtx(ctx).Create(&user).Error - if err != nil { - return "", "", err - } + user := db.From(ctx).User. + Create(). + SetEmail("test_user@ficsit.app"). + SetUsername("test_user"). + SaveX(ctx) slox.Info(ctx, "created fake test_user", slog.String("id", user.ID)) - userGroup := postgres.UserGroup{ - UserID: user.ID, - GroupID: auth.GroupAdmin.ID, - } - - err = postgres.DBCtx(ctx).Create(&userGroup).Error - if err != nil { - return "", "", err - } + db.From(ctx).UserGroup.Create().SetUser(user).SetGroupID(auth.GroupAdmin.ID).SaveX(ctx) slox.Info(ctx, "created user admin group") - session := postgres.UserSession{ - SMRModel: postgres.SMRModel{ - ID: util.GenerateUniqueID(), - }, - User: user, - Token: util.GenerateUserToken(), - } - - err = postgres.DBCtx(ctx).Create(&session).Error - if err != nil { - return "", "", err - } + session := db.From(ctx).UserSession. + Create(). + SetUser(user). + SetToken(util.GenerateUserToken()). + SaveX(ctx) slox.Info(ctx, "created fake user session", slog.String("token", session.Token)) diff --git a/tools.go b/tools.go index 8582e63b..6ed578f7 100644 --- a/tools.go +++ b/tools.go @@ -12,8 +12,9 @@ import ( // go generate -tags tools -x ./... //go:generate protoc -I./proto --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative proto/parser/parser.proto -//go:generate go run github.com/99designs/gqlgen generate -//go:generate go run github.com/swaggo/swag/cmd/swag init --generalInfo cmd/api/serve.go +//go:generate go run github.com/jmattheis/goverter/cmd/goverter@v1.0.0 gen -g wrapErrors -g ignoreUnexported ./conversion +//go:generate go run github.com/99designs/gqlgen@v0.17.39 generate +//go:generate go run github.com/swaggo/swag/cmd/swag@v1.16.2 init --generalInfo cmd/api/serve.go --output ./generated/docs //go:generate go run tools.go func main() { @@ -22,15 +23,13 @@ func main() { func generateEnt() { err := entc.Generate("./db/schema", &gen.Config{ - Target: "./ent", - Package: "github.com/satisfactorymodding/smr-api/ent", + Target: "./generated/ent", + Package: "github.com/satisfactorymodding/smr-api/generated/ent", Features: []gen.Feature{ - gen.FeatureLock, gen.FeatureModifier, - gen.FeatureUpsert, - gen.FeaturePrivacy, gen.FeatureIntercept, gen.FeatureSnapshot, + gen.FeatureExecQuery, }, IDType: &field.TypeInfo{ Type: field.TypeString, diff --git a/util/logging.go b/util/logging.go deleted file mode 100644 index 2360c4c8..00000000 --- a/util/logging.go +++ /dev/null @@ -1,12 +0,0 @@ -package util - -import ( - "context" - - "github.com/Vilsol/slox" -) - -// ReWrapCtx re-wraps the old logger but with a new context -func ReWrapCtx(ctx context.Context) context.Context { - return slox.Into(context.Background(), slox.From(ctx)) -} diff --git a/util/random.go b/util/random.go index 3ef66175..60233078 100644 --- a/util/random.go +++ b/util/random.go @@ -42,7 +42,7 @@ func GenerateUniqueID() string { PutUint48(result[:6], uint64(time.Now().UnixNano()/1e6)) - return string(base58.Encode(result)) + return base58.Encode(result) } func PutUint48(b []byte, v uint64) { From 4478f03282e86dae5c2288855169ebc1a78a4c79 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Sun, 29 Oct 2023 02:45:20 +0300 Subject: [PATCH 05/19] chore: fix pipeline --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa4a63b9..c4023ed0 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: run: go generate -tags tools -x ./... - name: Build - run: go build -v -o api-linux-amd64 . + run: go build -v -o api-linux-amd64 cmd/api/serve.go env: CGO_ENABLED: 1 From 47d105ec1ae71b469d460b4fafd8da7f17cf6759 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 19:50:04 +0200 Subject: [PATCH 06/19] refactor: move more stuff to ent --- .direnv/flake-profile | 1 + .direnv/flake-profile-1-link | 1 + .envrc | 2 +- conversion/ent_to_graphql.go | 114 ++ conversion/graphql.go | 40 - dataloader/LICENSE | 674 ---------- dataloader/loaders.go | 349 +++-- dataloader/userloader_gen.go | 210 --- dataloader/usermodloader_gen.go | 211 --- dataloader/versiondependencyloader_gen.go | 211 --- dataloader/versionloader_gen.go | 211 --- dataloader/versionloadernometa_gen.go | 211 --- db/postgres/guide.go | 197 --- db/postgres/postgres_types.go | 4 +- db/postgres/tags.go | 152 --- db/postgres/user_funcs.go | 101 -- db/postgres/utils.go | 4 - db/postgres/version.go | 25 - db/schema/guide.go | 7 +- db/schema/guide_tags.go | 6 +- db/schema/mod.go | 3 +- db/schema/user.go | 3 +- db/schema/version.go | 3 + db/schema/version_target.go | 44 + docker-compose-dev.yml | 5 +- flake.lock | 75 ++ flake.nix | 19 + generated/conv/guide.go | 56 + generated/conv/mod.go | 96 ++ generated/conv/sml_version.go | 24 - generated/conv/tag.go | 31 + generated/conv/user.go | 43 + generated/conv/user_mod.go | 32 + generated/conv/version.go | 64 + generated/conv/version_dependency.go | 33 + generated/ent/announcement_create.go | 441 +++++++ generated/ent/client.go | 190 ++- generated/ent/ent.go | 2 + generated/ent/guide.go | 23 +- generated/ent/guide/guide.go | 25 +- generated/ent/guide/where.go | 80 ++ generated/ent/guide_create.go | 638 ++++++++- generated/ent/guide_query.go | 22 +- generated/ent/guide_update.go | 74 +- generated/ent/guidetag.go | 16 +- generated/ent/guidetag/guidetag.go | 14 +- generated/ent/guidetag/where.go | 84 +- generated/ent/guidetag_create.go | 311 ++++- generated/ent/guidetag_query.go | 14 +- generated/ent/guidetag_update.go | 32 +- generated/ent/hook/hook.go | 12 + generated/ent/intercept/intercept.go | 30 + generated/ent/internal/schema.go | 2 +- generated/ent/migrate/schema.go | 45 +- generated/ent/mod_create.go | 1081 ++++++++++++++++ generated/ent/mod_query.go | 13 +- generated/ent/modtag_create.go | 293 +++++ generated/ent/mutation.go | 942 +++++++++++++- generated/ent/predicate/predicate.go | 3 + generated/ent/runtime/runtime.go | 30 +- generated/ent/smlversion_create.go | 721 +++++++++++ generated/ent/smlversiontarget_create.go | 375 ++++++ generated/ent/tag/tag.go | 2 +- generated/ent/tag_create.go | 401 ++++++ generated/ent/tx.go | 3 + generated/ent/user_create.go | 841 ++++++++++++ generated/ent/user_query.go | 13 +- generated/ent/usergroup_create.go | 441 +++++++ generated/ent/usermod_create.go | 333 +++++ generated/ent/usersession_create.go | 461 +++++++ generated/ent/version.go | 43 +- generated/ent/version/version.go | 49 +- generated/ent/version/where.go | 93 ++ generated/ent/version_create.go | 1210 +++++++++++++++++- generated/ent/version_query.go | 92 +- generated/ent/version_update.go | 187 ++- generated/ent/versiondependency_create.go | 485 +++++++ generated/ent/versiontarget.go | 178 +++ generated/ent/versiontarget/versiontarget.go | 108 ++ generated/ent/versiontarget/where.go | 427 ++++++ generated/ent/versiontarget_create.go | 767 +++++++++++ generated/ent/versiontarget_delete.go | 88 ++ generated/ent/versiontarget_query.go | 627 +++++++++ generated/ent/versiontarget_update.go | 410 ++++++ go.mod | 1 + go.sum | 2 + gql/directive.go | 58 +- gql/gql_types.go | 89 +- gql/gql_utils.go | 8 - gql/resolver_announcements.go | 14 +- gql/resolver_guides.go | 201 ++- gql/resolver_mods.go | 193 +-- gql/resolver_oauth.go | 105 +- gql/resolver_sml_versions.go | 7 +- gql/resolver_tags.go | 132 +- gql/resolver_users.go | 216 ++-- gql/resolver_versions.go | 99 +- gql/versions.go | 14 +- redis/jobs/jobs.go | 7 + redis/redis.go | 5 +- shell.nix | 5 +- storage/storage.go | 6 +- tests/guides_test.go | 3 + tests/mod_test.go | 151 +++ tests/utils.go | 8 +- tests/version_test.go | 291 +++++ tools.go | 1 + validation/validation.go | 11 +- 108 files changed, 14366 insertions(+), 3295 deletions(-) create mode 120000 .direnv/flake-profile create mode 120000 .direnv/flake-profile-1-link create mode 100644 conversion/ent_to_graphql.go delete mode 100644 conversion/graphql.go delete mode 100644 dataloader/LICENSE delete mode 100755 dataloader/userloader_gen.go delete mode 100755 dataloader/usermodloader_gen.go delete mode 100755 dataloader/versiondependencyloader_gen.go delete mode 100755 dataloader/versionloader_gen.go delete mode 100755 dataloader/versionloadernometa_gen.go delete mode 100644 db/postgres/guide.go delete mode 100644 db/postgres/tags.go delete mode 100644 db/postgres/user_funcs.go create mode 100644 db/schema/version_target.go create mode 100644 flake.lock create mode 100644 flake.nix create mode 100755 generated/conv/guide.go create mode 100755 generated/conv/mod.go create mode 100755 generated/conv/tag.go create mode 100755 generated/conv/user.go create mode 100755 generated/conv/user_mod.go create mode 100755 generated/conv/version.go create mode 100755 generated/conv/version_dependency.go create mode 100644 generated/ent/versiontarget.go create mode 100644 generated/ent/versiontarget/versiontarget.go create mode 100644 generated/ent/versiontarget/where.go create mode 100644 generated/ent/versiontarget_create.go create mode 100644 generated/ent/versiontarget_delete.go create mode 100644 generated/ent/versiontarget_query.go create mode 100644 generated/ent/versiontarget_update.go create mode 100644 tests/mod_test.go create mode 100644 tests/version_test.go diff --git a/.direnv/flake-profile b/.direnv/flake-profile new file mode 120000 index 00000000..0c05709d --- /dev/null +++ b/.direnv/flake-profile @@ -0,0 +1 @@ +flake-profile-1-link \ No newline at end of file diff --git a/.direnv/flake-profile-1-link b/.direnv/flake-profile-1-link new file mode 120000 index 00000000..78a8994c --- /dev/null +++ b/.direnv/flake-profile-1-link @@ -0,0 +1 @@ +/nix/store/zx4bs036j9parpd359js7l8nnbx676vf-nix-shell-env \ No newline at end of file diff --git a/.envrc b/.envrc index 65326bb6..8392d159 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix \ No newline at end of file +use flake \ No newline at end of file diff --git a/conversion/ent_to_graphql.go b/conversion/ent_to_graphql.go new file mode 100644 index 00000000..1ea5e3ae --- /dev/null +++ b/conversion/ent_to_graphql.go @@ -0,0 +1,114 @@ +package conversion + +import ( + "time" + + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/ent" +) + +// goverter:converter +// goverter:output:file ../generated/conv/announcement.go +// goverter:output:package conv +// goverter:extend TimeToString +type Announcement interface { + Convert(source *ent.Announcement) *generated.Announcement + ConvertSlice(source []*ent.Announcement) []*generated.Announcement +} + +// goverter:converter +// goverter:output:file ../generated/conv/sml_version.go +// goverter:output:package conv +// goverter:extend TimeToString +type SMLVersion interface { + // goverter:map Edges.Targets Targets + Convert(source *ent.SmlVersion) *generated.SMLVersion + ConvertSlice(source []*ent.SmlVersion) []*generated.SMLVersion +} + +// goverter:converter +// goverter:output:file ../generated/conv/user.go +// goverter:output:package conv +// goverter:extend TimeToString +type User interface { + // goverter:ignore Roles Groups Mods Guides + Convert(source *ent.User) *generated.User + ConvertSlice(source []*ent.User) []*generated.User +} + +// goverter:converter +// goverter:output:file ../generated/conv/guide.go +// goverter:output:package conv +// goverter:extend TimeToString +type Guide interface { + // goverter:ignore User + // goverter:map Edges.Tags Tags + Convert(source *ent.Guide) *generated.Guide + ConvertSlice(source []*ent.Guide) []*generated.Guide +} + +// goverter:converter +// goverter:output:file ../generated/conv/tag.go +// goverter:output:package conv +// goverter:extend TimeToString +type Tag interface { + Convert(source *ent.Tag) *generated.Tag + ConvertSlice(source []*ent.Tag) []*generated.Tag +} + +// goverter:converter +// goverter:output:file ../generated/conv/user_mod.go +// goverter:output:package conv +// goverter:extend TimeToString +type UserMod interface { + // goverter:ignore User Mod + Convert(source *ent.UserMod) *generated.UserMod + ConvertSlice(source []*ent.UserMod) []*generated.UserMod +} + +// goverter:converter +// goverter:output:file ../generated/conv/mod.go +// goverter:output:package conv +// goverter:extend TimeToString UIntToInt +type Mod interface { + // goverter:map Edges.Tags Tags + // goverter:ignore Authors Version Versions LatestVersions + Convert(source *ent.Mod) *generated.Mod + ConvertSlice(source []*ent.Mod) []*generated.Mod +} + +// goverter:converter +// goverter:output:file ../generated/conv/version.go +// goverter:output:package conv +// goverter:extend TimeToString UIntToInt Int64ToInt +type Version interface { + // goverter:map Edges.Targets Targets + // goverter:ignore Link Mod Dependencies Size Hash + Convert(source *ent.Version) *generated.Version + ConvertSlice(source []*ent.Version) []*generated.Version + + // goverter:ignore Link + ConvertTarget(source *ent.VersionTarget) *generated.VersionTarget +} + +// goverter:converter +// goverter:output:file ../generated/conv/version_dependency.go +// goverter:output:package conv +// goverter:extend TimeToString UIntToInt Int64ToInt +type VersionDependency interface { + // goverter:ignore Mod Version + Convert(source *ent.VersionDependency) *generated.VersionDependency + ConvertSlice(source []*ent.VersionDependency) []*generated.VersionDependency +} + +func TimeToString(i time.Time) string { + return i.Format(time.RFC3339) +} + +func UIntToInt(i uint) int { + return int(i) +} + +func Int64ToInt(i int64) int { + return int(i) +} diff --git a/conversion/graphql.go b/conversion/graphql.go deleted file mode 100644 index 9d6f1d24..00000000 --- a/conversion/graphql.go +++ /dev/null @@ -1,40 +0,0 @@ -package conversion - -import ( - "time" - - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/generated/ent" -) - -// goverter:converter -// goverter:output:file ../generated/conv/announcement.go -// goverter:output:package conv -// goverter:extend TimeToString -type Announcement interface { - Convert(source *ent.Announcement) *generated.Announcement - ConvertSlice(source []*ent.Announcement) []*generated.Announcement -} - -// goverter:converter -// goverter:output:file ../generated/conv/sml_version.go -// goverter:output:package conv -// goverter:extend TimeToString -type SMLVersion interface { - // goverter:map Edges.Targets Targets - Convert(source *ent.SmlVersion) *generated.SMLVersion - ConvertSlice(source []*ent.SmlVersion) []*generated.SMLVersion -} - -// goverter:converter -// goverter:output:file ../generated/conv/user.go -// goverter:output:package conv -// goverter:extend TimeToString -type User interface { - // goverter:ignore Roles Groups Mods Guides - Convert(source *ent.User) *generated.User -} - -func TimeToString(i time.Time) string { - return i.Format(time.RFC3339) -} diff --git a/dataloader/LICENSE b/dataloader/LICENSE deleted file mode 100644 index 6d62a2e4..00000000 --- a/dataloader/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - smr-api, satisfactory modding website - Copyright (C) 2021 Vilsol - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - smr-api Copyright (C) 2021 Vilsol - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<https://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<https://www.gnu.org/licenses/why-not-lgpl.html>. \ No newline at end of file diff --git a/dataloader/loaders.go b/dataloader/loaders.go index 861ed84c..7eeb6512 100644 --- a/dataloader/loaders.go +++ b/dataloader/loaders.go @@ -2,223 +2,178 @@ package dataloader import ( "context" - "time" + "errors" + "entgo.io/ent/dialect/sql" + "github.com/graph-gophers/dataloader/v7" "github.com/labstack/echo/v4" - "github.com/patrickmn/go-cache" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" ) type loadersKey struct{} type Loaders struct { - VersionDependenciesByVersionID VersionDependencyLoader - UserModsByModID UserModLoader - VersionsByModID VersionLoader - VersionsByModIDNoMeta VersionLoaderNoMeta - UserByID UserLoader + UserByID *dataloader.Loader[string, *ent.User] + VersionDependenciesByVersionID *dataloader.Loader[string, []*ent.VersionDependency] + UserModsByModID *dataloader.Loader[string, []*ent.UserMod] + VersionsByModID *dataloader.Loader[string, []*ent.Version] + VersionsByModIDNoMeta *dataloader.Loader[string, []*ent.Version] } func Middleware() func(handlerFunc echo.HandlerFunc) echo.HandlerFunc { - dbCache := cache.New(time.Second*5, time.Second*10) - return func(handlerFunc echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { ctx := context.WithValue(c.Request().Context(), loadersKey{}, &Loaders{ - VersionDependenciesByVersionID: VersionDependencyLoader{ - maxBatch: 100, - wait: time.Millisecond, - fetch: func(ids []string) ([][]postgres.VersionDependency, []error) { - fetchIds := make([]string, 0) - byID := map[string][]postgres.VersionDependency{} - for _, id := range ids { - if dependencies, ok := dbCache.Get("VersionDependenciesByVersionID_" + id); ok { - byID[id] = dependencies.([]postgres.VersionDependency) - } else { - fetchIds = append(fetchIds, id) - } - } - - var entities []postgres.VersionDependency - reqCtx := c.Request().Context() - postgres.DBCtx(reqCtx).Where("version_id IN ?", fetchIds).Find(&entities) - - for _, entity := range entities { - byID[entity.VersionID] = append(byID[entity.VersionID], entity) - } - - results := make([][]postgres.VersionDependency, len(ids)) - for i, id := range ids { - results[i] = byID[id] - dbCache.Set("VersionDependenciesByVersionID_"+id, results[i], cache.DefaultExpiration) - } - - return results, nil - }, - }, - UserModsByModID: UserModLoader{ - maxBatch: 100, - wait: time.Millisecond, - fetch: func(ids []string) ([][]postgres.UserMod, []error) { - fetchIds := make([]string, 0) - byID := map[string][]postgres.UserMod{} - for _, id := range ids { - if mods, ok := dbCache.Get("UserModsByModID_" + id); ok { - byID[id] = mods.([]postgres.UserMod) - } else { - fetchIds = append(fetchIds, id) - } - } - - var entities []postgres.UserMod - reqCtx := c.Request().Context() - postgres.DBCtx(reqCtx).Where("mod_id IN ?", fetchIds).Find(&entities) - - for _, entity := range entities { - byID[entity.ModID] = append(byID[entity.ModID], entity) - } - - results := make([][]postgres.UserMod, len(ids)) - for i, id := range ids { - results[i] = byID[id] - - if results[i] == nil { - results[i] = make([]postgres.UserMod, 0) - } - - dbCache.Set("UserModsByModID_"+id, results[i], cache.DefaultExpiration) - } - - return results, nil - }, - }, - VersionsByModID: VersionLoader{ - maxBatch: 100, - wait: time.Millisecond, - fetch: func(ids []string) ([][]postgres.Version, []error) { - fetchIds := make([]string, 0) - byID := map[string][]postgres.Version{} - for _, id := range ids { - if versions, ok := dbCache.Get("VersionsByModID_" + id); ok { - byID[id] = versions.([]postgres.Version) - } else { - fetchIds = append(fetchIds, id) - } - } - - var entities []postgres.Version - reqCtx := c.Request().Context() - postgres.DBCtx(reqCtx).Preload("Targets").Where("approved = ? AND denied = ? AND mod_id IN ?", true, false, fetchIds).Order("created_at desc").Find(&entities) - - for _, entity := range entities { - byID[entity.ModID] = append(byID[entity.ModID], entity) - } - - results := make([][]postgres.Version, len(ids)) - for i, id := range ids { - results[i] = byID[id] - - if results[i] == nil { - results[i] = make([]postgres.Version, 0) - } - - dbCache.Set("VersionsByModID_"+id, results[i], cache.DefaultExpiration) - } - - return results, nil - }, - }, - VersionsByModIDNoMeta: VersionLoaderNoMeta{ - maxBatch: 100, - wait: time.Millisecond, - fetch: func(ids []string) ([][]postgres.Version, []error) { - fetchIds := make([]string, 0) - byID := map[string][]postgres.Version{} - for _, id := range ids { - if versions, ok := dbCache.Get("VersionsByModIDNoMeta_" + id); ok { - byID[id] = versions.([]postgres.Version) - } else { - fetchIds = append(fetchIds, id) - } - } - - var entities []postgres.Version - reqCtx := c.Request().Context() - postgres.DBCtx(reqCtx).Preload("Targets").Select( - "id", - "created_at", - "updated_at", - "deleted_at", - "mod_id", - "version", - "sml_version", - "changelog", - "downloads", - "key", - "stability", - "approved", - "hotness", - "denied", - "mod_reference", - "version_major", - "version_minor", - "version_patch", - "size", - "hash", - ).Where("approved = ? AND denied = ? AND mod_id IN ?", true, false, fetchIds).Order("created_at desc").Find(&entities) - - for _, entity := range entities { - byID[entity.ModID] = append(byID[entity.ModID], entity) + VersionDependenciesByVersionID: dataloader.NewBatchedLoader(func(ctx context.Context, ids []string) []*dataloader.Result[[]*ent.VersionDependency] { + // TODO Query only selected fields from context + entities, err := db.From(ctx).VersionDependency.Query().Where(versiondependency.VersionIDIn(ids...)).All(ctx) + if err != nil { + return nil + } + + byID := map[string][]*ent.VersionDependency{} + for _, entity := range entities { + byID[entity.VersionID] = append(byID[entity.VersionID], entity) + } + + results := make([]*dataloader.Result[[]*ent.VersionDependency], len(ids)) + for i, id := range ids { + if u, ok := byID[id]; ok { + results[i] = &dataloader.Result[[]*ent.VersionDependency]{Data: u} + } else { + results[i] = &dataloader.Result[[]*ent.VersionDependency]{Error: errors.New("version not found")} } - - results := make([][]postgres.Version, len(ids)) - for i, id := range ids { - results[i] = byID[id] - - if results[i] == nil { - results[i] = make([]postgres.Version, 0) - } - - dbCache.Set("VersionsByModIDNoMeta_"+id, results[i], cache.DefaultExpiration) + } + + return results + }, dataloader.WithCache[string, []*ent.VersionDependency](&dataloader.NoCache[string, []*ent.VersionDependency]{})), + UserModsByModID: dataloader.NewBatchedLoader(func(ctx context.Context, ids []string) []*dataloader.Result[[]*ent.UserMod] { + // TODO Query only selected fields from context + entities, err := db.From(ctx).UserMod.Query().Where(usermod.ModIDIn(ids...)).All(ctx) + if err != nil { + return nil + } + + byID := map[string][]*ent.UserMod{} + for _, entity := range entities { + byID[entity.ModID] = append(byID[entity.ModID], entity) + } + + results := make([]*dataloader.Result[[]*ent.UserMod], len(ids)) + for i, id := range ids { + if u, ok := byID[id]; ok { + results[i] = &dataloader.Result[[]*ent.UserMod]{Data: u} + } else { + results[i] = &dataloader.Result[[]*ent.UserMod]{Error: errors.New("version not found")} } - - return results, nil - }, - }, - UserByID: UserLoader{ - maxBatch: 100, - wait: time.Millisecond, - fetch: func(ids []string) ([]*postgres.User, []error) { - fetchIds := make([]string, 0) - byID := map[string]*postgres.User{} - for _, id := range ids { - if versions, ok := dbCache.Get("UserByID_" + id); ok { - byID[id] = versions.(*postgres.User) - } else { - fetchIds = append(fetchIds, id) - } + } + + return results + }, dataloader.WithCache[string, []*ent.UserMod](&dataloader.NoCache[string, []*ent.UserMod]{})), + VersionsByModID: dataloader.NewBatchedLoader(func(ctx context.Context, ids []string) []*dataloader.Result[[]*ent.Version] { + // TODO Query only selected fields from context + entities, err := db.From(ctx).Version.Query().WithTargets().Where( + version.ModIDIn(ids...), + version.Approved(true), + version.Denied(false), + ).Order(version.ByCreatedAt(sql.OrderDesc())).All(ctx) + if err != nil { + return nil + } + + byID := map[string][]*ent.Version{} + for _, entity := range entities { + byID[entity.ModID] = append(byID[entity.ModID], entity) + } + + results := make([]*dataloader.Result[[]*ent.Version], len(ids)) + for i, id := range ids { + if u, ok := byID[id]; ok { + results[i] = &dataloader.Result[[]*ent.Version]{Data: u} + } else { + results[i] = &dataloader.Result[[]*ent.Version]{Error: errors.New("version not found")} } - - var entities []postgres.User - reqCtx := c.Request().Context() - postgres.DBCtx(reqCtx).Where("id IN ?", fetchIds).Find(&entities) - - for _, entity := range entities { - tempEntity := entity - byID[entity.ID] = &tempEntity + } + + return results + }, dataloader.WithCache[string, []*ent.Version](&dataloader.NoCache[string, []*ent.Version]{})), + VersionsByModIDNoMeta: dataloader.NewBatchedLoader(func(ctx context.Context, ids []string) []*dataloader.Result[[]*ent.Version] { + // TODO Query only selected fields from context + entities, err := db.From(ctx).Version.Query().Select( + version.FieldID, + version.FieldCreatedAt, + version.FieldUpdatedAt, + version.FieldDeletedAt, + version.FieldModID, + version.FieldVersion, + version.FieldSmlVersion, + version.FieldChangelog, + version.FieldDownloads, + version.FieldKey, + version.FieldStability, + version.FieldApproved, + version.FieldHotness, + version.FieldDenied, + version.FieldModReference, + version.FieldVersionMajor, + version.FieldVersionMinor, + version.FieldVersionPatch, + version.FieldSize, + version.FieldHash, + ).WithTargets().Where( + version.ModIDIn(ids...), + version.Approved(true), + version.Denied(false), + ).Order(version.ByCreatedAt(sql.OrderDesc())).All(ctx) + if err != nil { + return nil + } + + byID := map[string][]*ent.Version{} + for _, entity := range entities { + byID[entity.ModID] = append(byID[entity.ModID], entity) + } + + results := make([]*dataloader.Result[[]*ent.Version], len(ids)) + for i, id := range ids { + if u, ok := byID[id]; ok { + results[i] = &dataloader.Result[[]*ent.Version]{Data: u} + } else { + results[i] = &dataloader.Result[[]*ent.Version]{Error: errors.New("version not found")} } - - results := make([]*postgres.User, len(ids)) - for i, id := range ids { - results[i] = byID[id] - - dbCache.Set("UserByID_"+id, results[i], cache.DefaultExpiration) + } + + return results + }, dataloader.WithCache[string, []*ent.Version](&dataloader.NoCache[string, []*ent.Version]{})), + UserByID: dataloader.NewBatchedLoader(func(ctx context.Context, ids []string) []*dataloader.Result[*ent.User] { + // TODO Query only selected fields from context + entities, err := db.From(ctx).User.Query().Where(user.IDIn(ids...)).All(ctx) + if err != nil { + return nil + } + + byID := map[string]*ent.User{} + for _, entity := range entities { + byID[entity.ID] = entity + } + + results := make([]*dataloader.Result[*ent.User], len(ids)) + for i, id := range ids { + if u, ok := byID[id]; ok { + results[i] = &dataloader.Result[*ent.User]{Data: u} + } else { + results[i] = &dataloader.Result[*ent.User]{Error: errors.New("user not found")} } + } - return results, nil - }, - }, + return results + }, dataloader.WithCache[string, *ent.User](&dataloader.NoCache[string, *ent.User]{})), }) c.SetRequest(c.Request().WithContext(ctx)) diff --git a/dataloader/userloader_gen.go b/dataloader/userloader_gen.go deleted file mode 100755 index a91e92c3..00000000 --- a/dataloader/userloader_gen.go +++ /dev/null @@ -1,210 +0,0 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. - -package dataloader - -import ( - "sync" - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -// UserLoaderConfig captures the config to create a new UserLoader -type UserLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []string) ([]*postgres.User, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch -func NewUserLoader(config UserLoaderConfig) *UserLoader { - return &UserLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - -// UserLoader batches and caches requests -type UserLoader struct { - fetch func(keys []string) ([]*postgres.User, []error) - cache map[string]*postgres.User - batch *userLoaderBatch - wait time.Duration - maxBatch int - mu sync.Mutex -} - -type userLoaderBatch struct { - done chan struct{} - keys []string - data []*postgres.User - error []error - closing bool -} - -// Load a User by key, batching and caching will be applied automatically -func (l *UserLoader) Load(key string) (*postgres.User, error) { - return l.LoadThunk(key)() -} - -// LoadThunk returns a function that when called will block waiting for a User. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *UserLoader) LoadThunk(key string) func() (*postgres.User, error) { - l.mu.Lock() - if it, ok := l.cache[key]; ok { - l.mu.Unlock() - return func() (*postgres.User, error) { - return it, nil - } - } - if l.batch == nil { - l.batch = &userLoaderBatch{done: make(chan struct{})} - } - batch := l.batch - pos := batch.keyIndex(l, key) - l.mu.Unlock() - - return func() (*postgres.User, error) { - <-batch.done - - var data *postgres.User - if pos < len(batch.data) { - data = batch.data[pos] - } - - var err error - // its convenient to be able to return a single error for everything - if len(batch.error) == 1 { - err = batch.error[0] - } else if batch.error != nil { - err = batch.error[pos] - } - - if err == nil { - l.mu.Lock() - l.unsafeSet(key, data) - l.mu.Unlock() - } - - return data, err - } -} - -// LoadAll fetches many keys at once. It will be broken into appropriate sized -// sub batches depending on how the loader is configured -func (l *UserLoader) LoadAll(keys []string) ([]*postgres.User, []error) { - results := make([]func() (*postgres.User, error), len(keys)) - - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - - users := make([]*postgres.User, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - users[i], errors[i] = thunk() - } - return users, errors -} - -// LoadAllThunk returns a function that when called will block waiting for a Users. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *UserLoader) LoadAllThunk(keys []string) func() ([]*postgres.User, []error) { - results := make([]func() (*postgres.User, error), len(keys)) - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - return func() ([]*postgres.User, []error) { - users := make([]*postgres.User, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - users[i], errors[i] = thunk() - } - return users, errors - } -} - -// Prime the cache with the provided key and value. If the key already exists, no change is made -// and false is returned. -// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) -func (l *UserLoader) Prime(key string, value *postgres.User) bool { - l.mu.Lock() - var found bool - if _, found = l.cache[key]; !found { - // make a copy when writing to the cache, its easy to pass a pointer in from a loop var - // and end up with the whole cache pointing to the same value. - cpy := *value - l.unsafeSet(key, &cpy) - } - l.mu.Unlock() - return !found -} - -// Clear the value at key from the cache, if it exists -func (l *UserLoader) Clear(key string) { - l.mu.Lock() - delete(l.cache, key) - l.mu.Unlock() -} - -func (l *UserLoader) unsafeSet(key string, value *postgres.User) { - if l.cache == nil { - l.cache = map[string]*postgres.User{} - } - l.cache[key] = value -} - -// keyIndex will return the location of the key in the batch, if its not found -// it will add the key to the batch -func (b *userLoaderBatch) keyIndex(l *UserLoader, key string) int { - for i, existingKey := range b.keys { - if key == existingKey { - return i - } - } - - pos := len(b.keys) - b.keys = append(b.keys, key) - if pos == 0 { - go b.startTimer(l) - } - - if l.maxBatch != 0 && pos >= l.maxBatch-1 { - if !b.closing { - b.closing = true - l.batch = nil - go b.end(l) - } - } - - return pos -} - -func (b *userLoaderBatch) startTimer(l *UserLoader) { - time.Sleep(l.wait) - l.mu.Lock() - - // we must have hit a batch limit and are already finalizing this batch - if b.closing { - l.mu.Unlock() - return - } - - l.batch = nil - l.mu.Unlock() - - b.end(l) -} - -func (b *userLoaderBatch) end(l *UserLoader) { - b.data, b.error = l.fetch(b.keys) - close(b.done) -} diff --git a/dataloader/usermodloader_gen.go b/dataloader/usermodloader_gen.go deleted file mode 100755 index caf0335c..00000000 --- a/dataloader/usermodloader_gen.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. - -package dataloader - -import ( - "sync" - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -// UserModLoaderConfig captures the config to create a new UserModLoader -type UserModLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []string) ([][]postgres.UserMod, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewUserModLoader creates a new UserModLoader given a fetch, wait, and maxBatch -func NewUserModLoader(config UserModLoaderConfig) *UserModLoader { - return &UserModLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - -// UserModLoader batches and caches requests -type UserModLoader struct { - fetch func(keys []string) ([][]postgres.UserMod, []error) - cache map[string][]postgres.UserMod - batch *userModLoaderBatch - wait time.Duration - maxBatch int - mu sync.Mutex -} - -type userModLoaderBatch struct { - done chan struct{} - keys []string - data [][]postgres.UserMod - error []error - closing bool -} - -// Load a UserMod by key, batching and caching will be applied automatically -func (l *UserModLoader) Load(key string) ([]postgres.UserMod, error) { - return l.LoadThunk(key)() -} - -// LoadThunk returns a function that when called will block waiting for a UserMod. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *UserModLoader) LoadThunk(key string) func() ([]postgres.UserMod, error) { - l.mu.Lock() - if it, ok := l.cache[key]; ok { - l.mu.Unlock() - return func() ([]postgres.UserMod, error) { - return it, nil - } - } - if l.batch == nil { - l.batch = &userModLoaderBatch{done: make(chan struct{})} - } - batch := l.batch - pos := batch.keyIndex(l, key) - l.mu.Unlock() - - return func() ([]postgres.UserMod, error) { - <-batch.done - - var data []postgres.UserMod - if pos < len(batch.data) { - data = batch.data[pos] - } - - var err error - // its convenient to be able to return a single error for everything - if len(batch.error) == 1 { - err = batch.error[0] - } else if batch.error != nil { - err = batch.error[pos] - } - - if err == nil { - l.mu.Lock() - l.unsafeSet(key, data) - l.mu.Unlock() - } - - return data, err - } -} - -// LoadAll fetches many keys at once. It will be broken into appropriate sized -// sub batches depending on how the loader is configured -func (l *UserModLoader) LoadAll(keys []string) ([][]postgres.UserMod, []error) { - results := make([]func() ([]postgres.UserMod, error), len(keys)) - - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - - userMods := make([][]postgres.UserMod, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - userMods[i], errors[i] = thunk() - } - return userMods, errors -} - -// LoadAllThunk returns a function that when called will block waiting for a UserMods. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *UserModLoader) LoadAllThunk(keys []string) func() ([][]postgres.UserMod, []error) { - results := make([]func() ([]postgres.UserMod, error), len(keys)) - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - return func() ([][]postgres.UserMod, []error) { - userMods := make([][]postgres.UserMod, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - userMods[i], errors[i] = thunk() - } - return userMods, errors - } -} - -// Prime the cache with the provided key and value. If the key already exists, no change is made -// and false is returned. -// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) -func (l *UserModLoader) Prime(key string, value []postgres.UserMod) bool { - l.mu.Lock() - var found bool - if _, found = l.cache[key]; !found { - // make a copy when writing to the cache, its easy to pass a pointer in from a loop var - // and end up with the whole cache pointing to the same value. - cpy := make([]postgres.UserMod, len(value)) - copy(cpy, value) - l.unsafeSet(key, cpy) - } - l.mu.Unlock() - return !found -} - -// Clear the value at key from the cache, if it exists -func (l *UserModLoader) Clear(key string) { - l.mu.Lock() - delete(l.cache, key) - l.mu.Unlock() -} - -func (l *UserModLoader) unsafeSet(key string, value []postgres.UserMod) { - if l.cache == nil { - l.cache = map[string][]postgres.UserMod{} - } - l.cache[key] = value -} - -// keyIndex will return the location of the key in the batch, if its not found -// it will add the key to the batch -func (b *userModLoaderBatch) keyIndex(l *UserModLoader, key string) int { - for i, existingKey := range b.keys { - if key == existingKey { - return i - } - } - - pos := len(b.keys) - b.keys = append(b.keys, key) - if pos == 0 { - go b.startTimer(l) - } - - if l.maxBatch != 0 && pos >= l.maxBatch-1 { - if !b.closing { - b.closing = true - l.batch = nil - go b.end(l) - } - } - - return pos -} - -func (b *userModLoaderBatch) startTimer(l *UserModLoader) { - time.Sleep(l.wait) - l.mu.Lock() - - // we must have hit a batch limit and are already finalizing this batch - if b.closing { - l.mu.Unlock() - return - } - - l.batch = nil - l.mu.Unlock() - - b.end(l) -} - -func (b *userModLoaderBatch) end(l *UserModLoader) { - b.data, b.error = l.fetch(b.keys) - close(b.done) -} diff --git a/dataloader/versiondependencyloader_gen.go b/dataloader/versiondependencyloader_gen.go deleted file mode 100755 index dc05046b..00000000 --- a/dataloader/versiondependencyloader_gen.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. - -package dataloader - -import ( - "sync" - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -// VersionDependencyLoaderConfig captures the config to create a new VersionDependencyLoader -type VersionDependencyLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []string) ([][]postgres.VersionDependency, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewVersionDependencyLoader creates a new VersionDependencyLoader given a fetch, wait, and maxBatch -func NewVersionDependencyLoader(config VersionDependencyLoaderConfig) *VersionDependencyLoader { - return &VersionDependencyLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - -// VersionDependencyLoader batches and caches requests -type VersionDependencyLoader struct { - fetch func(keys []string) ([][]postgres.VersionDependency, []error) - cache map[string][]postgres.VersionDependency - batch *versionDependencyLoaderBatch - wait time.Duration - maxBatch int - mu sync.Mutex -} - -type versionDependencyLoaderBatch struct { - done chan struct{} - keys []string - data [][]postgres.VersionDependency - error []error - closing bool -} - -// Load a VersionDependency by key, batching and caching will be applied automatically -func (l *VersionDependencyLoader) Load(key string) ([]postgres.VersionDependency, error) { - return l.LoadThunk(key)() -} - -// LoadThunk returns a function that when called will block waiting for a VersionDependency. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionDependencyLoader) LoadThunk(key string) func() ([]postgres.VersionDependency, error) { - l.mu.Lock() - if it, ok := l.cache[key]; ok { - l.mu.Unlock() - return func() ([]postgres.VersionDependency, error) { - return it, nil - } - } - if l.batch == nil { - l.batch = &versionDependencyLoaderBatch{done: make(chan struct{})} - } - batch := l.batch - pos := batch.keyIndex(l, key) - l.mu.Unlock() - - return func() ([]postgres.VersionDependency, error) { - <-batch.done - - var data []postgres.VersionDependency - if pos < len(batch.data) { - data = batch.data[pos] - } - - var err error - // its convenient to be able to return a single error for everything - if len(batch.error) == 1 { - err = batch.error[0] - } else if batch.error != nil { - err = batch.error[pos] - } - - if err == nil { - l.mu.Lock() - l.unsafeSet(key, data) - l.mu.Unlock() - } - - return data, err - } -} - -// LoadAll fetches many keys at once. It will be broken into appropriate sized -// sub batches depending on how the loader is configured -func (l *VersionDependencyLoader) LoadAll(keys []string) ([][]postgres.VersionDependency, []error) { - results := make([]func() ([]postgres.VersionDependency, error), len(keys)) - - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - - versionDependencys := make([][]postgres.VersionDependency, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versionDependencys[i], errors[i] = thunk() - } - return versionDependencys, errors -} - -// LoadAllThunk returns a function that when called will block waiting for a VersionDependencys. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionDependencyLoader) LoadAllThunk(keys []string) func() ([][]postgres.VersionDependency, []error) { - results := make([]func() ([]postgres.VersionDependency, error), len(keys)) - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - return func() ([][]postgres.VersionDependency, []error) { - versionDependencys := make([][]postgres.VersionDependency, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versionDependencys[i], errors[i] = thunk() - } - return versionDependencys, errors - } -} - -// Prime the cache with the provided key and value. If the key already exists, no change is made -// and false is returned. -// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) -func (l *VersionDependencyLoader) Prime(key string, value []postgres.VersionDependency) bool { - l.mu.Lock() - var found bool - if _, found = l.cache[key]; !found { - // make a copy when writing to the cache, its easy to pass a pointer in from a loop var - // and end up with the whole cache pointing to the same value. - cpy := make([]postgres.VersionDependency, len(value)) - copy(cpy, value) - l.unsafeSet(key, cpy) - } - l.mu.Unlock() - return !found -} - -// Clear the value at key from the cache, if it exists -func (l *VersionDependencyLoader) Clear(key string) { - l.mu.Lock() - delete(l.cache, key) - l.mu.Unlock() -} - -func (l *VersionDependencyLoader) unsafeSet(key string, value []postgres.VersionDependency) { - if l.cache == nil { - l.cache = map[string][]postgres.VersionDependency{} - } - l.cache[key] = value -} - -// keyIndex will return the location of the key in the batch, if its not found -// it will add the key to the batch -func (b *versionDependencyLoaderBatch) keyIndex(l *VersionDependencyLoader, key string) int { - for i, existingKey := range b.keys { - if key == existingKey { - return i - } - } - - pos := len(b.keys) - b.keys = append(b.keys, key) - if pos == 0 { - go b.startTimer(l) - } - - if l.maxBatch != 0 && pos >= l.maxBatch-1 { - if !b.closing { - b.closing = true - l.batch = nil - go b.end(l) - } - } - - return pos -} - -func (b *versionDependencyLoaderBatch) startTimer(l *VersionDependencyLoader) { - time.Sleep(l.wait) - l.mu.Lock() - - // we must have hit a batch limit and are already finalizing this batch - if b.closing { - l.mu.Unlock() - return - } - - l.batch = nil - l.mu.Unlock() - - b.end(l) -} - -func (b *versionDependencyLoaderBatch) end(l *VersionDependencyLoader) { - b.data, b.error = l.fetch(b.keys) - close(b.done) -} diff --git a/dataloader/versionloader_gen.go b/dataloader/versionloader_gen.go deleted file mode 100755 index 75cd9c63..00000000 --- a/dataloader/versionloader_gen.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. - -package dataloader - -import ( - "sync" - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -// VersionLoaderConfig captures the config to create a new VersionLoader -type VersionLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []string) ([][]postgres.Version, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewVersionLoader creates a new VersionLoader given a fetch, wait, and maxBatch -func NewVersionLoader(config VersionLoaderConfig) *VersionLoader { - return &VersionLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - -// VersionLoader batches and caches requests -type VersionLoader struct { - fetch func(keys []string) ([][]postgres.Version, []error) - cache map[string][]postgres.Version - batch *versionLoaderBatch - wait time.Duration - maxBatch int - mu sync.Mutex -} - -type versionLoaderBatch struct { - done chan struct{} - keys []string - data [][]postgres.Version - error []error - closing bool -} - -// Load a Version by key, batching and caching will be applied automatically -func (l *VersionLoader) Load(key string) ([]postgres.Version, error) { - return l.LoadThunk(key)() -} - -// LoadThunk returns a function that when called will block waiting for a Version. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionLoader) LoadThunk(key string) func() ([]postgres.Version, error) { - l.mu.Lock() - if it, ok := l.cache[key]; ok { - l.mu.Unlock() - return func() ([]postgres.Version, error) { - return it, nil - } - } - if l.batch == nil { - l.batch = &versionLoaderBatch{done: make(chan struct{})} - } - batch := l.batch - pos := batch.keyIndex(l, key) - l.mu.Unlock() - - return func() ([]postgres.Version, error) { - <-batch.done - - var data []postgres.Version - if pos < len(batch.data) { - data = batch.data[pos] - } - - var err error - // its convenient to be able to return a single error for everything - if len(batch.error) == 1 { - err = batch.error[0] - } else if batch.error != nil { - err = batch.error[pos] - } - - if err == nil { - l.mu.Lock() - l.unsafeSet(key, data) - l.mu.Unlock() - } - - return data, err - } -} - -// LoadAll fetches many keys at once. It will be broken into appropriate sized -// sub batches depending on how the loader is configured -func (l *VersionLoader) LoadAll(keys []string) ([][]postgres.Version, []error) { - results := make([]func() ([]postgres.Version, error), len(keys)) - - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - - versions := make([][]postgres.Version, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versions[i], errors[i] = thunk() - } - return versions, errors -} - -// LoadAllThunk returns a function that when called will block waiting for a Versions. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionLoader) LoadAllThunk(keys []string) func() ([][]postgres.Version, []error) { - results := make([]func() ([]postgres.Version, error), len(keys)) - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - return func() ([][]postgres.Version, []error) { - versions := make([][]postgres.Version, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versions[i], errors[i] = thunk() - } - return versions, errors - } -} - -// Prime the cache with the provided key and value. If the key already exists, no change is made -// and false is returned. -// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) -func (l *VersionLoader) Prime(key string, value []postgres.Version) bool { - l.mu.Lock() - var found bool - if _, found = l.cache[key]; !found { - // make a copy when writing to the cache, its easy to pass a pointer in from a loop var - // and end up with the whole cache pointing to the same value. - cpy := make([]postgres.Version, len(value)) - copy(cpy, value) - l.unsafeSet(key, cpy) - } - l.mu.Unlock() - return !found -} - -// Clear the value at key from the cache, if it exists -func (l *VersionLoader) Clear(key string) { - l.mu.Lock() - delete(l.cache, key) - l.mu.Unlock() -} - -func (l *VersionLoader) unsafeSet(key string, value []postgres.Version) { - if l.cache == nil { - l.cache = map[string][]postgres.Version{} - } - l.cache[key] = value -} - -// keyIndex will return the location of the key in the batch, if its not found -// it will add the key to the batch -func (b *versionLoaderBatch) keyIndex(l *VersionLoader, key string) int { - for i, existingKey := range b.keys { - if key == existingKey { - return i - } - } - - pos := len(b.keys) - b.keys = append(b.keys, key) - if pos == 0 { - go b.startTimer(l) - } - - if l.maxBatch != 0 && pos >= l.maxBatch-1 { - if !b.closing { - b.closing = true - l.batch = nil - go b.end(l) - } - } - - return pos -} - -func (b *versionLoaderBatch) startTimer(l *VersionLoader) { - time.Sleep(l.wait) - l.mu.Lock() - - // we must have hit a batch limit and are already finalizing this batch - if b.closing { - l.mu.Unlock() - return - } - - l.batch = nil - l.mu.Unlock() - - b.end(l) -} - -func (b *versionLoaderBatch) end(l *VersionLoader) { - b.data, b.error = l.fetch(b.keys) - close(b.done) -} diff --git a/dataloader/versionloadernometa_gen.go b/dataloader/versionloadernometa_gen.go deleted file mode 100755 index c55b5aed..00000000 --- a/dataloader/versionloadernometa_gen.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. - -package dataloader - -import ( - "sync" - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -// VersionLoaderNoMetaConfig captures the config to create a new VersionLoaderNoMeta -type VersionLoaderNoMetaConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []string) ([][]postgres.Version, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewVersionLoaderNoMeta creates a new VersionLoaderNoMeta given a fetch, wait, and maxBatch -func NewVersionLoaderNoMeta(config VersionLoaderNoMetaConfig) *VersionLoaderNoMeta { - return &VersionLoaderNoMeta{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - -// VersionLoaderNoMeta batches and caches requests -type VersionLoaderNoMeta struct { - fetch func(keys []string) ([][]postgres.Version, []error) - cache map[string][]postgres.Version - batch *versionLoaderNoMetaBatch - wait time.Duration - maxBatch int - mu sync.Mutex -} - -type versionLoaderNoMetaBatch struct { - done chan struct{} - keys []string - data [][]postgres.Version - error []error - closing bool -} - -// Load a Version by key, batching and caching will be applied automatically -func (l *VersionLoaderNoMeta) Load(key string) ([]postgres.Version, error) { - return l.LoadThunk(key)() -} - -// LoadThunk returns a function that when called will block waiting for a Version. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionLoaderNoMeta) LoadThunk(key string) func() ([]postgres.Version, error) { - l.mu.Lock() - if it, ok := l.cache[key]; ok { - l.mu.Unlock() - return func() ([]postgres.Version, error) { - return it, nil - } - } - if l.batch == nil { - l.batch = &versionLoaderNoMetaBatch{done: make(chan struct{})} - } - batch := l.batch - pos := batch.keyIndex(l, key) - l.mu.Unlock() - - return func() ([]postgres.Version, error) { - <-batch.done - - var data []postgres.Version - if pos < len(batch.data) { - data = batch.data[pos] - } - - var err error - // its convenient to be able to return a single error for everything - if len(batch.error) == 1 { - err = batch.error[0] - } else if batch.error != nil { - err = batch.error[pos] - } - - if err == nil { - l.mu.Lock() - l.unsafeSet(key, data) - l.mu.Unlock() - } - - return data, err - } -} - -// LoadAll fetches many keys at once. It will be broken into appropriate sized -// sub batches depending on how the loader is configured -func (l *VersionLoaderNoMeta) LoadAll(keys []string) ([][]postgres.Version, []error) { - results := make([]func() ([]postgres.Version, error), len(keys)) - - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - - versions := make([][]postgres.Version, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versions[i], errors[i] = thunk() - } - return versions, errors -} - -// LoadAllThunk returns a function that when called will block waiting for a Versions. -// This method should be used if you want one goroutine to make requests to many -// different data loaders without blocking until the thunk is called. -func (l *VersionLoaderNoMeta) LoadAllThunk(keys []string) func() ([][]postgres.Version, []error) { - results := make([]func() ([]postgres.Version, error), len(keys)) - for i, key := range keys { - results[i] = l.LoadThunk(key) - } - return func() ([][]postgres.Version, []error) { - versions := make([][]postgres.Version, len(keys)) - errors := make([]error, len(keys)) - for i, thunk := range results { - versions[i], errors[i] = thunk() - } - return versions, errors - } -} - -// Prime the cache with the provided key and value. If the key already exists, no change is made -// and false is returned. -// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) -func (l *VersionLoaderNoMeta) Prime(key string, value []postgres.Version) bool { - l.mu.Lock() - var found bool - if _, found = l.cache[key]; !found { - // make a copy when writing to the cache, its easy to pass a pointer in from a loop var - // and end up with the whole cache pointing to the same value. - cpy := make([]postgres.Version, len(value)) - copy(cpy, value) - l.unsafeSet(key, cpy) - } - l.mu.Unlock() - return !found -} - -// Clear the value at key from the cache, if it exists -func (l *VersionLoaderNoMeta) Clear(key string) { - l.mu.Lock() - delete(l.cache, key) - l.mu.Unlock() -} - -func (l *VersionLoaderNoMeta) unsafeSet(key string, value []postgres.Version) { - if l.cache == nil { - l.cache = map[string][]postgres.Version{} - } - l.cache[key] = value -} - -// keyIndex will return the location of the key in the batch, if its not found -// it will add the key to the batch -func (b *versionLoaderNoMetaBatch) keyIndex(l *VersionLoaderNoMeta, key string) int { - for i, existingKey := range b.keys { - if key == existingKey { - return i - } - } - - pos := len(b.keys) - b.keys = append(b.keys, key) - if pos == 0 { - go b.startTimer(l) - } - - if l.maxBatch != 0 && pos >= l.maxBatch-1 { - if !b.closing { - b.closing = true - l.batch = nil - go b.end(l) - } - } - - return pos -} - -func (b *versionLoaderNoMetaBatch) startTimer(l *VersionLoaderNoMeta) { - time.Sleep(l.wait) - l.mu.Lock() - - // we must have hit a batch limit and are already finalizing this batch - if b.closing { - l.mu.Unlock() - return - } - - l.batch = nil - l.mu.Unlock() - - b.end(l) -} - -func (b *versionLoaderNoMetaBatch) end(l *VersionLoaderNoMeta) { - b.data, b.error = l.fetch(b.keys) - close(b.done) -} diff --git a/db/postgres/guide.go b/db/postgres/guide.go deleted file mode 100644 index bf938a9a..00000000 --- a/db/postgres/guide.go +++ /dev/null @@ -1,197 +0,0 @@ -package postgres - -import ( - "context" - "fmt" - "math" - "strings" - "time" - - "github.com/patrickmn/go-cache" - - "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" -) - -func CreateGuide(ctx context.Context, guide *Guide) (*Guide, error) { - // Allow only 8 new guides per 24h - - guide.ID = util.GenerateUniqueID() - - var guides []Guide - DBCtx(ctx).Order("created_at asc").Find(&guides, "user_id = ? AND created_at > ?", guide.UserID, time.Now().Add(time.Hour*24*-1)) - - currentAvailable := float64(8) - lastGuideTime := time.Now() - for _, guide := range guides { - currentAvailable-- - if guide.CreatedAt.After(lastGuideTime) { - diff := guide.CreatedAt.Sub(lastGuideTime) - currentAvailable = math.Min(8, currentAvailable+diff.Hours()/3) - } - lastGuideTime = guide.CreatedAt - } - - if currentAvailable < 1 { - timeToWait := time.Until(lastGuideTime.Add(time.Hour * 6)).Minutes() - return nil, fmt.Errorf("please wait %.0f minutes to post another guide", timeToWait) - } - - DBCtx(ctx).Create(&guide) - - return guide, nil -} - -func GetGuideByID(ctx context.Context, guideID string) *Guide { - cacheKey := "GetGuideById_" + guideID - - if guide, ok := dbCache.Get(cacheKey); ok { - return guide.(*Guide) - } - - return GetGuideByIDNoCache(ctx, guideID) -} - -func GetGuideByIDNoCache(ctx context.Context, guideID string) *Guide { - var guide Guide - DBCtx(ctx).Preload("Tags").Find(&guide, "id = ?", guideID) - - if guide.ID == "" { - return nil - } - - cacheKey := "GetGuideById_" + guideID - dbCache.Set(cacheKey, &guide, cache.DefaultExpiration) - - return &guide -} - -func GetGuides(ctx context.Context, filter *models.GuideFilter) []Guide { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetGuides_" + hash - if guides, ok := dbCache.Get(cacheKey); ok { - return guides.([]Guide) - } - } - - var guides []Guide - query := DBCtx(ctx).Preload("Tags") - - if filter != nil { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset). - Order(string(*filter.OrderBy) + " " + string(*filter.Order)) - - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - - if filter.TagIDs != nil && len(filter.TagIDs) > 0 { - query.Joins("INNER JOIN guide_tags on guide_tags.tag_id in ? AND guide_tags.guide_id = guides.id", filter.TagIDs) - } - } - - query.Find(&guides) - - if cacheKey != "" { - dbCache.Set(cacheKey, guides, cache.DefaultExpiration) - } - - return guides -} - -func GetGuidesByID(ctx context.Context, guideIds []string) []Guide { - cacheKey := "GetGuidesById_" + strings.Join(guideIds, ":") - - if guides, ok := dbCache.Get(cacheKey); ok { - return guides.([]Guide) - } - - var guides []Guide - DBCtx(ctx).Preload("Tags").Find(&guides, "id in (?)", guideIds) - - if len(guideIds) != len(guides) { - return nil - } - - dbCache.Set(cacheKey, guides, cache.DefaultExpiration) - - return guides -} - -func GetGuideCount(ctx context.Context, filter *models.GuideFilter) int64 { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetGuideCount_" + hash - if count, ok := dbCache.Get(cacheKey); ok { - return count.(int64) - } - } - - var guideCount int64 - query := DBCtx(ctx).Model(Guide{}) - - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Count(&guideCount) - - if cacheKey != "" { - dbCache.Set(cacheKey, guideCount, cache.DefaultExpiration) - } - - return guideCount -} - -func IncrementGuideViews(ctx context.Context, guide *Guide) { - DBCtx(ctx).Model(guide).Update("views", guide.Views+1) -} - -func GetUserGuides(ctx context.Context, userID string) []Guide { - var guides []Guide - DBCtx(ctx).Preload("Tags").Find(&guides, "user_id = ?", userID) - return guides -} - -func ClearGuideTags(ctx context.Context, guideID string) error { - r := DBCtx(ctx).Where("guide_id = ?", guideID).Delete(&GuideTag{}) - return r.Error -} - -func SetGuideTags(ctx context.Context, guideID string, tagIDs []string) error { - for _, tag := range tagIDs { - err := AddGuideTag(ctx, guideID, tag) - if err != nil { - return err - } - } - return nil -} - -func ResetGuideTags(ctx context.Context, guideID string, tagIDs []string) error { - err := ClearGuideTags(ctx, guideID) - if err != nil { - return err - } - err = SetGuideTags(ctx, guideID, tagIDs) - if err != nil { - return err - } - return nil -} - -func AddGuideTag(ctx context.Context, guideID string, tagID string) error { - r := DBCtx(ctx).Create(&GuideTag{GuideID: guideID, TagID: tagID}) - return r.Error -} - -func RemoveGuideTag(ctx context.Context, guideID string, tagID string) error { - r := DBCtx(ctx).Delete(&GuideTag{GuideID: guideID, TagID: tagID}) - return r.Error -} diff --git a/db/postgres/postgres_types.go b/db/postgres/postgres_types.go index 9adf4683..187a286e 100644 --- a/db/postgres/postgres_types.go +++ b/db/postgres/postgres_types.go @@ -169,8 +169,8 @@ type GuideTag struct { } type CompatibilityInfo struct { - EA Compatibility `gorm:"type:compatibility"` - EXP Compatibility `gorm:"type:compatibility"` + Ea Compatibility `gorm:"type:compatibility" json:"EA"` + Exp Compatibility `gorm:"type:compatibility" json:"EXP"` } type Compatibility struct { diff --git a/db/postgres/tags.go b/db/postgres/tags.go deleted file mode 100644 index 3ab95d1c..00000000 --- a/db/postgres/tags.go +++ /dev/null @@ -1,152 +0,0 @@ -package postgres - -import ( - "context" - "errors" - "fmt" - "math" - "strconv" - "strings" - "time" - - "github.com/finnbear/moderation" - "github.com/mitchellh/hashstructure/v2" - "github.com/patrickmn/go-cache" - - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/util" -) - -func ValidateTagName(tag string) error { - if len(tag) > 24 { - return errors.New("Tag name is over 24 characters long") - } - if len(tag) < 3 { - return errors.New("Tag name is under 3 characters long") - } - if moderation.IsInappropriate(tag) { - return errors.New("Tag name is inapproriate") - } - return nil -} - -func CreateTag(ctx context.Context, tag *Tag, ratelimit bool) (*Tag, error) { - err := ValidateTagName(tag.Name) - if err != nil { - return nil, err - } - - if GetTagByName(ctx, tag.Name) != nil { - return nil, fmt.Errorf("Tag %v already exists", tag.Name) - } - - if ratelimit { - var tags []Tag - DBCtx(ctx).Order("created_at asc").Find(&tags, "created_at > ?", time.Now().Add(time.Hour*24*-1)) - - currentAvailable := float64(8) - lastTagTime := time.Now() - for _, tag := range tags { - currentAvailable-- - if tag.CreatedAt.After(lastTagTime) { - diff := tag.CreatedAt.Sub(lastTagTime) - currentAvailable = math.Min(4, currentAvailable+diff.Hours()/6) - } - lastTagTime = tag.CreatedAt - } - - if currentAvailable < 1 { - timeToWait := time.Until(lastTagTime.Add(time.Hour * 6)).Minutes() - return nil, fmt.Errorf("please wait %.0f minutes to create another tag", timeToWait) - } - } - - tag.ID = util.GenerateUniqueID() - - err = DBCtx(ctx).Create(&tag).Error - - if err != nil { - return nil, fmt.Errorf("Could not create tag: %w", err) - } - - return tag, nil -} - -func GetTagByName(ctx context.Context, tagName string) *Tag { - cacheKey := "GetTagByName_" + tagName - - if tag, ok := dbCache.Get(cacheKey); ok { - return tag.(*Tag) - } - - var tag Tag - DBCtx(ctx).Find(&tag, "name = ?", tagName) - - if tag.Name == "" { - return nil - } - - dbCache.Set(cacheKey, &tag, cache.DefaultExpiration) - - return &tag -} - -func GetTagByID(ctx context.Context, tagID string) *Tag { - cacheKey := "GetTagById_" + tagID - - if tag, ok := dbCache.Get(cacheKey); ok { - return tag.(*Tag) - } - - var tag Tag - DBCtx(ctx).Find(&tag, "id = ?", tagID) - - if tag.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &tag, cache.DefaultExpiration) - - return &tag -} - -func GetTags(ctx context.Context, filter *generated.TagFilter) []Tag { - cacheKey := "" - hash, err := hashstructure.Hash(filter, hashstructure.FormatV2, nil) - if err == nil { - cacheKey = "GetTags" + strconv.FormatUint(hash, 10) - if tags, ok := dbCache.Get(cacheKey); ok { - return tags.([]Tag) - } - } - - query := DBCtx(ctx) - - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - cleanSearch := strings.ReplaceAll(strings.TrimSpace(*filter.Search), " ", " & ") - sub := DBCtx(ctx).Table("tags") - sub = sub.Select("id, similarity(name, ?) as s", cleanSearch, cleanSearch, cleanSearch) - - query = query.Joins("INNER JOIN (?) AS t1 on t1.id = tags.id", sub) - query = query.Where("t1.s > 0.2") - } - - query = query.Limit(*filter.Limit).Offset(*filter.Offset) - - if filter.Ids != nil && len(filter.Ids) > 0 { - query = query.Where("id in (?)", filter.Ids) - } - - query = query.Order("name " + string(*filter.Order)) - } - - var tags []Tag - query.Find(&tags) - - if cacheKey != "" { - dbCache.Set(cacheKey, tags, cache.DefaultExpiration) - } - - return tags -} diff --git a/db/postgres/user_funcs.go b/db/postgres/user_funcs.go deleted file mode 100644 index 33e36e80..00000000 --- a/db/postgres/user_funcs.go +++ /dev/null @@ -1,101 +0,0 @@ -package postgres - -import ( - "context" - - "github.com/satisfactorymodding/smr-api/auth" -) - -func (user User) Has(ctx context.Context, role *auth.Role) bool { - groups := auth.GetRoleGroups(role) - groupIds := make([]string, len(groups)) - for i, group := range groups { - groupIds[i] = group.ID - } - - var group UserGroup - DBCtx(ctx).Where("user_id = ?", user.ID).Where("group_id IN (?)", groupIds).First(&group) - - return group.UserID == user.ID -} - -func (user User) GetRoles(ctx context.Context) map[*auth.Role]bool { - var groups []UserGroup - DBCtx(ctx).Where("user_id = ?", user.ID).Find(&groups) - - roles := make(map[*auth.Role]bool) - - for _, group := range groups { - gr := auth.GetGroupByID(group.GroupID) - for _, role := range gr.Roles { - roles[role] = true - } - } - - return roles -} - -func (user User) GetGroups(ctx context.Context) []*auth.Group { - var groups []UserGroup - DBCtx(ctx).Where("user_id = ?", user.ID).Find(&groups) - - mappedGroups := make([]*auth.Group, len(groups)) - - for i, group := range groups { - mappedGroups[i] = auth.GetGroupByID(group.GroupID) - } - - return mappedGroups -} - -func (user User) SetGroups(ctx context.Context, groups []string) { - var currentGroups []UserGroup - DBCtx(ctx).Unscoped().Where("user_id = ?", user.ID).Find(¤tGroups) - - tx := DBCtx(ctx).Begin() - - for _, group := range groups { - if auth.GetGroupByID(group) == nil { - continue - } - - found := false - var deleted *UserGroup - for _, currentGroup := range currentGroups { - if group == currentGroup.GroupID { - found = true - if currentGroup.DeletedAt.Valid { - deleted = ¤tGroup - } - break - } - } - if !found { - tx.Create(&UserGroup{ - UserID: user.ID, - GroupID: group, - }) - } else if deleted != nil { - deleted.DeletedAt.Valid = false - tx.Unscoped().Save(deleted) - } - } - - for _, currentGroup := range currentGroups { - found := false - for _, group := range groups { - if group == currentGroup.GroupID { - found = true - break - } - } - if !found { - tx.Delete(&UserGroup{ - UserID: user.ID, - GroupID: currentGroup.GroupID, - }) - } - } - - tx.Commit() -} diff --git a/db/postgres/utils.go b/db/postgres/utils.go index 2b1e4ce0..44f119a5 100644 --- a/db/postgres/utils.go +++ b/db/postgres/utils.go @@ -10,10 +10,6 @@ type ( ContextDB struct{} ) -func ContextWithDB(ctx context.Context, db *gorm.DB) context.Context { - return context.WithValue(ctx, ContextDB{}, db) -} - func DBFromContext(ctx context.Context) *gorm.DB { value := ctx.Value(ContextDB{}) diff --git a/db/postgres/version.go b/db/postgres/version.go index ea88cdfe..39d77485 100644 --- a/db/postgres/version.go +++ b/db/postgres/version.go @@ -35,25 +35,6 @@ func GetVersionsByID(ctx context.Context, versionIds []string) []Version { return versions } -func GetModLatestVersions(ctx context.Context, modID string, unapproved bool) *[]Version { - cacheKey := "GetModLatestVersions_" + modID + "_" + fmt.Sprint(unapproved) - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.(*[]Version) - } - - var versions []Version - - DBCtx(ctx).Preload("Targets").Select("distinct on (mod_id, stability) *"). - Where("mod_id = ?", modID). - Where("approved = ? AND denied = ?", !unapproved, false). - Order("mod_id, stability, created_at desc"). - Find(&versions) - - dbCache.Set(cacheKey, &versions, cache.DefaultExpiration) - - return &versions -} - func GetModsLatestVersions(ctx context.Context, modIds []string, unapproved bool) *[]Version { cacheKey := "GetModsLatestVersions_" + strings.Join(modIds, ":") + "_" + fmt.Sprint(unapproved) if versions, ok := dbCache.Get(cacheKey); ok { @@ -297,12 +278,6 @@ func GetVersionTarget(ctx context.Context, versionID string, target string) *Ver return &versionTarget } -func GetVersionDependencies(ctx context.Context, versionID string) []VersionDependency { - var versionDependencies []VersionDependency - DBCtx(ctx).Where("version_id = ?", versionID).Find(&versionDependencies) - return versionDependencies -} - func GetModVersionsConstraint(ctx context.Context, modID string, constraint string) []Version { matches := semverCheck.FindAllStringSubmatch(constraint, -1) if len(matches) == 0 { diff --git a/db/schema/guide.go b/db/schema/guide.go index cd2a42e0..e751cbcb 100644 --- a/db/schema/guide.go +++ b/db/schema/guide.go @@ -20,10 +20,11 @@ func (Guide) Mixin() []ent.Mixin { func (Guide) Fields() []ent.Field { return []ent.Field{ + field.String("user_id").Optional(), field.String("name").MaxLen(32), field.String("short_description").MaxLen(128), field.String("guide"), - field.Int("views"), + field.Int("views").Default(0), } } @@ -31,8 +32,8 @@ func (Guide) Edges() []ent.Edge { return []ent.Edge{ edge.From("user", User.Type). Ref("guides"). - Unique(). - Required(), + Field("user_id"). + Unique(), edge.To("tags", Tag.Type). Through("guide_tags", GuideTag.Type), } diff --git a/db/schema/guide_tags.go b/db/schema/guide_tags.go index a0779518..26fd99e3 100644 --- a/db/schema/guide_tags.go +++ b/db/schema/guide_tags.go @@ -13,13 +13,13 @@ type GuideTag struct { func (GuideTag) Annotations() []schema.Annotation { return []schema.Annotation{ - field.ID("guide_tag", "tag_id"), + field.ID("guide_id", "tag_id"), } } func (GuideTag) Fields() []ent.Field { return []ent.Field{ - field.String("guide_tag"), + field.String("guide_id"), field.String("tag_id"), } } @@ -29,7 +29,7 @@ func (GuideTag) Edges() []ent.Edge { edge.To("guide", Guide.Type). Unique(). Required(). - Field("guide_tag"), + Field("guide_id"), edge.To("tag", Tag.Type). Unique(). Required(). diff --git a/db/schema/mod.go b/db/schema/mod.go index 48dabda8..c00ef7b1 100644 --- a/db/schema/mod.go +++ b/db/schema/mod.go @@ -50,8 +50,7 @@ func (Mod) Indexes() []ent.Index { func (Mod) Edges() []ent.Edge { return []ent.Edge{ - edge.To("versions", Version.Type). - StorageKey(edge.Column("mod_id")), + edge.To("versions", Version.Type), edge.From("authors", User.Type). Ref("mods"). Through("user_mods", UserMod.Type), diff --git a/db/schema/user.go b/db/schema/user.go index 5e59f492..ef793653 100644 --- a/db/schema/user.go +++ b/db/schema/user.go @@ -44,8 +44,7 @@ func (User) Indexes() []ent.Index { func (User) Edges() []ent.Edge { return []ent.Edge{ - edge.To("guides", Guide.Type). - StorageKey(edge.Column("user_id")), + edge.To("guides", Guide.Type), edge.To("sessions", UserSession.Type). StorageKey(edge.Column("user_id")), edge.To("mods", Mod.Type). diff --git a/db/schema/version.go b/db/schema/version.go index 4a588393..b07c5e07 100644 --- a/db/schema/version.go +++ b/db/schema/version.go @@ -20,6 +20,7 @@ func (Version) Mixin() []ent.Mixin { func (Version) Fields() []ent.Field { return []ent.Field{ + field.String("mod_id"), field.String("version").MaxLen(16), field.String("sml_version").MaxLen(16), field.String("changelog"), @@ -43,9 +44,11 @@ func (Version) Edges() []ent.Edge { return []ent.Edge{ edge.From("mod", Mod.Type). Ref("versions"). + Field("mod_id"). Unique(). Required(), edge.To("dependencies", Mod.Type). Through("version_dependencies", VersionDependency.Type), + edge.To("targets", VersionTarget.Type), } } diff --git a/db/schema/version_target.go b/db/schema/version_target.go new file mode 100644 index 00000000..2d9b325e --- /dev/null +++ b/db/schema/version_target.go @@ -0,0 +1,44 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type VersionTarget struct { + ent.Schema +} + +func (VersionTarget) Mixin() []ent.Mixin { + return []ent.Mixin{ + IDMixin{}, + } +} + +func (VersionTarget) Fields() []ent.Field { + return []ent.Field{ + field.String("version_id"), + field.String("target_name"), + field.String("key"), + field.String("hash"), + field.Int64("size"), + } +} + +func (VersionTarget) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("sml_version", Version.Type). + Ref("targets"). + Field("version_id"). + Unique(). + Required(), + } +} + +func (VersionTarget) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("version_id", "target_name").Unique(), + } +} diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 6b302312..dd8d0864 100755 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: '2' services: redis: - image: redis:alpine + image: redis:7.0.14-alpine ports: - 6379:6379 @@ -30,4 +30,5 @@ services: pak_parser: image: ghcr.io/vilsol/ficsit-pak-parser:v0.0.3 ports: - - 50051:50051 \ No newline at end of file + - 50051:50051 + restart: always \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..0c52fe07 --- /dev/null +++ b/flake.lock @@ -0,0 +1,75 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700014976, + "narHash": "sha256-dSGpS2YeJrXW5aH9y7Abd235gGufY3RuZFth6vuyVtU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "592047fc9e4f7b74a4dc85d1b9f5243dfe4899e3", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1701040486, + "narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "45827faa2132b8eade424f6bdd48d8828754341a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..a0b60e3c --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "smr-frontend"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs-unstable.url = "flake:nixpkgs/nixpkgs-unstable"; + }; + + outputs = { self, nixpkgs, flake-utils, nixpkgs-unstable }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + unstable = nixpkgs-unstable.legacyPackages.${system}; in + { + devShells.default = import ./shell.nix { inherit pkgs unstable; }; + } + ); +} \ No newline at end of file diff --git a/generated/conv/guide.go b/generated/conv/guide.go new file mode 100755 index 00000000..03a23dc4 --- /dev/null +++ b/generated/conv/guide.go @@ -0,0 +1,56 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +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 GuideImpl struct{} + +func (c *GuideImpl) Convert(source *ent.Guide) *generated.Guide { + var pGeneratedGuide *generated.Guide + if source != nil { + var generatedGuide generated.Guide + generatedGuide.ID = (*source).ID + generatedGuide.Name = (*source).Name + generatedGuide.ShortDescription = (*source).ShortDescription + generatedGuide.Guide = (*source).Guide + generatedGuide.Views = (*source).Views + generatedGuide.UserID = (*source).UserID + generatedGuide.UpdatedAt = conversion.TimeToString((*source).UpdatedAt) + generatedGuide.CreatedAt = conversion.TimeToString((*source).CreatedAt) + var pGeneratedTagList []*generated.Tag + if (*source).Edges.Tags != nil { + pGeneratedTagList = make([]*generated.Tag, len((*source).Edges.Tags)) + for i := 0; i < len((*source).Edges.Tags); i++ { + pGeneratedTagList[i] = c.pEntTagToPGeneratedTag((*source).Edges.Tags[i]) + } + } + generatedGuide.Tags = pGeneratedTagList + pGeneratedGuide = &generatedGuide + } + return pGeneratedGuide +} +func (c *GuideImpl) ConvertSlice(source []*ent.Guide) []*generated.Guide { + var pGeneratedGuideList []*generated.Guide + if source != nil { + pGeneratedGuideList = make([]*generated.Guide, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedGuideList[i] = c.Convert(source[i]) + } + } + return pGeneratedGuideList +} +func (c *GuideImpl) 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 + pGeneratedTag = &generatedTag + } + return pGeneratedTag +} diff --git a/generated/conv/mod.go b/generated/conv/mod.go new file mode 100755 index 00000000..95fa5e55 --- /dev/null +++ b/generated/conv/mod.go @@ -0,0 +1,96 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +package conv + +import ( + conversion "github.com/satisfactorymodding/smr-api/conversion" + postgres "github.com/satisfactorymodding/smr-api/db/postgres" + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" + "time" +) + +type ModImpl struct{} + +func (c *ModImpl) Convert(source *ent.Mod) *generated.Mod { + var pGeneratedMod *generated.Mod + if source != nil { + var generatedMod generated.Mod + generatedMod.ID = (*source).ID + generatedMod.Name = (*source).Name + generatedMod.ShortDescription = (*source).ShortDescription + pString := (*source).FullDescription + generatedMod.FullDescription = &pString + pString2 := (*source).Logo + generatedMod.Logo = &pString2 + pString3 := (*source).SourceURL + generatedMod.SourceURL = &pString3 + generatedMod.CreatorID = (*source).CreatorID + generatedMod.Approved = (*source).Approved + generatedMod.Views = conversion.UIntToInt((*source).Views) + generatedMod.Downloads = conversion.UIntToInt((*source).Downloads) + generatedMod.Hotness = conversion.UIntToInt((*source).Hotness) + generatedMod.Popularity = conversion.UIntToInt((*source).Popularity) + generatedMod.UpdatedAt = conversion.TimeToString((*source).UpdatedAt) + generatedMod.CreatedAt = conversion.TimeToString((*source).CreatedAt) + generatedMod.LastVersionDate = c.timeTimeToPString((*source).LastVersionDate) + generatedMod.ModReference = (*source).ModReference + generatedMod.Hidden = (*source).Hidden + var pGeneratedTagList []*generated.Tag + if (*source).Edges.Tags != nil { + pGeneratedTagList = make([]*generated.Tag, len((*source).Edges.Tags)) + for i := 0; i < len((*source).Edges.Tags); i++ { + pGeneratedTagList[i] = c.pEntTagToPGeneratedTag((*source).Edges.Tags[i]) + } + } + generatedMod.Tags = pGeneratedTagList + generatedMod.Compatibility = c.pPostgresCompatibilityInfoToPGeneratedCompatibilityInfo((*source).Compatibility) + pGeneratedMod = &generatedMod + } + return pGeneratedMod +} +func (c *ModImpl) ConvertSlice(source []*ent.Mod) []*generated.Mod { + var pGeneratedModList []*generated.Mod + if source != nil { + pGeneratedModList = make([]*generated.Mod, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedModList[i] = c.Convert(source[i]) + } + } + return pGeneratedModList +} +func (c *ModImpl) 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 + pGeneratedTag = &generatedTag + } + return pGeneratedTag +} +func (c *ModImpl) pPostgresCompatibilityInfoToPGeneratedCompatibilityInfo(source *postgres.CompatibilityInfo) *generated.CompatibilityInfo { + var pGeneratedCompatibilityInfo *generated.CompatibilityInfo + if source != nil { + var generatedCompatibilityInfo generated.CompatibilityInfo + generatedCompatibilityInfo.Ea = c.postgresCompatibilityToPGeneratedCompatibility((*source).Ea) + generatedCompatibilityInfo.Exp = c.postgresCompatibilityToPGeneratedCompatibility((*source).Exp) + pGeneratedCompatibilityInfo = &generatedCompatibilityInfo + } + return pGeneratedCompatibilityInfo +} +func (c *ModImpl) postgresCompatibilityToGeneratedCompatibility(source postgres.Compatibility) generated.Compatibility { + var generatedCompatibility generated.Compatibility + generatedCompatibility.State = generated.CompatibilityState(source.State) + pString := source.Note + generatedCompatibility.Note = &pString + return generatedCompatibility +} +func (c *ModImpl) postgresCompatibilityToPGeneratedCompatibility(source postgres.Compatibility) *generated.Compatibility { + generatedCompatibility := c.postgresCompatibilityToGeneratedCompatibility(source) + return &generatedCompatibility +} +func (c *ModImpl) timeTimeToPString(source time.Time) *string { + xstring := conversion.TimeToString(source) + return &xstring +} diff --git a/generated/conv/sml_version.go b/generated/conv/sml_version.go index 97064aae..b283229d 100755 --- a/generated/conv/sml_version.go +++ b/generated/conv/sml_version.go @@ -59,27 +59,3 @@ func (c *SMLVersionImpl) pEntSmlVersionTargetToPGeneratedSMLVersionTarget(source } return pGeneratedSMLVersionTarget } - -type UserImpl struct{} - -func (c *UserImpl) Convert(source *ent.User) *generated.User { - var pGeneratedUser *generated.User - if source != nil { - var generatedUser generated.User - generatedUser.ID = (*source).ID - pString := (*source).Email - generatedUser.Email = &pString - generatedUser.Username = (*source).Username - pString2 := (*source).Avatar - generatedUser.Avatar = &pString2 - generatedUser.CreatedAt = conversion.TimeToString((*source).CreatedAt) - pString3 := (*source).GithubID - generatedUser.GithubID = &pString3 - pString4 := (*source).GoogleID - generatedUser.GoogleID = &pString4 - pString5 := (*source).FacebookID - generatedUser.FacebookID = &pString5 - pGeneratedUser = &generatedUser - } - return pGeneratedUser -} diff --git a/generated/conv/tag.go b/generated/conv/tag.go new file mode 100755 index 00000000..0a910610 --- /dev/null +++ b/generated/conv/tag.go @@ -0,0 +1,31 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +package conv + +import ( + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type TagImpl struct{} + +func (c *TagImpl) Convert(source *ent.Tag) *generated.Tag { + var pGeneratedTag *generated.Tag + if source != nil { + var generatedTag generated.Tag + generatedTag.ID = (*source).ID + generatedTag.Name = (*source).Name + pGeneratedTag = &generatedTag + } + return pGeneratedTag +} +func (c *TagImpl) ConvertSlice(source []*ent.Tag) []*generated.Tag { + var pGeneratedTagList []*generated.Tag + if source != nil { + pGeneratedTagList = make([]*generated.Tag, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedTagList[i] = c.Convert(source[i]) + } + } + return pGeneratedTagList +} diff --git a/generated/conv/user.go b/generated/conv/user.go new file mode 100755 index 00000000..ab2742ae --- /dev/null +++ b/generated/conv/user.go @@ -0,0 +1,43 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +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 UserImpl struct{} + +func (c *UserImpl) Convert(source *ent.User) *generated.User { + var pGeneratedUser *generated.User + if source != nil { + var generatedUser generated.User + generatedUser.ID = (*source).ID + pString := (*source).Email + generatedUser.Email = &pString + generatedUser.Username = (*source).Username + pString2 := (*source).Avatar + generatedUser.Avatar = &pString2 + generatedUser.CreatedAt = conversion.TimeToString((*source).CreatedAt) + pString3 := (*source).GithubID + generatedUser.GithubID = &pString3 + pString4 := (*source).GoogleID + generatedUser.GoogleID = &pString4 + pString5 := (*source).FacebookID + generatedUser.FacebookID = &pString5 + pGeneratedUser = &generatedUser + } + return pGeneratedUser +} +func (c *UserImpl) ConvertSlice(source []*ent.User) []*generated.User { + var pGeneratedUserList []*generated.User + if source != nil { + pGeneratedUserList = make([]*generated.User, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedUserList[i] = c.Convert(source[i]) + } + } + return pGeneratedUserList +} diff --git a/generated/conv/user_mod.go b/generated/conv/user_mod.go new file mode 100755 index 00000000..d0b8cc78 --- /dev/null +++ b/generated/conv/user_mod.go @@ -0,0 +1,32 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +package conv + +import ( + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type UserModImpl struct{} + +func (c *UserModImpl) Convert(source *ent.UserMod) *generated.UserMod { + var pGeneratedUserMod *generated.UserMod + if source != nil { + var generatedUserMod generated.UserMod + generatedUserMod.UserID = (*source).UserID + generatedUserMod.ModID = (*source).ModID + generatedUserMod.Role = (*source).Role + pGeneratedUserMod = &generatedUserMod + } + return pGeneratedUserMod +} +func (c *UserModImpl) ConvertSlice(source []*ent.UserMod) []*generated.UserMod { + var pGeneratedUserModList []*generated.UserMod + if source != nil { + pGeneratedUserModList = make([]*generated.UserMod, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedUserModList[i] = c.Convert(source[i]) + } + } + return pGeneratedUserModList +} diff --git a/generated/conv/version.go b/generated/conv/version.go new file mode 100755 index 00000000..fe15fc4b --- /dev/null +++ b/generated/conv/version.go @@ -0,0 +1,64 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +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 VersionImpl struct{} + +func (c *VersionImpl) Convert(source *ent.Version) *generated.Version { + var pGeneratedVersion *generated.Version + if source != nil { + var generatedVersion generated.Version + generatedVersion.ID = (*source).ID + generatedVersion.ModID = (*source).ModID + generatedVersion.Version = (*source).Version + generatedVersion.SmlVersion = (*source).SmlVersion + generatedVersion.Changelog = (*source).Changelog + generatedVersion.Downloads = conversion.UIntToInt((*source).Downloads) + generatedVersion.Stability = generated.VersionStabilities((*source).Stability) + generatedVersion.Approved = (*source).Approved + generatedVersion.UpdatedAt = conversion.TimeToString((*source).UpdatedAt) + generatedVersion.CreatedAt = conversion.TimeToString((*source).CreatedAt) + var pGeneratedVersionTargetList []*generated.VersionTarget + if (*source).Edges.Targets != nil { + pGeneratedVersionTargetList = make([]*generated.VersionTarget, len((*source).Edges.Targets)) + for i := 0; i < len((*source).Edges.Targets); i++ { + pGeneratedVersionTargetList[i] = c.ConvertTarget((*source).Edges.Targets[i]) + } + } + generatedVersion.Targets = pGeneratedVersionTargetList + pString := (*source).Metadata + generatedVersion.Metadata = &pString + pGeneratedVersion = &generatedVersion + } + return pGeneratedVersion +} +func (c *VersionImpl) ConvertSlice(source []*ent.Version) []*generated.Version { + var pGeneratedVersionList []*generated.Version + if source != nil { + pGeneratedVersionList = make([]*generated.Version, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedVersionList[i] = c.Convert(source[i]) + } + } + return pGeneratedVersionList +} +func (c *VersionImpl) ConvertTarget(source *ent.VersionTarget) *generated.VersionTarget { + var pGeneratedVersionTarget *generated.VersionTarget + if source != nil { + var generatedVersionTarget generated.VersionTarget + generatedVersionTarget.VersionID = (*source).VersionID + generatedVersionTarget.TargetName = generated.TargetName((*source).TargetName) + pInt := conversion.Int64ToInt((*source).Size) + generatedVersionTarget.Size = &pInt + pString := (*source).Hash + generatedVersionTarget.Hash = &pString + pGeneratedVersionTarget = &generatedVersionTarget + } + return pGeneratedVersionTarget +} diff --git a/generated/conv/version_dependency.go b/generated/conv/version_dependency.go new file mode 100755 index 00000000..730b0d7a --- /dev/null +++ b/generated/conv/version_dependency.go @@ -0,0 +1,33 @@ +// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. + +package conv + +import ( + generated "github.com/satisfactorymodding/smr-api/generated" + ent "github.com/satisfactorymodding/smr-api/generated/ent" +) + +type VersionDependencyImpl struct{} + +func (c *VersionDependencyImpl) Convert(source *ent.VersionDependency) *generated.VersionDependency { + var pGeneratedVersionDependency *generated.VersionDependency + if source != nil { + var generatedVersionDependency generated.VersionDependency + generatedVersionDependency.VersionID = (*source).VersionID + generatedVersionDependency.ModID = (*source).ModID + generatedVersionDependency.Condition = (*source).Condition + generatedVersionDependency.Optional = (*source).Optional + pGeneratedVersionDependency = &generatedVersionDependency + } + return pGeneratedVersionDependency +} +func (c *VersionDependencyImpl) ConvertSlice(source []*ent.VersionDependency) []*generated.VersionDependency { + var pGeneratedVersionDependencyList []*generated.VersionDependency + if source != nil { + pGeneratedVersionDependencyList = make([]*generated.VersionDependency, len(source)) + for i := 0; i < len(source); i++ { + pGeneratedVersionDependencyList[i] = c.Convert(source[i]) + } + } + return pGeneratedVersionDependencyList +} diff --git a/generated/ent/announcement_create.go b/generated/ent/announcement_create.go index ea0cd27b..f6ac2679 100644 --- a/generated/ent/announcement_create.go +++ b/generated/ent/announcement_create.go @@ -8,6 +8,8 @@ import ( "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/announcement" @@ -18,6 +20,7 @@ type AnnouncementCreate struct { config mutation *AnnouncementMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -194,6 +197,7 @@ func (ac *AnnouncementCreate) createSpec() (*Announcement, *sqlgraph.CreateSpec) _node = &Announcement{config: ac.config} _spec = sqlgraph.NewCreateSpec(announcement.Table, sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeString)) ) + _spec.OnConflict = ac.conflict if id, ok := ac.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -221,11 +225,267 @@ func (ac *AnnouncementCreate) createSpec() (*Announcement, *sqlgraph.CreateSpec) return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Announcement.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.AnnouncementUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ac *AnnouncementCreate) OnConflict(opts ...sql.ConflictOption) *AnnouncementUpsertOne { + ac.conflict = opts + return &AnnouncementUpsertOne{ + create: ac, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Announcement.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ac *AnnouncementCreate) OnConflictColumns(columns ...string) *AnnouncementUpsertOne { + ac.conflict = append(ac.conflict, sql.ConflictColumns(columns...)) + return &AnnouncementUpsertOne{ + create: ac, + } +} + +type ( + // AnnouncementUpsertOne is the builder for "upsert"-ing + // one Announcement node. + AnnouncementUpsertOne struct { + create *AnnouncementCreate + } + + // AnnouncementUpsert is the "OnConflict" setter. + AnnouncementUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *AnnouncementUpsert) SetUpdatedAt(v time.Time) *AnnouncementUpsert { + u.Set(announcement.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AnnouncementUpsert) UpdateUpdatedAt() *AnnouncementUpsert { + u.SetExcluded(announcement.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AnnouncementUpsert) SetDeletedAt(v time.Time) *AnnouncementUpsert { + u.Set(announcement.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AnnouncementUpsert) UpdateDeletedAt() *AnnouncementUpsert { + u.SetExcluded(announcement.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AnnouncementUpsert) ClearDeletedAt() *AnnouncementUpsert { + u.SetNull(announcement.FieldDeletedAt) + return u +} + +// SetMessage sets the "message" field. +func (u *AnnouncementUpsert) SetMessage(v string) *AnnouncementUpsert { + u.Set(announcement.FieldMessage, v) + return u +} + +// UpdateMessage sets the "message" field to the value that was provided on create. +func (u *AnnouncementUpsert) UpdateMessage() *AnnouncementUpsert { + u.SetExcluded(announcement.FieldMessage) + return u +} + +// SetImportance sets the "importance" field. +func (u *AnnouncementUpsert) SetImportance(v string) *AnnouncementUpsert { + u.Set(announcement.FieldImportance, v) + return u +} + +// UpdateImportance sets the "importance" field to the value that was provided on create. +func (u *AnnouncementUpsert) UpdateImportance() *AnnouncementUpsert { + u.SetExcluded(announcement.FieldImportance) + 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.Announcement.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(announcement.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AnnouncementUpsertOne) UpdateNewValues() *AnnouncementUpsertOne { + 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(announcement.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(announcement.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Announcement.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AnnouncementUpsertOne) Ignore() *AnnouncementUpsertOne { + 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 *AnnouncementUpsertOne) DoNothing() *AnnouncementUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AnnouncementCreate.OnConflict +// documentation for more info. +func (u *AnnouncementUpsertOne) Update(set func(*AnnouncementUpsert)) *AnnouncementUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AnnouncementUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AnnouncementUpsertOne) SetUpdatedAt(v time.Time) *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AnnouncementUpsertOne) UpdateUpdatedAt() *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AnnouncementUpsertOne) SetDeletedAt(v time.Time) *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AnnouncementUpsertOne) UpdateDeletedAt() *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AnnouncementUpsertOne) ClearDeletedAt() *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.ClearDeletedAt() + }) +} + +// SetMessage sets the "message" field. +func (u *AnnouncementUpsertOne) SetMessage(v string) *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.SetMessage(v) + }) +} + +// UpdateMessage sets the "message" field to the value that was provided on create. +func (u *AnnouncementUpsertOne) UpdateMessage() *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateMessage() + }) +} + +// SetImportance sets the "importance" field. +func (u *AnnouncementUpsertOne) SetImportance(v string) *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.SetImportance(v) + }) +} + +// UpdateImportance sets the "importance" field to the value that was provided on create. +func (u *AnnouncementUpsertOne) UpdateImportance() *AnnouncementUpsertOne { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateImportance() + }) +} + +// Exec executes the query. +func (u *AnnouncementUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for AnnouncementCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AnnouncementUpsertOne) 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 *AnnouncementUpsertOne) 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: AnnouncementUpsertOne.ID is not supported by MySQL driver. Use AnnouncementUpsertOne.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 *AnnouncementUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // AnnouncementCreateBulk is the builder for creating many Announcement entities in bulk. type AnnouncementCreateBulk struct { config err error builders []*AnnouncementCreate + conflict []sql.ConflictOption } // Save creates the Announcement entities in the database. @@ -255,6 +515,7 @@ func (acb *AnnouncementCreateBulk) Save(ctx context.Context) ([]*Announcement, e _, err = mutators[i+1].Mutate(root, acb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = acb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, acb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -304,3 +565,183 @@ func (acb *AnnouncementCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Announcement.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.AnnouncementUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (acb *AnnouncementCreateBulk) OnConflict(opts ...sql.ConflictOption) *AnnouncementUpsertBulk { + acb.conflict = opts + return &AnnouncementUpsertBulk{ + create: acb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Announcement.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (acb *AnnouncementCreateBulk) OnConflictColumns(columns ...string) *AnnouncementUpsertBulk { + acb.conflict = append(acb.conflict, sql.ConflictColumns(columns...)) + return &AnnouncementUpsertBulk{ + create: acb, + } +} + +// AnnouncementUpsertBulk is the builder for "upsert"-ing +// a bulk of Announcement nodes. +type AnnouncementUpsertBulk struct { + create *AnnouncementCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Announcement.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(announcement.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AnnouncementUpsertBulk) UpdateNewValues() *AnnouncementUpsertBulk { + 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(announcement.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(announcement.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Announcement.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AnnouncementUpsertBulk) Ignore() *AnnouncementUpsertBulk { + 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 *AnnouncementUpsertBulk) DoNothing() *AnnouncementUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AnnouncementCreateBulk.OnConflict +// documentation for more info. +func (u *AnnouncementUpsertBulk) Update(set func(*AnnouncementUpsert)) *AnnouncementUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AnnouncementUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AnnouncementUpsertBulk) SetUpdatedAt(v time.Time) *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AnnouncementUpsertBulk) UpdateUpdatedAt() *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AnnouncementUpsertBulk) SetDeletedAt(v time.Time) *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AnnouncementUpsertBulk) UpdateDeletedAt() *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AnnouncementUpsertBulk) ClearDeletedAt() *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.ClearDeletedAt() + }) +} + +// SetMessage sets the "message" field. +func (u *AnnouncementUpsertBulk) SetMessage(v string) *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.SetMessage(v) + }) +} + +// UpdateMessage sets the "message" field to the value that was provided on create. +func (u *AnnouncementUpsertBulk) UpdateMessage() *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateMessage() + }) +} + +// SetImportance sets the "importance" field. +func (u *AnnouncementUpsertBulk) SetImportance(v string) *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.SetImportance(v) + }) +} + +// UpdateImportance sets the "importance" field to the value that was provided on create. +func (u *AnnouncementUpsertBulk) UpdateImportance() *AnnouncementUpsertBulk { + return u.Update(func(s *AnnouncementUpsert) { + s.UpdateImportance() + }) +} + +// Exec executes the query. +func (u *AnnouncementUpsertBulk) 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 AnnouncementCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for AnnouncementCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AnnouncementUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/client.go b/generated/ent/client.go index 5b51f8cc..1fd8c57b 100644 --- a/generated/ent/client.go +++ b/generated/ent/client.go @@ -29,6 +29,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" stdsql "database/sql" ) @@ -66,6 +67,8 @@ type Client struct { Version *VersionClient // VersionDependency is the client for interacting with the VersionDependency builders. VersionDependency *VersionDependencyClient + // VersionTarget is the client for interacting with the VersionTarget builders. + VersionTarget *VersionTargetClient } // NewClient creates a new client configured with the given options. @@ -93,6 +96,7 @@ func (c *Client) init() { c.UserSession = NewUserSessionClient(c.config) c.Version = NewVersionClient(c.config) c.VersionDependency = NewVersionDependencyClient(c.config) + c.VersionTarget = NewVersionTargetClient(c.config) } type ( @@ -192,6 +196,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { UserSession: NewUserSessionClient(cfg), Version: NewVersionClient(cfg), VersionDependency: NewVersionDependencyClient(cfg), + VersionTarget: NewVersionTargetClient(cfg), }, nil } @@ -225,6 +230,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) UserSession: NewUserSessionClient(cfg), Version: NewVersionClient(cfg), VersionDependency: NewVersionDependencyClient(cfg), + VersionTarget: NewVersionTargetClient(cfg), }, nil } @@ -256,7 +262,7 @@ func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.SmlVersion, c.SmlVersionTarget, c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, - c.Version, c.VersionDependency, + c.Version, c.VersionDependency, c.VersionTarget, } { n.Use(hooks...) } @@ -268,7 +274,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.Announcement, c.Guide, c.GuideTag, c.Mod, c.ModTag, c.SmlVersion, c.SmlVersionTarget, c.Tag, c.User, c.UserGroup, c.UserMod, c.UserSession, - c.Version, c.VersionDependency, + c.Version, c.VersionDependency, c.VersionTarget, } { n.Intercept(interceptors...) } @@ -305,6 +311,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Version.mutate(ctx, m) case *VersionDependencyMutation: return c.VersionDependency.mutate(ctx, m) + case *VersionTargetMutation: + return c.VersionTarget.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } @@ -685,7 +693,7 @@ func (c *GuideTagClient) Update() *GuideTagUpdate { // UpdateOne returns an update builder for the given entity. func (c *GuideTagClient) UpdateOne(gt *GuideTag) *GuideTagUpdateOne { mutation := newGuideTagMutation(c.config, OpUpdateOne) - mutation.guide = >.GuideTag + mutation.guide = >.GuideID mutation.tag = >.TagID return &GuideTagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -708,14 +716,14 @@ func (c *GuideTagClient) Query() *GuideTagQuery { // QueryGuide queries the guide edge of a GuideTag. func (c *GuideTagClient) QueryGuide(gt *GuideTag) *GuideQuery { return c.Query(). - Where(guidetag.GuideTag(gt.GuideTag), guidetag.TagID(gt.TagID)). + Where(guidetag.GuideID(gt.GuideID), guidetag.TagID(gt.TagID)). QueryGuide() } // QueryTag queries the tag edge of a GuideTag. func (c *GuideTagClient) QueryTag(gt *GuideTag) *TagQuery { return c.Query(). - Where(guidetag.GuideTag(gt.GuideTag), guidetag.TagID(gt.TagID)). + Where(guidetag.GuideID(gt.GuideID), guidetag.TagID(gt.TagID)). QueryTag() } @@ -2379,6 +2387,22 @@ func (c *VersionClient) QueryDependencies(v *Version) *ModQuery { return query } +// QueryTargets queries the targets edge of a Version. +func (c *VersionClient) QueryTargets(v *Version) *VersionTargetQuery { + query := (&VersionTargetClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := v.ID + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, id), + sqlgraph.To(versiontarget.Table, versiontarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, version.TargetsTable, version.TargetsColumn), + ) + fromV = sqlgraph.Neighbors(v.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryVersionDependencies queries the version_dependencies edge of a Version. func (c *VersionClient) QueryVersionDependencies(v *Version) *VersionDependencyQuery { query := (&VersionDependencyClient{config: c.config}).Query() @@ -2540,16 +2564,166 @@ func (c *VersionDependencyClient) mutate(ctx context.Context, m *VersionDependen } } +// VersionTargetClient is a client for the VersionTarget schema. +type VersionTargetClient struct { + config +} + +// NewVersionTargetClient returns a client for the VersionTarget from the given config. +func NewVersionTargetClient(c config) *VersionTargetClient { + return &VersionTargetClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `versiontarget.Hooks(f(g(h())))`. +func (c *VersionTargetClient) Use(hooks ...Hook) { + c.hooks.VersionTarget = append(c.hooks.VersionTarget, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `versiontarget.Intercept(f(g(h())))`. +func (c *VersionTargetClient) Intercept(interceptors ...Interceptor) { + c.inters.VersionTarget = append(c.inters.VersionTarget, interceptors...) +} + +// Create returns a builder for creating a VersionTarget entity. +func (c *VersionTargetClient) Create() *VersionTargetCreate { + mutation := newVersionTargetMutation(c.config, OpCreate) + return &VersionTargetCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of VersionTarget entities. +func (c *VersionTargetClient) CreateBulk(builders ...*VersionTargetCreate) *VersionTargetCreateBulk { + return &VersionTargetCreateBulk{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 *VersionTargetClient) MapCreateBulk(slice any, setFunc func(*VersionTargetCreate, int)) *VersionTargetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VersionTargetCreateBulk{err: fmt.Errorf("calling to VersionTargetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VersionTargetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VersionTargetCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for VersionTarget. +func (c *VersionTargetClient) Update() *VersionTargetUpdate { + mutation := newVersionTargetMutation(c.config, OpUpdate) + return &VersionTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *VersionTargetClient) UpdateOne(vt *VersionTarget) *VersionTargetUpdateOne { + mutation := newVersionTargetMutation(c.config, OpUpdateOne, withVersionTarget(vt)) + return &VersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *VersionTargetClient) UpdateOneID(id string) *VersionTargetUpdateOne { + mutation := newVersionTargetMutation(c.config, OpUpdateOne, withVersionTargetID(id)) + return &VersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for VersionTarget. +func (c *VersionTargetClient) Delete() *VersionTargetDelete { + mutation := newVersionTargetMutation(c.config, OpDelete) + return &VersionTargetDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *VersionTargetClient) DeleteOne(vt *VersionTarget) *VersionTargetDeleteOne { + return c.DeleteOneID(vt.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *VersionTargetClient) DeleteOneID(id string) *VersionTargetDeleteOne { + builder := c.Delete().Where(versiontarget.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &VersionTargetDeleteOne{builder} +} + +// Query returns a query builder for VersionTarget. +func (c *VersionTargetClient) Query() *VersionTargetQuery { + return &VersionTargetQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeVersionTarget}, + inters: c.Interceptors(), + } +} + +// Get returns a VersionTarget entity by its id. +func (c *VersionTargetClient) Get(ctx context.Context, id string) (*VersionTarget, error) { + return c.Query().Where(versiontarget.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *VersionTargetClient) GetX(ctx context.Context, id string) *VersionTarget { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySmlVersion queries the sml_version edge of a VersionTarget. +func (c *VersionTargetClient) QuerySmlVersion(vt *VersionTarget) *VersionQuery { + query := (&VersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := vt.ID + step := sqlgraph.NewStep( + sqlgraph.From(versiontarget.Table, versiontarget.FieldID, id), + sqlgraph.To(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, versiontarget.SmlVersionTable, versiontarget.SmlVersionColumn), + ) + fromV = sqlgraph.Neighbors(vt.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *VersionTargetClient) Hooks() []Hook { + return c.hooks.VersionTarget +} + +// Interceptors returns the client interceptors. +func (c *VersionTargetClient) Interceptors() []Interceptor { + return c.inters.VersionTarget +} + +func (c *VersionTargetClient) mutate(ctx context.Context, m *VersionTargetMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&VersionTargetCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&VersionTargetUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&VersionTargetUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&VersionTargetDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown VersionTarget mutation op: %q", m.Op()) + } +} + // hooks and interceptors per client, for fast access. type ( hooks struct { Announcement, Guide, GuideTag, Mod, ModTag, SmlVersion, SmlVersionTarget, Tag, - User, UserGroup, UserMod, UserSession, Version, VersionDependency []ent.Hook + User, UserGroup, UserMod, UserSession, Version, VersionDependency, + VersionTarget []ent.Hook } inters struct { Announcement, Guide, GuideTag, Mod, ModTag, SmlVersion, SmlVersionTarget, Tag, - User, UserGroup, UserMod, UserSession, Version, - VersionDependency []ent.Interceptor + User, UserGroup, UserMod, UserSession, Version, VersionDependency, + VersionTarget []ent.Interceptor } ) diff --git a/generated/ent/ent.go b/generated/ent/ent.go index 24011c05..7a405694 100644 --- a/generated/ent/ent.go +++ b/generated/ent/ent.go @@ -26,6 +26,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // ent aliases to avoid import conflicts in user's code. @@ -100,6 +101,7 @@ func checkColumn(table, column string) error { usersession.Table: usersession.ValidColumn, version.Table: version.ValidColumn, versiondependency.Table: versiondependency.ValidColumn, + versiontarget.Table: versiontarget.ValidColumn, }) }) return columnCheck(table, column) diff --git a/generated/ent/guide.go b/generated/ent/guide.go index 6ae19858..1fbdd27a 100644 --- a/generated/ent/guide.go +++ b/generated/ent/guide.go @@ -24,6 +24,8 @@ type Guide struct { UpdatedAt time.Time `json:"updated_at,omitempty"` // DeletedAt holds the value of the "deleted_at" field. DeletedAt time.Time `json:"deleted_at,omitempty"` + // UserID holds the value of the "user_id" field. + UserID string `json:"user_id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // ShortDescription holds the value of the "short_description" field. @@ -35,7 +37,6 @@ type Guide struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the GuideQuery when eager-loading is set. Edges GuideEdges `json:"edges"` - user_id *string selectValues sql.SelectValues } @@ -90,12 +91,10 @@ func (*Guide) scanValues(columns []string) ([]any, error) { switch columns[i] { case guide.FieldViews: values[i] = new(sql.NullInt64) - case guide.FieldID, guide.FieldName, guide.FieldShortDescription, guide.FieldGuide: + case guide.FieldID, guide.FieldUserID, guide.FieldName, guide.FieldShortDescription, guide.FieldGuide: values[i] = new(sql.NullString) case guide.FieldCreatedAt, guide.FieldUpdatedAt, guide.FieldDeletedAt: values[i] = new(sql.NullTime) - case guide.ForeignKeys[0]: // user_id - values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) } @@ -135,6 +134,12 @@ func (gu *Guide) assignValues(columns []string, values []any) error { } else if value.Valid { gu.DeletedAt = value.Time } + case guide.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + gu.UserID = value.String + } case guide.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -159,13 +164,6 @@ func (gu *Guide) assignValues(columns []string, values []any) error { } else if value.Valid { gu.Views = int(value.Int64) } - case guide.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field user_id", values[i]) - } else if value.Valid { - gu.user_id = new(string) - *gu.user_id = value.String - } default: gu.selectValues.Set(columns[i], values[i]) } @@ -226,6 +224,9 @@ func (gu *Guide) String() string { builder.WriteString("deleted_at=") builder.WriteString(gu.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(gu.UserID) + builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(gu.Name) builder.WriteString(", ") diff --git a/generated/ent/guide/guide.go b/generated/ent/guide/guide.go index ac5167de..edabfbcd 100644 --- a/generated/ent/guide/guide.go +++ b/generated/ent/guide/guide.go @@ -21,6 +21,8 @@ const ( FieldUpdatedAt = "updated_at" // FieldDeletedAt holds the string denoting the deleted_at field in the database. FieldDeletedAt = "deleted_at" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" // 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. @@ -55,7 +57,7 @@ const ( // It exists in this package in order to avoid circular dependency with the "guidetag" package. GuideTagsInverseTable = "guide_tags" // GuideTagsColumn is the table column denoting the guide_tags relation/edge. - GuideTagsColumn = "guide_tag" + GuideTagsColumn = "guide_id" ) // Columns holds all SQL columns for guide fields. @@ -64,22 +66,17 @@ var Columns = []string{ FieldCreatedAt, FieldUpdatedAt, FieldDeletedAt, + FieldUserID, FieldName, FieldShortDescription, FieldGuide, FieldViews, } -// ForeignKeys holds the SQL foreign-keys that are owned by the "guides" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "user_id", -} - var ( // TagsPrimaryKey and TagsColumn2 are the table columns denoting the // primary key for the tags relation (M2M). - TagsPrimaryKey = []string{"guide_tag", "tag_id"} + TagsPrimaryKey = []string{"guide_id", "tag_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -89,11 +86,6 @@ func ValidColumn(column string) bool { return true } } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } return false } @@ -115,6 +107,8 @@ var ( NameValidator func(string) error // 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 int // DefaultID holds the default value on creation for the "id" field. DefaultID func() string ) @@ -142,6 +136,11 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() } +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() diff --git a/generated/ent/guide/where.go b/generated/ent/guide/where.go index 3945a8e4..a867821e 100644 --- a/generated/ent/guide/where.go +++ b/generated/ent/guide/where.go @@ -80,6 +80,11 @@ func DeletedAt(v time.Time) predicate.Guide { return predicate.Guide(sql.FieldEQ(FieldDeletedAt, v)) } +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldUserID, v)) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.Guide { return predicate.Guide(sql.FieldEQ(FieldName, v)) @@ -230,6 +235,81 @@ func DeletedAtNotNil() predicate.Guide { return predicate.Guide(sql.FieldNotNull(FieldDeletedAt)) } +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.Guide { + return predicate.Guide(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.Guide { + return predicate.Guide(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.Guide { + return predicate.Guide(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.Guide { + return predicate.Guide(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.Guide { + return predicate.Guide(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.Guide { + return predicate.Guide(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.Guide { + return predicate.Guide(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDIsNil applies the IsNil predicate on the "user_id" field. +func UserIDIsNil() predicate.Guide { + return predicate.Guide(sql.FieldIsNull(FieldUserID)) +} + +// UserIDNotNil applies the NotNil predicate on the "user_id" field. +func UserIDNotNil() predicate.Guide { + return predicate.Guide(sql.FieldNotNull(FieldUserID)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.Guide { + return predicate.Guide(sql.FieldContainsFold(FieldUserID, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Guide { return predicate.Guide(sql.FieldEQ(FieldName, v)) diff --git a/generated/ent/guide_create.go b/generated/ent/guide_create.go index 0e5f1533..b36e20aa 100644 --- a/generated/ent/guide_create.go +++ b/generated/ent/guide_create.go @@ -8,6 +8,8 @@ import ( "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/guide" @@ -20,6 +22,7 @@ type GuideCreate struct { config mutation *GuideMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -64,6 +67,20 @@ func (gc *GuideCreate) SetNillableDeletedAt(t *time.Time) *GuideCreate { return gc } +// SetUserID sets the "user_id" field. +func (gc *GuideCreate) SetUserID(s string) *GuideCreate { + gc.mutation.SetUserID(s) + return gc +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (gc *GuideCreate) SetNillableUserID(s *string) *GuideCreate { + if s != nil { + gc.SetUserID(*s) + } + return gc +} + // SetName sets the "name" field. func (gc *GuideCreate) SetName(s string) *GuideCreate { gc.mutation.SetName(s) @@ -88,6 +105,14 @@ func (gc *GuideCreate) SetViews(i int) *GuideCreate { return gc } +// SetNillableViews sets the "views" field if the given value is not nil. +func (gc *GuideCreate) SetNillableViews(i *int) *GuideCreate { + if i != nil { + gc.SetViews(*i) + } + return gc +} + // SetID sets the "id" field. func (gc *GuideCreate) SetID(s string) *GuideCreate { gc.mutation.SetID(s) @@ -102,12 +127,6 @@ func (gc *GuideCreate) SetNillableID(s *string) *GuideCreate { return gc } -// SetUserID sets the "user" edge to the User entity by ID. -func (gc *GuideCreate) SetUserID(id string) *GuideCreate { - gc.mutation.SetUserID(id) - return gc -} - // SetUser sets the "user" edge to the User entity. func (gc *GuideCreate) SetUser(u *User) *GuideCreate { return gc.SetUserID(u.ID) @@ -179,6 +198,10 @@ func (gc *GuideCreate) defaults() error { v := guide.DefaultUpdatedAt() gc.mutation.SetUpdatedAt(v) } + if _, ok := gc.mutation.Views(); !ok { + v := guide.DefaultViews + gc.mutation.SetViews(v) + } if _, ok := gc.mutation.ID(); !ok { if guide.DefaultID == nil { return fmt.Errorf("ent: uninitialized guide.DefaultID (forgotten import ent/runtime?)") @@ -219,9 +242,6 @@ func (gc *GuideCreate) check() error { if _, ok := gc.mutation.Views(); !ok { return &ValidationError{Name: "views", err: errors.New(`ent: missing required field "Guide.views"`)} } - if _, ok := gc.mutation.UserID(); !ok { - return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Guide.user"`)} - } return nil } @@ -253,6 +273,7 @@ func (gc *GuideCreate) createSpec() (*Guide, *sqlgraph.CreateSpec) { _node = &Guide{config: gc.config} _spec = sqlgraph.NewCreateSpec(guide.Table, sqlgraph.NewFieldSpec(guide.FieldID, field.TypeString)) ) + _spec.OnConflict = gc.conflict if id, ok := gc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -299,7 +320,7 @@ func (gc *GuideCreate) createSpec() (*Guide, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.user_id = &nodes[0] + _node.UserID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := gc.mutation.TagsIDs(); len(nodes) > 0 { @@ -321,11 +342,371 @@ func (gc *GuideCreate) createSpec() (*Guide, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Guide.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.GuideUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (gc *GuideCreate) OnConflict(opts ...sql.ConflictOption) *GuideUpsertOne { + gc.conflict = opts + return &GuideUpsertOne{ + create: gc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Guide.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (gc *GuideCreate) OnConflictColumns(columns ...string) *GuideUpsertOne { + gc.conflict = append(gc.conflict, sql.ConflictColumns(columns...)) + return &GuideUpsertOne{ + create: gc, + } +} + +type ( + // GuideUpsertOne is the builder for "upsert"-ing + // one Guide node. + GuideUpsertOne struct { + create *GuideCreate + } + + // GuideUpsert is the "OnConflict" setter. + GuideUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *GuideUpsert) SetUpdatedAt(v time.Time) *GuideUpsert { + u.Set(guide.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *GuideUpsert) UpdateUpdatedAt() *GuideUpsert { + u.SetExcluded(guide.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *GuideUpsert) SetDeletedAt(v time.Time) *GuideUpsert { + u.Set(guide.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *GuideUpsert) UpdateDeletedAt() *GuideUpsert { + u.SetExcluded(guide.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *GuideUpsert) ClearDeletedAt() *GuideUpsert { + u.SetNull(guide.FieldDeletedAt) + return u +} + +// SetUserID sets the "user_id" field. +func (u *GuideUpsert) SetUserID(v string) *GuideUpsert { + u.Set(guide.FieldUserID, v) + return u +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *GuideUpsert) UpdateUserID() *GuideUpsert { + u.SetExcluded(guide.FieldUserID) + return u +} + +// ClearUserID clears the value of the "user_id" field. +func (u *GuideUpsert) ClearUserID() *GuideUpsert { + u.SetNull(guide.FieldUserID) + return u +} + +// SetName sets the "name" field. +func (u *GuideUpsert) SetName(v string) *GuideUpsert { + u.Set(guide.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *GuideUpsert) UpdateName() *GuideUpsert { + u.SetExcluded(guide.FieldName) + return u +} + +// SetShortDescription sets the "short_description" field. +func (u *GuideUpsert) SetShortDescription(v string) *GuideUpsert { + u.Set(guide.FieldShortDescription, v) + return u +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *GuideUpsert) UpdateShortDescription() *GuideUpsert { + u.SetExcluded(guide.FieldShortDescription) + return u +} + +// SetGuide sets the "guide" field. +func (u *GuideUpsert) SetGuide(v string) *GuideUpsert { + u.Set(guide.FieldGuide, v) + return u +} + +// UpdateGuide sets the "guide" field to the value that was provided on create. +func (u *GuideUpsert) UpdateGuide() *GuideUpsert { + u.SetExcluded(guide.FieldGuide) + return u +} + +// SetViews sets the "views" field. +func (u *GuideUpsert) SetViews(v int) *GuideUpsert { + u.Set(guide.FieldViews, v) + return u +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *GuideUpsert) UpdateViews() *GuideUpsert { + u.SetExcluded(guide.FieldViews) + return u +} + +// AddViews adds v to the "views" field. +func (u *GuideUpsert) AddViews(v int) *GuideUpsert { + u.Add(guide.FieldViews, v) + 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.Guide.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(guide.FieldID) +// }), +// ). +// Exec(ctx) +func (u *GuideUpsertOne) UpdateNewValues() *GuideUpsertOne { + 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(guide.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(guide.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Guide.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *GuideUpsertOne) Ignore() *GuideUpsertOne { + 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 *GuideUpsertOne) DoNothing() *GuideUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the GuideCreate.OnConflict +// documentation for more info. +func (u *GuideUpsertOne) Update(set func(*GuideUpsert)) *GuideUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&GuideUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *GuideUpsertOne) SetUpdatedAt(v time.Time) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateUpdatedAt() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *GuideUpsertOne) SetDeletedAt(v time.Time) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateDeletedAt() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *GuideUpsertOne) ClearDeletedAt() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.ClearDeletedAt() + }) +} + +// SetUserID sets the "user_id" field. +func (u *GuideUpsertOne) SetUserID(v string) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateUserID() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateUserID() + }) +} + +// ClearUserID clears the value of the "user_id" field. +func (u *GuideUpsertOne) ClearUserID() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.ClearUserID() + }) +} + +// SetName sets the "name" field. +func (u *GuideUpsertOne) SetName(v string) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateName() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *GuideUpsertOne) SetShortDescription(v string) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateShortDescription() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateShortDescription() + }) +} + +// SetGuide sets the "guide" field. +func (u *GuideUpsertOne) SetGuide(v string) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetGuide(v) + }) +} + +// UpdateGuide sets the "guide" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateGuide() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateGuide() + }) +} + +// SetViews sets the "views" field. +func (u *GuideUpsertOne) SetViews(v int) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *GuideUpsertOne) AddViews(v int) *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *GuideUpsertOne) UpdateViews() *GuideUpsertOne { + return u.Update(func(s *GuideUpsert) { + s.UpdateViews() + }) +} + +// Exec executes the query. +func (u *GuideUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for GuideCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *GuideUpsertOne) 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 *GuideUpsertOne) 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: GuideUpsertOne.ID is not supported by MySQL driver. Use GuideUpsertOne.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 *GuideUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // GuideCreateBulk is the builder for creating many Guide entities in bulk. type GuideCreateBulk struct { config err error builders []*GuideCreate + conflict []sql.ConflictOption } // Save creates the Guide entities in the database. @@ -355,6 +736,7 @@ func (gcb *GuideCreateBulk) Save(ctx context.Context) ([]*Guide, error) { _, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = gcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -404,3 +786,239 @@ func (gcb *GuideCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Guide.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.GuideUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (gcb *GuideCreateBulk) OnConflict(opts ...sql.ConflictOption) *GuideUpsertBulk { + gcb.conflict = opts + return &GuideUpsertBulk{ + create: gcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Guide.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (gcb *GuideCreateBulk) OnConflictColumns(columns ...string) *GuideUpsertBulk { + gcb.conflict = append(gcb.conflict, sql.ConflictColumns(columns...)) + return &GuideUpsertBulk{ + create: gcb, + } +} + +// GuideUpsertBulk is the builder for "upsert"-ing +// a bulk of Guide nodes. +type GuideUpsertBulk struct { + create *GuideCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Guide.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(guide.FieldID) +// }), +// ). +// Exec(ctx) +func (u *GuideUpsertBulk) UpdateNewValues() *GuideUpsertBulk { + 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(guide.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(guide.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Guide.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *GuideUpsertBulk) Ignore() *GuideUpsertBulk { + 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 *GuideUpsertBulk) DoNothing() *GuideUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the GuideCreateBulk.OnConflict +// documentation for more info. +func (u *GuideUpsertBulk) Update(set func(*GuideUpsert)) *GuideUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&GuideUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *GuideUpsertBulk) SetUpdatedAt(v time.Time) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateUpdatedAt() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *GuideUpsertBulk) SetDeletedAt(v time.Time) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateDeletedAt() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *GuideUpsertBulk) ClearDeletedAt() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.ClearDeletedAt() + }) +} + +// SetUserID sets the "user_id" field. +func (u *GuideUpsertBulk) SetUserID(v string) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateUserID() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateUserID() + }) +} + +// ClearUserID clears the value of the "user_id" field. +func (u *GuideUpsertBulk) ClearUserID() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.ClearUserID() + }) +} + +// SetName sets the "name" field. +func (u *GuideUpsertBulk) SetName(v string) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateName() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *GuideUpsertBulk) SetShortDescription(v string) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateShortDescription() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateShortDescription() + }) +} + +// SetGuide sets the "guide" field. +func (u *GuideUpsertBulk) SetGuide(v string) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetGuide(v) + }) +} + +// UpdateGuide sets the "guide" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateGuide() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateGuide() + }) +} + +// SetViews sets the "views" field. +func (u *GuideUpsertBulk) SetViews(v int) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *GuideUpsertBulk) AddViews(v int) *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *GuideUpsertBulk) UpdateViews() *GuideUpsertBulk { + return u.Update(func(s *GuideUpsert) { + s.UpdateViews() + }) +} + +// Exec executes the query. +func (u *GuideUpsertBulk) 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 GuideCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for GuideCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *GuideUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guide_query.go b/generated/ent/guide_query.go index e38779ca..1e233300 100644 --- a/generated/ent/guide_query.go +++ b/generated/ent/guide_query.go @@ -28,7 +28,6 @@ type GuideQuery struct { withUser *UserQuery withTags *TagQuery withGuideTags *GuideTagQuery - withFKs bool modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -443,7 +442,6 @@ func (gq *GuideQuery) prepareQuery(ctx context.Context) error { func (gq *GuideQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Guide, error) { var ( nodes = []*Guide{} - withFKs = gq.withFKs _spec = gq.querySpec() loadedTypes = [3]bool{ gq.withUser != nil, @@ -451,12 +449,6 @@ func (gq *GuideQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Guide, gq.withGuideTags != nil, } ) - if gq.withUser != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, guide.ForeignKeys...) - } _spec.ScanValues = func(columns []string) ([]any, error) { return (*Guide).scanValues(nil, columns) } @@ -505,10 +497,7 @@ func (gq *GuideQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*G ids := make([]string, 0, len(nodes)) nodeids := make(map[string][]*Guide) for i := range nodes { - if nodes[i].user_id == nil { - continue - } - fk := *nodes[i].user_id + fk := nodes[i].UserID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -605,7 +594,7 @@ func (gq *GuideQuery) loadGuideTags(ctx context.Context, query *GuideTagQuery, n } } if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(guidetag.FieldGuideTag) + query.ctx.AppendFieldOnce(guidetag.FieldGuideID) } query.Where(predicate.GuideTag(func(s *sql.Selector) { s.Where(sql.InValues(s.C(guide.GuideTagsColumn), fks...)) @@ -615,10 +604,10 @@ func (gq *GuideQuery) loadGuideTags(ctx context.Context, query *GuideTagQuery, n return err } for _, n := range neighbors { - fk := n.GuideTag + fk := n.GuideID node, ok := nodeids[fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "guide_tag" returned %v for node %v`, fk, n) + return fmt.Errorf(`unexpected referenced foreign-key "guide_id" returned %v for node %v`, fk, n) } assign(node, n) } @@ -653,6 +642,9 @@ func (gq *GuideQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if gq.withUser != nil { + _spec.Node.AddColumnOnce(guide.FieldUserID) + } } if ps := gq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { diff --git a/generated/ent/guide_update.go b/generated/ent/guide_update.go index 282da860..63984888 100644 --- a/generated/ent/guide_update.go +++ b/generated/ent/guide_update.go @@ -57,6 +57,26 @@ func (gu *GuideUpdate) ClearDeletedAt() *GuideUpdate { return gu } +// SetUserID sets the "user_id" field. +func (gu *GuideUpdate) SetUserID(s string) *GuideUpdate { + gu.mutation.SetUserID(s) + return gu +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableUserID(s *string) *GuideUpdate { + if s != nil { + gu.SetUserID(*s) + } + return gu +} + +// ClearUserID clears the value of the "user_id" field. +func (gu *GuideUpdate) ClearUserID() *GuideUpdate { + gu.mutation.ClearUserID() + return gu +} + // SetName sets the "name" field. func (gu *GuideUpdate) SetName(s string) *GuideUpdate { gu.mutation.SetName(s) @@ -82,15 +102,17 @@ func (gu *GuideUpdate) SetViews(i int) *GuideUpdate { return gu } -// AddViews adds i to the "views" field. -func (gu *GuideUpdate) AddViews(i int) *GuideUpdate { - gu.mutation.AddViews(i) +// SetNillableViews sets the "views" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableViews(i *int) *GuideUpdate { + if i != nil { + gu.SetViews(*i) + } return gu } -// SetUserID sets the "user" edge to the User entity by ID. -func (gu *GuideUpdate) SetUserID(id string) *GuideUpdate { - gu.mutation.SetUserID(id) +// AddViews adds i to the "views" field. +func (gu *GuideUpdate) AddViews(i int) *GuideUpdate { + gu.mutation.AddViews(i) return gu } @@ -200,9 +222,6 @@ func (gu *GuideUpdate) check() error { return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Guide.short_description": %w`, err)} } } - if _, ok := gu.mutation.UserID(); gu.mutation.UserCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Guide.user"`) - } return nil } @@ -370,6 +389,26 @@ func (guo *GuideUpdateOne) ClearDeletedAt() *GuideUpdateOne { return guo } +// SetUserID sets the "user_id" field. +func (guo *GuideUpdateOne) SetUserID(s string) *GuideUpdateOne { + guo.mutation.SetUserID(s) + return guo +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableUserID(s *string) *GuideUpdateOne { + if s != nil { + guo.SetUserID(*s) + } + return guo +} + +// ClearUserID clears the value of the "user_id" field. +func (guo *GuideUpdateOne) ClearUserID() *GuideUpdateOne { + guo.mutation.ClearUserID() + return guo +} + // SetName sets the "name" field. func (guo *GuideUpdateOne) SetName(s string) *GuideUpdateOne { guo.mutation.SetName(s) @@ -395,15 +434,17 @@ func (guo *GuideUpdateOne) SetViews(i int) *GuideUpdateOne { return guo } -// AddViews adds i to the "views" field. -func (guo *GuideUpdateOne) AddViews(i int) *GuideUpdateOne { - guo.mutation.AddViews(i) +// SetNillableViews sets the "views" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableViews(i *int) *GuideUpdateOne { + if i != nil { + guo.SetViews(*i) + } return guo } -// SetUserID sets the "user" edge to the User entity by ID. -func (guo *GuideUpdateOne) SetUserID(id string) *GuideUpdateOne { - guo.mutation.SetUserID(id) +// AddViews adds i to the "views" field. +func (guo *GuideUpdateOne) AddViews(i int) *GuideUpdateOne { + guo.mutation.AddViews(i) return guo } @@ -526,9 +567,6 @@ func (guo *GuideUpdateOne) check() error { return &ValidationError{Name: "short_description", err: fmt.Errorf(`ent: validator failed for field "Guide.short_description": %w`, err)} } } - if _, ok := guo.mutation.UserID(); guo.mutation.UserCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Guide.user"`) - } return nil } diff --git a/generated/ent/guidetag.go b/generated/ent/guidetag.go index d2442d9c..ef3e2e7f 100644 --- a/generated/ent/guidetag.go +++ b/generated/ent/guidetag.go @@ -16,8 +16,8 @@ import ( // GuideTag is the model entity for the GuideTag schema. type GuideTag struct { config `json:"-"` - // GuideTag holds the value of the "guide_tag" field. - GuideTag string `json:"guide_tag,omitempty"` + // GuideID holds the value of the "guide_id" field. + GuideID string `json:"guide_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. @@ -68,7 +68,7 @@ func (*GuideTag) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case guidetag.FieldGuideTag, guidetag.FieldTagID: + case guidetag.FieldGuideID, guidetag.FieldTagID: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -85,11 +85,11 @@ func (gt *GuideTag) assignValues(columns []string, values []any) error { } for i := range columns { switch columns[i] { - case guidetag.FieldGuideTag: + case guidetag.FieldGuideID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field guide_tag", values[i]) + return fmt.Errorf("unexpected type %T for field guide_id", values[i]) } else if value.Valid { - gt.GuideTag = value.String + gt.GuideID = value.String } case guidetag.FieldTagID: if value, ok := values[i].(*sql.NullString); !ok { @@ -142,8 +142,8 @@ func (gt *GuideTag) Unwrap() *GuideTag { func (gt *GuideTag) String() string { var builder strings.Builder builder.WriteString("GuideTag(") - builder.WriteString("guide_tag=") - builder.WriteString(gt.GuideTag) + builder.WriteString("guide_id=") + builder.WriteString(gt.GuideID) builder.WriteString(", ") builder.WriteString("tag_id=") builder.WriteString(gt.TagID) diff --git a/generated/ent/guidetag/guidetag.go b/generated/ent/guidetag/guidetag.go index 4dbe2e5e..2f66739b 100644 --- a/generated/ent/guidetag/guidetag.go +++ b/generated/ent/guidetag/guidetag.go @@ -10,8 +10,8 @@ import ( const ( // Label holds the string label denoting the guidetag type in the database. Label = "guide_tag" - // FieldGuideTag holds the string denoting the guide_tag field in the database. - FieldGuideTag = "guide_tag" + // FieldGuideID holds the string denoting the guide_id field in the database. + FieldGuideID = "guide_id" // FieldTagID holds the string denoting the tag_id field in the database. FieldTagID = "tag_id" // EdgeGuide holds the string denoting the guide edge name in mutations. @@ -30,7 +30,7 @@ const ( // It exists in this package in order to avoid circular dependency with the "guide" package. GuideInverseTable = "guides" // GuideColumn is the table column denoting the guide relation/edge. - GuideColumn = "guide_tag" + GuideColumn = "guide_id" // TagTable is the table that holds the tag relation/edge. TagTable = "guide_tags" // TagInverseTable is the table name for the Tag entity. @@ -42,7 +42,7 @@ const ( // Columns holds all SQL columns for guidetag fields. var Columns = []string{ - FieldGuideTag, + FieldGuideID, FieldTagID, } @@ -59,9 +59,9 @@ func ValidColumn(column string) bool { // OrderOption defines the ordering options for the GuideTag queries. type OrderOption func(*sql.Selector) -// ByGuideTag orders the results by the guide_tag field. -func ByGuideTag(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldGuideTag, opts...).ToFunc() +// ByGuideID orders the results by the guide_id field. +func ByGuideID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGuideID, opts...).ToFunc() } // ByTagID orders the results by the tag_id field. diff --git a/generated/ent/guidetag/where.go b/generated/ent/guidetag/where.go index 3dbf826d..62943a32 100644 --- a/generated/ent/guidetag/where.go +++ b/generated/ent/guidetag/where.go @@ -8,9 +8,9 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/predicate" ) -// GuideTag applies equality check predicate on the "guide_tag" field. It's identical to GuideTagEQ. -func GuideTag(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldEQ(FieldGuideTag, v)) +// GuideID applies equality check predicate on the "guide_id" field. It's identical to GuideIDEQ. +func GuideID(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldGuideID, v)) } // TagID applies equality check predicate on the "tag_id" field. It's identical to TagIDEQ. @@ -18,69 +18,69 @@ func TagID(v string) predicate.GuideTag { return predicate.GuideTag(sql.FieldEQ(FieldTagID, v)) } -// GuideTagEQ applies the EQ predicate on the "guide_tag" field. -func GuideTagEQ(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldEQ(FieldGuideTag, v)) +// GuideIDEQ applies the EQ predicate on the "guide_id" field. +func GuideIDEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEQ(FieldGuideID, v)) } -// GuideTagNEQ applies the NEQ predicate on the "guide_tag" field. -func GuideTagNEQ(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldNEQ(FieldGuideTag, v)) +// GuideIDNEQ applies the NEQ predicate on the "guide_id" field. +func GuideIDNEQ(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNEQ(FieldGuideID, v)) } -// GuideTagIn applies the In predicate on the "guide_tag" field. -func GuideTagIn(vs ...string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldIn(FieldGuideTag, vs...)) +// GuideIDIn applies the In predicate on the "guide_id" field. +func GuideIDIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldIn(FieldGuideID, vs...)) } -// GuideTagNotIn applies the NotIn predicate on the "guide_tag" field. -func GuideTagNotIn(vs ...string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldNotIn(FieldGuideTag, vs...)) +// GuideIDNotIn applies the NotIn predicate on the "guide_id" field. +func GuideIDNotIn(vs ...string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldNotIn(FieldGuideID, vs...)) } -// GuideTagGT applies the GT predicate on the "guide_tag" field. -func GuideTagGT(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldGT(FieldGuideTag, v)) +// GuideIDGT applies the GT predicate on the "guide_id" field. +func GuideIDGT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGT(FieldGuideID, v)) } -// GuideTagGTE applies the GTE predicate on the "guide_tag" field. -func GuideTagGTE(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldGTE(FieldGuideTag, v)) +// GuideIDGTE applies the GTE predicate on the "guide_id" field. +func GuideIDGTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldGTE(FieldGuideID, v)) } -// GuideTagLT applies the LT predicate on the "guide_tag" field. -func GuideTagLT(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldLT(FieldGuideTag, v)) +// GuideIDLT applies the LT predicate on the "guide_id" field. +func GuideIDLT(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLT(FieldGuideID, v)) } -// GuideTagLTE applies the LTE predicate on the "guide_tag" field. -func GuideTagLTE(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldLTE(FieldGuideTag, v)) +// GuideIDLTE applies the LTE predicate on the "guide_id" field. +func GuideIDLTE(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldLTE(FieldGuideID, v)) } -// GuideTagContains applies the Contains predicate on the "guide_tag" field. -func GuideTagContains(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldContains(FieldGuideTag, v)) +// GuideIDContains applies the Contains predicate on the "guide_id" field. +func GuideIDContains(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContains(FieldGuideID, v)) } -// GuideTagHasPrefix applies the HasPrefix predicate on the "guide_tag" field. -func GuideTagHasPrefix(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldHasPrefix(FieldGuideTag, v)) +// GuideIDHasPrefix applies the HasPrefix predicate on the "guide_id" field. +func GuideIDHasPrefix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasPrefix(FieldGuideID, v)) } -// GuideTagHasSuffix applies the HasSuffix predicate on the "guide_tag" field. -func GuideTagHasSuffix(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldHasSuffix(FieldGuideTag, v)) +// GuideIDHasSuffix applies the HasSuffix predicate on the "guide_id" field. +func GuideIDHasSuffix(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldHasSuffix(FieldGuideID, v)) } -// GuideTagEqualFold applies the EqualFold predicate on the "guide_tag" field. -func GuideTagEqualFold(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldEqualFold(FieldGuideTag, v)) +// GuideIDEqualFold applies the EqualFold predicate on the "guide_id" field. +func GuideIDEqualFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldEqualFold(FieldGuideID, v)) } -// GuideTagContainsFold applies the ContainsFold predicate on the "guide_tag" field. -func GuideTagContainsFold(v string) predicate.GuideTag { - return predicate.GuideTag(sql.FieldContainsFold(FieldGuideTag, v)) +// GuideIDContainsFold applies the ContainsFold predicate on the "guide_id" field. +func GuideIDContainsFold(v string) predicate.GuideTag { + return predicate.GuideTag(sql.FieldContainsFold(FieldGuideID, v)) } // TagIDEQ applies the EQ predicate on the "tag_id" field. diff --git a/generated/ent/guidetag_create.go b/generated/ent/guidetag_create.go index 71aaea6c..6d56ae1d 100644 --- a/generated/ent/guidetag_create.go +++ b/generated/ent/guidetag_create.go @@ -7,6 +7,7 @@ import ( "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/guide" @@ -19,11 +20,12 @@ type GuideTagCreate struct { config mutation *GuideTagMutation hooks []Hook + conflict []sql.ConflictOption } -// SetGuideTag sets the "guide_tag" field. -func (gtc *GuideTagCreate) SetGuideTag(s string) *GuideTagCreate { - gtc.mutation.SetGuideTag(s) +// SetGuideID sets the "guide_id" field. +func (gtc *GuideTagCreate) SetGuideID(s string) *GuideTagCreate { + gtc.mutation.SetGuideID(s) return gtc } @@ -33,12 +35,6 @@ func (gtc *GuideTagCreate) SetTagID(s string) *GuideTagCreate { return gtc } -// SetGuideID sets the "guide" edge to the Guide entity by ID. -func (gtc *GuideTagCreate) SetGuideID(id string) *GuideTagCreate { - gtc.mutation.SetGuideID(id) - return gtc -} - // SetGuide sets the "guide" edge to the Guide entity. func (gtc *GuideTagCreate) SetGuide(g *Guide) *GuideTagCreate { return gtc.SetGuideID(g.ID) @@ -83,8 +79,8 @@ func (gtc *GuideTagCreate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (gtc *GuideTagCreate) check() error { - if _, ok := gtc.mutation.GuideTag(); !ok { - return &ValidationError{Name: "guide_tag", err: errors.New(`ent: missing required field "GuideTag.guide_tag"`)} + if _, ok := gtc.mutation.GuideID(); !ok { + return &ValidationError{Name: "guide_id", err: errors.New(`ent: missing required field "GuideTag.guide_id"`)} } if _, ok := gtc.mutation.TagID(); !ok { return &ValidationError{Name: "tag_id", err: errors.New(`ent: missing required field "GuideTag.tag_id"`)} @@ -117,6 +113,7 @@ func (gtc *GuideTagCreate) createSpec() (*GuideTag, *sqlgraph.CreateSpec) { _node = &GuideTag{config: gtc.config} _spec = sqlgraph.NewCreateSpec(guidetag.Table, nil) ) + _spec.OnConflict = gtc.conflict if nodes := gtc.mutation.GuideIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -131,7 +128,7 @@ func (gtc *GuideTagCreate) createSpec() (*GuideTag, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.GuideTag = nodes[0] + _node.GuideID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := gtc.mutation.TagIDs(); len(nodes) > 0 { @@ -154,11 +151,168 @@ func (gtc *GuideTagCreate) createSpec() (*GuideTag, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.GuideTag.Create(). +// SetGuideID(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.GuideTagUpsert) { +// SetGuideID(v+v). +// }). +// Exec(ctx) +func (gtc *GuideTagCreate) OnConflict(opts ...sql.ConflictOption) *GuideTagUpsertOne { + gtc.conflict = opts + return &GuideTagUpsertOne{ + create: gtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.GuideTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (gtc *GuideTagCreate) OnConflictColumns(columns ...string) *GuideTagUpsertOne { + gtc.conflict = append(gtc.conflict, sql.ConflictColumns(columns...)) + return &GuideTagUpsertOne{ + create: gtc, + } +} + +type ( + // GuideTagUpsertOne is the builder for "upsert"-ing + // one GuideTag node. + GuideTagUpsertOne struct { + create *GuideTagCreate + } + + // GuideTagUpsert is the "OnConflict" setter. + GuideTagUpsert struct { + *sql.UpdateSet + } +) + +// SetGuideID sets the "guide_id" field. +func (u *GuideTagUpsert) SetGuideID(v string) *GuideTagUpsert { + u.Set(guidetag.FieldGuideID, v) + return u +} + +// UpdateGuideID sets the "guide_id" field to the value that was provided on create. +func (u *GuideTagUpsert) UpdateGuideID() *GuideTagUpsert { + u.SetExcluded(guidetag.FieldGuideID) + return u +} + +// SetTagID sets the "tag_id" field. +func (u *GuideTagUpsert) SetTagID(v string) *GuideTagUpsert { + u.Set(guidetag.FieldTagID, v) + return u +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *GuideTagUpsert) UpdateTagID() *GuideTagUpsert { + u.SetExcluded(guidetag.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.GuideTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *GuideTagUpsertOne) UpdateNewValues() *GuideTagUpsertOne { + 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.GuideTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *GuideTagUpsertOne) Ignore() *GuideTagUpsertOne { + 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 *GuideTagUpsertOne) DoNothing() *GuideTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the GuideTagCreate.OnConflict +// documentation for more info. +func (u *GuideTagUpsertOne) Update(set func(*GuideTagUpsert)) *GuideTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&GuideTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetGuideID sets the "guide_id" field. +func (u *GuideTagUpsertOne) SetGuideID(v string) *GuideTagUpsertOne { + return u.Update(func(s *GuideTagUpsert) { + s.SetGuideID(v) + }) +} + +// UpdateGuideID sets the "guide_id" field to the value that was provided on create. +func (u *GuideTagUpsertOne) UpdateGuideID() *GuideTagUpsertOne { + return u.Update(func(s *GuideTagUpsert) { + s.UpdateGuideID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *GuideTagUpsertOne) SetTagID(v string) *GuideTagUpsertOne { + return u.Update(func(s *GuideTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *GuideTagUpsertOne) UpdateTagID() *GuideTagUpsertOne { + return u.Update(func(s *GuideTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *GuideTagUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for GuideTagCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *GuideTagUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + // GuideTagCreateBulk is the builder for creating many GuideTag entities in bulk. type GuideTagCreateBulk struct { config err error builders []*GuideTagCreate + conflict []sql.ConflictOption } // Save creates the GuideTag entities in the database. @@ -187,6 +341,7 @@ func (gtcb *GuideTagCreateBulk) Save(ctx context.Context) ([]*GuideTag, error) { _, err = mutators[i+1].Mutate(root, gtcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = gtcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gtcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -235,3 +390,135 @@ func (gtcb *GuideTagCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.GuideTag.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.GuideTagUpsert) { +// SetGuideID(v+v). +// }). +// Exec(ctx) +func (gtcb *GuideTagCreateBulk) OnConflict(opts ...sql.ConflictOption) *GuideTagUpsertBulk { + gtcb.conflict = opts + return &GuideTagUpsertBulk{ + create: gtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.GuideTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (gtcb *GuideTagCreateBulk) OnConflictColumns(columns ...string) *GuideTagUpsertBulk { + gtcb.conflict = append(gtcb.conflict, sql.ConflictColumns(columns...)) + return &GuideTagUpsertBulk{ + create: gtcb, + } +} + +// GuideTagUpsertBulk is the builder for "upsert"-ing +// a bulk of GuideTag nodes. +type GuideTagUpsertBulk struct { + create *GuideTagCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.GuideTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *GuideTagUpsertBulk) UpdateNewValues() *GuideTagUpsertBulk { + 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.GuideTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *GuideTagUpsertBulk) Ignore() *GuideTagUpsertBulk { + 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 *GuideTagUpsertBulk) DoNothing() *GuideTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the GuideTagCreateBulk.OnConflict +// documentation for more info. +func (u *GuideTagUpsertBulk) Update(set func(*GuideTagUpsert)) *GuideTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&GuideTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetGuideID sets the "guide_id" field. +func (u *GuideTagUpsertBulk) SetGuideID(v string) *GuideTagUpsertBulk { + return u.Update(func(s *GuideTagUpsert) { + s.SetGuideID(v) + }) +} + +// UpdateGuideID sets the "guide_id" field to the value that was provided on create. +func (u *GuideTagUpsertBulk) UpdateGuideID() *GuideTagUpsertBulk { + return u.Update(func(s *GuideTagUpsert) { + s.UpdateGuideID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *GuideTagUpsertBulk) SetTagID(v string) *GuideTagUpsertBulk { + return u.Update(func(s *GuideTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *GuideTagUpsertBulk) UpdateTagID() *GuideTagUpsertBulk { + return u.Update(func(s *GuideTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *GuideTagUpsertBulk) 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 GuideTagCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for GuideTagCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *GuideTagUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/guidetag_query.go b/generated/ent/guidetag_query.go index 8845f619..c2502fe6 100644 --- a/generated/ent/guidetag_query.go +++ b/generated/ent/guidetag_query.go @@ -261,12 +261,12 @@ func (gtq *GuideTagQuery) WithTag(opts ...func(*TagQuery)) *GuideTagQuery { // Example: // // var v []struct { -// GuideTag string `json:"guide_tag,omitempty"` +// GuideID string `json:"guide_id,omitempty"` // Count int `json:"count,omitempty"` // } // // client.GuideTag.Query(). -// GroupBy(guidetag.FieldGuideTag). +// GroupBy(guidetag.FieldGuideID). // Aggregate(ent.Count()). // Scan(ctx, &v) func (gtq *GuideTagQuery) GroupBy(field string, fields ...string) *GuideTagGroupBy { @@ -284,11 +284,11 @@ func (gtq *GuideTagQuery) GroupBy(field string, fields ...string) *GuideTagGroup // Example: // // var v []struct { -// GuideTag string `json:"guide_tag,omitempty"` +// GuideID string `json:"guide_id,omitempty"` // } // // client.GuideTag.Query(). -// Select(guidetag.FieldGuideTag). +// Select(guidetag.FieldGuideID). // Scan(ctx, &v) func (gtq *GuideTagQuery) Select(fields ...string) *GuideTagSelect { gtq.ctx.Fields = append(gtq.ctx.Fields, fields...) @@ -378,7 +378,7 @@ func (gtq *GuideTagQuery) loadGuide(ctx context.Context, query *GuideQuery, node ids := make([]string, 0, len(nodes)) nodeids := make(map[string][]*GuideTag) for i := range nodes { - fk := nodes[i].GuideTag + fk := nodes[i].GuideID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -395,7 +395,7 @@ func (gtq *GuideTagQuery) loadGuide(ctx context.Context, query *GuideQuery, node for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "guide_tag" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "guide_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -457,7 +457,7 @@ func (gtq *GuideTagQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } if gtq.withGuide != nil { - _spec.Node.AddColumnOnce(guidetag.FieldGuideTag) + _spec.Node.AddColumnOnce(guidetag.FieldGuideID) } if gtq.withTag != nil { _spec.Node.AddColumnOnce(guidetag.FieldTagID) diff --git a/generated/ent/guidetag_update.go b/generated/ent/guidetag_update.go index 5bf54bdd..70bcf034 100644 --- a/generated/ent/guidetag_update.go +++ b/generated/ent/guidetag_update.go @@ -30,9 +30,9 @@ func (gtu *GuideTagUpdate) Where(ps ...predicate.GuideTag) *GuideTagUpdate { return gtu } -// SetGuideTag sets the "guide_tag" field. -func (gtu *GuideTagUpdate) SetGuideTag(s string) *GuideTagUpdate { - gtu.mutation.SetGuideTag(s) +// SetGuideID sets the "guide_id" field. +func (gtu *GuideTagUpdate) SetGuideID(s string) *GuideTagUpdate { + gtu.mutation.SetGuideID(s) return gtu } @@ -42,12 +42,6 @@ func (gtu *GuideTagUpdate) SetTagID(s string) *GuideTagUpdate { return gtu } -// SetGuideID sets the "guide" edge to the Guide entity by ID. -func (gtu *GuideTagUpdate) SetGuideID(id string) *GuideTagUpdate { - gtu.mutation.SetGuideID(id) - return gtu -} - // SetGuide sets the "guide" edge to the Guide entity. func (gtu *GuideTagUpdate) SetGuide(g *Guide) *GuideTagUpdate { return gtu.SetGuideID(g.ID) @@ -123,7 +117,7 @@ func (gtu *GuideTagUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := gtu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideTag, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) + _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideID, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) if ps := gtu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -211,9 +205,9 @@ type GuideTagUpdateOne struct { modifiers []func(*sql.UpdateBuilder) } -// SetGuideTag sets the "guide_tag" field. -func (gtuo *GuideTagUpdateOne) SetGuideTag(s string) *GuideTagUpdateOne { - gtuo.mutation.SetGuideTag(s) +// SetGuideID sets the "guide_id" field. +func (gtuo *GuideTagUpdateOne) SetGuideID(s string) *GuideTagUpdateOne { + gtuo.mutation.SetGuideID(s) return gtuo } @@ -223,12 +217,6 @@ func (gtuo *GuideTagUpdateOne) SetTagID(s string) *GuideTagUpdateOne { return gtuo } -// SetGuideID sets the "guide" edge to the Guide entity by ID. -func (gtuo *GuideTagUpdateOne) SetGuideID(id string) *GuideTagUpdateOne { - gtuo.mutation.SetGuideID(id) - return gtuo -} - // SetGuide sets the "guide" edge to the Guide entity. func (gtuo *GuideTagUpdateOne) SetGuide(g *Guide) *GuideTagUpdateOne { return gtuo.SetGuideID(g.ID) @@ -317,9 +305,9 @@ func (gtuo *GuideTagUpdateOne) sqlSave(ctx context.Context) (_node *GuideTag, er if err := gtuo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideTag, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) - if id, ok := gtuo.mutation.GuideTag(); !ok { - return nil, &ValidationError{Name: "guide_tag", err: errors.New(`ent: missing "GuideTag.guide_tag" for update`)} + _spec := sqlgraph.NewUpdateSpec(guidetag.Table, guidetag.Columns, sqlgraph.NewFieldSpec(guidetag.FieldGuideID, field.TypeString), sqlgraph.NewFieldSpec(guidetag.FieldTagID, field.TypeString)) + if id, ok := gtuo.mutation.GuideID(); !ok { + return nil, &ValidationError{Name: "guide_id", err: errors.New(`ent: missing "GuideTag.guide_id" for update`)} } else { _spec.Node.CompositeID[0].Value = id } diff --git a/generated/ent/hook/hook.go b/generated/ent/hook/hook.go index 01347f9f..a8cdff9f 100644 --- a/generated/ent/hook/hook.go +++ b/generated/ent/hook/hook.go @@ -177,6 +177,18 @@ func (f VersionDependencyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent. return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VersionDependencyMutation", m) } +// The VersionTargetFunc type is an adapter to allow the use of ordinary +// function as VersionTarget mutator. +type VersionTargetFunc func(context.Context, *ent.VersionTargetMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f VersionTargetFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.VersionTargetMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VersionTargetMutation", m) +} + // Condition is a hook condition function. type Condition func(context.Context, ent.Mutation) bool diff --git a/generated/ent/intercept/intercept.go b/generated/ent/intercept/intercept.go index 63d93251..dc20eea9 100644 --- a/generated/ent/intercept/intercept.go +++ b/generated/ent/intercept/intercept.go @@ -23,6 +23,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // The Query interface represents an operation that queries a graph. @@ -459,6 +460,33 @@ func (f TraverseVersionDependency) Traverse(ctx context.Context, q ent.Query) er return fmt.Errorf("unexpected query type %T. expect *ent.VersionDependencyQuery", q) } +// The VersionTargetFunc type is an adapter to allow the use of ordinary function as a Querier. +type VersionTargetFunc func(context.Context, *ent.VersionTargetQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f VersionTargetFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.VersionTargetQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.VersionTargetQuery", q) +} + +// The TraverseVersionTarget type is an adapter to allow the use of ordinary function as Traverser. +type TraverseVersionTarget func(context.Context, *ent.VersionTargetQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseVersionTarget) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseVersionTarget) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.VersionTargetQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.VersionTargetQuery", q) +} + // NewQuery returns the generic Query interface for the given typed query. func NewQuery(q ent.Query) (Query, error) { switch q := q.(type) { @@ -490,6 +518,8 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.VersionQuery, predicate.Version, version.OrderOption]{typ: ent.TypeVersion, tq: q}, nil case *ent.VersionDependencyQuery: return &query[*ent.VersionDependencyQuery, predicate.VersionDependency, versiondependency.OrderOption]{typ: ent.TypeVersionDependency, tq: q}, nil + case *ent.VersionTargetQuery: + return &query[*ent.VersionTargetQuery, predicate.VersionTarget, versiontarget.OrderOption]{typ: ent.TypeVersionTarget, tq: q}, nil default: return nil, fmt.Errorf("unknown query type %T", q) } diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go index 742d9dda..c28a258c 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":["id"]},{"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","ref_name":"guides","unique":true,"inverse":true,"required":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":"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":"guide","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"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_tag","unique":true,"required":true},{"name":"tag","type":"Tag","field":"tag_id","unique":true,"required":true}],"fields":[{"name":"guide_tag","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_tag","tag_id"],"StructTag":null}}},{"name":"Mod","config":{"Table":""},"edges":[{"name":"versions","type":"Version","storage_key":{"Table":"","Symbols":null,"Columns":["mod_id"]}},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"MixedIn":false,"MixinIndex":0}},{"name":"popularity","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"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":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"hidden","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"compatibility","type":{"Type":3,"Ident":"*postgres.CompatibilityInfo","PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","PkgName":"postgres","Nillable":true,"RType":{"Name":"CompatibilityInfo","Ident":"postgres.CompatibilityInfo","Kind":22,"PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","Methods":{}}},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"smlversion.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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","storage_key":{"Table":"","Symbols":null,"Columns":["user_id"]}},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"Version","config":{"Table":""},"edges":[{"name":"mod","type":"Mod","ref_name":"versions","unique":true,"inverse":true,"required":true},{"name":"dependencies","type":"Mod","through":{"N":"version_dependencies","T":"VersionDependency"}}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"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":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"version.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":5,"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":6,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"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":8,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"validators":2,"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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}}}],"Features":["sql/modifier","intercept","schema/snapshot","sql/execquery"]}` +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":["id"]},{"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":["id"]},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"MixedIn":false,"MixinIndex":0}},{"name":"popularity","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"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":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"hidden","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"compatibility","type":{"Type":3,"Ident":"*postgres.CompatibilityInfo","PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","PkgName":"postgres","Nillable":true,"RType":{"Name":"CompatibilityInfo","Ident":"postgres.CompatibilityInfo","Kind":22,"PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","Methods":{}}},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"smlversion.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"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"}],"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":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"version.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"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":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"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":9,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"validators":2,"position":{"Index":16,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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":"sml_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},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_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 37104bf6..8b7fdad0 100644 --- a/generated/ent/migrate/schema.go +++ b/generated/ent/migrate/schema.go @@ -44,8 +44,8 @@ var ( {Name: "name", Type: field.TypeString, Size: 32}, {Name: "short_description", Type: field.TypeString, Size: 128}, {Name: "guide", Type: field.TypeString}, - {Name: "views", Type: field.TypeInt}, - {Name: "user_id", Type: field.TypeString}, + {Name: "views", Type: field.TypeInt, Default: 0}, + {Name: "user_id", Type: field.TypeString, Nullable: true}, } // GuidesTable holds the schema information for the "guides" table. GuidesTable = &schema.Table{ @@ -57,7 +57,7 @@ var ( Symbol: "guides_users_guides", Columns: []*schema.Column{GuidesColumns[8]}, RefColumns: []*schema.Column{UsersColumns[0]}, - OnDelete: schema.NoAction, + OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ @@ -75,7 +75,7 @@ var ( } // GuideTagsColumns holds the columns for the "guide_tags" table. GuideTagsColumns = []*schema.Column{ - {Name: "guide_tag", Type: field.TypeString}, + {Name: "guide_id", Type: field.TypeString}, {Name: "tag_id", Type: field.TypeString}, } // GuideTagsTable holds the schema information for the "guide_tags" table. @@ -504,6 +504,41 @@ var ( }, }, } + // VersionTargetsColumns holds the columns for the "version_targets" table. + VersionTargetsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "target_name", Type: field.TypeString}, + {Name: "key", Type: field.TypeString}, + {Name: "hash", Type: field.TypeString}, + {Name: "size", Type: field.TypeInt64}, + {Name: "version_id", Type: field.TypeString}, + } + // VersionTargetsTable holds the schema information for the "version_targets" table. + VersionTargetsTable = &schema.Table{ + Name: "version_targets", + Columns: VersionTargetsColumns, + PrimaryKey: []*schema.Column{VersionTargetsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "version_targets_versions_targets", + Columns: []*schema.Column{VersionTargetsColumns[5]}, + RefColumns: []*schema.Column{VersionsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "versiontarget_id", + Unique: false, + Columns: []*schema.Column{VersionTargetsColumns[0]}, + }, + { + Name: "versiontarget_version_id_target_name", + Unique: true, + Columns: []*schema.Column{VersionTargetsColumns[5], VersionTargetsColumns[1]}, + }, + }, + } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AnnouncementsTable, @@ -520,6 +555,7 @@ var ( UserSessionsTable, VersionsTable, VersionDependenciesTable, + VersionTargetsTable, } ) @@ -537,4 +573,5 @@ func init() { VersionsTable.ForeignKeys[0].RefTable = ModsTable VersionDependenciesTable.ForeignKeys[0].RefTable = VersionsTable VersionDependenciesTable.ForeignKeys[1].RefTable = ModsTable + VersionTargetsTable.ForeignKeys[0].RefTable = VersionsTable } diff --git a/generated/ent/mod_create.go b/generated/ent/mod_create.go index f8b7821a..93acafac 100644 --- a/generated/ent/mod_create.go +++ b/generated/ent/mod_create.go @@ -8,6 +8,8 @@ import ( "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/db/postgres" @@ -22,6 +24,7 @@ type ModCreate struct { config mutation *ModMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -423,6 +426,7 @@ func (mc *ModCreate) createSpec() (*Mod, *sqlgraph.CreateSpec) { _node = &Mod{config: mc.config} _spec = sqlgraph.NewCreateSpec(mod.Table, sqlgraph.NewFieldSpec(mod.FieldID, field.TypeString)) ) + _spec.OnConflict = mc.conflict if id, ok := mc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -574,11 +578,683 @@ func (mc *ModCreate) createSpec() (*Mod, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Mod.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.ModUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mc *ModCreate) OnConflict(opts ...sql.ConflictOption) *ModUpsertOne { + mc.conflict = opts + return &ModUpsertOne{ + create: mc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Mod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mc *ModCreate) OnConflictColumns(columns ...string) *ModUpsertOne { + mc.conflict = append(mc.conflict, sql.ConflictColumns(columns...)) + return &ModUpsertOne{ + create: mc, + } +} + +type ( + // ModUpsertOne is the builder for "upsert"-ing + // one Mod node. + ModUpsertOne struct { + create *ModCreate + } + + // ModUpsert is the "OnConflict" setter. + ModUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModUpsert) SetUpdatedAt(v time.Time) *ModUpsert { + u.Set(mod.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModUpsert) UpdateUpdatedAt() *ModUpsert { + u.SetExcluded(mod.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *ModUpsert) SetDeletedAt(v time.Time) *ModUpsert { + u.Set(mod.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *ModUpsert) UpdateDeletedAt() *ModUpsert { + u.SetExcluded(mod.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *ModUpsert) ClearDeletedAt() *ModUpsert { + u.SetNull(mod.FieldDeletedAt) + return u +} + +// SetName sets the "name" field. +func (u *ModUpsert) SetName(v string) *ModUpsert { + u.Set(mod.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModUpsert) UpdateName() *ModUpsert { + u.SetExcluded(mod.FieldName) + return u +} + +// SetShortDescription sets the "short_description" field. +func (u *ModUpsert) SetShortDescription(v string) *ModUpsert { + u.Set(mod.FieldShortDescription, v) + return u +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModUpsert) UpdateShortDescription() *ModUpsert { + u.SetExcluded(mod.FieldShortDescription) + return u +} + +// SetFullDescription sets the "full_description" field. +func (u *ModUpsert) SetFullDescription(v string) *ModUpsert { + u.Set(mod.FieldFullDescription, v) + return u +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModUpsert) UpdateFullDescription() *ModUpsert { + u.SetExcluded(mod.FieldFullDescription) + return u +} + +// SetLogo sets the "logo" field. +func (u *ModUpsert) SetLogo(v string) *ModUpsert { + u.Set(mod.FieldLogo, v) + return u +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModUpsert) UpdateLogo() *ModUpsert { + u.SetExcluded(mod.FieldLogo) + return u +} + +// SetSourceURL sets the "source_url" field. +func (u *ModUpsert) SetSourceURL(v string) *ModUpsert { + u.Set(mod.FieldSourceURL, v) + return u +} + +// UpdateSourceURL sets the "source_url" field to the value that was provided on create. +func (u *ModUpsert) UpdateSourceURL() *ModUpsert { + u.SetExcluded(mod.FieldSourceURL) + return u +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModUpsert) SetCreatorID(v string) *ModUpsert { + u.Set(mod.FieldCreatorID, v) + return u +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModUpsert) UpdateCreatorID() *ModUpsert { + u.SetExcluded(mod.FieldCreatorID) + return u +} + +// SetApproved sets the "approved" field. +func (u *ModUpsert) SetApproved(v bool) *ModUpsert { + u.Set(mod.FieldApproved, v) + return u +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *ModUpsert) UpdateApproved() *ModUpsert { + u.SetExcluded(mod.FieldApproved) + return u +} + +// SetViews sets the "views" field. +func (u *ModUpsert) SetViews(v uint) *ModUpsert { + u.Set(mod.FieldViews, v) + return u +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModUpsert) UpdateViews() *ModUpsert { + u.SetExcluded(mod.FieldViews) + return u +} + +// AddViews adds v to the "views" field. +func (u *ModUpsert) AddViews(v uint) *ModUpsert { + u.Add(mod.FieldViews, v) + return u +} + +// SetHotness sets the "hotness" field. +func (u *ModUpsert) SetHotness(v uint) *ModUpsert { + u.Set(mod.FieldHotness, v) + return u +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModUpsert) UpdateHotness() *ModUpsert { + u.SetExcluded(mod.FieldHotness) + return u +} + +// AddHotness adds v to the "hotness" field. +func (u *ModUpsert) AddHotness(v uint) *ModUpsert { + u.Add(mod.FieldHotness, v) + return u +} + +// SetPopularity sets the "popularity" field. +func (u *ModUpsert) SetPopularity(v uint) *ModUpsert { + u.Set(mod.FieldPopularity, v) + return u +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModUpsert) UpdatePopularity() *ModUpsert { + u.SetExcluded(mod.FieldPopularity) + return u +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModUpsert) AddPopularity(v uint) *ModUpsert { + u.Add(mod.FieldPopularity, v) + return u +} + +// SetDownloads sets the "downloads" field. +func (u *ModUpsert) SetDownloads(v uint) *ModUpsert { + u.Set(mod.FieldDownloads, v) + return u +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *ModUpsert) UpdateDownloads() *ModUpsert { + u.SetExcluded(mod.FieldDownloads) + return u +} + +// AddDownloads adds v to the "downloads" field. +func (u *ModUpsert) AddDownloads(v uint) *ModUpsert { + u.Add(mod.FieldDownloads, v) + return u +} + +// SetDenied sets the "denied" field. +func (u *ModUpsert) SetDenied(v bool) *ModUpsert { + u.Set(mod.FieldDenied, v) + return u +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *ModUpsert) UpdateDenied() *ModUpsert { + u.SetExcluded(mod.FieldDenied) + return u +} + +// SetLastVersionDate sets the "last_version_date" field. +func (u *ModUpsert) SetLastVersionDate(v time.Time) *ModUpsert { + u.Set(mod.FieldLastVersionDate, v) + return u +} + +// UpdateLastVersionDate sets the "last_version_date" field to the value that was provided on create. +func (u *ModUpsert) UpdateLastVersionDate() *ModUpsert { + u.SetExcluded(mod.FieldLastVersionDate) + return u +} + +// SetModReference sets the "mod_reference" field. +func (u *ModUpsert) SetModReference(v string) *ModUpsert { + u.Set(mod.FieldModReference, v) + return u +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *ModUpsert) UpdateModReference() *ModUpsert { + u.SetExcluded(mod.FieldModReference) + return u +} + +// SetHidden sets the "hidden" field. +func (u *ModUpsert) SetHidden(v bool) *ModUpsert { + u.Set(mod.FieldHidden, v) + return u +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModUpsert) UpdateHidden() *ModUpsert { + u.SetExcluded(mod.FieldHidden) + return u +} + +// SetCompatibility sets the "compatibility" field. +func (u *ModUpsert) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsert { + u.Set(mod.FieldCompatibility, v) + return u +} + +// UpdateCompatibility sets the "compatibility" field to the value that was provided on create. +func (u *ModUpsert) UpdateCompatibility() *ModUpsert { + u.SetExcluded(mod.FieldCompatibility) + 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.Mod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(mod.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModUpsertOne) UpdateNewValues() *ModUpsertOne { + 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(mod.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(mod.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Mod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModUpsertOne) Ignore() *ModUpsertOne { + 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 *ModUpsertOne) DoNothing() *ModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModCreate.OnConflict +// documentation for more info. +func (u *ModUpsertOne) Update(set func(*ModUpsert)) *ModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModUpsertOne) SetUpdatedAt(v time.Time) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateUpdatedAt() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *ModUpsertOne) SetDeletedAt(v time.Time) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateDeletedAt() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *ModUpsertOne) ClearDeletedAt() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *ModUpsertOne) SetName(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateName() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *ModUpsertOne) SetShortDescription(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateShortDescription() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateShortDescription() + }) +} + +// SetFullDescription sets the "full_description" field. +func (u *ModUpsertOne) SetFullDescription(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetFullDescription(v) + }) +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateFullDescription() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateFullDescription() + }) +} + +// SetLogo sets the "logo" field. +func (u *ModUpsertOne) SetLogo(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetLogo(v) + }) +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateLogo() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateLogo() + }) +} + +// SetSourceURL sets the "source_url" field. +func (u *ModUpsertOne) SetSourceURL(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetSourceURL(v) + }) +} + +// UpdateSourceURL sets the "source_url" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateSourceURL() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateSourceURL() + }) +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModUpsertOne) SetCreatorID(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetCreatorID(v) + }) +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateCreatorID() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateCreatorID() + }) +} + +// SetApproved sets the "approved" field. +func (u *ModUpsertOne) SetApproved(v bool) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetApproved(v) + }) +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateApproved() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateApproved() + }) +} + +// SetViews sets the "views" field. +func (u *ModUpsertOne) SetViews(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *ModUpsertOne) AddViews(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateViews() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateViews() + }) +} + +// SetHotness sets the "hotness" field. +func (u *ModUpsertOne) SetHotness(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *ModUpsertOne) AddHotness(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateHotness() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateHotness() + }) +} + +// SetPopularity sets the "popularity" field. +func (u *ModUpsertOne) SetPopularity(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetPopularity(v) + }) +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModUpsertOne) AddPopularity(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.AddPopularity(v) + }) +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModUpsertOne) UpdatePopularity() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdatePopularity() + }) +} + +// SetDownloads sets the "downloads" field. +func (u *ModUpsertOne) SetDownloads(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetDownloads(v) + }) +} + +// AddDownloads adds v to the "downloads" field. +func (u *ModUpsertOne) AddDownloads(v uint) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.AddDownloads(v) + }) +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateDownloads() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateDownloads() + }) +} + +// SetDenied sets the "denied" field. +func (u *ModUpsertOne) SetDenied(v bool) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetDenied(v) + }) +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateDenied() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateDenied() + }) +} + +// SetLastVersionDate sets the "last_version_date" field. +func (u *ModUpsertOne) SetLastVersionDate(v time.Time) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetLastVersionDate(v) + }) +} + +// UpdateLastVersionDate sets the "last_version_date" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateLastVersionDate() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateLastVersionDate() + }) +} + +// SetModReference sets the "mod_reference" field. +func (u *ModUpsertOne) SetModReference(v string) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetModReference(v) + }) +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateModReference() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateModReference() + }) +} + +// SetHidden sets the "hidden" field. +func (u *ModUpsertOne) SetHidden(v bool) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetHidden(v) + }) +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateHidden() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateHidden() + }) +} + +// SetCompatibility sets the "compatibility" field. +func (u *ModUpsertOne) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.SetCompatibility(v) + }) +} + +// UpdateCompatibility sets the "compatibility" field to the value that was provided on create. +func (u *ModUpsertOne) UpdateCompatibility() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.UpdateCompatibility() + }) +} + +// Exec executes the query. +func (u *ModUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModUpsertOne) 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 *ModUpsertOne) 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: ModUpsertOne.ID is not supported by MySQL driver. Use ModUpsertOne.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 *ModUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // ModCreateBulk is the builder for creating many Mod entities in bulk. type ModCreateBulk struct { config err error builders []*ModCreate + conflict []sql.ConflictOption } // Save creates the Mod entities in the database. @@ -608,6 +1284,7 @@ func (mcb *ModCreateBulk) Save(ctx context.Context) ([]*Mod, error) { _, 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) { @@ -657,3 +1334,407 @@ func (mcb *ModCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Mod.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.ModUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (mcb *ModCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModUpsertBulk { + mcb.conflict = opts + return &ModUpsertBulk{ + create: mcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Mod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mcb *ModCreateBulk) OnConflictColumns(columns ...string) *ModUpsertBulk { + mcb.conflict = append(mcb.conflict, sql.ConflictColumns(columns...)) + return &ModUpsertBulk{ + create: mcb, + } +} + +// ModUpsertBulk is the builder for "upsert"-ing +// a bulk of Mod nodes. +type ModUpsertBulk struct { + create *ModCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Mod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(mod.FieldID) +// }), +// ). +// Exec(ctx) +func (u *ModUpsertBulk) UpdateNewValues() *ModUpsertBulk { + 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(mod.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(mod.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Mod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModUpsertBulk) Ignore() *ModUpsertBulk { + 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 *ModUpsertBulk) DoNothing() *ModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModCreateBulk.OnConflict +// documentation for more info. +func (u *ModUpsertBulk) Update(set func(*ModUpsert)) *ModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *ModUpsertBulk) SetUpdatedAt(v time.Time) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateUpdatedAt() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *ModUpsertBulk) SetDeletedAt(v time.Time) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateDeletedAt() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *ModUpsertBulk) ClearDeletedAt() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *ModUpsertBulk) SetName(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateName() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateName() + }) +} + +// SetShortDescription sets the "short_description" field. +func (u *ModUpsertBulk) SetShortDescription(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetShortDescription(v) + }) +} + +// UpdateShortDescription sets the "short_description" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateShortDescription() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateShortDescription() + }) +} + +// SetFullDescription sets the "full_description" field. +func (u *ModUpsertBulk) SetFullDescription(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetFullDescription(v) + }) +} + +// UpdateFullDescription sets the "full_description" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateFullDescription() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateFullDescription() + }) +} + +// SetLogo sets the "logo" field. +func (u *ModUpsertBulk) SetLogo(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetLogo(v) + }) +} + +// UpdateLogo sets the "logo" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateLogo() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateLogo() + }) +} + +// SetSourceURL sets the "source_url" field. +func (u *ModUpsertBulk) SetSourceURL(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetSourceURL(v) + }) +} + +// UpdateSourceURL sets the "source_url" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateSourceURL() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateSourceURL() + }) +} + +// SetCreatorID sets the "creator_id" field. +func (u *ModUpsertBulk) SetCreatorID(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetCreatorID(v) + }) +} + +// UpdateCreatorID sets the "creator_id" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateCreatorID() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateCreatorID() + }) +} + +// SetApproved sets the "approved" field. +func (u *ModUpsertBulk) SetApproved(v bool) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetApproved(v) + }) +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateApproved() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateApproved() + }) +} + +// SetViews sets the "views" field. +func (u *ModUpsertBulk) SetViews(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetViews(v) + }) +} + +// AddViews adds v to the "views" field. +func (u *ModUpsertBulk) AddViews(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.AddViews(v) + }) +} + +// UpdateViews sets the "views" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateViews() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateViews() + }) +} + +// SetHotness sets the "hotness" field. +func (u *ModUpsertBulk) SetHotness(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *ModUpsertBulk) AddHotness(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateHotness() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateHotness() + }) +} + +// SetPopularity sets the "popularity" field. +func (u *ModUpsertBulk) SetPopularity(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetPopularity(v) + }) +} + +// AddPopularity adds v to the "popularity" field. +func (u *ModUpsertBulk) AddPopularity(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.AddPopularity(v) + }) +} + +// UpdatePopularity sets the "popularity" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdatePopularity() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdatePopularity() + }) +} + +// SetDownloads sets the "downloads" field. +func (u *ModUpsertBulk) SetDownloads(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetDownloads(v) + }) +} + +// AddDownloads adds v to the "downloads" field. +func (u *ModUpsertBulk) AddDownloads(v uint) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.AddDownloads(v) + }) +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateDownloads() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateDownloads() + }) +} + +// SetDenied sets the "denied" field. +func (u *ModUpsertBulk) SetDenied(v bool) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetDenied(v) + }) +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateDenied() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateDenied() + }) +} + +// SetLastVersionDate sets the "last_version_date" field. +func (u *ModUpsertBulk) SetLastVersionDate(v time.Time) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetLastVersionDate(v) + }) +} + +// UpdateLastVersionDate sets the "last_version_date" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateLastVersionDate() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateLastVersionDate() + }) +} + +// SetModReference sets the "mod_reference" field. +func (u *ModUpsertBulk) SetModReference(v string) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetModReference(v) + }) +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateModReference() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateModReference() + }) +} + +// SetHidden sets the "hidden" field. +func (u *ModUpsertBulk) SetHidden(v bool) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetHidden(v) + }) +} + +// UpdateHidden sets the "hidden" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateHidden() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateHidden() + }) +} + +// SetCompatibility sets the "compatibility" field. +func (u *ModUpsertBulk) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.SetCompatibility(v) + }) +} + +// UpdateCompatibility sets the "compatibility" field to the value that was provided on create. +func (u *ModUpsertBulk) UpdateCompatibility() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.UpdateCompatibility() + }) +} + +// Exec executes the query. +func (u *ModUpsertBulk) 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 ModCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/mod_query.go b/generated/ent/mod_query.go index 7fcad71d..cafedb19 100644 --- a/generated/ent/mod_query.go +++ b/generated/ent/mod_query.go @@ -681,7 +681,9 @@ func (mq *ModQuery) loadVersions(ctx context.Context, query *VersionQuery, nodes init(nodes[i]) } } - query.withFKs = true + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(version.FieldModID) + } query.Where(predicate.Version(func(s *sql.Selector) { s.Where(sql.InValues(s.C(mod.VersionsColumn), fks...)) })) @@ -690,13 +692,10 @@ func (mq *ModQuery) loadVersions(ctx context.Context, query *VersionQuery, nodes return err } for _, n := range neighbors { - fk := n.mod_id - if fk == nil { - return fmt.Errorf(`foreign-key "mod_id" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] + 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.ID) + return fmt.Errorf(`unexpected referenced foreign-key "mod_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } diff --git a/generated/ent/modtag_create.go b/generated/ent/modtag_create.go index 7330d929..cde4a390 100644 --- a/generated/ent/modtag_create.go +++ b/generated/ent/modtag_create.go @@ -7,6 +7,7 @@ import ( "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" @@ -19,6 +20,7 @@ type ModTagCreate struct { config mutation *ModTagMutation hooks []Hook + conflict []sql.ConflictOption } // SetModID sets the "mod_id" field. @@ -111,6 +113,7 @@ func (mtc *ModTagCreate) createSpec() (*ModTag, *sqlgraph.CreateSpec) { _node = &ModTag{config: mtc.config} _spec = sqlgraph.NewCreateSpec(modtag.Table, nil) ) + _spec.OnConflict = mtc.conflict if nodes := mtc.mutation.ModIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -148,11 +151,168 @@ func (mtc *ModTagCreate) createSpec() (*ModTag, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModTag.Create(). +// SetModID(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.ModTagUpsert) { +// SetModID(v+v). +// }). +// Exec(ctx) +func (mtc *ModTagCreate) OnConflict(opts ...sql.ConflictOption) *ModTagUpsertOne { + mtc.conflict = opts + return &ModTagUpsertOne{ + create: mtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtc *ModTagCreate) OnConflictColumns(columns ...string) *ModTagUpsertOne { + mtc.conflict = append(mtc.conflict, sql.ConflictColumns(columns...)) + return &ModTagUpsertOne{ + create: mtc, + } +} + +type ( + // ModTagUpsertOne is the builder for "upsert"-ing + // one ModTag node. + ModTagUpsertOne struct { + create *ModTagCreate + } + + // ModTagUpsert is the "OnConflict" setter. + ModTagUpsert struct { + *sql.UpdateSet + } +) + +// SetModID sets the "mod_id" field. +func (u *ModTagUpsert) SetModID(v string) *ModTagUpsert { + u.Set(modtag.FieldModID, v) + return u +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModTagUpsert) UpdateModID() *ModTagUpsert { + u.SetExcluded(modtag.FieldModID) + return u +} + +// SetTagID sets the "tag_id" field. +func (u *ModTagUpsert) SetTagID(v string) *ModTagUpsert { + u.Set(modtag.FieldTagID, v) + return u +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModTagUpsert) UpdateTagID() *ModTagUpsert { + u.SetExcluded(modtag.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.ModTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModTagUpsertOne) UpdateNewValues() *ModTagUpsertOne { + 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.ModTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModTagUpsertOne) Ignore() *ModTagUpsertOne { + 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 *ModTagUpsertOne) DoNothing() *ModTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModTagCreate.OnConflict +// documentation for more info. +func (u *ModTagUpsertOne) Update(set func(*ModTagUpsert)) *ModTagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetModID sets the "mod_id" field. +func (u *ModTagUpsertOne) SetModID(v string) *ModTagUpsertOne { + return u.Update(func(s *ModTagUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModTagUpsertOne) UpdateModID() *ModTagUpsertOne { + return u.Update(func(s *ModTagUpsert) { + s.UpdateModID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *ModTagUpsertOne) SetTagID(v string) *ModTagUpsertOne { + return u.Update(func(s *ModTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModTagUpsertOne) UpdateTagID() *ModTagUpsertOne { + return u.Update(func(s *ModTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *ModTagUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModTagCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModTagUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + // ModTagCreateBulk is the builder for creating many ModTag entities in bulk. type ModTagCreateBulk struct { config err error builders []*ModTagCreate + conflict []sql.ConflictOption } // Save creates the ModTag entities in the database. @@ -181,6 +341,7 @@ func (mtcb *ModTagCreateBulk) Save(ctx context.Context) ([]*ModTag, error) { _, 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) { @@ -229,3 +390,135 @@ func (mtcb *ModTagCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.ModTag.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.ModTagUpsert) { +// SetModID(v+v). +// }). +// Exec(ctx) +func (mtcb *ModTagCreateBulk) OnConflict(opts ...sql.ConflictOption) *ModTagUpsertBulk { + mtcb.conflict = opts + return &ModTagUpsertBulk{ + create: mtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.ModTag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (mtcb *ModTagCreateBulk) OnConflictColumns(columns ...string) *ModTagUpsertBulk { + mtcb.conflict = append(mtcb.conflict, sql.ConflictColumns(columns...)) + return &ModTagUpsertBulk{ + create: mtcb, + } +} + +// ModTagUpsertBulk is the builder for "upsert"-ing +// a bulk of ModTag nodes. +type ModTagUpsertBulk struct { + create *ModTagCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.ModTag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ModTagUpsertBulk) UpdateNewValues() *ModTagUpsertBulk { + 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.ModTag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ModTagUpsertBulk) Ignore() *ModTagUpsertBulk { + 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 *ModTagUpsertBulk) DoNothing() *ModTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ModTagCreateBulk.OnConflict +// documentation for more info. +func (u *ModTagUpsertBulk) Update(set func(*ModTagUpsert)) *ModTagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ModTagUpsert{UpdateSet: update}) + })) + return u +} + +// SetModID sets the "mod_id" field. +func (u *ModTagUpsertBulk) SetModID(v string) *ModTagUpsertBulk { + return u.Update(func(s *ModTagUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *ModTagUpsertBulk) UpdateModID() *ModTagUpsertBulk { + return u.Update(func(s *ModTagUpsert) { + s.UpdateModID() + }) +} + +// SetTagID sets the "tag_id" field. +func (u *ModTagUpsertBulk) SetTagID(v string) *ModTagUpsertBulk { + return u.Update(func(s *ModTagUpsert) { + s.SetTagID(v) + }) +} + +// UpdateTagID sets the "tag_id" field to the value that was provided on create. +func (u *ModTagUpsertBulk) UpdateTagID() *ModTagUpsertBulk { + return u.Update(func(s *ModTagUpsert) { + s.UpdateTagID() + }) +} + +// Exec executes the query. +func (u *ModTagUpsertBulk) 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 ModTagCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ModTagCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ModTagUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/mutation.go b/generated/ent/mutation.go index 3e5eb695..b2b39e89 100644 --- a/generated/ent/mutation.go +++ b/generated/ent/mutation.go @@ -27,6 +27,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) const ( @@ -52,6 +53,7 @@ const ( TypeUserSession = "UserSession" TypeVersion = "Version" TypeVersionDependency = "VersionDependency" + TypeVersionTarget = "VersionTarget" ) // AnnouncementMutation represents an operation that mutates the Announcement nodes in the graph. @@ -874,6 +876,55 @@ func (m *GuideMutation) ResetDeletedAt() { delete(m.clearedFields, guide.FieldDeletedAt) } +// SetUserID sets the "user_id" field. +func (m *GuideMutation) SetUserID(s string) { + m.user = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *GuideMutation) UserID() (r string, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the Guide entity. +// If the Guide 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 *GuideMutation) OldUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ClearUserID clears the value of the "user_id" field. +func (m *GuideMutation) ClearUserID() { + m.user = nil + m.clearedFields[guide.FieldUserID] = struct{}{} +} + +// UserIDCleared returns if the "user_id" field was cleared in this mutation. +func (m *GuideMutation) UserIDCleared() bool { + _, ok := m.clearedFields[guide.FieldUserID] + return ok +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *GuideMutation) ResetUserID() { + m.user = nil + delete(m.clearedFields, guide.FieldUserID) +} + // SetName sets the "name" field. func (m *GuideMutation) SetName(s string) { m.name = &s @@ -1038,27 +1089,15 @@ func (m *GuideMutation) ResetViews() { m.addviews = nil } -// SetUserID sets the "user" edge to the User entity by id. -func (m *GuideMutation) SetUserID(id string) { - m.user = &id -} - // ClearUser clears the "user" edge to the User entity. func (m *GuideMutation) ClearUser() { m.cleareduser = true + m.clearedFields[guide.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. func (m *GuideMutation) UserCleared() bool { - return m.cleareduser -} - -// UserID returns the "user" edge ID in the mutation. -func (m *GuideMutation) UserID() (id string, exists bool) { - if m.user != nil { - return *m.user, true - } - return + return m.UserIDCleared() || m.cleareduser } // UserIDs returns the "user" edge IDs in the mutation. @@ -1165,7 +1204,7 @@ func (m *GuideMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *GuideMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.created_at != nil { fields = append(fields, guide.FieldCreatedAt) } @@ -1175,6 +1214,9 @@ func (m *GuideMutation) Fields() []string { if m.deleted_at != nil { fields = append(fields, guide.FieldDeletedAt) } + if m.user != nil { + fields = append(fields, guide.FieldUserID) + } if m.name != nil { fields = append(fields, guide.FieldName) } @@ -1201,6 +1243,8 @@ func (m *GuideMutation) Field(name string) (ent.Value, bool) { return m.UpdatedAt() case guide.FieldDeletedAt: return m.DeletedAt() + case guide.FieldUserID: + return m.UserID() case guide.FieldName: return m.Name() case guide.FieldShortDescription: @@ -1224,6 +1268,8 @@ func (m *GuideMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldUpdatedAt(ctx) case guide.FieldDeletedAt: return m.OldDeletedAt(ctx) + case guide.FieldUserID: + return m.OldUserID(ctx) case guide.FieldName: return m.OldName(ctx) case guide.FieldShortDescription: @@ -1262,6 +1308,13 @@ func (m *GuideMutation) SetField(name string, value ent.Value) error { } m.SetDeletedAt(v) return nil + case guide.FieldUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil case guide.FieldName: v, ok := value.(string) if !ok { @@ -1338,6 +1391,9 @@ func (m *GuideMutation) ClearedFields() []string { if m.FieldCleared(guide.FieldDeletedAt) { fields = append(fields, guide.FieldDeletedAt) } + if m.FieldCleared(guide.FieldUserID) { + fields = append(fields, guide.FieldUserID) + } return fields } @@ -1355,6 +1411,9 @@ func (m *GuideMutation) ClearField(name string) error { case guide.FieldDeletedAt: m.ClearDeletedAt() return nil + case guide.FieldUserID: + m.ClearUserID() + return nil } return fmt.Errorf("unknown Guide nullable field %s", name) } @@ -1372,6 +1431,9 @@ func (m *GuideMutation) ResetField(name string) error { case guide.FieldDeletedAt: m.ResetDeletedAt() return nil + case guide.FieldUserID: + m.ResetUserID() + return nil case guide.FieldName: m.ResetName() return nil @@ -1543,13 +1605,13 @@ func (m GuideTagMutation) Tx() (*Tx, error) { return tx, nil } -// SetGuideTag sets the "guide_tag" field. -func (m *GuideTagMutation) SetGuideTag(s string) { +// SetGuideID sets the "guide_id" field. +func (m *GuideTagMutation) SetGuideID(s string) { m.guide = &s } -// GuideTag returns the value of the "guide_tag" field in the mutation. -func (m *GuideTagMutation) GuideTag() (r string, exists bool) { +// GuideID returns the value of the "guide_id" field in the mutation. +func (m *GuideTagMutation) GuideID() (r string, exists bool) { v := m.guide if v == nil { return @@ -1557,8 +1619,8 @@ func (m *GuideTagMutation) GuideTag() (r string, exists bool) { return *v, true } -// ResetGuideTag resets all changes to the "guide_tag" field. -func (m *GuideTagMutation) ResetGuideTag() { +// ResetGuideID resets all changes to the "guide_id" field. +func (m *GuideTagMutation) ResetGuideID() { m.guide = nil } @@ -1581,15 +1643,10 @@ func (m *GuideTagMutation) ResetTagID() { m.tag = nil } -// SetGuideID sets the "guide" edge to the Guide entity by id. -func (m *GuideTagMutation) SetGuideID(id string) { - m.guide = &id -} - // ClearGuide clears the "guide" edge to the Guide entity. func (m *GuideTagMutation) ClearGuide() { m.clearedguide = true - m.clearedFields[guidetag.FieldGuideTag] = struct{}{} + m.clearedFields[guidetag.FieldGuideID] = struct{}{} } // GuideCleared reports if the "guide" edge to the Guide entity was cleared. @@ -1597,14 +1654,6 @@ func (m *GuideTagMutation) GuideCleared() bool { return m.clearedguide } -// GuideID returns the "guide" edge ID in the mutation. -func (m *GuideTagMutation) GuideID() (id string, exists bool) { - if m.guide != nil { - return *m.guide, true - } - return -} - // GuideIDs returns the "guide" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // GuideID instead. It exists only for internal usage by the builders. @@ -1684,7 +1733,7 @@ func (m *GuideTagMutation) Type() string { func (m *GuideTagMutation) Fields() []string { fields := make([]string, 0, 2) if m.guide != nil { - fields = append(fields, guidetag.FieldGuideTag) + fields = append(fields, guidetag.FieldGuideID) } if m.tag != nil { fields = append(fields, guidetag.FieldTagID) @@ -1697,8 +1746,8 @@ func (m *GuideTagMutation) Fields() []string { // schema. func (m *GuideTagMutation) Field(name string) (ent.Value, bool) { switch name { - case guidetag.FieldGuideTag: - return m.GuideTag() + case guidetag.FieldGuideID: + return m.GuideID() case guidetag.FieldTagID: return m.TagID() } @@ -1717,12 +1766,12 @@ func (m *GuideTagMutation) OldField(ctx context.Context, name string) (ent.Value // type. func (m *GuideTagMutation) SetField(name string, value ent.Value) error { switch name { - case guidetag.FieldGuideTag: + case guidetag.FieldGuideID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGuideTag(v) + m.SetGuideID(v) return nil case guidetag.FieldTagID: v, ok := value.(string) @@ -1780,8 +1829,8 @@ func (m *GuideTagMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *GuideTagMutation) ResetField(name string) error { switch name { - case guidetag.FieldGuideTag: - m.ResetGuideTag() + case guidetag.FieldGuideID: + m.ResetGuideID() return nil case guidetag.FieldTagID: m.ResetTagID() @@ -9457,6 +9506,9 @@ type VersionMutation struct { dependencies map[string]struct{} removeddependencies map[string]struct{} cleareddependencies bool + targets map[string]struct{} + removedtargets map[string]struct{} + clearedtargets bool done bool oldValue func(context.Context) (*Version, error) predicates []predicate.Version @@ -9687,6 +9739,42 @@ func (m *VersionMutation) ResetDeletedAt() { delete(m.clearedFields, version.FieldDeletedAt) } +// SetModID sets the "mod_id" field. +func (m *VersionMutation) SetModID(s string) { + m.mod = &s +} + +// ModID returns the value of the "mod_id" field in the mutation. +func (m *VersionMutation) ModID() (r string, exists bool) { + v := m.mod + if v == nil { + return + } + return *v, true +} + +// OldModID returns the old "mod_id" field's value of the Version entity. +// If the Version 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 *VersionMutation) OldModID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModID: %w", err) + } + return oldValue.ModID, nil +} + +// ResetModID resets all changes to the "mod_id" field. +func (m *VersionMutation) ResetModID() { + m.mod = nil +} + // SetVersion sets the "version" field. func (m *VersionMutation) SetVersion(s string) { m.version = &s @@ -10383,14 +10471,10 @@ func (m *VersionMutation) ResetHash() { m.hash = nil } -// SetModID sets the "mod" edge to the Mod entity by id. -func (m *VersionMutation) SetModID(id string) { - m.mod = &id -} - // ClearMod clears the "mod" edge to the Mod entity. func (m *VersionMutation) ClearMod() { m.clearedmod = true + m.clearedFields[version.FieldModID] = struct{}{} } // ModCleared reports if the "mod" edge to the Mod entity was cleared. @@ -10398,14 +10482,6 @@ func (m *VersionMutation) ModCleared() bool { return m.clearedmod } -// ModID returns the "mod" edge ID in the mutation. -func (m *VersionMutation) ModID() (id string, exists bool) { - if m.mod != nil { - return *m.mod, true - } - return -} - // 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. @@ -10476,6 +10552,60 @@ func (m *VersionMutation) ResetDependencies() { m.removeddependencies = nil } +// AddTargetIDs adds the "targets" edge to the VersionTarget entity by ids. +func (m *VersionMutation) 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 VersionTarget entity. +func (m *VersionMutation) ClearTargets() { + m.clearedtargets = true +} + +// TargetsCleared reports if the "targets" edge to the VersionTarget entity was cleared. +func (m *VersionMutation) TargetsCleared() bool { + return m.clearedtargets +} + +// RemoveTargetIDs removes the "targets" edge to the VersionTarget entity by IDs. +func (m *VersionMutation) 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 VersionTarget entity. +func (m *VersionMutation) RemovedTargetsIDs() (ids []string) { + for id := range m.removedtargets { + ids = append(ids, id) + } + return +} + +// TargetsIDs returns the "targets" edge IDs in the mutation. +func (m *VersionMutation) TargetsIDs() (ids []string) { + for id := range m.targets { + ids = append(ids, id) + } + return +} + +// ResetTargets resets all changes to the "targets" edge. +func (m *VersionMutation) ResetTargets() { + m.targets = nil + m.clearedtargets = false + m.removedtargets = nil +} + // Where appends a list predicates to the VersionMutation builder. func (m *VersionMutation) Where(ps ...predicate.Version) { m.predicates = append(m.predicates, ps...) @@ -10510,7 +10640,7 @@ func (m *VersionMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *VersionMutation) Fields() []string { - fields := make([]string, 0, 19) + fields := make([]string, 0, 20) if m.created_at != nil { fields = append(fields, version.FieldCreatedAt) } @@ -10520,6 +10650,9 @@ func (m *VersionMutation) Fields() []string { if m.deleted_at != nil { fields = append(fields, version.FieldDeletedAt) } + if m.mod != nil { + fields = append(fields, version.FieldModID) + } if m.version != nil { fields = append(fields, version.FieldVersion) } @@ -10582,6 +10715,8 @@ func (m *VersionMutation) Field(name string) (ent.Value, bool) { return m.UpdatedAt() case version.FieldDeletedAt: return m.DeletedAt() + case version.FieldModID: + return m.ModID() case version.FieldVersion: return m.Version() case version.FieldSmlVersion: @@ -10629,6 +10764,8 @@ func (m *VersionMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldUpdatedAt(ctx) case version.FieldDeletedAt: return m.OldDeletedAt(ctx) + case version.FieldModID: + return m.OldModID(ctx) case version.FieldVersion: return m.OldVersion(ctx) case version.FieldSmlVersion: @@ -10691,6 +10828,13 @@ func (m *VersionMutation) SetField(name string, value ent.Value) error { } m.SetDeletedAt(v) return nil + case version.FieldModID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModID(v) + return nil case version.FieldVersion: v, ok := value.(string) if !ok { @@ -10945,6 +11089,9 @@ func (m *VersionMutation) ResetField(name string) error { case version.FieldDeletedAt: m.ResetDeletedAt() return nil + case version.FieldModID: + m.ResetModID() + return nil case version.FieldVersion: m.ResetVersion() return nil @@ -10999,13 +11146,16 @@ func (m *VersionMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *VersionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.mod != nil { edges = append(edges, version.EdgeMod) } if m.dependencies != nil { edges = append(edges, version.EdgeDependencies) } + if m.targets != nil { + edges = append(edges, version.EdgeTargets) + } return edges } @@ -11023,16 +11173,25 @@ func (m *VersionMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case version.EdgeTargets: + ids := make([]ent.Value, 0, len(m.targets)) + for id := range m.targets { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *VersionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.removeddependencies != nil { edges = append(edges, version.EdgeDependencies) } + if m.removedtargets != nil { + edges = append(edges, version.EdgeTargets) + } return edges } @@ -11046,19 +11205,28 @@ func (m *VersionMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case version.EdgeTargets: + ids := make([]ent.Value, 0, len(m.removedtargets)) + for id := range m.removedtargets { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *VersionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearedmod { edges = append(edges, version.EdgeMod) } if m.cleareddependencies { edges = append(edges, version.EdgeDependencies) } + if m.clearedtargets { + edges = append(edges, version.EdgeTargets) + } return edges } @@ -11070,6 +11238,8 @@ func (m *VersionMutation) EdgeCleared(name string) bool { return m.clearedmod case version.EdgeDependencies: return m.cleareddependencies + case version.EdgeTargets: + return m.clearedtargets } return false } @@ -11095,6 +11265,9 @@ func (m *VersionMutation) ResetEdge(name string) error { case version.EdgeDependencies: m.ResetDependencies() return nil + case version.EdgeTargets: + m.ResetTargets() + return nil } return fmt.Errorf("unknown Version edge %s", name) } @@ -11674,3 +11847,654 @@ func (m *VersionDependencyMutation) ResetEdge(name string) error { } return fmt.Errorf("unknown VersionDependency edge %s", name) } + +// VersionTargetMutation represents an operation that mutates the VersionTarget nodes in the graph. +type VersionTargetMutation struct { + config + op Op + typ string + id *string + target_name *string + key *string + hash *string + size *int64 + addsize *int64 + clearedFields map[string]struct{} + sml_version *string + clearedsml_version bool + done bool + oldValue func(context.Context) (*VersionTarget, error) + predicates []predicate.VersionTarget +} + +var _ ent.Mutation = (*VersionTargetMutation)(nil) + +// versiontargetOption allows management of the mutation configuration using functional options. +type versiontargetOption func(*VersionTargetMutation) + +// newVersionTargetMutation creates new mutation for the VersionTarget entity. +func newVersionTargetMutation(c config, op Op, opts ...versiontargetOption) *VersionTargetMutation { + m := &VersionTargetMutation{ + config: c, + op: op, + typ: TypeVersionTarget, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withVersionTargetID sets the ID field of the mutation. +func withVersionTargetID(id string) versiontargetOption { + return func(m *VersionTargetMutation) { + var ( + err error + once sync.Once + value *VersionTarget + ) + m.oldValue = func(ctx context.Context) (*VersionTarget, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().VersionTarget.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withVersionTarget sets the old VersionTarget of the mutation. +func withVersionTarget(node *VersionTarget) versiontargetOption { + return func(m *VersionTargetMutation) { + m.oldValue = func(context.Context) (*VersionTarget, 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 VersionTargetMutation) 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 VersionTargetMutation) 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 VersionTarget entities. +func (m *VersionTargetMutation) 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 *VersionTargetMutation) 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 *VersionTargetMutation) 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().VersionTarget.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetVersionID sets the "version_id" field. +func (m *VersionTargetMutation) SetVersionID(s string) { + m.sml_version = &s +} + +// VersionID returns the value of the "version_id" field in the mutation. +func (m *VersionTargetMutation) VersionID() (r string, exists bool) { + v := m.sml_version + if v == nil { + return + } + return *v, true +} + +// OldVersionID returns the old "version_id" field's value of the VersionTarget entity. +// If the VersionTarget 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 *VersionTargetMutation) OldVersionID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionID: %w", err) + } + return oldValue.VersionID, nil +} + +// ResetVersionID resets all changes to the "version_id" field. +func (m *VersionTargetMutation) ResetVersionID() { + m.sml_version = nil +} + +// SetTargetName sets the "target_name" field. +func (m *VersionTargetMutation) SetTargetName(s string) { + m.target_name = &s +} + +// TargetName returns the value of the "target_name" field in the mutation. +func (m *VersionTargetMutation) TargetName() (r string, exists bool) { + v := m.target_name + if v == nil { + return + } + return *v, true +} + +// OldTargetName returns the old "target_name" field's value of the VersionTarget entity. +// If the VersionTarget 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 *VersionTargetMutation) 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 +} + +// ResetTargetName resets all changes to the "target_name" field. +func (m *VersionTargetMutation) ResetTargetName() { + m.target_name = nil +} + +// SetKey sets the "key" field. +func (m *VersionTargetMutation) SetKey(s string) { + m.key = &s +} + +// Key returns the value of the "key" field in the mutation. +func (m *VersionTargetMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return + } + return *v, true +} + +// OldKey returns the old "key" field's value of the VersionTarget entity. +// If the VersionTarget 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 *VersionTargetMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil +} + +// ResetKey resets all changes to the "key" field. +func (m *VersionTargetMutation) ResetKey() { + m.key = nil +} + +// SetHash sets the "hash" field. +func (m *VersionTargetMutation) SetHash(s string) { + m.hash = &s +} + +// Hash returns the value of the "hash" field in the mutation. +func (m *VersionTargetMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true +} + +// OldHash returns the old "hash" field's value of the VersionTarget entity. +// If the VersionTarget 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 *VersionTargetMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil +} + +// ResetHash resets all changes to the "hash" field. +func (m *VersionTargetMutation) ResetHash() { + m.hash = nil +} + +// SetSize sets the "size" field. +func (m *VersionTargetMutation) SetSize(i int64) { + m.size = &i + m.addsize = nil +} + +// Size returns the value of the "size" field in the mutation. +func (m *VersionTargetMutation) Size() (r int64, exists bool) { + v := m.size + if v == nil { + return + } + return *v, true +} + +// OldSize returns the old "size" field's value of the VersionTarget entity. +// If the VersionTarget 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 *VersionTargetMutation) OldSize(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSize: %w", err) + } + return oldValue.Size, nil +} + +// AddSize adds i to the "size" field. +func (m *VersionTargetMutation) AddSize(i int64) { + if m.addsize != nil { + *m.addsize += i + } else { + m.addsize = &i + } +} + +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *VersionTargetMutation) AddedSize() (r int64, exists bool) { + v := m.addsize + if v == nil { + return + } + return *v, true +} + +// ResetSize resets all changes to the "size" field. +func (m *VersionTargetMutation) ResetSize() { + m.size = nil + m.addsize = nil +} + +// SetSmlVersionID sets the "sml_version" edge to the Version entity by id. +func (m *VersionTargetMutation) SetSmlVersionID(id string) { + m.sml_version = &id +} + +// ClearSmlVersion clears the "sml_version" edge to the Version entity. +func (m *VersionTargetMutation) ClearSmlVersion() { + m.clearedsml_version = true + m.clearedFields[versiontarget.FieldVersionID] = struct{}{} +} + +// SmlVersionCleared reports if the "sml_version" edge to the Version entity was cleared. +func (m *VersionTargetMutation) SmlVersionCleared() bool { + return m.clearedsml_version +} + +// SmlVersionID returns the "sml_version" edge ID in the mutation. +func (m *VersionTargetMutation) SmlVersionID() (id string, exists bool) { + if m.sml_version != nil { + return *m.sml_version, true + } + return +} + +// SmlVersionIDs returns the "sml_version" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SmlVersionID instead. It exists only for internal usage by the builders. +func (m *VersionTargetMutation) SmlVersionIDs() (ids []string) { + if id := m.sml_version; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetSmlVersion resets all changes to the "sml_version" edge. +func (m *VersionTargetMutation) ResetSmlVersion() { + m.sml_version = nil + m.clearedsml_version = false +} + +// Where appends a list predicates to the VersionTargetMutation builder. +func (m *VersionTargetMutation) Where(ps ...predicate.VersionTarget) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the VersionTargetMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *VersionTargetMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.VersionTarget, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *VersionTargetMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *VersionTargetMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (VersionTarget). +func (m *VersionTargetMutation) 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 *VersionTargetMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.sml_version != nil { + fields = append(fields, versiontarget.FieldVersionID) + } + if m.target_name != nil { + fields = append(fields, versiontarget.FieldTargetName) + } + if m.key != nil { + fields = append(fields, versiontarget.FieldKey) + } + if m.hash != nil { + fields = append(fields, versiontarget.FieldHash) + } + if m.size != nil { + fields = append(fields, versiontarget.FieldSize) + } + 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 *VersionTargetMutation) Field(name string) (ent.Value, bool) { + switch name { + case versiontarget.FieldVersionID: + return m.VersionID() + case versiontarget.FieldTargetName: + return m.TargetName() + case versiontarget.FieldKey: + return m.Key() + case versiontarget.FieldHash: + return m.Hash() + case versiontarget.FieldSize: + return m.Size() + } + 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 *VersionTargetMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case versiontarget.FieldVersionID: + return m.OldVersionID(ctx) + case versiontarget.FieldTargetName: + return m.OldTargetName(ctx) + case versiontarget.FieldKey: + return m.OldKey(ctx) + case versiontarget.FieldHash: + return m.OldHash(ctx) + case versiontarget.FieldSize: + return m.OldSize(ctx) + } + return nil, fmt.Errorf("unknown VersionTarget 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 *VersionTargetMutation) SetField(name string, value ent.Value) error { + switch name { + case versiontarget.FieldVersionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionID(v) + return nil + case versiontarget.FieldTargetName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTargetName(v) + return nil + case versiontarget.FieldKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKey(v) + return nil + case versiontarget.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case versiontarget.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + } + return fmt.Errorf("unknown VersionTarget field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *VersionTargetMutation) AddedFields() []string { + var fields []string + if m.addsize != nil { + fields = append(fields, versiontarget.FieldSize) + } + 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 *VersionTargetMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case versiontarget.FieldSize: + return m.AddedSize() + } + 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 *VersionTargetMutation) AddField(name string, value ent.Value) error { + switch name { + case versiontarget.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSize(v) + return nil + } + return fmt.Errorf("unknown VersionTarget numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *VersionTargetMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *VersionTargetMutation) 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 *VersionTargetMutation) ClearField(name string) error { + return fmt.Errorf("unknown VersionTarget 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 *VersionTargetMutation) ResetField(name string) error { + switch name { + case versiontarget.FieldVersionID: + m.ResetVersionID() + return nil + case versiontarget.FieldTargetName: + m.ResetTargetName() + return nil + case versiontarget.FieldKey: + m.ResetKey() + return nil + case versiontarget.FieldHash: + m.ResetHash() + return nil + case versiontarget.FieldSize: + m.ResetSize() + return nil + } + return fmt.Errorf("unknown VersionTarget field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *VersionTargetMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.sml_version != nil { + edges = append(edges, versiontarget.EdgeSmlVersion) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *VersionTargetMutation) AddedIDs(name string) []ent.Value { + switch name { + case versiontarget.EdgeSmlVersion: + if id := m.sml_version; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *VersionTargetMutation) 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 *VersionTargetMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *VersionTargetMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsml_version { + edges = append(edges, versiontarget.EdgeSmlVersion) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *VersionTargetMutation) EdgeCleared(name string) bool { + switch name { + case versiontarget.EdgeSmlVersion: + return m.clearedsml_version + } + 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 *VersionTargetMutation) ClearEdge(name string) error { + switch name { + case versiontarget.EdgeSmlVersion: + m.ClearSmlVersion() + return nil + } + return fmt.Errorf("unknown VersionTarget 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 *VersionTargetMutation) ResetEdge(name string) error { + switch name { + case versiontarget.EdgeSmlVersion: + m.ResetSmlVersion() + return nil + } + return fmt.Errorf("unknown VersionTarget edge %s", name) +} diff --git a/generated/ent/predicate/predicate.go b/generated/ent/predicate/predicate.go index e035ad9d..d2c8dea2 100644 --- a/generated/ent/predicate/predicate.go +++ b/generated/ent/predicate/predicate.go @@ -47,3 +47,6 @@ type Version func(*sql.Selector) // VersionDependency is the predicate function for versiondependency builders. type VersionDependency func(*sql.Selector) + +// VersionTarget is the predicate function for versiontarget builders. +type VersionTarget func(*sql.Selector) diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go index ab3c3387..270fbae0 100644 --- a/generated/ent/runtime/runtime.go +++ b/generated/ent/runtime/runtime.go @@ -17,6 +17,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // The init function reads all schema descriptors with runtime code @@ -70,13 +71,17 @@ func init() { // guide.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. guide.UpdateDefaultUpdatedAt = guideDescUpdatedAt.UpdateDefault.(func() time.Time) // guideDescName is the schema descriptor for name field. - guideDescName := guideFields[0].Descriptor() + guideDescName := guideFields[1].Descriptor() // guide.NameValidator is a validator for the "name" field. It is called by the builders before save. guide.NameValidator = guideDescName.Validators[0].(func(string) error) // guideDescShortDescription is the schema descriptor for short_description field. - guideDescShortDescription := guideFields[1].Descriptor() + guideDescShortDescription := guideFields[2].Descriptor() // guide.ShortDescriptionValidator is a validator for the "short_description" field. It is called by the builders before save. guide.ShortDescriptionValidator = guideDescShortDescription.Validators[0].(func(string) error) + // guideDescViews is the schema descriptor for views field. + guideDescViews := guideFields[4].Descriptor() + // guide.DefaultViews holds the default value on creation for the views field. + guide.DefaultViews = guideDescViews.Default.(int) // guideDescID is the schema descriptor for id field. guideDescID := guideMixinFields0[0].Descriptor() // guide.DefaultID holds the default value on creation for the id field. @@ -340,27 +345,27 @@ func init() { // version.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. version.UpdateDefaultUpdatedAt = versionDescUpdatedAt.UpdateDefault.(func() time.Time) // versionDescVersion is the schema descriptor for version field. - versionDescVersion := versionFields[0].Descriptor() + versionDescVersion := versionFields[1].Descriptor() // version.VersionValidator is a validator for the "version" field. It is called by the builders before save. version.VersionValidator = versionDescVersion.Validators[0].(func(string) error) // versionDescSmlVersion is the schema descriptor for sml_version field. - versionDescSmlVersion := versionFields[1].Descriptor() + versionDescSmlVersion := versionFields[2].Descriptor() // version.SmlVersionValidator is a validator for the "sml_version" field. It is called by the builders before save. version.SmlVersionValidator = versionDescSmlVersion.Validators[0].(func(string) error) // versionDescApproved is the schema descriptor for approved field. - versionDescApproved := versionFields[6].Descriptor() + versionDescApproved := versionFields[7].Descriptor() // version.DefaultApproved holds the default value on creation for the approved field. version.DefaultApproved = versionDescApproved.Default.(bool) // versionDescDenied is the schema descriptor for denied field. - versionDescDenied := versionFields[8].Descriptor() + versionDescDenied := versionFields[9].Descriptor() // version.DefaultDenied holds the default value on creation for the denied field. version.DefaultDenied = versionDescDenied.Default.(bool) // versionDescModReference is the schema descriptor for mod_reference field. - versionDescModReference := versionFields[10].Descriptor() + versionDescModReference := versionFields[11].Descriptor() // version.ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. version.ModReferenceValidator = versionDescModReference.Validators[0].(func(string) error) // versionDescHash is the schema descriptor for hash field. - versionDescHash := versionFields[15].Descriptor() + versionDescHash := versionFields[16].Descriptor() // version.HashValidator is a validator for the "hash" field. It is called by the builders before save. version.HashValidator = func() func(string) error { validators := versionDescHash.Validators @@ -404,6 +409,15 @@ func init() { versiondependencyDescCondition := versiondependencyFields[2].Descriptor() // versiondependency.ConditionValidator is a validator for the "condition" field. It is called by the builders before save. versiondependency.ConditionValidator = versiondependencyDescCondition.Validators[0].(func(string) error) + versiontargetMixin := schema.VersionTarget{}.Mixin() + versiontargetMixinFields0 := versiontargetMixin[0].Fields() + _ = versiontargetMixinFields0 + versiontargetFields := schema.VersionTarget{}.Fields() + _ = versiontargetFields + // versiontargetDescID is the schema descriptor for id field. + versiontargetDescID := versiontargetMixinFields0[0].Descriptor() + // versiontarget.DefaultID holds the default value on creation for the id field. + versiontarget.DefaultID = versiontargetDescID.Default.(func() string) } const ( diff --git a/generated/ent/smlversion_create.go b/generated/ent/smlversion_create.go index e475a714..3b9de703 100644 --- a/generated/ent/smlversion_create.go +++ b/generated/ent/smlversion_create.go @@ -8,6 +8,8 @@ import ( "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/smlversion" @@ -19,6 +21,7 @@ type SmlVersionCreate struct { config mutation *SmlVersionMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -301,6 +304,7 @@ func (svc *SmlVersionCreate) createSpec() (*SmlVersion, *sqlgraph.CreateSpec) { _node = &SmlVersion{config: svc.config} _spec = sqlgraph.NewCreateSpec(smlversion.Table, sqlgraph.NewFieldSpec(smlversion.FieldID, field.TypeString)) ) + _spec.OnConflict = svc.conflict if id, ok := svc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -368,11 +372,449 @@ func (svc *SmlVersionCreate) createSpec() (*SmlVersion, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.SmlVersion.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.SmlVersionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (svc *SmlVersionCreate) OnConflict(opts ...sql.ConflictOption) *SmlVersionUpsertOne { + svc.conflict = opts + return &SmlVersionUpsertOne{ + create: svc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.SmlVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (svc *SmlVersionCreate) OnConflictColumns(columns ...string) *SmlVersionUpsertOne { + svc.conflict = append(svc.conflict, sql.ConflictColumns(columns...)) + return &SmlVersionUpsertOne{ + create: svc, + } +} + +type ( + // SmlVersionUpsertOne is the builder for "upsert"-ing + // one SmlVersion node. + SmlVersionUpsertOne struct { + create *SmlVersionCreate + } + + // SmlVersionUpsert is the "OnConflict" setter. + SmlVersionUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *SmlVersionUpsert) SetUpdatedAt(v time.Time) *SmlVersionUpsert { + u.Set(smlversion.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateUpdatedAt() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *SmlVersionUpsert) SetDeletedAt(v time.Time) *SmlVersionUpsert { + u.Set(smlversion.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateDeletedAt() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *SmlVersionUpsert) ClearDeletedAt() *SmlVersionUpsert { + u.SetNull(smlversion.FieldDeletedAt) + return u +} + +// SetVersion sets the "version" field. +func (u *SmlVersionUpsert) SetVersion(v string) *SmlVersionUpsert { + u.Set(smlversion.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateVersion() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldVersion) + return u +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (u *SmlVersionUpsert) SetSatisfactoryVersion(v int) *SmlVersionUpsert { + u.Set(smlversion.FieldSatisfactoryVersion, v) + return u +} + +// UpdateSatisfactoryVersion sets the "satisfactory_version" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateSatisfactoryVersion() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldSatisfactoryVersion) + return u +} + +// AddSatisfactoryVersion adds v to the "satisfactory_version" field. +func (u *SmlVersionUpsert) AddSatisfactoryVersion(v int) *SmlVersionUpsert { + u.Add(smlversion.FieldSatisfactoryVersion, v) + return u +} + +// SetStability sets the "stability" field. +func (u *SmlVersionUpsert) SetStability(v smlversion.Stability) *SmlVersionUpsert { + u.Set(smlversion.FieldStability, v) + return u +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateStability() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldStability) + return u +} + +// SetDate sets the "date" field. +func (u *SmlVersionUpsert) SetDate(v time.Time) *SmlVersionUpsert { + u.Set(smlversion.FieldDate, v) + return u +} + +// UpdateDate sets the "date" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateDate() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldDate) + return u +} + +// SetLink sets the "link" field. +func (u *SmlVersionUpsert) SetLink(v string) *SmlVersionUpsert { + u.Set(smlversion.FieldLink, v) + return u +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateLink() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldLink) + return u +} + +// SetChangelog sets the "changelog" field. +func (u *SmlVersionUpsert) SetChangelog(v string) *SmlVersionUpsert { + u.Set(smlversion.FieldChangelog, v) + return u +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateChangelog() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldChangelog) + return u +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (u *SmlVersionUpsert) SetBootstrapVersion(v string) *SmlVersionUpsert { + u.Set(smlversion.FieldBootstrapVersion, v) + return u +} + +// UpdateBootstrapVersion sets the "bootstrap_version" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateBootstrapVersion() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldBootstrapVersion) + return u +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (u *SmlVersionUpsert) ClearBootstrapVersion() *SmlVersionUpsert { + u.SetNull(smlversion.FieldBootstrapVersion) + return u +} + +// SetEngineVersion sets the "engine_version" field. +func (u *SmlVersionUpsert) SetEngineVersion(v string) *SmlVersionUpsert { + u.Set(smlversion.FieldEngineVersion, v) + return u +} + +// UpdateEngineVersion sets the "engine_version" field to the value that was provided on create. +func (u *SmlVersionUpsert) UpdateEngineVersion() *SmlVersionUpsert { + u.SetExcluded(smlversion.FieldEngineVersion) + 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.SmlVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(smlversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *SmlVersionUpsertOne) UpdateNewValues() *SmlVersionUpsertOne { + 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(smlversion.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(smlversion.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.SmlVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SmlVersionUpsertOne) Ignore() *SmlVersionUpsertOne { + 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 *SmlVersionUpsertOne) DoNothing() *SmlVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SmlVersionCreate.OnConflict +// documentation for more info. +func (u *SmlVersionUpsertOne) Update(set func(*SmlVersionUpsert)) *SmlVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SmlVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *SmlVersionUpsertOne) SetUpdatedAt(v time.Time) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateUpdatedAt() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *SmlVersionUpsertOne) SetDeletedAt(v time.Time) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateDeletedAt() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *SmlVersionUpsertOne) ClearDeletedAt() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetVersion sets the "version" field. +func (u *SmlVersionUpsertOne) SetVersion(v string) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateVersion() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (u *SmlVersionUpsertOne) SetSatisfactoryVersion(v int) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetSatisfactoryVersion(v) + }) +} + +// AddSatisfactoryVersion adds v to the "satisfactory_version" field. +func (u *SmlVersionUpsertOne) AddSatisfactoryVersion(v int) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.AddSatisfactoryVersion(v) + }) +} + +// UpdateSatisfactoryVersion sets the "satisfactory_version" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateSatisfactoryVersion() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateSatisfactoryVersion() + }) +} + +// SetStability sets the "stability" field. +func (u *SmlVersionUpsertOne) SetStability(v smlversion.Stability) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetStability(v) + }) +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateStability() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateStability() + }) +} + +// SetDate sets the "date" field. +func (u *SmlVersionUpsertOne) SetDate(v time.Time) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetDate(v) + }) +} + +// UpdateDate sets the "date" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateDate() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateDate() + }) +} + +// SetLink sets the "link" field. +func (u *SmlVersionUpsertOne) SetLink(v string) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetLink(v) + }) +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateLink() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateLink() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *SmlVersionUpsertOne) SetChangelog(v string) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateChangelog() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateChangelog() + }) +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (u *SmlVersionUpsertOne) SetBootstrapVersion(v string) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetBootstrapVersion(v) + }) +} + +// UpdateBootstrapVersion sets the "bootstrap_version" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateBootstrapVersion() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateBootstrapVersion() + }) +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (u *SmlVersionUpsertOne) ClearBootstrapVersion() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.ClearBootstrapVersion() + }) +} + +// SetEngineVersion sets the "engine_version" field. +func (u *SmlVersionUpsertOne) SetEngineVersion(v string) *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.SetEngineVersion(v) + }) +} + +// UpdateEngineVersion sets the "engine_version" field to the value that was provided on create. +func (u *SmlVersionUpsertOne) UpdateEngineVersion() *SmlVersionUpsertOne { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateEngineVersion() + }) +} + +// Exec executes the query. +func (u *SmlVersionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SmlVersionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SmlVersionUpsertOne) 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 *SmlVersionUpsertOne) 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: SmlVersionUpsertOne.ID is not supported by MySQL driver. Use SmlVersionUpsertOne.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 *SmlVersionUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // SmlVersionCreateBulk is the builder for creating many SmlVersion entities in bulk. type SmlVersionCreateBulk struct { config err error builders []*SmlVersionCreate + conflict []sql.ConflictOption } // Save creates the SmlVersion entities in the database. @@ -402,6 +844,7 @@ func (svcb *SmlVersionCreateBulk) Save(ctx context.Context) ([]*SmlVersion, erro _, err = mutators[i+1].Mutate(root, svcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = svcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, svcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -451,3 +894,281 @@ func (svcb *SmlVersionCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.SmlVersion.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.SmlVersionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (svcb *SmlVersionCreateBulk) OnConflict(opts ...sql.ConflictOption) *SmlVersionUpsertBulk { + svcb.conflict = opts + return &SmlVersionUpsertBulk{ + create: svcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.SmlVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (svcb *SmlVersionCreateBulk) OnConflictColumns(columns ...string) *SmlVersionUpsertBulk { + svcb.conflict = append(svcb.conflict, sql.ConflictColumns(columns...)) + return &SmlVersionUpsertBulk{ + create: svcb, + } +} + +// SmlVersionUpsertBulk is the builder for "upsert"-ing +// a bulk of SmlVersion nodes. +type SmlVersionUpsertBulk struct { + create *SmlVersionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.SmlVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(smlversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *SmlVersionUpsertBulk) UpdateNewValues() *SmlVersionUpsertBulk { + 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(smlversion.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(smlversion.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.SmlVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SmlVersionUpsertBulk) Ignore() *SmlVersionUpsertBulk { + 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 *SmlVersionUpsertBulk) DoNothing() *SmlVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SmlVersionCreateBulk.OnConflict +// documentation for more info. +func (u *SmlVersionUpsertBulk) Update(set func(*SmlVersionUpsert)) *SmlVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SmlVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *SmlVersionUpsertBulk) SetUpdatedAt(v time.Time) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateUpdatedAt() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *SmlVersionUpsertBulk) SetDeletedAt(v time.Time) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateDeletedAt() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *SmlVersionUpsertBulk) ClearDeletedAt() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetVersion sets the "version" field. +func (u *SmlVersionUpsertBulk) SetVersion(v string) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateVersion() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetSatisfactoryVersion sets the "satisfactory_version" field. +func (u *SmlVersionUpsertBulk) SetSatisfactoryVersion(v int) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetSatisfactoryVersion(v) + }) +} + +// AddSatisfactoryVersion adds v to the "satisfactory_version" field. +func (u *SmlVersionUpsertBulk) AddSatisfactoryVersion(v int) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.AddSatisfactoryVersion(v) + }) +} + +// UpdateSatisfactoryVersion sets the "satisfactory_version" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateSatisfactoryVersion() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateSatisfactoryVersion() + }) +} + +// SetStability sets the "stability" field. +func (u *SmlVersionUpsertBulk) SetStability(v smlversion.Stability) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetStability(v) + }) +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateStability() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateStability() + }) +} + +// SetDate sets the "date" field. +func (u *SmlVersionUpsertBulk) SetDate(v time.Time) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetDate(v) + }) +} + +// UpdateDate sets the "date" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateDate() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateDate() + }) +} + +// SetLink sets the "link" field. +func (u *SmlVersionUpsertBulk) SetLink(v string) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetLink(v) + }) +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateLink() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateLink() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *SmlVersionUpsertBulk) SetChangelog(v string) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateChangelog() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateChangelog() + }) +} + +// SetBootstrapVersion sets the "bootstrap_version" field. +func (u *SmlVersionUpsertBulk) SetBootstrapVersion(v string) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetBootstrapVersion(v) + }) +} + +// UpdateBootstrapVersion sets the "bootstrap_version" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateBootstrapVersion() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateBootstrapVersion() + }) +} + +// ClearBootstrapVersion clears the value of the "bootstrap_version" field. +func (u *SmlVersionUpsertBulk) ClearBootstrapVersion() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.ClearBootstrapVersion() + }) +} + +// SetEngineVersion sets the "engine_version" field. +func (u *SmlVersionUpsertBulk) SetEngineVersion(v string) *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.SetEngineVersion(v) + }) +} + +// UpdateEngineVersion sets the "engine_version" field to the value that was provided on create. +func (u *SmlVersionUpsertBulk) UpdateEngineVersion() *SmlVersionUpsertBulk { + return u.Update(func(s *SmlVersionUpsert) { + s.UpdateEngineVersion() + }) +} + +// Exec executes the query. +func (u *SmlVersionUpsertBulk) 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 SmlVersionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SmlVersionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SmlVersionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/smlversiontarget_create.go b/generated/ent/smlversiontarget_create.go index 09d7f040..44d4cce4 100644 --- a/generated/ent/smlversiontarget_create.go +++ b/generated/ent/smlversiontarget_create.go @@ -7,6 +7,8 @@ import ( "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/smlversion" @@ -18,6 +20,7 @@ type SmlVersionTargetCreate struct { config mutation *SmlVersionTargetMutation hooks []Hook + conflict []sql.ConflictOption } // SetVersionID sets the "version_id" field. @@ -149,6 +152,7 @@ func (svtc *SmlVersionTargetCreate) createSpec() (*SmlVersionTarget, *sqlgraph.C _node = &SmlVersionTarget{config: svtc.config} _spec = sqlgraph.NewCreateSpec(smlversiontarget.Table, sqlgraph.NewFieldSpec(smlversiontarget.FieldID, field.TypeString)) ) + _spec.OnConflict = svtc.conflict if id, ok := svtc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -181,11 +185,225 @@ func (svtc *SmlVersionTargetCreate) createSpec() (*SmlVersionTarget, *sqlgraph.C return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.SmlVersionTarget.Create(). +// SetVersionID(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.SmlVersionTargetUpsert) { +// SetVersionID(v+v). +// }). +// Exec(ctx) +func (svtc *SmlVersionTargetCreate) OnConflict(opts ...sql.ConflictOption) *SmlVersionTargetUpsertOne { + svtc.conflict = opts + return &SmlVersionTargetUpsertOne{ + create: svtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.SmlVersionTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (svtc *SmlVersionTargetCreate) OnConflictColumns(columns ...string) *SmlVersionTargetUpsertOne { + svtc.conflict = append(svtc.conflict, sql.ConflictColumns(columns...)) + return &SmlVersionTargetUpsertOne{ + create: svtc, + } +} + +type ( + // SmlVersionTargetUpsertOne is the builder for "upsert"-ing + // one SmlVersionTarget node. + SmlVersionTargetUpsertOne struct { + create *SmlVersionTargetCreate + } + + // SmlVersionTargetUpsert is the "OnConflict" setter. + SmlVersionTargetUpsert struct { + *sql.UpdateSet + } +) + +// SetVersionID sets the "version_id" field. +func (u *SmlVersionTargetUpsert) SetVersionID(v string) *SmlVersionTargetUpsert { + u.Set(smlversiontarget.FieldVersionID, v) + return u +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *SmlVersionTargetUpsert) UpdateVersionID() *SmlVersionTargetUpsert { + u.SetExcluded(smlversiontarget.FieldVersionID) + return u +} + +// SetTargetName sets the "target_name" field. +func (u *SmlVersionTargetUpsert) SetTargetName(v string) *SmlVersionTargetUpsert { + u.Set(smlversiontarget.FieldTargetName, v) + return u +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *SmlVersionTargetUpsert) UpdateTargetName() *SmlVersionTargetUpsert { + u.SetExcluded(smlversiontarget.FieldTargetName) + return u +} + +// SetLink sets the "link" field. +func (u *SmlVersionTargetUpsert) SetLink(v string) *SmlVersionTargetUpsert { + u.Set(smlversiontarget.FieldLink, v) + return u +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionTargetUpsert) UpdateLink() *SmlVersionTargetUpsert { + u.SetExcluded(smlversiontarget.FieldLink) + 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.SmlVersionTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(smlversiontarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *SmlVersionTargetUpsertOne) UpdateNewValues() *SmlVersionTargetUpsertOne { + 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(smlversiontarget.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.SmlVersionTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SmlVersionTargetUpsertOne) Ignore() *SmlVersionTargetUpsertOne { + 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 *SmlVersionTargetUpsertOne) DoNothing() *SmlVersionTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SmlVersionTargetCreate.OnConflict +// documentation for more info. +func (u *SmlVersionTargetUpsertOne) Update(set func(*SmlVersionTargetUpsert)) *SmlVersionTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SmlVersionTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetVersionID sets the "version_id" field. +func (u *SmlVersionTargetUpsertOne) SetVersionID(v string) *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertOne) UpdateVersionID() *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateVersionID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *SmlVersionTargetUpsertOne) SetTargetName(v string) *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertOne) UpdateTargetName() *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateTargetName() + }) +} + +// SetLink sets the "link" field. +func (u *SmlVersionTargetUpsertOne) SetLink(v string) *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetLink(v) + }) +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertOne) UpdateLink() *SmlVersionTargetUpsertOne { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateLink() + }) +} + +// Exec executes the query. +func (u *SmlVersionTargetUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SmlVersionTargetCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SmlVersionTargetUpsertOne) 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 *SmlVersionTargetUpsertOne) 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: SmlVersionTargetUpsertOne.ID is not supported by MySQL driver. Use SmlVersionTargetUpsertOne.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 *SmlVersionTargetUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // SmlVersionTargetCreateBulk is the builder for creating many SmlVersionTarget entities in bulk. type SmlVersionTargetCreateBulk struct { config err error builders []*SmlVersionTargetCreate + conflict []sql.ConflictOption } // Save creates the SmlVersionTarget entities in the database. @@ -215,6 +433,7 @@ func (svtcb *SmlVersionTargetCreateBulk) Save(ctx context.Context) ([]*SmlVersio _, err = mutators[i+1].Mutate(root, svtcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = svtcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, svtcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -264,3 +483,159 @@ func (svtcb *SmlVersionTargetCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.SmlVersionTarget.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.SmlVersionTargetUpsert) { +// SetVersionID(v+v). +// }). +// Exec(ctx) +func (svtcb *SmlVersionTargetCreateBulk) OnConflict(opts ...sql.ConflictOption) *SmlVersionTargetUpsertBulk { + svtcb.conflict = opts + return &SmlVersionTargetUpsertBulk{ + create: svtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.SmlVersionTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (svtcb *SmlVersionTargetCreateBulk) OnConflictColumns(columns ...string) *SmlVersionTargetUpsertBulk { + svtcb.conflict = append(svtcb.conflict, sql.ConflictColumns(columns...)) + return &SmlVersionTargetUpsertBulk{ + create: svtcb, + } +} + +// SmlVersionTargetUpsertBulk is the builder for "upsert"-ing +// a bulk of SmlVersionTarget nodes. +type SmlVersionTargetUpsertBulk struct { + create *SmlVersionTargetCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.SmlVersionTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(smlversiontarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *SmlVersionTargetUpsertBulk) UpdateNewValues() *SmlVersionTargetUpsertBulk { + 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(smlversiontarget.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.SmlVersionTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SmlVersionTargetUpsertBulk) Ignore() *SmlVersionTargetUpsertBulk { + 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 *SmlVersionTargetUpsertBulk) DoNothing() *SmlVersionTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SmlVersionTargetCreateBulk.OnConflict +// documentation for more info. +func (u *SmlVersionTargetUpsertBulk) Update(set func(*SmlVersionTargetUpsert)) *SmlVersionTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SmlVersionTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetVersionID sets the "version_id" field. +func (u *SmlVersionTargetUpsertBulk) SetVersionID(v string) *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertBulk) UpdateVersionID() *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateVersionID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *SmlVersionTargetUpsertBulk) SetTargetName(v string) *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertBulk) UpdateTargetName() *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateTargetName() + }) +} + +// SetLink sets the "link" field. +func (u *SmlVersionTargetUpsertBulk) SetLink(v string) *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.SetLink(v) + }) +} + +// UpdateLink sets the "link" field to the value that was provided on create. +func (u *SmlVersionTargetUpsertBulk) UpdateLink() *SmlVersionTargetUpsertBulk { + return u.Update(func(s *SmlVersionTargetUpsert) { + s.UpdateLink() + }) +} + +// Exec executes the query. +func (u *SmlVersionTargetUpsertBulk) 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 SmlVersionTargetCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SmlVersionTargetCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SmlVersionTargetUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/tag/tag.go b/generated/ent/tag/tag.go index aea3e0e8..050d1776 100644 --- a/generated/ent/tag/tag.go +++ b/generated/ent/tag/tag.go @@ -74,7 +74,7 @@ var ( ModsPrimaryKey = []string{"mod_id", "tag_id"} // GuidesPrimaryKey and GuidesColumn2 are the table columns denoting the // primary key for the guides relation (M2M). - GuidesPrimaryKey = []string{"guide_tag", "tag_id"} + GuidesPrimaryKey = []string{"guide_id", "tag_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). diff --git a/generated/ent/tag_create.go b/generated/ent/tag_create.go index d0e7bee4..b6a387b7 100644 --- a/generated/ent/tag_create.go +++ b/generated/ent/tag_create.go @@ -8,6 +8,8 @@ import ( "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/guide" @@ -20,6 +22,7 @@ type TagCreate struct { config mutation *TagMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -222,6 +225,7 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { _node = &Tag{config: tc.config} _spec = sqlgraph.NewCreateSpec(tag.Table, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString)) ) + _spec.OnConflict = tc.conflict if id, ok := tc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -277,11 +281,241 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Tag.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.TagUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (tc *TagCreate) OnConflict(opts ...sql.ConflictOption) *TagUpsertOne { + tc.conflict = opts + return &TagUpsertOne{ + create: tc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Tag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (tc *TagCreate) OnConflictColumns(columns ...string) *TagUpsertOne { + tc.conflict = append(tc.conflict, sql.ConflictColumns(columns...)) + return &TagUpsertOne{ + create: tc, + } +} + +type ( + // TagUpsertOne is the builder for "upsert"-ing + // one Tag node. + TagUpsertOne struct { + create *TagCreate + } + + // TagUpsert is the "OnConflict" setter. + TagUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *TagUpsert) SetUpdatedAt(v time.Time) *TagUpsert { + u.Set(tag.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *TagUpsert) UpdateUpdatedAt() *TagUpsert { + u.SetExcluded(tag.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *TagUpsert) SetDeletedAt(v time.Time) *TagUpsert { + u.Set(tag.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *TagUpsert) UpdateDeletedAt() *TagUpsert { + u.SetExcluded(tag.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *TagUpsert) ClearDeletedAt() *TagUpsert { + u.SetNull(tag.FieldDeletedAt) + return u +} + +// SetName sets the "name" field. +func (u *TagUpsert) SetName(v string) *TagUpsert { + u.Set(tag.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *TagUpsert) UpdateName() *TagUpsert { + u.SetExcluded(tag.FieldName) + 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.Tag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(tag.FieldID) +// }), +// ). +// Exec(ctx) +func (u *TagUpsertOne) UpdateNewValues() *TagUpsertOne { + 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(tag.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(tag.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Tag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *TagUpsertOne) Ignore() *TagUpsertOne { + 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 *TagUpsertOne) DoNothing() *TagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the TagCreate.OnConflict +// documentation for more info. +func (u *TagUpsertOne) Update(set func(*TagUpsert)) *TagUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&TagUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *TagUpsertOne) SetUpdatedAt(v time.Time) *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *TagUpsertOne) UpdateUpdatedAt() *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *TagUpsertOne) SetDeletedAt(v time.Time) *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *TagUpsertOne) UpdateDeletedAt() *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *TagUpsertOne) ClearDeletedAt() *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *TagUpsertOne) SetName(v string) *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *TagUpsertOne) UpdateName() *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.UpdateName() + }) +} + +// Exec executes the query. +func (u *TagUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for TagCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *TagUpsertOne) 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 *TagUpsertOne) 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: TagUpsertOne.ID is not supported by MySQL driver. Use TagUpsertOne.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 *TagUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // TagCreateBulk is the builder for creating many Tag entities in bulk. type TagCreateBulk struct { config err error builders []*TagCreate + conflict []sql.ConflictOption } // Save creates the Tag entities in the database. @@ -311,6 +545,7 @@ func (tcb *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error) { _, err = mutators[i+1].Mutate(root, tcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = tcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, tcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -360,3 +595,169 @@ func (tcb *TagCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Tag.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.TagUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (tcb *TagCreateBulk) OnConflict(opts ...sql.ConflictOption) *TagUpsertBulk { + tcb.conflict = opts + return &TagUpsertBulk{ + create: tcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Tag.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (tcb *TagCreateBulk) OnConflictColumns(columns ...string) *TagUpsertBulk { + tcb.conflict = append(tcb.conflict, sql.ConflictColumns(columns...)) + return &TagUpsertBulk{ + create: tcb, + } +} + +// TagUpsertBulk is the builder for "upsert"-ing +// a bulk of Tag nodes. +type TagUpsertBulk struct { + create *TagCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Tag.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(tag.FieldID) +// }), +// ). +// Exec(ctx) +func (u *TagUpsertBulk) UpdateNewValues() *TagUpsertBulk { + 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(tag.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(tag.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Tag.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *TagUpsertBulk) Ignore() *TagUpsertBulk { + 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 *TagUpsertBulk) DoNothing() *TagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the TagCreateBulk.OnConflict +// documentation for more info. +func (u *TagUpsertBulk) Update(set func(*TagUpsert)) *TagUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&TagUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *TagUpsertBulk) SetUpdatedAt(v time.Time) *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *TagUpsertBulk) UpdateUpdatedAt() *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *TagUpsertBulk) SetDeletedAt(v time.Time) *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *TagUpsertBulk) UpdateDeletedAt() *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *TagUpsertBulk) ClearDeletedAt() *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *TagUpsertBulk) SetName(v string) *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *TagUpsertBulk) UpdateName() *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.UpdateName() + }) +} + +// Exec executes the query. +func (u *TagUpsertBulk) 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 TagCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for TagCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *TagUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/tx.go b/generated/ent/tx.go index 307aafcd..bbdaaf6a 100644 --- a/generated/ent/tx.go +++ b/generated/ent/tx.go @@ -42,6 +42,8 @@ type Tx struct { Version *VersionClient // VersionDependency is the client for interacting with the VersionDependency builders. VersionDependency *VersionDependencyClient + // VersionTarget is the client for interacting with the VersionTarget builders. + VersionTarget *VersionTargetClient // lazily loaded. client *Client @@ -187,6 +189,7 @@ func (tx *Tx) init() { tx.UserSession = NewUserSessionClient(tx.config) tx.Version = NewVersionClient(tx.config) tx.VersionDependency = NewVersionDependencyClient(tx.config) + tx.VersionTarget = NewVersionTargetClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/generated/ent/user_create.go b/generated/ent/user_create.go index 46b41e3f..aef0a44c 100644 --- a/generated/ent/user_create.go +++ b/generated/ent/user_create.go @@ -8,6 +8,8 @@ import ( "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/guide" @@ -22,6 +24,7 @@ type UserCreate struct { config mutation *UserMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -395,6 +398,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _node = &User{config: uc.config} _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeString)) ) + _spec.OnConflict = uc.conflict if id, ok := uc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -514,11 +518,527 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.User.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.UserUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (uc *UserCreate) OnConflict(opts ...sql.ConflictOption) *UserUpsertOne { + uc.conflict = opts + return &UserUpsertOne{ + create: uc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.User.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (uc *UserCreate) OnConflictColumns(columns ...string) *UserUpsertOne { + uc.conflict = append(uc.conflict, sql.ConflictColumns(columns...)) + return &UserUpsertOne{ + create: uc, + } +} + +type ( + // UserUpsertOne is the builder for "upsert"-ing + // one User node. + UserUpsertOne struct { + create *UserCreate + } + + // UserUpsert is the "OnConflict" setter. + UserUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserUpsert) SetUpdatedAt(v time.Time) *UserUpsert { + u.Set(user.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserUpsert) UpdateUpdatedAt() *UserUpsert { + u.SetExcluded(user.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserUpsert) SetDeletedAt(v time.Time) *UserUpsert { + u.Set(user.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserUpsert) UpdateDeletedAt() *UserUpsert { + u.SetExcluded(user.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserUpsert) ClearDeletedAt() *UserUpsert { + u.SetNull(user.FieldDeletedAt) + return u +} + +// SetEmail sets the "email" field. +func (u *UserUpsert) SetEmail(v string) *UserUpsert { + u.Set(user.FieldEmail, v) + return u +} + +// UpdateEmail sets the "email" field to the value that was provided on create. +func (u *UserUpsert) UpdateEmail() *UserUpsert { + u.SetExcluded(user.FieldEmail) + return u +} + +// SetUsername sets the "username" field. +func (u *UserUpsert) SetUsername(v string) *UserUpsert { + u.Set(user.FieldUsername, v) + return u +} + +// UpdateUsername sets the "username" field to the value that was provided on create. +func (u *UserUpsert) UpdateUsername() *UserUpsert { + u.SetExcluded(user.FieldUsername) + return u +} + +// SetAvatar sets the "avatar" field. +func (u *UserUpsert) SetAvatar(v string) *UserUpsert { + u.Set(user.FieldAvatar, v) + return u +} + +// UpdateAvatar sets the "avatar" field to the value that was provided on create. +func (u *UserUpsert) UpdateAvatar() *UserUpsert { + u.SetExcluded(user.FieldAvatar) + return u +} + +// ClearAvatar clears the value of the "avatar" field. +func (u *UserUpsert) ClearAvatar() *UserUpsert { + u.SetNull(user.FieldAvatar) + return u +} + +// SetJoinedFrom sets the "joined_from" field. +func (u *UserUpsert) SetJoinedFrom(v string) *UserUpsert { + u.Set(user.FieldJoinedFrom, v) + return u +} + +// UpdateJoinedFrom sets the "joined_from" field to the value that was provided on create. +func (u *UserUpsert) UpdateJoinedFrom() *UserUpsert { + u.SetExcluded(user.FieldJoinedFrom) + return u +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (u *UserUpsert) ClearJoinedFrom() *UserUpsert { + u.SetNull(user.FieldJoinedFrom) + return u +} + +// SetBanned sets the "banned" field. +func (u *UserUpsert) SetBanned(v bool) *UserUpsert { + u.Set(user.FieldBanned, v) + return u +} + +// UpdateBanned sets the "banned" field to the value that was provided on create. +func (u *UserUpsert) UpdateBanned() *UserUpsert { + u.SetExcluded(user.FieldBanned) + return u +} + +// SetRank sets the "rank" field. +func (u *UserUpsert) SetRank(v int) *UserUpsert { + u.Set(user.FieldRank, v) + return u +} + +// UpdateRank sets the "rank" field to the value that was provided on create. +func (u *UserUpsert) UpdateRank() *UserUpsert { + u.SetExcluded(user.FieldRank) + return u +} + +// AddRank adds v to the "rank" field. +func (u *UserUpsert) AddRank(v int) *UserUpsert { + u.Add(user.FieldRank, v) + return u +} + +// SetGithubID sets the "github_id" field. +func (u *UserUpsert) SetGithubID(v string) *UserUpsert { + u.Set(user.FieldGithubID, v) + return u +} + +// UpdateGithubID sets the "github_id" field to the value that was provided on create. +func (u *UserUpsert) UpdateGithubID() *UserUpsert { + u.SetExcluded(user.FieldGithubID) + return u +} + +// ClearGithubID clears the value of the "github_id" field. +func (u *UserUpsert) ClearGithubID() *UserUpsert { + u.SetNull(user.FieldGithubID) + return u +} + +// SetGoogleID sets the "google_id" field. +func (u *UserUpsert) SetGoogleID(v string) *UserUpsert { + u.Set(user.FieldGoogleID, v) + return u +} + +// UpdateGoogleID sets the "google_id" field to the value that was provided on create. +func (u *UserUpsert) UpdateGoogleID() *UserUpsert { + u.SetExcluded(user.FieldGoogleID) + return u +} + +// ClearGoogleID clears the value of the "google_id" field. +func (u *UserUpsert) ClearGoogleID() *UserUpsert { + u.SetNull(user.FieldGoogleID) + return u +} + +// SetFacebookID sets the "facebook_id" field. +func (u *UserUpsert) SetFacebookID(v string) *UserUpsert { + u.Set(user.FieldFacebookID, v) + return u +} + +// UpdateFacebookID sets the "facebook_id" field to the value that was provided on create. +func (u *UserUpsert) UpdateFacebookID() *UserUpsert { + u.SetExcluded(user.FieldFacebookID) + return u +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (u *UserUpsert) ClearFacebookID() *UserUpsert { + u.SetNull(user.FieldFacebookID) + 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.User.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(user.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserUpsertOne) UpdateNewValues() *UserUpsertOne { + 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(user.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(user.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.User.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserUpsertOne) Ignore() *UserUpsertOne { + 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 *UserUpsertOne) DoNothing() *UserUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserCreate.OnConflict +// documentation for more info. +func (u *UserUpsertOne) Update(set func(*UserUpsert)) *UserUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserUpsertOne) SetUpdatedAt(v time.Time) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateUpdatedAt() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserUpsertOne) SetDeletedAt(v time.Time) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateDeletedAt() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserUpsertOne) ClearDeletedAt() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearDeletedAt() + }) +} + +// SetEmail sets the "email" field. +func (u *UserUpsertOne) SetEmail(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetEmail(v) + }) +} + +// UpdateEmail sets the "email" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateEmail() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateEmail() + }) +} + +// SetUsername sets the "username" field. +func (u *UserUpsertOne) SetUsername(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetUsername(v) + }) +} + +// UpdateUsername sets the "username" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateUsername() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateUsername() + }) +} + +// SetAvatar sets the "avatar" field. +func (u *UserUpsertOne) SetAvatar(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetAvatar(v) + }) +} + +// UpdateAvatar sets the "avatar" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateAvatar() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateAvatar() + }) +} + +// ClearAvatar clears the value of the "avatar" field. +func (u *UserUpsertOne) ClearAvatar() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearAvatar() + }) +} + +// SetJoinedFrom sets the "joined_from" field. +func (u *UserUpsertOne) SetJoinedFrom(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetJoinedFrom(v) + }) +} + +// UpdateJoinedFrom sets the "joined_from" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateJoinedFrom() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateJoinedFrom() + }) +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (u *UserUpsertOne) ClearJoinedFrom() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearJoinedFrom() + }) +} + +// SetBanned sets the "banned" field. +func (u *UserUpsertOne) SetBanned(v bool) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetBanned(v) + }) +} + +// UpdateBanned sets the "banned" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateBanned() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateBanned() + }) +} + +// SetRank sets the "rank" field. +func (u *UserUpsertOne) SetRank(v int) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetRank(v) + }) +} + +// AddRank adds v to the "rank" field. +func (u *UserUpsertOne) AddRank(v int) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.AddRank(v) + }) +} + +// UpdateRank sets the "rank" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateRank() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateRank() + }) +} + +// SetGithubID sets the "github_id" field. +func (u *UserUpsertOne) SetGithubID(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetGithubID(v) + }) +} + +// UpdateGithubID sets the "github_id" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateGithubID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateGithubID() + }) +} + +// ClearGithubID clears the value of the "github_id" field. +func (u *UserUpsertOne) ClearGithubID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearGithubID() + }) +} + +// SetGoogleID sets the "google_id" field. +func (u *UserUpsertOne) SetGoogleID(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetGoogleID(v) + }) +} + +// UpdateGoogleID sets the "google_id" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateGoogleID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateGoogleID() + }) +} + +// ClearGoogleID clears the value of the "google_id" field. +func (u *UserUpsertOne) ClearGoogleID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearGoogleID() + }) +} + +// SetFacebookID sets the "facebook_id" field. +func (u *UserUpsertOne) SetFacebookID(v string) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetFacebookID(v) + }) +} + +// UpdateFacebookID sets the "facebook_id" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateFacebookID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateFacebookID() + }) +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (u *UserUpsertOne) ClearFacebookID() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.ClearFacebookID() + }) +} + +// Exec executes the query. +func (u *UserUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserUpsertOne) 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 *UserUpsertOne) 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: UserUpsertOne.ID is not supported by MySQL driver. Use UserUpsertOne.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 *UserUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config err error builders []*UserCreate + conflict []sql.ConflictOption } // Save creates the User entities in the database. @@ -548,6 +1068,7 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { _, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = ucb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -597,3 +1118,323 @@ func (ucb *UserCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.User.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.UserUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ucb *UserCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserUpsertBulk { + ucb.conflict = opts + return &UserUpsertBulk{ + create: ucb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.User.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ucb *UserCreateBulk) OnConflictColumns(columns ...string) *UserUpsertBulk { + ucb.conflict = append(ucb.conflict, sql.ConflictColumns(columns...)) + return &UserUpsertBulk{ + create: ucb, + } +} + +// UserUpsertBulk is the builder for "upsert"-ing +// a bulk of User nodes. +type UserUpsertBulk struct { + create *UserCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.User.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(user.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserUpsertBulk) UpdateNewValues() *UserUpsertBulk { + 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(user.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(user.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.User.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserUpsertBulk) Ignore() *UserUpsertBulk { + 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 *UserUpsertBulk) DoNothing() *UserUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserCreateBulk.OnConflict +// documentation for more info. +func (u *UserUpsertBulk) Update(set func(*UserUpsert)) *UserUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserUpsertBulk) SetUpdatedAt(v time.Time) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateUpdatedAt() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserUpsertBulk) SetDeletedAt(v time.Time) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateDeletedAt() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserUpsertBulk) ClearDeletedAt() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearDeletedAt() + }) +} + +// SetEmail sets the "email" field. +func (u *UserUpsertBulk) SetEmail(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetEmail(v) + }) +} + +// UpdateEmail sets the "email" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateEmail() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateEmail() + }) +} + +// SetUsername sets the "username" field. +func (u *UserUpsertBulk) SetUsername(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetUsername(v) + }) +} + +// UpdateUsername sets the "username" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateUsername() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateUsername() + }) +} + +// SetAvatar sets the "avatar" field. +func (u *UserUpsertBulk) SetAvatar(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetAvatar(v) + }) +} + +// UpdateAvatar sets the "avatar" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateAvatar() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateAvatar() + }) +} + +// ClearAvatar clears the value of the "avatar" field. +func (u *UserUpsertBulk) ClearAvatar() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearAvatar() + }) +} + +// SetJoinedFrom sets the "joined_from" field. +func (u *UserUpsertBulk) SetJoinedFrom(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetJoinedFrom(v) + }) +} + +// UpdateJoinedFrom sets the "joined_from" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateJoinedFrom() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateJoinedFrom() + }) +} + +// ClearJoinedFrom clears the value of the "joined_from" field. +func (u *UserUpsertBulk) ClearJoinedFrom() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearJoinedFrom() + }) +} + +// SetBanned sets the "banned" field. +func (u *UserUpsertBulk) SetBanned(v bool) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetBanned(v) + }) +} + +// UpdateBanned sets the "banned" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateBanned() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateBanned() + }) +} + +// SetRank sets the "rank" field. +func (u *UserUpsertBulk) SetRank(v int) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetRank(v) + }) +} + +// AddRank adds v to the "rank" field. +func (u *UserUpsertBulk) AddRank(v int) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.AddRank(v) + }) +} + +// UpdateRank sets the "rank" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateRank() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateRank() + }) +} + +// SetGithubID sets the "github_id" field. +func (u *UserUpsertBulk) SetGithubID(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetGithubID(v) + }) +} + +// UpdateGithubID sets the "github_id" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateGithubID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateGithubID() + }) +} + +// ClearGithubID clears the value of the "github_id" field. +func (u *UserUpsertBulk) ClearGithubID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearGithubID() + }) +} + +// SetGoogleID sets the "google_id" field. +func (u *UserUpsertBulk) SetGoogleID(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetGoogleID(v) + }) +} + +// UpdateGoogleID sets the "google_id" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateGoogleID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateGoogleID() + }) +} + +// ClearGoogleID clears the value of the "google_id" field. +func (u *UserUpsertBulk) ClearGoogleID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearGoogleID() + }) +} + +// SetFacebookID sets the "facebook_id" field. +func (u *UserUpsertBulk) SetFacebookID(v string) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetFacebookID(v) + }) +} + +// UpdateFacebookID sets the "facebook_id" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateFacebookID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateFacebookID() + }) +} + +// ClearFacebookID clears the value of the "facebook_id" field. +func (u *UserUpsertBulk) ClearFacebookID() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.ClearFacebookID() + }) +} + +// Exec executes the query. +func (u *UserUpsertBulk) 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 UserCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/user_query.go b/generated/ent/user_query.go index 91a9bc76..57ac546d 100644 --- a/generated/ent/user_query.go +++ b/generated/ent/user_query.go @@ -592,7 +592,9 @@ func (uq *UserQuery) loadGuides(ctx context.Context, query *GuideQuery, nodes [] init(nodes[i]) } } - query.withFKs = true + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(guide.FieldUserID) + } query.Where(predicate.Guide(func(s *sql.Selector) { s.Where(sql.InValues(s.C(user.GuidesColumn), fks...)) })) @@ -601,13 +603,10 @@ func (uq *UserQuery) loadGuides(ctx context.Context, query *GuideQuery, nodes [] return err } for _, n := range neighbors { - fk := n.user_id - if fk == nil { - return fmt.Errorf(`foreign-key "user_id" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] + fk := n.UserID + node, ok := nodeids[fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } diff --git a/generated/ent/usergroup_create.go b/generated/ent/usergroup_create.go index 0d25586b..aaae50a0 100644 --- a/generated/ent/usergroup_create.go +++ b/generated/ent/usergroup_create.go @@ -8,6 +8,8 @@ import ( "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/user" @@ -19,6 +21,7 @@ type UserGroupCreate struct { config mutation *UserGroupMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -213,6 +216,7 @@ func (ugc *UserGroupCreate) createSpec() (*UserGroup, *sqlgraph.CreateSpec) { _node = &UserGroup{config: ugc.config} _spec = sqlgraph.NewCreateSpec(usergroup.Table, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeString)) ) + _spec.OnConflict = ugc.conflict if id, ok := ugc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -253,11 +257,267 @@ func (ugc *UserGroupCreate) createSpec() (*UserGroup, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserGroup.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.UserGroupUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ugc *UserGroupCreate) OnConflict(opts ...sql.ConflictOption) *UserGroupUpsertOne { + ugc.conflict = opts + return &UserGroupUpsertOne{ + create: ugc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserGroup.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ugc *UserGroupCreate) OnConflictColumns(columns ...string) *UserGroupUpsertOne { + ugc.conflict = append(ugc.conflict, sql.ConflictColumns(columns...)) + return &UserGroupUpsertOne{ + create: ugc, + } +} + +type ( + // UserGroupUpsertOne is the builder for "upsert"-ing + // one UserGroup node. + UserGroupUpsertOne struct { + create *UserGroupCreate + } + + // UserGroupUpsert is the "OnConflict" setter. + UserGroupUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserGroupUpsert) SetUpdatedAt(v time.Time) *UserGroupUpsert { + u.Set(usergroup.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserGroupUpsert) UpdateUpdatedAt() *UserGroupUpsert { + u.SetExcluded(usergroup.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserGroupUpsert) SetDeletedAt(v time.Time) *UserGroupUpsert { + u.Set(usergroup.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserGroupUpsert) UpdateDeletedAt() *UserGroupUpsert { + u.SetExcluded(usergroup.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserGroupUpsert) ClearDeletedAt() *UserGroupUpsert { + u.SetNull(usergroup.FieldDeletedAt) + return u +} + +// SetUserID sets the "user_id" field. +func (u *UserGroupUpsert) SetUserID(v string) *UserGroupUpsert { + u.Set(usergroup.FieldUserID, v) + return u +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserGroupUpsert) UpdateUserID() *UserGroupUpsert { + u.SetExcluded(usergroup.FieldUserID) + return u +} + +// SetGroupID sets the "group_id" field. +func (u *UserGroupUpsert) SetGroupID(v string) *UserGroupUpsert { + u.Set(usergroup.FieldGroupID, v) + return u +} + +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *UserGroupUpsert) UpdateGroupID() *UserGroupUpsert { + u.SetExcluded(usergroup.FieldGroupID) + 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.UserGroup.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(usergroup.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserGroupUpsertOne) UpdateNewValues() *UserGroupUpsertOne { + 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(usergroup.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(usergroup.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserGroup.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserGroupUpsertOne) Ignore() *UserGroupUpsertOne { + 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 *UserGroupUpsertOne) DoNothing() *UserGroupUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserGroupCreate.OnConflict +// documentation for more info. +func (u *UserGroupUpsertOne) Update(set func(*UserGroupUpsert)) *UserGroupUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserGroupUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserGroupUpsertOne) SetUpdatedAt(v time.Time) *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserGroupUpsertOne) UpdateUpdatedAt() *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserGroupUpsertOne) SetDeletedAt(v time.Time) *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserGroupUpsertOne) UpdateDeletedAt() *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserGroupUpsertOne) ClearDeletedAt() *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.ClearDeletedAt() + }) +} + +// SetUserID sets the "user_id" field. +func (u *UserGroupUpsertOne) SetUserID(v string) *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserGroupUpsertOne) UpdateUserID() *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateUserID() + }) +} + +// SetGroupID sets the "group_id" field. +func (u *UserGroupUpsertOne) SetGroupID(v string) *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.SetGroupID(v) + }) +} + +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *UserGroupUpsertOne) UpdateGroupID() *UserGroupUpsertOne { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateGroupID() + }) +} + +// Exec executes the query. +func (u *UserGroupUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserGroupCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserGroupUpsertOne) 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 *UserGroupUpsertOne) 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: UserGroupUpsertOne.ID is not supported by MySQL driver. Use UserGroupUpsertOne.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 *UserGroupUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // UserGroupCreateBulk is the builder for creating many UserGroup entities in bulk. type UserGroupCreateBulk struct { config err error builders []*UserGroupCreate + conflict []sql.ConflictOption } // Save creates the UserGroup entities in the database. @@ -287,6 +547,7 @@ func (ugcb *UserGroupCreateBulk) Save(ctx context.Context) ([]*UserGroup, error) _, err = mutators[i+1].Mutate(root, ugcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = ugcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ugcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -336,3 +597,183 @@ func (ugcb *UserGroupCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserGroup.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.UserGroupUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (ugcb *UserGroupCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserGroupUpsertBulk { + ugcb.conflict = opts + return &UserGroupUpsertBulk{ + create: ugcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserGroup.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ugcb *UserGroupCreateBulk) OnConflictColumns(columns ...string) *UserGroupUpsertBulk { + ugcb.conflict = append(ugcb.conflict, sql.ConflictColumns(columns...)) + return &UserGroupUpsertBulk{ + create: ugcb, + } +} + +// UserGroupUpsertBulk is the builder for "upsert"-ing +// a bulk of UserGroup nodes. +type UserGroupUpsertBulk struct { + create *UserGroupCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.UserGroup.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(usergroup.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserGroupUpsertBulk) UpdateNewValues() *UserGroupUpsertBulk { + 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(usergroup.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(usergroup.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserGroup.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserGroupUpsertBulk) Ignore() *UserGroupUpsertBulk { + 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 *UserGroupUpsertBulk) DoNothing() *UserGroupUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserGroupCreateBulk.OnConflict +// documentation for more info. +func (u *UserGroupUpsertBulk) Update(set func(*UserGroupUpsert)) *UserGroupUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserGroupUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserGroupUpsertBulk) SetUpdatedAt(v time.Time) *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserGroupUpsertBulk) UpdateUpdatedAt() *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserGroupUpsertBulk) SetDeletedAt(v time.Time) *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserGroupUpsertBulk) UpdateDeletedAt() *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserGroupUpsertBulk) ClearDeletedAt() *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.ClearDeletedAt() + }) +} + +// SetUserID sets the "user_id" field. +func (u *UserGroupUpsertBulk) SetUserID(v string) *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserGroupUpsertBulk) UpdateUserID() *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateUserID() + }) +} + +// SetGroupID sets the "group_id" field. +func (u *UserGroupUpsertBulk) SetGroupID(v string) *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.SetGroupID(v) + }) +} + +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *UserGroupUpsertBulk) UpdateGroupID() *UserGroupUpsertBulk { + return u.Update(func(s *UserGroupUpsert) { + s.UpdateGroupID() + }) +} + +// Exec executes the query. +func (u *UserGroupUpsertBulk) 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 UserGroupCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserGroupCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserGroupUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usermod_create.go b/generated/ent/usermod_create.go index 6c6123e6..e1bc94b0 100644 --- a/generated/ent/usermod_create.go +++ b/generated/ent/usermod_create.go @@ -7,6 +7,7 @@ import ( "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" @@ -19,6 +20,7 @@ type UserModCreate struct { config mutation *UserModMutation hooks []Hook + conflict []sql.ConflictOption } // SetUserID sets the "user_id" field. @@ -120,6 +122,7 @@ func (umc *UserModCreate) createSpec() (*UserMod, *sqlgraph.CreateSpec) { _node = &UserMod{config: umc.config} _spec = sqlgraph.NewCreateSpec(usermod.Table, nil) ) + _spec.OnConflict = umc.conflict if value, ok := umc.mutation.Role(); ok { _spec.SetField(usermod.FieldRole, field.TypeString, value) _node.Role = value @@ -161,11 +164,194 @@ func (umc *UserModCreate) createSpec() (*UserMod, *sqlgraph.CreateSpec) { return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserMod.Create(). +// SetUserID(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.UserModUpsert) { +// SetUserID(v+v). +// }). +// Exec(ctx) +func (umc *UserModCreate) OnConflict(opts ...sql.ConflictOption) *UserModUpsertOne { + umc.conflict = opts + return &UserModUpsertOne{ + create: umc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserMod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (umc *UserModCreate) OnConflictColumns(columns ...string) *UserModUpsertOne { + umc.conflict = append(umc.conflict, sql.ConflictColumns(columns...)) + return &UserModUpsertOne{ + create: umc, + } +} + +type ( + // UserModUpsertOne is the builder for "upsert"-ing + // one UserMod node. + UserModUpsertOne struct { + create *UserModCreate + } + + // UserModUpsert is the "OnConflict" setter. + UserModUpsert struct { + *sql.UpdateSet + } +) + +// SetUserID sets the "user_id" field. +func (u *UserModUpsert) SetUserID(v string) *UserModUpsert { + u.Set(usermod.FieldUserID, v) + return u +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserModUpsert) UpdateUserID() *UserModUpsert { + u.SetExcluded(usermod.FieldUserID) + return u +} + +// SetModID sets the "mod_id" field. +func (u *UserModUpsert) SetModID(v string) *UserModUpsert { + u.Set(usermod.FieldModID, v) + return u +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *UserModUpsert) UpdateModID() *UserModUpsert { + u.SetExcluded(usermod.FieldModID) + return u +} + +// SetRole sets the "role" field. +func (u *UserModUpsert) SetRole(v string) *UserModUpsert { + u.Set(usermod.FieldRole, v) + return u +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserModUpsert) UpdateRole() *UserModUpsert { + u.SetExcluded(usermod.FieldRole) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.UserMod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *UserModUpsertOne) UpdateNewValues() *UserModUpsertOne { + 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.UserMod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserModUpsertOne) Ignore() *UserModUpsertOne { + 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 *UserModUpsertOne) DoNothing() *UserModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserModCreate.OnConflict +// documentation for more info. +func (u *UserModUpsertOne) Update(set func(*UserModUpsert)) *UserModUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserModUpsert{UpdateSet: update}) + })) + return u +} + +// SetUserID sets the "user_id" field. +func (u *UserModUpsertOne) SetUserID(v string) *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserModUpsertOne) UpdateUserID() *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.UpdateUserID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *UserModUpsertOne) SetModID(v string) *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *UserModUpsertOne) UpdateModID() *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.UpdateModID() + }) +} + +// SetRole sets the "role" field. +func (u *UserModUpsertOne) SetRole(v string) *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.SetRole(v) + }) +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserModUpsertOne) UpdateRole() *UserModUpsertOne { + return u.Update(func(s *UserModUpsert) { + s.UpdateRole() + }) +} + +// Exec executes the query. +func (u *UserModUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserModCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserModUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + // UserModCreateBulk is the builder for creating many UserMod entities in bulk. type UserModCreateBulk struct { config err error builders []*UserModCreate + conflict []sql.ConflictOption } // Save creates the UserMod entities in the database. @@ -194,6 +380,7 @@ func (umcb *UserModCreateBulk) Save(ctx context.Context) ([]*UserMod, error) { _, err = mutators[i+1].Mutate(root, umcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = umcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, umcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -242,3 +429,149 @@ func (umcb *UserModCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserMod.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.UserModUpsert) { +// SetUserID(v+v). +// }). +// Exec(ctx) +func (umcb *UserModCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserModUpsertBulk { + umcb.conflict = opts + return &UserModUpsertBulk{ + create: umcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserMod.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (umcb *UserModCreateBulk) OnConflictColumns(columns ...string) *UserModUpsertBulk { + umcb.conflict = append(umcb.conflict, sql.ConflictColumns(columns...)) + return &UserModUpsertBulk{ + create: umcb, + } +} + +// UserModUpsertBulk is the builder for "upsert"-ing +// a bulk of UserMod nodes. +type UserModUpsertBulk struct { + create *UserModCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.UserMod.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *UserModUpsertBulk) UpdateNewValues() *UserModUpsertBulk { + 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.UserMod.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserModUpsertBulk) Ignore() *UserModUpsertBulk { + 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 *UserModUpsertBulk) DoNothing() *UserModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserModCreateBulk.OnConflict +// documentation for more info. +func (u *UserModUpsertBulk) Update(set func(*UserModUpsert)) *UserModUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserModUpsert{UpdateSet: update}) + })) + return u +} + +// SetUserID sets the "user_id" field. +func (u *UserModUpsertBulk) SetUserID(v string) *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserModUpsertBulk) UpdateUserID() *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.UpdateUserID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *UserModUpsertBulk) SetModID(v string) *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *UserModUpsertBulk) UpdateModID() *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.UpdateModID() + }) +} + +// SetRole sets the "role" field. +func (u *UserModUpsertBulk) SetRole(v string) *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.SetRole(v) + }) +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserModUpsertBulk) UpdateRole() *UserModUpsertBulk { + return u.Update(func(s *UserModUpsert) { + s.UpdateRole() + }) +} + +// Exec executes the query. +func (u *UserModUpsertBulk) 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 UserModCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserModCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserModUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/usersession_create.go b/generated/ent/usersession_create.go index 97897178..56de7283 100644 --- a/generated/ent/usersession_create.go +++ b/generated/ent/usersession_create.go @@ -8,6 +8,8 @@ import ( "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/user" @@ -19,6 +21,7 @@ type UserSessionCreate struct { config mutation *UserSessionMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -219,6 +222,7 @@ func (usc *UserSessionCreate) createSpec() (*UserSession, *sqlgraph.CreateSpec) _node = &UserSession{config: usc.config} _spec = sqlgraph.NewCreateSpec(usersession.Table, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeString)) ) + _spec.OnConflict = usc.conflict if id, ok := usc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -263,11 +267,280 @@ func (usc *UserSessionCreate) createSpec() (*UserSession, *sqlgraph.CreateSpec) return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserSession.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.UserSessionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (usc *UserSessionCreate) OnConflict(opts ...sql.ConflictOption) *UserSessionUpsertOne { + usc.conflict = opts + return &UserSessionUpsertOne{ + create: usc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserSession.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (usc *UserSessionCreate) OnConflictColumns(columns ...string) *UserSessionUpsertOne { + usc.conflict = append(usc.conflict, sql.ConflictColumns(columns...)) + return &UserSessionUpsertOne{ + create: usc, + } +} + +type ( + // UserSessionUpsertOne is the builder for "upsert"-ing + // one UserSession node. + UserSessionUpsertOne struct { + create *UserSessionCreate + } + + // UserSessionUpsert is the "OnConflict" setter. + UserSessionUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserSessionUpsert) SetUpdatedAt(v time.Time) *UserSessionUpsert { + u.Set(usersession.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserSessionUpsert) UpdateUpdatedAt() *UserSessionUpsert { + u.SetExcluded(usersession.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserSessionUpsert) SetDeletedAt(v time.Time) *UserSessionUpsert { + u.Set(usersession.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserSessionUpsert) UpdateDeletedAt() *UserSessionUpsert { + u.SetExcluded(usersession.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserSessionUpsert) ClearDeletedAt() *UserSessionUpsert { + u.SetNull(usersession.FieldDeletedAt) + return u +} + +// SetToken sets the "token" field. +func (u *UserSessionUpsert) SetToken(v string) *UserSessionUpsert { + u.Set(usersession.FieldToken, v) + return u +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *UserSessionUpsert) UpdateToken() *UserSessionUpsert { + u.SetExcluded(usersession.FieldToken) + return u +} + +// SetUserAgent sets the "user_agent" field. +func (u *UserSessionUpsert) SetUserAgent(v string) *UserSessionUpsert { + u.Set(usersession.FieldUserAgent, v) + return u +} + +// UpdateUserAgent sets the "user_agent" field to the value that was provided on create. +func (u *UserSessionUpsert) UpdateUserAgent() *UserSessionUpsert { + u.SetExcluded(usersession.FieldUserAgent) + return u +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (u *UserSessionUpsert) ClearUserAgent() *UserSessionUpsert { + u.SetNull(usersession.FieldUserAgent) + 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.UserSession.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(usersession.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserSessionUpsertOne) UpdateNewValues() *UserSessionUpsertOne { + 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(usersession.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(usersession.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserSession.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserSessionUpsertOne) Ignore() *UserSessionUpsertOne { + 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 *UserSessionUpsertOne) DoNothing() *UserSessionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserSessionCreate.OnConflict +// documentation for more info. +func (u *UserSessionUpsertOne) Update(set func(*UserSessionUpsert)) *UserSessionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserSessionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserSessionUpsertOne) SetUpdatedAt(v time.Time) *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserSessionUpsertOne) UpdateUpdatedAt() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserSessionUpsertOne) SetDeletedAt(v time.Time) *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserSessionUpsertOne) UpdateDeletedAt() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserSessionUpsertOne) ClearDeletedAt() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetToken sets the "token" field. +func (u *UserSessionUpsertOne) SetToken(v string) *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.SetToken(v) + }) +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *UserSessionUpsertOne) UpdateToken() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateToken() + }) +} + +// SetUserAgent sets the "user_agent" field. +func (u *UserSessionUpsertOne) SetUserAgent(v string) *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.SetUserAgent(v) + }) +} + +// UpdateUserAgent sets the "user_agent" field to the value that was provided on create. +func (u *UserSessionUpsertOne) UpdateUserAgent() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateUserAgent() + }) +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (u *UserSessionUpsertOne) ClearUserAgent() *UserSessionUpsertOne { + return u.Update(func(s *UserSessionUpsert) { + s.ClearUserAgent() + }) +} + +// Exec executes the query. +func (u *UserSessionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserSessionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserSessionUpsertOne) 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 *UserSessionUpsertOne) 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: UserSessionUpsertOne.ID is not supported by MySQL driver. Use UserSessionUpsertOne.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 *UserSessionUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // UserSessionCreateBulk is the builder for creating many UserSession entities in bulk. type UserSessionCreateBulk struct { config err error builders []*UserSessionCreate + conflict []sql.ConflictOption } // Save creates the UserSession entities in the database. @@ -297,6 +570,7 @@ func (uscb *UserSessionCreateBulk) Save(ctx context.Context) ([]*UserSession, er _, err = mutators[i+1].Mutate(root, uscb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = uscb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, uscb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -346,3 +620,190 @@ func (uscb *UserSessionCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserSession.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.UserSessionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (uscb *UserSessionCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserSessionUpsertBulk { + uscb.conflict = opts + return &UserSessionUpsertBulk{ + create: uscb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserSession.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (uscb *UserSessionCreateBulk) OnConflictColumns(columns ...string) *UserSessionUpsertBulk { + uscb.conflict = append(uscb.conflict, sql.ConflictColumns(columns...)) + return &UserSessionUpsertBulk{ + create: uscb, + } +} + +// UserSessionUpsertBulk is the builder for "upsert"-ing +// a bulk of UserSession nodes. +type UserSessionUpsertBulk struct { + create *UserSessionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.UserSession.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(usersession.FieldID) +// }), +// ). +// Exec(ctx) +func (u *UserSessionUpsertBulk) UpdateNewValues() *UserSessionUpsertBulk { + 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(usersession.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(usersession.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserSession.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserSessionUpsertBulk) Ignore() *UserSessionUpsertBulk { + 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 *UserSessionUpsertBulk) DoNothing() *UserSessionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserSessionCreateBulk.OnConflict +// documentation for more info. +func (u *UserSessionUpsertBulk) Update(set func(*UserSessionUpsert)) *UserSessionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserSessionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *UserSessionUpsertBulk) SetUpdatedAt(v time.Time) *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *UserSessionUpsertBulk) UpdateUpdatedAt() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *UserSessionUpsertBulk) SetDeletedAt(v time.Time) *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *UserSessionUpsertBulk) UpdateDeletedAt() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *UserSessionUpsertBulk) ClearDeletedAt() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetToken sets the "token" field. +func (u *UserSessionUpsertBulk) SetToken(v string) *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.SetToken(v) + }) +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *UserSessionUpsertBulk) UpdateToken() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateToken() + }) +} + +// SetUserAgent sets the "user_agent" field. +func (u *UserSessionUpsertBulk) SetUserAgent(v string) *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.SetUserAgent(v) + }) +} + +// UpdateUserAgent sets the "user_agent" field to the value that was provided on create. +func (u *UserSessionUpsertBulk) UpdateUserAgent() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.UpdateUserAgent() + }) +} + +// ClearUserAgent clears the value of the "user_agent" field. +func (u *UserSessionUpsertBulk) ClearUserAgent() *UserSessionUpsertBulk { + return u.Update(func(s *UserSessionUpsert) { + s.ClearUserAgent() + }) +} + +// Exec executes the query. +func (u *UserSessionUpsertBulk) 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 UserSessionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserSessionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserSessionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/version.go b/generated/ent/version.go index ab9245b7..ba7a07af 100644 --- a/generated/ent/version.go +++ b/generated/ent/version.go @@ -24,6 +24,8 @@ type Version struct { UpdatedAt time.Time `json:"updated_at,omitempty"` // DeletedAt holds the value of the "deleted_at" field. DeletedAt time.Time `json:"deleted_at,omitempty"` + // ModID holds the value of the "mod_id" field. + ModID string `json:"mod_id,omitempty"` // Version holds the value of the "version" field. Version string `json:"version,omitempty"` // SmlVersion holds the value of the "sml_version" field. @@ -59,7 +61,6 @@ type Version struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the VersionQuery when eager-loading is set. Edges VersionEdges `json:"edges"` - mod_id *string selectValues sql.SelectValues } @@ -69,11 +70,13 @@ type VersionEdges struct { Mod *Mod `json:"mod,omitempty"` // Dependencies holds the value of the dependencies edge. Dependencies []*Mod `json:"dependencies,omitempty"` + // Targets holds the value of the targets edge. + Targets []*VersionTarget `json:"targets,omitempty"` // VersionDependencies holds the value of the version_dependencies edge. VersionDependencies []*VersionDependency `json:"version_dependencies,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [4]bool } // ModOrErr returns the Mod value or an error if the edge @@ -98,10 +101,19 @@ func (e VersionEdges) DependenciesOrErr() ([]*Mod, error) { return nil, &NotLoadedError{edge: "dependencies"} } +// TargetsOrErr returns the Targets value or an error if the edge +// was not loaded in eager-loading. +func (e VersionEdges) TargetsOrErr() ([]*VersionTarget, error) { + if e.loadedTypes[2] { + return e.Targets, nil + } + return nil, &NotLoadedError{edge: "targets"} +} + // VersionDependenciesOrErr returns the VersionDependencies value or an error if the edge // was not loaded in eager-loading. func (e VersionEdges) VersionDependenciesOrErr() ([]*VersionDependency, error) { - if e.loadedTypes[2] { + if e.loadedTypes[3] { return e.VersionDependencies, nil } return nil, &NotLoadedError{edge: "version_dependencies"} @@ -116,12 +128,10 @@ func (*Version) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case version.FieldDownloads, version.FieldHotness, version.FieldVersionMajor, version.FieldVersionMinor, version.FieldVersionPatch, version.FieldSize: values[i] = new(sql.NullInt64) - case version.FieldID, version.FieldVersion, version.FieldSmlVersion, version.FieldChangelog, version.FieldKey, version.FieldStability, version.FieldMetadata, version.FieldModReference, version.FieldHash: + case version.FieldID, version.FieldModID, version.FieldVersion, version.FieldSmlVersion, version.FieldChangelog, version.FieldKey, version.FieldStability, version.FieldMetadata, version.FieldModReference, version.FieldHash: values[i] = new(sql.NullString) case version.FieldCreatedAt, version.FieldUpdatedAt, version.FieldDeletedAt: values[i] = new(sql.NullTime) - case version.ForeignKeys[0]: // mod_id - values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) } @@ -161,6 +171,12 @@ func (v *Version) assignValues(columns []string, values []any) error { } else if value.Valid { v.DeletedAt = value.Time } + case version.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 { + v.ModID = value.String + } case version.FieldVersion: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field version", values[i]) @@ -257,13 +273,6 @@ func (v *Version) assignValues(columns []string, values []any) error { } else if value.Valid { v.Hash = value.String } - case version.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field mod_id", values[i]) - } else if value.Valid { - v.mod_id = new(string) - *v.mod_id = value.String - } default: v.selectValues.Set(columns[i], values[i]) } @@ -287,6 +296,11 @@ func (v *Version) QueryDependencies() *ModQuery { return NewVersionClient(v.config).QueryDependencies(v) } +// QueryTargets queries the "targets" edge of the Version entity. +func (v *Version) QueryTargets() *VersionTargetQuery { + return NewVersionClient(v.config).QueryTargets(v) +} + // QueryVersionDependencies queries the "version_dependencies" edge of the Version entity. func (v *Version) QueryVersionDependencies() *VersionDependencyQuery { return NewVersionClient(v.config).QueryVersionDependencies(v) @@ -324,6 +338,9 @@ func (v *Version) String() string { builder.WriteString("deleted_at=") builder.WriteString(v.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("mod_id=") + builder.WriteString(v.ModID) + builder.WriteString(", ") builder.WriteString("version=") builder.WriteString(v.Version) builder.WriteString(", ") diff --git a/generated/ent/version/version.go b/generated/ent/version/version.go index 00b68c98..e9205b75 100644 --- a/generated/ent/version/version.go +++ b/generated/ent/version/version.go @@ -22,6 +22,8 @@ const ( FieldUpdatedAt = "updated_at" // FieldDeletedAt holds the string denoting the deleted_at field in the database. FieldDeletedAt = "deleted_at" + // FieldModID holds the string denoting the mod_id field in the database. + FieldModID = "mod_id" // FieldVersion holds the string denoting the version field in the database. FieldVersion = "version" // FieldSmlVersion holds the string denoting the sml_version field in the database. @@ -58,6 +60,8 @@ const ( EdgeMod = "mod" // EdgeDependencies holds the string denoting the dependencies edge name in mutations. EdgeDependencies = "dependencies" + // EdgeTargets holds the string denoting the targets edge name in mutations. + EdgeTargets = "targets" // EdgeVersionDependencies holds the string denoting the version_dependencies edge name in mutations. EdgeVersionDependencies = "version_dependencies" // Table holds the table name of the version in the database. @@ -74,6 +78,13 @@ const ( // DependenciesInverseTable is the table name for the Mod entity. // It exists in this package in order to avoid circular dependency with the "mod" package. DependenciesInverseTable = "mods" + // TargetsTable is the table that holds the targets relation/edge. + TargetsTable = "version_targets" + // TargetsInverseTable is the table name for the VersionTarget entity. + // It exists in this package in order to avoid circular dependency with the "versiontarget" package. + TargetsInverseTable = "version_targets" + // TargetsColumn is the table column denoting the targets relation/edge. + TargetsColumn = "version_id" // VersionDependenciesTable is the table that holds the version_dependencies relation/edge. VersionDependenciesTable = "version_dependencies" // VersionDependenciesInverseTable is the table name for the VersionDependency entity. @@ -89,6 +100,7 @@ var Columns = []string{ FieldCreatedAt, FieldUpdatedAt, FieldDeletedAt, + FieldModID, FieldVersion, FieldSmlVersion, FieldChangelog, @@ -107,12 +119,6 @@ var Columns = []string{ FieldHash, } -// ForeignKeys holds the SQL foreign-keys that are owned by the "versions" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "mod_id", -} - var ( // DependenciesPrimaryKey and DependenciesColumn2 are the table columns denoting the // primary key for the dependencies relation (M2M). @@ -126,11 +132,6 @@ func ValidColumn(column string) bool { return true } } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } return false } @@ -211,6 +212,11 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() } +// ByModID orders the results by the mod_id field. +func ByModID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModID, opts...).ToFunc() +} + // ByVersion orders the results by the version field. func ByVersion(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldVersion, opts...).ToFunc() @@ -312,6 +318,20 @@ func ByDependencies(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// 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...)...) + } +} + // ByVersionDependenciesCount orders the results by version_dependencies count. func ByVersionDependenciesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -339,6 +359,13 @@ func newDependenciesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, false, DependenciesTable, DependenciesPrimaryKey...), ) } +func newTargetsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TargetsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TargetsTable, TargetsColumn), + ) +} func newVersionDependenciesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/generated/ent/version/where.go b/generated/ent/version/where.go index c4e73573..29eed150 100644 --- a/generated/ent/version/where.go +++ b/generated/ent/version/where.go @@ -80,6 +80,11 @@ func DeletedAt(v time.Time) predicate.Version { return predicate.Version(sql.FieldEQ(FieldDeletedAt, v)) } +// ModID applies equality check predicate on the "mod_id" field. It's identical to ModIDEQ. +func ModID(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldModID, v)) +} + // Version applies equality check predicate on the "version" field. It's identical to VersionEQ. func Version(v string) predicate.Version { return predicate.Version(sql.FieldEQ(FieldVersion, v)) @@ -285,6 +290,71 @@ func DeletedAtNotNil() predicate.Version { return predicate.Version(sql.FieldNotNull(FieldDeletedAt)) } +// ModIDEQ applies the EQ predicate on the "mod_id" field. +func ModIDEQ(v string) predicate.Version { + return predicate.Version(sql.FieldEQ(FieldModID, v)) +} + +// ModIDNEQ applies the NEQ predicate on the "mod_id" field. +func ModIDNEQ(v string) predicate.Version { + return predicate.Version(sql.FieldNEQ(FieldModID, v)) +} + +// ModIDIn applies the In predicate on the "mod_id" field. +func ModIDIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldIn(FieldModID, vs...)) +} + +// ModIDNotIn applies the NotIn predicate on the "mod_id" field. +func ModIDNotIn(vs ...string) predicate.Version { + return predicate.Version(sql.FieldNotIn(FieldModID, vs...)) +} + +// ModIDGT applies the GT predicate on the "mod_id" field. +func ModIDGT(v string) predicate.Version { + return predicate.Version(sql.FieldGT(FieldModID, v)) +} + +// ModIDGTE applies the GTE predicate on the "mod_id" field. +func ModIDGTE(v string) predicate.Version { + return predicate.Version(sql.FieldGTE(FieldModID, v)) +} + +// ModIDLT applies the LT predicate on the "mod_id" field. +func ModIDLT(v string) predicate.Version { + return predicate.Version(sql.FieldLT(FieldModID, v)) +} + +// ModIDLTE applies the LTE predicate on the "mod_id" field. +func ModIDLTE(v string) predicate.Version { + return predicate.Version(sql.FieldLTE(FieldModID, v)) +} + +// ModIDContains applies the Contains predicate on the "mod_id" field. +func ModIDContains(v string) predicate.Version { + return predicate.Version(sql.FieldContains(FieldModID, v)) +} + +// ModIDHasPrefix applies the HasPrefix predicate on the "mod_id" field. +func ModIDHasPrefix(v string) predicate.Version { + return predicate.Version(sql.FieldHasPrefix(FieldModID, v)) +} + +// ModIDHasSuffix applies the HasSuffix predicate on the "mod_id" field. +func ModIDHasSuffix(v string) predicate.Version { + return predicate.Version(sql.FieldHasSuffix(FieldModID, v)) +} + +// ModIDEqualFold applies the EqualFold predicate on the "mod_id" field. +func ModIDEqualFold(v string) predicate.Version { + return predicate.Version(sql.FieldEqualFold(FieldModID, v)) +} + +// ModIDContainsFold applies the ContainsFold predicate on the "mod_id" field. +func ModIDContainsFold(v string) predicate.Version { + return predicate.Version(sql.FieldContainsFold(FieldModID, v)) +} + // VersionEQ applies the EQ predicate on the "version" field. func VersionEQ(v string) predicate.Version { return predicate.Version(sql.FieldEQ(FieldVersion, v)) @@ -1066,6 +1136,29 @@ func HasDependenciesWith(preds ...predicate.Mod) predicate.Version { }) } +// HasTargets applies the HasEdge predicate on the "targets" edge. +func HasTargets() predicate.Version { + return predicate.Version(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.VersionTarget) predicate.Version { + return predicate.Version(func(s *sql.Selector) { + step := newTargetsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasVersionDependencies applies the HasEdge predicate on the "version_dependencies" edge. func HasVersionDependencies() predicate.Version { return predicate.Version(func(s *sql.Selector) { diff --git a/generated/ent/version_create.go b/generated/ent/version_create.go index bb80d7fe..bcff9a2d 100644 --- a/generated/ent/version_create.go +++ b/generated/ent/version_create.go @@ -8,10 +8,13 @@ import ( "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/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // VersionCreate is the builder for creating a Version entity. @@ -19,6 +22,7 @@ type VersionCreate struct { config mutation *VersionMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -63,6 +67,12 @@ func (vc *VersionCreate) SetNillableDeletedAt(t *time.Time) *VersionCreate { return vc } +// SetModID sets the "mod_id" field. +func (vc *VersionCreate) SetModID(s string) *VersionCreate { + vc.mutation.SetModID(s) + return vc +} + // SetVersion sets the "version" field. func (vc *VersionCreate) SetVersion(s string) *VersionCreate { vc.mutation.SetVersion(s) @@ -189,12 +199,6 @@ func (vc *VersionCreate) SetNillableID(s *string) *VersionCreate { return vc } -// SetModID sets the "mod" edge to the Mod entity by ID. -func (vc *VersionCreate) SetModID(id string) *VersionCreate { - vc.mutation.SetModID(id) - return vc -} - // SetMod sets the "mod" edge to the Mod entity. func (vc *VersionCreate) SetMod(m *Mod) *VersionCreate { return vc.SetModID(m.ID) @@ -215,6 +219,21 @@ func (vc *VersionCreate) AddDependencies(m ...*Mod) *VersionCreate { return vc.AddDependencyIDs(ids...) } +// AddTargetIDs adds the "targets" edge to the VersionTarget entity by IDs. +func (vc *VersionCreate) AddTargetIDs(ids ...string) *VersionCreate { + vc.mutation.AddTargetIDs(ids...) + return vc +} + +// AddTargets adds the "targets" edges to the VersionTarget entity. +func (vc *VersionCreate) AddTargets(v ...*VersionTarget) *VersionCreate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return vc.AddTargetIDs(ids...) +} + // Mutation returns the VersionMutation object of the builder. func (vc *VersionCreate) Mutation() *VersionMutation { return vc.mutation @@ -292,6 +311,9 @@ func (vc *VersionCreate) check() error { if _, ok := vc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Version.updated_at"`)} } + if _, ok := vc.mutation.ModID(); !ok { + return &ValidationError{Name: "mod_id", err: errors.New(`ent: missing required field "Version.mod_id"`)} + } if _, ok := vc.mutation.Version(); !ok { return &ValidationError{Name: "version", err: errors.New(`ent: missing required field "Version.version"`)} } @@ -399,6 +421,7 @@ func (vc *VersionCreate) createSpec() (*Version, *sqlgraph.CreateSpec) { _node = &Version{config: vc.config} _spec = sqlgraph.NewCreateSpec(version.Table, sqlgraph.NewFieldSpec(version.FieldID, field.TypeString)) ) + _spec.OnConflict = vc.conflict if id, ok := vc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id @@ -493,7 +516,7 @@ func (vc *VersionCreate) createSpec() (*Version, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.mod_id = &nodes[0] + _node.ModID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := vc.mutation.DependenciesIDs(); len(nodes) > 0 { @@ -516,14 +539,754 @@ func (vc *VersionCreate) createSpec() (*Version, *sqlgraph.CreateSpec) { edge.Target.Fields = specE.Fields _spec.Edges = append(_spec.Edges, edge) } + if nodes := vc.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.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.Version.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.VersionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (vc *VersionCreate) OnConflict(opts ...sql.ConflictOption) *VersionUpsertOne { + vc.conflict = opts + return &VersionUpsertOne{ + create: vc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Version.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vc *VersionCreate) OnConflictColumns(columns ...string) *VersionUpsertOne { + vc.conflict = append(vc.conflict, sql.ConflictColumns(columns...)) + return &VersionUpsertOne{ + create: vc, + } +} + +type ( + // VersionUpsertOne is the builder for "upsert"-ing + // one Version node. + VersionUpsertOne struct { + create *VersionCreate + } + + // VersionUpsert is the "OnConflict" setter. + VersionUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionUpsert) SetUpdatedAt(v time.Time) *VersionUpsert { + u.Set(version.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionUpsert) UpdateUpdatedAt() *VersionUpsert { + u.SetExcluded(version.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionUpsert) SetDeletedAt(v time.Time) *VersionUpsert { + u.Set(version.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionUpsert) UpdateDeletedAt() *VersionUpsert { + u.SetExcluded(version.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionUpsert) ClearDeletedAt() *VersionUpsert { + u.SetNull(version.FieldDeletedAt) + return u +} + +// SetModID sets the "mod_id" field. +func (u *VersionUpsert) SetModID(v string) *VersionUpsert { + u.Set(version.FieldModID, v) + return u +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionUpsert) UpdateModID() *VersionUpsert { + u.SetExcluded(version.FieldModID) + return u +} + +// SetVersion sets the "version" field. +func (u *VersionUpsert) SetVersion(v string) *VersionUpsert { + u.Set(version.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *VersionUpsert) UpdateVersion() *VersionUpsert { + u.SetExcluded(version.FieldVersion) + return u +} + +// SetSmlVersion sets the "sml_version" field. +func (u *VersionUpsert) SetSmlVersion(v string) *VersionUpsert { + u.Set(version.FieldSmlVersion, v) + return u +} + +// UpdateSmlVersion sets the "sml_version" field to the value that was provided on create. +func (u *VersionUpsert) UpdateSmlVersion() *VersionUpsert { + u.SetExcluded(version.FieldSmlVersion) + return u +} + +// SetChangelog sets the "changelog" field. +func (u *VersionUpsert) SetChangelog(v string) *VersionUpsert { + u.Set(version.FieldChangelog, v) + return u +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *VersionUpsert) UpdateChangelog() *VersionUpsert { + u.SetExcluded(version.FieldChangelog) + return u +} + +// SetDownloads sets the "downloads" field. +func (u *VersionUpsert) SetDownloads(v uint) *VersionUpsert { + u.Set(version.FieldDownloads, v) + return u +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *VersionUpsert) UpdateDownloads() *VersionUpsert { + u.SetExcluded(version.FieldDownloads) + return u +} + +// AddDownloads adds v to the "downloads" field. +func (u *VersionUpsert) AddDownloads(v uint) *VersionUpsert { + u.Add(version.FieldDownloads, v) + return u +} + +// SetKey sets the "key" field. +func (u *VersionUpsert) SetKey(v string) *VersionUpsert { + u.Set(version.FieldKey, v) + return u +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionUpsert) UpdateKey() *VersionUpsert { + u.SetExcluded(version.FieldKey) + return u +} + +// SetStability sets the "stability" field. +func (u *VersionUpsert) SetStability(v version.Stability) *VersionUpsert { + u.Set(version.FieldStability, v) + return u +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *VersionUpsert) UpdateStability() *VersionUpsert { + u.SetExcluded(version.FieldStability) + return u +} + +// SetApproved sets the "approved" field. +func (u *VersionUpsert) SetApproved(v bool) *VersionUpsert { + u.Set(version.FieldApproved, v) + return u +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *VersionUpsert) UpdateApproved() *VersionUpsert { + u.SetExcluded(version.FieldApproved) + return u +} + +// SetHotness sets the "hotness" field. +func (u *VersionUpsert) SetHotness(v uint) *VersionUpsert { + u.Set(version.FieldHotness, v) + return u +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *VersionUpsert) UpdateHotness() *VersionUpsert { + u.SetExcluded(version.FieldHotness) + return u +} + +// AddHotness adds v to the "hotness" field. +func (u *VersionUpsert) AddHotness(v uint) *VersionUpsert { + u.Add(version.FieldHotness, v) + return u +} + +// SetDenied sets the "denied" field. +func (u *VersionUpsert) SetDenied(v bool) *VersionUpsert { + u.Set(version.FieldDenied, v) + return u +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *VersionUpsert) UpdateDenied() *VersionUpsert { + u.SetExcluded(version.FieldDenied) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *VersionUpsert) SetMetadata(v string) *VersionUpsert { + u.Set(version.FieldMetadata, v) + return u +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *VersionUpsert) UpdateMetadata() *VersionUpsert { + u.SetExcluded(version.FieldMetadata) + return u +} + +// SetModReference sets the "mod_reference" field. +func (u *VersionUpsert) SetModReference(v string) *VersionUpsert { + u.Set(version.FieldModReference, v) + return u +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *VersionUpsert) UpdateModReference() *VersionUpsert { + u.SetExcluded(version.FieldModReference) + return u +} + +// SetVersionMajor sets the "version_major" field. +func (u *VersionUpsert) SetVersionMajor(v int) *VersionUpsert { + u.Set(version.FieldVersionMajor, v) + return u +} + +// UpdateVersionMajor sets the "version_major" field to the value that was provided on create. +func (u *VersionUpsert) UpdateVersionMajor() *VersionUpsert { + u.SetExcluded(version.FieldVersionMajor) + return u +} + +// AddVersionMajor adds v to the "version_major" field. +func (u *VersionUpsert) AddVersionMajor(v int) *VersionUpsert { + u.Add(version.FieldVersionMajor, v) + return u +} + +// SetVersionMinor sets the "version_minor" field. +func (u *VersionUpsert) SetVersionMinor(v int) *VersionUpsert { + u.Set(version.FieldVersionMinor, v) + return u +} + +// UpdateVersionMinor sets the "version_minor" field to the value that was provided on create. +func (u *VersionUpsert) UpdateVersionMinor() *VersionUpsert { + u.SetExcluded(version.FieldVersionMinor) + return u +} + +// AddVersionMinor adds v to the "version_minor" field. +func (u *VersionUpsert) AddVersionMinor(v int) *VersionUpsert { + u.Add(version.FieldVersionMinor, v) + return u +} + +// SetVersionPatch sets the "version_patch" field. +func (u *VersionUpsert) SetVersionPatch(v int) *VersionUpsert { + u.Set(version.FieldVersionPatch, v) + return u +} + +// UpdateVersionPatch sets the "version_patch" field to the value that was provided on create. +func (u *VersionUpsert) UpdateVersionPatch() *VersionUpsert { + u.SetExcluded(version.FieldVersionPatch) + return u +} + +// AddVersionPatch adds v to the "version_patch" field. +func (u *VersionUpsert) AddVersionPatch(v int) *VersionUpsert { + u.Add(version.FieldVersionPatch, v) + return u +} + +// SetSize sets the "size" field. +func (u *VersionUpsert) SetSize(v int64) *VersionUpsert { + u.Set(version.FieldSize, v) + return u +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionUpsert) UpdateSize() *VersionUpsert { + u.SetExcluded(version.FieldSize) + return u +} + +// AddSize adds v to the "size" field. +func (u *VersionUpsert) AddSize(v int64) *VersionUpsert { + u.Add(version.FieldSize, v) + return u +} + +// SetHash sets the "hash" field. +func (u *VersionUpsert) SetHash(v string) *VersionUpsert { + u.Set(version.FieldHash, v) + return u +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionUpsert) UpdateHash() *VersionUpsert { + u.SetExcluded(version.FieldHash) + 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.Version.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(version.FieldID) +// }), +// ). +// Exec(ctx) +func (u *VersionUpsertOne) UpdateNewValues() *VersionUpsertOne { + 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(version.FieldID) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(version.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Version.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionUpsertOne) Ignore() *VersionUpsertOne { + 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 *VersionUpsertOne) DoNothing() *VersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionCreate.OnConflict +// documentation for more info. +func (u *VersionUpsertOne) Update(set func(*VersionUpsert)) *VersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionUpsertOne) SetUpdatedAt(v time.Time) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateUpdatedAt() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionUpsertOne) SetDeletedAt(v time.Time) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateDeletedAt() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionUpsertOne) ClearDeletedAt() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetModID sets the "mod_id" field. +func (u *VersionUpsertOne) SetModID(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateModID() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateModID() + }) +} + +// SetVersion sets the "version" field. +func (u *VersionUpsertOne) SetVersion(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateVersion() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersion() + }) +} + +// SetSmlVersion sets the "sml_version" field. +func (u *VersionUpsertOne) SetSmlVersion(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetSmlVersion(v) + }) +} + +// UpdateSmlVersion sets the "sml_version" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateSmlVersion() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateSmlVersion() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *VersionUpsertOne) SetChangelog(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateChangelog() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateChangelog() + }) +} + +// SetDownloads sets the "downloads" field. +func (u *VersionUpsertOne) SetDownloads(v uint) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetDownloads(v) + }) +} + +// AddDownloads adds v to the "downloads" field. +func (u *VersionUpsertOne) AddDownloads(v uint) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddDownloads(v) + }) +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateDownloads() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateDownloads() + }) +} + +// SetKey sets the "key" field. +func (u *VersionUpsertOne) SetKey(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetKey(v) + }) +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateKey() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateKey() + }) +} + +// SetStability sets the "stability" field. +func (u *VersionUpsertOne) SetStability(v version.Stability) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetStability(v) + }) +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateStability() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateStability() + }) +} + +// SetApproved sets the "approved" field. +func (u *VersionUpsertOne) SetApproved(v bool) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetApproved(v) + }) +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateApproved() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateApproved() + }) +} + +// SetHotness sets the "hotness" field. +func (u *VersionUpsertOne) SetHotness(v uint) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *VersionUpsertOne) AddHotness(v uint) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateHotness() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateHotness() + }) +} + +// SetDenied sets the "denied" field. +func (u *VersionUpsertOne) SetDenied(v bool) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetDenied(v) + }) +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateDenied() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateDenied() + }) +} + +// SetMetadata sets the "metadata" field. +func (u *VersionUpsertOne) SetMetadata(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateMetadata() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateMetadata() + }) +} + +// SetModReference sets the "mod_reference" field. +func (u *VersionUpsertOne) SetModReference(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetModReference(v) + }) +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateModReference() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateModReference() + }) +} + +// SetVersionMajor sets the "version_major" field. +func (u *VersionUpsertOne) SetVersionMajor(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetVersionMajor(v) + }) +} + +// AddVersionMajor adds v to the "version_major" field. +func (u *VersionUpsertOne) AddVersionMajor(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddVersionMajor(v) + }) +} + +// UpdateVersionMajor sets the "version_major" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateVersionMajor() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionMajor() + }) +} + +// SetVersionMinor sets the "version_minor" field. +func (u *VersionUpsertOne) SetVersionMinor(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetVersionMinor(v) + }) +} + +// AddVersionMinor adds v to the "version_minor" field. +func (u *VersionUpsertOne) AddVersionMinor(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddVersionMinor(v) + }) +} + +// UpdateVersionMinor sets the "version_minor" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateVersionMinor() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionMinor() + }) +} + +// SetVersionPatch sets the "version_patch" field. +func (u *VersionUpsertOne) SetVersionPatch(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetVersionPatch(v) + }) +} + +// AddVersionPatch adds v to the "version_patch" field. +func (u *VersionUpsertOne) AddVersionPatch(v int) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddVersionPatch(v) + }) +} + +// UpdateVersionPatch sets the "version_patch" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateVersionPatch() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionPatch() + }) +} + +// SetSize sets the "size" field. +func (u *VersionUpsertOne) SetSize(v int64) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *VersionUpsertOne) AddSize(v int64) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateSize() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *VersionUpsertOne) SetHash(v string) *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionUpsertOne) UpdateHash() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.UpdateHash() + }) +} + +// Exec executes the query. +func (u *VersionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionUpsertOne) 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 *VersionUpsertOne) 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: VersionUpsertOne.ID is not supported by MySQL driver. Use VersionUpsertOne.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 *VersionUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + // VersionCreateBulk is the builder for creating many Version entities in bulk. type VersionCreateBulk struct { config err error builders []*VersionCreate + conflict []sql.ConflictOption } // Save creates the Version entities in the database. @@ -553,6 +1316,7 @@ func (vcb *VersionCreateBulk) Save(ctx context.Context) ([]*Version, error) { _, err = mutators[i+1].Mutate(root, vcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = vcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, vcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -602,3 +1366,435 @@ func (vcb *VersionCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Version.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.VersionUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (vcb *VersionCreateBulk) OnConflict(opts ...sql.ConflictOption) *VersionUpsertBulk { + vcb.conflict = opts + return &VersionUpsertBulk{ + create: vcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Version.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vcb *VersionCreateBulk) OnConflictColumns(columns ...string) *VersionUpsertBulk { + vcb.conflict = append(vcb.conflict, sql.ConflictColumns(columns...)) + return &VersionUpsertBulk{ + create: vcb, + } +} + +// VersionUpsertBulk is the builder for "upsert"-ing +// a bulk of Version nodes. +type VersionUpsertBulk struct { + create *VersionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Version.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(version.FieldID) +// }), +// ). +// Exec(ctx) +func (u *VersionUpsertBulk) UpdateNewValues() *VersionUpsertBulk { + 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(version.FieldID) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(version.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Version.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionUpsertBulk) Ignore() *VersionUpsertBulk { + 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 *VersionUpsertBulk) DoNothing() *VersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionCreateBulk.OnConflict +// documentation for more info. +func (u *VersionUpsertBulk) Update(set func(*VersionUpsert)) *VersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionUpsertBulk) SetUpdatedAt(v time.Time) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateUpdatedAt() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionUpsertBulk) SetDeletedAt(v time.Time) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateDeletedAt() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionUpsertBulk) ClearDeletedAt() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearDeletedAt() + }) +} + +// SetModID sets the "mod_id" field. +func (u *VersionUpsertBulk) SetModID(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateModID() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateModID() + }) +} + +// SetVersion sets the "version" field. +func (u *VersionUpsertBulk) SetVersion(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateVersion() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersion() + }) +} + +// SetSmlVersion sets the "sml_version" field. +func (u *VersionUpsertBulk) SetSmlVersion(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetSmlVersion(v) + }) +} + +// UpdateSmlVersion sets the "sml_version" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateSmlVersion() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateSmlVersion() + }) +} + +// SetChangelog sets the "changelog" field. +func (u *VersionUpsertBulk) SetChangelog(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetChangelog(v) + }) +} + +// UpdateChangelog sets the "changelog" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateChangelog() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateChangelog() + }) +} + +// SetDownloads sets the "downloads" field. +func (u *VersionUpsertBulk) SetDownloads(v uint) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetDownloads(v) + }) +} + +// AddDownloads adds v to the "downloads" field. +func (u *VersionUpsertBulk) AddDownloads(v uint) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddDownloads(v) + }) +} + +// UpdateDownloads sets the "downloads" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateDownloads() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateDownloads() + }) +} + +// SetKey sets the "key" field. +func (u *VersionUpsertBulk) SetKey(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetKey(v) + }) +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateKey() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateKey() + }) +} + +// SetStability sets the "stability" field. +func (u *VersionUpsertBulk) SetStability(v version.Stability) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetStability(v) + }) +} + +// UpdateStability sets the "stability" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateStability() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateStability() + }) +} + +// SetApproved sets the "approved" field. +func (u *VersionUpsertBulk) SetApproved(v bool) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetApproved(v) + }) +} + +// UpdateApproved sets the "approved" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateApproved() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateApproved() + }) +} + +// SetHotness sets the "hotness" field. +func (u *VersionUpsertBulk) SetHotness(v uint) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetHotness(v) + }) +} + +// AddHotness adds v to the "hotness" field. +func (u *VersionUpsertBulk) AddHotness(v uint) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddHotness(v) + }) +} + +// UpdateHotness sets the "hotness" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateHotness() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateHotness() + }) +} + +// SetDenied sets the "denied" field. +func (u *VersionUpsertBulk) SetDenied(v bool) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetDenied(v) + }) +} + +// UpdateDenied sets the "denied" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateDenied() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateDenied() + }) +} + +// SetMetadata sets the "metadata" field. +func (u *VersionUpsertBulk) SetMetadata(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateMetadata() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateMetadata() + }) +} + +// SetModReference sets the "mod_reference" field. +func (u *VersionUpsertBulk) SetModReference(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetModReference(v) + }) +} + +// UpdateModReference sets the "mod_reference" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateModReference() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateModReference() + }) +} + +// SetVersionMajor sets the "version_major" field. +func (u *VersionUpsertBulk) SetVersionMajor(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetVersionMajor(v) + }) +} + +// AddVersionMajor adds v to the "version_major" field. +func (u *VersionUpsertBulk) AddVersionMajor(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddVersionMajor(v) + }) +} + +// UpdateVersionMajor sets the "version_major" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateVersionMajor() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionMajor() + }) +} + +// SetVersionMinor sets the "version_minor" field. +func (u *VersionUpsertBulk) SetVersionMinor(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetVersionMinor(v) + }) +} + +// AddVersionMinor adds v to the "version_minor" field. +func (u *VersionUpsertBulk) AddVersionMinor(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddVersionMinor(v) + }) +} + +// UpdateVersionMinor sets the "version_minor" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateVersionMinor() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionMinor() + }) +} + +// SetVersionPatch sets the "version_patch" field. +func (u *VersionUpsertBulk) SetVersionPatch(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetVersionPatch(v) + }) +} + +// AddVersionPatch adds v to the "version_patch" field. +func (u *VersionUpsertBulk) AddVersionPatch(v int) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddVersionPatch(v) + }) +} + +// UpdateVersionPatch sets the "version_patch" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateVersionPatch() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateVersionPatch() + }) +} + +// SetSize sets the "size" field. +func (u *VersionUpsertBulk) SetSize(v int64) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *VersionUpsertBulk) AddSize(v int64) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateSize() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *VersionUpsertBulk) SetHash(v string) *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionUpsertBulk) UpdateHash() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.UpdateHash() + }) +} + +// Exec executes the query. +func (u *VersionUpsertBulk) 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 VersionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/version_query.go b/generated/ent/version_query.go index ad64a835..fba4fff6 100644 --- a/generated/ent/version_query.go +++ b/generated/ent/version_query.go @@ -15,6 +15,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // VersionQuery is the builder for querying Version entities. @@ -26,8 +27,8 @@ type VersionQuery struct { predicates []predicate.Version withMod *ModQuery withDependencies *ModQuery + withTargets *VersionTargetQuery withVersionDependencies *VersionDependencyQuery - withFKs bool modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -109,6 +110,28 @@ func (vq *VersionQuery) QueryDependencies() *ModQuery { return query } +// QueryTargets chains the current query on the "targets" edge. +func (vq *VersionQuery) QueryTargets() *VersionTargetQuery { + query := (&VersionTargetClient{config: vq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(version.Table, version.FieldID, selector), + sqlgraph.To(versiontarget.Table, versiontarget.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, version.TargetsTable, version.TargetsColumn), + ) + fromU = sqlgraph.SetNeighbors(vq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryVersionDependencies chains the current query on the "version_dependencies" edge. func (vq *VersionQuery) QueryVersionDependencies() *VersionDependencyQuery { query := (&VersionDependencyClient{config: vq.config}).Query() @@ -325,6 +348,7 @@ func (vq *VersionQuery) Clone() *VersionQuery { predicates: append([]predicate.Version{}, vq.predicates...), withMod: vq.withMod.Clone(), withDependencies: vq.withDependencies.Clone(), + withTargets: vq.withTargets.Clone(), withVersionDependencies: vq.withVersionDependencies.Clone(), // clone intermediate query. sql: vq.sql.Clone(), @@ -354,6 +378,17 @@ func (vq *VersionQuery) WithDependencies(opts ...func(*ModQuery)) *VersionQuery return vq } +// 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 (vq *VersionQuery) WithTargets(opts ...func(*VersionTargetQuery)) *VersionQuery { + query := (&VersionTargetClient{config: vq.config}).Query() + for _, opt := range opts { + opt(query) + } + vq.withTargets = query + return vq +} + // WithVersionDependencies tells the query-builder to eager-load the nodes that are connected to // the "version_dependencies" edge. The optional arguments are used to configure the query builder of the edge. func (vq *VersionQuery) WithVersionDependencies(opts ...func(*VersionDependencyQuery)) *VersionQuery { @@ -442,20 +477,14 @@ func (vq *VersionQuery) prepareQuery(ctx context.Context) error { func (vq *VersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Version, error) { var ( nodes = []*Version{} - withFKs = vq.withFKs _spec = vq.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [4]bool{ vq.withMod != nil, vq.withDependencies != nil, + vq.withTargets != nil, vq.withVersionDependencies != nil, } ) - if vq.withMod != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, version.ForeignKeys...) - } _spec.ScanValues = func(columns []string) ([]any, error) { return (*Version).scanValues(nil, columns) } @@ -490,6 +519,13 @@ func (vq *VersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Vers return nil, err } } + if query := vq.withTargets; query != nil { + if err := vq.loadTargets(ctx, query, nodes, + func(n *Version) { n.Edges.Targets = []*VersionTarget{} }, + func(n *Version, e *VersionTarget) { n.Edges.Targets = append(n.Edges.Targets, e) }); err != nil { + return nil, err + } + } if query := vq.withVersionDependencies; query != nil { if err := vq.loadVersionDependencies(ctx, query, nodes, func(n *Version) { n.Edges.VersionDependencies = []*VersionDependency{} }, @@ -506,10 +542,7 @@ func (vq *VersionQuery) loadMod(ctx context.Context, query *ModQuery, nodes []*V ids := make([]string, 0, len(nodes)) nodeids := make(map[string][]*Version) for i := range nodes { - if nodes[i].mod_id == nil { - continue - } - fk := *nodes[i].mod_id + fk := nodes[i].ModID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -595,6 +628,36 @@ func (vq *VersionQuery) loadDependencies(ctx context.Context, query *ModQuery, n } return nil } +func (vq *VersionQuery) loadTargets(ctx context.Context, query *VersionTargetQuery, nodes []*Version, init func(*Version), assign func(*Version, *VersionTarget)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Version) + 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(versiontarget.FieldVersionID) + } + query.Where(predicate.VersionTarget(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(version.TargetsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.VersionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "version_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (vq *VersionQuery) loadVersionDependencies(ctx context.Context, query *VersionDependencyQuery, nodes []*Version, init func(*Version), assign func(*Version, *VersionDependency)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[string]*Version) @@ -654,6 +717,9 @@ func (vq *VersionQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if vq.withMod != nil { + _spec.Node.AddColumnOnce(version.FieldModID) + } } if ps := vq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { diff --git a/generated/ent/version_update.go b/generated/ent/version_update.go index cc6365b9..5349b40e 100644 --- a/generated/ent/version_update.go +++ b/generated/ent/version_update.go @@ -14,6 +14,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/mod" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" ) // VersionUpdate is the builder for updating Version entities. @@ -56,6 +57,12 @@ func (vu *VersionUpdate) ClearDeletedAt() *VersionUpdate { return vu } +// SetModID sets the "mod_id" field. +func (vu *VersionUpdate) SetModID(s string) *VersionUpdate { + vu.mutation.SetModID(s) + return vu +} + // SetVersion sets the "version" field. func (vu *VersionUpdate) SetVersion(s string) *VersionUpdate { vu.mutation.SetVersion(s) @@ -210,12 +217,6 @@ func (vu *VersionUpdate) SetHash(s string) *VersionUpdate { return vu } -// SetModID sets the "mod" edge to the Mod entity by ID. -func (vu *VersionUpdate) SetModID(id string) *VersionUpdate { - vu.mutation.SetModID(id) - return vu -} - // SetMod sets the "mod" edge to the Mod entity. func (vu *VersionUpdate) SetMod(m *Mod) *VersionUpdate { return vu.SetModID(m.ID) @@ -236,6 +237,21 @@ func (vu *VersionUpdate) AddDependencies(m ...*Mod) *VersionUpdate { return vu.AddDependencyIDs(ids...) } +// AddTargetIDs adds the "targets" edge to the VersionTarget entity by IDs. +func (vu *VersionUpdate) AddTargetIDs(ids ...string) *VersionUpdate { + vu.mutation.AddTargetIDs(ids...) + return vu +} + +// AddTargets adds the "targets" edges to the VersionTarget entity. +func (vu *VersionUpdate) AddTargets(v ...*VersionTarget) *VersionUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return vu.AddTargetIDs(ids...) +} + // Mutation returns the VersionMutation object of the builder. func (vu *VersionUpdate) Mutation() *VersionMutation { return vu.mutation @@ -268,6 +284,27 @@ func (vu *VersionUpdate) RemoveDependencies(m ...*Mod) *VersionUpdate { return vu.RemoveDependencyIDs(ids...) } +// ClearTargets clears all "targets" edges to the VersionTarget entity. +func (vu *VersionUpdate) ClearTargets() *VersionUpdate { + vu.mutation.ClearTargets() + return vu +} + +// RemoveTargetIDs removes the "targets" edge to VersionTarget entities by IDs. +func (vu *VersionUpdate) RemoveTargetIDs(ids ...string) *VersionUpdate { + vu.mutation.RemoveTargetIDs(ids...) + return vu +} + +// RemoveTargets removes "targets" edges to VersionTarget entities. +func (vu *VersionUpdate) RemoveTargets(v ...*VersionTarget) *VersionUpdate { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return vu.RemoveTargetIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (vu *VersionUpdate) Save(ctx context.Context) (int, error) { if err := vu.defaults(); err != nil { @@ -522,6 +559,51 @@ func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if vu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !vu.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.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 := vu.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.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(vu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, vu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -570,6 +652,12 @@ func (vuo *VersionUpdateOne) ClearDeletedAt() *VersionUpdateOne { return vuo } +// SetModID sets the "mod_id" field. +func (vuo *VersionUpdateOne) SetModID(s string) *VersionUpdateOne { + vuo.mutation.SetModID(s) + return vuo +} + // SetVersion sets the "version" field. func (vuo *VersionUpdateOne) SetVersion(s string) *VersionUpdateOne { vuo.mutation.SetVersion(s) @@ -724,12 +812,6 @@ func (vuo *VersionUpdateOne) SetHash(s string) *VersionUpdateOne { return vuo } -// SetModID sets the "mod" edge to the Mod entity by ID. -func (vuo *VersionUpdateOne) SetModID(id string) *VersionUpdateOne { - vuo.mutation.SetModID(id) - return vuo -} - // SetMod sets the "mod" edge to the Mod entity. func (vuo *VersionUpdateOne) SetMod(m *Mod) *VersionUpdateOne { return vuo.SetModID(m.ID) @@ -750,6 +832,21 @@ func (vuo *VersionUpdateOne) AddDependencies(m ...*Mod) *VersionUpdateOne { return vuo.AddDependencyIDs(ids...) } +// AddTargetIDs adds the "targets" edge to the VersionTarget entity by IDs. +func (vuo *VersionUpdateOne) AddTargetIDs(ids ...string) *VersionUpdateOne { + vuo.mutation.AddTargetIDs(ids...) + return vuo +} + +// AddTargets adds the "targets" edges to the VersionTarget entity. +func (vuo *VersionUpdateOne) AddTargets(v ...*VersionTarget) *VersionUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return vuo.AddTargetIDs(ids...) +} + // Mutation returns the VersionMutation object of the builder. func (vuo *VersionUpdateOne) Mutation() *VersionMutation { return vuo.mutation @@ -782,6 +879,27 @@ func (vuo *VersionUpdateOne) RemoveDependencies(m ...*Mod) *VersionUpdateOne { return vuo.RemoveDependencyIDs(ids...) } +// ClearTargets clears all "targets" edges to the VersionTarget entity. +func (vuo *VersionUpdateOne) ClearTargets() *VersionUpdateOne { + vuo.mutation.ClearTargets() + return vuo +} + +// RemoveTargetIDs removes the "targets" edge to VersionTarget entities by IDs. +func (vuo *VersionUpdateOne) RemoveTargetIDs(ids ...string) *VersionUpdateOne { + vuo.mutation.RemoveTargetIDs(ids...) + return vuo +} + +// RemoveTargets removes "targets" edges to VersionTarget entities. +func (vuo *VersionUpdateOne) RemoveTargets(v ...*VersionTarget) *VersionUpdateOne { + ids := make([]string, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return vuo.RemoveTargetIDs(ids...) +} + // Where appends a list predicates to the VersionUpdate builder. func (vuo *VersionUpdateOne) Where(ps ...predicate.Version) *VersionUpdateOne { vuo.mutation.Where(ps...) @@ -1066,6 +1184,51 @@ func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err e edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if vuo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.RemovedTargetsIDs(); len(nodes) > 0 && !vuo.mutation.TargetsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.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 := vuo.mutation.TargetsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: version.TargetsTable, + Columns: []string{version.TargetsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(versiontarget.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(vuo.modifiers...) _node = &Version{config: vuo.config} _spec.Assign = _node.assignValues diff --git a/generated/ent/versiondependency_create.go b/generated/ent/versiondependency_create.go index 849c7657..a39aa987 100644 --- a/generated/ent/versiondependency_create.go +++ b/generated/ent/versiondependency_create.go @@ -8,6 +8,7 @@ import ( "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" @@ -20,6 +21,7 @@ type VersionDependencyCreate struct { config mutation *VersionDependencyMutation hooks []Hook + conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. @@ -205,6 +207,7 @@ func (vdc *VersionDependencyCreate) createSpec() (*VersionDependency, *sqlgraph. _node = &VersionDependency{config: vdc.config} _spec = sqlgraph.NewCreateSpec(versiondependency.Table, nil) ) + _spec.OnConflict = vdc.conflict if value, ok := vdc.mutation.CreatedAt(); ok { _spec.SetField(versiondependency.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value @@ -262,11 +265,290 @@ func (vdc *VersionDependencyCreate) createSpec() (*VersionDependency, *sqlgraph. return _node, _spec } +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.VersionDependency.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.VersionDependencyUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (vdc *VersionDependencyCreate) OnConflict(opts ...sql.ConflictOption) *VersionDependencyUpsertOne { + vdc.conflict = opts + return &VersionDependencyUpsertOne{ + create: vdc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vdc *VersionDependencyCreate) OnConflictColumns(columns ...string) *VersionDependencyUpsertOne { + vdc.conflict = append(vdc.conflict, sql.ConflictColumns(columns...)) + return &VersionDependencyUpsertOne{ + create: vdc, + } +} + +type ( + // VersionDependencyUpsertOne is the builder for "upsert"-ing + // one VersionDependency node. + VersionDependencyUpsertOne struct { + create *VersionDependencyCreate + } + + // VersionDependencyUpsert is the "OnConflict" setter. + VersionDependencyUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionDependencyUpsert) SetUpdatedAt(v time.Time) *VersionDependencyUpsert { + u.Set(versiondependency.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateUpdatedAt() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionDependencyUpsert) SetDeletedAt(v time.Time) *VersionDependencyUpsert { + u.Set(versiondependency.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateDeletedAt() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionDependencyUpsert) ClearDeletedAt() *VersionDependencyUpsert { + u.SetNull(versiondependency.FieldDeletedAt) + return u +} + +// SetVersionID sets the "version_id" field. +func (u *VersionDependencyUpsert) SetVersionID(v string) *VersionDependencyUpsert { + u.Set(versiondependency.FieldVersionID, v) + return u +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateVersionID() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldVersionID) + return u +} + +// SetModID sets the "mod_id" field. +func (u *VersionDependencyUpsert) SetModID(v string) *VersionDependencyUpsert { + u.Set(versiondependency.FieldModID, v) + return u +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateModID() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldModID) + return u +} + +// SetCondition sets the "condition" field. +func (u *VersionDependencyUpsert) SetCondition(v string) *VersionDependencyUpsert { + u.Set(versiondependency.FieldCondition, v) + return u +} + +// UpdateCondition sets the "condition" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateCondition() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldCondition) + return u +} + +// SetOptional sets the "optional" field. +func (u *VersionDependencyUpsert) SetOptional(v bool) *VersionDependencyUpsert { + u.Set(versiondependency.FieldOptional, v) + return u +} + +// UpdateOptional sets the "optional" field to the value that was provided on create. +func (u *VersionDependencyUpsert) UpdateOptional() *VersionDependencyUpsert { + u.SetExcluded(versiondependency.FieldOptional) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *VersionDependencyUpsertOne) UpdateNewValues() *VersionDependencyUpsertOne { + 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.CreatedAt(); exists { + s.SetIgnore(versiondependency.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionDependencyUpsertOne) Ignore() *VersionDependencyUpsertOne { + 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 *VersionDependencyUpsertOne) DoNothing() *VersionDependencyUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionDependencyCreate.OnConflict +// documentation for more info. +func (u *VersionDependencyUpsertOne) Update(set func(*VersionDependencyUpsert)) *VersionDependencyUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionDependencyUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionDependencyUpsertOne) SetUpdatedAt(v time.Time) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateUpdatedAt() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionDependencyUpsertOne) SetDeletedAt(v time.Time) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateDeletedAt() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionDependencyUpsertOne) ClearDeletedAt() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.ClearDeletedAt() + }) +} + +// SetVersionID sets the "version_id" field. +func (u *VersionDependencyUpsertOne) SetVersionID(v string) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateVersionID() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateVersionID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *VersionDependencyUpsertOne) SetModID(v string) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateModID() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateModID() + }) +} + +// SetCondition sets the "condition" field. +func (u *VersionDependencyUpsertOne) SetCondition(v string) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetCondition(v) + }) +} + +// UpdateCondition sets the "condition" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateCondition() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateCondition() + }) +} + +// SetOptional sets the "optional" field. +func (u *VersionDependencyUpsertOne) SetOptional(v bool) *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetOptional(v) + }) +} + +// UpdateOptional sets the "optional" field to the value that was provided on create. +func (u *VersionDependencyUpsertOne) UpdateOptional() *VersionDependencyUpsertOne { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateOptional() + }) +} + +// Exec executes the query. +func (u *VersionDependencyUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionDependencyCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionDependencyUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + // VersionDependencyCreateBulk is the builder for creating many VersionDependency entities in bulk. type VersionDependencyCreateBulk struct { config err error builders []*VersionDependencyCreate + conflict []sql.ConflictOption } // Save creates the VersionDependency entities in the database. @@ -296,6 +578,7 @@ func (vdcb *VersionDependencyCreateBulk) Save(ctx context.Context) ([]*VersionDe _, err = mutators[i+1].Mutate(root, vdcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = vdcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, vdcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -344,3 +627,205 @@ func (vdcb *VersionDependencyCreateBulk) ExecX(ctx context.Context) { panic(err) } } + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.VersionDependency.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.VersionDependencyUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (vdcb *VersionDependencyCreateBulk) OnConflict(opts ...sql.ConflictOption) *VersionDependencyUpsertBulk { + vdcb.conflict = opts + return &VersionDependencyUpsertBulk{ + create: vdcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vdcb *VersionDependencyCreateBulk) OnConflictColumns(columns ...string) *VersionDependencyUpsertBulk { + vdcb.conflict = append(vdcb.conflict, sql.ConflictColumns(columns...)) + return &VersionDependencyUpsertBulk{ + create: vdcb, + } +} + +// VersionDependencyUpsertBulk is the builder for "upsert"-ing +// a bulk of VersionDependency nodes. +type VersionDependencyUpsertBulk struct { + create *VersionDependencyCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *VersionDependencyUpsertBulk) UpdateNewValues() *VersionDependencyUpsertBulk { + 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.CreatedAt(); exists { + s.SetIgnore(versiondependency.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.VersionDependency.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionDependencyUpsertBulk) Ignore() *VersionDependencyUpsertBulk { + 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 *VersionDependencyUpsertBulk) DoNothing() *VersionDependencyUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionDependencyCreateBulk.OnConflict +// documentation for more info. +func (u *VersionDependencyUpsertBulk) Update(set func(*VersionDependencyUpsert)) *VersionDependencyUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionDependencyUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *VersionDependencyUpsertBulk) SetUpdatedAt(v time.Time) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateUpdatedAt() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *VersionDependencyUpsertBulk) SetDeletedAt(v time.Time) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateDeletedAt() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *VersionDependencyUpsertBulk) ClearDeletedAt() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.ClearDeletedAt() + }) +} + +// SetVersionID sets the "version_id" field. +func (u *VersionDependencyUpsertBulk) SetVersionID(v string) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateVersionID() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateVersionID() + }) +} + +// SetModID sets the "mod_id" field. +func (u *VersionDependencyUpsertBulk) SetModID(v string) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetModID(v) + }) +} + +// UpdateModID sets the "mod_id" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateModID() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateModID() + }) +} + +// SetCondition sets the "condition" field. +func (u *VersionDependencyUpsertBulk) SetCondition(v string) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetCondition(v) + }) +} + +// UpdateCondition sets the "condition" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateCondition() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateCondition() + }) +} + +// SetOptional sets the "optional" field. +func (u *VersionDependencyUpsertBulk) SetOptional(v bool) *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.SetOptional(v) + }) +} + +// UpdateOptional sets the "optional" field to the value that was provided on create. +func (u *VersionDependencyUpsertBulk) UpdateOptional() *VersionDependencyUpsertBulk { + return u.Update(func(s *VersionDependencyUpsert) { + s.UpdateOptional() + }) +} + +// Exec executes the query. +func (u *VersionDependencyUpsertBulk) 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 VersionDependencyCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionDependencyCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionDependencyUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/versiontarget.go b/generated/ent/versiontarget.go new file mode 100644 index 00000000..6d87097b --- /dev/null +++ b/generated/ent/versiontarget.go @@ -0,0 +1,178 @@ +// 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/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" +) + +// VersionTarget is the model entity for the VersionTarget schema. +type VersionTarget struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // VersionID holds the value of the "version_id" field. + VersionID string `json:"version_id,omitempty"` + // TargetName holds the value of the "target_name" field. + TargetName string `json:"target_name,omitempty"` + // Key holds the value of the "key" field. + Key string `json:"key,omitempty"` + // Hash holds the value of the "hash" field. + Hash string `json:"hash,omitempty"` + // Size holds the value of the "size" field. + Size int64 `json:"size,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the VersionTargetQuery when eager-loading is set. + Edges VersionTargetEdges `json:"edges"` + selectValues sql.SelectValues +} + +// VersionTargetEdges holds the relations/edges for other nodes in the graph. +type VersionTargetEdges struct { + // SmlVersion holds the value of the sml_version edge. + SmlVersion *Version `json:"sml_version,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// SmlVersionOrErr returns the SmlVersion value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e VersionTargetEdges) SmlVersionOrErr() (*Version, error) { + if e.loadedTypes[0] { + if e.SmlVersion == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: version.Label} + } + return e.SmlVersion, nil + } + return nil, &NotLoadedError{edge: "sml_version"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*VersionTarget) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case versiontarget.FieldSize: + values[i] = new(sql.NullInt64) + case versiontarget.FieldID, versiontarget.FieldVersionID, versiontarget.FieldTargetName, versiontarget.FieldKey, versiontarget.FieldHash: + 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 VersionTarget fields. +func (vt *VersionTarget) 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 versiontarget.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + vt.ID = value.String + } + case versiontarget.FieldVersionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version_id", values[i]) + } else if value.Valid { + vt.VersionID = value.String + } + case versiontarget.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 { + vt.TargetName = value.String + } + case versiontarget.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + vt.Key = value.String + } + case versiontarget.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + vt.Hash = value.String + } + case versiontarget.FieldSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + vt.Size = value.Int64 + } + default: + vt.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the VersionTarget. +// This includes values selected through modifiers, order, etc. +func (vt *VersionTarget) Value(name string) (ent.Value, error) { + return vt.selectValues.Get(name) +} + +// QuerySmlVersion queries the "sml_version" edge of the VersionTarget entity. +func (vt *VersionTarget) QuerySmlVersion() *VersionQuery { + return NewVersionTargetClient(vt.config).QuerySmlVersion(vt) +} + +// Update returns a builder for updating this VersionTarget. +// Note that you need to call VersionTarget.Unwrap() before calling this method if this VersionTarget +// was returned from a transaction, and the transaction was committed or rolled back. +func (vt *VersionTarget) Update() *VersionTargetUpdateOne { + return NewVersionTargetClient(vt.config).UpdateOne(vt) +} + +// Unwrap unwraps the VersionTarget 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 (vt *VersionTarget) Unwrap() *VersionTarget { + _tx, ok := vt.config.driver.(*txDriver) + if !ok { + panic("ent: VersionTarget is not a transactional entity") + } + vt.config.driver = _tx.drv + return vt +} + +// String implements the fmt.Stringer. +func (vt *VersionTarget) String() string { + var builder strings.Builder + builder.WriteString("VersionTarget(") + builder.WriteString(fmt.Sprintf("id=%v, ", vt.ID)) + builder.WriteString("version_id=") + builder.WriteString(vt.VersionID) + builder.WriteString(", ") + builder.WriteString("target_name=") + builder.WriteString(vt.TargetName) + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(vt.Key) + builder.WriteString(", ") + builder.WriteString("hash=") + builder.WriteString(vt.Hash) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(fmt.Sprintf("%v", vt.Size)) + builder.WriteByte(')') + return builder.String() +} + +// VersionTargets is a parsable slice of VersionTarget. +type VersionTargets []*VersionTarget diff --git a/generated/ent/versiontarget/versiontarget.go b/generated/ent/versiontarget/versiontarget.go new file mode 100644 index 00000000..1685af0f --- /dev/null +++ b/generated/ent/versiontarget/versiontarget.go @@ -0,0 +1,108 @@ +// Code generated by ent, DO NOT EDIT. + +package versiontarget + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the versiontarget type in the database. + Label = "version_target" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldVersionID holds the string denoting the version_id field in the database. + FieldVersionID = "version_id" + // FieldTargetName holds the string denoting the target_name field in the database. + FieldTargetName = "target_name" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // EdgeSmlVersion holds the string denoting the sml_version edge name in mutations. + EdgeSmlVersion = "sml_version" + // Table holds the table name of the versiontarget in the database. + Table = "version_targets" + // SmlVersionTable is the table that holds the sml_version relation/edge. + SmlVersionTable = "version_targets" + // SmlVersionInverseTable is the table name for the Version entity. + // It exists in this package in order to avoid circular dependency with the "version" package. + SmlVersionInverseTable = "versions" + // SmlVersionColumn is the table column denoting the sml_version relation/edge. + SmlVersionColumn = "version_id" +) + +// Columns holds all SQL columns for versiontarget fields. +var Columns = []string{ + FieldID, + FieldVersionID, + FieldTargetName, + FieldKey, + FieldHash, + FieldSize, +} + +// 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 VersionTarget 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() +} + +// ByVersionID orders the results by the version_id field. +func ByVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionID, opts...).ToFunc() +} + +// ByTargetName orders the results by the target_name field. +func ByTargetName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTargetName, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// BySmlVersionField orders the results by sml_version field. +func BySmlVersionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSmlVersionStep(), sql.OrderByField(field, opts...)) + } +} +func newSmlVersionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SmlVersionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SmlVersionTable, SmlVersionColumn), + ) +} diff --git a/generated/ent/versiontarget/where.go b/generated/ent/versiontarget/where.go new file mode 100644 index 00000000..11cb20b5 --- /dev/null +++ b/generated/ent/versiontarget/where.go @@ -0,0 +1,427 @@ +// Code generated by ent, DO NOT EDIT. + +package versiontarget + +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.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContainsFold(FieldID, id)) +} + +// VersionID applies equality check predicate on the "version_id" field. It's identical to VersionIDEQ. +func VersionID(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldVersionID, v)) +} + +// TargetName applies equality check predicate on the "target_name" field. It's identical to TargetNameEQ. +func TargetName(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldKey, v)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldHash, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldSize, v)) +} + +// VersionIDEQ applies the EQ predicate on the "version_id" field. +func VersionIDEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldVersionID, v)) +} + +// VersionIDNEQ applies the NEQ predicate on the "version_id" field. +func VersionIDNEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldVersionID, v)) +} + +// VersionIDIn applies the In predicate on the "version_id" field. +func VersionIDIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldVersionID, vs...)) +} + +// VersionIDNotIn applies the NotIn predicate on the "version_id" field. +func VersionIDNotIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldVersionID, vs...)) +} + +// VersionIDGT applies the GT predicate on the "version_id" field. +func VersionIDGT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldVersionID, v)) +} + +// VersionIDGTE applies the GTE predicate on the "version_id" field. +func VersionIDGTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldVersionID, v)) +} + +// VersionIDLT applies the LT predicate on the "version_id" field. +func VersionIDLT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldVersionID, v)) +} + +// VersionIDLTE applies the LTE predicate on the "version_id" field. +func VersionIDLTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldVersionID, v)) +} + +// VersionIDContains applies the Contains predicate on the "version_id" field. +func VersionIDContains(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContains(FieldVersionID, v)) +} + +// VersionIDHasPrefix applies the HasPrefix predicate on the "version_id" field. +func VersionIDHasPrefix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasPrefix(FieldVersionID, v)) +} + +// VersionIDHasSuffix applies the HasSuffix predicate on the "version_id" field. +func VersionIDHasSuffix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasSuffix(FieldVersionID, v)) +} + +// VersionIDEqualFold applies the EqualFold predicate on the "version_id" field. +func VersionIDEqualFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEqualFold(FieldVersionID, v)) +} + +// VersionIDContainsFold applies the ContainsFold predicate on the "version_id" field. +func VersionIDContainsFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContainsFold(FieldVersionID, v)) +} + +// TargetNameEQ applies the EQ predicate on the "target_name" field. +func TargetNameEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldTargetName, v)) +} + +// TargetNameNEQ applies the NEQ predicate on the "target_name" field. +func TargetNameNEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldTargetName, v)) +} + +// TargetNameIn applies the In predicate on the "target_name" field. +func TargetNameIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldTargetName, vs...)) +} + +// TargetNameNotIn applies the NotIn predicate on the "target_name" field. +func TargetNameNotIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldTargetName, vs...)) +} + +// TargetNameGT applies the GT predicate on the "target_name" field. +func TargetNameGT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldTargetName, v)) +} + +// TargetNameGTE applies the GTE predicate on the "target_name" field. +func TargetNameGTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldTargetName, v)) +} + +// TargetNameLT applies the LT predicate on the "target_name" field. +func TargetNameLT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldTargetName, v)) +} + +// TargetNameLTE applies the LTE predicate on the "target_name" field. +func TargetNameLTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldTargetName, v)) +} + +// TargetNameContains applies the Contains predicate on the "target_name" field. +func TargetNameContains(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContains(FieldTargetName, v)) +} + +// TargetNameHasPrefix applies the HasPrefix predicate on the "target_name" field. +func TargetNameHasPrefix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasPrefix(FieldTargetName, v)) +} + +// TargetNameHasSuffix applies the HasSuffix predicate on the "target_name" field. +func TargetNameHasSuffix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasSuffix(FieldTargetName, v)) +} + +// TargetNameEqualFold applies the EqualFold predicate on the "target_name" field. +func TargetNameEqualFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEqualFold(FieldTargetName, v)) +} + +// TargetNameContainsFold applies the ContainsFold predicate on the "target_name" field. +func TargetNameContainsFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContainsFold(FieldTargetName, v)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContainsFold(FieldKey, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldContainsFold(FieldHash, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v int64) predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldLTE(FieldSize, v)) +} + +// HasSmlVersion applies the HasEdge predicate on the "sml_version" edge. +func HasSmlVersion() predicate.VersionTarget { + return predicate.VersionTarget(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SmlVersionTable, SmlVersionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSmlVersionWith applies the HasEdge predicate on the "sml_version" edge with a given conditions (other predicates). +func HasSmlVersionWith(preds ...predicate.Version) predicate.VersionTarget { + return predicate.VersionTarget(func(s *sql.Selector) { + step := newSmlVersionStep() + 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.VersionTarget) predicate.VersionTarget { + return predicate.VersionTarget(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.VersionTarget) predicate.VersionTarget { + return predicate.VersionTarget(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.VersionTarget) predicate.VersionTarget { + return predicate.VersionTarget(sql.NotPredicates(p)) +} diff --git a/generated/ent/versiontarget_create.go b/generated/ent/versiontarget_create.go new file mode 100644 index 00000000..8ad3c6ee --- /dev/null +++ b/generated/ent/versiontarget_create.go @@ -0,0 +1,767 @@ +// 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/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" +) + +// VersionTargetCreate is the builder for creating a VersionTarget entity. +type VersionTargetCreate struct { + config + mutation *VersionTargetMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetVersionID sets the "version_id" field. +func (vtc *VersionTargetCreate) SetVersionID(s string) *VersionTargetCreate { + vtc.mutation.SetVersionID(s) + return vtc +} + +// SetTargetName sets the "target_name" field. +func (vtc *VersionTargetCreate) SetTargetName(s string) *VersionTargetCreate { + vtc.mutation.SetTargetName(s) + return vtc +} + +// SetKey sets the "key" field. +func (vtc *VersionTargetCreate) SetKey(s string) *VersionTargetCreate { + vtc.mutation.SetKey(s) + return vtc +} + +// SetHash sets the "hash" field. +func (vtc *VersionTargetCreate) SetHash(s string) *VersionTargetCreate { + vtc.mutation.SetHash(s) + return vtc +} + +// SetSize sets the "size" field. +func (vtc *VersionTargetCreate) SetSize(i int64) *VersionTargetCreate { + vtc.mutation.SetSize(i) + return vtc +} + +// SetID sets the "id" field. +func (vtc *VersionTargetCreate) SetID(s string) *VersionTargetCreate { + vtc.mutation.SetID(s) + return vtc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (vtc *VersionTargetCreate) SetNillableID(s *string) *VersionTargetCreate { + if s != nil { + vtc.SetID(*s) + } + return vtc +} + +// SetSmlVersionID sets the "sml_version" edge to the Version entity by ID. +func (vtc *VersionTargetCreate) SetSmlVersionID(id string) *VersionTargetCreate { + vtc.mutation.SetSmlVersionID(id) + return vtc +} + +// SetSmlVersion sets the "sml_version" edge to the Version entity. +func (vtc *VersionTargetCreate) SetSmlVersion(v *Version) *VersionTargetCreate { + return vtc.SetSmlVersionID(v.ID) +} + +// Mutation returns the VersionTargetMutation object of the builder. +func (vtc *VersionTargetCreate) Mutation() *VersionTargetMutation { + return vtc.mutation +} + +// Save creates the VersionTarget in the database. +func (vtc *VersionTargetCreate) Save(ctx context.Context) (*VersionTarget, error) { + vtc.defaults() + return withHooks(ctx, vtc.sqlSave, vtc.mutation, vtc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (vtc *VersionTargetCreate) SaveX(ctx context.Context) *VersionTarget { + v, err := vtc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vtc *VersionTargetCreate) Exec(ctx context.Context) error { + _, err := vtc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtc *VersionTargetCreate) ExecX(ctx context.Context) { + if err := vtc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (vtc *VersionTargetCreate) defaults() { + if _, ok := vtc.mutation.ID(); !ok { + v := versiontarget.DefaultID() + vtc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vtc *VersionTargetCreate) check() error { + if _, ok := vtc.mutation.VersionID(); !ok { + return &ValidationError{Name: "version_id", err: errors.New(`ent: missing required field "VersionTarget.version_id"`)} + } + if _, ok := vtc.mutation.TargetName(); !ok { + return &ValidationError{Name: "target_name", err: errors.New(`ent: missing required field "VersionTarget.target_name"`)} + } + if _, ok := vtc.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "VersionTarget.key"`)} + } + if _, ok := vtc.mutation.Hash(); !ok { + return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "VersionTarget.hash"`)} + } + if _, ok := vtc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "VersionTarget.size"`)} + } + if _, ok := vtc.mutation.SmlVersionID(); !ok { + return &ValidationError{Name: "sml_version", err: errors.New(`ent: missing required edge "VersionTarget.sml_version"`)} + } + return nil +} + +func (vtc *VersionTargetCreate) sqlSave(ctx context.Context) (*VersionTarget, error) { + if err := vtc.check(); err != nil { + return nil, err + } + _node, _spec := vtc.createSpec() + if err := sqlgraph.CreateNode(ctx, vtc.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 VersionTarget.ID type: %T", _spec.ID.Value) + } + } + vtc.mutation.id = &_node.ID + vtc.mutation.done = true + return _node, nil +} + +func (vtc *VersionTargetCreate) createSpec() (*VersionTarget, *sqlgraph.CreateSpec) { + var ( + _node = &VersionTarget{config: vtc.config} + _spec = sqlgraph.NewCreateSpec(versiontarget.Table, sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString)) + ) + _spec.OnConflict = vtc.conflict + if id, ok := vtc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := vtc.mutation.TargetName(); ok { + _spec.SetField(versiontarget.FieldTargetName, field.TypeString, value) + _node.TargetName = value + } + if value, ok := vtc.mutation.Key(); ok { + _spec.SetField(versiontarget.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := vtc.mutation.Hash(); ok { + _spec.SetField(versiontarget.FieldHash, field.TypeString, value) + _node.Hash = value + } + if value, ok := vtc.mutation.Size(); ok { + _spec.SetField(versiontarget.FieldSize, field.TypeInt64, value) + _node.Size = value + } + if nodes := vtc.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: versiontarget.SmlVersionTable, + Columns: []string{versiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.VersionID = 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.VersionTarget.Create(). +// SetVersionID(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.VersionTargetUpsert) { +// SetVersionID(v+v). +// }). +// Exec(ctx) +func (vtc *VersionTargetCreate) OnConflict(opts ...sql.ConflictOption) *VersionTargetUpsertOne { + vtc.conflict = opts + return &VersionTargetUpsertOne{ + create: vtc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.VersionTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vtc *VersionTargetCreate) OnConflictColumns(columns ...string) *VersionTargetUpsertOne { + vtc.conflict = append(vtc.conflict, sql.ConflictColumns(columns...)) + return &VersionTargetUpsertOne{ + create: vtc, + } +} + +type ( + // VersionTargetUpsertOne is the builder for "upsert"-ing + // one VersionTarget node. + VersionTargetUpsertOne struct { + create *VersionTargetCreate + } + + // VersionTargetUpsert is the "OnConflict" setter. + VersionTargetUpsert struct { + *sql.UpdateSet + } +) + +// SetVersionID sets the "version_id" field. +func (u *VersionTargetUpsert) SetVersionID(v string) *VersionTargetUpsert { + u.Set(versiontarget.FieldVersionID, v) + return u +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionTargetUpsert) UpdateVersionID() *VersionTargetUpsert { + u.SetExcluded(versiontarget.FieldVersionID) + return u +} + +// SetTargetName sets the "target_name" field. +func (u *VersionTargetUpsert) SetTargetName(v string) *VersionTargetUpsert { + u.Set(versiontarget.FieldTargetName, v) + return u +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *VersionTargetUpsert) UpdateTargetName() *VersionTargetUpsert { + u.SetExcluded(versiontarget.FieldTargetName) + return u +} + +// SetKey sets the "key" field. +func (u *VersionTargetUpsert) SetKey(v string) *VersionTargetUpsert { + u.Set(versiontarget.FieldKey, v) + return u +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionTargetUpsert) UpdateKey() *VersionTargetUpsert { + u.SetExcluded(versiontarget.FieldKey) + return u +} + +// SetHash sets the "hash" field. +func (u *VersionTargetUpsert) SetHash(v string) *VersionTargetUpsert { + u.Set(versiontarget.FieldHash, v) + return u +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionTargetUpsert) UpdateHash() *VersionTargetUpsert { + u.SetExcluded(versiontarget.FieldHash) + return u +} + +// SetSize sets the "size" field. +func (u *VersionTargetUpsert) SetSize(v int64) *VersionTargetUpsert { + u.Set(versiontarget.FieldSize, v) + return u +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionTargetUpsert) UpdateSize() *VersionTargetUpsert { + u.SetExcluded(versiontarget.FieldSize) + return u +} + +// AddSize adds v to the "size" field. +func (u *VersionTargetUpsert) AddSize(v int64) *VersionTargetUpsert { + u.Add(versiontarget.FieldSize, v) + 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.VersionTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(versiontarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *VersionTargetUpsertOne) UpdateNewValues() *VersionTargetUpsertOne { + 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(versiontarget.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.VersionTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionTargetUpsertOne) Ignore() *VersionTargetUpsertOne { + 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 *VersionTargetUpsertOne) DoNothing() *VersionTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionTargetCreate.OnConflict +// documentation for more info. +func (u *VersionTargetUpsertOne) Update(set func(*VersionTargetUpsert)) *VersionTargetUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetVersionID sets the "version_id" field. +func (u *VersionTargetUpsertOne) SetVersionID(v string) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionTargetUpsertOne) UpdateVersionID() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateVersionID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *VersionTargetUpsertOne) SetTargetName(v string) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *VersionTargetUpsertOne) UpdateTargetName() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateTargetName() + }) +} + +// SetKey sets the "key" field. +func (u *VersionTargetUpsertOne) SetKey(v string) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.SetKey(v) + }) +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionTargetUpsertOne) UpdateKey() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateKey() + }) +} + +// SetHash sets the "hash" field. +func (u *VersionTargetUpsertOne) SetHash(v string) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionTargetUpsertOne) UpdateHash() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateHash() + }) +} + +// SetSize sets the "size" field. +func (u *VersionTargetUpsertOne) SetSize(v int64) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *VersionTargetUpsertOne) AddSize(v int64) *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionTargetUpsertOne) UpdateSize() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateSize() + }) +} + +// Exec executes the query. +func (u *VersionTargetUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionTargetCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionTargetUpsertOne) 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 *VersionTargetUpsertOne) 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: VersionTargetUpsertOne.ID is not supported by MySQL driver. Use VersionTargetUpsertOne.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 *VersionTargetUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// VersionTargetCreateBulk is the builder for creating many VersionTarget entities in bulk. +type VersionTargetCreateBulk struct { + config + err error + builders []*VersionTargetCreate + conflict []sql.ConflictOption +} + +// Save creates the VersionTarget entities in the database. +func (vtcb *VersionTargetCreateBulk) Save(ctx context.Context) ([]*VersionTarget, error) { + if vtcb.err != nil { + return nil, vtcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(vtcb.builders)) + nodes := make([]*VersionTarget, len(vtcb.builders)) + mutators := make([]Mutator, len(vtcb.builders)) + for i := range vtcb.builders { + func(i int, root context.Context) { + builder := vtcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*VersionTargetMutation) + 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, vtcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = vtcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, vtcb.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, vtcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (vtcb *VersionTargetCreateBulk) SaveX(ctx context.Context) []*VersionTarget { + v, err := vtcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vtcb *VersionTargetCreateBulk) Exec(ctx context.Context) error { + _, err := vtcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtcb *VersionTargetCreateBulk) ExecX(ctx context.Context) { + if err := vtcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.VersionTarget.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.VersionTargetUpsert) { +// SetVersionID(v+v). +// }). +// Exec(ctx) +func (vtcb *VersionTargetCreateBulk) OnConflict(opts ...sql.ConflictOption) *VersionTargetUpsertBulk { + vtcb.conflict = opts + return &VersionTargetUpsertBulk{ + create: vtcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.VersionTarget.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (vtcb *VersionTargetCreateBulk) OnConflictColumns(columns ...string) *VersionTargetUpsertBulk { + vtcb.conflict = append(vtcb.conflict, sql.ConflictColumns(columns...)) + return &VersionTargetUpsertBulk{ + create: vtcb, + } +} + +// VersionTargetUpsertBulk is the builder for "upsert"-ing +// a bulk of VersionTarget nodes. +type VersionTargetUpsertBulk struct { + create *VersionTargetCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.VersionTarget.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(versiontarget.FieldID) +// }), +// ). +// Exec(ctx) +func (u *VersionTargetUpsertBulk) UpdateNewValues() *VersionTargetUpsertBulk { + 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(versiontarget.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.VersionTarget.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *VersionTargetUpsertBulk) Ignore() *VersionTargetUpsertBulk { + 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 *VersionTargetUpsertBulk) DoNothing() *VersionTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the VersionTargetCreateBulk.OnConflict +// documentation for more info. +func (u *VersionTargetUpsertBulk) Update(set func(*VersionTargetUpsert)) *VersionTargetUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&VersionTargetUpsert{UpdateSet: update}) + })) + return u +} + +// SetVersionID sets the "version_id" field. +func (u *VersionTargetUpsertBulk) SetVersionID(v string) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.SetVersionID(v) + }) +} + +// UpdateVersionID sets the "version_id" field to the value that was provided on create. +func (u *VersionTargetUpsertBulk) UpdateVersionID() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateVersionID() + }) +} + +// SetTargetName sets the "target_name" field. +func (u *VersionTargetUpsertBulk) SetTargetName(v string) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.SetTargetName(v) + }) +} + +// UpdateTargetName sets the "target_name" field to the value that was provided on create. +func (u *VersionTargetUpsertBulk) UpdateTargetName() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateTargetName() + }) +} + +// SetKey sets the "key" field. +func (u *VersionTargetUpsertBulk) SetKey(v string) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.SetKey(v) + }) +} + +// UpdateKey sets the "key" field to the value that was provided on create. +func (u *VersionTargetUpsertBulk) UpdateKey() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateKey() + }) +} + +// SetHash sets the "hash" field. +func (u *VersionTargetUpsertBulk) SetHash(v string) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *VersionTargetUpsertBulk) UpdateHash() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateHash() + }) +} + +// SetSize sets the "size" field. +func (u *VersionTargetUpsertBulk) SetSize(v int64) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *VersionTargetUpsertBulk) AddSize(v int64) *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *VersionTargetUpsertBulk) UpdateSize() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.UpdateSize() + }) +} + +// Exec executes the query. +func (u *VersionTargetUpsertBulk) 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 VersionTargetCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for VersionTargetCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *VersionTargetUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/versiontarget_delete.go b/generated/ent/versiontarget_delete.go new file mode 100644 index 00000000..ab7a01b3 --- /dev/null +++ b/generated/ent/versiontarget_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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" +) + +// VersionTargetDelete is the builder for deleting a VersionTarget entity. +type VersionTargetDelete struct { + config + hooks []Hook + mutation *VersionTargetMutation +} + +// Where appends a list predicates to the VersionTargetDelete builder. +func (vtd *VersionTargetDelete) Where(ps ...predicate.VersionTarget) *VersionTargetDelete { + vtd.mutation.Where(ps...) + return vtd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (vtd *VersionTargetDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, vtd.sqlExec, vtd.mutation, vtd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtd *VersionTargetDelete) ExecX(ctx context.Context) int { + n, err := vtd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (vtd *VersionTargetDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(versiontarget.Table, sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString)) + if ps := vtd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, vtd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + vtd.mutation.done = true + return affected, err +} + +// VersionTargetDeleteOne is the builder for deleting a single VersionTarget entity. +type VersionTargetDeleteOne struct { + vtd *VersionTargetDelete +} + +// Where appends a list predicates to the VersionTargetDelete builder. +func (vtdo *VersionTargetDeleteOne) Where(ps ...predicate.VersionTarget) *VersionTargetDeleteOne { + vtdo.vtd.mutation.Where(ps...) + return vtdo +} + +// Exec executes the deletion query. +func (vtdo *VersionTargetDeleteOne) Exec(ctx context.Context) error { + n, err := vtdo.vtd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{versiontarget.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtdo *VersionTargetDeleteOne) ExecX(ctx context.Context) { + if err := vtdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/generated/ent/versiontarget_query.go b/generated/ent/versiontarget_query.go new file mode 100644 index 00000000..1087821a --- /dev/null +++ b/generated/ent/versiontarget_query.go @@ -0,0 +1,627 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" +) + +// VersionTargetQuery is the builder for querying VersionTarget entities. +type VersionTargetQuery struct { + config + ctx *QueryContext + order []versiontarget.OrderOption + inters []Interceptor + predicates []predicate.VersionTarget + withSmlVersion *VersionQuery + 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 VersionTargetQuery builder. +func (vtq *VersionTargetQuery) Where(ps ...predicate.VersionTarget) *VersionTargetQuery { + vtq.predicates = append(vtq.predicates, ps...) + return vtq +} + +// Limit the number of records to be returned by this query. +func (vtq *VersionTargetQuery) Limit(limit int) *VersionTargetQuery { + vtq.ctx.Limit = &limit + return vtq +} + +// Offset to start from. +func (vtq *VersionTargetQuery) Offset(offset int) *VersionTargetQuery { + vtq.ctx.Offset = &offset + return vtq +} + +// 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 (vtq *VersionTargetQuery) Unique(unique bool) *VersionTargetQuery { + vtq.ctx.Unique = &unique + return vtq +} + +// Order specifies how the records should be ordered. +func (vtq *VersionTargetQuery) Order(o ...versiontarget.OrderOption) *VersionTargetQuery { + vtq.order = append(vtq.order, o...) + return vtq +} + +// QuerySmlVersion chains the current query on the "sml_version" edge. +func (vtq *VersionTargetQuery) QuerySmlVersion() *VersionQuery { + query := (&VersionClient{config: vtq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vtq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vtq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(versiontarget.Table, versiontarget.FieldID, selector), + sqlgraph.To(version.Table, version.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, versiontarget.SmlVersionTable, versiontarget.SmlVersionColumn), + ) + fromU = sqlgraph.SetNeighbors(vtq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first VersionTarget entity from the query. +// Returns a *NotFoundError when no VersionTarget was found. +func (vtq *VersionTargetQuery) First(ctx context.Context) (*VersionTarget, error) { + nodes, err := vtq.Limit(1).All(setContextOp(ctx, vtq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{versiontarget.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (vtq *VersionTargetQuery) FirstX(ctx context.Context) *VersionTarget { + node, err := vtq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first VersionTarget ID from the query. +// Returns a *NotFoundError when no VersionTarget ID was found. +func (vtq *VersionTargetQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = vtq.Limit(1).IDs(setContextOp(ctx, vtq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{versiontarget.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (vtq *VersionTargetQuery) FirstIDX(ctx context.Context) string { + id, err := vtq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single VersionTarget entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one VersionTarget entity is found. +// Returns a *NotFoundError when no VersionTarget entities are found. +func (vtq *VersionTargetQuery) Only(ctx context.Context) (*VersionTarget, error) { + nodes, err := vtq.Limit(2).All(setContextOp(ctx, vtq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{versiontarget.Label} + default: + return nil, &NotSingularError{versiontarget.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (vtq *VersionTargetQuery) OnlyX(ctx context.Context) *VersionTarget { + node, err := vtq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only VersionTarget ID in the query. +// Returns a *NotSingularError when more than one VersionTarget ID is found. +// Returns a *NotFoundError when no entities are found. +func (vtq *VersionTargetQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = vtq.Limit(2).IDs(setContextOp(ctx, vtq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{versiontarget.Label} + default: + err = &NotSingularError{versiontarget.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (vtq *VersionTargetQuery) OnlyIDX(ctx context.Context) string { + id, err := vtq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of VersionTargets. +func (vtq *VersionTargetQuery) All(ctx context.Context) ([]*VersionTarget, error) { + ctx = setContextOp(ctx, vtq.ctx, "All") + if err := vtq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*VersionTarget, *VersionTargetQuery]() + return withInterceptors[[]*VersionTarget](ctx, vtq, qr, vtq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (vtq *VersionTargetQuery) AllX(ctx context.Context) []*VersionTarget { + nodes, err := vtq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of VersionTarget IDs. +func (vtq *VersionTargetQuery) IDs(ctx context.Context) (ids []string, err error) { + if vtq.ctx.Unique == nil && vtq.path != nil { + vtq.Unique(true) + } + ctx = setContextOp(ctx, vtq.ctx, "IDs") + if err = vtq.Select(versiontarget.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (vtq *VersionTargetQuery) IDsX(ctx context.Context) []string { + ids, err := vtq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (vtq *VersionTargetQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, vtq.ctx, "Count") + if err := vtq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, vtq, querierCount[*VersionTargetQuery](), vtq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (vtq *VersionTargetQuery) CountX(ctx context.Context) int { + count, err := vtq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (vtq *VersionTargetQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, vtq.ctx, "Exist") + switch _, err := vtq.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 (vtq *VersionTargetQuery) ExistX(ctx context.Context) bool { + exist, err := vtq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the VersionTargetQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (vtq *VersionTargetQuery) Clone() *VersionTargetQuery { + if vtq == nil { + return nil + } + return &VersionTargetQuery{ + config: vtq.config, + ctx: vtq.ctx.Clone(), + order: append([]versiontarget.OrderOption{}, vtq.order...), + inters: append([]Interceptor{}, vtq.inters...), + predicates: append([]predicate.VersionTarget{}, vtq.predicates...), + withSmlVersion: vtq.withSmlVersion.Clone(), + // clone intermediate query. + sql: vtq.sql.Clone(), + path: vtq.path, + } +} + +// WithSmlVersion tells the query-builder to eager-load the nodes that are connected to +// the "sml_version" edge. The optional arguments are used to configure the query builder of the edge. +func (vtq *VersionTargetQuery) WithSmlVersion(opts ...func(*VersionQuery)) *VersionTargetQuery { + query := (&VersionClient{config: vtq.config}).Query() + for _, opt := range opts { + opt(query) + } + vtq.withSmlVersion = query + return vtq +} + +// 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 { +// VersionID string `json:"version_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.VersionTarget.Query(). +// GroupBy(versiontarget.FieldVersionID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (vtq *VersionTargetQuery) GroupBy(field string, fields ...string) *VersionTargetGroupBy { + vtq.ctx.Fields = append([]string{field}, fields...) + grbuild := &VersionTargetGroupBy{build: vtq} + grbuild.flds = &vtq.ctx.Fields + grbuild.label = versiontarget.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 { +// VersionID string `json:"version_id,omitempty"` +// } +// +// client.VersionTarget.Query(). +// Select(versiontarget.FieldVersionID). +// Scan(ctx, &v) +func (vtq *VersionTargetQuery) Select(fields ...string) *VersionTargetSelect { + vtq.ctx.Fields = append(vtq.ctx.Fields, fields...) + sbuild := &VersionTargetSelect{VersionTargetQuery: vtq} + sbuild.label = versiontarget.Label + sbuild.flds, sbuild.scan = &vtq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a VersionTargetSelect configured with the given aggregations. +func (vtq *VersionTargetQuery) Aggregate(fns ...AggregateFunc) *VersionTargetSelect { + return vtq.Select().Aggregate(fns...) +} + +func (vtq *VersionTargetQuery) prepareQuery(ctx context.Context) error { + for _, inter := range vtq.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, vtq); err != nil { + return err + } + } + } + for _, f := range vtq.ctx.Fields { + if !versiontarget.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if vtq.path != nil { + prev, err := vtq.path(ctx) + if err != nil { + return err + } + vtq.sql = prev + } + return nil +} + +func (vtq *VersionTargetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*VersionTarget, error) { + var ( + nodes = []*VersionTarget{} + _spec = vtq.querySpec() + loadedTypes = [1]bool{ + vtq.withSmlVersion != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*VersionTarget).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &VersionTarget{config: vtq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(vtq.modifiers) > 0 { + _spec.Modifiers = vtq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, vtq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := vtq.withSmlVersion; query != nil { + if err := vtq.loadSmlVersion(ctx, query, nodes, nil, + func(n *VersionTarget, e *Version) { n.Edges.SmlVersion = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (vtq *VersionTargetQuery) loadSmlVersion(ctx context.Context, query *VersionQuery, nodes []*VersionTarget, init func(*VersionTarget), assign func(*VersionTarget, *Version)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*VersionTarget) + for i := range nodes { + fk := nodes[i].VersionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(version.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 "version_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (vtq *VersionTargetQuery) sqlCount(ctx context.Context) (int, error) { + _spec := vtq.querySpec() + if len(vtq.modifiers) > 0 { + _spec.Modifiers = vtq.modifiers + } + _spec.Node.Columns = vtq.ctx.Fields + if len(vtq.ctx.Fields) > 0 { + _spec.Unique = vtq.ctx.Unique != nil && *vtq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, vtq.driver, _spec) +} + +func (vtq *VersionTargetQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(versiontarget.Table, versiontarget.Columns, sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString)) + _spec.From = vtq.sql + if unique := vtq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if vtq.path != nil { + _spec.Unique = true + } + if fields := vtq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, versiontarget.FieldID) + for i := range fields { + if fields[i] != versiontarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if vtq.withSmlVersion != nil { + _spec.Node.AddColumnOnce(versiontarget.FieldVersionID) + } + } + if ps := vtq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := vtq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := vtq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := vtq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (vtq *VersionTargetQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(vtq.driver.Dialect()) + t1 := builder.Table(versiontarget.Table) + columns := vtq.ctx.Fields + if len(columns) == 0 { + columns = versiontarget.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if vtq.sql != nil { + selector = vtq.sql + selector.Select(selector.Columns(columns...)...) + } + if vtq.ctx.Unique != nil && *vtq.ctx.Unique { + selector.Distinct() + } + for _, m := range vtq.modifiers { + m(selector) + } + for _, p := range vtq.predicates { + p(selector) + } + for _, p := range vtq.order { + p(selector) + } + if offset := vtq.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 := vtq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (vtq *VersionTargetQuery) Modify(modifiers ...func(s *sql.Selector)) *VersionTargetSelect { + vtq.modifiers = append(vtq.modifiers, modifiers...) + return vtq.Select() +} + +// VersionTargetGroupBy is the group-by builder for VersionTarget entities. +type VersionTargetGroupBy struct { + selector + build *VersionTargetQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (vtgb *VersionTargetGroupBy) Aggregate(fns ...AggregateFunc) *VersionTargetGroupBy { + vtgb.fns = append(vtgb.fns, fns...) + return vtgb +} + +// Scan applies the selector query and scans the result into the given value. +func (vtgb *VersionTargetGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vtgb.build.ctx, "GroupBy") + if err := vtgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionTargetQuery, *VersionTargetGroupBy](ctx, vtgb.build, vtgb, vtgb.build.inters, v) +} + +func (vtgb *VersionTargetGroupBy) sqlScan(ctx context.Context, root *VersionTargetQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(vtgb.fns)) + for _, fn := range vtgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*vtgb.flds)+len(vtgb.fns)) + for _, f := range *vtgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*vtgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := vtgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// VersionTargetSelect is the builder for selecting fields of VersionTarget entities. +type VersionTargetSelect struct { + *VersionTargetQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (vts *VersionTargetSelect) Aggregate(fns ...AggregateFunc) *VersionTargetSelect { + vts.fns = append(vts.fns, fns...) + return vts +} + +// Scan applies the selector query and scans the result into the given value. +func (vts *VersionTargetSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vts.ctx, "Select") + if err := vts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*VersionTargetQuery, *VersionTargetSelect](ctx, vts.VersionTargetQuery, vts, vts.inters, v) +} + +func (vts *VersionTargetSelect) sqlScan(ctx context.Context, root *VersionTargetQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(vts.fns)) + for _, fn := range vts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*vts.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 := vts.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 (vts *VersionTargetSelect) Modify(modifiers ...func(s *sql.Selector)) *VersionTargetSelect { + vts.modifiers = append(vts.modifiers, modifiers...) + return vts +} diff --git a/generated/ent/versiontarget_update.go b/generated/ent/versiontarget_update.go new file mode 100644 index 00000000..2dd1d1a8 --- /dev/null +++ b/generated/ent/versiontarget_update.go @@ -0,0 +1,410 @@ +// 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/predicate" + "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" +) + +// VersionTargetUpdate is the builder for updating VersionTarget entities. +type VersionTargetUpdate struct { + config + hooks []Hook + mutation *VersionTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the VersionTargetUpdate builder. +func (vtu *VersionTargetUpdate) Where(ps ...predicate.VersionTarget) *VersionTargetUpdate { + vtu.mutation.Where(ps...) + return vtu +} + +// SetVersionID sets the "version_id" field. +func (vtu *VersionTargetUpdate) SetVersionID(s string) *VersionTargetUpdate { + vtu.mutation.SetVersionID(s) + return vtu +} + +// SetTargetName sets the "target_name" field. +func (vtu *VersionTargetUpdate) SetTargetName(s string) *VersionTargetUpdate { + vtu.mutation.SetTargetName(s) + return vtu +} + +// SetKey sets the "key" field. +func (vtu *VersionTargetUpdate) SetKey(s string) *VersionTargetUpdate { + vtu.mutation.SetKey(s) + return vtu +} + +// SetHash sets the "hash" field. +func (vtu *VersionTargetUpdate) SetHash(s string) *VersionTargetUpdate { + vtu.mutation.SetHash(s) + return vtu +} + +// SetSize sets the "size" field. +func (vtu *VersionTargetUpdate) SetSize(i int64) *VersionTargetUpdate { + vtu.mutation.ResetSize() + vtu.mutation.SetSize(i) + return vtu +} + +// AddSize adds i to the "size" field. +func (vtu *VersionTargetUpdate) AddSize(i int64) *VersionTargetUpdate { + vtu.mutation.AddSize(i) + return vtu +} + +// SetSmlVersionID sets the "sml_version" edge to the Version entity by ID. +func (vtu *VersionTargetUpdate) SetSmlVersionID(id string) *VersionTargetUpdate { + vtu.mutation.SetSmlVersionID(id) + return vtu +} + +// SetSmlVersion sets the "sml_version" edge to the Version entity. +func (vtu *VersionTargetUpdate) SetSmlVersion(v *Version) *VersionTargetUpdate { + return vtu.SetSmlVersionID(v.ID) +} + +// Mutation returns the VersionTargetMutation object of the builder. +func (vtu *VersionTargetUpdate) Mutation() *VersionTargetMutation { + return vtu.mutation +} + +// ClearSmlVersion clears the "sml_version" edge to the Version entity. +func (vtu *VersionTargetUpdate) ClearSmlVersion() *VersionTargetUpdate { + vtu.mutation.ClearSmlVersion() + return vtu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (vtu *VersionTargetUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, vtu.sqlSave, vtu.mutation, vtu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vtu *VersionTargetUpdate) SaveX(ctx context.Context) int { + affected, err := vtu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (vtu *VersionTargetUpdate) Exec(ctx context.Context) error { + _, err := vtu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtu *VersionTargetUpdate) ExecX(ctx context.Context) { + if err := vtu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vtu *VersionTargetUpdate) check() error { + if _, ok := vtu.mutation.SmlVersionID(); vtu.mutation.SmlVersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionTarget.sml_version"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vtu *VersionTargetUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionTargetUpdate { + vtu.modifiers = append(vtu.modifiers, modifiers...) + return vtu +} + +func (vtu *VersionTargetUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := vtu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(versiontarget.Table, versiontarget.Columns, sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString)) + if ps := vtu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vtu.mutation.TargetName(); ok { + _spec.SetField(versiontarget.FieldTargetName, field.TypeString, value) + } + if value, ok := vtu.mutation.Key(); ok { + _spec.SetField(versiontarget.FieldKey, field.TypeString, value) + } + if value, ok := vtu.mutation.Hash(); ok { + _spec.SetField(versiontarget.FieldHash, field.TypeString, value) + } + if value, ok := vtu.mutation.Size(); ok { + _spec.SetField(versiontarget.FieldSize, field.TypeInt64, value) + } + if value, ok := vtu.mutation.AddedSize(); ok { + _spec.AddField(versiontarget.FieldSize, field.TypeInt64, value) + } + if vtu.mutation.SmlVersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: versiontarget.SmlVersionTable, + Columns: []string{versiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vtu.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: versiontarget.SmlVersionTable, + Columns: []string{versiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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(vtu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, vtu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{versiontarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + vtu.mutation.done = true + return n, nil +} + +// VersionTargetUpdateOne is the builder for updating a single VersionTarget entity. +type VersionTargetUpdateOne struct { + config + fields []string + hooks []Hook + mutation *VersionTargetMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetVersionID sets the "version_id" field. +func (vtuo *VersionTargetUpdateOne) SetVersionID(s string) *VersionTargetUpdateOne { + vtuo.mutation.SetVersionID(s) + return vtuo +} + +// SetTargetName sets the "target_name" field. +func (vtuo *VersionTargetUpdateOne) SetTargetName(s string) *VersionTargetUpdateOne { + vtuo.mutation.SetTargetName(s) + return vtuo +} + +// SetKey sets the "key" field. +func (vtuo *VersionTargetUpdateOne) SetKey(s string) *VersionTargetUpdateOne { + vtuo.mutation.SetKey(s) + return vtuo +} + +// SetHash sets the "hash" field. +func (vtuo *VersionTargetUpdateOne) SetHash(s string) *VersionTargetUpdateOne { + vtuo.mutation.SetHash(s) + return vtuo +} + +// SetSize sets the "size" field. +func (vtuo *VersionTargetUpdateOne) SetSize(i int64) *VersionTargetUpdateOne { + vtuo.mutation.ResetSize() + vtuo.mutation.SetSize(i) + return vtuo +} + +// AddSize adds i to the "size" field. +func (vtuo *VersionTargetUpdateOne) AddSize(i int64) *VersionTargetUpdateOne { + vtuo.mutation.AddSize(i) + return vtuo +} + +// SetSmlVersionID sets the "sml_version" edge to the Version entity by ID. +func (vtuo *VersionTargetUpdateOne) SetSmlVersionID(id string) *VersionTargetUpdateOne { + vtuo.mutation.SetSmlVersionID(id) + return vtuo +} + +// SetSmlVersion sets the "sml_version" edge to the Version entity. +func (vtuo *VersionTargetUpdateOne) SetSmlVersion(v *Version) *VersionTargetUpdateOne { + return vtuo.SetSmlVersionID(v.ID) +} + +// Mutation returns the VersionTargetMutation object of the builder. +func (vtuo *VersionTargetUpdateOne) Mutation() *VersionTargetMutation { + return vtuo.mutation +} + +// ClearSmlVersion clears the "sml_version" edge to the Version entity. +func (vtuo *VersionTargetUpdateOne) ClearSmlVersion() *VersionTargetUpdateOne { + vtuo.mutation.ClearSmlVersion() + return vtuo +} + +// Where appends a list predicates to the VersionTargetUpdate builder. +func (vtuo *VersionTargetUpdateOne) Where(ps ...predicate.VersionTarget) *VersionTargetUpdateOne { + vtuo.mutation.Where(ps...) + return vtuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (vtuo *VersionTargetUpdateOne) Select(field string, fields ...string) *VersionTargetUpdateOne { + vtuo.fields = append([]string{field}, fields...) + return vtuo +} + +// Save executes the query and returns the updated VersionTarget entity. +func (vtuo *VersionTargetUpdateOne) Save(ctx context.Context) (*VersionTarget, error) { + return withHooks(ctx, vtuo.sqlSave, vtuo.mutation, vtuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vtuo *VersionTargetUpdateOne) SaveX(ctx context.Context) *VersionTarget { + node, err := vtuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (vtuo *VersionTargetUpdateOne) Exec(ctx context.Context) error { + _, err := vtuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vtuo *VersionTargetUpdateOne) ExecX(ctx context.Context) { + if err := vtuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vtuo *VersionTargetUpdateOne) check() error { + if _, ok := vtuo.mutation.SmlVersionID(); vtuo.mutation.SmlVersionCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "VersionTarget.sml_version"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vtuo *VersionTargetUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VersionTargetUpdateOne { + vtuo.modifiers = append(vtuo.modifiers, modifiers...) + return vtuo +} + +func (vtuo *VersionTargetUpdateOne) sqlSave(ctx context.Context) (_node *VersionTarget, err error) { + if err := vtuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(versiontarget.Table, versiontarget.Columns, sqlgraph.NewFieldSpec(versiontarget.FieldID, field.TypeString)) + id, ok := vtuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "VersionTarget.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := vtuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, versiontarget.FieldID) + for _, f := range fields { + if !versiontarget.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != versiontarget.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := vtuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vtuo.mutation.TargetName(); ok { + _spec.SetField(versiontarget.FieldTargetName, field.TypeString, value) + } + if value, ok := vtuo.mutation.Key(); ok { + _spec.SetField(versiontarget.FieldKey, field.TypeString, value) + } + if value, ok := vtuo.mutation.Hash(); ok { + _spec.SetField(versiontarget.FieldHash, field.TypeString, value) + } + if value, ok := vtuo.mutation.Size(); ok { + _spec.SetField(versiontarget.FieldSize, field.TypeInt64, value) + } + if value, ok := vtuo.mutation.AddedSize(); ok { + _spec.AddField(versiontarget.FieldSize, field.TypeInt64, value) + } + if vtuo.mutation.SmlVersionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: versiontarget.SmlVersionTable, + Columns: []string{versiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vtuo.mutation.SmlVersionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: versiontarget.SmlVersionTable, + Columns: []string{versiontarget.SmlVersionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(version.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(vtuo.modifiers...) + _node = &VersionTarget{config: vtuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, vtuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{versiontarget.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + vtuo.mutation.done = true + return _node, nil +} diff --git a/go.mod b/go.mod index 1691ee10..c5a614ed 100755 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis/v8 v8.11.5 github.com/golang-migrate/migrate/v4 v4.16.2 + github.com/graph-gophers/dataloader/v7 v7.1.0 github.com/jackc/pgx/v5 v5.4.3 github.com/lab259/go-migration v1.3.1 github.com/labstack/echo-contrib v0.15.0 diff --git a/go.sum b/go.sum index f46a23fc..6b46a4c4 100644 --- a/go.sum +++ b/go.sum @@ -336,6 +336,8 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/graph-gophers/dataloader/v7 v7.1.0 h1:Wn8HGF/q7MNXcvfaBnLEPEFJttVHR8zuEqP1obys/oc= +github.com/graph-gophers/dataloader/v7 v7.1.0/go.mod h1:1bKE0Dm6OUcTB/OAuYVOZctgIz7Q3d0XrYtlIzTgg6Q= github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= diff --git a/gql/directive.go b/gql/directive.go index 405b4c2a..23f3063e 100644 --- a/gql/directive.go +++ b/gql/directive.go @@ -2,7 +2,6 @@ package gql import ( "context" - "net/http" "reflect" "github.com/99designs/gqlgen/graphql" @@ -10,9 +9,7 @@ import ( "github.com/satisfactorymodding/smr-api/auth" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/util" ) func MakeDirective() generated.DirectiveRoot { @@ -44,13 +41,7 @@ func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field return nil, err } - dbMod := postgres.GetModByID(ctx, getArgument(ctx, field).(string)) - - if dbMod == nil { - return nil, errors.New("mod not found") - } - - if db.UserCanUploadModVersions(ctx, user, dbMod.ID) { + if db.UserCanUploadModVersions(ctx, user, getArgument(ctx, field).(string)) { return next(ctx) } @@ -75,13 +66,7 @@ func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Re return nil, errors.New("user not authorized to perform this action") } - dbMod := postgres.GetModByID(ctx, getArgument(ctx, *field).(string)) - - if dbMod == nil { - return nil, errors.New("mod not found") - } - - if db.UserCanUploadModVersions(ctx, user, dbMod.ID) { + if db.UserCanUploadModVersions(ctx, user, getArgument(ctx, *field).(string)) { return next(ctx) } @@ -94,13 +79,7 @@ func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, f return nil, err } - dbVersion := postgres.GetVersion(ctx, getArgument(ctx, field).(string)) - - if dbVersion == nil { - return nil, errors.New("version not found") - } - - if db.UserCanUploadModVersions(ctx, user, dbVersion.ModID) { + if db.UserCanUploadModVersions(ctx, user, getArgument(ctx, field).(string)) { return next(ctx) } @@ -124,13 +103,7 @@ func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, fi userID = getArgument(ctx, field).(string) } - dbUser := postgres.GetUserByID(ctx, userID) - - if dbUser == nil { - return nil, errors.New("user not found") - } - - if dbUser.ID == user.ID { + if userID == user.ID { return next(ctx) } @@ -147,13 +120,12 @@ func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, fie return nil, err } - dbGuide := postgres.GetGuideByID(ctx, getArgument(ctx, field).(string)) - - if dbGuide == nil { - return nil, errors.New("guide not found") + g, err := db.From(ctx).Guide.Get(ctx, getArgument(ctx, field).(string)) + if err != nil { + return nil, err } - if dbGuide.UserID == user.ID { + if g.UserID == user.ID { return next(ctx) } @@ -178,15 +150,13 @@ func isLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (inte } func isNotLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - header := ctx.Value(util.ContextHeader{}).(http.Header) - authorization := header.Get("Authorization") - - if authorization != "" { - user := postgres.GetUserByToken(ctx, authorization) + user, err := db.UserFromGQLContext(ctx) + if err != nil { + return nil, err + } - if user != nil { - return nil, errors.New("user is logged in") - } + if user != nil { + return nil, errors.New("user is logged in") } return next(ctx) diff --git a/gql/gql_types.go b/gql/gql_types.go index 3dd3a367..b193fb07 100644 --- a/gql/gql_types.go +++ b/gql/gql_types.go @@ -7,28 +7,6 @@ import ( "github.com/satisfactorymodding/smr-api/generated" ) -func DBUserToGenerated(user *postgres.User) *generated.User { - if user == nil { - return nil - } - - Email := user.Email - Avatar := user.Avatar - - result := &generated.User{ - ID: user.ID, - Username: user.Username, - Email: &Email, - Avatar: &Avatar, - CreatedAt: user.CreatedAt.Format(time.RFC3339Nano), - GithubID: user.GithubID, - GoogleID: user.GoogleID, - FacebookID: user.FacebookID, - } - - return result -} - func DBModToGenerated(mod *postgres.Mod) *generated.Mod { if mod == nil { return nil @@ -104,45 +82,6 @@ func DBVersionsToGeneratedSlice(versions []postgres.Version) []*generated.Versio return converted } -func DBGuideToGenerated(guide *postgres.Guide) *generated.Guide { - if guide == nil { - return nil - } - - return &generated.Guide{ - ID: guide.ID, - Name: guide.Name, - ShortDescription: guide.ShortDescription, - Guide: guide.Guide, - UserID: guide.UserID, - Views: int(guide.Views), - UpdatedAt: guide.UpdatedAt.Format(time.RFC3339Nano), - CreatedAt: guide.CreatedAt.Format(time.RFC3339Nano), - Tags: DBTagsToGeneratedSlice(guide.Tags), - } -} - -func DBSMLVersionToGenerated(smlVersion *postgres.SMLVersion) *generated.SMLVersion { - if smlVersion == nil { - return nil - } - - return &generated.SMLVersion{ - ID: smlVersion.ID, - Version: smlVersion.Version, - SatisfactoryVersion: smlVersion.SatisfactoryVersion, - BootstrapVersion: smlVersion.BootstrapVersion, - Stability: generated.VersionStabilities(smlVersion.Stability), - Link: smlVersion.Link, - Targets: DBSMLVersionTargetToGeneratedSlice(smlVersion.Targets), - Changelog: smlVersion.Changelog, - Date: smlVersion.Date.Format(time.RFC3339Nano), - UpdatedAt: smlVersion.UpdatedAt.Format(time.RFC3339Nano), - CreatedAt: smlVersion.CreatedAt.Format(time.RFC3339Nano), - EngineVersion: smlVersion.EngineVersion, - } -} - func DBVersionDependencyToGenerated(versionDependency *postgres.VersionDependency) *generated.VersionDependency { if versionDependency == nil { return nil @@ -199,33 +138,13 @@ func DBVersionTargetsToGeneratedSlice(versionTargets []postgres.VersionTarget) [ return converted } -func DBSMLVersionTargetToGenerated(smlVersionTarget *postgres.SMLVersionTarget) *generated.SMLVersionTarget { - if smlVersionTarget == nil { - return nil - } - - return &generated.SMLVersionTarget{ - VersionID: smlVersionTarget.VersionID, - TargetName: generated.TargetName(smlVersionTarget.TargetName), - Link: smlVersionTarget.Link, - } -} - -func DBSMLVersionTargetToGeneratedSlice(smlVersionTargets []postgres.SMLVersionTarget) []*generated.SMLVersionTarget { - converted := make([]*generated.SMLVersionTarget, len(smlVersionTargets)) - for i, smlVersionTarget := range smlVersionTargets { - converted[i] = DBSMLVersionTargetToGenerated(&smlVersionTarget) - } - return converted -} - func GenCompInfoToDBCompInfo(gen *generated.CompatibilityInfoInput) *postgres.CompatibilityInfo { if gen == nil { return nil } return &postgres.CompatibilityInfo{ - EA: GenCompToDBComp(gen.Ea), - EXP: GenCompToDBComp(gen.Exp), + Ea: GenCompToDBComp(gen.Ea), + Exp: GenCompToDBComp(gen.Exp), } } @@ -242,8 +161,8 @@ func DBCompInfoToGenCompInfo(gen *postgres.CompatibilityInfo) *generated.Compati return nil } return &generated.CompatibilityInfo{ - Ea: DBCompToGenComp(gen.EA), - Exp: DBCompToGenComp(gen.EXP), + Ea: DBCompToGenComp(gen.Ea), + Exp: DBCompToGenComp(gen.Exp), } } diff --git a/gql/gql_utils.go b/gql/gql_utils.go index a563621d..16f8813f 100644 --- a/gql/gql_utils.go +++ b/gql/gql_utils.go @@ -73,14 +73,6 @@ func SetStabilityINN(value *generated.VersionStabilities, target *string) { *target = string(*value) } -func SetDateINN(value *string, target *time.Time) { - if value == nil { - return - } - - *target, _ = time.Parse(time.RFC3339Nano, *value) -} - func SetCompatibilityINN(value *generated.CompatibilityInfoInput, target **postgres.CompatibilityInfo) { if value == nil { return diff --git a/gql/resolver_announcements.go b/gql/resolver_announcements.go index 206d3d3b..ead4eb83 100644 --- a/gql/resolver_announcements.go +++ b/gql/resolver_announcements.go @@ -70,10 +70,10 @@ func (r *mutationResolver) UpdateAnnouncement(ctx context.Context, announcementI } func (r *queryResolver) GetAnnouncement(ctx context.Context, announcementID string) (*generated.Announcement, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncement") + wrapper, ctx := WrapQueryTrace(ctx, "getAnnouncement") defer wrapper.end() - result, err := db.From(newCtx).Announcement.Get(newCtx, announcementID) + result, err := db.From(ctx).Announcement.Get(ctx, announcementID) if err != nil { return nil, err } @@ -82,10 +82,10 @@ func (r *queryResolver) GetAnnouncement(ctx context.Context, announcementID stri } func (r *queryResolver) GetAnnouncements(ctx context.Context) ([]*generated.Announcement, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncements") + wrapper, ctx := WrapQueryTrace(ctx, "getAnnouncements") defer wrapper.end() - result, err := db.From(newCtx).Debug().Announcement.Query().All(newCtx) + result, err := db.From(ctx).Debug().Announcement.Query().All(ctx) if err != nil { return nil, err } @@ -94,13 +94,13 @@ func (r *queryResolver) GetAnnouncements(ctx context.Context) ([]*generated.Anno } func (r *queryResolver) GetAnnouncementsByImportance(ctx context.Context, importance generated.AnnouncementImportance) ([]*generated.Announcement, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getAnnouncementsByImportance") + wrapper, ctx := WrapQueryTrace(ctx, "getAnnouncementsByImportance") defer wrapper.end() - result, err := db.From(newCtx).Announcement. + result, err := db.From(ctx).Announcement. Query(). Where(announcement.ImportanceEQ(string(importance))). - All(newCtx) + All(ctx) if err != nil { return nil, err } diff --git a/gql/resolver_guides.go b/gql/resolver_guides.go index e72f6d7d..cce0952c 100644 --- a/gql/resolver_guides.go +++ b/gql/resolver_guides.go @@ -3,114 +3,154 @@ package gql import ( "context" "fmt" + "log/slog" + "math" + "strings" "time" + "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" - "github.com/pkg/errors" + "github.com/Vilsol/slox" "gopkg.in/go-playground/validator.v9" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" + "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/util" ) -func (r *mutationResolver) CreateGuide(ctx context.Context, guide generated.NewGuide) (*generated.Guide, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createGuide") +func (r *mutationResolver) CreateGuide(ctx context.Context, g generated.NewGuide) (*generated.Guide, error) { + wrapper, ctx := WrapMutationTrace(ctx, "createGuide") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&guide); err != nil { + if err := val.Struct(&g); err != nil { return nil, fmt.Errorf("validation failed: %w", err) } - dbGuide := &postgres.Guide{ - Name: guide.Name, - ShortDescription: guide.ShortDescription, - Guide: guide.Guide, - } - user, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - dbGuide.UserID = user.ID - - resultGuide, err := postgres.CreateGuide(newCtx, dbGuide) + // Allow only 8 new guides per 24h + guides, err := db.From(ctx).Guide.Query().Where( + guide.UserID(user.ID), + guide.CreatedAtGT(time.Now().Add(time.Hour*24*-1)), + ).All(ctx) if err != nil { return nil, err } - err = postgres.SetGuideTags(newCtx, resultGuide.ID, guide.TagIDs) + currentAvailable := float64(8) + lastGuideTime := time.Now() + for _, existingGuide := range guides { + currentAvailable-- + if existingGuide.CreatedAt.After(lastGuideTime) { + diff := existingGuide.CreatedAt.Sub(lastGuideTime) + currentAvailable = math.Min(8, currentAvailable+diff.Hours()/3) + } + lastGuideTime = existingGuide.CreatedAt + } + if currentAvailable < 1 { + timeToWait := time.Until(lastGuideTime.Add(time.Hour * 6)).Minutes() + return nil, fmt.Errorf("please wait %.0f minutes to post another guide", timeToWait) + } + + result, err := db.From(ctx).Guide. + Create(). + SetName(g.Name). + SetShortDescription(g.ShortDescription). + SetGuide(g.Guide). + SetUser(user). + AddTagIDs(g.TagIDs...). + Save(ctx) if err != nil { return nil, err } - // Need to get the guide again to populate tags - return DBGuideToGenerated(postgres.GetGuideByIDNoCache(newCtx, resultGuide.ID)), nil + return (*conv.GuideImpl)(nil).Convert(result), nil } -func (r *mutationResolver) UpdateGuide(ctx context.Context, guideID string, guide generated.UpdateGuide) (*generated.Guide, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateGuide") +func (r *mutationResolver) UpdateGuide(ctx context.Context, guideID string, g generated.UpdateGuide) (*generated.Guide, error) { + wrapper, ctx := WrapMutationTrace(ctx, "updateGuide") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&guide); err != nil { + if err := val.Struct(&g); err != nil { return nil, fmt.Errorf("validation failed: %w", err) } - err := postgres.ResetGuideTags(newCtx, guideID, guide.TagIDs) - if err != nil { - return nil, err - } + if err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + update := tx.Guide.UpdateOneID(guideID) - dbGuide := postgres.GetGuideByIDNoCache(newCtx, guideID) + SetINNOEF(g.Name, update.SetName) + SetINNOEF(g.ShortDescription, update.SetShortDescription) + SetINNOEF(g.Guide, update.SetGuide) - if dbGuide == nil { - return nil, errors.New("guide not found") - } + if err := update.Exec(ctx); err != nil { + return err + } + + if _, err := tx.GuideTag.Delete().Where( + guidetag.GuideID(guideID), + guidetag.TagIDNotIn(g.TagIDs...), + ).Exec(ctx); err != nil { + return err + } - SetStringINNOE(guide.Name, &dbGuide.Name) - SetStringINNOE(guide.ShortDescription, &dbGuide.ShortDescription) - SetStringINNOE(guide.Guide, &dbGuide.Guide) + return tx.GuideTag.MapCreateBulk(g.TagIDs, func(create *ent.GuideTagCreate, i int) { + create.SetGuideID(guideID).SetTagID(g.TagIDs[i]) + }).Exec(ctx) + }, nil); err != nil { + return nil, err + } - postgres.Save(newCtx, &dbGuide) + result, err := db.From(ctx).Guide.Query().WithTags().Where(guide.ID(guideID)).First(ctx) + if err != nil { + return nil, err + } - return DBGuideToGenerated(dbGuide), nil + return (*conv.GuideImpl)(nil).Convert(result), nil } func (r *mutationResolver) DeleteGuide(ctx context.Context, guideID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteGuide") + wrapper, ctx := WrapMutationTrace(ctx, "deleteGuide") defer wrapper.end() - dbGuide := postgres.GetGuideByID(newCtx, guideID) - - if dbGuide == nil { - return false, errors.New("guide not found") + if err := db.From(ctx).Guide.DeleteOneID(guideID).Exec(ctx); err != nil { + return false, err } - postgres.Delete(newCtx, &dbGuide) - return true, nil } func (r *queryResolver) GetGuide(ctx context.Context, guideID string) (*generated.Guide, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getGuide") + wrapper, ctx := WrapQueryTrace(ctx, "getGuide") defer wrapper.end() - guide := postgres.GetGuideByID(newCtx, guideID) + result, err := db.From(ctx).Guide.Get(ctx, guideID) + if err != nil { + return nil, err + } - if guide != nil { + if result != nil { if redis.CanIncrement(RealIP(ctx), "view", "guide:"+guideID, time.Hour*4) { - postgres.IncrementGuideViews(newCtx, guide) + err := result.Update().AddViews(1).Exec(ctx) + if err != nil { + slox.Error(ctx, "failed incrementing views", slog.Any("err", err)) + } } } - return DBGuideToGenerated(guide), nil + return (*conv.GuideImpl)(nil).Convert(result), nil } func (r *queryResolver) GetGuides(ctx context.Context, _ map[string]interface{}) (*generated.GetGuides, error) { @@ -122,7 +162,7 @@ func (r *queryResolver) GetGuides(ctx context.Context, _ map[string]interface{}) type getGuidesResolver struct{ *Resolver } func (r *getGuidesResolver) Guides(ctx context.Context, _ *generated.GetGuides) ([]*generated.Guide, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetGuides.guides") + wrapper, ctx := WrapQueryTrace(ctx, "GetGuides.guides") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -131,28 +171,19 @@ func (r *getGuidesResolver) Guides(ctx context.Context, _ *generated.GetGuides) return nil, err } - var guides []postgres.Guide + query := db.From(ctx).Guide.Query().WithTags() + query = convertGuideFilter(query, guideFilter) - if guideFilter.Ids == nil || len(guideFilter.Ids) == 0 { - guides = postgres.GetGuides(newCtx, guideFilter) - } else { - guides = postgres.GetGuidesByID(newCtx, guideFilter.Ids) - } - - if guides == nil { - return nil, errors.New("guides not found") - } - - converted := make([]*generated.Guide, len(guides)) - for k, v := range guides { - converted[k] = DBGuideToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.GuideImpl)(nil).ConvertSlice(result), nil } func (r *getGuidesResolver) Count(ctx context.Context, _ *generated.GetGuides) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetGuides.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetGuides.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -161,24 +192,52 @@ func (r *getGuidesResolver) Count(ctx context.Context, _ *generated.GetGuides) ( return 0, err } - if guideFilter.Ids != nil && len(guideFilter.Ids) != 0 { - return len(guideFilter.Ids), nil + query := db.From(ctx).Guide.Query().WithTags() + query = convertGuideFilter(query, guideFilter) + + result, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetGuideCount(newCtx, guideFilter)), nil + return result, nil } type guideResolver struct{ *Resolver } func (r *guideResolver) User(ctx context.Context, obj *generated.Guide) (*generated.User, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "Guide.user") + wrapper, ctx := WrapQueryTrace(ctx, "Guide.user") defer wrapper.end() - user := postgres.GetUserByID(newCtx, obj.UserID) - - if user == nil { - return nil, errors.New("user not found") + result, err := db.From(ctx).User.Get(ctx, obj.UserID) + if err != nil { + return nil, err } - return DBUserToGenerated(user), nil + return (*conv.UserImpl)(nil).Convert(result), nil +} + +func convertGuideFilter(query *ent.GuideQuery, filter *models.GuideFilter) *ent.GuideQuery { + if len(filter.Ids) > 0 { + query = query.Where(guide.IDIn(filter.Ids...)) + } else if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset). + Order(sql.OrderByField( + filter.OrderBy.String(), + db.OrderToOrder(filter.Order.String()), + ).ToFunc()) + + if filter.Search != nil && *filter.Search != "" { + query = query.Modify(func(s *sql.Selector) { + s.Where(sql.ExprP("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & "))) + }).Clone() + } + + if filter.TagIDs != nil && len(filter.TagIDs) > 0 { + query = query.Where(guide.HasTagsWith(tag.IDIn(filter.TagIDs...))) + } + } + return query } diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 171a0e90..4a38b425 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -5,10 +5,13 @@ import ( "context" "fmt" "io" + "log/slog" "strings" "time" + "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" + "github.com/Vilsol/slox" "github.com/dgraph-io/ristretto" "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" @@ -17,6 +20,10 @@ import ( "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "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/version" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/redis" @@ -35,7 +42,7 @@ var DisallowedModReferences = map[string]bool{ } func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) (*generated.Mod, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createMod") + wrapper, ctx := WrapMutationTrace(ctx, "createMod") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -47,7 +54,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) return nil, errors.New("using this mod reference is not allowed") } - if postgres.GetModByReference(newCtx, mod.ModReference) != nil { + if postgres.GetModByReference(ctx, mod.ModReference) != nil { return nil, errors.New("mod with this mod reference already exists") } @@ -86,7 +93,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) dbMod.Logo = "" } - resultMod, err := postgres.CreateMod(newCtx, dbMod) + resultMod, err := postgres.CreateMod(ctx, dbMod) if err != nil { return nil, err } @@ -95,22 +102,22 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) success, logoKey := storage.UploadModLogo(ctx, resultMod.ID, bytes.NewReader(logoData)) if success { resultMod.Logo = storage.GenerateDownloadLink(logoKey) - postgres.Save(newCtx, &resultMod) + postgres.Save(ctx, &resultMod) } } - err = postgres.SetModTags(newCtx, resultMod.ID, mod.TagIDs) + err = postgres.SetModTags(ctx, resultMod.ID, mod.TagIDs) if err != nil { return nil, err } // Need to get the mod again to populate tags - return DBModToGenerated(postgres.GetModByIDNoCache(newCtx, resultMod.ID)), nil + return DBModToGenerated(postgres.GetModByIDNoCache(ctx, resultMod.ID)), nil } func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod generated.UpdateMod) (*generated.Mod, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateMod") + wrapper, ctx := WrapMutationTrace(ctx, "updateMod") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) @@ -119,13 +126,13 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } if mod.TagIDs != nil { - err := postgres.ResetModTags(newCtx, modID, mod.TagIDs) + err := postgres.ResetModTags(ctx, modID, mod.TagIDs) if err != nil { return nil, err } } - dbMod := postgres.GetModByIDNoCache(newCtx, modID) + dbMod := postgres.GetModByIDNoCache(ctx, modID) if dbMod == nil { return nil, errors.New("mod not found") @@ -162,10 +169,10 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } } - postgres.Save(newCtx, &dbMod) + postgres.Save(ctx, &dbMod) if mod.Authors != nil { - authors, err := dataloader.For(ctx).UserModsByModID.Load(modID) + authors, err := dataloader.For(ctx).UserModsByModID.Load(ctx, modID)() if err != nil { return nil, err } @@ -185,7 +192,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } if !found { - postgres.Delete(newCtx, author) + postgres.Delete(ctx, author) } } @@ -196,7 +203,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene role = "editor" } - postgres.Save(newCtx, &postgres.UserMod{ + postgres.Save(ctx, &postgres.UserMod{ UserID: userMod.UserID, ModID: modID, Role: role, @@ -229,25 +236,25 @@ func (r *mutationResolver) UpdateMultipleModCompatibilities(ctx context.Context, } func (r *mutationResolver) DeleteMod(ctx context.Context, modID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteMod") + wrapper, ctx := WrapMutationTrace(ctx, "deleteMod") defer wrapper.end() - dbMod := postgres.GetModByID(newCtx, modID) + dbMod := postgres.GetModByID(ctx, modID) if dbMod == nil { return false, errors.New("mod not found") } - postgres.Delete(newCtx, &dbMod) + postgres.Delete(ctx, &dbMod) return true, nil } func (r *mutationResolver) ApproveMod(ctx context.Context, modID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "approveMod") + wrapper, ctx := WrapMutationTrace(ctx, "approveMod") defer wrapper.end() - dbMod := postgres.GetModByID(newCtx, modID) + dbMod := postgres.GetModByID(ctx, modID) if dbMod == nil { return false, errors.New("mod not found") @@ -255,7 +262,7 @@ func (r *mutationResolver) ApproveMod(ctx context.Context, modID string) (bool, dbMod.Approved = true - postgres.Save(newCtx, &dbMod) + postgres.Save(ctx, &dbMod) go integrations.NewMod(db.ReWrapCtx(ctx), dbMod) @@ -263,10 +270,10 @@ func (r *mutationResolver) ApproveMod(ctx context.Context, modID string) (bool, } func (r *mutationResolver) DenyMod(ctx context.Context, modID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "denyMod") + wrapper, ctx := WrapMutationTrace(ctx, "denyMod") defer wrapper.end() - dbMod := postgres.GetModByID(newCtx, modID) + dbMod := postgres.GetModByID(ctx, modID) if dbMod == nil { return false, errors.New("mod not found") @@ -274,21 +281,21 @@ func (r *mutationResolver) DenyMod(ctx context.Context, modID string) (bool, err dbMod.Denied = true - postgres.Save(newCtx, &dbMod) - postgres.Delete(newCtx, &dbMod) + postgres.Save(ctx, &dbMod) + postgres.Delete(ctx, &dbMod) return true, nil } func (r *queryResolver) GetMod(ctx context.Context, modID string) (*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getMod") + wrapper, ctx := WrapQueryTrace(ctx, "getMod") defer wrapper.end() - mod := postgres.GetModByID(newCtx, modID) + mod := postgres.GetModByID(ctx, modID) if mod != nil { if redis.CanIncrement(RealIP(ctx), "view", "mod:"+modID, time.Hour*4) { - postgres.IncrementModViews(newCtx, mod) + postgres.IncrementModViews(ctx, mod) } } @@ -296,14 +303,14 @@ func (r *queryResolver) GetMod(ctx context.Context, modID string) (*generated.Mo } func (r *queryResolver) GetModByReference(ctx context.Context, modReference string) (*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getModByReference") + wrapper, ctx := WrapQueryTrace(ctx, "getModByReference") defer wrapper.end() - mod := postgres.GetModByReference(newCtx, modReference) + mod := postgres.GetModByReference(ctx, modReference) if mod != nil { if redis.CanIncrement(RealIP(ctx), "view", "mod:"+mod.ID, time.Hour*4) { - postgres.IncrementModViews(newCtx, mod) + postgres.IncrementModViews(ctx, mod) } } @@ -337,7 +344,7 @@ func (r *queryResolver) GetMyUnapprovedMods(ctx context.Context, _ map[string]in type getModsResolver struct{ *Resolver } func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMods.mods") + wrapper, ctx := WrapQueryTrace(ctx, "GetMods.mods") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -352,7 +359,7 @@ func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*ge modFilter.AddField(field.Name) } - mods := postgres.GetModsNew(newCtx, modFilter, unapproved) + mods := postgres.GetModsNew(ctx, modFilter, unapproved) if mods == nil { return nil, errors.New("mods not found") @@ -367,7 +374,7 @@ func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*ge } func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMods.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetMods.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -382,13 +389,13 @@ func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, return len(modFilter.Ids), nil } - return int(postgres.GetModCountNew(newCtx, modFilter, unapproved)), nil + return int(postgres.GetModCountNew(ctx, modFilter, unapproved)), nil } type getMyModsResolver struct{ *Resolver } func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([]*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMyMods.mods") + wrapper, ctx := WrapQueryTrace(ctx, "GetMyMods.mods") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -406,9 +413,9 @@ func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([ var mods []postgres.Mod if modFilter.Ids == nil || len(modFilter.Ids) == 0 { - mods = postgres.GetModsNew(newCtx, modFilter, unapproved) + mods = postgres.GetModsNew(ctx, modFilter, unapproved) } else { - mods = postgres.GetModsByID(newCtx, modFilter.Ids) + mods = postgres.GetModsByID(ctx, modFilter.Ids) } if mods == nil { @@ -424,7 +431,7 @@ func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([ } func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMyMods.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetMyMods.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -439,7 +446,7 @@ func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) ( return len(modFilter.Ids), nil } - return int(postgres.GetModCountNew(newCtx, modFilter, unapproved)), nil + return int(postgres.GetModCountNew(ctx, modFilter, unapproved)), nil } type modResolver struct{ *Resolver } @@ -448,7 +455,7 @@ func (r *modResolver) Authors(ctx context.Context, obj *generated.Mod) ([]*gener wrapper, _ := WrapQueryTrace(ctx, "Mod.authors") defer wrapper.end() - authors, err := dataloader.For(ctx).UserModsByModID.Load(obj.ID) + authors, err := dataloader.For(ctx).UserModsByModID.Load(ctx, obj.ID)() if err != nil { return nil, err } @@ -470,9 +477,9 @@ func (r *modResolver) Authors(ctx context.Context, obj *generated.Mod) ([]*gener } func (r *modResolver) Version(ctx context.Context, obj *generated.Mod, version string) (*generated.Version, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "Mod.version") + wrapper, ctx := WrapQueryTrace(ctx, "Mod.version") defer wrapper.end() - return DBVersionToGenerated(postgres.GetModVersionByName(newCtx, obj.ID, version)), nil + return DBVersionToGenerated(postgres.GetModVersionByName(ctx, obj.ID, version)), nil } var versionNoMetaCache, _ = ristretto.NewCache(&ristretto.Config{ @@ -484,7 +491,7 @@ var versionNoMetaCache, _ = ristretto.NewCache(&ristretto.Config{ const versionNoMetaCacheTTL = time.Second * 30 func (r *modResolver) Versions(ctx context.Context, obj *generated.Mod, filter map[string]interface{}) ([]*generated.Version, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "Mod.versions") + wrapper, ctx := WrapQueryTrace(ctx, "Mod.versions") defer wrapper.end() versionFilter, err := models.ProcessVersionFilter(filter) @@ -501,18 +508,18 @@ func (r *modResolver) Versions(ctx context.Context, obj *generated.Mod, filter m } } - var versions []postgres.Version + var versions []*ent.Version if versionFilter == nil || versionFilter.IsDefault(true) { if hasMetadata { - versions, err = dataloader.For(ctx).VersionsByModID.Load(obj.ID) + versions, err = dataloader.For(ctx).VersionsByModID.Load(ctx, obj.ID)() } else { if cacheVersions, ok := versionNoMetaCache.Get(obj.ID); ok { - versions = cacheVersions.([]postgres.Version) + versions = cacheVersions.([]*ent.Version) } if versions == nil { - versions, err = dataloader.For(ctx).VersionsByModIDNoMeta.Load(obj.ID) + versions, err = dataloader.For(ctx).VersionsByModIDNoMeta.Load(ctx, obj.ID)() if err == nil && versions != nil { versionNoMetaCache.SetWithTTL(obj.ID, versions, int64(len(versions)), versionNoMetaCacheTTL) } @@ -527,42 +534,68 @@ func (r *modResolver) Versions(ctx context.Context, obj *generated.Mod, filter m versions = versions[:*versionFilter.Limit] } } else { - versions = postgres.GetModVersionsNew(newCtx, obj.ID, versionFilter, false) + query := db.From(ctx).Version.Query().WithTargets().Where( + version.Approved(true), + version.Denied(false), + version.ModID(obj.ID), + ) + + if filter != nil { + query = query.Limit(*versionFilter.Limit). + Offset(*versionFilter.Offset). + Order(sql.OrderByField( + versionFilter.OrderBy.String(), + db.OrderToOrder(versionFilter.Order.String()), + ).ToFunc()) + } + + versions, err = query.All(ctx) + if err != nil { + return nil, err + } } if versions == nil { return nil, errors.New("versions not found") } - converted := make([]*generated.Version, len(versions)) - for k, v := range versions { - converted[k] = DBVersionToGenerated(&v) - } - - return converted, nil + return (*conv.VersionImpl)(nil).ConvertSlice(versions), nil } func (r *modResolver) LatestVersions(ctx context.Context, obj *generated.Mod) (*generated.LatestVersions, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "Mod.latestVersions") + wrapper, ctx := WrapQueryTrace(ctx, "Mod.latestVersions") defer wrapper.end() - versions := postgres.GetModLatestVersions(newCtx, obj.ID, false) - - if versions == nil { - return nil, errors.New("versions not found") + versions, err := db.From(ctx).Version. + Query(). + WithTargets(). + Where( + version.ModID(obj.ID), + version.Approved(true), + version.Denied(false), + ). + Order( + version.ByModID(), + version.ByStability(), + version.ByCreatedAt(), + ). + Modify(func(s *sql.Selector) { + s.SelectExpr(sql.Expr("DISTINCT on (mod_id, stability) *")) + }). + All(ctx) + if err != nil { + return nil, err } - versionsD := *versions - converted := generated.LatestVersions{} - for _, v := range versionsD { + for _, v := range versions { switch v.Stability { - case string(generated.VersionStabilitiesAlpha): - converted.Alpha = DBVersionToGenerated(&v) - case string(generated.VersionStabilitiesBeta): - converted.Beta = DBVersionToGenerated(&v) - case string(generated.VersionStabilitiesRelease): - converted.Release = DBVersionToGenerated(&v) + case version.StabilityAlpha: + converted.Alpha = (*conv.VersionImpl)(nil).Convert(v) + case version.StabilityBeta: + converted.Beta = (*conv.VersionImpl)(nil).Convert(v) + case version.StabilityRelease: + converted.Release = (*conv.VersionImpl)(nil).Convert(v) } } @@ -570,22 +603,30 @@ func (r *modResolver) LatestVersions(ctx context.Context, obj *generated.Mod) (* } func (r *queryResolver) GetModByIDOrReference(ctx context.Context, modIDOrReference string) (*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getModByIdOrReference") + wrapper, ctx := WrapQueryTrace(ctx, "getModByIdOrReference") defer wrapper.end() - mod := postgres.GetModByIDOrReference(newCtx, modIDOrReference) + m, err := db.From(ctx).Mod.Query().Where(mod.Or( + mod.ID(modIDOrReference), + mod.ModReference(modIDOrReference), + )).First(ctx) + if err != nil { + return nil, err + } - if mod != nil { - if redis.CanIncrement(RealIP(ctx), "view", "mod:"+mod.ID, time.Hour*4) { - postgres.IncrementModViews(newCtx, mod) + if m != nil { + if redis.CanIncrement(RealIP(ctx), "view", "mod:"+m.ID, time.Hour*4) { + if err := m.Update().AddViews(1).Exec(ctx); err != nil { + slox.Error(ctx, "failed incrementing mod views", slog.Any("err", err)) + } } } - return DBModToGenerated(mod), nil + return (*conv.ModImpl)(nil).Convert(m), nil } func (r *queryResolver) ResolveModVersions(ctx context.Context, filter []*generated.ModVersionConstraint) ([]*generated.ModVersion, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "resolveModVersions") + wrapper, ctx := WrapQueryTrace(ctx, "resolveModVersions") defer wrapper.end() constraintMapping := make(map[string]string) @@ -595,7 +636,7 @@ func (r *queryResolver) ResolveModVersions(ctx context.Context, filter []*genera constraintMapping[constraint.ModIDOrReference] = constraint.Version } - mods := postgres.GetModsByIDOrReference(newCtx, modIDOrReferences) + mods := postgres.GetModsByIDOrReference(ctx, modIDOrReferences) if mods == nil { return nil, errors.New("no mods found") @@ -608,7 +649,7 @@ func (r *queryResolver) ResolveModVersions(ctx context.Context, filter []*genera constraint = constraintMapping[mod.ModReference] } - versions := postgres.GetModVersionsConstraint(newCtx, mod.ID, constraint) + versions := postgres.GetModVersionsConstraint(ctx, mod.ID, constraint) converted := make([]*generated.Version, len(versions)) for k, v := range versions { diff --git a/gql/resolver_oauth.go b/gql/resolver_oauth.go index 9aab4eef..2df28efd 100644 --- a/gql/resolver_oauth.go +++ b/gql/resolver_oauth.go @@ -9,8 +9,10 @@ import ( "github.com/pkg/errors" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/user" "github.com/satisfactorymodding/smr-api/oauth" "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/util" @@ -35,14 +37,14 @@ func (r *queryResolver) GetOAuthOptions(ctx context.Context, callbackURL string) } func (r *mutationResolver) OAuthGithub(ctx context.Context, code string, state string) (*generated.UserSession, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "oAuthGithub") + wrapper, ctx := WrapMutationTrace(ctx, "oAuthGithub") defer wrapper.end() if code == "" { return nil, errors.New("invalid oauth code") } - user, err := oauth.GithubCallback(code, state) + u, err := oauth.GithubCallback(code, state) if err != nil { return nil, err } @@ -50,7 +52,7 @@ func (r *mutationResolver) OAuthGithub(ctx context.Context, code string, state s header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(newCtx, user, userAgent) + token, err := completeOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -61,14 +63,14 @@ func (r *mutationResolver) OAuthGithub(ctx context.Context, code string, state s } func (r *mutationResolver) OAuthGoogle(ctx context.Context, code string, state string) (*generated.UserSession, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "oAuthGoogle") + wrapper, ctx := WrapMutationTrace(ctx, "oAuthGoogle") defer wrapper.end() if code == "" { return nil, errors.New("invalid oauth code") } - user, err := oauth.GoogleCallback(code, state) + u, err := oauth.GoogleCallback(code, state) if err != nil { return nil, err } @@ -76,7 +78,7 @@ func (r *mutationResolver) OAuthGoogle(ctx context.Context, code string, state s header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(newCtx, user, userAgent) + token, err := completeOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -87,14 +89,14 @@ func (r *mutationResolver) OAuthGoogle(ctx context.Context, code string, state s } func (r *mutationResolver) OAuthFacebook(ctx context.Context, code string, state string) (*generated.UserSession, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "oAuthFacebook") + wrapper, ctx := WrapMutationTrace(ctx, "oAuthFacebook") defer wrapper.end() if code == "" { return nil, errors.New("invalid oauth code") } - user, err := oauth.FacebookCallback(code, state) + u, err := oauth.FacebookCallback(code, state) if err != nil { return nil, err } @@ -102,7 +104,7 @@ func (r *mutationResolver) OAuthFacebook(ctx context.Context, code string, state header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(newCtx, user, userAgent) + token, err := completeOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -112,11 +114,79 @@ func (r *mutationResolver) OAuthFacebook(ctx context.Context, code string, state }, nil } -func completeOAuthFlow(ctx context.Context, user *oauth.UserData, userAgent string) (*string, error) { - avatarURL := user.Avatar - user.Avatar = "" +func completeOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string) (*string, error) { + avatarURL := u.Avatar + u.Avatar = "" - session, dbUser, newUser := postgres.GetUserSession(ctx, user, userAgent) + find := db.From(ctx).User.Query().Where(user.Email(u.Email)) + + if u.Site == oauth.SiteGithub { + find = find.Where(user.GithubID(u.ID)) + } else if u.Site == oauth.SiteGoogle { + find = find.Where(user.GoogleID(u.ID)) + } else if u.Site == oauth.SiteFacebook { + find = find.Where(user.FacebookID(u.ID)) + } + + found, err := find.First(ctx) + if err != nil && !ent.IsNotFound(err) { + return nil, err + } + + newUser := false + if ent.IsNotFound(err) { + var err error + create := db.From(ctx).User. + Create(). + SetEmail(u.Email). + SetAvatar(u.Avatar). + SetJoinedFrom(string(u.Site)). + SetUsername(u.Username) + + if u.Site == oauth.SiteGithub { + create = create.SetGithubID(u.ID) + } else if u.Site == oauth.SiteGoogle { + create = create.SetGoogleID(u.ID) + } else if u.Site == oauth.SiteFacebook { + create = create.SetFacebookID(u.ID) + } + + found, err = create.Save(ctx) + if err != nil { + return nil, err + } + + newUser = true + } + + if !newUser { + var update *ent.UserUpdateOne + if u.Site == oauth.SiteGithub && found.GithubID == "" { + update = found.Update().SetGithubID(u.ID) + } else if u.Site == oauth.SiteGoogle && found.GoogleID == "" { + update = found.Update().SetGoogleID(u.ID) + } else if u.Site == oauth.SiteFacebook && found.FacebookID == "" { + update = found.Update().SetFacebookID(u.ID) + } + + if update != nil { + if err := update.Exec(ctx); err != nil { + return nil, err + } + } + } + + // TODO Archive old deleted sessions to cold storage + + session, err := db.From(ctx).UserSession. + Create(). + SetUserID(found.ID). + SetToken(util.GenerateUserToken()). + SetUserAgent(userAgent). + Save(ctx) + if err != nil { + return nil, err + } if avatarURL != "" && newUser { avatarData, err := util.LinkToWebp(ctx, avatarURL) @@ -124,10 +194,11 @@ func completeOAuthFlow(ctx context.Context, user *oauth.UserData, userAgent stri return nil, err } - success, avatarKey := storage.UploadUserAvatar(ctx, session.UserID, bytes.NewReader(avatarData)) + success, avatarKey := storage.UploadUserAvatar(ctx, found.ID, bytes.NewReader(avatarData)) if success { - dbUser.Avatar = storage.GenerateDownloadLink(avatarKey) - postgres.Save(ctx, &dbUser) + if err := found.Update().SetAvatar(storage.GenerateDownloadLink(avatarKey)).Exec(ctx); err != nil { + return nil, err + } } } diff --git a/gql/resolver_sml_versions.go b/gql/resolver_sml_versions.go index b6d7d37d..220dcc02 100644 --- a/gql/resolver_sml_versions.go +++ b/gql/resolver_sml_versions.go @@ -211,7 +211,7 @@ func (r *getSMLVersionsResolver) SmlVersions(ctx context.Context, _ *generated.G } query := db.From(ctx).SmlVersion.Query().WithTargets() - query = convertFilter(query, smlVersionFilter) + query = convertSMLVersionFilter(query, smlVersionFilter) result, err := query.All(ctx) if err != nil { @@ -232,7 +232,7 @@ func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLV } query := db.From(ctx).SmlVersion.Query().WithTargets() - query = convertFilter(query, smlVersionFilter) + query = convertSMLVersionFilter(query, smlVersionFilter) result, err := query.Count(ctx) if err != nil { @@ -242,7 +242,7 @@ func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLV return result, nil } -func convertFilter(query *ent.SmlVersionQuery, filter *models.SMLVersionFilter) *ent.SmlVersionQuery { +func convertSMLVersionFilter(query *ent.SmlVersionQuery, filter *models.SMLVersionFilter) *ent.SmlVersionQuery { if len(filter.Ids) > 0 { query = query.Where(smlversion.IDIn(filter.Ids...)) } else if filter != nil { @@ -253,6 +253,7 @@ func convertFilter(query *ent.SmlVersionQuery, filter *models.SMLVersionFilter) filter.OrderBy.String(), db.OrderToOrder(filter.Order.String()), ).ToFunc()) + if filter.Search != nil && *filter.Search != "" { query = query.Modify(func(s *sql.Selector) { s.Where(sql.ExprP("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & "))) diff --git a/gql/resolver_tags.go b/gql/resolver_tags.go index 08d618fe..0f093eb8 100644 --- a/gql/resolver_tags.go +++ b/gql/resolver_tags.go @@ -1,107 +1,136 @@ package gql import ( + "strings" + + "entgo.io/ent/dialect/sql" + "github.com/finnbear/moderation" "github.com/pkg/errors" "golang.org/x/net/context" - "github.com/satisfactorymodding/smr-api/db/postgres" + "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/tag" ) func (r *mutationResolver) CreateTag(ctx context.Context, tagName string, description string) (*generated.Tag, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createTag") + wrapper, ctx := WrapMutationTrace(ctx, "createTag") defer wrapper.end() - dbTag := &postgres.Tag{ - Name: tagName, - Description: description, + if err := ValidateTagName(tagName); err != nil { + return nil, err } - resultTag, err := postgres.CreateTag(newCtx, dbTag, true) + result, err := db.From(ctx).Tag.Create().SetName(tagName).Save(ctx) if err != nil { return nil, err } - return DBTagToGenerated(resultTag), nil + + return (*conv.TagImpl)(nil).Convert(result), nil } func (r *mutationResolver) CreateMultipleTags(ctx context.Context, tags []*generated.NewTag) ([]*generated.Tag, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createMultipleTags") + wrapper, ctx := WrapMutationTrace(ctx, "createMultipleTags") defer wrapper.end() - resultTags := make([]postgres.Tag, len(tags)) - - for i, tag := range tags { - dbTag := &postgres.Tag{ - Name: tag.Name, - Description: tag.Description, - } - - resultTag, err := postgres.CreateTag(newCtx, dbTag, false) - if err != nil { + for _, t := range tags { + if err := ValidateTagName(t.Name); err != nil { return nil, err } + } - resultTags[i] = *resultTag + result, err := db.From(ctx).Tag.MapCreateBulk(tagNames, func(create *ent.TagCreate, i int) { + create.SetName(tagNames[i]) + }).Save(ctx) + if err != nil { + return nil, err } - return DBTagsToGeneratedSlice(resultTags), nil + return (*conv.TagImpl)(nil).ConvertSlice(result), nil } func (r *mutationResolver) DeleteTag(ctx context.Context, id string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteTag") + wrapper, ctx := WrapMutationTrace(ctx, "deleteTag") defer wrapper.end() - dbTag := postgres.GetTagByID(newCtx, id) - - if dbTag == nil { - return false, errors.New("Tag not found") + if err := db.From(ctx).Tag.DeleteOneID(id).Exec(ctx); err != nil { + return false, err } - postgres.Delete(newCtx, &dbTag) - return true, nil } func (r *mutationResolver) UpdateTag(ctx context.Context, id string, newName string, description string) (*generated.Tag, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateTag") + wrapper, ctx := WrapMutationTrace(ctx, "updateTag") defer wrapper.end() - dbTag := postgres.GetTagByID(newCtx, id) - - if dbTag == nil { - return nil, errors.New("Tag not found") + if err := ValidateTagName(newName); err != nil { + return nil, err } - err := postgres.ValidateTagName(dbTag.Name) + update := db.From(ctx).Tag.UpdateOneID(id) + + SetINNOEF(&newName, update.SetName) + + result, err := update.SetName(newName).Save(ctx) if err != nil { return nil, err } - SetStringINNOE(&newName, &dbTag.Name) - SetStringINNOE(&description, &dbTag.Description) - - postgres.Save(newCtx, &dbTag) - - return DBTagToGenerated(dbTag), nil + return (*conv.TagImpl)(nil).Convert(result), nil } func (r *queryResolver) GetTag(ctx context.Context, id string) (*generated.Tag, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getTag_"+id) + wrapper, ctx := WrapQueryTrace(ctx, "getTag") defer wrapper.end() - tag := postgres.GetTagByID(newCtx, id) + result, err := db.From(ctx).Tag.Get(ctx, id) + if err != nil { + return nil, err + } - return DBTagToGenerated(tag), nil + return (*conv.TagImpl)(nil).Convert(result), nil } func (r *queryResolver) GetTags(ctx context.Context, filter *generated.TagFilter) ([]*generated.Tag, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getTags") + wrapper, ctx := WrapQueryTrace(ctx, "getTags") defer wrapper.end() insertFilterDefaults(&filter) - tags := postgres.GetTags(newCtx, filter) - return DBTagsToGeneratedSlice(tags), nil + query := db.From(ctx).Tag.Query() + + if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset). + Order(sql.OrderByField( + tag.FieldName, + db.OrderToOrder(filter.Order.String()), + ).ToFunc()) + + if filter.Search != nil && *filter.Search != "" { + cleanSearch := strings.ReplaceAll(strings.TrimSpace(*filter.Search), " ", " & ") + + query = query.Modify(func(s *sql.Selector) { + s.AppendSelectExpr(sql.Expr("similarity(name, ?) as s", cleanSearch)) + s.Where(sql.ExprP("s > 0.2")) + }).Clone() + } + + if filter.Ids != nil && len(filter.Ids) > 0 { + query.Where(tag.IDIn(filter.Ids...)) + } + } + + result, err := query.All(ctx) + if err != nil { + return nil, err + } + + return (*conv.TagImpl)(nil).ConvertSlice(result), nil } func insertFilterDefaults(filter **generated.TagFilter) { @@ -122,3 +151,16 @@ func insertFilterDefaults(filter **generated.TagFilter) { inner.Order = &Order } } + +func ValidateTagName(tag string) error { + if len(tag) > 24 { + return errors.New("Tag name is over 24 characters long") + } + if len(tag) < 3 { + return errors.New("Tag name is under 3 characters long") + } + if moderation.IsInappropriate(tag) { + return errors.New("Tag name is inapproriate") + } + return nil +} diff --git a/gql/resolver_users.go b/gql/resolver_users.go index 30489e04..ef213f7c 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -18,24 +18,31 @@ import ( "github.com/satisfactorymodding/smr-api/auth" "github.com/satisfactorymodding/smr-api/dataloader" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db/schema" "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/guide" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usergroup" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/util" "github.com/satisfactorymodding/smr-api/util/converter" ) func (r *mutationResolver) UpdateUser(ctx context.Context, userID string, input generated.UpdateUser) (*generated.User, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateUser") + wrapper, ctx := WrapMutationTrace(ctx, "updateUser") defer wrapper.end() - dbUser := postgres.GetUserByID(newCtx, userID) - - if dbUser == nil { - return nil, errors.New("user not found") + u, err := db.From(ctx).User.Get(ctx, userID) + if err != nil { + return nil, err } + update := u.Update() if input.Avatar != nil { file, err := io.ReadAll(input.Avatar.File) if err != nil { @@ -47,14 +54,78 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, userID string, input return nil, err } - success, avatarKey := storage.UploadUserAvatar(ctx, dbUser.ID, bytes.NewReader(avatarData)) + success, avatarKey := storage.UploadUserAvatar(ctx, u.ID, bytes.NewReader(avatarData)) if success { - dbUser.Avatar = storage.GenerateDownloadLink(avatarKey) + update = update.SetAvatar(storage.GenerateDownloadLink(avatarKey)) } } if input.Groups != nil { - dbUser.SetGroups(newCtx, input.Groups) + currentGroups, err := db.From(ctx).UserGroup. + Query(). + Where(usergroup.UserID(u.ID)). + All(schema.SkipSoftDelete(ctx)) + if err != nil { + return nil, err + } + + err = db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { + for _, group := range input.Groups { + if auth.GetGroupByID(group) == nil { + continue + } + + found := false + var deleted *ent.UserGroup + for _, currentGroup := range currentGroups { + if group == currentGroup.GroupID { + found = true + if currentGroup.DeletedAt.IsZero() { + deleted = currentGroup + } + break + } + } + + if !found { + if err := tx.UserGroup. + Create(). + SetUserID(u.ID). + SetGroupID(group). + Exec(ctx); err != nil { + return err + } + } else if deleted != nil { + if err := deleted.Update().ClearDeletedAt().Exec(schema.SkipSoftDelete(ctx)); err != nil { + return err + } + } + } + + for _, currentGroup := range currentGroups { + found := false + for _, group := range input.Groups { + if group == currentGroup.GroupID { + found = true + break + } + } + + if !found { + if _, err := tx.UserGroup.Delete().Where( + usergroup.UserID(u.ID), + usergroup.GroupID(currentGroup.GroupID), + ).Exec(ctx); err != nil { + return err + } + } + } + + return nil + }, nil) + if err != nil { + return nil, err + } } if input.Username != nil { @@ -62,24 +133,32 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, userID string, input return nil, errors.New("username must be at least 3 characters long") } - dbUser.Username = *input.Username - - if len(dbUser.Username) > 32 { - dbUser.Username = dbUser.Username[:32] + newUsername := *input.Username + if len(newUsername) > 32 { + newUsername = newUsername[:32] } + + update = update.SetUsername(newUsername) } - postgres.Save(newCtx, &dbUser) + result, err := update.Save(ctx) + if err != nil { + return nil, err + } - return DBUserToGenerated(dbUser), nil + return (*conv.UserImpl)(nil).Convert(result), nil } func (r *mutationResolver) Logout(ctx context.Context) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "logout") + wrapper, ctx := WrapMutationTrace(ctx, "logout") defer wrapper.end() header := ctx.Value(util.ContextHeader{}).(http.Header) - postgres.LogoutSession(newCtx, header.Get("Authorization")) + + // TODO Archive old deleted sessions to cold storage + if _, err := db.From(ctx).UserSession.Delete().Where(usersession.Token(header.Get("Authorization"))).Exec(ctx); err != nil { + return false, err + } return true, nil } @@ -88,90 +167,78 @@ func (r *queryResolver) GetMe(ctx context.Context) (*generated.User, error) { wrapper, ctx := WrapQueryTrace(ctx, "getMe") defer wrapper.end() - user, err := db.UserFromGQLContext(ctx) + result, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - return (*conv.UserImpl)(nil).Convert(user), nil + return (*conv.UserImpl)(nil).Convert(result), nil } func (r *queryResolver) GetUser(ctx context.Context, userID string) (*generated.User, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getUser") + wrapper, ctx := WrapQueryTrace(ctx, "getUser") defer wrapper.end() - return DBUserToGenerated(postgres.GetUserByID(newCtx, userID)), nil + + result, err := db.From(ctx).User.Get(ctx, userID) + if err != nil { + return nil, err + } + + return (*conv.UserImpl)(nil).Convert(result), nil } func (r *queryResolver) GetUsers(ctx context.Context, userIds []string) ([]*generated.User, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getUsers") + wrapper, ctx := WrapQueryTrace(ctx, "getUsers") defer wrapper.end() - users := postgres.GetUsersByID(newCtx, userIds) - - if users == nil { - return nil, errors.New("users not found") - } - - converted := make([]*generated.User, len(*users)) - for k, v := range *users { - converted[k] = DBUserToGenerated(&v) + result, err := db.From(ctx).User.Query().Where(user.IDIn(userIds...)).All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.UserImpl)(nil).ConvertSlice(result), nil } type userResolver struct{ *Resolver } func (r *userResolver) Mods(ctx context.Context, obj *generated.User) ([]*generated.UserMod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "User.mods") + wrapper, ctx := WrapQueryTrace(ctx, "User.mods") defer wrapper.end() - mods := postgres.GetUserMods(newCtx, obj.ID) - - if mods == nil { - return []*generated.UserMod{}, nil - } - - converted := make([]*generated.UserMod, len(mods)) - for k, v := range mods { - converted[k] = &generated.UserMod{ - UserID: v.UserID, - ModID: v.ModID, - Role: v.Role, - } + result, err := db.From(ctx).UserMod. + Query(). + Where(usermod.UserID(obj.ID)). + Where(usermod.HasModWith(mod.DeletedAtIsNil())). + All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.UserModImpl)(nil).ConvertSlice(result), nil } func (r *userResolver) Guides(ctx context.Context, obj *generated.User) ([]*generated.Guide, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "User.guides") + wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - guides := postgres.GetUserGuides(newCtx, obj.ID) - - if guides == nil { - return nil, errors.New("guides not found") - } - - converted := make([]*generated.Guide, len(guides)) - for k, v := range guides { - converted[k] = DBGuideToGenerated(&v) + result, err := db.From(ctx).Guide.Query().Where(guide.UserID(obj.ID)).WithTags().All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.GuideImpl)(nil).ConvertSlice(result), nil } func (r *userResolver) Groups(ctx context.Context, _ *generated.User) ([]*generated.Group, error) { wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - user, err := db.UserFromGQLContext(ctx) + u, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - groups, err := user.QueryGroups().All(ctx) + groups, err := u.QueryGroups().All(ctx) if err != nil { return nil, err } @@ -192,12 +259,12 @@ func (r *userResolver) Roles(ctx context.Context, _ *generated.User) (*generated wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - user, err := db.UserFromGQLContext(ctx) + u, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - groups, err := user.QueryGroups().All(ctx) + groups, err := u.QueryGroups().All(ctx) if err != nil { return nil, err } @@ -254,29 +321,24 @@ func (r *userModResolver) User(ctx context.Context, obj *generated.UserMod) (*ge wrapper, _ := WrapQueryTrace(ctx, "UserMod.user") defer wrapper.end() - user, err := dataloader.For(ctx).UserByID.Load(obj.UserID) + result, err := dataloader.For(ctx).UserByID.Load(ctx, obj.UserID)() if err != nil { return nil, err } - if user == nil { - return nil, errors.New("user not found") - } - - return DBUserToGenerated(user), nil + return (*conv.UserImpl)(nil).Convert(result), nil } func (r *userModResolver) Mod(ctx context.Context, obj *generated.UserMod) (*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "UserMod.mod") + wrapper, ctx := WrapQueryTrace(ctx, "UserMod.mod") defer wrapper.end() - mod := postgres.GetModByID(newCtx, obj.ModID) - - if mod == nil { - return nil, errors.New("mod not found") + result, err := db.From(ctx).Mod.Get(ctx, obj.ModID) + if err != nil { + return nil, err } - return DBModToGenerated(mod), nil + return (*conv.ModImpl)(nil).Convert(result), nil } func (r *mutationResolver) DiscourseSso(ctx context.Context, sso string, sig string) (*string, error) { @@ -295,16 +357,16 @@ func (r *mutationResolver) DiscourseSso(ctx context.Context, sso string, sig str return nil, fmt.Errorf("failed to decode sso: %w", err) } - user, err := db.UserFromGQLContext(ctx) + u, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - if user == nil { + if u == nil { return nil, errors.New("user not logged in") } - rawResult := string(nonceString) + "&username=" + user.Username + "&email=" + url.QueryEscape(user.Email) + "&external_id=" + user.ID + rawResult := string(nonceString) + "&username=" + u.Username + "&email=" + url.QueryEscape(u.Email) + "&external_id=" + u.ID encodedResult := base64.StdEncoding.EncodeToString([]byte(rawResult)) escapedResult := url.QueryEscape(encodedResult) diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index b71cc793..2abda30c 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -4,6 +4,8 @@ import ( "bytes" "context" "fmt" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent" "io" "log/slog" "runtime/debug" @@ -26,10 +28,10 @@ import ( ) func (r *mutationResolver) CreateVersion(ctx context.Context, modID string) (string, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createVersion") + wrapper, ctx := WrapMutationTrace(ctx, "createVersion") defer wrapper.end() - mod := postgres.GetModByID(newCtx, modID) + mod := postgres.GetModByID(ctx, modID) if mod == nil { return "", errors.New("mod not found") @@ -51,14 +53,14 @@ func (r *mutationResolver) CreateVersion(ctx context.Context, modID string) (str } func (r *mutationResolver) UploadVersionPart(ctx context.Context, modID string, versionID string, part int, file graphql.Upload) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "createVersion") + wrapper, ctx := WrapMutationTrace(ctx, "createVersion") defer wrapper.end() if part > 100 { return false, errors.New("files can consist of max 41 chunks") } - mod := postgres.GetModByID(newCtx, modID) + mod := postgres.GetModByID(ctx, modID) if mod == nil { return false, errors.New("mod not found") @@ -84,10 +86,10 @@ func (r *mutationResolver) UploadVersionPart(ctx context.Context, modID string, } func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID string, versionID string, version generated.NewVersion) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "finalizeCreateVersion") + wrapper, ctx := WrapMutationTrace(ctx, "finalizeCreateVersion") defer wrapper.end() - mod := postgres.GetModByID(newCtx, modID) + mod := postgres.GetModByID(ctx, modID) if mod == nil { return false, errors.New("mod not found") @@ -101,9 +103,9 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri return false, errors.New("you must update your mod reference on the site to match your mod_reference in your data.json") } - newCtx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) + ctx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) - slox.Info(newCtx, "finalization gql call") + slox.Info(ctx, "finalization gql call") go func(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) { defer func() { @@ -137,10 +139,10 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri } func (r *mutationResolver) UpdateVersion(ctx context.Context, versionID string, version generated.UpdateVersion) (*generated.Version, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "updateVersion") + wrapper, ctx := WrapMutationTrace(ctx, "updateVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(newCtx, versionID) + dbVersion := postgres.GetVersion(ctx, versionID) if dbVersion == nil { return nil, errors.New("version not found") @@ -149,31 +151,31 @@ func (r *mutationResolver) UpdateVersion(ctx context.Context, versionID string, SetStringINNOE(version.Changelog, &dbVersion.Changelog) SetStabilityINN(version.Stability, &dbVersion.Stability) - postgres.Save(newCtx, &dbVersion) + postgres.Save(ctx, &dbVersion) return DBVersionToGenerated(dbVersion), nil } func (r *mutationResolver) DeleteVersion(ctx context.Context, versionID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "deleteVersion") + wrapper, ctx := WrapMutationTrace(ctx, "deleteVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(newCtx, versionID) + dbVersion := postgres.GetVersion(ctx, versionID) if dbVersion == nil { return false, errors.New("version not found") } - postgres.Delete(newCtx, &dbVersion) + postgres.Delete(ctx, &dbVersion) return true, nil } func (r *mutationResolver) ApproveVersion(ctx context.Context, versionID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "approveVersion") + wrapper, ctx := WrapMutationTrace(ctx, "approveVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(newCtx, versionID) + dbVersion := postgres.GetVersion(ctx, versionID) if dbVersion == nil { return false, errors.New("version not found") @@ -181,12 +183,12 @@ func (r *mutationResolver) ApproveVersion(ctx context.Context, versionID string) dbVersion.Approved = true - postgres.Save(newCtx, &dbVersion) + postgres.Save(ctx, &dbVersion) - mod := postgres.GetModByID(newCtx, dbVersion.ModID) + mod := postgres.GetModByID(ctx, dbVersion.ModID) now := time.Now() mod.LastVersionDate = &now - postgres.Save(newCtx, &mod) + postgres.Save(ctx, &mod) go integrations.NewVersion(db.ReWrapCtx(ctx), dbVersion) @@ -194,10 +196,10 @@ func (r *mutationResolver) ApproveVersion(ctx context.Context, versionID string) } func (r *mutationResolver) DenyVersion(ctx context.Context, versionID string) (bool, error) { - wrapper, newCtx := WrapMutationTrace(ctx, "denyVersion") + wrapper, ctx := WrapMutationTrace(ctx, "denyVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(newCtx, versionID) + dbVersion := postgres.GetVersion(ctx, versionID) if dbVersion == nil { return false, errors.New("version not found") @@ -205,19 +207,19 @@ func (r *mutationResolver) DenyVersion(ctx context.Context, versionID string) (b dbVersion.Denied = true - postgres.Save(newCtx, &dbVersion) - postgres.Delete(newCtx, &dbVersion) + postgres.Save(ctx, &dbVersion) + postgres.Delete(ctx, &dbVersion) - mod := postgres.GetModByID(newCtx, dbVersion.ModID) - postgres.Save(newCtx, &mod) + mod := postgres.GetModByID(ctx, dbVersion.ModID) + postgres.Save(ctx, &mod) return true, nil } func (r *queryResolver) GetVersion(ctx context.Context, versionID string) (*generated.Version, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "getVersion") + wrapper, ctx := WrapQueryTrace(ctx, "getVersion") defer wrapper.end() - return DBVersionToGenerated(postgres.GetVersion(newCtx, versionID)), nil + return DBVersionToGenerated(postgres.GetVersion(ctx, versionID)), nil } func (r *queryResolver) GetVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetVersions, error) { @@ -245,10 +247,10 @@ func (r *queryResolver) GetMyUnapprovedVersions(ctx context.Context, _ map[strin } func (r *queryResolver) CheckVersionUploadState(ctx context.Context, modID string, versionID string) (*generated.CreateVersionResponse, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "checkVersionUploadState") + wrapper, ctx := WrapQueryTrace(ctx, "checkVersionUploadState") defer wrapper.end() - mod := postgres.GetModByID(newCtx, modID) + mod := postgres.GetModByID(ctx, modID) if mod == nil { return nil, errors.New("mod not found") @@ -268,7 +270,7 @@ func (r *queryResolver) CheckVersionUploadState(ctx context.Context, modID strin type getVersionsResolver struct{ *Resolver } func (r *getVersionsResolver) Versions(ctx context.Context, _ *generated.GetVersions) ([]*generated.Version, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetVersions.versions") + wrapper, ctx := WrapQueryTrace(ctx, "GetVersions.versions") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -286,9 +288,9 @@ func (r *getVersionsResolver) Versions(ctx context.Context, _ *generated.GetVers var versions []postgres.Version if versionFilter.Ids == nil || len(versionFilter.Ids) == 0 { - versions = postgres.GetVersionsNew(newCtx, versionFilter, unapproved) + versions = postgres.GetVersionsNew(ctx, versionFilter, unapproved) } else { - versions = postgres.GetVersionsByID(newCtx, versionFilter.Ids) + versions = postgres.GetVersionsByID(ctx, versionFilter.Ids) } if versions == nil { @@ -304,7 +306,7 @@ func (r *getVersionsResolver) Versions(ctx context.Context, _ *generated.GetVers } func (r *getVersionsResolver) Count(ctx context.Context, _ *generated.GetVersions) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetVersions.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetVersions.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -319,7 +321,7 @@ func (r *getVersionsResolver) Count(ctx context.Context, _ *generated.GetVersion return len(versionFilter.Ids), nil } - return int(postgres.GetVersionCountNew(newCtx, versionFilter, unapproved)), nil + return int(postgres.GetVersionCountNew(ctx, versionFilter, unapproved)), nil } type versionResolver struct{ *Resolver } @@ -349,10 +351,10 @@ func (r *versionResolver) Link(ctx context.Context, obj *generated.Version) (str } func (r *versionResolver) Mod(ctx context.Context, obj *generated.Version) (*generated.Mod, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "Version.mod") + wrapper, ctx := WrapQueryTrace(ctx, "Version.mod") defer wrapper.end() - return DBModToGenerated(postgres.GetModByID(newCtx, obj.ModID)), nil + return DBModToGenerated(postgres.GetModByID(ctx, obj.ModID)), nil } func (r *versionResolver) Hash(ctx context.Context, obj *generated.Version) (*string, error) { @@ -408,18 +410,18 @@ var versionDependencyCache, _ = ristretto.NewCache(&ristretto.Config{ const versionDependencyCacheTTL = time.Minute * 10 func (r *versionResolver) Dependencies(ctx context.Context, obj *generated.Version) ([]*generated.VersionDependency, error) { - wrapper, _ := WrapQueryTrace(ctx, "Version.dependencies") + wrapper, ctx := WrapQueryTrace(ctx, "Version.dependencies") defer wrapper.end() - var dependencies []postgres.VersionDependency + var dependencies []*ent.VersionDependency if cacheVersions, ok := versionDependencyCache.Get(obj.ID); ok { - dependencies = cacheVersions.([]postgres.VersionDependency) + dependencies = cacheVersions.([]*ent.VersionDependency) } if dependencies == nil { var err error - dependencies, err = dataloader.For(ctx).VersionDependenciesByVersionID.Load(obj.ID) + dependencies, err = dataloader.For(ctx).VersionDependenciesByVersionID.Load(ctx, obj.ID)() if err != nil { return nil, err @@ -428,12 +430,7 @@ func (r *versionResolver) Dependencies(ctx context.Context, obj *generated.Versi versionDependencyCache.SetWithTTL(obj.ID, dependencies, int64(len(dependencies)), versionDependencyCacheTTL) } - converted := make([]*generated.VersionDependency, len(dependencies)) - for k, v := range dependencies { - converted[k] = DBVersionDependencyToGenerated(&v) - } - - return converted, nil + return (*conv.VersionDependencyImpl)(nil).ConvertSlice(dependencies), nil } type versionTargetResolver struct{ *Resolver } @@ -445,7 +442,7 @@ func (r *versionTargetResolver) Link(_ context.Context, obj *generated.VersionTa type getMyVersionsResolver struct{ *Resolver } func (r *getMyVersionsResolver) Versions(ctx context.Context, _ *generated.GetMyVersions) ([]*generated.Version, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMyVersions.versions") + wrapper, ctx := WrapQueryTrace(ctx, "GetMyVersions.versions") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -463,9 +460,9 @@ func (r *getMyVersionsResolver) Versions(ctx context.Context, _ *generated.GetMy var versions []postgres.Version if versionFilter.Ids == nil || len(versionFilter.Ids) == 0 { - versions = postgres.GetVersionsNew(newCtx, versionFilter, unapproved) + versions = postgres.GetVersionsNew(ctx, versionFilter, unapproved) } else { - versions = postgres.GetVersionsByID(newCtx, versionFilter.Ids) + versions = postgres.GetVersionsByID(ctx, versionFilter.Ids) } if versions == nil { @@ -481,7 +478,7 @@ func (r *getMyVersionsResolver) Versions(ctx context.Context, _ *generated.GetMy } func (r *getMyVersionsResolver) Count(ctx context.Context, _ *generated.GetMyVersions) (int, error) { - wrapper, newCtx := WrapQueryTrace(ctx, "GetMyVersions.count") + wrapper, ctx := WrapQueryTrace(ctx, "GetMyVersions.count") defer wrapper.end() resolverContext := graphql.GetFieldContext(ctx) @@ -496,5 +493,5 @@ func (r *getMyVersionsResolver) Count(ctx context.Context, _ *generated.GetMyVer return len(versionFilter.Ids), nil } - return int(postgres.GetVersionCountNew(newCtx, versionFilter, unapproved)), nil + return int(postgres.GetVersionCountNew(ctx, versionFilter, unapproved)), nil } diff --git a/gql/versions.go b/gql/versions.go index 34138cda..15ba473f 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/spf13/viper" "io" "log/slog" "time" @@ -24,16 +25,18 @@ import ( func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) (*generated.CreateVersionResponse, error) { ctx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) - slox.Info(ctx, "Creating multipart upload") + slox.Info(ctx, "Completing multipart upload") success, _ := storage.CompleteUploadMultipartMod(ctx, mod.ID, mod.Name, versionID) if !success { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "failed uploading mod") return nil, errors.New("failed uploading mod") } modFile, err := storage.GetMod(mod.ID, mod.Name, versionID) if err != nil { + slox.Error(ctx, "failed getting mod", slog.Any("err", err)) storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) return nil, err } @@ -42,27 +45,32 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI fileData, err := io.ReadAll(modFile) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "failed reading mod file", slog.Any("err", err)) return nil, fmt.Errorf("failed reading mod file: %w", err) } modInfo, err := validation.ExtractModInfo(ctx, fileData, true, true, mod.ModReference) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "failed extracting mod info", slog.Any("err", err)) return nil, fmt.Errorf("failed extracting mod info: %w", err) } if modInfo.ModReference != mod.ModReference { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "data.json mod_reference does not match mod reference", slog.Any("err", err)) return nil, errors.New("data.json mod_reference does not match mod reference") } if modInfo.Type == validation.DataJSON { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "data.json mods are obsolete and not allowed", slog.Any("err", err)) return nil, errors.New("data.json mods are obsolete and not allowed") } if modInfo.Type == validation.MultiTargetUEPlugin && !util.FlagEnabled(util.FeatureFlagAllowMultiTargetUpload) { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) + slox.Error(ctx, "multi-target mods are not allowed", slog.Any("err", err)) return nil, errors.New("multi-target mods are not allowed") } @@ -92,6 +100,8 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI } } + autoApproved = autoApproved || viper.GetBool("skip-virus-check") + dbVersion.Approved = autoApproved err = postgres.CreateVersion(ctx, dbVersion) @@ -166,6 +176,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI if !separateSuccess { removeMod(ctx, modInfo, mod, dbVersion) + slox.Error(ctx, "failed to separate mod") return nil, errors.New("failed to separate mod") } } @@ -175,6 +186,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI if !success { removeMod(ctx, modInfo, mod, dbVersion) + slox.Error(ctx, "failed to upload mod") return nil, errors.New("failed to upload mod") } diff --git a/redis/jobs/jobs.go b/redis/jobs/jobs.go index 82cda3ff..123b3fe3 100644 --- a/redis/jobs/jobs.go +++ b/redis/jobs/jobs.go @@ -94,3 +94,10 @@ func SubmitJobScanModOnVirusTotalTask(ctx context.Context, modID string, version slox.Error(ctx, "error adding task", slog.Any("err", err)) } } + +func Purge() { + err := queue.Purge() + if err != nil { + slog.Error("failed purging queue", slog.Any("err", err)) + } +} diff --git a/redis/redis.go b/redis/redis.go index 33b7bcf1..25bf225b 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -56,7 +56,10 @@ func StoreNonce(nonce string, redirectURI string) { func GetNonce(nonce string) (string, error) { result, err := client.Get("nonce:" + nonce).Result() - return result, fmt.Errorf("failed to get nonce: %w", err) + if err != nil { + return "", fmt.Errorf("failed to get nonce: %w", err) + } + return result, nil } func GetAllKeys() []string { diff --git a/shell.nix b/shell.nix index 79a57276..b924e10c 100644 --- a/shell.nix +++ b/shell.nix @@ -1,8 +1,5 @@ -{ pkgs ? import <nixpkgs> {} }: +{ pkgs, unstable }: -let - unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { }; -in pkgs.mkShell { nativeBuildInputs = with pkgs.buildPackages; [ libwebp diff --git a/storage/storage.go b/storage/storage.go index 33421a4d..1543ca2e 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -247,7 +247,11 @@ func Get(key string) (io.ReadCloser, error) { } get, err := storage.Get(key) - return get, fmt.Errorf("failed to get object: %w", err) + if err != nil { + return nil, fmt.Errorf("failed to get object: %w", err) + } + + return get, nil } func GetMod(modID string, name string, versionID string) (io.ReadCloser, error) { diff --git a/tests/guides_test.go b/tests/guides_test.go index 96da84a9..6b1da5f3 100644 --- a/tests/guides_test.go +++ b/tests/guides_test.go @@ -20,6 +20,9 @@ func init() { db.EnableDebug() } +// TODO Add guide tag test +// TODO Add rate limit test + func TestGuides(t *testing.T) { ctx, client, stop := setup() defer stop() diff --git a/tests/mod_test.go b/tests/mod_test.go new file mode 100644 index 00000000..d5f44dc5 --- /dev/null +++ b/tests/mod_test.go @@ -0,0 +1,151 @@ +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/db/postgres" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/migrations" +) + +func init() { + migrations.SetMigrationDir("../migrations") + config.SetConfigDir("../") + postgres.EnableDebug() + db.EnableDebug() +} + +// TODO Add mod tag test +// TODO Add rate limit test + +func TestMods(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + token, userID, err := makeUser(ctx) + testza.AssertNoError(t, err) + + // Run Twice to detect any cache issues + for i := 0; i < 2; i++ { + t.Run(strconv.Itoa(i), func(t *testing.T) { + var objID string + + modReference := "hello" + strconv.Itoa(i) + + t.Run("Create", func(t *testing.T) { + createRequest := authRequest(`mutation ($mod_reference: ModReference!) { + createMod(mod: { + name: "Hello World", + short_description: "Foo Bar 123 Foo Bar 123", + full_description: "Lorem ipsum dolor sit amet", + mod_reference: $mod_reference + }) { + id + } + }`, token) + createRequest.Var("mod_reference", modReference) + + var createResponse struct { + CreateMod generated.Mod + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateMod.ID) + + objID = createResponse.CreateMod.ID + }) + + t.Run("Query One", func(t *testing.T) { + queryRequest := authRequest(`query ($id: ModID!) { + getMod(modId: $id) { + id + name + short_description + full_description + mod_reference + creator_id + } + }`, token) + queryRequest.Var("id", objID) + + var queryResponse struct { + GetMod generated.Mod + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + testza.AssertEqual(t, objID, queryResponse.GetMod.ID) + testza.AssertEqual(t, "Hello World", queryResponse.GetMod.Name) + testza.AssertEqual(t, "Foo Bar 123 Foo Bar 123", queryResponse.GetMod.ShortDescription) + fullDescription := "Lorem ipsum dolor sit amet" + testza.AssertEqual(t, &fullDescription, queryResponse.GetMod.FullDescription) + testza.AssertEqual(t, modReference, queryResponse.GetMod.ModReference) + testza.AssertEqual(t, userID, queryResponse.GetMod.CreatorID) + }) + + t.Run("Update", func(t *testing.T) { + updateRequest := authRequest(`mutation ($id: ModID!) { + updateMod( + modId: $id, + mod: { + name: "Foo Bar" + } + ) { + id + } + }`, token) + updateRequest.Var("id", objID) + + var updateResponse struct { + UpdateMod generated.Mod + } + testza.AssertNoError(t, client.Run(ctx, updateRequest, &updateResponse)) + }) + + t.Run("Query Many", func(t *testing.T) { + queryRequest := authRequest(`query { + getMods { + count + mods { + id + name + short_description + full_description + mod_reference + creator_id + } + } + }`, token) + + var queryResponse struct { + GetMods generated.GetMods + } + testza.AssertNoError(t, client.Run(ctx, queryRequest, &queryResponse)) + testza.AssertEqual(t, 1, queryResponse.GetMods.Count) + testza.AssertEqual(t, 1, len(queryResponse.GetMods.Mods)) + testza.AssertEqual(t, objID, queryResponse.GetMods.Mods[0].ID) + testza.AssertEqual(t, "Foo Bar", queryResponse.GetMods.Mods[0].Name) + testza.AssertEqual(t, "Foo Bar 123 Foo Bar 123", queryResponse.GetMods.Mods[0].ShortDescription) + fullDescription := "Lorem ipsum dolor sit amet" + testza.AssertEqual(t, &fullDescription, queryResponse.GetMods.Mods[0].FullDescription) + testza.AssertEqual(t, modReference, queryResponse.GetMods.Mods[0].ModReference) + testza.AssertEqual(t, userID, queryResponse.GetMods.Mods[0].CreatorID) + }) + + t.Run("Delete", func(t *testing.T) { + deleteRequest := authRequest(`mutation ($id: ModID!) { + deleteMod(modId: $id) + }`, token) + deleteRequest.Var("id", objID) + + var deleteResponse struct { + DeleteMod bool + } + testza.AssertNoError(t, client.Run(ctx, deleteRequest, &deleteResponse)) + testza.AssertTrue(t, deleteResponse.DeleteMod) + }) + }) + } +} diff --git a/tests/utils.go b/tests/utils.go index 760f7c6e..cd212643 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -2,11 +2,11 @@ package tests import ( "context" - "log/slog" - "sync" - "github.com/Vilsol/slox" "github.com/machinebox/graphql" + "github.com/satisfactorymodding/smr-api/validation" + "log/slog" + "sync" smr "github.com/satisfactorymodding/smr-api/api" "github.com/satisfactorymodding/smr-api/auth" @@ -17,6 +17,8 @@ import ( ) func setup() (context.Context, *graphql.Client, func()) { + validation.StaticPath = "../static" + client := graphql.NewClient("http://localhost:5020/v2/query") ctx := smr.Initialize(context.Background()) diff --git a/tests/version_test.go b/tests/version_test.go new file mode 100644 index 00000000..11399858 --- /dev/null +++ b/tests/version_test.go @@ -0,0 +1,291 @@ +package tests + +import ( + "bytes" + "encoding/json" + "errors" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/spf13/viper" + "io" + "math" + "mime/multipart" + "net/http" + "net/url" + "os" + "path" + "path/filepath" + "strconv" + "testing" + "time" + + "github.com/MarvinJWendt/testza" + + "github.com/satisfactorymodding/smr-api/config" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/migrations" +) + +func init() { + migrations.SetMigrationDir("../migrations") + config.SetConfigDir("../") + postgres.EnableDebug() + db.EnableDebug() +} + +const testModURL = "https://storage-staging.ficsit.app/file/smr-staging-s3/mods/4ha9SfdXaHAq4q/FicsitRemoteMonitoring-0.10.3.smod" + +// TODO Add rate limit test + +func TestVersions(t *testing.T) { + ctx, client, stop := setup() + defer stop() + + viper.Set("skip-virus-check", true) + + token, _, err := makeUser(ctx) + testza.AssertNoError(t, err) + + var modID string + + modReference := "FicsitRemoteMonitoring" + + u, err := url.Parse(testModURL) + testza.AssertNoError(t, err) + + modPath := filepath.Join(t.TempDir(), path.Base(u.Path)) + + t.Run("Download Test Mod", func(t *testing.T) { + response, err := http.Get(testModURL) + testza.AssertNoError(t, err) + + defer response.Body.Close() + + file, err := os.OpenFile(modPath, os.O_CREATE|os.O_WRONLY, 0644) + testza.AssertNoError(t, err) + + _, err = io.Copy(file, response.Body) + testza.AssertNoError(t, err) + }) + + t.Run("Create SML Version", func(t *testing.T) { + createRequest := authRequest(`mutation { + createSMLVersion(smlVersion: { + version: "1.2.3", + satisfactory_version: 123, + stability: release, + link: "https://google.com", + targets: [ + { + targetName: Windows, + link: "https://this-is-windows.com" + }, + { + targetName: WindowsServer, + link: "https://this-is-windows-server.com" + }, + { + targetName: LinuxServer, + link: "https://this-is-linux-server.com" + } + ], + changelog: "Hello World", + date: "2023-10-27T01:00:51+00:00", + bootstrap_version: "0.0.0", + engine_version: "5.2" + }) { + id + } + }`, token) + + var createResponse struct { + CreateSMLVersion generated.SMLVersion + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateSMLVersion.ID) + }) + + t.Run("Create Mod", func(t *testing.T) { + createRequest := authRequest(`mutation CreateMod($mod_reference: ModReference!) { + createMod(mod: { + name: "Hello World", + short_description: "Foo Bar 123 Foo Bar 123", + full_description: "Lorem ipsum dolor sit amet", + mod_reference: $mod_reference + }) { + id + } + }`, token) + createRequest.Var("mod_reference", modReference) + + var createResponse struct { + CreateMod generated.Mod + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateMod.ID) + + modID = createResponse.CreateMod.ID + }) + + var versionID string + + t.Run("Create Version", func(t *testing.T) { + createRequest := authRequest(`mutation CreateVersion($mod_id: ModID!) { + createVersion(modId: $mod_id) + }`, token) + createRequest.Var("mod_id", modID) + + var createResponse struct { + CreateVersion string + } + testza.AssertNoError(t, client.Run(ctx, createRequest, &createResponse)) + testza.AssertNotEqual(t, "", createResponse.CreateVersion) + + versionID = createResponse.CreateVersion + }) + + t.Run("Upload Parts", func(t *testing.T) { + f, err := os.Open(modPath) + testza.AssertNoError(t, err) + + stat, err := f.Stat() + testza.AssertNoError(t, err) + + chunkSize := int64(1e+7) + chunkCount := int(math.Ceil(float64(stat.Size()) / float64(chunkSize))) // Split in 10MB chunks + + for i := 0; i < chunkCount; i++ { + t.Run("Part"+strconv.Itoa(i), func(t *testing.T) { + _, err = f.Seek(int64(i)*chunkSize, 0) + testza.AssertNoError(t, err) + + chunk := make([]byte, chunkSize) + n, err := f.Read(chunk) + testza.AssertNoError(t, err) + chunk = chunk[:n] + + operationBody, err := json.Marshal(map[string]interface{}{ + "query": `mutation UploadVersionPart($mod_id: ModID!, $version_id: VersionID!, $part: Int!, $file: Upload!) { + uploadVersionPart( + modId: $mod_id, + versionId: $version_id, + file: $file, + part: $part + ) + }`, + "variables": map[string]interface{}{ + "mod_id": modID, + "version_id": versionID, + "part": i + 1, + "file": nil, + }, + }) + testza.AssertNoError(t, err) + + mapBody, err := json.Marshal(map[string]interface{}{ + "0": []string{"variables.file"}, + }) + testza.AssertNoError(t, err) + + body := &bytes.Buffer{} + writer := multipart.NewWriter(body) + + operations, err := writer.CreateFormField("operations") + testza.AssertNoError(t, err) + + _, err = operations.Write(operationBody) + testza.AssertNoError(t, err) + + mapField, err := writer.CreateFormField("map") + testza.AssertNoError(t, err) + + _, err = mapField.Write(mapBody) + testza.AssertNoError(t, err) + + part, err := writer.CreateFormFile("0", filepath.Base(path.Base(u.Path))) + testza.AssertNoError(t, err) + + _, err = io.Copy(part, bytes.NewReader(chunk)) + testza.AssertNoError(t, err) + + err = writer.Close() + testza.AssertNoError(t, err) + + r, _ := http.NewRequest("POST", "http://localhost:5020/v2/query", body) + r.Header.Add("Content-Type", writer.FormDataContentType()) + r.Header.Add("Authorization", token) + + resp, err := http.DefaultClient.Do(r) + testza.AssertNoError(t, err) + + defer resp.Body.Close() + all, err := io.ReadAll(resp.Body) + testza.AssertNoError(t, err) + + response := make(map[string]interface{}) + testza.AssertNoError(t, json.Unmarshal(all, &response)) + + testza.AssertTrue(t, response["data"].(map[string]interface{})["uploadVersionPart"].(bool)) + }) + } + }) + + t.Run("Finalize Version", func(t *testing.T) { + finalizeRequest := authRequest(`mutation FinalizeCreateVersion($mod_id: ModID!, $version_id: VersionID!) { + finalizeCreateVersion(modId: $mod_id, versionId: $version_id, version: { + changelog: "Hello World", + stability: release + }) + }`, token) + finalizeRequest.Var("mod_id", modID) + finalizeRequest.Var("version_id", versionID) + + var finalizeResponse struct { + FinalizeCreateVersion bool + } + testza.AssertNoError(t, client.Run(ctx, finalizeRequest, &finalizeResponse)) + testza.AssertTrue(t, finalizeResponse.FinalizeCreateVersion) + }) + + t.Run("Wait For Version", func(t *testing.T) { + request := authRequest(`query CheckVersionUploadState($mod_id: ModID!, $version_id: VersionID!) { + checkVersionUploadState(modId: $mod_id, versionId: $version_id) { + version { + id + } + auto_approved + } + }`, token) + request.Var("mod_id", modID) + request.Var("version_id", versionID) + + end := time.Now().Add(time.Minute) + for time.Now().Before(end) { + var response struct { + CheckVersionUploadState struct { + Version struct { + ID string + } + AutoApproved bool + } + } + + err := client.Run(ctx, request, &response) + testza.AssertNoError(t, err) + + if err != nil { + break + } + + if response.CheckVersionUploadState.Version.ID != "" { + break + } + + time.Sleep(time.Second * 3) + } + + if time.Now().After(end) { + testza.AssertNoError(t, errors.New("failed finishing mod")) + } + }) +} diff --git a/tools.go b/tools.go index 6ed578f7..0042c9da 100644 --- a/tools.go +++ b/tools.go @@ -30,6 +30,7 @@ func generateEnt() { gen.FeatureIntercept, gen.FeatureSnapshot, gen.FeatureExecQuery, + gen.FeatureUpsert, }, IDType: &field.TypeInfo{ Type: field.TypeString, diff --git a/validation/validation.go b/validation/validation.go index 0f97cfb3..356d964f 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -8,6 +8,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "github.com/davecgh/go-spew/spew" "io" "log/slog" "path" @@ -65,15 +66,17 @@ var ( uPluginJSONSchema gojsonschema.JSONLoader ) +var StaticPath = "static/" + func InitializeValidator() { - absPath, err := filepath.Abs("static/data-json-schema.json") + absPath, err := filepath.Abs(filepath.Join(StaticPath, "data-json-schema.json")) if err != nil { panic(err) } dataJSONSchema = gojsonschema.NewReferenceLoader("file://" + strings.ReplaceAll(absPath, "\\", "/")) - absPath, err = filepath.Abs("static/uplugin-json-schema.json") + absPath, err = filepath.Abs(filepath.Join(StaticPath, "uplugin-json-schema.json")) if err != nil { panic(err) @@ -166,6 +169,8 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal } } + slox.Info(ctx, "decided engine version", slog.String("version", engineVersion)) + parserClient := parser.NewParserClient(conn) stream, err := parserClient.Parse(ctx, &parser.ParseRequest{ ZipData: body, @@ -193,6 +198,8 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal if errors.Is(err, io.EOF) || err == io.EOF { break } + spew.Config.DisablePointerMethods = false + spew.Dump(err) return nil, fmt.Errorf("failed reading parser stream: %w", err) } From 5336524711db3029d7757c99ba4982120330d88c Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 19:59:49 +0200 Subject: [PATCH 07/19] chore: setup minio in ci --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4023ed0..76350ca5 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,6 +82,13 @@ jobs: - name: Start stack run: docker-compose -f docker-compose-dev.yml up -d + - name: Setup Minio + run: | + go install github.com/minio/mc@latest + mc alias set local http://localhost:9000 minio minio123 + mc admin user svcacct add local minio --access-key REPLACE_ME_KEY --secret-key REPLACE_ME_SECRET + mc anonymous set public local/smr + - name: Test run: go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./... env: From 3e302a0b041a41f8701c922b868100b5f86b8545 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 20:05:33 +0200 Subject: [PATCH 08/19] chore: lint, ci feature flag --- .github/workflows/build.yml | 1 + gql/resolver_versions.go | 4 ++-- gql/versions.go | 2 +- tests/utils.go | 6 +++--- tests/version_test.go | 6 +++--- validation/validation.go | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76350ca5..3bfe4c7d 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,6 +95,7 @@ jobs: CGO_ENABLED: 1 REPO_PASETO.PUBLIC_KEY: 408c5155a389aeabf1c1b0da73ff5a3079b6aa6628e4c661b1e1ce412181cc8a REPO_PASETO.PRIVATE_KEY: a5f7409588f6b72d443db0d432f37f1214a5ec88cb55a70e24b90194ed549465408c5155a389aeabf1c1b0da73ff5a3079b6aa6628e4c661b1e1ce412181cc8a + REPO_FEATURE_FLAGS.ALLOW_MULTI_TARGET_UPLOAD: "true" - name: Codecov uses: codecov/codecov-action@v1 \ No newline at end of file diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index 2abda30c..d2f5a087 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "fmt" - "github.com/satisfactorymodding/smr-api/generated/conv" - "github.com/satisfactorymodding/smr-api/generated/ent" "io" "log/slog" "runtime/debug" @@ -20,6 +18,8 @@ import ( "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" "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/integrations" "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/redis" diff --git a/gql/versions.go b/gql/versions.go index 15ba473f..71a5fb6d 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -4,13 +4,13 @@ import ( "context" "encoding/json" "fmt" - "github.com/spf13/viper" "io" "log/slog" "time" "github.com/Vilsol/slox" "github.com/pkg/errors" + "github.com/spf13/viper" "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" diff --git a/tests/utils.go b/tests/utils.go index cd212643..4e294635 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -2,11 +2,10 @@ package tests import ( "context" - "github.com/Vilsol/slox" - "github.com/machinebox/graphql" - "github.com/satisfactorymodding/smr-api/validation" "log/slog" "sync" + "github.com/Vilsol/slox" + "github.com/machinebox/graphql" smr "github.com/satisfactorymodding/smr-api/api" "github.com/satisfactorymodding/smr-api/auth" @@ -14,6 +13,7 @@ import ( "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/util" + "github.com/satisfactorymodding/smr-api/validation" ) func setup() (context.Context, *graphql.Client, func()) { diff --git a/tests/version_test.go b/tests/version_test.go index 11399858..855f1458 100644 --- a/tests/version_test.go +++ b/tests/version_test.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/json" "errors" - "github.com/satisfactorymodding/smr-api/generated" - "github.com/spf13/viper" "io" "math" "mime/multipart" @@ -19,10 +17,12 @@ import ( "time" "github.com/MarvinJWendt/testza" + "github.com/spf13/viper" "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -61,7 +61,7 @@ func TestVersions(t *testing.T) { defer response.Body.Close() - file, err := os.OpenFile(modPath, os.O_CREATE|os.O_WRONLY, 0644) + file, err := os.OpenFile(modPath, os.O_CREATE|os.O_WRONLY, 0o644) testza.AssertNoError(t, err) _, err = io.Copy(file, response.Body) diff --git a/validation/validation.go b/validation/validation.go index 356d964f..90638d64 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -8,7 +8,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/davecgh/go-spew/spew" "io" "log/slog" "path" @@ -20,6 +19,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/Vilsol/slox" + "github.com/davecgh/go-spew/spew" "github.com/pkg/errors" "github.com/spf13/viper" "github.com/xeipuuv/gojsonschema" From d8bd9190c7814e83e0eb2405299828e272c10994 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 20:09:41 +0200 Subject: [PATCH 09/19] chore: lint --- tests/utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/utils.go b/tests/utils.go index 4e294635..cac3229c 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -4,6 +4,7 @@ import ( "context" "log/slog" "sync" + "github.com/Vilsol/slox" "github.com/machinebox/graphql" From a0148ac45931f3b3012e9c2bcf9502d7dfb5aecc Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 20:31:50 +0200 Subject: [PATCH 10/19] fix: retry metadata extraction --- go.mod | 3 +- go.sum | 2 + validation/validation.go | 87 +++++++++++++++++++++++----------------- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index c5a614ed..6307e24b 100755 --- a/go.mod +++ b/go.mod @@ -10,11 +10,13 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 github.com/Vilsol/slox v0.0.1 github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f + github.com/avast/retry-go v3.0.0+incompatible github.com/avast/retry-go/v3 v3.1.1 github.com/aws/aws-sdk-go v1.46.1 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cespare/xxhash v1.1.0 github.com/chai2010/webp v1.1.1 + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/dgraph-io/ristretto v0.1.1 github.com/felixge/fgprof v0.9.3 github.com/finnbear/moderation v0.11.4 @@ -83,7 +85,6 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/containerd/console v1.0.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect diff --git a/go.sum b/go.sum index 6b46a4c4..8abf08c9 100644 --- a/go.sum +++ b/go.sum @@ -103,6 +103,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk= +github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= +github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/avast/retry-go/v3 v3.1.1 h1:49Scxf4v8PmiQ/nY0aY3p0hDueqSmc7++cBbtiDGu2g= github.com/avast/retry-go/v3 v3.1.1/go.mod h1:6cXRK369RpzFL3UQGqIUp9Q7GDrams+KsYWrfNA1/nQ= github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= diff --git a/validation/validation.go b/validation/validation.go index 90638d64..54d37172 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -19,6 +19,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/Vilsol/slox" + "github.com/avast/retry-go" "github.com/davecgh/go-spew/spew" "github.com/pkg/errors" "github.com/spf13/viper" @@ -171,52 +172,66 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal slox.Info(ctx, "decided engine version", slog.String("version", engineVersion)) - parserClient := parser.NewParserClient(conn) - stream, err := parserClient.Parse(ctx, &parser.ParseRequest{ - ZipData: body, - EngineVersion: engineVersion, - }, - grpc.MaxCallSendMsgSize(1024*1024*1024), // 1GB - grpc.MaxCallRecvMsgSize(1024*1024*1024), // 1GB - ) - if err != nil { - return nil, fmt.Errorf("failed to parse mod: %w", err) - } - - defer func(stream parser.Parser_ParseClient) { - err := stream.CloseSend() + if err := retry.Do(func() error { + parserClient := parser.NewParserClient(conn) + stream, err := parserClient.Parse(ctx, &parser.ParseRequest{ + ZipData: body, + EngineVersion: engineVersion, + }, + grpc.MaxCallSendMsgSize(1024*1024*1024), // 1GB + grpc.MaxCallRecvMsgSize(1024*1024*1024), // 1GB + ) if err != nil { - slox.Error(ctx, "failed closing parser stream", slog.Any("err", err)) + return fmt.Errorf("failed to parse mod: %w", err) } - }(stream) - beforeUpload := time.Now().Add(-time.Minute) - for { - asset, err := stream.Recv() - if err != nil { - //nolint - if errors.Is(err, io.EOF) || err == io.EOF { - break + defer func(stream parser.Parser_ParseClient) { + err := stream.CloseSend() + if err != nil { + slox.Error(ctx, "failed closing parser stream", slog.Any("err", err)) } - spew.Config.DisablePointerMethods = false - spew.Dump(err) - return nil, fmt.Errorf("failed reading parser stream: %w", err) - } + }(stream) - slox.Info(ctx, "received asset from parser", slog.String("path", asset.GetPath())) - - if asset.Path == "metadata.json" { - out, err := ExtractMetadata(asset.Data) + beforeUpload := time.Now().Add(-time.Minute) + for { + asset, err := stream.Recv() if err != nil { - return nil, err + //nolint + if errors.Is(err, io.EOF) || err == io.EOF { + break + } + spew.Config.DisablePointerMethods = false + spew.Dump(err) + return fmt.Errorf("failed reading parser stream: %w", err) + } + + slox.Info(ctx, "received asset from parser", slog.String("path", asset.GetPath())) + + if asset.Path == "metadata.json" { + out, err := ExtractMetadata(asset.Data) + if err != nil { + return err + } + modInfo.Metadata = append(modInfo.Metadata, out) } - modInfo.Metadata = append(modInfo.Metadata, out) + + storage.UploadModAsset(ctx, modInfo.ModReference, asset.GetPath(), asset.GetData()) } - storage.UploadModAsset(ctx, modInfo.ModReference, asset.GetPath(), asset.GetData()) - } + storage.DeleteOldModAssets(ctx, modInfo.ModReference, beforeUpload) - storage.DeleteOldModAssets(ctx, modInfo.ModReference, beforeUpload) + return nil + }, + retry.Attempts(10), + retry.Delay(time.Second*10), + retry.DelayType(retry.FixedDelay), + retry.OnRetry(func(n uint, err error) { + if n > 0 { + slox.Info(ctx, "retrying to extract metadata", slog.Uint64("n", uint64(n))) + } + })); err != nil { + return nil, err //nolint + } } modInfo.Size = int64(len(body)) From 020e7ce01e6a0cfd806bb69a76834bbee4677c3a Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 20:34:00 +0200 Subject: [PATCH 11/19] chore: remove debug --- go.mod | 2 +- validation/validation.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 6307e24b..bdd8a732 100755 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cespare/xxhash v1.1.0 github.com/chai2010/webp v1.1.1 - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/dgraph-io/ristretto v0.1.1 github.com/felixge/fgprof v0.9.3 github.com/finnbear/moderation v0.11.4 @@ -85,6 +84,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/containerd/console v1.0.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect diff --git a/validation/validation.go b/validation/validation.go index 54d37172..a381784e 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -20,7 +20,6 @@ import ( "github.com/Masterminds/semver/v3" "github.com/Vilsol/slox" "github.com/avast/retry-go" - "github.com/davecgh/go-spew/spew" "github.com/pkg/errors" "github.com/spf13/viper" "github.com/xeipuuv/gojsonschema" @@ -200,8 +199,6 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal if errors.Is(err, io.EOF) || err == io.EOF { break } - spew.Config.DisablePointerMethods = false - spew.Dump(err) return fmt.Errorf("failed reading parser stream: %w", err) } From cf1166e27dd5b71ae92a83562f15edae5cca7827 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Fri, 1 Dec 2023 20:38:13 +0200 Subject: [PATCH 12/19] chore: run test for longer --- tests/version_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/version_test.go b/tests/version_test.go index 855f1458..bcc023a3 100644 --- a/tests/version_test.go +++ b/tests/version_test.go @@ -259,7 +259,7 @@ func TestVersions(t *testing.T) { request.Var("mod_id", modID) request.Var("version_id", versionID) - end := time.Now().Add(time.Minute) + end := time.Now().Add(time.Minute * 5) for time.Now().Before(end) { var response struct { CheckVersionUploadState struct { From 1553de5ac7488120eafb8670ded90aeb03e63c8e Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 4 Dec 2023 07:51:45 +0200 Subject: [PATCH 13/19] refactor: more ent --- db/postgres/mod.go | 214 ---------- db/postgres/postgres.go | 14 - db/postgres/postgres_types.go | 28 -- db/postgres/version.go | 225 ---------- db/schema/mod.go | 18 +- db/schema/sml_version.go | 4 +- db/schema/version.go | 24 +- db/schema/version_target.go | 6 +- db/utils.go | 131 +++++- docker-compose-dev.yml | 2 +- generated/conv/mod.go | 24 +- generated/ent/internal/schema.go | 2 +- generated/ent/migrate/schema.go | 46 +- generated/ent/mod.go | 4 +- generated/ent/mod/mod.go | 10 + generated/ent/mod/where.go | 30 ++ generated/ent/mod_create.go | 157 ++++++- generated/ent/mod_update.go | 176 +++++++- generated/ent/mutation.go | 314 +++++++++++++- generated/ent/runtime/runtime.go | 28 ++ generated/ent/smlversion.go | 5 +- generated/ent/smlversion/smlversion.go | 19 +- generated/ent/smlversion/where.go | 27 +- generated/ent/smlversion_create.go | 11 +- generated/ent/smlversion_update.go | 9 +- generated/ent/version.go | 5 +- generated/ent/version/version.go | 23 +- generated/ent/version/where.go | 107 ++++- generated/ent/version_create.go | 283 +++++++++++-- generated/ent/version_update.go | 313 +++++++++++++- generated/ent/versiontarget/where.go | 30 ++ generated/ent/versiontarget_create.go | 93 ++++- generated/ent/versiontarget_update.go | 102 +++++ gql/gql_types.go | 160 +------ gql/gql_utils.go | 30 +- gql/resolver_mods.go | 394 ++++++++++++------ gql/resolver_sml_versions.go | 2 +- gql/resolver_versions.go | 188 ++++++--- gql/versions.go | 198 +++++---- integrations/discord.go | 19 +- .../consumer_scan_mod_on_virus_total.go | 23 +- redis/jobs/consumers/utils.go | 70 ++-- util/db.go | 27 ++ validation/validation.go | 9 +- 44 files changed, 2401 insertions(+), 1203 deletions(-) create mode 100644 util/db.go diff --git a/db/postgres/mod.go b/db/postgres/mod.go index 00f29422..c6c33a07 100644 --- a/db/postgres/mod.go +++ b/db/postgres/mod.go @@ -3,16 +3,9 @@ package postgres import ( "context" "fmt" - "math" "strings" - "time" "github.com/patrickmn/go-cache" - "gorm.io/gorm" - - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" ) func GetModByID(ctx context.Context, modID string) *Mod { @@ -37,24 +30,6 @@ func GetModByIDNoCache(ctx context.Context, modID string) *Mod { return &mod } -func GetModByReference(ctx context.Context, modReference string) *Mod { - cacheKey := "GetModByReference_" + modReference - if mod, ok := dbCache.Get(cacheKey); ok { - return mod.(*Mod) - } - - var mod Mod - DBCtx(ctx).Preload("Tags").Preload("Versions.Targets").Find(&mod, "mod_reference = ?", modReference) - - if mod.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &mod, cache.DefaultExpiration) - - return &mod -} - func GetModsByID(ctx context.Context, modIds []string) []Mod { cacheKey := "GetModsById_" + strings.Join(modIds, ":") if mods, ok := dbCache.Get(cacheKey); ok { @@ -73,12 +48,6 @@ func GetModsByID(ctx context.Context, modIds []string) []Mod { return mods } -func DeleteMod(ctx context.Context, modID string) { - DBCtx(ctx).Delete(Mod{}, "id = ?", modID) - DBCtx(ctx).Delete(Version{}, "mod_id = ?", modID) - DBCtx(ctx).Delete(UserMod{}, "mod_id = ?", modID) -} - func GetModCount(ctx context.Context, search string, unapproved bool) int64 { cacheLey := "GetModCount_" + search + "_" + fmt.Sprint(unapproved) if count, ok := dbCache.Get(cacheLey); ok { @@ -99,26 +68,6 @@ func GetModCount(ctx context.Context, search string, unapproved bool) int64 { return modCount } -func GetModCountNew(ctx context.Context, filter *models.ModFilter, unapproved bool) int64 { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetModCountNew_" + hash + "_" + fmt.Sprint(unapproved) - if count, ok := dbCache.Get(cacheKey); ok { - return count.(int64) - } - } - - var modCount int64 - NewModQuery(ctx, filter, unapproved, true).Count(&modCount) - - if cacheKey != "" { - dbCache.Set(cacheKey, modCount, cache.DefaultExpiration) - } - - return modCount -} - func IncrementModViews(ctx context.Context, mod *Mod) { // TODO unignore // DBCtx(ctx).Model(mod).Update("views", mod.Views+1) @@ -152,118 +101,6 @@ func GetMods(ctx context.Context, limit int, offset int, orderBy string, order s return mods } -func GetModsNew(ctx context.Context, filter *models.ModFilter, unapproved bool) []Mod { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetModsNew_" + hash + "_" + fmt.Sprint(unapproved) - if mods, ok := dbCache.Get(cacheKey); ok { - return mods.([]Mod) - } - } - - var mods []Mod - NewModQuery(ctx, filter, unapproved, false).Find(&mods) - - if cacheKey != "" { - dbCache.Set(cacheKey, mods, cache.DefaultExpiration) - } - - return mods -} - -func CreateMod(ctx context.Context, mod *Mod) (*Mod, error) { - // Allow only new 4 mods per 24h - - mod.ID = util.GenerateUniqueID() - - var mods []Mod - DBCtx(ctx).Order("created_at asc").Find(&mods, "creator_id = ? AND created_at > ?", mod.CreatorID, time.Now().Add(time.Hour*24*-1)) - - currentAvailable := float64(4) - lastModTime := time.Now() - for _, mod := range mods { - currentAvailable-- - if mod.CreatedAt.After(lastModTime) { - diff := mod.CreatedAt.Sub(lastModTime) - currentAvailable = math.Min(4, currentAvailable+diff.Hours()/6) - } - lastModTime = mod.CreatedAt - } - - if currentAvailable < 1 { - timeToWait := time.Until(lastModTime.Add(time.Hour * 6)).Minutes() - return nil, fmt.Errorf("please wait %.0f minutes to post another mod", timeToWait) - } - - DBCtx(ctx).Create(&mod) - DBCtx(ctx).Create(&UserMod{ - Role: "creator", - ModID: mod.ID, - UserID: mod.CreatorID, - }) - - return mod, nil -} - -func NewModQuery(ctx context.Context, filter *models.ModFilter, unapproved bool, count bool) *gorm.DB { - query := DBCtx(ctx) - - if count { - query = query.Model(Mod{}) - } - - query = query.Where("approved = ? AND denied = ?", !unapproved, false) - query = query.Preload("Tags").Preload("Versions.Targets") - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - cleanSearch := strings.ReplaceAll(strings.TrimSpace(*filter.Search), " ", " & ") - sub := DBCtx(ctx).Table("mods") - sub = sub.Select("id, (similarity(name, ?) * 2 + similarity(short_description, ?) + similarity(full_description, ?) * 0.5) as s", cleanSearch, cleanSearch, cleanSearch) - - query = query.Joins("INNER JOIN (?) AS t1 on t1.id = mods.id", sub) - query = query.Where("t1.s > 0.2") - - if !count && *filter.OrderBy == generated.ModFieldsSearch { - query = query.Order("t1.s DESC") - } - } - - if !count { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset) - - if *filter.OrderBy != generated.ModFieldsSearch { - if string(*filter.OrderBy) == "last_version_date" { - query = query.Order("case when last_version_date is null then 1 else 0 end, last_version_date " + string(*filter.Order)) - } else { - query = query.Order("mods." + string(*filter.OrderBy) + " " + string(*filter.Order)) - } - } - } - - if filter.Hidden == nil || !(*filter.Hidden) { - query = query.Where("hidden = false") - } - - if filter.Ids != nil && len(filter.Ids) > 0 { - query = query.Where("mods.id in (?)", filter.Ids) - } else if filter.References != nil && len(filter.References) > 0 { - query = query.Where("mod_reference in (?)", filter.References) - } - - if filter.Fields != nil && len(filter.Fields) > 0 { - query = query.Select(filter.Fields) - } - - if filter.TagIDs != nil && len(filter.TagIDs) > 0 { - query.Joins("INNER JOIN mod_tags on mod_tags.tag_id in ? AND mod_tags.mod_id = mods.id", filter.TagIDs) - } - } - - return query -} - func GetModByIDOrReference(ctx context.Context, modIDOrReference string) *Mod { cacheKey := "GetModByIDOrReference_" + modIDOrReference if mod, ok := dbCache.Get(cacheKey); ok { @@ -281,54 +118,3 @@ func GetModByIDOrReference(ctx context.Context, modIDOrReference string) *Mod { return &mod } - -func ClearModTags(ctx context.Context, modID string) error { - r := DBCtx(ctx).Where("mod_id = ?", modID).Delete(&ModTag{}) - return r.Error -} - -func SetModTags(ctx context.Context, modID string, tagIDs []string) error { - for _, tag := range tagIDs { - err := AddModTag(ctx, modID, tag) - if err != nil { - return err - } - } - return nil -} - -func ResetModTags(ctx context.Context, modID string, tagIDs []string) error { - err := ClearModTags(ctx, modID) - if err != nil { - return err - } - err = SetModTags(ctx, modID, tagIDs) - if err != nil { - return err - } - return nil -} - -func AddModTag(ctx context.Context, modID string, tagID string) error { - r := DBCtx(ctx).Create(&ModTag{ModID: modID, TagID: tagID}) - return r.Error -} - -func RemoveModTag(ctx context.Context, modID string, tagID string) error { - r := DBCtx(ctx).Delete(&ModTag{ModID: modID, TagID: tagID}) - return r.Error -} - -func GetModsByIDOrReference(ctx context.Context, modIDOrReferences []string) []Mod { - cacheKey := "GetModsByIDOrReference_" + strings.Join(modIDOrReferences, "-") - if mod, ok := dbCache.Get(cacheKey); ok { - return mod.([]Mod) - } - - var mods []Mod - DBCtx(ctx).Preload("Tags").Find(&mods, "mod_reference IN ? OR id IN ?", modIDOrReferences, modIDOrReferences) - - dbCache.Set(cacheKey, mods, cache.DefaultExpiration) - - return mods -} diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go index 275ecad7..9afd83dc 100644 --- a/db/postgres/postgres.go +++ b/db/postgres/postgres.go @@ -122,16 +122,6 @@ func Save(ctx context.Context, object interface{}) { DBCtx(ctx).Save(object) } -func Delete(ctx context.Context, object interface{}) { - DBCtx(ctx).Delete(object) - ClearCache() -} - -func DeleteForced(ctx context.Context, object interface{}) { - DBCtx(ctx).Unscoped().Delete(object) - ClearCache() -} - func DBCtx(ctx context.Context) *gorm.DB { if ctx != nil { dbCtx := DBFromContext(ctx) @@ -145,10 +135,6 @@ func DBCtx(ctx context.Context) *gorm.DB { return db } -func ClearCache() { - dbCache.Flush() -} - func EnableDebug() { if db != nil { db = db.Debug() diff --git a/db/postgres/postgres_types.go b/db/postgres/postgres_types.go index 187a286e..095462fd 100644 --- a/db/postgres/postgres_types.go +++ b/db/postgres/postgres_types.go @@ -108,24 +108,6 @@ func (TinyVersion) TableName() string { return "versions" } -type Guide struct { - SMRModel - Name string `gorm:"type:varchar(50)"` - ShortDescription string `gorm:"type:varchar(128)"` - Guide string - UserID string - Tags []Tag `gorm:"many2many:guide_tags"` - User User - Views uint -} - -type UserGroup struct { - SMRDates - - UserID string `gorm:"primary_key"` - GroupID string `gorm:"primary_key"` -} - type SMLVersion struct { Date time.Time BootstrapVersion *string @@ -158,16 +140,6 @@ type Tag struct { Mods []Mod `gorm:"many2many:mod_tags"` } -type ModTag struct { - TagID string `gorm:"primary_key;type:varchar(24)"` - ModID string `gorm:"primary_key;type:varchar(16)"` -} - -type GuideTag struct { - TagID string `gorm:"primary_key;type:varchar(24)"` - GuideID string `gorm:"primary_key;type:varchar(16)"` -} - type CompatibilityInfo struct { Ea Compatibility `gorm:"type:compatibility" json:"EA"` Exp Compatibility `gorm:"type:compatibility" json:"EXP"` diff --git a/db/postgres/version.go b/db/postgres/version.go index 39d77485..b0b9a184 100644 --- a/db/postgres/version.go +++ b/db/postgres/version.go @@ -2,39 +2,14 @@ package postgres import ( "context" - "errors" "fmt" - "regexp" - "strconv" "strings" - "time" "github.com/patrickmn/go-cache" "github.com/satisfactorymodding/smr-api/models" - "github.com/satisfactorymodding/smr-api/util" ) -var semverCheck = regexp.MustCompile(`^(<=|<|>|>=|\^)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) - -func GetVersionsByID(ctx context.Context, versionIds []string) []Version { - cacheKey := "GetVersionsById_" + strings.Join(versionIds, ":") - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.([]Version) - } - - var versions []Version - DBCtx(ctx).Preload("Targets").Find(&versions, "id in (?)", versionIds) - - if len(versionIds) != len(versions) { - return nil - } - - dbCache.Set(cacheKey, versions, cache.DefaultExpiration) - - return versions -} - func GetModsLatestVersions(ctx context.Context, modIds []string, unapproved bool) *[]Version { cacheKey := "GetModsLatestVersions_" + strings.Join(modIds, ":") + "_" + fmt.Sprint(unapproved) if versions, ok := dbCache.Get(cacheKey); ok { @@ -132,48 +107,6 @@ func GetModVersion(ctx context.Context, modID string, versionID string) *Version return &version } -func GetModVersionByName(ctx context.Context, modID string, versionName string) *Version { - cacheKey := "GetModVersionByName_" + modID + "_" + versionName - if version, ok := dbCache.Get(cacheKey); ok { - return version.(*Version) - } - - var version Version - DBCtx(ctx).Preload("Targets").First(&version, "mod_id = ? AND version = ?", modID, versionName) - - if version.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &version, cache.DefaultExpiration) - - return &version -} - -func CreateVersion(ctx context.Context, version *Version) error { - var versionCount int64 - DBCtx(ctx).Model(Version{}).Where("mod_id = ? AND version = ?", version.ModID, version.Version).Count(&versionCount) - - if versionCount > 0 { - return errors.New("this mod already has a version with this name") - } - - // Allow only new 5 versions per 24h - - var versions []Version - DBCtx(ctx).Order("created_at asc").Find(&versions, "mod_id = ? AND created_at > ?", version.ModID, time.Now().Add(time.Hour*24*-1)) - - if len(versions) >= 5 { - timeToWait := time.Until(versions[0].CreatedAt.Add(time.Hour * 24)).Minutes() - return fmt.Errorf("please wait %.0f minutes to post another version", timeToWait) - } - - version.ID = util.GenerateUniqueID() - DBCtx(ctx).Create(&version) - - return nil -} - func IncrementVersionDownloads(ctx context.Context, version *Version) { DBCtx(ctx).Model(version).Update("downloads", version.Downloads+1) } @@ -196,70 +129,6 @@ func GetVersion(ctx context.Context, versionID string) *Version { return &version } -func GetVersionsNew(ctx context.Context, filter *models.VersionFilter, unapproved bool) []Version { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetVersionsNew_" + hash + "_" + fmt.Sprint(unapproved) - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.([]Version) - } - } - - var versions []Version - query := DBCtx(ctx).Preload("Targets").Where("approved = ? AND denied = ?", !unapproved, false) - - if filter != nil { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset). - Order(string(*filter.OrderBy) + " " + string(*filter.Order)) - - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(version) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - - if filter.Fields != nil && len(filter.Fields) > 0 { - query = query.Select(filter.Fields) - } - } - - query.Preload("Targets").Find(&versions) - - if cacheKey != "" { - dbCache.Set(cacheKey, versions, cache.DefaultExpiration) - } - - return versions -} - -func GetVersionCountNew(ctx context.Context, filter *models.VersionFilter, unapproved bool) int64 { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetVersionCountNew_" + hash + "_" + fmt.Sprint(unapproved) - if versionCount, ok := dbCache.Get(cacheKey); ok { - return versionCount.(int64) - } - } - - var versionCount int64 - query := DBCtx(ctx).Model(Version{}).Where("approved = ? AND denied = ?", !unapproved, false) - - if filter != nil { - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(version) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Count(&versionCount) - - if cacheKey != "" { - dbCache.Set(cacheKey, versionCount, cache.DefaultExpiration) - } - - return versionCount -} - func GetVersionTarget(ctx context.Context, versionID string, target string) *VersionTarget { cacheKey := "GetVersionTarget_" + versionID + "_" + target if versionTarget, ok := dbCache.Get(cacheKey); ok { @@ -277,97 +146,3 @@ func GetVersionTarget(ctx context.Context, versionID string, target string) *Ver return &versionTarget } - -func GetModVersionsConstraint(ctx context.Context, modID string, constraint string) []Version { - matches := semverCheck.FindAllStringSubmatch(constraint, -1) - if len(matches) == 0 { - return nil - } - - major, err := strconv.Atoi(matches[0][2]) - if err != nil { - return nil - } - - minor, err := strconv.Atoi(matches[0][3]) - if err != nil { - return nil - } - - patch, err := strconv.Atoi(matches[0][4]) - if err != nil { - return nil - } - - query := DBCtx(ctx).Preload("Targets").Where("mod_id", modID) - - /* - <=1.2.3 - major < 1 - major = 1, minor < 2 - major = 1, minor = 2, patch <= 3 - - <1.2.3 - major < 1 - major = 1, minor < 2 - major = 1, minor = 2, patch < 3 - - >1.2.3 - major > 1 - major = 1, minor > 2 - major = 1, minor = 2, patch > 3 - - >=1.2.3 - major > 1 - major = 1, minor > 2 - major = 1, minor = 2, patch >= 3 - - 1.2.3 - major = 1, minor = 2, patch = 3 - - ^1.2.3 (>=1.2.3, <2.0.0) - major = 1, minor > 2 - major = 1, minor = 2, patch >= 3 - - ^0.2.3 (>=0.2.3, <0.3.0) - major = 0, minor = 2, patch >= 3 - - ^0.0.3 (>=0.0.3, <0.0.4) - major = 0, minor = 0, patch = 3 - */ - - sign := matches[0][1] - switch sign { - case "<=": - query = query.Where(db.Or("version_major < ?", major). - Or("version_major = ? AND version_minor < ?", major, minor). - Or("version_major = ? AND version_minor = ? AND version_patch <= ?", major, minor, patch)) - case "<": - query = query.Where(db.Or("version_major < ?", major). - Or("version_major = ? AND version_minor < ?", major, minor). - Or("version_major = ? AND version_minor = ? AND version_patch < ?", major, minor, patch)) - case ">": - query = query.Where(db.Or("version_major > ?", major). - Or("version_major = ? AND version_minor > ?", major, minor). - Or("version_major = ? AND version_minor = ? AND version_patch > ?", major, minor, patch)) - case ">=": - query = query.Where(db.Or("version_major > ?", major). - Or("version_major = ? AND version_minor > ?", major, minor). - Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch)) - case "^": - if major != 0 { - query = query.Where(db.Or("version_major = ? AND version_minor > ?", major, minor). - Or("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch)) - } else if minor != 0 { - query = query.Where("version_major = ? AND version_minor = ? AND version_patch >= ?", major, minor, patch) - } else { - query = query.Where("version_major = ? AND version_minor = ? AND version_patch = ?", major, minor, patch) - } - default: - query = query.Where("version_major = ? AND version_minor = ? AND version_patch = ?", major, minor, patch) - } - - var versions []Version - query.Preload("Targets").Find(&versions) - return versions -} diff --git a/db/schema/mod.go b/db/schema/mod.go index c00ef7b1..5bebb809 100644 --- a/db/schema/mod.go +++ b/db/schema/mod.go @@ -6,7 +6,7 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/util" ) type Mod struct { @@ -27,18 +27,18 @@ func (Mod) Fields() []ent.Field { field.String("short_description").MaxLen(128), field.String("full_description"), field.String("logo"), - field.String("source_url"), + field.String("source_url").Optional(), field.String("creator_id"), field.Bool("approved").Default(false), - field.Uint("views"), - field.Uint("hotness"), - field.Uint("popularity"), - field.Uint("downloads"), + field.Uint("views").Default(0), + field.Uint("hotness").Default(0), + field.Uint("popularity").Default(0), + field.Uint("downloads").Default(0), field.Bool("denied").Default(false), - field.Time("last_version_date"), + field.Time("last_version_date").Optional(), field.String("mod_reference").MaxLen(32).Unique(), - field.Bool("hidden"), - field.JSON("compatibility", &postgres.CompatibilityInfo{}), + field.Bool("hidden").Default(false), + field.JSON("compatibility", &util.CompatibilityInfo{}).Optional(), } } diff --git a/db/schema/sml_version.go b/db/schema/sml_version.go index 5c37fd08..89dc0252 100644 --- a/db/schema/sml_version.go +++ b/db/schema/sml_version.go @@ -4,6 +4,8 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + + "github.com/satisfactorymodding/smr-api/util" ) type SmlVersion struct { @@ -22,7 +24,7 @@ func (SmlVersion) Fields() []ent.Field { return []ent.Field{ field.String("version").MaxLen(32).Unique(), field.Int("satisfactory_version"), - field.Enum("stability").Values("alpha", "beta", "release"), + field.Enum("stability").GoType(util.Stability("")), field.Time("date"), field.String("link"), field.String("changelog"), diff --git a/db/schema/version.go b/db/schema/version.go index b07c5e07..5d01e431 100644 --- a/db/schema/version.go +++ b/db/schema/version.go @@ -4,6 +4,8 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + + "github.com/satisfactorymodding/smr-api/util" ) type Version struct { @@ -23,20 +25,20 @@ func (Version) Fields() []ent.Field { field.String("mod_id"), field.String("version").MaxLen(16), field.String("sml_version").MaxLen(16), - field.String("changelog"), - field.Uint("downloads"), - field.String("key"), - field.Enum("stability").Values("alpha", "beta", "release"), + field.String("changelog").Optional(), + field.Uint("downloads").Default(0), + field.String("key").Optional(), + field.Enum("stability").GoType(util.Stability("")), field.Bool("approved").Default(false), - field.Uint("hotness"), + field.Uint("hotness").Default(0), field.Bool("denied").Default(false), - field.String("metadata"), + field.String("metadata").Optional(), field.String("mod_reference").MaxLen(32), - field.Int("version_major"), - field.Int("version_minor"), - field.Int("version_patch"), - field.Int64("size"), - field.String("hash").MinLen(64).MaxLen(64), + field.Int("version_major").Optional(), + field.Int("version_minor").Optional(), + field.Int("version_patch").Optional(), + field.Int64("size").Optional(), + field.String("hash").MinLen(64).MaxLen(64).Optional(), } } diff --git a/db/schema/version_target.go b/db/schema/version_target.go index 2d9b325e..f0263636 100644 --- a/db/schema/version_target.go +++ b/db/schema/version_target.go @@ -21,9 +21,9 @@ func (VersionTarget) Fields() []ent.Field { return []ent.Field{ field.String("version_id"), field.String("target_name"), - field.String("key"), - field.String("hash"), - field.Int64("size"), + field.String("key").Optional(), + field.String("hash").Optional(), + field.Int64("size").Optional(), } } diff --git a/db/utils.go b/db/utils.go index e2218f7d..48ec1da7 100644 --- a/db/utils.go +++ b/db/utils.go @@ -1,6 +1,17 @@ package db -import "entgo.io/ent/dialect/sql" +import ( + "context" + "regexp" + "strconv" + + "entgo.io/ent/dialect/sql" + + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/version" +) + +var semverCheck = regexp.MustCompile(`^(<=|<|>|>=|\^)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) func OrderToOrder(order string) sql.OrderTermOption { if order == "asc" || order == "ascending" { @@ -9,3 +20,121 @@ func OrderToOrder(order string) sql.OrderTermOption { return sql.OrderDesc() } + +func GetModVersionsConstraint(ctx context.Context, modID string, constraint string) ([]*ent.Version, error) { + matches := semverCheck.FindAllStringSubmatch(constraint, -1) + if len(matches) == 0 { + return nil, nil + } + + major, err := strconv.Atoi(matches[0][2]) + if err != nil { + return nil, nil + } + + minor, err := strconv.Atoi(matches[0][3]) + if err != nil { + return nil, nil + } + + patch, err := strconv.Atoi(matches[0][4]) + if err != nil { + return nil, nil + } + + q := From(ctx).Version.Query().WithTargets().Where(version.ModID(modID)) + + /* + <=1.2.3 + major < 1 + major = 1, minor < 2 + major = 1, minor = 2, patch <= 3 + + <1.2.3 + major < 1 + major = 1, minor < 2 + major = 1, minor = 2, patch < 3 + + >1.2.3 + major > 1 + major = 1, minor > 2 + major = 1, minor = 2, patch > 3 + + >=1.2.3 + major > 1 + major = 1, minor > 2 + major = 1, minor = 2, patch >= 3 + + 1.2.3 + major = 1, minor = 2, patch = 3 + + ^1.2.3 (>=1.2.3, <2.0.0) + major = 1, minor > 2 + major = 1, minor = 2, patch >= 3 + + ^0.2.3 (>=0.2.3, <0.3.0) + major = 0, minor = 2, patch >= 3 + + ^0.0.3 (>=0.0.3, <0.0.4) + major = 0, minor = 0, patch = 3 + */ + + sign := matches[0][1] + switch sign { + case "<=": + q = q.Where( + version.Or( + version.VersionMajorLT(major), + version.And(version.VersionMajorEQ(major), version.VersionMinorLT(minor)), + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchLTE(patch)), + ), + ) + case "<": + q = q.Where( + version.Or( + version.VersionMajorLT(major), + version.And(version.VersionMajorEQ(major), version.VersionMinorLT(minor)), + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchLT(patch)), + ), + ) + case ">": + q = q.Where( + version.Or( + version.VersionMajorGT(major), + version.And(version.VersionMajorEQ(major), version.VersionMinorGT(minor)), + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchGT(patch)), + ), + ) + case ">=": + q = q.Where( + version.Or( + version.VersionMajorGT(major), + version.And(version.VersionMajorEQ(major), version.VersionMinorGT(minor)), + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchGTE(patch)), + ), + ) + case "^": + if major != 0 { + q = q.Where( + version.Or( + version.And(version.VersionMajorEQ(major), version.VersionMinorGT(minor)), + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchGTE(patch)), + ), + ) + } else if minor != 0 { + q = q.Where( + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchGTE(patch)), + ) + } else { + q = q.Where( + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchEQ(patch)), + ) + } + default: + q = q.Where( + version.And(version.VersionMajorEQ(major), version.VersionMinorEQ(minor), version.VersionPatchEQ(patch)), + ) + } + + return q.All(ctx) +} diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index dd8d0864..6bdfc1a3 100755 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -28,7 +28,7 @@ services: MINIO_SECRET_KEY: REPLACE_ME_SECRET pak_parser: - image: ghcr.io/vilsol/ficsit-pak-parser:v0.0.3 + image: ghcr.io/vilsol/ficsit-pak-parser:v0.0.5 ports: - 50051:50051 restart: always \ No newline at end of file diff --git a/generated/conv/mod.go b/generated/conv/mod.go index 95fa5e55..ff36db04 100755 --- a/generated/conv/mod.go +++ b/generated/conv/mod.go @@ -4,9 +4,9 @@ package conv import ( conversion "github.com/satisfactorymodding/smr-api/conversion" - postgres "github.com/satisfactorymodding/smr-api/db/postgres" generated "github.com/satisfactorymodding/smr-api/generated" ent "github.com/satisfactorymodding/smr-api/generated/ent" + util "github.com/satisfactorymodding/smr-api/util" "time" ) @@ -44,7 +44,7 @@ func (c *ModImpl) Convert(source *ent.Mod) *generated.Mod { } } generatedMod.Tags = pGeneratedTagList - generatedMod.Compatibility = c.pPostgresCompatibilityInfoToPGeneratedCompatibilityInfo((*source).Compatibility) + generatedMod.Compatibility = c.pUtilCompatibilityInfoToPGeneratedCompatibilityInfo((*source).Compatibility) pGeneratedMod = &generatedMod } return pGeneratedMod @@ -69,28 +69,28 @@ func (c *ModImpl) pEntTagToPGeneratedTag(source *ent.Tag) *generated.Tag { } return pGeneratedTag } -func (c *ModImpl) pPostgresCompatibilityInfoToPGeneratedCompatibilityInfo(source *postgres.CompatibilityInfo) *generated.CompatibilityInfo { +func (c *ModImpl) pUtilCompatibilityInfoToPGeneratedCompatibilityInfo(source *util.CompatibilityInfo) *generated.CompatibilityInfo { var pGeneratedCompatibilityInfo *generated.CompatibilityInfo if source != nil { var generatedCompatibilityInfo generated.CompatibilityInfo - generatedCompatibilityInfo.Ea = c.postgresCompatibilityToPGeneratedCompatibility((*source).Ea) - generatedCompatibilityInfo.Exp = c.postgresCompatibilityToPGeneratedCompatibility((*source).Exp) + generatedCompatibilityInfo.Ea = c.utilCompatibilityToPGeneratedCompatibility((*source).Ea) + generatedCompatibilityInfo.Exp = c.utilCompatibilityToPGeneratedCompatibility((*source).Exp) pGeneratedCompatibilityInfo = &generatedCompatibilityInfo } return pGeneratedCompatibilityInfo } -func (c *ModImpl) postgresCompatibilityToGeneratedCompatibility(source postgres.Compatibility) generated.Compatibility { +func (c *ModImpl) timeTimeToPString(source time.Time) *string { + xstring := conversion.TimeToString(source) + return &xstring +} +func (c *ModImpl) utilCompatibilityToGeneratedCompatibility(source util.Compatibility) generated.Compatibility { var generatedCompatibility generated.Compatibility generatedCompatibility.State = generated.CompatibilityState(source.State) pString := source.Note generatedCompatibility.Note = &pString return generatedCompatibility } -func (c *ModImpl) postgresCompatibilityToPGeneratedCompatibility(source postgres.Compatibility) *generated.Compatibility { - generatedCompatibility := c.postgresCompatibilityToGeneratedCompatibility(source) +func (c *ModImpl) utilCompatibilityToPGeneratedCompatibility(source util.Compatibility) *generated.Compatibility { + generatedCompatibility := c.utilCompatibilityToGeneratedCompatibility(source) return &generatedCompatibility } -func (c *ModImpl) timeTimeToPString(source time.Time) *string { - xstring := conversion.TimeToString(source) - return &xstring -} diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go index c28a258c..fcc3ab33 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":["id"]},{"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":["id"]},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"views","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"MixedIn":false,"MixinIndex":0}},{"name":"popularity","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"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":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"hidden","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"compatibility","type":{"Type":3,"Ident":"*postgres.CompatibilityInfo","PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","PkgName":"postgres","Nillable":true,"RType":{"Name":"CompatibilityInfo","Ident":"postgres.CompatibilityInfo","Kind":22,"PkgPath":"github.com/satisfactorymodding/smr-api/db/postgres","Methods":{}}},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"smlversion.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"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"}],"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":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"downloads","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"stability","type":{"Type":6,"Ident":"version.Stability","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"alpha","V":"alpha"},{"N":"beta","V":"beta"},{"N":"release","V":"release"}],"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":"hotness","type":{"Type":17,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":8,"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":9,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":15,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"validators":2,"position":{"Index":16,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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":"sml_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},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_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":["id"]},{"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":["id"]},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"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":7,"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":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":"downloads","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":"denied","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"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":14,"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":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"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"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"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"}],"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":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":5,"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"}],"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":"hotness","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":"denied","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":15,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"optional":true,"validators":2,"position":{"Index":16,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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":"sml_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":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_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 8b7fdad0..25c01af0 100644 --- a/generated/ent/migrate/schema.go +++ b/generated/ent/migrate/schema.go @@ -108,18 +108,18 @@ var ( {Name: "short_description", Type: field.TypeString, Size: 128}, {Name: "full_description", Type: field.TypeString}, {Name: "logo", Type: field.TypeString}, - {Name: "source_url", Type: field.TypeString}, + {Name: "source_url", Type: field.TypeString, Nullable: true}, {Name: "creator_id", Type: field.TypeString}, {Name: "approved", Type: field.TypeBool, Default: false}, - {Name: "views", Type: field.TypeUint}, - {Name: "hotness", Type: field.TypeUint}, - {Name: "popularity", Type: field.TypeUint}, - {Name: "downloads", Type: field.TypeUint}, + {Name: "views", Type: field.TypeUint, Default: 0}, + {Name: "hotness", Type: field.TypeUint, Default: 0}, + {Name: "popularity", Type: field.TypeUint, Default: 0}, + {Name: "downloads", Type: field.TypeUint, Default: 0}, {Name: "denied", Type: field.TypeBool, Default: false}, - {Name: "last_version_date", Type: field.TypeTime}, + {Name: "last_version_date", Type: field.TypeTime, Nullable: true}, {Name: "mod_reference", Type: field.TypeString, Unique: true, Size: 32}, - {Name: "hidden", Type: field.TypeBool}, - {Name: "compatibility", Type: field.TypeJSON}, + {Name: "hidden", Type: field.TypeBool, Default: false}, + {Name: "compatibility", Type: field.TypeJSON, Nullable: true}, } // ModsTable holds the schema information for the "mods" table. ModsTable = &schema.Table{ @@ -177,7 +177,7 @@ var ( {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "version", Type: field.TypeString, Unique: true, Size: 32}, {Name: "satisfactory_version", Type: field.TypeInt}, - {Name: "stability", Type: field.TypeEnum, Enums: []string{"alpha", "beta", "release"}}, + {Name: "stability", Type: field.TypeEnum, Enums: []string{"release", "beta", "alpha"}}, {Name: "date", Type: field.TypeTime}, {Name: "link", Type: field.TypeString}, {Name: "changelog", Type: field.TypeString}, @@ -425,20 +425,20 @@ var ( {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "version", Type: field.TypeString, Size: 16}, {Name: "sml_version", Type: field.TypeString, Size: 16}, - {Name: "changelog", Type: field.TypeString}, - {Name: "downloads", Type: field.TypeUint}, - {Name: "key", Type: field.TypeString}, - {Name: "stability", Type: field.TypeEnum, Enums: []string{"alpha", "beta", "release"}}, + {Name: "changelog", Type: field.TypeString, Nullable: true}, + {Name: "downloads", Type: field.TypeUint, Default: 0}, + {Name: "key", Type: field.TypeString, Nullable: true}, + {Name: "stability", Type: field.TypeEnum, Enums: []string{"release", "beta", "alpha"}}, {Name: "approved", Type: field.TypeBool, Default: false}, - {Name: "hotness", Type: field.TypeUint}, + {Name: "hotness", Type: field.TypeUint, Default: 0}, {Name: "denied", Type: field.TypeBool, Default: false}, - {Name: "metadata", Type: field.TypeString}, + {Name: "metadata", Type: field.TypeString, Nullable: true}, {Name: "mod_reference", Type: field.TypeString, Size: 32}, - {Name: "version_major", Type: field.TypeInt}, - {Name: "version_minor", Type: field.TypeInt}, - {Name: "version_patch", Type: field.TypeInt}, - {Name: "size", Type: field.TypeInt64}, - {Name: "hash", Type: field.TypeString, Size: 64}, + {Name: "version_major", Type: field.TypeInt, Nullable: true}, + {Name: "version_minor", Type: field.TypeInt, Nullable: true}, + {Name: "version_patch", Type: field.TypeInt, Nullable: true}, + {Name: "size", Type: field.TypeInt64, Nullable: true}, + {Name: "hash", Type: field.TypeString, Nullable: true, Size: 64}, {Name: "mod_id", Type: field.TypeString}, } // VersionsTable holds the schema information for the "versions" table. @@ -508,9 +508,9 @@ var ( VersionTargetsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, {Name: "target_name", Type: field.TypeString}, - {Name: "key", Type: field.TypeString}, - {Name: "hash", Type: field.TypeString}, - {Name: "size", Type: field.TypeInt64}, + {Name: "key", Type: field.TypeString, Nullable: true}, + {Name: "hash", Type: field.TypeString, Nullable: true}, + {Name: "size", Type: field.TypeInt64, Nullable: true}, {Name: "version_id", Type: field.TypeString}, } // VersionTargetsTable holds the schema information for the "version_targets" table. diff --git a/generated/ent/mod.go b/generated/ent/mod.go index 7c7bbeb4..87a147d8 100644 --- a/generated/ent/mod.go +++ b/generated/ent/mod.go @@ -10,8 +10,8 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/util" ) // Mod is the model entity for the Mod schema. @@ -56,7 +56,7 @@ type Mod struct { // Hidden holds the value of the "hidden" field. Hidden bool `json:"hidden,omitempty"` // Compatibility holds the value of the "compatibility" field. - Compatibility *postgres.CompatibilityInfo `json:"compatibility,omitempty"` + Compatibility *util.CompatibilityInfo `json:"compatibility,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ModQuery when eager-loading is set. Edges ModEdges `json:"edges"` diff --git a/generated/ent/mod/mod.go b/generated/ent/mod/mod.go index ebda24d3..79ae3c80 100644 --- a/generated/ent/mod/mod.go +++ b/generated/ent/mod/mod.go @@ -180,10 +180,20 @@ var ( ShortDescriptionValidator func(string) error // DefaultApproved holds the default value on creation for the "approved" field. DefaultApproved bool + // 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 + // DefaultPopularity holds the default value on creation for the "popularity" field. + DefaultPopularity uint + // DefaultDownloads holds the default value on creation for the "downloads" field. + DefaultDownloads uint // DefaultDenied holds the default value on creation for the "denied" field. DefaultDenied bool // ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. ModReferenceValidator func(string) error + // 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 ) diff --git a/generated/ent/mod/where.go b/generated/ent/mod/where.go index 170d06bf..a284da4f 100644 --- a/generated/ent/mod/where.go +++ b/generated/ent/mod/where.go @@ -600,6 +600,16 @@ func SourceURLHasSuffix(v string) predicate.Mod { return predicate.Mod(sql.FieldHasSuffix(FieldSourceURL, v)) } +// SourceURLIsNil applies the IsNil predicate on the "source_url" field. +func SourceURLIsNil() predicate.Mod { + return predicate.Mod(sql.FieldIsNull(FieldSourceURL)) +} + +// SourceURLNotNil applies the NotNil predicate on the "source_url" field. +func SourceURLNotNil() predicate.Mod { + return predicate.Mod(sql.FieldNotNull(FieldSourceURL)) +} + // SourceURLEqualFold applies the EqualFold predicate on the "source_url" field. func SourceURLEqualFold(v string) predicate.Mod { return predicate.Mod(sql.FieldEqualFold(FieldSourceURL, v)) @@ -895,6 +905,16 @@ func LastVersionDateLTE(v time.Time) predicate.Mod { return predicate.Mod(sql.FieldLTE(FieldLastVersionDate, v)) } +// LastVersionDateIsNil applies the IsNil predicate on the "last_version_date" field. +func LastVersionDateIsNil() predicate.Mod { + return predicate.Mod(sql.FieldIsNull(FieldLastVersionDate)) +} + +// LastVersionDateNotNil applies the NotNil predicate on the "last_version_date" field. +func LastVersionDateNotNil() predicate.Mod { + return predicate.Mod(sql.FieldNotNull(FieldLastVersionDate)) +} + // ModReferenceEQ applies the EQ predicate on the "mod_reference" field. func ModReferenceEQ(v string) predicate.Mod { return predicate.Mod(sql.FieldEQ(FieldModReference, v)) @@ -970,6 +990,16 @@ func HiddenNEQ(v bool) predicate.Mod { return predicate.Mod(sql.FieldNEQ(FieldHidden, v)) } +// CompatibilityIsNil applies the IsNil predicate on the "compatibility" field. +func CompatibilityIsNil() predicate.Mod { + return predicate.Mod(sql.FieldIsNull(FieldCompatibility)) +} + +// CompatibilityNotNil applies the NotNil predicate on the "compatibility" field. +func CompatibilityNotNil() predicate.Mod { + return predicate.Mod(sql.FieldNotNull(FieldCompatibility)) +} + // HasVersions applies the HasEdge predicate on the "versions" edge. func HasVersions() predicate.Mod { return predicate.Mod(func(s *sql.Selector) { diff --git a/generated/ent/mod_create.go b/generated/ent/mod_create.go index 93acafac..389e47f2 100644 --- a/generated/ent/mod_create.go +++ b/generated/ent/mod_create.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated/ent/mod" "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/generated/ent/user" "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/util" ) // ModCreate is the builder for creating a Mod entity. @@ -99,6 +99,14 @@ func (mc *ModCreate) SetSourceURL(s string) *ModCreate { return mc } +// SetNillableSourceURL sets the "source_url" field if the given value is not nil. +func (mc *ModCreate) SetNillableSourceURL(s *string) *ModCreate { + if s != nil { + mc.SetSourceURL(*s) + } + return mc +} + // SetCreatorID sets the "creator_id" field. func (mc *ModCreate) SetCreatorID(s string) *ModCreate { mc.mutation.SetCreatorID(s) @@ -125,24 +133,56 @@ func (mc *ModCreate) SetViews(u uint) *ModCreate { return mc } +// SetNillableViews sets the "views" field if the given value is not nil. +func (mc *ModCreate) SetNillableViews(u *uint) *ModCreate { + if u != nil { + mc.SetViews(*u) + } + return mc +} + // SetHotness sets the "hotness" field. func (mc *ModCreate) SetHotness(u uint) *ModCreate { mc.mutation.SetHotness(u) return mc } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (mc *ModCreate) SetNillableHotness(u *uint) *ModCreate { + if u != nil { + mc.SetHotness(*u) + } + return mc +} + // SetPopularity sets the "popularity" field. func (mc *ModCreate) SetPopularity(u uint) *ModCreate { mc.mutation.SetPopularity(u) return mc } +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (mc *ModCreate) SetNillablePopularity(u *uint) *ModCreate { + if u != nil { + mc.SetPopularity(*u) + } + return mc +} + // SetDownloads sets the "downloads" field. func (mc *ModCreate) SetDownloads(u uint) *ModCreate { mc.mutation.SetDownloads(u) return mc } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (mc *ModCreate) SetNillableDownloads(u *uint) *ModCreate { + if u != nil { + mc.SetDownloads(*u) + } + return mc +} + // SetDenied sets the "denied" field. func (mc *ModCreate) SetDenied(b bool) *ModCreate { mc.mutation.SetDenied(b) @@ -163,6 +203,14 @@ func (mc *ModCreate) SetLastVersionDate(t time.Time) *ModCreate { return mc } +// SetNillableLastVersionDate sets the "last_version_date" field if the given value is not nil. +func (mc *ModCreate) SetNillableLastVersionDate(t *time.Time) *ModCreate { + if t != nil { + mc.SetLastVersionDate(*t) + } + return mc +} + // SetModReference sets the "mod_reference" field. func (mc *ModCreate) SetModReference(s string) *ModCreate { mc.mutation.SetModReference(s) @@ -175,9 +223,17 @@ func (mc *ModCreate) SetHidden(b bool) *ModCreate { return mc } +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (mc *ModCreate) SetNillableHidden(b *bool) *ModCreate { + if b != nil { + mc.SetHidden(*b) + } + return mc +} + // SetCompatibility sets the "compatibility" field. -func (mc *ModCreate) SetCompatibility(pi *postgres.CompatibilityInfo) *ModCreate { - mc.mutation.SetCompatibility(pi) +func (mc *ModCreate) SetCompatibility(ui *util.CompatibilityInfo) *ModCreate { + mc.mutation.SetCompatibility(ui) return mc } @@ -310,10 +366,30 @@ func (mc *ModCreate) defaults() error { v := mod.DefaultApproved mc.mutation.SetApproved(v) } + if _, ok := mc.mutation.Views(); !ok { + v := mod.DefaultViews + mc.mutation.SetViews(v) + } + if _, ok := mc.mutation.Hotness(); !ok { + v := mod.DefaultHotness + mc.mutation.SetHotness(v) + } + if _, ok := mc.mutation.Popularity(); !ok { + v := mod.DefaultPopularity + mc.mutation.SetPopularity(v) + } + if _, ok := mc.mutation.Downloads(); !ok { + v := mod.DefaultDownloads + mc.mutation.SetDownloads(v) + } if _, ok := mc.mutation.Denied(); !ok { v := mod.DefaultDenied mc.mutation.SetDenied(v) } + if _, ok := mc.mutation.Hidden(); !ok { + v := mod.DefaultHidden + mc.mutation.SetHidden(v) + } if _, ok := mc.mutation.ID(); !ok { if mod.DefaultID == nil { return fmt.Errorf("ent: uninitialized mod.DefaultID (forgotten import ent/runtime?)") @@ -354,9 +430,6 @@ func (mc *ModCreate) check() error { if _, ok := mc.mutation.Logo(); !ok { return &ValidationError{Name: "logo", err: errors.New(`ent: missing required field "Mod.logo"`)} } - if _, ok := mc.mutation.SourceURL(); !ok { - return &ValidationError{Name: "source_url", err: errors.New(`ent: missing required field "Mod.source_url"`)} - } if _, ok := mc.mutation.CreatorID(); !ok { return &ValidationError{Name: "creator_id", err: errors.New(`ent: missing required field "Mod.creator_id"`)} } @@ -378,9 +451,6 @@ func (mc *ModCreate) check() error { if _, ok := mc.mutation.Denied(); !ok { return &ValidationError{Name: "denied", err: errors.New(`ent: missing required field "Mod.denied"`)} } - if _, ok := mc.mutation.LastVersionDate(); !ok { - return &ValidationError{Name: "last_version_date", err: errors.New(`ent: missing required field "Mod.last_version_date"`)} - } if _, ok := mc.mutation.ModReference(); !ok { return &ValidationError{Name: "mod_reference", err: errors.New(`ent: missing required field "Mod.mod_reference"`)} } @@ -392,9 +462,6 @@ func (mc *ModCreate) check() error { if _, ok := mc.mutation.Hidden(); !ok { return &ValidationError{Name: "hidden", err: errors.New(`ent: missing required field "Mod.hidden"`)} } - if _, ok := mc.mutation.Compatibility(); !ok { - return &ValidationError{Name: "compatibility", err: errors.New(`ent: missing required field "Mod.compatibility"`)} - } return nil } @@ -717,6 +784,12 @@ func (u *ModUpsert) UpdateSourceURL() *ModUpsert { return u } +// ClearSourceURL clears the value of the "source_url" field. +func (u *ModUpsert) ClearSourceURL() *ModUpsert { + u.SetNull(mod.FieldSourceURL) + return u +} + // SetCreatorID sets the "creator_id" field. func (u *ModUpsert) SetCreatorID(v string) *ModUpsert { u.Set(mod.FieldCreatorID, v) @@ -837,6 +910,12 @@ func (u *ModUpsert) UpdateLastVersionDate() *ModUpsert { return u } +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (u *ModUpsert) ClearLastVersionDate() *ModUpsert { + u.SetNull(mod.FieldLastVersionDate) + return u +} + // SetModReference sets the "mod_reference" field. func (u *ModUpsert) SetModReference(v string) *ModUpsert { u.Set(mod.FieldModReference, v) @@ -862,7 +941,7 @@ func (u *ModUpsert) UpdateHidden() *ModUpsert { } // SetCompatibility sets the "compatibility" field. -func (u *ModUpsert) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsert { +func (u *ModUpsert) SetCompatibility(v *util.CompatibilityInfo) *ModUpsert { u.Set(mod.FieldCompatibility, v) return u } @@ -873,6 +952,12 @@ func (u *ModUpsert) UpdateCompatibility() *ModUpsert { return u } +// ClearCompatibility clears the value of the "compatibility" field. +func (u *ModUpsert) ClearCompatibility() *ModUpsert { + u.SetNull(mod.FieldCompatibility) + 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: // @@ -1029,6 +1114,13 @@ func (u *ModUpsertOne) UpdateSourceURL() *ModUpsertOne { }) } +// ClearSourceURL clears the value of the "source_url" field. +func (u *ModUpsertOne) ClearSourceURL() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.ClearSourceURL() + }) +} + // SetCreatorID sets the "creator_id" field. func (u *ModUpsertOne) SetCreatorID(v string) *ModUpsertOne { return u.Update(func(s *ModUpsert) { @@ -1169,6 +1261,13 @@ func (u *ModUpsertOne) UpdateLastVersionDate() *ModUpsertOne { }) } +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (u *ModUpsertOne) ClearLastVersionDate() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.ClearLastVersionDate() + }) +} + // SetModReference sets the "mod_reference" field. func (u *ModUpsertOne) SetModReference(v string) *ModUpsertOne { return u.Update(func(s *ModUpsert) { @@ -1198,7 +1297,7 @@ func (u *ModUpsertOne) UpdateHidden() *ModUpsertOne { } // SetCompatibility sets the "compatibility" field. -func (u *ModUpsertOne) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsertOne { +func (u *ModUpsertOne) SetCompatibility(v *util.CompatibilityInfo) *ModUpsertOne { return u.Update(func(s *ModUpsert) { s.SetCompatibility(v) }) @@ -1211,6 +1310,13 @@ func (u *ModUpsertOne) UpdateCompatibility() *ModUpsertOne { }) } +// ClearCompatibility clears the value of the "compatibility" field. +func (u *ModUpsertOne) ClearCompatibility() *ModUpsertOne { + return u.Update(func(s *ModUpsert) { + s.ClearCompatibility() + }) +} + // Exec executes the query. func (u *ModUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1534,6 +1640,13 @@ func (u *ModUpsertBulk) UpdateSourceURL() *ModUpsertBulk { }) } +// ClearSourceURL clears the value of the "source_url" field. +func (u *ModUpsertBulk) ClearSourceURL() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.ClearSourceURL() + }) +} + // SetCreatorID sets the "creator_id" field. func (u *ModUpsertBulk) SetCreatorID(v string) *ModUpsertBulk { return u.Update(func(s *ModUpsert) { @@ -1674,6 +1787,13 @@ func (u *ModUpsertBulk) UpdateLastVersionDate() *ModUpsertBulk { }) } +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (u *ModUpsertBulk) ClearLastVersionDate() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.ClearLastVersionDate() + }) +} + // SetModReference sets the "mod_reference" field. func (u *ModUpsertBulk) SetModReference(v string) *ModUpsertBulk { return u.Update(func(s *ModUpsert) { @@ -1703,7 +1823,7 @@ func (u *ModUpsertBulk) UpdateHidden() *ModUpsertBulk { } // SetCompatibility sets the "compatibility" field. -func (u *ModUpsertBulk) SetCompatibility(v *postgres.CompatibilityInfo) *ModUpsertBulk { +func (u *ModUpsertBulk) SetCompatibility(v *util.CompatibilityInfo) *ModUpsertBulk { return u.Update(func(s *ModUpsert) { s.SetCompatibility(v) }) @@ -1716,6 +1836,13 @@ func (u *ModUpsertBulk) UpdateCompatibility() *ModUpsertBulk { }) } +// ClearCompatibility clears the value of the "compatibility" field. +func (u *ModUpsertBulk) ClearCompatibility() *ModUpsertBulk { + return u.Update(func(s *ModUpsert) { + s.ClearCompatibility() + }) +} + // Exec executes the query. func (u *ModUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/generated/ent/mod_update.go b/generated/ent/mod_update.go index fe182682..69e368de 100644 --- a/generated/ent/mod_update.go +++ b/generated/ent/mod_update.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated/ent/mod" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/tag" "github.com/satisfactorymodding/smr-api/generated/ent/user" "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/util" ) // ModUpdate is the builder for updating Mod entities. @@ -89,6 +89,20 @@ func (mu *ModUpdate) SetSourceURL(s string) *ModUpdate { return mu } +// SetNillableSourceURL sets the "source_url" field if the given value is not nil. +func (mu *ModUpdate) SetNillableSourceURL(s *string) *ModUpdate { + if s != nil { + mu.SetSourceURL(*s) + } + return mu +} + +// ClearSourceURL clears the value of the "source_url" field. +func (mu *ModUpdate) ClearSourceURL() *ModUpdate { + mu.mutation.ClearSourceURL() + return mu +} + // SetCreatorID sets the "creator_id" field. func (mu *ModUpdate) SetCreatorID(s string) *ModUpdate { mu.mutation.SetCreatorID(s) @@ -116,6 +130,14 @@ func (mu *ModUpdate) SetViews(u uint) *ModUpdate { return mu } +// SetNillableViews sets the "views" field if the given value is not nil. +func (mu *ModUpdate) SetNillableViews(u *uint) *ModUpdate { + if u != nil { + mu.SetViews(*u) + } + return mu +} + // AddViews adds u to the "views" field. func (mu *ModUpdate) AddViews(u int) *ModUpdate { mu.mutation.AddViews(u) @@ -129,6 +151,14 @@ func (mu *ModUpdate) SetHotness(u uint) *ModUpdate { return mu } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (mu *ModUpdate) SetNillableHotness(u *uint) *ModUpdate { + if u != nil { + mu.SetHotness(*u) + } + return mu +} + // AddHotness adds u to the "hotness" field. func (mu *ModUpdate) AddHotness(u int) *ModUpdate { mu.mutation.AddHotness(u) @@ -142,6 +172,14 @@ func (mu *ModUpdate) SetPopularity(u uint) *ModUpdate { return mu } +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (mu *ModUpdate) SetNillablePopularity(u *uint) *ModUpdate { + if u != nil { + mu.SetPopularity(*u) + } + return mu +} + // AddPopularity adds u to the "popularity" field. func (mu *ModUpdate) AddPopularity(u int) *ModUpdate { mu.mutation.AddPopularity(u) @@ -155,6 +193,14 @@ func (mu *ModUpdate) SetDownloads(u uint) *ModUpdate { return mu } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (mu *ModUpdate) SetNillableDownloads(u *uint) *ModUpdate { + if u != nil { + mu.SetDownloads(*u) + } + return mu +} + // AddDownloads adds u to the "downloads" field. func (mu *ModUpdate) AddDownloads(u int) *ModUpdate { mu.mutation.AddDownloads(u) @@ -181,6 +227,20 @@ func (mu *ModUpdate) SetLastVersionDate(t time.Time) *ModUpdate { return mu } +// SetNillableLastVersionDate sets the "last_version_date" field if the given value is not nil. +func (mu *ModUpdate) SetNillableLastVersionDate(t *time.Time) *ModUpdate { + if t != nil { + mu.SetLastVersionDate(*t) + } + return mu +} + +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (mu *ModUpdate) ClearLastVersionDate() *ModUpdate { + mu.mutation.ClearLastVersionDate() + return mu +} + // SetModReference sets the "mod_reference" field. func (mu *ModUpdate) SetModReference(s string) *ModUpdate { mu.mutation.SetModReference(s) @@ -193,9 +253,23 @@ func (mu *ModUpdate) SetHidden(b bool) *ModUpdate { return mu } +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (mu *ModUpdate) SetNillableHidden(b *bool) *ModUpdate { + if b != nil { + mu.SetHidden(*b) + } + return mu +} + // SetCompatibility sets the "compatibility" field. -func (mu *ModUpdate) SetCompatibility(pi *postgres.CompatibilityInfo) *ModUpdate { - mu.mutation.SetCompatibility(pi) +func (mu *ModUpdate) SetCompatibility(ui *util.CompatibilityInfo) *ModUpdate { + mu.mutation.SetCompatibility(ui) + return mu +} + +// ClearCompatibility clears the value of the "compatibility" field. +func (mu *ModUpdate) ClearCompatibility() *ModUpdate { + mu.mutation.ClearCompatibility() return mu } @@ -452,6 +526,9 @@ func (mu *ModUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := mu.mutation.SourceURL(); ok { _spec.SetField(mod.FieldSourceURL, field.TypeString, value) } + if mu.mutation.SourceURLCleared() { + _spec.ClearField(mod.FieldSourceURL, field.TypeString) + } if value, ok := mu.mutation.CreatorID(); ok { _spec.SetField(mod.FieldCreatorID, field.TypeString, value) } @@ -488,6 +565,9 @@ func (mu *ModUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := mu.mutation.LastVersionDate(); ok { _spec.SetField(mod.FieldLastVersionDate, field.TypeTime, value) } + if mu.mutation.LastVersionDateCleared() { + _spec.ClearField(mod.FieldLastVersionDate, field.TypeTime) + } if value, ok := mu.mutation.ModReference(); ok { _spec.SetField(mod.FieldModReference, field.TypeString, value) } @@ -497,6 +577,9 @@ func (mu *ModUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := mu.mutation.Compatibility(); ok { _spec.SetField(mod.FieldCompatibility, field.TypeJSON, value) } + if mu.mutation.CompatibilityCleared() { + _spec.ClearField(mod.FieldCompatibility, field.TypeJSON) + } if mu.mutation.VersionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -767,6 +850,20 @@ func (muo *ModUpdateOne) SetSourceURL(s string) *ModUpdateOne { return muo } +// SetNillableSourceURL sets the "source_url" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableSourceURL(s *string) *ModUpdateOne { + if s != nil { + muo.SetSourceURL(*s) + } + return muo +} + +// ClearSourceURL clears the value of the "source_url" field. +func (muo *ModUpdateOne) ClearSourceURL() *ModUpdateOne { + muo.mutation.ClearSourceURL() + return muo +} + // SetCreatorID sets the "creator_id" field. func (muo *ModUpdateOne) SetCreatorID(s string) *ModUpdateOne { muo.mutation.SetCreatorID(s) @@ -794,6 +891,14 @@ func (muo *ModUpdateOne) SetViews(u uint) *ModUpdateOne { return muo } +// SetNillableViews sets the "views" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableViews(u *uint) *ModUpdateOne { + if u != nil { + muo.SetViews(*u) + } + return muo +} + // AddViews adds u to the "views" field. func (muo *ModUpdateOne) AddViews(u int) *ModUpdateOne { muo.mutation.AddViews(u) @@ -807,6 +912,14 @@ func (muo *ModUpdateOne) SetHotness(u uint) *ModUpdateOne { return muo } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableHotness(u *uint) *ModUpdateOne { + if u != nil { + muo.SetHotness(*u) + } + return muo +} + // AddHotness adds u to the "hotness" field. func (muo *ModUpdateOne) AddHotness(u int) *ModUpdateOne { muo.mutation.AddHotness(u) @@ -820,6 +933,14 @@ func (muo *ModUpdateOne) SetPopularity(u uint) *ModUpdateOne { return muo } +// SetNillablePopularity sets the "popularity" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillablePopularity(u *uint) *ModUpdateOne { + if u != nil { + muo.SetPopularity(*u) + } + return muo +} + // AddPopularity adds u to the "popularity" field. func (muo *ModUpdateOne) AddPopularity(u int) *ModUpdateOne { muo.mutation.AddPopularity(u) @@ -833,6 +954,14 @@ func (muo *ModUpdateOne) SetDownloads(u uint) *ModUpdateOne { return muo } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableDownloads(u *uint) *ModUpdateOne { + if u != nil { + muo.SetDownloads(*u) + } + return muo +} + // AddDownloads adds u to the "downloads" field. func (muo *ModUpdateOne) AddDownloads(u int) *ModUpdateOne { muo.mutation.AddDownloads(u) @@ -859,6 +988,20 @@ func (muo *ModUpdateOne) SetLastVersionDate(t time.Time) *ModUpdateOne { return muo } +// SetNillableLastVersionDate sets the "last_version_date" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableLastVersionDate(t *time.Time) *ModUpdateOne { + if t != nil { + muo.SetLastVersionDate(*t) + } + return muo +} + +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (muo *ModUpdateOne) ClearLastVersionDate() *ModUpdateOne { + muo.mutation.ClearLastVersionDate() + return muo +} + // SetModReference sets the "mod_reference" field. func (muo *ModUpdateOne) SetModReference(s string) *ModUpdateOne { muo.mutation.SetModReference(s) @@ -871,9 +1014,23 @@ func (muo *ModUpdateOne) SetHidden(b bool) *ModUpdateOne { return muo } +// SetNillableHidden sets the "hidden" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableHidden(b *bool) *ModUpdateOne { + if b != nil { + muo.SetHidden(*b) + } + return muo +} + // SetCompatibility sets the "compatibility" field. -func (muo *ModUpdateOne) SetCompatibility(pi *postgres.CompatibilityInfo) *ModUpdateOne { - muo.mutation.SetCompatibility(pi) +func (muo *ModUpdateOne) SetCompatibility(ui *util.CompatibilityInfo) *ModUpdateOne { + muo.mutation.SetCompatibility(ui) + return muo +} + +// ClearCompatibility clears the value of the "compatibility" field. +func (muo *ModUpdateOne) ClearCompatibility() *ModUpdateOne { + muo.mutation.ClearCompatibility() return muo } @@ -1160,6 +1317,9 @@ func (muo *ModUpdateOne) sqlSave(ctx context.Context) (_node *Mod, err error) { if value, ok := muo.mutation.SourceURL(); ok { _spec.SetField(mod.FieldSourceURL, field.TypeString, value) } + if muo.mutation.SourceURLCleared() { + _spec.ClearField(mod.FieldSourceURL, field.TypeString) + } if value, ok := muo.mutation.CreatorID(); ok { _spec.SetField(mod.FieldCreatorID, field.TypeString, value) } @@ -1196,6 +1356,9 @@ func (muo *ModUpdateOne) sqlSave(ctx context.Context) (_node *Mod, err error) { if value, ok := muo.mutation.LastVersionDate(); ok { _spec.SetField(mod.FieldLastVersionDate, field.TypeTime, value) } + if muo.mutation.LastVersionDateCleared() { + _spec.ClearField(mod.FieldLastVersionDate, field.TypeTime) + } if value, ok := muo.mutation.ModReference(); ok { _spec.SetField(mod.FieldModReference, field.TypeString, value) } @@ -1205,6 +1368,9 @@ func (muo *ModUpdateOne) sqlSave(ctx context.Context) (_node *Mod, err error) { if value, ok := muo.mutation.Compatibility(); ok { _spec.SetField(mod.FieldCompatibility, field.TypeJSON, value) } + if muo.mutation.CompatibilityCleared() { + _spec.ClearField(mod.FieldCompatibility, field.TypeJSON) + } if muo.mutation.VersionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/generated/ent/mutation.go b/generated/ent/mutation.go index b2b39e89..8d527afe 100644 --- a/generated/ent/mutation.go +++ b/generated/ent/mutation.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated/ent/announcement" "github.com/satisfactorymodding/smr-api/generated/ent/guide" "github.com/satisfactorymodding/smr-api/generated/ent/guidetag" @@ -28,6 +27,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" + "github.com/satisfactorymodding/smr-api/util" ) const ( @@ -1959,7 +1959,7 @@ type ModMutation struct { last_version_date *time.Time mod_reference *string hidden *bool - compatibility **postgres.CompatibilityInfo + compatibility **util.CompatibilityInfo clearedFields map[string]struct{} versions map[string]struct{} removedversions map[string]struct{} @@ -2378,9 +2378,22 @@ func (m *ModMutation) OldSourceURL(ctx context.Context) (v string, err error) { return oldValue.SourceURL, nil } +// ClearSourceURL clears the value of the "source_url" field. +func (m *ModMutation) ClearSourceURL() { + m.source_url = nil + m.clearedFields[mod.FieldSourceURL] = struct{}{} +} + +// SourceURLCleared returns if the "source_url" field was cleared in this mutation. +func (m *ModMutation) SourceURLCleared() bool { + _, ok := m.clearedFields[mod.FieldSourceURL] + return ok +} + // ResetSourceURL resets all changes to the "source_url" field. func (m *ModMutation) ResetSourceURL() { m.source_url = nil + delete(m.clearedFields, mod.FieldSourceURL) } // SetCreatorID sets the "creator_id" field. @@ -2746,9 +2759,22 @@ func (m *ModMutation) OldLastVersionDate(ctx context.Context) (v time.Time, err return oldValue.LastVersionDate, nil } +// ClearLastVersionDate clears the value of the "last_version_date" field. +func (m *ModMutation) ClearLastVersionDate() { + m.last_version_date = nil + m.clearedFields[mod.FieldLastVersionDate] = struct{}{} +} + +// LastVersionDateCleared returns if the "last_version_date" field was cleared in this mutation. +func (m *ModMutation) LastVersionDateCleared() bool { + _, ok := m.clearedFields[mod.FieldLastVersionDate] + return ok +} + // ResetLastVersionDate resets all changes to the "last_version_date" field. func (m *ModMutation) ResetLastVersionDate() { m.last_version_date = nil + delete(m.clearedFields, mod.FieldLastVersionDate) } // SetModReference sets the "mod_reference" field. @@ -2824,12 +2850,12 @@ func (m *ModMutation) ResetHidden() { } // SetCompatibility sets the "compatibility" field. -func (m *ModMutation) SetCompatibility(pi *postgres.CompatibilityInfo) { - m.compatibility = &pi +func (m *ModMutation) SetCompatibility(ui *util.CompatibilityInfo) { + m.compatibility = &ui } // Compatibility returns the value of the "compatibility" field in the mutation. -func (m *ModMutation) Compatibility() (r *postgres.CompatibilityInfo, exists bool) { +func (m *ModMutation) Compatibility() (r *util.CompatibilityInfo, exists bool) { v := m.compatibility if v == nil { return @@ -2840,7 +2866,7 @@ func (m *ModMutation) Compatibility() (r *postgres.CompatibilityInfo, exists boo // OldCompatibility returns the old "compatibility" field's value of the Mod entity. // If the Mod 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 *ModMutation) OldCompatibility(ctx context.Context) (v *postgres.CompatibilityInfo, err error) { +func (m *ModMutation) OldCompatibility(ctx context.Context) (v *util.CompatibilityInfo, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCompatibility is only allowed on UpdateOne operations") } @@ -2854,9 +2880,22 @@ func (m *ModMutation) OldCompatibility(ctx context.Context) (v *postgres.Compati return oldValue.Compatibility, nil } +// ClearCompatibility clears the value of the "compatibility" field. +func (m *ModMutation) ClearCompatibility() { + m.compatibility = nil + m.clearedFields[mod.FieldCompatibility] = struct{}{} +} + +// CompatibilityCleared returns if the "compatibility" field was cleared in this mutation. +func (m *ModMutation) CompatibilityCleared() bool { + _, ok := m.clearedFields[mod.FieldCompatibility] + return ok +} + // ResetCompatibility resets all changes to the "compatibility" field. func (m *ModMutation) ResetCompatibility() { m.compatibility = nil + delete(m.clearedFields, mod.FieldCompatibility) } // AddVersionIDs adds the "versions" edge to the Version entity by ids. @@ -3396,7 +3435,7 @@ func (m *ModMutation) SetField(name string, value ent.Value) error { m.SetHidden(v) return nil case mod.FieldCompatibility: - v, ok := value.(*postgres.CompatibilityInfo) + v, ok := value.(*util.CompatibilityInfo) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -3486,6 +3525,15 @@ func (m *ModMutation) ClearedFields() []string { if m.FieldCleared(mod.FieldDeletedAt) { fields = append(fields, mod.FieldDeletedAt) } + if m.FieldCleared(mod.FieldSourceURL) { + fields = append(fields, mod.FieldSourceURL) + } + if m.FieldCleared(mod.FieldLastVersionDate) { + fields = append(fields, mod.FieldLastVersionDate) + } + if m.FieldCleared(mod.FieldCompatibility) { + fields = append(fields, mod.FieldCompatibility) + } return fields } @@ -3503,6 +3551,15 @@ func (m *ModMutation) ClearField(name string) error { case mod.FieldDeletedAt: m.ClearDeletedAt() return nil + case mod.FieldSourceURL: + m.ClearSourceURL() + return nil + case mod.FieldLastVersionDate: + m.ClearLastVersionDate() + return nil + case mod.FieldCompatibility: + m.ClearCompatibility() + return nil } return fmt.Errorf("unknown Mod nullable field %s", name) } @@ -4125,7 +4182,7 @@ type SmlVersionMutation struct { version *string satisfactory_version *int addsatisfactory_version *int - stability *smlversion.Stability + stability *util.Stability date *time.Time link *string changelog *string @@ -4458,12 +4515,12 @@ func (m *SmlVersionMutation) ResetSatisfactoryVersion() { } // SetStability sets the "stability" field. -func (m *SmlVersionMutation) SetStability(s smlversion.Stability) { - m.stability = &s +func (m *SmlVersionMutation) SetStability(u util.Stability) { + m.stability = &u } // Stability returns the value of the "stability" field in the mutation. -func (m *SmlVersionMutation) Stability() (r smlversion.Stability, exists bool) { +func (m *SmlVersionMutation) Stability() (r util.Stability, exists bool) { v := m.stability if v == nil { return @@ -4474,7 +4531,7 @@ func (m *SmlVersionMutation) Stability() (r smlversion.Stability, exists bool) { // OldStability returns the old "stability" field's value of the SmlVersion entity. // If the SmlVersion 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 *SmlVersionMutation) OldStability(ctx context.Context) (v smlversion.Stability, err error) { +func (m *SmlVersionMutation) OldStability(ctx context.Context) (v util.Stability, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStability is only allowed on UpdateOne operations") } @@ -4914,7 +4971,7 @@ func (m *SmlVersionMutation) SetField(name string, value ent.Value) error { m.SetSatisfactoryVersion(v) return nil case smlversion.FieldStability: - v, ok := value.(smlversion.Stability) + v, ok := value.(util.Stability) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -9484,7 +9541,7 @@ type VersionMutation struct { downloads *uint adddownloads *int key *string - stability *version.Stability + stability *util.Stability approved *bool hotness *uint addhotness *int @@ -9878,9 +9935,22 @@ func (m *VersionMutation) OldChangelog(ctx context.Context) (v string, err error return oldValue.Changelog, nil } +// ClearChangelog clears the value of the "changelog" field. +func (m *VersionMutation) ClearChangelog() { + m.changelog = nil + m.clearedFields[version.FieldChangelog] = struct{}{} +} + +// ChangelogCleared returns if the "changelog" field was cleared in this mutation. +func (m *VersionMutation) ChangelogCleared() bool { + _, ok := m.clearedFields[version.FieldChangelog] + return ok +} + // ResetChangelog resets all changes to the "changelog" field. func (m *VersionMutation) ResetChangelog() { m.changelog = nil + delete(m.clearedFields, version.FieldChangelog) } // SetDownloads sets the "downloads" field. @@ -9970,18 +10040,31 @@ func (m *VersionMutation) OldKey(ctx context.Context) (v string, err error) { return oldValue.Key, nil } +// ClearKey clears the value of the "key" field. +func (m *VersionMutation) ClearKey() { + m.key = nil + m.clearedFields[version.FieldKey] = struct{}{} +} + +// KeyCleared returns if the "key" field was cleared in this mutation. +func (m *VersionMutation) KeyCleared() bool { + _, ok := m.clearedFields[version.FieldKey] + return ok +} + // ResetKey resets all changes to the "key" field. func (m *VersionMutation) ResetKey() { m.key = nil + delete(m.clearedFields, version.FieldKey) } // SetStability sets the "stability" field. -func (m *VersionMutation) SetStability(v version.Stability) { - m.stability = &v +func (m *VersionMutation) SetStability(u util.Stability) { + m.stability = &u } // Stability returns the value of the "stability" field in the mutation. -func (m *VersionMutation) Stability() (r version.Stability, exists bool) { +func (m *VersionMutation) Stability() (r util.Stability, exists bool) { v := m.stability if v == nil { return @@ -9992,7 +10075,7 @@ func (m *VersionMutation) Stability() (r version.Stability, exists bool) { // OldStability returns the old "stability" field's value of the Version entity. // If the Version 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 *VersionMutation) OldStability(ctx context.Context) (v version.Stability, err error) { +func (m *VersionMutation) OldStability(ctx context.Context) (v util.Stability, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStability is only allowed on UpdateOne operations") } @@ -10170,9 +10253,22 @@ func (m *VersionMutation) OldMetadata(ctx context.Context) (v string, err error) return oldValue.Metadata, nil } +// ClearMetadata clears the value of the "metadata" field. +func (m *VersionMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[version.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *VersionMutation) MetadataCleared() bool { + _, ok := m.clearedFields[version.FieldMetadata] + return ok +} + // ResetMetadata resets all changes to the "metadata" field. func (m *VersionMutation) ResetMetadata() { m.metadata = nil + delete(m.clearedFields, version.FieldMetadata) } // SetModReference sets the "mod_reference" field. @@ -10261,10 +10357,24 @@ func (m *VersionMutation) AddedVersionMajor() (r int, exists bool) { return *v, true } +// ClearVersionMajor clears the value of the "version_major" field. +func (m *VersionMutation) ClearVersionMajor() { + m.version_major = nil + m.addversion_major = nil + m.clearedFields[version.FieldVersionMajor] = struct{}{} +} + +// VersionMajorCleared returns if the "version_major" field was cleared in this mutation. +func (m *VersionMutation) VersionMajorCleared() bool { + _, ok := m.clearedFields[version.FieldVersionMajor] + return ok +} + // ResetVersionMajor resets all changes to the "version_major" field. func (m *VersionMutation) ResetVersionMajor() { m.version_major = nil m.addversion_major = nil + delete(m.clearedFields, version.FieldVersionMajor) } // SetVersionMinor sets the "version_minor" field. @@ -10317,10 +10427,24 @@ func (m *VersionMutation) AddedVersionMinor() (r int, exists bool) { return *v, true } +// ClearVersionMinor clears the value of the "version_minor" field. +func (m *VersionMutation) ClearVersionMinor() { + m.version_minor = nil + m.addversion_minor = nil + m.clearedFields[version.FieldVersionMinor] = struct{}{} +} + +// VersionMinorCleared returns if the "version_minor" field was cleared in this mutation. +func (m *VersionMutation) VersionMinorCleared() bool { + _, ok := m.clearedFields[version.FieldVersionMinor] + return ok +} + // ResetVersionMinor resets all changes to the "version_minor" field. func (m *VersionMutation) ResetVersionMinor() { m.version_minor = nil m.addversion_minor = nil + delete(m.clearedFields, version.FieldVersionMinor) } // SetVersionPatch sets the "version_patch" field. @@ -10373,10 +10497,24 @@ func (m *VersionMutation) AddedVersionPatch() (r int, exists bool) { return *v, true } +// ClearVersionPatch clears the value of the "version_patch" field. +func (m *VersionMutation) ClearVersionPatch() { + m.version_patch = nil + m.addversion_patch = nil + m.clearedFields[version.FieldVersionPatch] = struct{}{} +} + +// VersionPatchCleared returns if the "version_patch" field was cleared in this mutation. +func (m *VersionMutation) VersionPatchCleared() bool { + _, ok := m.clearedFields[version.FieldVersionPatch] + return ok +} + // ResetVersionPatch resets all changes to the "version_patch" field. func (m *VersionMutation) ResetVersionPatch() { m.version_patch = nil m.addversion_patch = nil + delete(m.clearedFields, version.FieldVersionPatch) } // SetSize sets the "size" field. @@ -10429,10 +10567,24 @@ func (m *VersionMutation) AddedSize() (r int64, exists bool) { return *v, true } +// ClearSize clears the value of the "size" field. +func (m *VersionMutation) ClearSize() { + m.size = nil + m.addsize = nil + m.clearedFields[version.FieldSize] = struct{}{} +} + +// SizeCleared returns if the "size" field was cleared in this mutation. +func (m *VersionMutation) SizeCleared() bool { + _, ok := m.clearedFields[version.FieldSize] + return ok +} + // ResetSize resets all changes to the "size" field. func (m *VersionMutation) ResetSize() { m.size = nil m.addsize = nil + delete(m.clearedFields, version.FieldSize) } // SetHash sets the "hash" field. @@ -10466,9 +10618,22 @@ func (m *VersionMutation) OldHash(ctx context.Context) (v string, err error) { return oldValue.Hash, nil } +// ClearHash clears the value of the "hash" field. +func (m *VersionMutation) ClearHash() { + m.hash = nil + m.clearedFields[version.FieldHash] = struct{}{} +} + +// HashCleared returns if the "hash" field was cleared in this mutation. +func (m *VersionMutation) HashCleared() bool { + _, ok := m.clearedFields[version.FieldHash] + return ok +} + // ResetHash resets all changes to the "hash" field. func (m *VersionMutation) ResetHash() { m.hash = nil + delete(m.clearedFields, version.FieldHash) } // ClearMod clears the "mod" edge to the Mod entity. @@ -10871,7 +11036,7 @@ func (m *VersionMutation) SetField(name string, value ent.Value) error { m.SetKey(v) return nil case version.FieldStability: - v, ok := value.(version.Stability) + v, ok := value.(util.Stability) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -11055,6 +11220,30 @@ func (m *VersionMutation) ClearedFields() []string { if m.FieldCleared(version.FieldDeletedAt) { fields = append(fields, version.FieldDeletedAt) } + if m.FieldCleared(version.FieldChangelog) { + fields = append(fields, version.FieldChangelog) + } + if m.FieldCleared(version.FieldKey) { + fields = append(fields, version.FieldKey) + } + if m.FieldCleared(version.FieldMetadata) { + fields = append(fields, version.FieldMetadata) + } + if m.FieldCleared(version.FieldVersionMajor) { + fields = append(fields, version.FieldVersionMajor) + } + if m.FieldCleared(version.FieldVersionMinor) { + fields = append(fields, version.FieldVersionMinor) + } + if m.FieldCleared(version.FieldVersionPatch) { + fields = append(fields, version.FieldVersionPatch) + } + if m.FieldCleared(version.FieldSize) { + fields = append(fields, version.FieldSize) + } + if m.FieldCleared(version.FieldHash) { + fields = append(fields, version.FieldHash) + } return fields } @@ -11072,6 +11261,30 @@ func (m *VersionMutation) ClearField(name string) error { case version.FieldDeletedAt: m.ClearDeletedAt() return nil + case version.FieldChangelog: + m.ClearChangelog() + return nil + case version.FieldKey: + m.ClearKey() + return nil + case version.FieldMetadata: + m.ClearMetadata() + return nil + case version.FieldVersionMajor: + m.ClearVersionMajor() + return nil + case version.FieldVersionMinor: + m.ClearVersionMinor() + return nil + case version.FieldVersionPatch: + m.ClearVersionPatch() + return nil + case version.FieldSize: + m.ClearSize() + return nil + case version.FieldHash: + m.ClearHash() + return nil } return fmt.Errorf("unknown Version nullable field %s", name) } @@ -12074,9 +12287,22 @@ func (m *VersionTargetMutation) OldKey(ctx context.Context) (v string, err error return oldValue.Key, nil } +// ClearKey clears the value of the "key" field. +func (m *VersionTargetMutation) ClearKey() { + m.key = nil + m.clearedFields[versiontarget.FieldKey] = struct{}{} +} + +// KeyCleared returns if the "key" field was cleared in this mutation. +func (m *VersionTargetMutation) KeyCleared() bool { + _, ok := m.clearedFields[versiontarget.FieldKey] + return ok +} + // ResetKey resets all changes to the "key" field. func (m *VersionTargetMutation) ResetKey() { m.key = nil + delete(m.clearedFields, versiontarget.FieldKey) } // SetHash sets the "hash" field. @@ -12110,9 +12336,22 @@ func (m *VersionTargetMutation) OldHash(ctx context.Context) (v string, err erro return oldValue.Hash, nil } +// ClearHash clears the value of the "hash" field. +func (m *VersionTargetMutation) ClearHash() { + m.hash = nil + m.clearedFields[versiontarget.FieldHash] = struct{}{} +} + +// HashCleared returns if the "hash" field was cleared in this mutation. +func (m *VersionTargetMutation) HashCleared() bool { + _, ok := m.clearedFields[versiontarget.FieldHash] + return ok +} + // ResetHash resets all changes to the "hash" field. func (m *VersionTargetMutation) ResetHash() { m.hash = nil + delete(m.clearedFields, versiontarget.FieldHash) } // SetSize sets the "size" field. @@ -12165,10 +12404,24 @@ func (m *VersionTargetMutation) AddedSize() (r int64, exists bool) { return *v, true } +// ClearSize clears the value of the "size" field. +func (m *VersionTargetMutation) ClearSize() { + m.size = nil + m.addsize = nil + m.clearedFields[versiontarget.FieldSize] = struct{}{} +} + +// SizeCleared returns if the "size" field was cleared in this mutation. +func (m *VersionTargetMutation) SizeCleared() bool { + _, ok := m.clearedFields[versiontarget.FieldSize] + return ok +} + // ResetSize resets all changes to the "size" field. func (m *VersionTargetMutation) ResetSize() { m.size = nil m.addsize = nil + delete(m.clearedFields, versiontarget.FieldSize) } // SetSmlVersionID sets the "sml_version" edge to the Version entity by id. @@ -12386,7 +12639,17 @@ func (m *VersionTargetMutation) AddField(name string, value ent.Value) error { // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *VersionTargetMutation) ClearedFields() []string { - return nil + var fields []string + if m.FieldCleared(versiontarget.FieldKey) { + fields = append(fields, versiontarget.FieldKey) + } + if m.FieldCleared(versiontarget.FieldHash) { + fields = append(fields, versiontarget.FieldHash) + } + if m.FieldCleared(versiontarget.FieldSize) { + fields = append(fields, versiontarget.FieldSize) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was @@ -12399,6 +12662,17 @@ func (m *VersionTargetMutation) FieldCleared(name string) bool { // 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 *VersionTargetMutation) ClearField(name string) error { + switch name { + case versiontarget.FieldKey: + m.ClearKey() + return nil + case versiontarget.FieldHash: + m.ClearHash() + return nil + case versiontarget.FieldSize: + m.ClearSize() + return nil + } return fmt.Errorf("unknown VersionTarget nullable field %s", name) } diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go index 270fbae0..3c6ddced 100644 --- a/generated/ent/runtime/runtime.go +++ b/generated/ent/runtime/runtime.go @@ -119,6 +119,22 @@ func init() { modDescApproved := modFields[6].Descriptor() // mod.DefaultApproved holds the default value on creation for the approved field. mod.DefaultApproved = modDescApproved.Default.(bool) + // modDescViews is the schema descriptor for views field. + modDescViews := modFields[7].Descriptor() + // mod.DefaultViews holds the default value on creation for the views field. + mod.DefaultViews = modDescViews.Default.(uint) + // modDescHotness is the schema descriptor for hotness field. + modDescHotness := modFields[8].Descriptor() + // mod.DefaultHotness holds the default value on creation for the hotness field. + mod.DefaultHotness = modDescHotness.Default.(uint) + // modDescPopularity is the schema descriptor for popularity field. + modDescPopularity := modFields[9].Descriptor() + // mod.DefaultPopularity holds the default value on creation for the popularity field. + mod.DefaultPopularity = modDescPopularity.Default.(uint) + // modDescDownloads is the schema descriptor for downloads field. + modDescDownloads := modFields[10].Descriptor() + // mod.DefaultDownloads holds the default value on creation for the downloads field. + mod.DefaultDownloads = modDescDownloads.Default.(uint) // modDescDenied is the schema descriptor for denied field. modDescDenied := modFields[11].Descriptor() // mod.DefaultDenied holds the default value on creation for the denied field. @@ -127,6 +143,10 @@ func init() { modDescModReference := modFields[13].Descriptor() // mod.ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. mod.ModReferenceValidator = modDescModReference.Validators[0].(func(string) error) + // modDescHidden is the schema descriptor for hidden field. + modDescHidden := modFields[14].Descriptor() + // mod.DefaultHidden holds the default value on creation for the hidden field. + mod.DefaultHidden = modDescHidden.Default.(bool) // modDescID is the schema descriptor for id field. modDescID := modMixinFields0[0].Descriptor() // mod.DefaultID holds the default value on creation for the id field. @@ -352,10 +372,18 @@ func init() { versionDescSmlVersion := versionFields[2].Descriptor() // version.SmlVersionValidator is a validator for the "sml_version" field. It is called by the builders before save. version.SmlVersionValidator = versionDescSmlVersion.Validators[0].(func(string) error) + // versionDescDownloads is the schema descriptor for downloads field. + versionDescDownloads := versionFields[4].Descriptor() + // version.DefaultDownloads holds the default value on creation for the downloads field. + version.DefaultDownloads = versionDescDownloads.Default.(uint) // versionDescApproved is the schema descriptor for approved field. versionDescApproved := versionFields[7].Descriptor() // version.DefaultApproved holds the default value on creation for the approved field. version.DefaultApproved = versionDescApproved.Default.(bool) + // versionDescHotness is the schema descriptor for hotness field. + versionDescHotness := versionFields[8].Descriptor() + // version.DefaultHotness holds the default value on creation for the hotness field. + version.DefaultHotness = versionDescHotness.Default.(uint) // versionDescDenied is the schema descriptor for denied field. versionDescDenied := versionFields[9].Descriptor() // version.DefaultDenied holds the default value on creation for the denied field. diff --git a/generated/ent/smlversion.go b/generated/ent/smlversion.go index 491125ae..40ea4913 100644 --- a/generated/ent/smlversion.go +++ b/generated/ent/smlversion.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" + "github.com/satisfactorymodding/smr-api/util" ) // SmlVersion is the model entity for the SmlVersion schema. @@ -28,7 +29,7 @@ type SmlVersion struct { // SatisfactoryVersion holds the value of the "satisfactory_version" field. SatisfactoryVersion int `json:"satisfactory_version,omitempty"` // Stability holds the value of the "stability" field. - Stability smlversion.Stability `json:"stability,omitempty"` + Stability util.Stability `json:"stability,omitempty"` // Date holds the value of the "date" field. Date time.Time `json:"date,omitempty"` // Link holds the value of the "link" field. @@ -129,7 +130,7 @@ func (sv *SmlVersion) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field stability", values[i]) } else if value.Valid { - sv.Stability = smlversion.Stability(value.String) + sv.Stability = util.Stability(value.String) } case smlversion.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { diff --git a/generated/ent/smlversion/smlversion.go b/generated/ent/smlversion/smlversion.go index 9b372040..7db282ae 100644 --- a/generated/ent/smlversion/smlversion.go +++ b/generated/ent/smlversion/smlversion.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/util" ) const ( @@ -103,24 +104,10 @@ var ( DefaultID func() string ) -// Stability defines the type for the "stability" enum field. -type Stability string - -// Stability values. -const ( - StabilityAlpha Stability = "alpha" - StabilityBeta Stability = "beta" - StabilityRelease Stability = "release" -) - -func (s Stability) String() string { - return string(s) -} - // StabilityValidator is a validator for the "stability" field enum values. It is called by the builders before save. -func StabilityValidator(s Stability) error { +func StabilityValidator(s util.Stability) error { switch s { - case StabilityAlpha, StabilityBeta, StabilityRelease: + case "release", "beta", "alpha": return nil default: return fmt.Errorf("smlversion: invalid enum value for stability field: %q", s) diff --git a/generated/ent/smlversion/where.go b/generated/ent/smlversion/where.go index df78e319..84c4bb1c 100644 --- a/generated/ent/smlversion/where.go +++ b/generated/ent/smlversion/where.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/util" ) // ID filters vertices based on their ID field. @@ -351,23 +352,33 @@ func SatisfactoryVersionLTE(v int) predicate.SmlVersion { } // StabilityEQ applies the EQ predicate on the "stability" field. -func StabilityEQ(v Stability) predicate.SmlVersion { - return predicate.SmlVersion(sql.FieldEQ(FieldStability, v)) +func StabilityEQ(v util.Stability) predicate.SmlVersion { + vc := v + return predicate.SmlVersion(sql.FieldEQ(FieldStability, vc)) } // StabilityNEQ applies the NEQ predicate on the "stability" field. -func StabilityNEQ(v Stability) predicate.SmlVersion { - return predicate.SmlVersion(sql.FieldNEQ(FieldStability, v)) +func StabilityNEQ(v util.Stability) predicate.SmlVersion { + vc := v + return predicate.SmlVersion(sql.FieldNEQ(FieldStability, vc)) } // StabilityIn applies the In predicate on the "stability" field. -func StabilityIn(vs ...Stability) predicate.SmlVersion { - return predicate.SmlVersion(sql.FieldIn(FieldStability, vs...)) +func StabilityIn(vs ...util.Stability) predicate.SmlVersion { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.SmlVersion(sql.FieldIn(FieldStability, v...)) } // StabilityNotIn applies the NotIn predicate on the "stability" field. -func StabilityNotIn(vs ...Stability) predicate.SmlVersion { - return predicate.SmlVersion(sql.FieldNotIn(FieldStability, vs...)) +func StabilityNotIn(vs ...util.Stability) predicate.SmlVersion { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.SmlVersion(sql.FieldNotIn(FieldStability, v...)) } // DateEQ applies the EQ predicate on the "date" field. diff --git a/generated/ent/smlversion_create.go b/generated/ent/smlversion_create.go index 3b9de703..e815cc61 100644 --- a/generated/ent/smlversion_create.go +++ b/generated/ent/smlversion_create.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/schema/field" "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/util" ) // SmlVersionCreate is the builder for creating a SmlVersion entity. @@ -79,8 +80,8 @@ func (svc *SmlVersionCreate) SetSatisfactoryVersion(i int) *SmlVersionCreate { } // SetStability sets the "stability" field. -func (svc *SmlVersionCreate) SetStability(s smlversion.Stability) *SmlVersionCreate { - svc.mutation.SetStability(s) +func (svc *SmlVersionCreate) SetStability(u util.Stability) *SmlVersionCreate { + svc.mutation.SetStability(u) return svc } @@ -482,7 +483,7 @@ func (u *SmlVersionUpsert) AddSatisfactoryVersion(v int) *SmlVersionUpsert { } // SetStability sets the "stability" field. -func (u *SmlVersionUpsert) SetStability(v smlversion.Stability) *SmlVersionUpsert { +func (u *SmlVersionUpsert) SetStability(v util.Stability) *SmlVersionUpsert { u.Set(smlversion.FieldStability, v) return u } @@ -681,7 +682,7 @@ func (u *SmlVersionUpsertOne) UpdateSatisfactoryVersion() *SmlVersionUpsertOne { } // SetStability sets the "stability" field. -func (u *SmlVersionUpsertOne) SetStability(v smlversion.Stability) *SmlVersionUpsertOne { +func (u *SmlVersionUpsertOne) SetStability(v util.Stability) *SmlVersionUpsertOne { return u.Update(func(s *SmlVersionUpsert) { s.SetStability(v) }) @@ -1060,7 +1061,7 @@ func (u *SmlVersionUpsertBulk) UpdateSatisfactoryVersion() *SmlVersionUpsertBulk } // SetStability sets the "stability" field. -func (u *SmlVersionUpsertBulk) SetStability(v smlversion.Stability) *SmlVersionUpsertBulk { +func (u *SmlVersionUpsertBulk) SetStability(v util.Stability) *SmlVersionUpsertBulk { return u.Update(func(s *SmlVersionUpsert) { s.SetStability(v) }) diff --git a/generated/ent/smlversion_update.go b/generated/ent/smlversion_update.go index c45bb940..840249a9 100644 --- a/generated/ent/smlversion_update.go +++ b/generated/ent/smlversion_update.go @@ -14,6 +14,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" "github.com/satisfactorymodding/smr-api/generated/ent/smlversiontarget" + "github.com/satisfactorymodding/smr-api/util" ) // SmlVersionUpdate is the builder for updating SmlVersion entities. @@ -76,8 +77,8 @@ func (svu *SmlVersionUpdate) AddSatisfactoryVersion(i int) *SmlVersionUpdate { } // SetStability sets the "stability" field. -func (svu *SmlVersionUpdate) SetStability(s smlversion.Stability) *SmlVersionUpdate { - svu.mutation.SetStability(s) +func (svu *SmlVersionUpdate) SetStability(u util.Stability) *SmlVersionUpdate { + svu.mutation.SetStability(u) return svu } @@ -411,8 +412,8 @@ func (svuo *SmlVersionUpdateOne) AddSatisfactoryVersion(i int) *SmlVersionUpdate } // SetStability sets the "stability" field. -func (svuo *SmlVersionUpdateOne) SetStability(s smlversion.Stability) *SmlVersionUpdateOne { - svuo.mutation.SetStability(s) +func (svuo *SmlVersionUpdateOne) SetStability(u util.Stability) *SmlVersionUpdateOne { + svuo.mutation.SetStability(u) return svuo } diff --git a/generated/ent/version.go b/generated/ent/version.go index ba7a07af..30d37906 100644 --- a/generated/ent/version.go +++ b/generated/ent/version.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/satisfactorymodding/smr-api/generated/ent/mod" "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/util" ) // Version is the model entity for the Version schema. @@ -37,7 +38,7 @@ type Version struct { // Key holds the value of the "key" field. Key string `json:"key,omitempty"` // Stability holds the value of the "stability" field. - Stability version.Stability `json:"stability,omitempty"` + Stability util.Stability `json:"stability,omitempty"` // Approved holds the value of the "approved" field. Approved bool `json:"approved,omitempty"` // Hotness holds the value of the "hotness" field. @@ -211,7 +212,7 @@ func (v *Version) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field stability", values[i]) } else if value.Valid { - v.Stability = version.Stability(value.String) + v.Stability = util.Stability(value.String) } case version.FieldApproved: if value, ok := values[i].(*sql.NullBool); !ok { diff --git a/generated/ent/version/version.go b/generated/ent/version/version.go index e9205b75..e2f52fdd 100644 --- a/generated/ent/version/version.go +++ b/generated/ent/version/version.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/satisfactorymodding/smr-api/util" ) const ( @@ -153,8 +154,12 @@ var ( VersionValidator func(string) error // SmlVersionValidator is a validator for the "sml_version" field. It is called by the builders before save. SmlVersionValidator func(string) error + // DefaultDownloads holds the default value on creation for the "downloads" field. + DefaultDownloads uint // DefaultApproved holds the default value on creation for the "approved" field. DefaultApproved bool + // DefaultHotness holds the default value on creation for the "hotness" field. + DefaultHotness uint // DefaultDenied holds the default value on creation for the "denied" field. DefaultDenied bool // ModReferenceValidator is a validator for the "mod_reference" field. It is called by the builders before save. @@ -165,24 +170,10 @@ var ( DefaultID func() string ) -// Stability defines the type for the "stability" enum field. -type Stability string - -// Stability values. -const ( - StabilityAlpha Stability = "alpha" - StabilityBeta Stability = "beta" - StabilityRelease Stability = "release" -) - -func (s Stability) String() string { - return string(s) -} - // StabilityValidator is a validator for the "stability" field enum values. It is called by the builders before save. -func StabilityValidator(s Stability) error { +func StabilityValidator(s util.Stability) error { switch s { - case StabilityAlpha, StabilityBeta, StabilityRelease: + case "release", "beta", "alpha": return nil default: return fmt.Errorf("version: invalid enum value for stability field: %q", s) diff --git a/generated/ent/version/where.go b/generated/ent/version/where.go index 29eed150..2a005b58 100644 --- a/generated/ent/version/where.go +++ b/generated/ent/version/where.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/satisfactorymodding/smr-api/generated/ent/predicate" + "github.com/satisfactorymodding/smr-api/util" ) // ID filters vertices based on their ID field. @@ -540,6 +541,16 @@ func ChangelogHasSuffix(v string) predicate.Version { return predicate.Version(sql.FieldHasSuffix(FieldChangelog, v)) } +// ChangelogIsNil applies the IsNil predicate on the "changelog" field. +func ChangelogIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldChangelog)) +} + +// ChangelogNotNil applies the NotNil predicate on the "changelog" field. +func ChangelogNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldChangelog)) +} + // ChangelogEqualFold applies the EqualFold predicate on the "changelog" field. func ChangelogEqualFold(v string) predicate.Version { return predicate.Version(sql.FieldEqualFold(FieldChangelog, v)) @@ -645,6 +656,16 @@ func KeyHasSuffix(v string) predicate.Version { return predicate.Version(sql.FieldHasSuffix(FieldKey, v)) } +// KeyIsNil applies the IsNil predicate on the "key" field. +func KeyIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldKey)) +} + +// KeyNotNil applies the NotNil predicate on the "key" field. +func KeyNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldKey)) +} + // KeyEqualFold applies the EqualFold predicate on the "key" field. func KeyEqualFold(v string) predicate.Version { return predicate.Version(sql.FieldEqualFold(FieldKey, v)) @@ -656,23 +677,33 @@ func KeyContainsFold(v string) predicate.Version { } // StabilityEQ applies the EQ predicate on the "stability" field. -func StabilityEQ(v Stability) predicate.Version { - return predicate.Version(sql.FieldEQ(FieldStability, v)) +func StabilityEQ(v util.Stability) predicate.Version { + vc := v + return predicate.Version(sql.FieldEQ(FieldStability, vc)) } // StabilityNEQ applies the NEQ predicate on the "stability" field. -func StabilityNEQ(v Stability) predicate.Version { - return predicate.Version(sql.FieldNEQ(FieldStability, v)) +func StabilityNEQ(v util.Stability) predicate.Version { + vc := v + return predicate.Version(sql.FieldNEQ(FieldStability, vc)) } // StabilityIn applies the In predicate on the "stability" field. -func StabilityIn(vs ...Stability) predicate.Version { - return predicate.Version(sql.FieldIn(FieldStability, vs...)) +func StabilityIn(vs ...util.Stability) predicate.Version { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Version(sql.FieldIn(FieldStability, v...)) } // StabilityNotIn applies the NotIn predicate on the "stability" field. -func StabilityNotIn(vs ...Stability) predicate.Version { - return predicate.Version(sql.FieldNotIn(FieldStability, vs...)) +func StabilityNotIn(vs ...util.Stability) predicate.Version { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Version(sql.FieldNotIn(FieldStability, v...)) } // ApprovedEQ applies the EQ predicate on the "approved" field. @@ -790,6 +821,16 @@ func MetadataHasSuffix(v string) predicate.Version { return predicate.Version(sql.FieldHasSuffix(FieldMetadata, v)) } +// MetadataIsNil applies the IsNil predicate on the "metadata" field. +func MetadataIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldMetadata)) +} + +// MetadataNotNil applies the NotNil predicate on the "metadata" field. +func MetadataNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldMetadata)) +} + // MetadataEqualFold applies the EqualFold predicate on the "metadata" field. func MetadataEqualFold(v string) predicate.Version { return predicate.Version(sql.FieldEqualFold(FieldMetadata, v)) @@ -905,6 +946,16 @@ func VersionMajorLTE(v int) predicate.Version { return predicate.Version(sql.FieldLTE(FieldVersionMajor, v)) } +// VersionMajorIsNil applies the IsNil predicate on the "version_major" field. +func VersionMajorIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldVersionMajor)) +} + +// VersionMajorNotNil applies the NotNil predicate on the "version_major" field. +func VersionMajorNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldVersionMajor)) +} + // VersionMinorEQ applies the EQ predicate on the "version_minor" field. func VersionMinorEQ(v int) predicate.Version { return predicate.Version(sql.FieldEQ(FieldVersionMinor, v)) @@ -945,6 +996,16 @@ func VersionMinorLTE(v int) predicate.Version { return predicate.Version(sql.FieldLTE(FieldVersionMinor, v)) } +// VersionMinorIsNil applies the IsNil predicate on the "version_minor" field. +func VersionMinorIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldVersionMinor)) +} + +// VersionMinorNotNil applies the NotNil predicate on the "version_minor" field. +func VersionMinorNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldVersionMinor)) +} + // VersionPatchEQ applies the EQ predicate on the "version_patch" field. func VersionPatchEQ(v int) predicate.Version { return predicate.Version(sql.FieldEQ(FieldVersionPatch, v)) @@ -985,6 +1046,16 @@ func VersionPatchLTE(v int) predicate.Version { return predicate.Version(sql.FieldLTE(FieldVersionPatch, v)) } +// VersionPatchIsNil applies the IsNil predicate on the "version_patch" field. +func VersionPatchIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldVersionPatch)) +} + +// VersionPatchNotNil applies the NotNil predicate on the "version_patch" field. +func VersionPatchNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldVersionPatch)) +} + // SizeEQ applies the EQ predicate on the "size" field. func SizeEQ(v int64) predicate.Version { return predicate.Version(sql.FieldEQ(FieldSize, v)) @@ -1025,6 +1096,16 @@ func SizeLTE(v int64) predicate.Version { return predicate.Version(sql.FieldLTE(FieldSize, v)) } +// SizeIsNil applies the IsNil predicate on the "size" field. +func SizeIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldSize)) +} + +// SizeNotNil applies the NotNil predicate on the "size" field. +func SizeNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldSize)) +} + // HashEQ applies the EQ predicate on the "hash" field. func HashEQ(v string) predicate.Version { return predicate.Version(sql.FieldEQ(FieldHash, v)) @@ -1080,6 +1161,16 @@ func HashHasSuffix(v string) predicate.Version { return predicate.Version(sql.FieldHasSuffix(FieldHash, v)) } +// HashIsNil applies the IsNil predicate on the "hash" field. +func HashIsNil() predicate.Version { + return predicate.Version(sql.FieldIsNull(FieldHash)) +} + +// HashNotNil applies the NotNil predicate on the "hash" field. +func HashNotNil() predicate.Version { + return predicate.Version(sql.FieldNotNull(FieldHash)) +} + // HashEqualFold applies the EqualFold predicate on the "hash" field. func HashEqualFold(v string) predicate.Version { return predicate.Version(sql.FieldEqualFold(FieldHash, v)) diff --git a/generated/ent/version_create.go b/generated/ent/version_create.go index bcff9a2d..e5c13b37 100644 --- a/generated/ent/version_create.go +++ b/generated/ent/version_create.go @@ -15,6 +15,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/mod" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" + "github.com/satisfactorymodding/smr-api/util" ) // VersionCreate is the builder for creating a Version entity. @@ -91,21 +92,45 @@ func (vc *VersionCreate) SetChangelog(s string) *VersionCreate { return vc } +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (vc *VersionCreate) SetNillableChangelog(s *string) *VersionCreate { + if s != nil { + vc.SetChangelog(*s) + } + return vc +} + // SetDownloads sets the "downloads" field. func (vc *VersionCreate) SetDownloads(u uint) *VersionCreate { vc.mutation.SetDownloads(u) return vc } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (vc *VersionCreate) SetNillableDownloads(u *uint) *VersionCreate { + if u != nil { + vc.SetDownloads(*u) + } + return vc +} + // SetKey sets the "key" field. func (vc *VersionCreate) SetKey(s string) *VersionCreate { vc.mutation.SetKey(s) return vc } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vc *VersionCreate) SetNillableKey(s *string) *VersionCreate { + if s != nil { + vc.SetKey(*s) + } + return vc +} + // SetStability sets the "stability" field. -func (vc *VersionCreate) SetStability(v version.Stability) *VersionCreate { - vc.mutation.SetStability(v) +func (vc *VersionCreate) SetStability(u util.Stability) *VersionCreate { + vc.mutation.SetStability(u) return vc } @@ -129,6 +154,14 @@ func (vc *VersionCreate) SetHotness(u uint) *VersionCreate { return vc } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (vc *VersionCreate) SetNillableHotness(u *uint) *VersionCreate { + if u != nil { + vc.SetHotness(*u) + } + return vc +} + // SetDenied sets the "denied" field. func (vc *VersionCreate) SetDenied(b bool) *VersionCreate { vc.mutation.SetDenied(b) @@ -149,6 +182,14 @@ func (vc *VersionCreate) SetMetadata(s string) *VersionCreate { return vc } +// SetNillableMetadata sets the "metadata" field if the given value is not nil. +func (vc *VersionCreate) SetNillableMetadata(s *string) *VersionCreate { + if s != nil { + vc.SetMetadata(*s) + } + return vc +} + // SetModReference sets the "mod_reference" field. func (vc *VersionCreate) SetModReference(s string) *VersionCreate { vc.mutation.SetModReference(s) @@ -161,30 +202,70 @@ func (vc *VersionCreate) SetVersionMajor(i int) *VersionCreate { return vc } +// SetNillableVersionMajor sets the "version_major" field if the given value is not nil. +func (vc *VersionCreate) SetNillableVersionMajor(i *int) *VersionCreate { + if i != nil { + vc.SetVersionMajor(*i) + } + return vc +} + // SetVersionMinor sets the "version_minor" field. func (vc *VersionCreate) SetVersionMinor(i int) *VersionCreate { vc.mutation.SetVersionMinor(i) return vc } +// SetNillableVersionMinor sets the "version_minor" field if the given value is not nil. +func (vc *VersionCreate) SetNillableVersionMinor(i *int) *VersionCreate { + if i != nil { + vc.SetVersionMinor(*i) + } + return vc +} + // SetVersionPatch sets the "version_patch" field. func (vc *VersionCreate) SetVersionPatch(i int) *VersionCreate { vc.mutation.SetVersionPatch(i) return vc } +// SetNillableVersionPatch sets the "version_patch" field if the given value is not nil. +func (vc *VersionCreate) SetNillableVersionPatch(i *int) *VersionCreate { + if i != nil { + vc.SetVersionPatch(*i) + } + return vc +} + // SetSize sets the "size" field. func (vc *VersionCreate) SetSize(i int64) *VersionCreate { vc.mutation.SetSize(i) return vc } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vc *VersionCreate) SetNillableSize(i *int64) *VersionCreate { + if i != nil { + vc.SetSize(*i) + } + return vc +} + // SetHash sets the "hash" field. func (vc *VersionCreate) SetHash(s string) *VersionCreate { vc.mutation.SetHash(s) return vc } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vc *VersionCreate) SetNillableHash(s *string) *VersionCreate { + if s != nil { + vc.SetHash(*s) + } + return vc +} + // SetID sets the "id" field. func (vc *VersionCreate) SetID(s string) *VersionCreate { vc.mutation.SetID(s) @@ -285,10 +366,18 @@ func (vc *VersionCreate) defaults() error { v := version.DefaultUpdatedAt() vc.mutation.SetUpdatedAt(v) } + if _, ok := vc.mutation.Downloads(); !ok { + v := version.DefaultDownloads + vc.mutation.SetDownloads(v) + } if _, ok := vc.mutation.Approved(); !ok { v := version.DefaultApproved vc.mutation.SetApproved(v) } + if _, ok := vc.mutation.Hotness(); !ok { + v := version.DefaultHotness + vc.mutation.SetHotness(v) + } if _, ok := vc.mutation.Denied(); !ok { v := version.DefaultDenied vc.mutation.SetDenied(v) @@ -330,15 +419,9 @@ func (vc *VersionCreate) check() error { return &ValidationError{Name: "sml_version", err: fmt.Errorf(`ent: validator failed for field "Version.sml_version": %w`, err)} } } - if _, ok := vc.mutation.Changelog(); !ok { - return &ValidationError{Name: "changelog", err: errors.New(`ent: missing required field "Version.changelog"`)} - } if _, ok := vc.mutation.Downloads(); !ok { return &ValidationError{Name: "downloads", err: errors.New(`ent: missing required field "Version.downloads"`)} } - if _, ok := vc.mutation.Key(); !ok { - return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Version.key"`)} - } if _, ok := vc.mutation.Stability(); !ok { return &ValidationError{Name: "stability", err: errors.New(`ent: missing required field "Version.stability"`)} } @@ -356,9 +439,6 @@ func (vc *VersionCreate) check() error { if _, ok := vc.mutation.Denied(); !ok { return &ValidationError{Name: "denied", err: errors.New(`ent: missing required field "Version.denied"`)} } - if _, ok := vc.mutation.Metadata(); !ok { - return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "Version.metadata"`)} - } if _, ok := vc.mutation.ModReference(); !ok { return &ValidationError{Name: "mod_reference", err: errors.New(`ent: missing required field "Version.mod_reference"`)} } @@ -367,21 +447,6 @@ func (vc *VersionCreate) check() error { return &ValidationError{Name: "mod_reference", err: fmt.Errorf(`ent: validator failed for field "Version.mod_reference": %w`, err)} } } - if _, ok := vc.mutation.VersionMajor(); !ok { - return &ValidationError{Name: "version_major", err: errors.New(`ent: missing required field "Version.version_major"`)} - } - if _, ok := vc.mutation.VersionMinor(); !ok { - return &ValidationError{Name: "version_minor", err: errors.New(`ent: missing required field "Version.version_minor"`)} - } - if _, ok := vc.mutation.VersionPatch(); !ok { - return &ValidationError{Name: "version_patch", err: errors.New(`ent: missing required field "Version.version_patch"`)} - } - if _, ok := vc.mutation.Size(); !ok { - return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "Version.size"`)} - } - if _, ok := vc.mutation.Hash(); !ok { - return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "Version.hash"`)} - } if v, ok := vc.mutation.Hash(); ok { if err := version.HashValidator(v); err != nil { return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Version.hash": %w`, err)} @@ -685,6 +750,12 @@ func (u *VersionUpsert) UpdateChangelog() *VersionUpsert { return u } +// ClearChangelog clears the value of the "changelog" field. +func (u *VersionUpsert) ClearChangelog() *VersionUpsert { + u.SetNull(version.FieldChangelog) + return u +} + // SetDownloads sets the "downloads" field. func (u *VersionUpsert) SetDownloads(v uint) *VersionUpsert { u.Set(version.FieldDownloads, v) @@ -715,8 +786,14 @@ func (u *VersionUpsert) UpdateKey() *VersionUpsert { return u } +// ClearKey clears the value of the "key" field. +func (u *VersionUpsert) ClearKey() *VersionUpsert { + u.SetNull(version.FieldKey) + return u +} + // SetStability sets the "stability" field. -func (u *VersionUpsert) SetStability(v version.Stability) *VersionUpsert { +func (u *VersionUpsert) SetStability(v util.Stability) *VersionUpsert { u.Set(version.FieldStability, v) return u } @@ -781,6 +858,12 @@ func (u *VersionUpsert) UpdateMetadata() *VersionUpsert { return u } +// ClearMetadata clears the value of the "metadata" field. +func (u *VersionUpsert) ClearMetadata() *VersionUpsert { + u.SetNull(version.FieldMetadata) + return u +} + // SetModReference sets the "mod_reference" field. func (u *VersionUpsert) SetModReference(v string) *VersionUpsert { u.Set(version.FieldModReference, v) @@ -811,6 +894,12 @@ func (u *VersionUpsert) AddVersionMajor(v int) *VersionUpsert { return u } +// ClearVersionMajor clears the value of the "version_major" field. +func (u *VersionUpsert) ClearVersionMajor() *VersionUpsert { + u.SetNull(version.FieldVersionMajor) + return u +} + // SetVersionMinor sets the "version_minor" field. func (u *VersionUpsert) SetVersionMinor(v int) *VersionUpsert { u.Set(version.FieldVersionMinor, v) @@ -829,6 +918,12 @@ func (u *VersionUpsert) AddVersionMinor(v int) *VersionUpsert { return u } +// ClearVersionMinor clears the value of the "version_minor" field. +func (u *VersionUpsert) ClearVersionMinor() *VersionUpsert { + u.SetNull(version.FieldVersionMinor) + return u +} + // SetVersionPatch sets the "version_patch" field. func (u *VersionUpsert) SetVersionPatch(v int) *VersionUpsert { u.Set(version.FieldVersionPatch, v) @@ -847,6 +942,12 @@ func (u *VersionUpsert) AddVersionPatch(v int) *VersionUpsert { return u } +// ClearVersionPatch clears the value of the "version_patch" field. +func (u *VersionUpsert) ClearVersionPatch() *VersionUpsert { + u.SetNull(version.FieldVersionPatch) + return u +} + // SetSize sets the "size" field. func (u *VersionUpsert) SetSize(v int64) *VersionUpsert { u.Set(version.FieldSize, v) @@ -865,6 +966,12 @@ func (u *VersionUpsert) AddSize(v int64) *VersionUpsert { return u } +// ClearSize clears the value of the "size" field. +func (u *VersionUpsert) ClearSize() *VersionUpsert { + u.SetNull(version.FieldSize) + return u +} + // SetHash sets the "hash" field. func (u *VersionUpsert) SetHash(v string) *VersionUpsert { u.Set(version.FieldHash, v) @@ -877,6 +984,12 @@ func (u *VersionUpsert) UpdateHash() *VersionUpsert { return u } +// ClearHash clears the value of the "hash" field. +func (u *VersionUpsert) ClearHash() *VersionUpsert { + u.SetNull(version.FieldHash) + 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: // @@ -1019,6 +1132,13 @@ func (u *VersionUpsertOne) UpdateChangelog() *VersionUpsertOne { }) } +// ClearChangelog clears the value of the "changelog" field. +func (u *VersionUpsertOne) ClearChangelog() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearChangelog() + }) +} + // SetDownloads sets the "downloads" field. func (u *VersionUpsertOne) SetDownloads(v uint) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1054,8 +1174,15 @@ func (u *VersionUpsertOne) UpdateKey() *VersionUpsertOne { }) } +// ClearKey clears the value of the "key" field. +func (u *VersionUpsertOne) ClearKey() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearKey() + }) +} + // SetStability sets the "stability" field. -func (u *VersionUpsertOne) SetStability(v version.Stability) *VersionUpsertOne { +func (u *VersionUpsertOne) SetStability(v util.Stability) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { s.SetStability(v) }) @@ -1131,6 +1258,13 @@ func (u *VersionUpsertOne) UpdateMetadata() *VersionUpsertOne { }) } +// ClearMetadata clears the value of the "metadata" field. +func (u *VersionUpsertOne) ClearMetadata() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearMetadata() + }) +} + // SetModReference sets the "mod_reference" field. func (u *VersionUpsertOne) SetModReference(v string) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1166,6 +1300,13 @@ func (u *VersionUpsertOne) UpdateVersionMajor() *VersionUpsertOne { }) } +// ClearVersionMajor clears the value of the "version_major" field. +func (u *VersionUpsertOne) ClearVersionMajor() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionMajor() + }) +} + // SetVersionMinor sets the "version_minor" field. func (u *VersionUpsertOne) SetVersionMinor(v int) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1187,6 +1328,13 @@ func (u *VersionUpsertOne) UpdateVersionMinor() *VersionUpsertOne { }) } +// ClearVersionMinor clears the value of the "version_minor" field. +func (u *VersionUpsertOne) ClearVersionMinor() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionMinor() + }) +} + // SetVersionPatch sets the "version_patch" field. func (u *VersionUpsertOne) SetVersionPatch(v int) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1208,6 +1356,13 @@ func (u *VersionUpsertOne) UpdateVersionPatch() *VersionUpsertOne { }) } +// ClearVersionPatch clears the value of the "version_patch" field. +func (u *VersionUpsertOne) ClearVersionPatch() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionPatch() + }) +} + // SetSize sets the "size" field. func (u *VersionUpsertOne) SetSize(v int64) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1229,6 +1384,13 @@ func (u *VersionUpsertOne) UpdateSize() *VersionUpsertOne { }) } +// ClearSize clears the value of the "size" field. +func (u *VersionUpsertOne) ClearSize() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearSize() + }) +} + // SetHash sets the "hash" field. func (u *VersionUpsertOne) SetHash(v string) *VersionUpsertOne { return u.Update(func(s *VersionUpsert) { @@ -1243,6 +1405,13 @@ func (u *VersionUpsertOne) UpdateHash() *VersionUpsertOne { }) } +// ClearHash clears the value of the "hash" field. +func (u *VersionUpsertOne) ClearHash() *VersionUpsertOne { + return u.Update(func(s *VersionUpsert) { + s.ClearHash() + }) +} + // Exec executes the query. func (u *VersionUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1552,6 +1721,13 @@ func (u *VersionUpsertBulk) UpdateChangelog() *VersionUpsertBulk { }) } +// ClearChangelog clears the value of the "changelog" field. +func (u *VersionUpsertBulk) ClearChangelog() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearChangelog() + }) +} + // SetDownloads sets the "downloads" field. func (u *VersionUpsertBulk) SetDownloads(v uint) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1587,8 +1763,15 @@ func (u *VersionUpsertBulk) UpdateKey() *VersionUpsertBulk { }) } +// ClearKey clears the value of the "key" field. +func (u *VersionUpsertBulk) ClearKey() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearKey() + }) +} + // SetStability sets the "stability" field. -func (u *VersionUpsertBulk) SetStability(v version.Stability) *VersionUpsertBulk { +func (u *VersionUpsertBulk) SetStability(v util.Stability) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { s.SetStability(v) }) @@ -1664,6 +1847,13 @@ func (u *VersionUpsertBulk) UpdateMetadata() *VersionUpsertBulk { }) } +// ClearMetadata clears the value of the "metadata" field. +func (u *VersionUpsertBulk) ClearMetadata() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearMetadata() + }) +} + // SetModReference sets the "mod_reference" field. func (u *VersionUpsertBulk) SetModReference(v string) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1699,6 +1889,13 @@ func (u *VersionUpsertBulk) UpdateVersionMajor() *VersionUpsertBulk { }) } +// ClearVersionMajor clears the value of the "version_major" field. +func (u *VersionUpsertBulk) ClearVersionMajor() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionMajor() + }) +} + // SetVersionMinor sets the "version_minor" field. func (u *VersionUpsertBulk) SetVersionMinor(v int) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1720,6 +1917,13 @@ func (u *VersionUpsertBulk) UpdateVersionMinor() *VersionUpsertBulk { }) } +// ClearVersionMinor clears the value of the "version_minor" field. +func (u *VersionUpsertBulk) ClearVersionMinor() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionMinor() + }) +} + // SetVersionPatch sets the "version_patch" field. func (u *VersionUpsertBulk) SetVersionPatch(v int) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1741,6 +1945,13 @@ func (u *VersionUpsertBulk) UpdateVersionPatch() *VersionUpsertBulk { }) } +// ClearVersionPatch clears the value of the "version_patch" field. +func (u *VersionUpsertBulk) ClearVersionPatch() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearVersionPatch() + }) +} + // SetSize sets the "size" field. func (u *VersionUpsertBulk) SetSize(v int64) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1762,6 +1973,13 @@ func (u *VersionUpsertBulk) UpdateSize() *VersionUpsertBulk { }) } +// ClearSize clears the value of the "size" field. +func (u *VersionUpsertBulk) ClearSize() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearSize() + }) +} + // SetHash sets the "hash" field. func (u *VersionUpsertBulk) SetHash(v string) *VersionUpsertBulk { return u.Update(func(s *VersionUpsert) { @@ -1776,6 +1994,13 @@ func (u *VersionUpsertBulk) UpdateHash() *VersionUpsertBulk { }) } +// ClearHash clears the value of the "hash" field. +func (u *VersionUpsertBulk) ClearHash() *VersionUpsertBulk { + return u.Update(func(s *VersionUpsert) { + s.ClearHash() + }) +} + // Exec executes the query. func (u *VersionUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/generated/ent/version_update.go b/generated/ent/version_update.go index 5349b40e..c2a5fe01 100644 --- a/generated/ent/version_update.go +++ b/generated/ent/version_update.go @@ -15,6 +15,7 @@ import ( "github.com/satisfactorymodding/smr-api/generated/ent/predicate" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" + "github.com/satisfactorymodding/smr-api/util" ) // VersionUpdate is the builder for updating Version entities. @@ -81,6 +82,20 @@ func (vu *VersionUpdate) SetChangelog(s string) *VersionUpdate { return vu } +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableChangelog(s *string) *VersionUpdate { + if s != nil { + vu.SetChangelog(*s) + } + return vu +} + +// ClearChangelog clears the value of the "changelog" field. +func (vu *VersionUpdate) ClearChangelog() *VersionUpdate { + vu.mutation.ClearChangelog() + return vu +} + // SetDownloads sets the "downloads" field. func (vu *VersionUpdate) SetDownloads(u uint) *VersionUpdate { vu.mutation.ResetDownloads() @@ -88,6 +103,14 @@ func (vu *VersionUpdate) SetDownloads(u uint) *VersionUpdate { return vu } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableDownloads(u *uint) *VersionUpdate { + if u != nil { + vu.SetDownloads(*u) + } + return vu +} + // AddDownloads adds u to the "downloads" field. func (vu *VersionUpdate) AddDownloads(u int) *VersionUpdate { vu.mutation.AddDownloads(u) @@ -100,9 +123,23 @@ func (vu *VersionUpdate) SetKey(s string) *VersionUpdate { return vu } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableKey(s *string) *VersionUpdate { + if s != nil { + vu.SetKey(*s) + } + return vu +} + +// ClearKey clears the value of the "key" field. +func (vu *VersionUpdate) ClearKey() *VersionUpdate { + vu.mutation.ClearKey() + return vu +} + // SetStability sets the "stability" field. -func (vu *VersionUpdate) SetStability(v version.Stability) *VersionUpdate { - vu.mutation.SetStability(v) +func (vu *VersionUpdate) SetStability(u util.Stability) *VersionUpdate { + vu.mutation.SetStability(u) return vu } @@ -127,6 +164,14 @@ func (vu *VersionUpdate) SetHotness(u uint) *VersionUpdate { return vu } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableHotness(u *uint) *VersionUpdate { + if u != nil { + vu.SetHotness(*u) + } + return vu +} + // AddHotness adds u to the "hotness" field. func (vu *VersionUpdate) AddHotness(u int) *VersionUpdate { vu.mutation.AddHotness(u) @@ -153,6 +198,20 @@ func (vu *VersionUpdate) SetMetadata(s string) *VersionUpdate { return vu } +// SetNillableMetadata sets the "metadata" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableMetadata(s *string) *VersionUpdate { + if s != nil { + vu.SetMetadata(*s) + } + return vu +} + +// ClearMetadata clears the value of the "metadata" field. +func (vu *VersionUpdate) ClearMetadata() *VersionUpdate { + vu.mutation.ClearMetadata() + return vu +} + // SetModReference sets the "mod_reference" field. func (vu *VersionUpdate) SetModReference(s string) *VersionUpdate { vu.mutation.SetModReference(s) @@ -166,12 +225,26 @@ func (vu *VersionUpdate) SetVersionMajor(i int) *VersionUpdate { return vu } +// SetNillableVersionMajor sets the "version_major" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableVersionMajor(i *int) *VersionUpdate { + if i != nil { + vu.SetVersionMajor(*i) + } + return vu +} + // AddVersionMajor adds i to the "version_major" field. func (vu *VersionUpdate) AddVersionMajor(i int) *VersionUpdate { vu.mutation.AddVersionMajor(i) return vu } +// ClearVersionMajor clears the value of the "version_major" field. +func (vu *VersionUpdate) ClearVersionMajor() *VersionUpdate { + vu.mutation.ClearVersionMajor() + return vu +} + // SetVersionMinor sets the "version_minor" field. func (vu *VersionUpdate) SetVersionMinor(i int) *VersionUpdate { vu.mutation.ResetVersionMinor() @@ -179,12 +252,26 @@ func (vu *VersionUpdate) SetVersionMinor(i int) *VersionUpdate { return vu } +// SetNillableVersionMinor sets the "version_minor" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableVersionMinor(i *int) *VersionUpdate { + if i != nil { + vu.SetVersionMinor(*i) + } + return vu +} + // AddVersionMinor adds i to the "version_minor" field. func (vu *VersionUpdate) AddVersionMinor(i int) *VersionUpdate { vu.mutation.AddVersionMinor(i) return vu } +// ClearVersionMinor clears the value of the "version_minor" field. +func (vu *VersionUpdate) ClearVersionMinor() *VersionUpdate { + vu.mutation.ClearVersionMinor() + return vu +} + // SetVersionPatch sets the "version_patch" field. func (vu *VersionUpdate) SetVersionPatch(i int) *VersionUpdate { vu.mutation.ResetVersionPatch() @@ -192,12 +279,26 @@ func (vu *VersionUpdate) SetVersionPatch(i int) *VersionUpdate { return vu } +// SetNillableVersionPatch sets the "version_patch" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableVersionPatch(i *int) *VersionUpdate { + if i != nil { + vu.SetVersionPatch(*i) + } + return vu +} + // AddVersionPatch adds i to the "version_patch" field. func (vu *VersionUpdate) AddVersionPatch(i int) *VersionUpdate { vu.mutation.AddVersionPatch(i) return vu } +// ClearVersionPatch clears the value of the "version_patch" field. +func (vu *VersionUpdate) ClearVersionPatch() *VersionUpdate { + vu.mutation.ClearVersionPatch() + return vu +} + // SetSize sets the "size" field. func (vu *VersionUpdate) SetSize(i int64) *VersionUpdate { vu.mutation.ResetSize() @@ -205,18 +306,46 @@ func (vu *VersionUpdate) SetSize(i int64) *VersionUpdate { return vu } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableSize(i *int64) *VersionUpdate { + if i != nil { + vu.SetSize(*i) + } + return vu +} + // AddSize adds i to the "size" field. func (vu *VersionUpdate) AddSize(i int64) *VersionUpdate { vu.mutation.AddSize(i) return vu } +// ClearSize clears the value of the "size" field. +func (vu *VersionUpdate) ClearSize() *VersionUpdate { + vu.mutation.ClearSize() + return vu +} + // SetHash sets the "hash" field. func (vu *VersionUpdate) SetHash(s string) *VersionUpdate { vu.mutation.SetHash(s) return vu } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableHash(s *string) *VersionUpdate { + if s != nil { + vu.SetHash(*s) + } + return vu +} + +// ClearHash clears the value of the "hash" field. +func (vu *VersionUpdate) ClearHash() *VersionUpdate { + vu.mutation.ClearHash() + return vu +} + // SetMod sets the "mod" edge to the Mod entity. func (vu *VersionUpdate) SetMod(m *Mod) *VersionUpdate { return vu.SetModID(m.ID) @@ -416,6 +545,9 @@ func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.Changelog(); ok { _spec.SetField(version.FieldChangelog, field.TypeString, value) } + if vu.mutation.ChangelogCleared() { + _spec.ClearField(version.FieldChangelog, field.TypeString) + } if value, ok := vu.mutation.Downloads(); ok { _spec.SetField(version.FieldDownloads, field.TypeUint, value) } @@ -425,6 +557,9 @@ func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.Key(); ok { _spec.SetField(version.FieldKey, field.TypeString, value) } + if vu.mutation.KeyCleared() { + _spec.ClearField(version.FieldKey, field.TypeString) + } if value, ok := vu.mutation.Stability(); ok { _spec.SetField(version.FieldStability, field.TypeEnum, value) } @@ -443,6 +578,9 @@ func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.Metadata(); ok { _spec.SetField(version.FieldMetadata, field.TypeString, value) } + if vu.mutation.MetadataCleared() { + _spec.ClearField(version.FieldMetadata, field.TypeString) + } if value, ok := vu.mutation.ModReference(); ok { _spec.SetField(version.FieldModReference, field.TypeString, value) } @@ -452,27 +590,42 @@ func (vu *VersionUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.AddedVersionMajor(); ok { _spec.AddField(version.FieldVersionMajor, field.TypeInt, value) } + if vu.mutation.VersionMajorCleared() { + _spec.ClearField(version.FieldVersionMajor, field.TypeInt) + } if value, ok := vu.mutation.VersionMinor(); ok { _spec.SetField(version.FieldVersionMinor, field.TypeInt, value) } if value, ok := vu.mutation.AddedVersionMinor(); ok { _spec.AddField(version.FieldVersionMinor, field.TypeInt, value) } + if vu.mutation.VersionMinorCleared() { + _spec.ClearField(version.FieldVersionMinor, field.TypeInt) + } if value, ok := vu.mutation.VersionPatch(); ok { _spec.SetField(version.FieldVersionPatch, field.TypeInt, value) } if value, ok := vu.mutation.AddedVersionPatch(); ok { _spec.AddField(version.FieldVersionPatch, field.TypeInt, value) } + if vu.mutation.VersionPatchCleared() { + _spec.ClearField(version.FieldVersionPatch, field.TypeInt) + } if value, ok := vu.mutation.Size(); ok { _spec.SetField(version.FieldSize, field.TypeInt64, value) } if value, ok := vu.mutation.AddedSize(); ok { _spec.AddField(version.FieldSize, field.TypeInt64, value) } + if vu.mutation.SizeCleared() { + _spec.ClearField(version.FieldSize, field.TypeInt64) + } if value, ok := vu.mutation.Hash(); ok { _spec.SetField(version.FieldHash, field.TypeString, value) } + if vu.mutation.HashCleared() { + _spec.ClearField(version.FieldHash, field.TypeString) + } if vu.mutation.ModCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -676,6 +829,20 @@ func (vuo *VersionUpdateOne) SetChangelog(s string) *VersionUpdateOne { return vuo } +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableChangelog(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetChangelog(*s) + } + return vuo +} + +// ClearChangelog clears the value of the "changelog" field. +func (vuo *VersionUpdateOne) ClearChangelog() *VersionUpdateOne { + vuo.mutation.ClearChangelog() + return vuo +} + // SetDownloads sets the "downloads" field. func (vuo *VersionUpdateOne) SetDownloads(u uint) *VersionUpdateOne { vuo.mutation.ResetDownloads() @@ -683,6 +850,14 @@ func (vuo *VersionUpdateOne) SetDownloads(u uint) *VersionUpdateOne { return vuo } +// SetNillableDownloads sets the "downloads" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableDownloads(u *uint) *VersionUpdateOne { + if u != nil { + vuo.SetDownloads(*u) + } + return vuo +} + // AddDownloads adds u to the "downloads" field. func (vuo *VersionUpdateOne) AddDownloads(u int) *VersionUpdateOne { vuo.mutation.AddDownloads(u) @@ -695,9 +870,23 @@ func (vuo *VersionUpdateOne) SetKey(s string) *VersionUpdateOne { return vuo } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableKey(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetKey(*s) + } + return vuo +} + +// ClearKey clears the value of the "key" field. +func (vuo *VersionUpdateOne) ClearKey() *VersionUpdateOne { + vuo.mutation.ClearKey() + return vuo +} + // SetStability sets the "stability" field. -func (vuo *VersionUpdateOne) SetStability(v version.Stability) *VersionUpdateOne { - vuo.mutation.SetStability(v) +func (vuo *VersionUpdateOne) SetStability(u util.Stability) *VersionUpdateOne { + vuo.mutation.SetStability(u) return vuo } @@ -722,6 +911,14 @@ func (vuo *VersionUpdateOne) SetHotness(u uint) *VersionUpdateOne { return vuo } +// SetNillableHotness sets the "hotness" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableHotness(u *uint) *VersionUpdateOne { + if u != nil { + vuo.SetHotness(*u) + } + return vuo +} + // AddHotness adds u to the "hotness" field. func (vuo *VersionUpdateOne) AddHotness(u int) *VersionUpdateOne { vuo.mutation.AddHotness(u) @@ -748,6 +945,20 @@ func (vuo *VersionUpdateOne) SetMetadata(s string) *VersionUpdateOne { return vuo } +// SetNillableMetadata sets the "metadata" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableMetadata(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetMetadata(*s) + } + return vuo +} + +// ClearMetadata clears the value of the "metadata" field. +func (vuo *VersionUpdateOne) ClearMetadata() *VersionUpdateOne { + vuo.mutation.ClearMetadata() + return vuo +} + // SetModReference sets the "mod_reference" field. func (vuo *VersionUpdateOne) SetModReference(s string) *VersionUpdateOne { vuo.mutation.SetModReference(s) @@ -761,12 +972,26 @@ func (vuo *VersionUpdateOne) SetVersionMajor(i int) *VersionUpdateOne { return vuo } +// SetNillableVersionMajor sets the "version_major" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableVersionMajor(i *int) *VersionUpdateOne { + if i != nil { + vuo.SetVersionMajor(*i) + } + return vuo +} + // AddVersionMajor adds i to the "version_major" field. func (vuo *VersionUpdateOne) AddVersionMajor(i int) *VersionUpdateOne { vuo.mutation.AddVersionMajor(i) return vuo } +// ClearVersionMajor clears the value of the "version_major" field. +func (vuo *VersionUpdateOne) ClearVersionMajor() *VersionUpdateOne { + vuo.mutation.ClearVersionMajor() + return vuo +} + // SetVersionMinor sets the "version_minor" field. func (vuo *VersionUpdateOne) SetVersionMinor(i int) *VersionUpdateOne { vuo.mutation.ResetVersionMinor() @@ -774,12 +999,26 @@ func (vuo *VersionUpdateOne) SetVersionMinor(i int) *VersionUpdateOne { return vuo } +// SetNillableVersionMinor sets the "version_minor" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableVersionMinor(i *int) *VersionUpdateOne { + if i != nil { + vuo.SetVersionMinor(*i) + } + return vuo +} + // AddVersionMinor adds i to the "version_minor" field. func (vuo *VersionUpdateOne) AddVersionMinor(i int) *VersionUpdateOne { vuo.mutation.AddVersionMinor(i) return vuo } +// ClearVersionMinor clears the value of the "version_minor" field. +func (vuo *VersionUpdateOne) ClearVersionMinor() *VersionUpdateOne { + vuo.mutation.ClearVersionMinor() + return vuo +} + // SetVersionPatch sets the "version_patch" field. func (vuo *VersionUpdateOne) SetVersionPatch(i int) *VersionUpdateOne { vuo.mutation.ResetVersionPatch() @@ -787,12 +1026,26 @@ func (vuo *VersionUpdateOne) SetVersionPatch(i int) *VersionUpdateOne { return vuo } +// SetNillableVersionPatch sets the "version_patch" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableVersionPatch(i *int) *VersionUpdateOne { + if i != nil { + vuo.SetVersionPatch(*i) + } + return vuo +} + // AddVersionPatch adds i to the "version_patch" field. func (vuo *VersionUpdateOne) AddVersionPatch(i int) *VersionUpdateOne { vuo.mutation.AddVersionPatch(i) return vuo } +// ClearVersionPatch clears the value of the "version_patch" field. +func (vuo *VersionUpdateOne) ClearVersionPatch() *VersionUpdateOne { + vuo.mutation.ClearVersionPatch() + return vuo +} + // SetSize sets the "size" field. func (vuo *VersionUpdateOne) SetSize(i int64) *VersionUpdateOne { vuo.mutation.ResetSize() @@ -800,18 +1053,46 @@ func (vuo *VersionUpdateOne) SetSize(i int64) *VersionUpdateOne { return vuo } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableSize(i *int64) *VersionUpdateOne { + if i != nil { + vuo.SetSize(*i) + } + return vuo +} + // AddSize adds i to the "size" field. func (vuo *VersionUpdateOne) AddSize(i int64) *VersionUpdateOne { vuo.mutation.AddSize(i) return vuo } +// ClearSize clears the value of the "size" field. +func (vuo *VersionUpdateOne) ClearSize() *VersionUpdateOne { + vuo.mutation.ClearSize() + return vuo +} + // SetHash sets the "hash" field. func (vuo *VersionUpdateOne) SetHash(s string) *VersionUpdateOne { vuo.mutation.SetHash(s) return vuo } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableHash(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetHash(*s) + } + return vuo +} + +// ClearHash clears the value of the "hash" field. +func (vuo *VersionUpdateOne) ClearHash() *VersionUpdateOne { + vuo.mutation.ClearHash() + return vuo +} + // SetMod sets the "mod" edge to the Mod entity. func (vuo *VersionUpdateOne) SetMod(m *Mod) *VersionUpdateOne { return vuo.SetModID(m.ID) @@ -1041,6 +1322,9 @@ func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err e if value, ok := vuo.mutation.Changelog(); ok { _spec.SetField(version.FieldChangelog, field.TypeString, value) } + if vuo.mutation.ChangelogCleared() { + _spec.ClearField(version.FieldChangelog, field.TypeString) + } if value, ok := vuo.mutation.Downloads(); ok { _spec.SetField(version.FieldDownloads, field.TypeUint, value) } @@ -1050,6 +1334,9 @@ func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err e if value, ok := vuo.mutation.Key(); ok { _spec.SetField(version.FieldKey, field.TypeString, value) } + if vuo.mutation.KeyCleared() { + _spec.ClearField(version.FieldKey, field.TypeString) + } if value, ok := vuo.mutation.Stability(); ok { _spec.SetField(version.FieldStability, field.TypeEnum, value) } @@ -1068,6 +1355,9 @@ func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err e if value, ok := vuo.mutation.Metadata(); ok { _spec.SetField(version.FieldMetadata, field.TypeString, value) } + if vuo.mutation.MetadataCleared() { + _spec.ClearField(version.FieldMetadata, field.TypeString) + } if value, ok := vuo.mutation.ModReference(); ok { _spec.SetField(version.FieldModReference, field.TypeString, value) } @@ -1077,27 +1367,42 @@ func (vuo *VersionUpdateOne) sqlSave(ctx context.Context) (_node *Version, err e if value, ok := vuo.mutation.AddedVersionMajor(); ok { _spec.AddField(version.FieldVersionMajor, field.TypeInt, value) } + if vuo.mutation.VersionMajorCleared() { + _spec.ClearField(version.FieldVersionMajor, field.TypeInt) + } if value, ok := vuo.mutation.VersionMinor(); ok { _spec.SetField(version.FieldVersionMinor, field.TypeInt, value) } if value, ok := vuo.mutation.AddedVersionMinor(); ok { _spec.AddField(version.FieldVersionMinor, field.TypeInt, value) } + if vuo.mutation.VersionMinorCleared() { + _spec.ClearField(version.FieldVersionMinor, field.TypeInt) + } if value, ok := vuo.mutation.VersionPatch(); ok { _spec.SetField(version.FieldVersionPatch, field.TypeInt, value) } if value, ok := vuo.mutation.AddedVersionPatch(); ok { _spec.AddField(version.FieldVersionPatch, field.TypeInt, value) } + if vuo.mutation.VersionPatchCleared() { + _spec.ClearField(version.FieldVersionPatch, field.TypeInt) + } if value, ok := vuo.mutation.Size(); ok { _spec.SetField(version.FieldSize, field.TypeInt64, value) } if value, ok := vuo.mutation.AddedSize(); ok { _spec.AddField(version.FieldSize, field.TypeInt64, value) } + if vuo.mutation.SizeCleared() { + _spec.ClearField(version.FieldSize, field.TypeInt64) + } if value, ok := vuo.mutation.Hash(); ok { _spec.SetField(version.FieldHash, field.TypeString, value) } + if vuo.mutation.HashCleared() { + _spec.ClearField(version.FieldHash, field.TypeString) + } if vuo.mutation.ModCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/generated/ent/versiontarget/where.go b/generated/ent/versiontarget/where.go index 11cb20b5..f89436c4 100644 --- a/generated/ent/versiontarget/where.go +++ b/generated/ent/versiontarget/where.go @@ -273,6 +273,16 @@ func KeyHasSuffix(v string) predicate.VersionTarget { return predicate.VersionTarget(sql.FieldHasSuffix(FieldKey, v)) } +// KeyIsNil applies the IsNil predicate on the "key" field. +func KeyIsNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIsNull(FieldKey)) +} + +// KeyNotNil applies the NotNil predicate on the "key" field. +func KeyNotNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotNull(FieldKey)) +} + // KeyEqualFold applies the EqualFold predicate on the "key" field. func KeyEqualFold(v string) predicate.VersionTarget { return predicate.VersionTarget(sql.FieldEqualFold(FieldKey, v)) @@ -338,6 +348,16 @@ func HashHasSuffix(v string) predicate.VersionTarget { return predicate.VersionTarget(sql.FieldHasSuffix(FieldHash, v)) } +// HashIsNil applies the IsNil predicate on the "hash" field. +func HashIsNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIsNull(FieldHash)) +} + +// HashNotNil applies the NotNil predicate on the "hash" field. +func HashNotNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotNull(FieldHash)) +} + // HashEqualFold applies the EqualFold predicate on the "hash" field. func HashEqualFold(v string) predicate.VersionTarget { return predicate.VersionTarget(sql.FieldEqualFold(FieldHash, v)) @@ -388,6 +408,16 @@ func SizeLTE(v int64) predicate.VersionTarget { return predicate.VersionTarget(sql.FieldLTE(FieldSize, v)) } +// SizeIsNil applies the IsNil predicate on the "size" field. +func SizeIsNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldIsNull(FieldSize)) +} + +// SizeNotNil applies the NotNil predicate on the "size" field. +func SizeNotNil() predicate.VersionTarget { + return predicate.VersionTarget(sql.FieldNotNull(FieldSize)) +} + // HasSmlVersion applies the HasEdge predicate on the "sml_version" edge. func HasSmlVersion() predicate.VersionTarget { return predicate.VersionTarget(func(s *sql.Selector) { diff --git a/generated/ent/versiontarget_create.go b/generated/ent/versiontarget_create.go index 8ad3c6ee..e95899f7 100644 --- a/generated/ent/versiontarget_create.go +++ b/generated/ent/versiontarget_create.go @@ -41,18 +41,42 @@ func (vtc *VersionTargetCreate) SetKey(s string) *VersionTargetCreate { return vtc } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vtc *VersionTargetCreate) SetNillableKey(s *string) *VersionTargetCreate { + if s != nil { + vtc.SetKey(*s) + } + return vtc +} + // SetHash sets the "hash" field. func (vtc *VersionTargetCreate) SetHash(s string) *VersionTargetCreate { vtc.mutation.SetHash(s) return vtc } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vtc *VersionTargetCreate) SetNillableHash(s *string) *VersionTargetCreate { + if s != nil { + vtc.SetHash(*s) + } + return vtc +} + // SetSize sets the "size" field. func (vtc *VersionTargetCreate) SetSize(i int64) *VersionTargetCreate { vtc.mutation.SetSize(i) return vtc } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vtc *VersionTargetCreate) SetNillableSize(i *int64) *VersionTargetCreate { + if i != nil { + vtc.SetSize(*i) + } + return vtc +} + // SetID sets the "id" field. func (vtc *VersionTargetCreate) SetID(s string) *VersionTargetCreate { vtc.mutation.SetID(s) @@ -127,15 +151,6 @@ func (vtc *VersionTargetCreate) check() error { if _, ok := vtc.mutation.TargetName(); !ok { return &ValidationError{Name: "target_name", err: errors.New(`ent: missing required field "VersionTarget.target_name"`)} } - if _, ok := vtc.mutation.Key(); !ok { - return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "VersionTarget.key"`)} - } - if _, ok := vtc.mutation.Hash(); !ok { - return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "VersionTarget.hash"`)} - } - if _, ok := vtc.mutation.Size(); !ok { - return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "VersionTarget.size"`)} - } if _, ok := vtc.mutation.SmlVersionID(); !ok { return &ValidationError{Name: "sml_version", err: errors.New(`ent: missing required edge "VersionTarget.sml_version"`)} } @@ -296,6 +311,12 @@ func (u *VersionTargetUpsert) UpdateKey() *VersionTargetUpsert { return u } +// ClearKey clears the value of the "key" field. +func (u *VersionTargetUpsert) ClearKey() *VersionTargetUpsert { + u.SetNull(versiontarget.FieldKey) + return u +} + // SetHash sets the "hash" field. func (u *VersionTargetUpsert) SetHash(v string) *VersionTargetUpsert { u.Set(versiontarget.FieldHash, v) @@ -308,6 +329,12 @@ func (u *VersionTargetUpsert) UpdateHash() *VersionTargetUpsert { return u } +// ClearHash clears the value of the "hash" field. +func (u *VersionTargetUpsert) ClearHash() *VersionTargetUpsert { + u.SetNull(versiontarget.FieldHash) + return u +} + // SetSize sets the "size" field. func (u *VersionTargetUpsert) SetSize(v int64) *VersionTargetUpsert { u.Set(versiontarget.FieldSize, v) @@ -326,6 +353,12 @@ func (u *VersionTargetUpsert) AddSize(v int64) *VersionTargetUpsert { return u } +// ClearSize clears the value of the "size" field. +func (u *VersionTargetUpsert) ClearSize() *VersionTargetUpsert { + u.SetNull(versiontarget.FieldSize) + 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: // @@ -416,6 +449,13 @@ func (u *VersionTargetUpsertOne) UpdateKey() *VersionTargetUpsertOne { }) } +// ClearKey clears the value of the "key" field. +func (u *VersionTargetUpsertOne) ClearKey() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearKey() + }) +} + // SetHash sets the "hash" field. func (u *VersionTargetUpsertOne) SetHash(v string) *VersionTargetUpsertOne { return u.Update(func(s *VersionTargetUpsert) { @@ -430,6 +470,13 @@ func (u *VersionTargetUpsertOne) UpdateHash() *VersionTargetUpsertOne { }) } +// ClearHash clears the value of the "hash" field. +func (u *VersionTargetUpsertOne) ClearHash() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearHash() + }) +} + // SetSize sets the "size" field. func (u *VersionTargetUpsertOne) SetSize(v int64) *VersionTargetUpsertOne { return u.Update(func(s *VersionTargetUpsert) { @@ -451,6 +498,13 @@ func (u *VersionTargetUpsertOne) UpdateSize() *VersionTargetUpsertOne { }) } +// ClearSize clears the value of the "size" field. +func (u *VersionTargetUpsertOne) ClearSize() *VersionTargetUpsertOne { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearSize() + }) +} + // Exec executes the query. func (u *VersionTargetUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -708,6 +762,13 @@ func (u *VersionTargetUpsertBulk) UpdateKey() *VersionTargetUpsertBulk { }) } +// ClearKey clears the value of the "key" field. +func (u *VersionTargetUpsertBulk) ClearKey() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearKey() + }) +} + // SetHash sets the "hash" field. func (u *VersionTargetUpsertBulk) SetHash(v string) *VersionTargetUpsertBulk { return u.Update(func(s *VersionTargetUpsert) { @@ -722,6 +783,13 @@ func (u *VersionTargetUpsertBulk) UpdateHash() *VersionTargetUpsertBulk { }) } +// ClearHash clears the value of the "hash" field. +func (u *VersionTargetUpsertBulk) ClearHash() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearHash() + }) +} + // SetSize sets the "size" field. func (u *VersionTargetUpsertBulk) SetSize(v int64) *VersionTargetUpsertBulk { return u.Update(func(s *VersionTargetUpsert) { @@ -743,6 +811,13 @@ func (u *VersionTargetUpsertBulk) UpdateSize() *VersionTargetUpsertBulk { }) } +// ClearSize clears the value of the "size" field. +func (u *VersionTargetUpsertBulk) ClearSize() *VersionTargetUpsertBulk { + return u.Update(func(s *VersionTargetUpsert) { + s.ClearSize() + }) +} + // Exec executes the query. func (u *VersionTargetUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/generated/ent/versiontarget_update.go b/generated/ent/versiontarget_update.go index 2dd1d1a8..e592b543 100644 --- a/generated/ent/versiontarget_update.go +++ b/generated/ent/versiontarget_update.go @@ -47,12 +47,40 @@ func (vtu *VersionTargetUpdate) SetKey(s string) *VersionTargetUpdate { return vtu } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vtu *VersionTargetUpdate) SetNillableKey(s *string) *VersionTargetUpdate { + if s != nil { + vtu.SetKey(*s) + } + return vtu +} + +// ClearKey clears the value of the "key" field. +func (vtu *VersionTargetUpdate) ClearKey() *VersionTargetUpdate { + vtu.mutation.ClearKey() + return vtu +} + // SetHash sets the "hash" field. func (vtu *VersionTargetUpdate) SetHash(s string) *VersionTargetUpdate { vtu.mutation.SetHash(s) return vtu } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vtu *VersionTargetUpdate) SetNillableHash(s *string) *VersionTargetUpdate { + if s != nil { + vtu.SetHash(*s) + } + return vtu +} + +// ClearHash clears the value of the "hash" field. +func (vtu *VersionTargetUpdate) ClearHash() *VersionTargetUpdate { + vtu.mutation.ClearHash() + return vtu +} + // SetSize sets the "size" field. func (vtu *VersionTargetUpdate) SetSize(i int64) *VersionTargetUpdate { vtu.mutation.ResetSize() @@ -60,12 +88,26 @@ func (vtu *VersionTargetUpdate) SetSize(i int64) *VersionTargetUpdate { return vtu } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vtu *VersionTargetUpdate) SetNillableSize(i *int64) *VersionTargetUpdate { + if i != nil { + vtu.SetSize(*i) + } + return vtu +} + // AddSize adds i to the "size" field. func (vtu *VersionTargetUpdate) AddSize(i int64) *VersionTargetUpdate { vtu.mutation.AddSize(i) return vtu } +// ClearSize clears the value of the "size" field. +func (vtu *VersionTargetUpdate) ClearSize() *VersionTargetUpdate { + vtu.mutation.ClearSize() + return vtu +} + // SetSmlVersionID sets the "sml_version" edge to the Version entity by ID. func (vtu *VersionTargetUpdate) SetSmlVersionID(id string) *VersionTargetUpdate { vtu.mutation.SetSmlVersionID(id) @@ -147,15 +189,24 @@ func (vtu *VersionTargetUpdate) sqlSave(ctx context.Context) (n int, err error) if value, ok := vtu.mutation.Key(); ok { _spec.SetField(versiontarget.FieldKey, field.TypeString, value) } + if vtu.mutation.KeyCleared() { + _spec.ClearField(versiontarget.FieldKey, field.TypeString) + } if value, ok := vtu.mutation.Hash(); ok { _spec.SetField(versiontarget.FieldHash, field.TypeString, value) } + if vtu.mutation.HashCleared() { + _spec.ClearField(versiontarget.FieldHash, field.TypeString) + } if value, ok := vtu.mutation.Size(); ok { _spec.SetField(versiontarget.FieldSize, field.TypeInt64, value) } if value, ok := vtu.mutation.AddedSize(); ok { _spec.AddField(versiontarget.FieldSize, field.TypeInt64, value) } + if vtu.mutation.SizeCleared() { + _spec.ClearField(versiontarget.FieldSize, field.TypeInt64) + } if vtu.mutation.SmlVersionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -225,12 +276,40 @@ func (vtuo *VersionTargetUpdateOne) SetKey(s string) *VersionTargetUpdateOne { return vtuo } +// SetNillableKey sets the "key" field if the given value is not nil. +func (vtuo *VersionTargetUpdateOne) SetNillableKey(s *string) *VersionTargetUpdateOne { + if s != nil { + vtuo.SetKey(*s) + } + return vtuo +} + +// ClearKey clears the value of the "key" field. +func (vtuo *VersionTargetUpdateOne) ClearKey() *VersionTargetUpdateOne { + vtuo.mutation.ClearKey() + return vtuo +} + // SetHash sets the "hash" field. func (vtuo *VersionTargetUpdateOne) SetHash(s string) *VersionTargetUpdateOne { vtuo.mutation.SetHash(s) return vtuo } +// SetNillableHash sets the "hash" field if the given value is not nil. +func (vtuo *VersionTargetUpdateOne) SetNillableHash(s *string) *VersionTargetUpdateOne { + if s != nil { + vtuo.SetHash(*s) + } + return vtuo +} + +// ClearHash clears the value of the "hash" field. +func (vtuo *VersionTargetUpdateOne) ClearHash() *VersionTargetUpdateOne { + vtuo.mutation.ClearHash() + return vtuo +} + // SetSize sets the "size" field. func (vtuo *VersionTargetUpdateOne) SetSize(i int64) *VersionTargetUpdateOne { vtuo.mutation.ResetSize() @@ -238,12 +317,26 @@ func (vtuo *VersionTargetUpdateOne) SetSize(i int64) *VersionTargetUpdateOne { return vtuo } +// SetNillableSize sets the "size" field if the given value is not nil. +func (vtuo *VersionTargetUpdateOne) SetNillableSize(i *int64) *VersionTargetUpdateOne { + if i != nil { + vtuo.SetSize(*i) + } + return vtuo +} + // AddSize adds i to the "size" field. func (vtuo *VersionTargetUpdateOne) AddSize(i int64) *VersionTargetUpdateOne { vtuo.mutation.AddSize(i) return vtuo } +// ClearSize clears the value of the "size" field. +func (vtuo *VersionTargetUpdateOne) ClearSize() *VersionTargetUpdateOne { + vtuo.mutation.ClearSize() + return vtuo +} + // SetSmlVersionID sets the "sml_version" edge to the Version entity by ID. func (vtuo *VersionTargetUpdateOne) SetSmlVersionID(id string) *VersionTargetUpdateOne { vtuo.mutation.SetSmlVersionID(id) @@ -355,15 +448,24 @@ func (vtuo *VersionTargetUpdateOne) sqlSave(ctx context.Context) (_node *Version if value, ok := vtuo.mutation.Key(); ok { _spec.SetField(versiontarget.FieldKey, field.TypeString, value) } + if vtuo.mutation.KeyCleared() { + _spec.ClearField(versiontarget.FieldKey, field.TypeString) + } if value, ok := vtuo.mutation.Hash(); ok { _spec.SetField(versiontarget.FieldHash, field.TypeString, value) } + if vtuo.mutation.HashCleared() { + _spec.ClearField(versiontarget.FieldHash, field.TypeString) + } if value, ok := vtuo.mutation.Size(); ok { _spec.SetField(versiontarget.FieldSize, field.TypeInt64, value) } if value, ok := vtuo.mutation.AddedSize(); ok { _spec.AddField(versiontarget.FieldSize, field.TypeInt64, value) } + if vtuo.mutation.SizeCleared() { + _spec.ClearField(versiontarget.FieldSize, field.TypeInt64) + } if vtuo.mutation.SmlVersionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/gql/gql_types.go b/gql/gql_types.go index b193fb07..52aef7b3 100644 --- a/gql/gql_types.go +++ b/gql/gql_types.go @@ -1,174 +1,24 @@ package gql import ( - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/util" ) -func DBModToGenerated(mod *postgres.Mod) *generated.Mod { - if mod == nil { - return nil - } - - Logo := mod.Logo - SourceURL := mod.SourceURL - FullDescription := mod.FullDescription - - var LastVersionDate string - if mod.LastVersionDate != nil { - LastVersionDate = mod.LastVersionDate.Format(time.RFC3339Nano) - } - - return &generated.Mod{ - ID: mod.ID, - Name: mod.Name, - ShortDescription: mod.ShortDescription, - Logo: &Logo, - SourceURL: &SourceURL, - CreatorID: mod.CreatorID, - Approved: mod.Approved, - Views: int(mod.Views), - Downloads: int(mod.Downloads), - Hotness: int(mod.Hotness), - Popularity: int(mod.Popularity), - UpdatedAt: mod.UpdatedAt.Format(time.RFC3339Nano), - CreatedAt: mod.CreatedAt.Format(time.RFC3339Nano), - FullDescription: &FullDescription, - LastVersionDate: &LastVersionDate, - ModReference: mod.ModReference, - Hidden: mod.Hidden, - Versions: DBVersionsToGeneratedSlice(mod.Versions), - Tags: DBTagsToGeneratedSlice(mod.Tags), - Compatibility: DBCompInfoToGenCompInfo(mod.Compatibility), - } -} - -func DBVersionToGenerated(version *postgres.Version) *generated.Version { - if version == nil { - return nil - } - - size := 0 - - if version.Size != nil { - size = int(*version.Size) - } - - return &generated.Version{ - ID: version.ID, - Version: version.Version, - SmlVersion: version.SMLVersion, - Changelog: version.Changelog, - Downloads: int(version.Downloads), - Stability: generated.VersionStabilities(version.Stability), - Targets: DBVersionTargetsToGeneratedSlice(version.Targets), - Approved: version.Approved, - UpdatedAt: version.UpdatedAt.Format(time.RFC3339Nano), - CreatedAt: version.CreatedAt.Format(time.RFC3339Nano), - ModID: version.ModID, - Metadata: version.Metadata, - Hash: version.Hash, - Size: &size, - } -} - -func DBVersionsToGeneratedSlice(versions []postgres.Version) []*generated.Version { - converted := make([]*generated.Version, len(versions)) - for i, version := range versions { - converted[i] = DBVersionToGenerated(&version) - } - return converted -} - -func DBVersionDependencyToGenerated(versionDependency *postgres.VersionDependency) *generated.VersionDependency { - if versionDependency == nil { - return nil - } - - return &generated.VersionDependency{ - VersionID: versionDependency.VersionID, - ModID: versionDependency.ModID, - Condition: versionDependency.Condition, - Optional: versionDependency.Optional, - } -} - -func DBTagToGenerated(tag *postgres.Tag) *generated.Tag { - if tag == nil { - return nil - } - return &generated.Tag{ - Name: tag.Name, - ID: tag.ID, - Description: tag.Description, - } -} - -func DBTagsToGeneratedSlice(tags []postgres.Tag) []*generated.Tag { - converted := make([]*generated.Tag, len(tags)) - for i, tag := range tags { - converted[i] = DBTagToGenerated(&tag) - } - return converted -} - -func DBVersionTargetToGenerated(versionTarget *postgres.VersionTarget) *generated.VersionTarget { - if versionTarget == nil { - return nil - } - - hash := versionTarget.Hash - size := int(versionTarget.Size) - - return &generated.VersionTarget{ - VersionID: versionTarget.VersionID, - TargetName: generated.TargetName(versionTarget.TargetName), - Hash: &hash, - Size: &size, - } -} - -func DBVersionTargetsToGeneratedSlice(versionTargets []postgres.VersionTarget) []*generated.VersionTarget { - converted := make([]*generated.VersionTarget, len(versionTargets)) - for i, versionTarget := range versionTargets { - converted[i] = DBVersionTargetToGenerated(&versionTarget) - } - return converted -} - -func GenCompInfoToDBCompInfo(gen *generated.CompatibilityInfoInput) *postgres.CompatibilityInfo { +func GenCompInfoToDBCompInfo(gen *generated.CompatibilityInfoInput) *util.CompatibilityInfo { if gen == nil { return nil } - return &postgres.CompatibilityInfo{ + return &util.CompatibilityInfo{ Ea: GenCompToDBComp(gen.Ea), Exp: GenCompToDBComp(gen.Exp), } } -func GenCompToDBComp(gen *generated.CompatibilityInput) postgres.Compatibility { - r := postgres.Compatibility{ +func GenCompToDBComp(gen *generated.CompatibilityInput) util.Compatibility { + r := util.Compatibility{ State: string(gen.State), } SetINN(gen.Note, &r.Note) return r } - -func DBCompInfoToGenCompInfo(gen *postgres.CompatibilityInfo) *generated.CompatibilityInfo { - if gen == nil { - return nil - } - return &generated.CompatibilityInfo{ - Ea: DBCompToGenComp(gen.Ea), - Exp: DBCompToGenComp(gen.Exp), - } -} - -func DBCompToGenComp(db postgres.Compatibility) *generated.Compatibility { - return &generated.Compatibility{ - State: generated.CompatibilityState(db.State), - Note: &db.Note, - } -} diff --git a/gql/gql_utils.go b/gql/gql_utils.go index 16f8813f..e489eb4a 100644 --- a/gql/gql_utils.go +++ b/gql/gql_utils.go @@ -12,9 +12,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" "github.com/satisfactorymodding/smr-api/util" ) @@ -49,15 +47,6 @@ func (wrapper TraceWrapper) end() { } } -// SetStringINNOE sets target if value not nil or empty -func SetStringINNOE(value *string, target *string) { - if value == nil || *value == "" { - return - } - - *target = *value -} - // SetINN sets target if value not nil func SetINN[T any](v *T, target *T) { if v != nil { @@ -65,37 +54,30 @@ func SetINN[T any](v *T, target *T) { } } -func SetStabilityINN(value *generated.VersionStabilities, target *string) { - if value == nil { - return - } - - *target = string(*value) -} - -func SetCompatibilityINN(value *generated.CompatibilityInfoInput, target **postgres.CompatibilityInfo) { +func SetCompatibilityINNF[B any](value *generated.CompatibilityInfoInput, target func(*util.CompatibilityInfo) B) { if value == nil { return } - toDB := GenCompInfoToDBCompInfo(value) - *target = toDB + target(GenCompInfoToDBCompInfo(value)) } +// SetINNF - Set if not null function func SetINNF[T any, B any](value *T, target func(T) B) { if value != nil { target(*value) } } +// SetINNOEF - Set if not null or empty function func SetINNOEF[T comparable, B any](value *T, target func(T) B) { if value != nil && *value != *(new(T)) { target(*value) } } -func SetStabilityINNF[B any](value *generated.VersionStabilities, target func(smlversion.Stability) B) { +func SetStabilityINNF[B any](value *generated.VersionStabilities, target func(util.Stability) B) { if value != nil { - target(smlversion.Stability(*value)) + target(util.Stability(*value)) } } diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 4a38b425..8282b83b 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "log/slog" + "math" "strings" "time" @@ -18,11 +19,12 @@ import ( "github.com/satisfactorymodding/smr-api/dataloader" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "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/modtag" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/models" @@ -41,45 +43,49 @@ var DisallowedModReferences = map[string]bool{ "docmod": true, } -func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) (*generated.Mod, error) { +func (r *mutationResolver) CreateMod(ctx context.Context, newMod generated.NewMod) (*generated.Mod, error) { wrapper, ctx := WrapMutationTrace(ctx, "createMod") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&mod); err != nil { + if err := val.Struct(&newMod); err != nil { return nil, fmt.Errorf("validation failed: %w", err) } - if DisallowedModReferences[strings.ToLower(mod.ModReference)] { + if DisallowedModReferences[strings.ToLower(newMod.ModReference)] { return nil, errors.New("using this mod reference is not allowed") } - if postgres.GetModByReference(ctx, mod.ModReference) != nil { - return nil, errors.New("mod with this mod reference already exists") + exist, err := db.From(ctx).Mod.Query().Where(mod.ModReference(newMod.ModReference)).Exist(ctx) + if err != nil { + return nil, err } - dbMod := &postgres.Mod{ - Name: mod.Name, - ShortDescription: mod.ShortDescription, - Approved: true, - ModReference: mod.ModReference, + if exist { + return nil, errors.New("mod with this mod reference already exists") } - SetINN(mod.SourceURL, &dbMod.SourceURL) - SetINN(mod.FullDescription, &dbMod.FullDescription) - SetINN(mod.Hidden, &dbMod.Hidden) + dbMod := db.From(ctx).Mod.Create(). + SetName(newMod.Name). + SetShortDescription(newMod.ShortDescription). + SetApproved(true). + SetModReference(newMod.ModReference) + + SetINNF(newMod.SourceURL, dbMod.SetSourceURL) + SetINNF(newMod.FullDescription, dbMod.SetFullDescription) + SetINNF(newMod.Hidden, dbMod.SetHidden) user, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } - dbMod.CreatorID = user.ID + dbMod.SetCreatorID(user.ID) var logoData []byte - if mod.Logo != nil { - file, err := io.ReadAll(mod.Logo.File) + if newMod.Logo != nil { + file, err := io.ReadAll(newMod.Logo.File) if err != nil { return nil, fmt.Errorf("failed to read logo file: %w", err) } @@ -90,68 +96,104 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) return nil, fmt.Errorf("failed to convert logo file: %w", err) } } else { - dbMod.Logo = "" + dbMod.SetLogo("") + } + + // Allow only new 4 mods per 24h + existingMods, err := db.From(ctx).Mod.Query(). + Order(mod.ByCreatedAt(sql.OrderAsc())). + Where(mod.CreatorID(user.ID), mod.CreatedAtGT(time.Now().Add(time.Hour*24*-1))). + All(ctx) + if err != nil { + return nil, err + } + + currentAvailable := float64(4) + lastModTime := time.Now() + for _, mod := range existingMods { + currentAvailable-- + if mod.CreatedAt.After(lastModTime) { + diff := mod.CreatedAt.Sub(lastModTime) + currentAvailable = math.Min(4, currentAvailable+diff.Hours()/6) + } + lastModTime = mod.CreatedAt + } + + if currentAvailable < 1 { + timeToWait := time.Until(lastModTime.Add(time.Hour * 6)).Minutes() + return nil, fmt.Errorf("please wait %.0f minutes to post another mod", timeToWait) } - resultMod, err := postgres.CreateMod(ctx, dbMod) + // Create mod + resultMod, err := dbMod.Save(ctx) if err != nil { return nil, err } + if err := db.From(ctx).UserMod.Create(). + SetRole("creator"). + SetModID(resultMod.ID). + SetUserID(user.ID). + Exec(ctx); err != nil { + return nil, err + } + if logoData != nil { success, logoKey := storage.UploadModLogo(ctx, resultMod.ID, bytes.NewReader(logoData)) if success { - resultMod.Logo = storage.GenerateDownloadLink(logoKey) - postgres.Save(ctx, &resultMod) + resultMod, err = resultMod.Update().SetLogo(storage.GenerateDownloadLink(logoKey)).Save(ctx) + if err != nil { + return nil, err + } + } + } + + if len(newMod.TagIDs) > 0 { + if err := resultMod.Update().AddTagIDs(newMod.TagIDs...).Exec(ctx); err != nil { + return nil, err } } - err = postgres.SetModTags(ctx, resultMod.ID, mod.TagIDs) + // Need to get the mod again to populate tags + resultMod, err = db.From(ctx).Mod.Query().WithTags().Where(mod.ID(resultMod.ID)).First(ctx) if err != nil { return nil, err } - // Need to get the mod again to populate tags - return DBModToGenerated(postgres.GetModByIDNoCache(ctx, resultMod.ID)), nil + return (*conv.ModImpl)(nil).Convert(resultMod), nil } -func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod generated.UpdateMod) (*generated.Mod, error) { +func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, updateMod generated.UpdateMod) (*generated.Mod, error) { wrapper, ctx := WrapMutationTrace(ctx, "updateMod") defer wrapper.end() val := ctx.Value(util.ContextValidator{}).(*validator.Validate) - if err := val.Struct(&mod); err != nil { + if err := val.Struct(&updateMod); err != nil { return nil, fmt.Errorf("validation failed: %w", err) } - if mod.TagIDs != nil { - err := postgres.ResetModTags(ctx, modID, mod.TagIDs) - if err != nil { - return nil, err - } - } - - dbMod := postgres.GetModByIDNoCache(ctx, modID) - - if dbMod == nil { - return nil, errors.New("mod not found") + dbMod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return nil, err } - if mod.ModReference != nil && *mod.ModReference != dbMod.ModReference && dbMod.ID != dbMod.ModReference { + if updateMod.ModReference != nil && *updateMod.ModReference != dbMod.ModReference && dbMod.ID != dbMod.ModReference { return nil, errors.New("this mod already has set a mod reference") } - SetStringINNOE(mod.Name, &dbMod.Name) - SetStringINNOE(mod.ShortDescription, &dbMod.ShortDescription) - SetINN(mod.SourceURL, &dbMod.SourceURL) - SetINN(mod.FullDescription, &dbMod.FullDescription) - SetINN(mod.ModReference, &dbMod.ModReference) - SetINN(mod.Hidden, &dbMod.Hidden) - SetCompatibilityINN(mod.Compatibility, &dbMod.Compatibility) + dbUpdate := dbMod.Update().ClearTags().AddTagIDs(updateMod.TagIDs...) + + SetINNOEF(updateMod.Name, dbUpdate.SetName) + SetINNOEF(updateMod.ShortDescription, dbUpdate.SetShortDescription) + SetINNF(updateMod.SourceURL, dbUpdate.SetSourceURL) + SetINNF(updateMod.FullDescription, dbUpdate.SetFullDescription) + SetINNF(updateMod.ModReference, dbUpdate.SetModReference) + SetINNF(updateMod.Hidden, dbUpdate.SetHidden) + SetCompatibilityINNF(updateMod.Compatibility, dbUpdate.SetCompatibility) - if mod.Logo != nil { - file, err := io.ReadAll(mod.Logo.File) + if updateMod.Logo != nil { + file, err := io.ReadAll(updateMod.Logo.File) if err != nil { return nil, fmt.Errorf("failed to read logo file: %w", err) } @@ -169,9 +211,12 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } } - postgres.Save(ctx, &dbMod) + dbMod, err = dbUpdate.Save(ctx) + if err != nil { + return nil, err + } - if mod.Authors != nil { + if updateMod.Authors != nil { authors, err := dataloader.For(ctx).UserModsByModID.Load(ctx, modID)() if err != nil { return nil, err @@ -184,7 +229,7 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } found := false - for _, userMod := range mod.Authors { + for _, userMod := range updateMod.Authors { if userMod.UserID == author.UserID { found = true break @@ -192,26 +237,32 @@ func (r *mutationResolver) UpdateMod(ctx context.Context, modID string, mod gene } if !found { - postgres.Delete(ctx, author) + if _, err := db.From(ctx).UserMod.Delete(). + Where(usermod.UserID(author.UserID), usermod.ModID(author.ModID)). + Exec(ctx); err != nil { + return nil, err + } } } - for _, userMod := range mod.Authors { + for _, userMod := range updateMod.Authors { role := "creator" if userMod.Role == "editor" { role = "editor" } - postgres.Save(ctx, &postgres.UserMod{ - UserID: userMod.UserID, - ModID: modID, - Role: role, - }) + if err := db.From(ctx).UserMod.Create(). + SetUserID(userMod.UserID). + SetModID(modID). + SetRole(role). + Exec(ctx); err != nil { + return nil, err + } } } - return DBModToGenerated(dbMod), nil + return (*conv.ModImpl)(nil).Convert(dbMod), nil } func (r *mutationResolver) UpdateModCompatibility(ctx context.Context, modID string, compatibility generated.CompatibilityInfoInput) (bool, error) { @@ -239,14 +290,10 @@ func (r *mutationResolver) DeleteMod(ctx context.Context, modID string) (bool, e wrapper, ctx := WrapMutationTrace(ctx, "deleteMod") defer wrapper.end() - dbMod := postgres.GetModByID(ctx, modID) - - if dbMod == nil { - return false, errors.New("mod not found") + if err := db.From(ctx).Mod.DeleteOneID(modID).Exec(ctx); err != nil { + return false, err } - postgres.Delete(ctx, &dbMod) - return true, nil } @@ -254,15 +301,18 @@ func (r *mutationResolver) ApproveMod(ctx context.Context, modID string) (bool, wrapper, ctx := WrapMutationTrace(ctx, "approveMod") defer wrapper.end() - dbMod := postgres.GetModByID(ctx, modID) + dbMod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return false, err + } if dbMod == nil { return false, errors.New("mod not found") } - dbMod.Approved = true - - postgres.Save(ctx, &dbMod) + if err := dbMod.Update().SetApproved(true).Exec(ctx); err != nil { + return false, err + } go integrations.NewMod(db.ReWrapCtx(ctx), dbMod) @@ -273,16 +323,22 @@ func (r *mutationResolver) DenyMod(ctx context.Context, modID string) (bool, err wrapper, ctx := WrapMutationTrace(ctx, "denyMod") defer wrapper.end() - dbMod := postgres.GetModByID(ctx, modID) + dbMod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return false, err + } if dbMod == nil { return false, errors.New("mod not found") } - dbMod.Denied = true + if err := dbMod.Update().SetDenied(true).Exec(ctx); err != nil { + return false, err + } - postgres.Save(ctx, &dbMod) - postgres.Delete(ctx, &dbMod) + if err := db.From(ctx).Mod.DeleteOneID(modID).Exec(ctx); err != nil { + return false, err + } return true, nil } @@ -291,30 +347,40 @@ func (r *queryResolver) GetMod(ctx context.Context, modID string) (*generated.Mo wrapper, ctx := WrapQueryTrace(ctx, "getMod") defer wrapper.end() - mod := postgres.GetModByID(ctx, modID) + dbMod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return nil, err + } - if mod != nil { + if dbMod != nil { if redis.CanIncrement(RealIP(ctx), "view", "mod:"+modID, time.Hour*4) { - postgres.IncrementModViews(ctx, mod) + if err := dbMod.Update().AddViews(1).Exec(ctx); err != nil { + return nil, err + } } } - return DBModToGenerated(mod), nil + return (*conv.ModImpl)(nil).Convert(dbMod), nil } func (r *queryResolver) GetModByReference(ctx context.Context, modReference string) (*generated.Mod, error) { wrapper, ctx := WrapQueryTrace(ctx, "getModByReference") defer wrapper.end() - mod := postgres.GetModByReference(ctx, modReference) + dbMod, err := db.From(ctx).Mod.Query().Where(mod.ModReference(modReference)).First(ctx) + if err != nil { + return nil, err + } - if mod != nil { - if redis.CanIncrement(RealIP(ctx), "view", "mod:"+mod.ID, time.Hour*4) { - postgres.IncrementModViews(ctx, mod) + if dbMod != nil { + if redis.CanIncrement(RealIP(ctx), "view", "mod:"+dbMod.ID, time.Hour*4) { + if err := dbMod.Update().AddViews(1).Exec(ctx); err != nil { + return nil, err + } } } - return DBModToGenerated(mod), nil + return (*conv.ModImpl)(nil).Convert(dbMod), nil } func (r *queryResolver) GetMods(ctx context.Context, _ map[string]interface{}) (*generated.GetMods, error) { @@ -359,18 +425,15 @@ func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*ge modFilter.AddField(field.Name) } - mods := postgres.GetModsNew(ctx, modFilter, unapproved) - - if mods == nil { - return nil, errors.New("mods not found") - } + query := db.From(ctx).Debug().Mod.Query() + query = convertModFilter(query, modFilter, false, unapproved) - converted := make([]*generated.Mod, len(mods)) - for k, v := range mods { - converted[k] = DBModToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.ModImpl)(nil).ConvertSlice(result), nil } func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, error) { @@ -385,11 +448,15 @@ func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, return 0, err } - if modFilter.Ids != nil && len(modFilter.Ids) != 0 { - return len(modFilter.Ids), nil + query := db.From(ctx).Debug().Mod.Query() + query = convertModFilter(query, modFilter, false, unapproved) + + result, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetModCountNew(ctx, modFilter, unapproved)), nil + return result, nil } type getMyModsResolver struct{ *Resolver } @@ -410,24 +477,15 @@ func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([ modFilter.AddField(field.Name) } - var mods []postgres.Mod - - if modFilter.Ids == nil || len(modFilter.Ids) == 0 { - mods = postgres.GetModsNew(ctx, modFilter, unapproved) - } else { - mods = postgres.GetModsByID(ctx, modFilter.Ids) - } - - if mods == nil { - return nil, errors.New("mods not found") - } + query := db.From(ctx).Debug().Mod.Query() + query = convertModFilter(query, modFilter, false, unapproved) - converted := make([]*generated.Mod, len(mods)) - for k, v := range mods { - converted[k] = DBModToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.ModImpl)(nil).ConvertSlice(result), nil } func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) (int, error) { @@ -442,11 +500,15 @@ func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) ( return 0, err } - if modFilter.Ids != nil && len(modFilter.Ids) != 0 { - return len(modFilter.Ids), nil + query := db.From(ctx).Debug().Mod.Query() + query = convertModFilter(query, modFilter, false, unapproved) + + result, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetModCountNew(ctx, modFilter, unapproved)), nil + return result, nil } type modResolver struct{ *Resolver } @@ -476,10 +538,19 @@ func (r *modResolver) Authors(ctx context.Context, obj *generated.Mod) ([]*gener return converted, nil } -func (r *modResolver) Version(ctx context.Context, obj *generated.Mod, version string) (*generated.Version, error) { +func (r *modResolver) Version(ctx context.Context, obj *generated.Mod, versionName string) (*generated.Version, error) { wrapper, ctx := WrapQueryTrace(ctx, "Mod.version") defer wrapper.end() - return DBVersionToGenerated(postgres.GetModVersionByName(ctx, obj.ID, version)), nil + + dbVersion, err := db.From(ctx).Version.Query(). + WithTargets(). + Where(version.Version(versionName), version.ModID(obj.ID)). + First(ctx) + if err != nil { + return nil, err + } + + return (*conv.VersionImpl)(nil).Convert(dbVersion), nil } var versionNoMetaCache, _ = ristretto.NewCache(&ristretto.Config{ @@ -590,11 +661,11 @@ func (r *modResolver) LatestVersions(ctx context.Context, obj *generated.Mod) (* converted := generated.LatestVersions{} for _, v := range versions { switch v.Stability { - case version.StabilityAlpha: + case util.StabilityAlpha: converted.Alpha = (*conv.VersionImpl)(nil).Convert(v) - case version.StabilityBeta: + case util.StabilityBeta: converted.Beta = (*conv.VersionImpl)(nil).Convert(v) - case version.StabilityRelease: + case util.StabilityRelease: converted.Release = (*conv.VersionImpl)(nil).Convert(v) } } @@ -636,30 +707,30 @@ func (r *queryResolver) ResolveModVersions(ctx context.Context, filter []*genera constraintMapping[constraint.ModIDOrReference] = constraint.Version } - mods := postgres.GetModsByIDOrReference(ctx, modIDOrReferences) - - if mods == nil { - return nil, errors.New("no mods found") + mods, err := db.From(ctx).Mod.Query(). + WithTags(). + Where(mod.Or(mod.IDIn(modIDOrReferences...), mod.ModReferenceIn(modIDOrReferences...))). + All(ctx) + if err != nil { + return nil, err } modVersions := make([]*generated.ModVersion, len(mods)) - for i, mod := range mods { - constraint, ok := constraintMapping[mod.ID] + for i, m := range mods { + constraint, ok := constraintMapping[m.ID] if !ok { - constraint = constraintMapping[mod.ModReference] + constraint = constraintMapping[m.ModReference] } - versions := postgres.GetModVersionsConstraint(ctx, mod.ID, constraint) - - converted := make([]*generated.Version, len(versions)) - for k, v := range versions { - converted[k] = DBVersionToGenerated(&v) + versions, err := db.GetModVersionsConstraint(ctx, m.ID, constraint) + if err != nil { + return nil, err } modVersions[i] = &generated.ModVersion{ - ID: mod.ID, - ModReference: mod.ModReference, - Versions: converted, + ID: m.ID, + ModReference: m.ModReference, + Versions: (*conv.VersionImpl)(nil).ConvertSlice(versions), } } @@ -684,3 +755,64 @@ func (r *queryResolver) GetModAssetList(ctx context.Context, modReference string return assets, nil } + +func convertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, unapproved bool) *ent.ModQuery { + if len(filter.Ids) > 0 { + query = query.Where(mod.IDIn(filter.Ids...)) + } else if len(filter.References) > 0 { + query = query.Where(mod.ModReferenceIn(filter.References...)) + } else if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset) + + if *filter.OrderBy != generated.ModFieldsSearch { + if string(*filter.OrderBy) == "last_version_date" { + query = query.Order(sql.OrderByField( + "case when last_version_date is null then 1 else 0 end, last_version_date", + db.OrderToOrder(filter.Order.String()), + ).ToFunc()) + } else { + query = query.Order(sql.OrderByField( + filter.OrderBy.String(), + db.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.SelectExpr(sql.ExprP("id, (similarity(name, ?) * 2 + similarity(short_description, ?) + similarity(full_description, ?) * 0.5) as s", cleanSearch, cleanSearch, cleanSearch)) + join.From(sql.Table(mod.Table)).As("t1") + s.Join(join).On(s.C(mod.FieldID), join.C("id")) + }) + + query = query.Where(func(s *sql.Selector) { + s.Where(sql.ExprP(`"t1"."s" > 0.2`)) + }) + + if !count && *filter.OrderBy == generated.ModFieldsSearch { + query = query.Order(func(s *sql.Selector) { + s.OrderExpr(sql.ExprP(`"t1"."s" DESC`)) + }) + } + } + + if filter.Hidden == nil || !(*filter.Hidden) { + query = query.Where(mod.Hidden(false)) + } + + if filter.TagIDs != nil && len(filter.TagIDs) > 0 { + query = query.Where(func(s *sql.Selector) { + t := sql.Table(modtag.Table) + s.Join(t).OnP(sql.ExprP("mod_tags.tag_id in ? AND mod_tags.mod_id = mods.id", filter.TagIDs)) + }) + } + } + + query = query.Where(mod.Approved(!unapproved), mod.Denied(false)) + + return query +} diff --git a/gql/resolver_sml_versions.go b/gql/resolver_sml_versions.go index 220dcc02..ccfd5a49 100644 --- a/gql/resolver_sml_versions.go +++ b/gql/resolver_sml_versions.go @@ -41,7 +41,7 @@ func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion gene SetVersion(smlVersion.Version). SetSatisfactoryVersion(smlVersion.SatisfactoryVersion). SetNillableBootstrapVersion(smlVersion.BootstrapVersion). - SetStability(smlversion.Stability(smlVersion.Stability)). + SetStability(util.Stability(smlVersion.Stability)). SetLink(smlVersion.Link). SetChangelog(smlVersion.Changelog). SetDate(date). diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index d2f5a087..3f4acb86 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -7,8 +7,10 @@ import ( "io" "log/slog" "runtime/debug" + "strings" "time" + "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/Vilsol/slox" "github.com/dgraph-io/ristretto" @@ -16,10 +18,10 @@ import ( "github.com/satisfactorymodding/smr-api/dataloader" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "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/version" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/redis" @@ -31,7 +33,10 @@ func (r *mutationResolver) CreateVersion(ctx context.Context, modID string) (str wrapper, ctx := WrapMutationTrace(ctx, "createVersion") defer wrapper.end() - mod := postgres.GetModByID(ctx, modID) + mod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return "", err + } if mod == nil { return "", errors.New("mod not found") @@ -60,7 +65,10 @@ func (r *mutationResolver) UploadVersionPart(ctx context.Context, modID string, return false, errors.New("files can consist of max 41 chunks") } - mod := postgres.GetModByID(ctx, modID) + mod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return false, err + } if mod == nil { return false, errors.New("mod not found") @@ -89,7 +97,10 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri wrapper, ctx := WrapMutationTrace(ctx, "finalizeCreateVersion") defer wrapper.end() - mod := postgres.GetModByID(ctx, modID) + mod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return false, err + } if mod == nil { return false, errors.New("mod not found") @@ -107,7 +118,7 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri slox.Info(ctx, "finalization gql call") - go func(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) { + go func(ctx context.Context, mod *ent.Mod, versionID string, version generated.NewVersion) { defer func() { if r := recover(); r != nil { slox.Error(ctx, "recovered from version finalization", slog.Any("recover", r), slog.String("stack", string(debug.Stack()))) @@ -142,32 +153,36 @@ func (r *mutationResolver) UpdateVersion(ctx context.Context, versionID string, wrapper, ctx := WrapMutationTrace(ctx, "updateVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(ctx, versionID) + dbVersion, get := db.From(ctx).Version.Get(ctx, versionID) + if get != nil { + return nil, get + } if dbVersion == nil { return nil, errors.New("version not found") } - SetStringINNOE(version.Changelog, &dbVersion.Changelog) - SetStabilityINN(version.Stability, &dbVersion.Stability) + update := dbVersion.Update() + + SetINNOEF(version.Changelog, update.SetChangelog) + SetStabilityINNF(version.Stability, update.SetStability) - postgres.Save(ctx, &dbVersion) + dbVersion, err := update.Save(ctx) + if err != nil { + return nil, err + } - return DBVersionToGenerated(dbVersion), nil + return (*conv.VersionImpl)(nil).Convert(dbVersion), nil } func (r *mutationResolver) DeleteVersion(ctx context.Context, versionID string) (bool, error) { wrapper, ctx := WrapMutationTrace(ctx, "deleteVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(ctx, versionID) - - if dbVersion == nil { - return false, errors.New("version not found") + if err := db.From(ctx).Version.DeleteOneID(versionID).Exec(ctx); err != nil { + return false, err } - postgres.Delete(ctx, &dbVersion) - return true, nil } @@ -175,20 +190,22 @@ func (r *mutationResolver) ApproveVersion(ctx context.Context, versionID string) wrapper, ctx := WrapMutationTrace(ctx, "approveVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(ctx, versionID) + dbVersion, err := db.From(ctx).Version.Get(ctx, versionID) + if err != nil { + return false, err + } if dbVersion == nil { return false, errors.New("version not found") } - dbVersion.Approved = true - - postgres.Save(ctx, &dbVersion) + if err := dbVersion.Update().SetApproved(true).Exec(ctx); err != nil { + return false, err + } - mod := postgres.GetModByID(ctx, dbVersion.ModID) - now := time.Now() - mod.LastVersionDate = &now - postgres.Save(ctx, &mod) + if err := db.From(ctx).Mod.UpdateOneID(dbVersion.ModID).SetLastVersionDate(time.Now()).Exec(ctx); err != nil { + return false, err + } go integrations.NewVersion(db.ReWrapCtx(ctx), dbVersion) @@ -199,19 +216,24 @@ func (r *mutationResolver) DenyVersion(ctx context.Context, versionID string) (b wrapper, ctx := WrapMutationTrace(ctx, "denyVersion") defer wrapper.end() - dbVersion := postgres.GetVersion(ctx, versionID) + dbVersion, err := db.From(ctx).Version.Get(ctx, versionID) + if err != nil { + return false, err + } if dbVersion == nil { return false, errors.New("version not found") } - dbVersion.Denied = true + if err := dbVersion.Update().SetDenied(true).Exec(ctx); err != nil { + return false, err + } - postgres.Save(ctx, &dbVersion) - postgres.Delete(ctx, &dbVersion) + if err := db.From(ctx).Mod.UpdateOneID(dbVersion.ModID).SetLastVersionDate(time.Now()).Exec(ctx); err != nil { + return false, err + } - mod := postgres.GetModByID(ctx, dbVersion.ModID) - postgres.Save(ctx, &mod) + db.From(ctx).Version.DeleteOneID(versionID) return true, nil } @@ -219,7 +241,13 @@ func (r *mutationResolver) DenyVersion(ctx context.Context, versionID string) (b func (r *queryResolver) GetVersion(ctx context.Context, versionID string) (*generated.Version, error) { wrapper, ctx := WrapQueryTrace(ctx, "getVersion") defer wrapper.end() - return DBVersionToGenerated(postgres.GetVersion(ctx, versionID)), nil + + result, err := db.From(ctx).Version.Get(ctx, versionID) + if err != nil { + return nil, err + } + + return (*conv.VersionImpl)(nil).Convert(result), nil } func (r *queryResolver) GetVersions(ctx context.Context, _ map[string]interface{}) (*generated.GetVersions, error) { @@ -250,7 +278,10 @@ func (r *queryResolver) CheckVersionUploadState(ctx context.Context, modID strin wrapper, ctx := WrapQueryTrace(ctx, "checkVersionUploadState") defer wrapper.end() - mod := postgres.GetModByID(ctx, modID) + mod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return nil, err + } if mod == nil { return nil, errors.New("mod not found") @@ -285,24 +316,15 @@ func (r *getVersionsResolver) Versions(ctx context.Context, _ *generated.GetVers versionFilter.AddField(field.Name) } - var versions []postgres.Version - - if versionFilter.Ids == nil || len(versionFilter.Ids) == 0 { - versions = postgres.GetVersionsNew(ctx, versionFilter, unapproved) - } else { - versions = postgres.GetVersionsByID(ctx, versionFilter.Ids) - } - - if versions == nil { - return nil, errors.New("versions not found") - } + query := db.From(ctx).Version.Query().WithTargets() + query = convertVersionFilter(query, versionFilter, unapproved) - converted := make([]*generated.Version, len(versions)) - for k, v := range versions { - converted[k] = DBVersionToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.VersionImpl)(nil).ConvertSlice(result), nil } func (r *getVersionsResolver) Count(ctx context.Context, _ *generated.GetVersions) (int, error) { @@ -317,11 +339,15 @@ func (r *getVersionsResolver) Count(ctx context.Context, _ *generated.GetVersion return 0, err } - if versionFilter.Ids != nil && len(versionFilter.Ids) != 0 { - return len(versionFilter.Ids), nil + query := db.From(ctx).Version.Query().WithTargets() + query = convertVersionFilter(query, versionFilter, unapproved) + + count, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetVersionCountNew(ctx, versionFilter, unapproved)), nil + return count, nil } type versionResolver struct{ *Resolver } @@ -354,7 +380,12 @@ func (r *versionResolver) Mod(ctx context.Context, obj *generated.Version) (*gen wrapper, ctx := WrapQueryTrace(ctx, "Version.mod") defer wrapper.end() - return DBModToGenerated(postgres.GetModByID(ctx, obj.ModID)), nil + mod, err := db.From(ctx).Mod.Get(ctx, obj.ModID) + if err != nil { + return nil, err + } + + return (*conv.ModImpl)(nil).Convert(mod), nil } func (r *versionResolver) Hash(ctx context.Context, obj *generated.Version) (*string, error) { @@ -457,24 +488,15 @@ func (r *getMyVersionsResolver) Versions(ctx context.Context, _ *generated.GetMy versionFilter.AddField(field.Name) } - var versions []postgres.Version + query := db.From(ctx).Version.Query().WithTargets() + query = convertVersionFilter(query, versionFilter, unapproved) - if versionFilter.Ids == nil || len(versionFilter.Ids) == 0 { - versions = postgres.GetVersionsNew(ctx, versionFilter, unapproved) - } else { - versions = postgres.GetVersionsByID(ctx, versionFilter.Ids) - } - - if versions == nil { - return nil, errors.New("versions not found") - } - - converted := make([]*generated.Version, len(versions)) - for k, v := range versions { - converted[k] = DBVersionToGenerated(&v) + result, err := query.All(ctx) + if err != nil { + return nil, err } - return converted, nil + return (*conv.VersionImpl)(nil).ConvertSlice(result), nil } func (r *getMyVersionsResolver) Count(ctx context.Context, _ *generated.GetMyVersions) (int, error) { @@ -489,9 +511,37 @@ func (r *getMyVersionsResolver) Count(ctx context.Context, _ *generated.GetMyVer return 0, err } - if versionFilter.Ids != nil && len(versionFilter.Ids) != 0 { - return len(versionFilter.Ids), nil + query := db.From(ctx).Version.Query().WithTargets() + query = convertVersionFilter(query, versionFilter, unapproved) + + count, err := query.Count(ctx) + if err != nil { + return 0, err } - return int(postgres.GetVersionCountNew(ctx, versionFilter, unapproved)), nil + return count, nil +} + +func convertVersionFilter(query *ent.VersionQuery, filter *models.VersionFilter, unapproved bool) *ent.VersionQuery { + if len(filter.Ids) > 0 { + query = query.Where(version.IDIn(filter.Ids...)) + } else if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset). + Order(sql.OrderByField( + filter.OrderBy.String(), + db.OrderToOrder(filter.Order.String()), + ).ToFunc()) + + if filter.Search != nil && *filter.Search != "" { + query = query.Modify(func(s *sql.Selector) { + s.Where(sql.ExprP("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & "))) + }).Clone() + } + } + + query = query.Where(version.Approved(!unapproved), version.Denied(false)) + + return query } diff --git a/gql/versions.go b/gql/versions.go index 71a5fb6d..b6ca54ee 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -8,13 +8,19 @@ import ( "log/slog" "time" + "entgo.io/ent/dialect/sql" "github.com/Vilsol/slox" "github.com/pkg/errors" "github.com/spf13/viper" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db/schema" "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent" + version2 "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiondependency" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/redis/jobs" "github.com/satisfactorymodding/smr-api/storage" @@ -22,7 +28,7 @@ import ( "github.com/satisfactorymodding/smr-api/validation" ) -func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) (*generated.CreateVersionResponse, error) { +func FinalizeVersionUploadAsync(ctx context.Context, mod *ent.Mod, versionID string, version generated.NewVersion) (*generated.CreateVersionResponse, error) { ctx = slox.With(ctx, slog.String("mod_id", mod.ID), slog.String("version_id", versionID)) slox.Info(ctx, "Completing multipart upload") @@ -78,20 +84,6 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI versionMinor := int(modInfo.Semver.Minor()) versionPatch := int(modInfo.Semver.Patch()) - dbVersion := &postgres.Version{ - Version: modInfo.Version, - SMLVersion: modInfo.SMLVersion, - Changelog: version.Changelog, - ModID: mod.ID, - Stability: string(version.Stability), - ModReference: &modInfo.ModReference, - Size: &modInfo.Size, - Hash: &modInfo.Hash, - VersionMajor: &versionMajor, - VersionMinor: &versionMinor, - VersionPatch: &versionPatch, - } - autoApproved := true for _, obj := range modInfo.Objects { if obj.Type != "pak" { @@ -102,35 +94,72 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI autoApproved = autoApproved || viper.GetBool("skip-virus-check") - dbVersion.Approved = autoApproved + count, err := db.From(ctx).Version.Query(). + Where(version2.ModID(mod.ID), version2.Version(modInfo.Version)). + Count(ctx) + if err != nil { + return nil, err + } - err = postgres.CreateVersion(ctx, dbVersion) + if count > 0 { + return nil, errors.New("this mod already has a version with this name") + } + // Allow only new 5 versions per 24h + versions, err := db.From(ctx).Version.Query(). + Order(version2.ByCreatedAt(sql.OrderAsc())). + Where(version2.ModID(mod.ID), version2.CreatedAt(time.Now().Add(time.Hour*24*-1))). + All(ctx) + if err != nil { + return nil, err + } + + if len(versions) >= 5 { + timeToWait := time.Until(versions[0].CreatedAt.Add(time.Hour * 24)).Minutes() + return nil, fmt.Errorf("please wait %.0f minutes to post another version", timeToWait) + } + + dbVersion, err := db.From(ctx).Version.Create(). + SetVersion(modInfo.Version). + SetSmlVersion(modInfo.SMLVersion). + SetChangelog(version.Changelog). + SetModID(mod.ID). + SetStability(util.Stability(version.Stability)). + SetModReference(modInfo.ModReference). + SetSize(modInfo.Size). + SetHash(modInfo.Hash). + SetVersionMajor(versionMajor). + SetVersionMinor(versionMinor). + SetVersionPatch(versionPatch). + SetApproved(autoApproved). + Save(ctx) if err != nil { storage.DeleteMod(ctx, mod.ID, mod.Name, versionID) return nil, err } for modID, condition := range modInfo.Dependencies { - dependency := postgres.VersionDependency{ - VersionID: dbVersion.ID, - ModID: modID, - Condition: condition, - Optional: false, + _, err = db.From(ctx).VersionDependency.Create(). + SetVersion(dbVersion). + SetModID(modID). + SetCondition(condition). + SetOptional(false). + Save(ctx) + if err != nil { + return nil, err } - - postgres.Save(ctx, &dependency) } for modID, condition := range modInfo.OptionalDependencies { - dependency := postgres.VersionDependency{ - VersionID: dbVersion.ID, - ModID: modID, - Condition: condition, - Optional: true, + _, err = db.From(ctx).VersionDependency.Create(). + SetVersion(dbVersion). + SetModID(modID). + SetCondition(condition). + SetOptional(true). + Save(ctx) + if err != nil { + return nil, err } - - postgres.Save(ctx, &dependency) } jsonData, err := json.Marshal(modInfo.Metadata) @@ -138,21 +167,23 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI slox.Error(ctx, "failed serializing", slog.Any("err", err), slog.String("version_id", dbVersion.ID)) } else { metadata := string(jsonData) - dbVersion.Metadata = &metadata - postgres.Save(ctx, &dbVersion) + if _, err := dbVersion.Update().SetMetadata(metadata).Save(ctx); err != nil { + return nil, err + } } if modInfo.Type == validation.MultiTargetUEPlugin { - targets := make([]*postgres.VersionTarget, 0) + targets := make([]*ent.VersionTarget, 0) for _, target := range modInfo.Targets { - dbVersionTarget := &postgres.VersionTarget{ - VersionID: dbVersion.ID, - TargetName: target, + dbVersionTarget, err := db.From(ctx).VersionTarget.Create(). + SetVersionID(dbVersion.ID). + SetTargetName(target). + Save(ctx) + if err != nil { + return nil, err } - postgres.Save(ctx, dbVersionTarget) - targets = append(targets, dbVersionTarget) } @@ -166,11 +197,9 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI break } - target.Key = key - target.Hash = hash - target.Size = size - - postgres.Save(ctx, target) + if _, err := target.Update().SetKey(key).SetHash(hash).SetSize(size).Save(ctx); err != nil { + return nil, err + } } if !separateSuccess { @@ -191,26 +220,25 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI } if modInfo.Type == validation.UEPlugin { - dbVersionTarget := &postgres.VersionTarget{ - VersionID: dbVersion.ID, - TargetName: "Windows", - Key: key, - Hash: *dbVersion.Hash, - Size: *dbVersion.Size, + if _, err := db.From(ctx).VersionTarget.Create(). + SetVersionID(dbVersion.ID). + SetTargetName("Windows"). + SetKey(key). + SetHash(dbVersion.Hash). + SetSize(dbVersion.Size). + Save(ctx); err != nil { + return nil, err } - - postgres.Save(ctx, dbVersionTarget) } - dbVersion.Key = key - postgres.Save(ctx, &dbVersion) - postgres.Save(ctx, &mod) + if _, err := dbVersion.Update().SetKey(key).Save(ctx); err != nil { + return nil, err + } if autoApproved { - mod := postgres.GetModByID(ctx, dbVersion.ModID) - now := time.Now() - mod.LastVersionDate = &now - postgres.Save(ctx, &mod) + if _, err := mod.Update().SetLastVersionDate(time.Now()).Save(ctx); err != nil { + return nil, err + } go integrations.NewVersion(db.ReWrapCtx(ctx), dbVersion) } else { @@ -220,46 +248,52 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI return &generated.CreateVersionResponse{ AutoApproved: autoApproved, - Version: DBVersionToGenerated(dbVersion), + Version: (*conv.VersionImpl)(nil).Convert(dbVersion), }, nil } -func removeMod(ctx context.Context, modInfo *validation.ModInfo, mod *postgres.Mod, dbVersion *postgres.Version) { +func removeMod(ctx context.Context, modInfo *validation.ModInfo, mod *ent.Mod, dbVersion *ent.Version) { for modID, condition := range modInfo.Dependencies { - dependency := postgres.VersionDependency{ - VersionID: dbVersion.ID, - ModID: modID, - Condition: condition, - Optional: false, + if _, err := db.From(ctx).VersionDependency.Delete().Where( + versiondependency.VersionID(dbVersion.ID), + versiondependency.ModID(modID), + versiondependency.Condition(condition), + versiondependency.Optional(false), + ).Exec(schema.SkipSoftDelete(ctx)); err != nil { + slox.Error(ctx, "failed deleting version dependency", slog.Any("err", err)) + return } - - postgres.DeleteForced(ctx, &dependency) } for modID, condition := range modInfo.OptionalDependencies { - dependency := postgres.VersionDependency{ - VersionID: dbVersion.ID, - ModID: modID, - Condition: condition, - Optional: true, + if _, err := db.From(ctx).VersionDependency.Delete().Where( + versiondependency.VersionID(dbVersion.ID), + versiondependency.ModID(modID), + versiondependency.Condition(condition), + versiondependency.Optional(true), + ).Exec(schema.SkipSoftDelete(ctx)); err != nil { + slox.Error(ctx, "failed deleting version dependency", slog.Any("err", err)) + return } - - postgres.DeleteForced(ctx, &dependency) } for _, target := range modInfo.Targets { - dbVersionTarget := postgres.VersionTarget{ - VersionID: dbVersion.ID, - TargetName: target, + if _, err := db.From(ctx).VersionTarget.Delete().Where( + versiontarget.VersionID(dbVersion.ID), + versiontarget.TargetName(target), + ).Exec(schema.SkipSoftDelete(ctx)); err != nil { + slox.Error(ctx, "failed deleting version target", slog.Any("err", err)) + return } - - postgres.DeleteForced(ctx, &dbVersionTarget) } // For UEPlugin mods, a Windows target is created. // However, that happens after the last possible call to this function, therefore we can ignore it - postgres.DeleteForced(ctx, &dbVersion) + if err := db.From(ctx).Version.DeleteOneID(dbVersion.ID).Exec(schema.SkipSoftDelete(ctx)); err != nil { + slox.Error(ctx, "failed deleting version", slog.Any("err", err)) + return + } storage.DeleteMod(ctx, mod.ID, mod.Name, dbVersion.ID) for _, target := range modInfo.Targets { diff --git a/integrations/discord.go b/integrations/discord.go index 4bc435b7..b9bacc84 100644 --- a/integrations/discord.go +++ b/integrations/discord.go @@ -16,10 +16,11 @@ import ( "github.com/russross/blackfriday" "github.com/spf13/viper" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" ) -func NewMod(ctx context.Context, mod *postgres.Mod) { +func NewMod(ctx context.Context, mod *ent.Mod) { if mod == nil { return } @@ -32,7 +33,11 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { return } - user := postgres.GetUserByID(ctx, mod.CreatorID) + user, err := db.From(ctx).User.Get(ctx, mod.CreatorID) + if err != nil { + slox.Error(ctx, "failed retrieving user", slog.Any("err", err)) + return + } if user == nil { return @@ -78,7 +83,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { _, _ = io.ReadAll(res.Body) } -func NewVersion(ctx context.Context, version *postgres.Version) { +func NewVersion(ctx context.Context, version *ent.Version) { slox.Info(ctx, "new version discord webhook", slog.String("stack", string(debug.Stack()))) if version == nil { @@ -89,9 +94,9 @@ func NewVersion(ctx context.Context, version *postgres.Version) { return } - mod := postgres.GetModByID(ctx, version.ModID) - - if mod == nil { + mod, err := db.From(ctx).Mod.Get(ctx, version.ModID) + if err != nil { + slox.Error(ctx, "failed retrieving mod", slog.Any("err", err)) return } diff --git a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go index 7906c56b..48fa4e5c 100644 --- a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go +++ b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go @@ -16,7 +16,6 @@ import ( "github.com/vmihailenco/taskq/v3" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/integrations" "github.com/satisfactorymodding/smr-api/redis/jobs/tasks" "github.com/satisfactorymodding/smr-api/storage" @@ -38,13 +37,10 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { slox.Info(ctx, "starting virus scan of mod", slog.String("mod", task.ModID), slog.String("version", task.VersionID)) - version := postgres.GetVersion(ctx, task.VersionID) - // Version got deleted? - if version == nil { - log.Error().Msgf("mod %s version %s does not exist to be scanned", task.ModID, task.VersionID) - return nil + version, err := db.From(ctx).Version.Get(ctx, task.VersionID) + if err != nil { + return err } - link := storage.GenerateDownloadLink(version.Key) response, _ := http.Get(link) @@ -85,13 +81,14 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { if task.ApproveAfter { slox.Info(ctx, "approving mod after successful virus scan", slog.String("mod", task.ModID), slog.String("version", task.VersionID)) - version.Approved = true - postgres.Save(ctx, &version) - mod := postgres.GetModByID(ctx, task.ModID) - now := time.Now() - mod.LastVersionDate = &now - postgres.Save(ctx, &mod) + if err := version.Update().SetApproved(true).Exec(ctx); err != nil { + return err + } + + if err := db.From(ctx).Mod.UpdateOneID(task.ModID).SetLastVersionDate(time.Now()).Exec(ctx); err != nil { + return err + } go integrations.NewVersion(db.ReWrapCtx(ctx), version) } diff --git a/redis/jobs/consumers/utils.go b/redis/jobs/consumers/utils.go index 6cb77c7b..2267e4ca 100644 --- a/redis/jobs/consumers/utils.go +++ b/redis/jobs/consumers/utils.go @@ -11,7 +11,7 @@ import ( "github.com/Vilsol/slox" "github.com/pkg/errors" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/validation" ) @@ -20,7 +20,11 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin // perform task slox.Info(ctx, "Updating DB for mod version with metadata", slog.String("mod", modID), slog.String("version", versionID), slog.Bool("metadata", metadata)) - version := postgres.GetVersion(ctx, versionID) + version, err := db.From(ctx).Version.Get(ctx, versionID) + if err != nil { + return err + } + link := storage.GenerateDownloadLink(version.Key) response, _ := http.Get(link) @@ -30,7 +34,10 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin return fmt.Errorf("failed to read response body: %w", err) } - mod := postgres.GetModByID(ctx, modID) + mod, err := db.From(ctx).Mod.Get(ctx, modID) + if err != nil { + return err + } if mod == nil { return errors.New("mod not found") @@ -44,25 +51,29 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin } for depModID, condition := range info.Dependencies { - dependency := postgres.VersionDependency{ - VersionID: version.ID, - ModID: depModID, - Condition: condition, - Optional: false, + if err := db.From(ctx).VersionDependency.Create(). + SetVersionID(version.ID). + SetModID(depModID). + SetCondition(condition). + SetOptional(false). + OnConflict(). + DoNothing(). + Exec(ctx); err != nil { + return err } - - postgres.Save(ctx, &dependency) } for depModID, condition := range info.OptionalDependencies { - dependency := postgres.VersionDependency{ - VersionID: version.ID, - ModID: depModID, - Condition: condition, - Optional: true, + if err := db.From(ctx).VersionDependency.Create(). + SetVersionID(version.ID). + SetModID(depModID). + SetCondition(condition). + SetOptional(true). + OnConflict(). + DoNothing(). + Exec(ctx); err != nil { + return err } - - postgres.Save(ctx, &dependency) } if metadata { @@ -70,8 +81,9 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin if err != nil { slox.Error(ctx, "failed serializing", slog.Any("err", err), slog.String("version", versionID)) } else { - metadata := string(jsonData) - version.Metadata = &metadata + if err := version.Update().SetMetadata(string(jsonData)).Exec(ctx); err != nil { + return err + } } } @@ -79,15 +91,13 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin versionMinor := int(info.Semver.Minor()) versionPatch := int(info.Semver.Patch()) - version.Size = &info.Size - version.Hash = &info.Hash - version.VersionMajor = &versionMajor - version.VersionMinor = &versionMinor - version.VersionPatch = &versionPatch - - version.ModReference = &info.ModReference - version.SMLVersion = info.SMLVersion - postgres.Save(ctx, &version) - - return nil + return version.Update(). + SetSize(info.Size). + SetHash(info.Hash). + SetVersionMajor(versionMajor). + SetVersionMinor(versionMinor). + SetVersionPatch(versionPatch). + SetModReference(info.ModReference). + SetSmlVersion(info.SMLVersion). + Exec(ctx) } diff --git a/util/db.go b/util/db.go new file mode 100644 index 00000000..8c24e4d2 --- /dev/null +++ b/util/db.go @@ -0,0 +1,27 @@ +package util + +type Stability string + +const ( + StabilityRelease = "release" + StabilityBeta = "beta" + StabilityAlpha = "alpha" +) + +func (s Stability) Values() []string { + return []string{ + StabilityRelease, + StabilityBeta, + StabilityAlpha, + } +} + +type CompatibilityInfo struct { + Ea Compatibility `gorm:"type:compatibility" json:"EA"` + Exp Compatibility `gorm:"type:compatibility" json:"EXP"` +} + +type Compatibility struct { + State string + Note string +} diff --git a/validation/validation.go b/validation/validation.go index a381784e..1a9113b2 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -26,7 +26,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/proto/parser" "github.com/satisfactorymodding/smr-api/storage" ) @@ -148,8 +148,11 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal engineVersion := "4.26" //nolint - if postgres.DBCtx(nil) != nil { - smlVersions := postgres.GetSMLVersions(ctx, nil) + if db.From(ctx) != nil { + smlVersions, err := db.From(ctx).SmlVersion.Query().All(ctx) + if err != nil { + return nil, err + } // Sort decrementing by version sort.Slice(smlVersions, func(a, b int) bool { From 47b9d26f065e8c679eee799b39b1bb97f63c4be4 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 11 Dec 2023 21:42:07 +0200 Subject: [PATCH 14/19] fix: login --- db/postgres/sml_version.go | 22 ---------------------- db/user.go | 10 +++++----- gql/directive.go | 30 +++++++++++++++--------------- gql/resolver_guides.go | 2 +- gql/resolver_mods.go | 23 ++++++++++++----------- gql/resolver_users.go | 8 ++++---- tests/announcements_test.go | 2 +- tests/guides_test.go | 2 +- tests/mod_test.go | 2 +- tests/sml_versions_test.go | 2 +- 10 files changed, 41 insertions(+), 62 deletions(-) diff --git a/db/postgres/sml_version.go b/db/postgres/sml_version.go index 398f56c6..2d7d68ad 100644 --- a/db/postgres/sml_version.go +++ b/db/postgres/sml_version.go @@ -2,30 +2,8 @@ package postgres import ( "context" - "strings" - - "github.com/satisfactorymodding/smr-api/models" ) -func GetSMLVersions(ctx context.Context, filter *models.SMLVersionFilter) []SMLVersion { - var smlVersions []SMLVersion - query := DBCtx(ctx) - - if filter != nil { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset). - Order(string(*filter.OrderBy) + " " + string(*filter.Order)) - - if filter.Search != nil && *filter.Search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(*filter.Search, " ", " & ")) - } - } - - query.Preload("Targets").Find(&smlVersions) - - return smlVersions -} - func GetSMLLatestVersions(ctx context.Context) *[]SMLVersion { var smlVersions []SMLVersion diff --git a/db/user.go b/db/user.go index be84a9a8..20025638 100644 --- a/db/user.go +++ b/db/user.go @@ -32,24 +32,24 @@ func UserHas(ctx context.Context, role *auth.Role, usr *ent.User) bool { return exist } -func UserFromGQLContext(ctx context.Context) (*ent.User, error) { +func UserFromGQLContext(ctx context.Context) (*ent.User, bool, error) { header := ctx.Value(util.ContextHeader{}).(http.Header) authorization := header.Get("Authorization") if authorization == "" { - return nil, errors.New("user not logged in") + return nil, true, errors.New("user not logged in") } user, err := From(ctx).UserSession.Query().Where(usersession.Token(authorization)).QueryUser().First(ctx) if err != nil { if ent.IsNotFound(err) { - return nil, errors.New("user not logged in") + return nil, true, errors.New("user not logged in") } - return nil, err + return nil, false, err } - return user, nil + return user, false, nil } func UserCanUploadModVersions(ctx context.Context, user *ent.User, modID string) bool { diff --git a/gql/directive.go b/gql/directive.go index 23f3063e..74f9bc81 100644 --- a/gql/directive.go +++ b/gql/directive.go @@ -36,7 +36,7 @@ type Directive struct { } func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -53,7 +53,7 @@ func canEditMod(ctx context.Context, _ interface{}, next graphql.Resolver, field } func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Resolver, field *string) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func canEditModCompatibility(ctx context.Context, _ interface{}, next graphql.Re } func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -91,7 +91,7 @@ func canEditVersion(ctx context.Context, _ interface{}, next graphql.Resolver, f } func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, field string, object bool) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -115,7 +115,7 @@ func canEditUser(ctx context.Context, obj interface{}, next graphql.Resolver, fi } func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, field string) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -137,7 +137,7 @@ func canEditGuide(ctx context.Context, _ interface{}, next graphql.Resolver, fie } func isLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -150,8 +150,8 @@ func isLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (inte } func isNotLoggedIn(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) - if err != nil { + user, nonFatal, err := db.UserFromGQLContext(ctx) + if err != nil && !nonFatal { return nil, err } @@ -167,7 +167,7 @@ func getArgument(ctx context.Context, key string) interface{} { } func canApproveMods(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -180,7 +180,7 @@ func canApproveMods(ctx context.Context, _ interface{}, next graphql.Resolver) ( } func canApproveVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -193,7 +193,7 @@ func canApproveVersions(ctx context.Context, _ interface{}, next graphql.Resolve } func canEditUsers(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -206,7 +206,7 @@ func canEditUsers(ctx context.Context, _ interface{}, next graphql.Resolver) (in } func canEditSMLVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -219,7 +219,7 @@ func canEditSMLVersions(ctx context.Context, _ interface{}, next graphql.Resolve } func canEditBootstrapVersions(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -232,7 +232,7 @@ func canEditBootstrapVersions(ctx context.Context, _ interface{}, next graphql.R } func canEditAnnouncements(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -245,7 +245,7 @@ func canEditAnnouncements(ctx context.Context, _ interface{}, next graphql.Resol } func canManageTags(ctx context.Context, _ interface{}, next graphql.Resolver) (interface{}, error) { - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } diff --git a/gql/resolver_guides.go b/gql/resolver_guides.go index cce0952c..68e5e5aa 100644 --- a/gql/resolver_guides.go +++ b/gql/resolver_guides.go @@ -34,7 +34,7 @@ func (r *mutationResolver) CreateGuide(ctx context.Context, g generated.NewGuide return nil, fmt.Errorf("validation failed: %w", err) } - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 8282b83b..1837dbcd 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -75,7 +75,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, newMod generated.NewMo SetINNF(newMod.FullDescription, dbMod.SetFullDescription) SetINNF(newMod.Hidden, dbMod.SetHidden) - user, err := db.UserFromGQLContext(ctx) + user, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -347,7 +347,7 @@ func (r *queryResolver) GetMod(ctx context.Context, modID string) (*generated.Mo wrapper, ctx := WrapQueryTrace(ctx, "getMod") defer wrapper.end() - dbMod, err := db.From(ctx).Mod.Get(ctx, modID) + dbMod, err := db.From(ctx).Mod.Query().Where(mod.ID(modID)).WithTags().First(ctx) if err != nil { return nil, err } @@ -367,7 +367,7 @@ func (r *queryResolver) GetModByReference(ctx context.Context, modReference stri wrapper, ctx := WrapQueryTrace(ctx, "getModByReference") defer wrapper.end() - dbMod, err := db.From(ctx).Mod.Query().Where(mod.ModReference(modReference)).First(ctx) + dbMod, err := db.From(ctx).Mod.Query().Where(mod.ModReference(modReference)).WithTags().First(ctx) if err != nil { return nil, err } @@ -448,7 +448,7 @@ func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, return 0, err } - query := db.From(ctx).Debug().Mod.Query() + query := db.From(ctx).Mod.Query() query = convertModFilter(query, modFilter, false, unapproved) result, err := query.Count(ctx) @@ -477,7 +477,7 @@ func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([ modFilter.AddField(field.Name) } - query := db.From(ctx).Debug().Mod.Query() + query := db.From(ctx).Mod.Query() query = convertModFilter(query, modFilter, false, unapproved) result, err := query.All(ctx) @@ -500,7 +500,7 @@ func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) ( return 0, err } - query := db.From(ctx).Debug().Mod.Query() + query := db.From(ctx).Mod.Query() query = convertModFilter(query, modFilter, false, unapproved) result, err := query.Count(ctx) @@ -677,7 +677,7 @@ func (r *queryResolver) GetModByIDOrReference(ctx context.Context, modIDOrRefere wrapper, ctx := WrapQueryTrace(ctx, "getModByIdOrReference") defer wrapper.end() - m, err := db.From(ctx).Mod.Query().Where(mod.Or( + m, err := db.From(ctx).Mod.Query().WithTags().Where(mod.Or( mod.ID(modIDOrReference), mod.ModReference(modIDOrReference), )).First(ctx) @@ -757,6 +757,8 @@ func (r *queryResolver) GetModAssetList(ctx context.Context, modReference string } func convertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, unapproved bool) *ent.ModQuery { + query = query.WithTags() + if len(filter.Ids) > 0 { query = query.Where(mod.IDIn(filter.Ids...)) } else if len(filter.References) > 0 { @@ -768,10 +770,9 @@ func convertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, if *filter.OrderBy != generated.ModFieldsSearch { if string(*filter.OrderBy) == "last_version_date" { - query = query.Order(sql.OrderByField( - "case when last_version_date is null then 1 else 0 end, last_version_date", - db.OrderToOrder(filter.Order.String()), - ).ToFunc()) + query = query.Modify(func(s *sql.Selector) { + s.OrderExpr(sql.ExprP("case when last_version_date is null then 1 else 0 end, last_version_date")) + }).Clone() } else { query = query.Order(sql.OrderByField( filter.OrderBy.String(), diff --git a/gql/resolver_users.go b/gql/resolver_users.go index ef213f7c..dc60d651 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -167,7 +167,7 @@ func (r *queryResolver) GetMe(ctx context.Context) (*generated.User, error) { wrapper, ctx := WrapQueryTrace(ctx, "getMe") defer wrapper.end() - result, err := db.UserFromGQLContext(ctx) + result, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -233,7 +233,7 @@ func (r *userResolver) Groups(ctx context.Context, _ *generated.User) ([]*genera wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - u, err := db.UserFromGQLContext(ctx) + u, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -259,7 +259,7 @@ func (r *userResolver) Roles(ctx context.Context, _ *generated.User) (*generated wrapper, ctx := WrapQueryTrace(ctx, "User.guides") defer wrapper.end() - u, err := db.UserFromGQLContext(ctx) + u, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } @@ -357,7 +357,7 @@ func (r *mutationResolver) DiscourseSso(ctx context.Context, sso string, sig str return nil, fmt.Errorf("failed to decode sso: %w", err) } - u, err := db.UserFromGQLContext(ctx) + u, _, err := db.UserFromGQLContext(ctx) if err != nil { return nil, err } diff --git a/tests/announcements_test.go b/tests/announcements_test.go index cbe31a0d..c880b350 100644 --- a/tests/announcements_test.go +++ b/tests/announcements_test.go @@ -29,7 +29,7 @@ func TestAnnouncements(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - t.Run(strconv.Itoa(i), func(t *testing.T) { + t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var announcementID string t.Run("Create", func(t *testing.T) { diff --git a/tests/guides_test.go b/tests/guides_test.go index 6b1da5f3..6544423c 100644 --- a/tests/guides_test.go +++ b/tests/guides_test.go @@ -32,7 +32,7 @@ func TestGuides(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - t.Run(strconv.Itoa(i), func(t *testing.T) { + t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var guideID string t.Run("Create", func(t *testing.T) { diff --git a/tests/mod_test.go b/tests/mod_test.go index d5f44dc5..1b0733e9 100644 --- a/tests/mod_test.go +++ b/tests/mod_test.go @@ -32,7 +32,7 @@ func TestMods(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - t.Run(strconv.Itoa(i), func(t *testing.T) { + t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var objID string modReference := "hello" + strconv.Itoa(i) diff --git a/tests/sml_versions_test.go b/tests/sml_versions_test.go index 0bb5e80c..e981a12e 100644 --- a/tests/sml_versions_test.go +++ b/tests/sml_versions_test.go @@ -35,7 +35,7 @@ func TestSMLVersions(t *testing.T) { // Run Twice to detect any cache issues for i := 0; i < 2; i++ { - t.Run(strconv.Itoa(i), func(t *testing.T) { + t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var objID string t.Run("Create", func(t *testing.T) { From 68881629aaeecce2645e4d4477af28c58b6906dc Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Tue, 12 Dec 2023 07:59:02 +0200 Subject: [PATCH 15/19] refactor: gorm gone --- .golangci.yml | 1 - api/api.go | 2 - conversion/ent_to_graphql.go | 2 +- db/mod.go | 75 ++++++ db/oauth.go | 103 ++++++++ db/postgres/mod.go | 120 --------- db/postgres/otel/callbacks.go | 77 ------ db/postgres/otel/config.go | 28 -- db/postgres/otel/plugin.go | 98 ------- db/postgres/postgres.go | 144 ---------- db/postgres/postgres_types.go | 165 ------------ db/postgres/sml_version.go | 15 -- db/postgres/user.go | 139 ---------- db/postgres/utils.go | 21 -- db/postgres/version.go | 148 ----------- generated/conv/version.go | 4 + go.mod | 8 +- go.sum | 12 - gql/resolver_announcements.go | 2 +- gql/resolver_mods.go | 73 +----- gql/resolver_oauth.go | 101 +------ gql/resolver_versions.go | 2 +- migrations/code.go | 22 +- .../code/20200426221900_test_new_migration.go | 8 +- migrations/code/20200501224200_parse_paks.go | 8 +- .../20200524203800_after_reference_fix.go | 8 +- .../20200621195500_after_id_length_fix.go | 8 +- ...20200622003600_after_validation_disable.go | 8 +- .../code/20200629093800_copy_to_new_bucket.go | 7 +- .../20200707150700_after_sml_version_fix.go | 12 +- .../code/20200829171600_after_db_dirty.go | 8 +- .../20200829225100_after_broken_datajson.go | 12 +- .../code/20200830011200_after_gorm_hotfix.go | 8 +- .../code/20201014162200_after_bp_fix.go | 8 +- .../code/20201016202600_after_body_enable.go | 8 +- .../20201019203800_after_remove_filter.go | 8 +- migrations/migrations.go | 21 +- migrations/utils/utils.go | 46 ++-- nodes/mod.go | 247 ++++++++++++++---- nodes/mod_types.go | 178 ------------- nodes/oauth.go | 28 +- nodes/oauth_types.go | 10 - nodes/shared.go | 4 +- nodes/sml.go | 28 +- nodes/user.go | 96 ++++--- nodes/user_types.go | 33 --- nodes/version.go | 36 ++- tests/announcements_test.go | 2 - tests/guides_test.go | 2 - tests/mod_test.go | 2 - tests/sml_versions_test.go | 2 - tests/utils.go | 38 ++- tests/version_test.go | 2 - validation/validation.go | 2 + 54 files changed, 679 insertions(+), 1571 deletions(-) create mode 100644 db/mod.go create mode 100644 db/oauth.go delete mode 100644 db/postgres/mod.go delete mode 100644 db/postgres/otel/callbacks.go delete mode 100644 db/postgres/otel/config.go delete mode 100644 db/postgres/otel/plugin.go delete mode 100644 db/postgres/postgres.go delete mode 100644 db/postgres/postgres_types.go delete mode 100644 db/postgres/sml_version.go delete mode 100644 db/postgres/user.go delete mode 100644 db/postgres/utils.go delete mode 100644 db/postgres/version.go delete mode 100644 nodes/mod_types.go diff --git a/.golangci.yml b/.golangci.yml index d775fb76..ba826d15 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -56,7 +56,6 @@ linters: - contextcheck - durationcheck - errorlint - - goconst - goimports - revive - misspell diff --git a/api/api.go b/api/api.go index db941b99..6edcb19d 100644 --- a/api/api.go +++ b/api/api.go @@ -39,7 +39,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/dataloader" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/gql" "github.com/satisfactorymodding/smr-api/migrations" @@ -79,7 +78,6 @@ func Initialize(baseCtx context.Context) context.Context { } redis.InitializeRedis(ctx) - postgres.InitializePostgres(ctx) ctx, err := db.WithDB(ctx) if err != nil { diff --git a/conversion/ent_to_graphql.go b/conversion/ent_to_graphql.go index 1ea5e3ae..8f954f92 100644 --- a/conversion/ent_to_graphql.go +++ b/conversion/ent_to_graphql.go @@ -83,7 +83,7 @@ type Mod interface { // goverter:extend TimeToString UIntToInt Int64ToInt type Version interface { // goverter:map Edges.Targets Targets - // goverter:ignore Link Mod Dependencies Size Hash + // goverter:ignore Link Mod Dependencies Convert(source *ent.Version) *generated.Version ConvertSlice(source []*ent.Version) []*generated.Version diff --git a/db/mod.go b/db/mod.go new file mode 100644 index 00000000..61b6f134 --- /dev/null +++ b/db/mod.go @@ -0,0 +1,75 @@ +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/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/modtag" + "github.com/satisfactorymodding/smr-api/models" +) + +func ConvertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, unapproved bool) *ent.ModQuery { + query = query.WithTags() + + if len(filter.Ids) > 0 { + query = query.Where(mod.IDIn(filter.Ids...)) + } else if len(filter.References) > 0 { + query = query.Where(mod.ModReferenceIn(filter.References...)) + } else if filter != nil { + query = query. + Limit(*filter.Limit). + Offset(*filter.Offset) + + if *filter.OrderBy != generated.ModFieldsSearch { + if string(*filter.OrderBy) == "last_version_date" { + query = query.Modify(func(s *sql.Selector) { + s.OrderExpr(sql.ExprP("case when last_version_date is null then 1 else 0 end, last_version_date")) + }).Clone() + } else { + 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.SelectExpr(sql.ExprP("id, (similarity(name, ?) * 2 + similarity(short_description, ?) + similarity(full_description, ?) * 0.5) as s", cleanSearch, cleanSearch, cleanSearch)) + join.From(sql.Table(mod.Table)).As("t1") + s.Join(join).On(s.C(mod.FieldID), join.C("id")) + }) + + query = query.Where(func(s *sql.Selector) { + s.Where(sql.ExprP(`"t1"."s" > 0.2`)) + }) + + if !count && *filter.OrderBy == generated.ModFieldsSearch { + query = query.Order(func(s *sql.Selector) { + s.OrderExpr(sql.ExprP(`"t1"."s" DESC`)) + }) + } + } + + if filter.Hidden == nil || !(*filter.Hidden) { + query = query.Where(mod.Hidden(false)) + } + + if filter.TagIDs != nil && len(filter.TagIDs) > 0 { + query = query.Where(func(s *sql.Selector) { + t := sql.Table(modtag.Table) + s.Join(t).OnP(sql.ExprP("mod_tags.tag_id in ? AND mod_tags.mod_id = mods.id", filter.TagIDs)) + }) + } + } + + query = query.Where(mod.Approved(!unapproved), mod.Denied(false)) + + return query +} diff --git a/db/oauth.go b/db/oauth.go new file mode 100644 index 00000000..d34976ce --- /dev/null +++ b/db/oauth.go @@ -0,0 +1,103 @@ +package db + +import ( + "bytes" + "context" + + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/oauth" + "github.com/satisfactorymodding/smr-api/storage" + "github.com/satisfactorymodding/smr-api/util" +) + +func CompleteOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string) (*string, error) { + avatarURL := u.Avatar + u.Avatar = "" + + find := From(ctx).User.Query().Where(user.Email(u.Email)) + + if u.Site == oauth.SiteGithub { + find = find.Where(user.GithubID(u.ID)) + } else if u.Site == oauth.SiteGoogle { + find = find.Where(user.GoogleID(u.ID)) + } else if u.Site == oauth.SiteFacebook { + find = find.Where(user.FacebookID(u.ID)) + } + + found, err := find.First(ctx) + if err != nil && !ent.IsNotFound(err) { + return nil, err + } + + newUser := false + if ent.IsNotFound(err) { + var err error + create := From(ctx).User. + Create(). + SetEmail(u.Email). + SetAvatar(u.Avatar). + SetJoinedFrom(string(u.Site)). + SetUsername(u.Username) + + if u.Site == oauth.SiteGithub { + create = create.SetGithubID(u.ID) + } else if u.Site == oauth.SiteGoogle { + create = create.SetGoogleID(u.ID) + } else if u.Site == oauth.SiteFacebook { + create = create.SetFacebookID(u.ID) + } + + found, err = create.Save(ctx) + if err != nil { + return nil, err + } + + newUser = true + } + + if !newUser { + var update *ent.UserUpdateOne + if u.Site == oauth.SiteGithub && found.GithubID == "" { + update = found.Update().SetGithubID(u.ID) + } else if u.Site == oauth.SiteGoogle && found.GoogleID == "" { + update = found.Update().SetGoogleID(u.ID) + } else if u.Site == oauth.SiteFacebook && found.FacebookID == "" { + update = found.Update().SetFacebookID(u.ID) + } + + if update != nil { + if err := update.Exec(ctx); err != nil { + return nil, err + } + } + } + + // TODO Archive old deleted sessions to cold storage + + session, err := From(ctx).UserSession. + Create(). + SetUserID(found.ID). + SetToken(util.GenerateUserToken()). + SetUserAgent(userAgent). + Save(ctx) + if err != nil { + return nil, err + } + + if avatarURL != "" && newUser { + avatarData, err := util.LinkToWebp(ctx, avatarURL) + if err != nil { + return nil, err + } + + success, avatarKey := storage.UploadUserAvatar(ctx, found.ID, bytes.NewReader(avatarData)) + if success { + if err := found.Update().SetAvatar(storage.GenerateDownloadLink(avatarKey)).Exec(ctx); err != nil { + return nil, err + } + } + } + + return &session.Token, nil +} diff --git a/db/postgres/mod.go b/db/postgres/mod.go deleted file mode 100644 index c6c33a07..00000000 --- a/db/postgres/mod.go +++ /dev/null @@ -1,120 +0,0 @@ -package postgres - -import ( - "context" - "fmt" - "strings" - - "github.com/patrickmn/go-cache" -) - -func GetModByID(ctx context.Context, modID string) *Mod { - cacheKey := "GetModById_" + modID - if mod, ok := dbCache.Get(cacheKey); ok { - return mod.(*Mod) - } - - return GetModByIDNoCache(ctx, modID) -} - -func GetModByIDNoCache(ctx context.Context, modID string) *Mod { - var mod Mod - DBCtx(ctx).Preload("Tags").Preload("Versions.Targets").Find(&mod, "id = ?", modID) - - if mod.ID == "" { - return nil - } - - dbCache.Set("GetModById_"+modID, &mod, cache.DefaultExpiration) - - return &mod -} - -func GetModsByID(ctx context.Context, modIds []string) []Mod { - cacheKey := "GetModsById_" + strings.Join(modIds, ":") - if mods, ok := dbCache.Get(cacheKey); ok { - return mods.([]Mod) - } - - var mods []Mod - DBCtx(ctx).Preload("Tags").Find(&mods, "id in (?)", modIds) - - if len(modIds) != len(mods) { - return nil - } - - dbCache.Set(cacheKey, mods, cache.DefaultExpiration) - - return mods -} - -func GetModCount(ctx context.Context, search string, unapproved bool) int64 { - cacheLey := "GetModCount_" + search + "_" + fmt.Sprint(unapproved) - if count, ok := dbCache.Get(cacheLey); ok { - return count.(int64) - } - - var modCount int64 - query := DBCtx(ctx).Model(Mod{}).Where("approved = ? AND denied = ?", !unapproved, false) - - if search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(search, " ", " & ")) - } - - query.Count(&modCount) - - dbCache.Set(cacheLey, modCount, cache.DefaultExpiration) - - return modCount -} - -func IncrementModViews(ctx context.Context, mod *Mod) { - // TODO unignore - // DBCtx(ctx).Model(mod).Update("views", mod.Views+1) -} - -func GetMods(ctx context.Context, limit int, offset int, orderBy string, order string, search string, unapproved bool) []Mod { - cacheKey := "GetMods_" + fmt.Sprint(limit) + "_" + fmt.Sprint(offset) + "_" + orderBy + "_" + order + "_" + search + "_" + fmt.Sprint(unapproved) - if mods, ok := dbCache.Get(cacheKey); ok { - return mods.([]Mod) - } - - var mods []Mod - query := DBCtx(ctx).Limit(limit).Offset(offset) - - if orderBy == "last_version_date" { - query = query.Order("case when last_version_date is null then 1 else 0 end, last_version_date") - } else { - query = query.Order(orderBy + " " + order) - } - - query = query.Where("approved = ? AND denied = ?", !unapproved, false) - - if search != "" { - query = query.Where("to_tsvector(name) @@ to_tsquery(?)", strings.ReplaceAll(search, " ", " & ")) - } - - query.Find(&mods) - - dbCache.Set(cacheKey, mods, cache.DefaultExpiration) - - return mods -} - -func GetModByIDOrReference(ctx context.Context, modIDOrReference string) *Mod { - cacheKey := "GetModByIDOrReference_" + modIDOrReference - if mod, ok := dbCache.Get(cacheKey); ok { - return mod.(*Mod) - } - - var mod Mod - DBCtx(ctx).Preload("Tags").Preload("Versions.Targets").Find(&mod, "mod_reference = ? OR id = ?", modIDOrReference, modIDOrReference) - - if mod.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &mod, cache.DefaultExpiration) - - return &mod -} diff --git a/db/postgres/otel/callbacks.go b/db/postgres/otel/callbacks.go deleted file mode 100644 index cc691f7d..00000000 --- a/db/postgres/otel/callbacks.go +++ /dev/null @@ -1,77 +0,0 @@ -package otel - -import ( - "strings" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - semconv "go.opentelemetry.io/otel/semconv/v1.7.0" - oteltrace "go.opentelemetry.io/otel/trace" - "gorm.io/gorm" -) - -const ( - spanName = "gorm.query" - - dbTableKey = attribute.Key("db.table") - dbCountKey = attribute.Key("db.count") - dbOperationKey = semconv.DBOperationKey - dbStatementKey = semconv.DBStatementKey -) - -func dbTable(name string) attribute.KeyValue { - return dbTableKey.String(name) -} - -func dbStatement(stmt string) attribute.KeyValue { - return dbStatementKey.String(stmt) -} - -func dbCount(n int64) attribute.KeyValue { - return dbCountKey.Int64(n) -} - -func dbOperation(op string) attribute.KeyValue { - return dbOperationKey.String(op) -} - -func (op *Plugin) before(tx *gorm.DB) { - tx.Statement.Context, _ = op.tracer. - Start(tx.Statement.Context, spanName, oteltrace.WithSpanKind(oteltrace.SpanKindClient)) -} - -func extractQuery(tx *gorm.DB) string { - return tx.Dialector.Explain(tx.Statement.SQL.String(), tx.Statement.Vars...) -} - -func (op *Plugin) after(operation string) gormHookFunc { - return func(tx *gorm.DB) { - span := oteltrace.SpanFromContext(tx.Statement.Context) - if !span.IsRecording() { - // skip the reporting if not recording - return - } - defer span.End() - - // Error - if tx.Error != nil { - span.SetStatus(codes.Error, tx.Error.Error()) - } - - // extract the db operation - query := extractQuery(tx) - if operation == "" { - operation = strings.ToUpper(strings.Split(query, " ")[0]) - } - - if tx.Statement.Table != "" { - span.SetAttributes(dbTable(tx.Statement.Table)) - } - - span.SetAttributes( - dbStatement(query), - dbOperation(operation), - dbCount(tx.Statement.RowsAffected), - ) - } -} diff --git a/db/postgres/otel/config.go b/db/postgres/otel/config.go deleted file mode 100644 index 996e6806..00000000 --- a/db/postgres/otel/config.go +++ /dev/null @@ -1,28 +0,0 @@ -package otel - -import ( - oteltrace "go.opentelemetry.io/otel/trace" -) - -type config struct { - tracerProvider oteltrace.TracerProvider - serviceName string -} - -// Option is used to configure the client. -type Option func(*config) - -// WithTracerProvider specifies a tracer provider to use for creating a tracer. -// If none is specified, the global provider is used. -func WithTracerProvider(provider oteltrace.TracerProvider) Option { - return func(cfg *config) { - cfg.tracerProvider = provider - } -} - -// WithServiceName sets the service name. -func WithServiceName(serviceName string) Option { - return func(cfg *config) { - cfg.serviceName = serviceName - } -} diff --git a/db/postgres/otel/plugin.go b/db/postgres/otel/plugin.go deleted file mode 100644 index f4a0dd5b..00000000 --- a/db/postgres/otel/plugin.go +++ /dev/null @@ -1,98 +0,0 @@ -package otel - -import ( - "fmt" - - "go.opentelemetry.io/contrib" - "go.opentelemetry.io/otel" - oteltrace "go.opentelemetry.io/otel/trace" - "gorm.io/gorm" -) - -const ( - defaultTracerName = "go.opentelemetry.io/contrib/instrumentation/github.com/go-gorm/gorm/otelgorm" - defaultServiceName = "gorm" - - callBackBeforeName = "otel:before" - callBackAfterName = "otel:after" -) - -type gormHookFunc func(tx *gorm.DB) - -type Plugin struct { - cfg *config - tracer oteltrace.Tracer -} - -func (op *Plugin) Name() string { - return "OpenTelemetryPlugin" -} - -// NewPlugin initialize a new gorm.DB plugin that traces queries -// You may pass optional Options to the function -func NewPlugin(opts ...Option) *Plugin { - cfg := &config{} - for _, o := range opts { - o(cfg) - } - - if cfg.serviceName == "" { - cfg.serviceName = defaultServiceName - } - - if cfg.tracerProvider == nil { - cfg.tracerProvider = otel.GetTracerProvider() - } - - return &Plugin{ - cfg: cfg, - tracer: cfg.tracerProvider.Tracer( - defaultTracerName, - oteltrace.WithInstrumentationVersion(contrib.Version()), - ), - } -} - -type registerCallback interface { - Register(name string, fn func(*gorm.DB)) error -} - -func beforeName(name string) string { - return callBackBeforeName + "_" + name -} - -func afterName(name string) string { - return callBackAfterName + "_" + name -} - -func (op *Plugin) Initialize(db *gorm.DB) error { - registerHooks := []struct { - callback registerCallback - hook gormHookFunc - name string - }{ - // before hooks - {db.Callback().Create().Before("gorm:before_create"), op.before, beforeName("create")}, - {db.Callback().Query().Before("gorm:query"), op.before, beforeName("query")}, - {db.Callback().Delete().Before("gorm:before_delete"), op.before, beforeName("delete")}, - {db.Callback().Update().Before("gorm:before_update"), op.before, beforeName("update")}, - {db.Callback().Row().Before("gorm:row"), op.before, beforeName("row")}, - {db.Callback().Raw().Before("gorm:raw"), op.before, beforeName("raw")}, - - // after hooks - {db.Callback().Create().After("gorm:after_create"), op.after("INSERT"), afterName("create")}, - {db.Callback().Query().After("gorm:after_query"), op.after("SELECT"), afterName("select")}, - {db.Callback().Delete().After("gorm:after_delete"), op.after("DELETE"), afterName("delete")}, - {db.Callback().Update().After("gorm:after_update"), op.after("UPDATE"), afterName("update")}, - {db.Callback().Row().After("gorm:row"), op.after(""), afterName("row")}, - {db.Callback().Raw().After("gorm:raw"), op.after(""), afterName("raw")}, - } - - for _, h := range registerHooks { - if err := h.callback.Register(h.name, h.hook); err != nil { - return fmt.Errorf("register %s hook: %w", h.name, err) - } - } - - return nil -} diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go deleted file mode 100644 index 9afd83dc..00000000 --- a/db/postgres/postgres.go +++ /dev/null @@ -1,144 +0,0 @@ -package postgres - -import ( - "context" - "fmt" - "log/slog" - "time" - - "github.com/Vilsol/slox" - "github.com/patrickmn/go-cache" - "github.com/spf13/viper" - "gorm.io/driver/postgres" - "gorm.io/gorm" - "gorm.io/gorm/logger" - "gorm.io/gorm/utils" - - "github.com/satisfactorymodding/smr-api/db/postgres/otel" -) - -var ( - db *gorm.DB - dbCache *cache.Cache -) - -type GormLogger struct { - SlowThreshold time.Duration - Debug bool -} - -func (l *GormLogger) LogMode(mode logger.LogLevel) logger.Interface { - return &GormLogger{ - SlowThreshold: l.SlowThreshold, - Debug: mode >= 4, - } -} - -func (*GormLogger) Info(ctx context.Context, msg string, data ...interface{}) { - slox.Info(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) -} - -func (*GormLogger) Warn(ctx context.Context, msg string, data ...interface{}) { - slox.Warn(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) -} - -func (*GormLogger) Error(ctx context.Context, msg string, data ...interface{}) { - slox.Error(ctx, fmt.Sprintf(msg, data...), slog.String("file", utils.FileWithLineNum())) -} - -func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { - since := time.Since(begin) - elapsed := float64(since.Nanoseconds()) / 1e6 - - sql, rows := fc() - - level := slog.LevelInfo - attrs := make([]slog.Attr, 0) - toLog := false - switch { - case err != nil: - level = slog.LevelError - attrs = append(attrs, slog.Any("err", err)) - toLog = true - case since > l.SlowThreshold && l.SlowThreshold != 0: - level = slog.LevelWarn - toLog = true - case l.Debug: - level = slog.LevelInfo - toLog = true - } - - if toLog { - if len(sql) > 256 { - sql = sql[:256] - } - - attrs = append(attrs, slog.Float64("elapsed", elapsed)) - attrs = append(attrs, slog.Int64("rows", rows)) - slog.LogAttrs(ctx, level, sql, attrs...) - } -} - -var debugEnabled = false - -func InitializePostgres(ctx context.Context) { - connection := postgres.Open(fmt.Sprintf( - "sslmode=disable host=%s port=%d user=%s dbname=%s password=%s", - viper.GetString("database.postgres.host"), - viper.GetInt("database.postgres.port"), - viper.GetString("database.postgres.user"), - viper.GetString("database.postgres.db"), - viper.GetString("database.postgres.pass"), - )) - - dbInit, err := gorm.Open(connection, &gorm.Config{ - Logger: &GormLogger{ - SlowThreshold: time.Second, - }, - }) - if err != nil { - panic(err) - } - - err = dbInit.Use(otel.NewPlugin()) - if err != nil { - panic(err) - } - - db = dbInit - - if debugEnabled { - db = db.Debug() - } - - dbCache = cache.New(time.Second*5, time.Second*10) - - // TODO Create search indexes - - slox.Info(ctx, "Postgres initialized") -} - -func Save(ctx context.Context, object interface{}) { - DBCtx(ctx).Save(object) -} - -func DBCtx(ctx context.Context) *gorm.DB { - if ctx != nil { - dbCtx := DBFromContext(ctx) - if dbCtx != nil { - return dbCtx - } - - return db.WithContext(ctx) - } - - return db -} - -func EnableDebug() { - if db != nil { - db = db.Debug() - } - - debugEnabled = true -} diff --git a/db/postgres/postgres_types.go b/db/postgres/postgres_types.go deleted file mode 100644 index 095462fd..00000000 --- a/db/postgres/postgres_types.go +++ /dev/null @@ -1,165 +0,0 @@ -package postgres - -import ( - "time" - - "gorm.io/gorm" -) - -type Tabler interface { - TableName() string -} - -type SMRDates struct { - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt gorm.DeletedAt `gorm:"index"` -} - -type SMRModel struct { - ID string `gorm:"primary_key;type:varchar(14)"` - SMRDates -} - -type User struct { - GithubID *string - GoogleID *string - FacebookID *string - SMRModel - Email string `gorm:"type:varchar(256);unique_index"` - Username string `gorm:"type:varchar(32)"` - Avatar string - JoinedFrom string - Mods []Mod `gorm:"many2many:user_mods;"` - Banned bool `gorm:"default:false;not null"` -} - -type UserSession struct { - SMRModel - UserID string - Token string `gorm:"type:varchar(256);unique_index"` - UserAgent string - User User -} - -type Mod struct { - LastVersionDate *time.Time - Compatibility *CompatibilityInfo `gorm:"serializer:json"` - SMRModel - CreatorID string - Logo string - SourceURL string - FullDescription string - ShortDescription string `gorm:"type:varchar(128)"` - Name string `gorm:"type:varchar(32)"` - ModReference string - Versions []Version - Tags []Tag `gorm:"many2many:mod_tags"` - Users []User `gorm:"many2many:user_mods;"` - Downloads uint - Popularity uint - Hotness uint - Views uint - Hidden bool - Denied bool `gorm:"default:false;not null"` - Approved bool `gorm:"default:false;not null"` -} - -type UserMod struct { - UserID string `gorm:"primary_key"` - ModID string `gorm:"primary_key"` - Role string -} - -// If updated, update dataloader -type Version struct { - Metadata *string - Hash *string - Size *int64 - VersionPatch *int - VersionMinor *int - VersionMajor *int - ModReference *string - SMRModel - Changelog string - Stability string `gorm:"default:'alpha'" sql:"type:version_stability"` - Key string - SMLVersion string `gorm:"type:varchar(16)"` - Version string `gorm:"type:varchar(16)"` - ModID string - Targets []VersionTarget `gorm:"foreignKey:VersionID"` - Hotness uint - Downloads uint - Denied bool `gorm:"default:false;not null"` - Approved bool `gorm:"default:false;not null"` -} - -type TinyVersion struct { - Hash *string - Size *int64 - SMRModel - SMLVersion string `gorm:"type:varchar(16)"` - Version string `gorm:"type:varchar(16)"` - Targets []VersionTarget `gorm:"foreignKey:VersionID;preload:true"` - Dependencies []VersionDependency `gorm:"foreignKey:VersionID"` -} - -func (TinyVersion) TableName() string { - return "versions" -} - -type SMLVersion struct { - Date time.Time - BootstrapVersion *string - SMRModel - Version string `gorm:"type:varchar(32);unique_index"` - Stability string `sql:"type:version_stability"` - Link string - Changelog string - EngineVersion string - Targets []SMLVersionTarget `gorm:"foreignKey:VersionID"` - SatisfactoryVersion int -} - -type VersionDependency struct { - SMRDates - - VersionID string `gorm:"primary_key;type:varchar(14)"` - ModID string `gorm:"primary_key;type:varchar(14)"` - - Condition string `gorm:"type:varchar(64)"` - Optional bool -} - -type Tag struct { - SMRModel - - Name string `gorm:"type:varchar(24)"` - Description string `gorm:"type:varchar(512)"` - - Mods []Mod `gorm:"many2many:mod_tags"` -} - -type CompatibilityInfo struct { - Ea Compatibility `gorm:"type:compatibility" json:"EA"` - Exp Compatibility `gorm:"type:compatibility" json:"EXP"` -} - -type Compatibility struct { - State string - Note string -} - -type VersionTarget struct { - VersionID string `gorm:"primary_key;type:varchar(14)"` - TargetName string `gorm:"primary_key;type:varchar(16)"` - Key string - Hash string - Size int64 -} - -type SMLVersionTarget struct { - VersionID string `gorm:"primary_key;type:varchar(14)"` - TargetName string `gorm:"primary_key;type:varchar(16)"` - Link string -} diff --git a/db/postgres/sml_version.go b/db/postgres/sml_version.go deleted file mode 100644 index 2d7d68ad..00000000 --- a/db/postgres/sml_version.go +++ /dev/null @@ -1,15 +0,0 @@ -package postgres - -import ( - "context" -) - -func GetSMLLatestVersions(ctx context.Context) *[]SMLVersion { - var smlVersions []SMLVersion - - DBCtx(ctx).Preload("Targets").Select("distinct on (stability) *"). - Order("stability, created_at desc"). - Find(&smlVersions) - - return &smlVersions -} diff --git a/db/postgres/user.go b/db/postgres/user.go deleted file mode 100644 index ce12df66..00000000 --- a/db/postgres/user.go +++ /dev/null @@ -1,139 +0,0 @@ -package postgres - -import ( - "context" - - "github.com/satisfactorymodding/smr-api/oauth" - "github.com/satisfactorymodding/smr-api/util" -) - -func GetUserSession(ctx context.Context, oauthUser *oauth.UserData, userAgent string) (*UserSession, *User, bool) { - user := User{ - Email: oauthUser.Email, - Avatar: oauthUser.Avatar, - JoinedFrom: string(oauthUser.Site), - Username: oauthUser.Username, - } - - // Find or create the user by email - find := DBCtx(ctx).Where(&User{Email: oauthUser.Email}) - - if oauthUser.Site == oauth.SiteGithub { - find = find.Or(&User{GithubID: &oauthUser.ID}) - } else if oauthUser.Site == oauth.SiteGoogle { - find = find.Or(&User{GoogleID: &oauthUser.ID}) - } else if oauthUser.Site == oauth.SiteFacebook { - find = find.Or(&User{FacebookID: &oauthUser.ID}) - } - - find.Find(&user) - - newUser := false - - if user.ID == "" { - user.ID = util.GenerateUniqueID() - - if oauthUser.Site == oauth.SiteGithub { - user.GithubID = &oauthUser.ID - } else if oauthUser.Site == oauth.SiteGoogle { - user.GoogleID = &oauthUser.ID - } else if oauthUser.Site == oauth.SiteFacebook { - user.FacebookID = &oauthUser.ID - } - - DBCtx(ctx).Create(&user) - newUser = true - } - - if !newUser { - newID := false - if oauthUser.Site == oauth.SiteGithub && user.GithubID == nil { - user.GithubID = &oauthUser.ID - newID = true - } else if oauthUser.Site == oauth.SiteGoogle && user.GoogleID == nil { - user.GoogleID = &oauthUser.ID - newID = true - } else if oauthUser.Site == oauth.SiteFacebook && user.FacebookID == nil { - user.FacebookID = &oauthUser.ID - newID = true - } - - if newID { - Save(ctx, &user) - } - } - - // TODO Archive old deleted sessions to cold storage - // DBCtx(ctx).Delete(&UserSession{UserAgent: userAgent}) - - session := UserSession{ - User: user, - Token: util.GenerateUserToken(), - UserAgent: userAgent, - } - - session.ID = util.GenerateUniqueID() - - // Create a new session - DBCtx(ctx).Create(&session) - - return &session, &user, newUser -} - -func LogoutSession(ctx context.Context, token string) { - // TODO Archive old deleted sessions to cold storage - DBCtx(ctx).Delete(&UserSession{Token: token}) -} - -func GetUserByToken(ctx context.Context, token string) *User { - // TODO Merge into a single query - var session UserSession - DBCtx(ctx).Find(&session, UserSession{Token: token}) - - if session.ID == "" { - return nil - } - - var user User - DBCtx(ctx).Find(&user, "id = ?", session.UserID) - - if user.ID == "" { - return nil - } - - return &user -} - -func GetUserByID(ctx context.Context, userID string) *User { - var user User - DBCtx(ctx).Find(&user, "id = ?", userID) - - if user.ID == "" { - return nil - } - - return &user -} - -func GetUsersByID(ctx context.Context, userIds []string) *[]User { - var users []User - DBCtx(ctx).Find(&users, "id in (?)", userIds) - - if len(userIds) != len(users) { - return nil - } - - return &users -} - -func GetUserMods(ctx context.Context, userID string) []UserMod { - var mods []UserMod - DBCtx(ctx).Raw("SELECT * from \"user_mods\" as tdm WHERE user_id = ? AND mod_id = (SELECT id FROM mods WHERE id = tdm.mod_id AND deleted_at is NULL LIMIT 1)", userID).Find(&mods) - return mods -} - -func GetModAuthors(ctx context.Context, modID string) []UserMod { - var authors []UserMod - DBCtx(ctx).Find(&authors, "mod_id = ?", modID) - return authors -} diff --git a/db/postgres/utils.go b/db/postgres/utils.go deleted file mode 100644 index 44f119a5..00000000 --- a/db/postgres/utils.go +++ /dev/null @@ -1,21 +0,0 @@ -package postgres - -import ( - "context" - - "gorm.io/gorm" -) - -type ( - ContextDB struct{} -) - -func DBFromContext(ctx context.Context) *gorm.DB { - value := ctx.Value(ContextDB{}) - - if value == nil { - return nil - } - - return value.(*gorm.DB) -} diff --git a/db/postgres/version.go b/db/postgres/version.go deleted file mode 100644 index b0b9a184..00000000 --- a/db/postgres/version.go +++ /dev/null @@ -1,148 +0,0 @@ -package postgres - -import ( - "context" - "fmt" - "strings" - - "github.com/patrickmn/go-cache" - - "github.com/satisfactorymodding/smr-api/models" -) - -func GetModsLatestVersions(ctx context.Context, modIds []string, unapproved bool) *[]Version { - cacheKey := "GetModsLatestVersions_" + strings.Join(modIds, ":") + "_" + fmt.Sprint(unapproved) - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.(*[]Version) - } - - var versions []Version - - DBCtx(ctx).Preload("Targets").Select("distinct on (mod_id, stability) *"). - Where("mod_id in (?)", modIds). - Where("approved = ? AND denied = ?", !unapproved, false). - Order("mod_id, stability, created_at desc"). - Find(&versions) - - dbCache.Set(cacheKey, &versions, cache.DefaultExpiration) - - return &versions -} - -func GetModVersions(ctx context.Context, modID string, limit int, offset int, orderBy string, order string, unapproved bool) []Version { - cacheKey := "GetModVersions_" + modID + "_" + fmt.Sprint(limit) + "_" + fmt.Sprint(offset) + "_" + orderBy + "_" + order + "_" + fmt.Sprint(unapproved) - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.([]Version) - } - - var versions []Version - DBCtx(ctx).Preload("Targets").Limit(limit).Offset(offset).Order(orderBy+" "+order).Where("approved = ? AND denied = ?", !unapproved, false).Find(&versions, "mod_id = ?", modID) - - dbCache.Set(cacheKey, versions, cache.DefaultExpiration) - - return versions -} - -func GetAllModVersionsWithDependencies(ctx context.Context, modID string) []TinyVersion { - cacheKey := "GetAllModVersionsWithDependencies_" + modID - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.([]TinyVersion) - } - - var versions []TinyVersion - DBCtx(ctx). - Preload("Dependencies"). - Preload("Targets"). - Where("approved = ? AND denied = ?", true, false). - Find(&versions, "mod_id = ?", modID) - - dbCache.Set(cacheKey, versions, cache.DefaultExpiration) - - return versions -} - -func GetModVersionsNew(ctx context.Context, modID string, filter *models.VersionFilter, unapproved bool) []Version { - hash, err := filter.Hash() - cacheKey := "" - if err == nil { - cacheKey = "GetModVersionsNew_" + modID + "_" + hash + "_" + fmt.Sprint(unapproved) - if versions, ok := dbCache.Get(cacheKey); ok { - return versions.([]Version) - } - } - - var versions []Version - query := DBCtx(ctx).Preload("Targets") - - if filter != nil { - query = query.Limit(*filter.Limit). - Offset(*filter.Offset). - Order(string(*filter.OrderBy) + " " + string(*filter.Order)) - } - - query.Preload("Targets").Where("approved = ? AND denied = ?", !unapproved, false).Find(&versions, "mod_id = ?", modID) - - if cacheKey != "" { - dbCache.Set(cacheKey, versions, cache.DefaultExpiration) - } - - return versions -} - -func GetModVersion(ctx context.Context, modID string, versionID string) *Version { - cacheKey := "GetModVersion_" + modID + "_" + versionID - if version, ok := dbCache.Get(cacheKey); ok { - return version.(*Version) - } - - var version Version - DBCtx(ctx).Preload("Targets").First(&version, "mod_id = ? AND id = ?", modID, versionID) - - if version.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &version, cache.DefaultExpiration) - - return &version -} - -func IncrementVersionDownloads(ctx context.Context, version *Version) { - DBCtx(ctx).Model(version).Update("downloads", version.Downloads+1) -} - -func GetVersion(ctx context.Context, versionID string) *Version { - cacheKey := "GetVersion_" + versionID - if version, ok := dbCache.Get(cacheKey); ok { - return version.(*Version) - } - - var version Version - DBCtx(ctx).Preload("Targets").First(&version, "id = ?", versionID) - - if version.ID == "" { - return nil - } - - dbCache.Set(cacheKey, &version, cache.DefaultExpiration) - - return &version -} - -func GetVersionTarget(ctx context.Context, versionID string, target string) *VersionTarget { - cacheKey := "GetVersionTarget_" + versionID + "_" + target - if versionTarget, ok := dbCache.Get(cacheKey); ok { - return versionTarget.(*VersionTarget) - } - - var versionTarget VersionTarget - DBCtx(ctx).First(&versionTarget, "version_id = ? AND target_name = ?", versionID, target) - - if versionTarget.VersionID == "" { - return nil - } - - dbCache.Set(cacheKey, &versionTarget, cache.DefaultExpiration) - - return &versionTarget -} diff --git a/generated/conv/version.go b/generated/conv/version.go index fe15fc4b..0e30d461 100755 --- a/generated/conv/version.go +++ b/generated/conv/version.go @@ -34,6 +34,10 @@ func (c *VersionImpl) Convert(source *ent.Version) *generated.Version { generatedVersion.Targets = pGeneratedVersionTargetList pString := (*source).Metadata generatedVersion.Metadata = &pString + pInt := conversion.Int64ToInt((*source).Size) + generatedVersion.Size = &pInt + pString2 := (*source).Hash + generatedVersion.Hash = &pString2 pGeneratedVersion = &generatedVersion } return pGeneratedVersion diff --git a/go.mod b/go.mod index bdd8a732..8b7fbad0 100755 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/satisfactorymodding/smr-api go 1.21 +toolchain go1.21.4 + require ( ariga.io/entcache v0.1.0 entgo.io/ent v0.12.4 @@ -33,7 +35,6 @@ require ( github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/mitchellh/mapstructure v1.5.0 github.com/o1egl/paseto v1.0.0 - github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/russross/blackfriday v1.6.0 github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591 @@ -44,7 +45,6 @@ require ( github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9 github.com/vmihailenco/taskq/v3 v3.2.9 github.com/xeipuuv/gojsonschema v1.2.0 - go.opentelemetry.io/contrib v1.20.0 go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 @@ -58,8 +58,6 @@ require ( google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gopkg.in/go-playground/validator.v9 v9.31.0 - gorm.io/driver/postgres v1.5.3 - gorm.io/gorm v1.25.5 ) require ( @@ -122,8 +120,6 @@ require ( github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.17.1 // indirect diff --git a/go.sum b/go.sum index 8abf08c9..6756e3d7 100644 --- a/go.sum +++ b/go.sum @@ -375,10 +375,6 @@ github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033 h1:R0efOJW github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033/go.mod h1:JHpPOBFu/UpmWT79z9fw5lQn7Oem6lnkS3jN4ZQdfLQ= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -491,8 +487,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -619,8 +613,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opentelemetry.io/contrib v1.20.0 h1:oXUiIQLlkbi9uZB/bt5B1WRLsrTKqb7bPpAQ+6htn2w= -go.opentelemetry.io/contrib v1.20.0/go.mod h1:gIzjwWFoGazJmtCaDgViqOSJPde2mCWzv60o0bWPcZs= go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 h1:JJCIHAxGCB5HM3NxeIwFjHc087Xwk96TG9kaZU6TAec= go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0/go.mod h1:Px9kH7SJ+NhsgWRtD/eMcs15Tyt4uL3rM7X54qv6pfA= go.opentelemetry.io/contrib/propagators/b3 v1.20.0 h1:Yty9Vs4F3D6/liF1o6FNt0PvN85h/BJJ6DQKJ3nrcM0= @@ -1045,10 +1037,6 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/postgres v1.5.3 h1:qKGY5CPHOuj47K/VxbCXJfFvIUeqMSXXadqdCY+MbBU= -gorm.io/driver/postgres v1.5.3/go.mod h1:F+LtvlFhZT7UBiA81mC9W6Su3D4WUhSboc/36QZU0gk= -gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= -gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/gql/resolver_announcements.go b/gql/resolver_announcements.go index ead4eb83..4c021b36 100644 --- a/gql/resolver_announcements.go +++ b/gql/resolver_announcements.go @@ -85,7 +85,7 @@ func (r *queryResolver) GetAnnouncements(ctx context.Context) ([]*generated.Anno wrapper, ctx := WrapQueryTrace(ctx, "getAnnouncements") defer wrapper.end() - result, err := db.From(ctx).Debug().Announcement.Query().All(ctx) + result, err := db.From(ctx).Announcement.Query().All(ctx) if err != nil { return nil, err } diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 1837dbcd..3302d90b 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -23,7 +23,6 @@ import ( "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/modtag" "github.com/satisfactorymodding/smr-api/generated/ent/usermod" "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/integrations" @@ -425,8 +424,8 @@ func (r *getModsResolver) Mods(ctx context.Context, _ *generated.GetMods) ([]*ge modFilter.AddField(field.Name) } - query := db.From(ctx).Debug().Mod.Query() - query = convertModFilter(query, modFilter, false, unapproved) + query := db.From(ctx).Mod.Query() + query = db.ConvertModFilter(query, modFilter, false, unapproved) result, err := query.All(ctx) if err != nil { @@ -449,7 +448,7 @@ func (r *getModsResolver) Count(ctx context.Context, _ *generated.GetMods) (int, } query := db.From(ctx).Mod.Query() - query = convertModFilter(query, modFilter, false, unapproved) + query = db.ConvertModFilter(query, modFilter, false, unapproved) result, err := query.Count(ctx) if err != nil { @@ -478,7 +477,7 @@ func (r *getMyModsResolver) Mods(ctx context.Context, _ *generated.GetMyMods) ([ } query := db.From(ctx).Mod.Query() - query = convertModFilter(query, modFilter, false, unapproved) + query = db.ConvertModFilter(query, modFilter, false, unapproved) result, err := query.All(ctx) if err != nil { @@ -501,7 +500,7 @@ func (r *getMyModsResolver) Count(ctx context.Context, _ *generated.GetMyMods) ( } query := db.From(ctx).Mod.Query() - query = convertModFilter(query, modFilter, false, unapproved) + query = db.ConvertModFilter(query, modFilter, false, unapproved) result, err := query.Count(ctx) if err != nil { @@ -755,65 +754,3 @@ func (r *queryResolver) GetModAssetList(ctx context.Context, modReference string return assets, nil } - -func convertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, unapproved bool) *ent.ModQuery { - query = query.WithTags() - - if len(filter.Ids) > 0 { - query = query.Where(mod.IDIn(filter.Ids...)) - } else if len(filter.References) > 0 { - query = query.Where(mod.ModReferenceIn(filter.References...)) - } else if filter != nil { - query = query. - Limit(*filter.Limit). - Offset(*filter.Offset) - - if *filter.OrderBy != generated.ModFieldsSearch { - if string(*filter.OrderBy) == "last_version_date" { - query = query.Modify(func(s *sql.Selector) { - s.OrderExpr(sql.ExprP("case when last_version_date is null then 1 else 0 end, last_version_date")) - }).Clone() - } else { - query = query.Order(sql.OrderByField( - filter.OrderBy.String(), - db.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.SelectExpr(sql.ExprP("id, (similarity(name, ?) * 2 + similarity(short_description, ?) + similarity(full_description, ?) * 0.5) as s", cleanSearch, cleanSearch, cleanSearch)) - join.From(sql.Table(mod.Table)).As("t1") - s.Join(join).On(s.C(mod.FieldID), join.C("id")) - }) - - query = query.Where(func(s *sql.Selector) { - s.Where(sql.ExprP(`"t1"."s" > 0.2`)) - }) - - if !count && *filter.OrderBy == generated.ModFieldsSearch { - query = query.Order(func(s *sql.Selector) { - s.OrderExpr(sql.ExprP(`"t1"."s" DESC`)) - }) - } - } - - if filter.Hidden == nil || !(*filter.Hidden) { - query = query.Where(mod.Hidden(false)) - } - - if filter.TagIDs != nil && len(filter.TagIDs) > 0 { - query = query.Where(func(s *sql.Selector) { - t := sql.Table(modtag.Table) - s.Join(t).OnP(sql.ExprP("mod_tags.tag_id in ? AND mod_tags.mod_id = mods.id", filter.TagIDs)) - }) - } - } - - query = query.Where(mod.Approved(!unapproved), mod.Denied(false)) - - return query -} diff --git a/gql/resolver_oauth.go b/gql/resolver_oauth.go index 2df28efd..40942289 100644 --- a/gql/resolver_oauth.go +++ b/gql/resolver_oauth.go @@ -1,7 +1,6 @@ package gql import ( - "bytes" "context" "fmt" "net/http" @@ -11,10 +10,7 @@ import ( "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/generated/ent" - "github.com/satisfactorymodding/smr-api/generated/ent/user" "github.com/satisfactorymodding/smr-api/oauth" - "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/util" ) @@ -52,7 +48,7 @@ func (r *mutationResolver) OAuthGithub(ctx context.Context, code string, state s header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(ctx, u, userAgent) + token, err := db.CompleteOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -78,7 +74,7 @@ func (r *mutationResolver) OAuthGoogle(ctx context.Context, code string, state s header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(ctx, u, userAgent) + token, err := db.CompleteOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -104,7 +100,7 @@ func (r *mutationResolver) OAuthFacebook(ctx context.Context, code string, state header := ctx.Value(util.ContextHeader{}).(http.Header) userAgent := header.Get("User-Agent") - token, err := completeOAuthFlow(ctx, u, userAgent) + token, err := db.CompleteOAuthFlow(ctx, u, userAgent) if err != nil { return nil, err } @@ -113,94 +109,3 @@ func (r *mutationResolver) OAuthFacebook(ctx context.Context, code string, state Token: *token, }, nil } - -func completeOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string) (*string, error) { - avatarURL := u.Avatar - u.Avatar = "" - - find := db.From(ctx).User.Query().Where(user.Email(u.Email)) - - if u.Site == oauth.SiteGithub { - find = find.Where(user.GithubID(u.ID)) - } else if u.Site == oauth.SiteGoogle { - find = find.Where(user.GoogleID(u.ID)) - } else if u.Site == oauth.SiteFacebook { - find = find.Where(user.FacebookID(u.ID)) - } - - found, err := find.First(ctx) - if err != nil && !ent.IsNotFound(err) { - return nil, err - } - - newUser := false - if ent.IsNotFound(err) { - var err error - create := db.From(ctx).User. - Create(). - SetEmail(u.Email). - SetAvatar(u.Avatar). - SetJoinedFrom(string(u.Site)). - SetUsername(u.Username) - - if u.Site == oauth.SiteGithub { - create = create.SetGithubID(u.ID) - } else if u.Site == oauth.SiteGoogle { - create = create.SetGoogleID(u.ID) - } else if u.Site == oauth.SiteFacebook { - create = create.SetFacebookID(u.ID) - } - - found, err = create.Save(ctx) - if err != nil { - return nil, err - } - - newUser = true - } - - if !newUser { - var update *ent.UserUpdateOne - if u.Site == oauth.SiteGithub && found.GithubID == "" { - update = found.Update().SetGithubID(u.ID) - } else if u.Site == oauth.SiteGoogle && found.GoogleID == "" { - update = found.Update().SetGoogleID(u.ID) - } else if u.Site == oauth.SiteFacebook && found.FacebookID == "" { - update = found.Update().SetFacebookID(u.ID) - } - - if update != nil { - if err := update.Exec(ctx); err != nil { - return nil, err - } - } - } - - // TODO Archive old deleted sessions to cold storage - - session, err := db.From(ctx).UserSession. - Create(). - SetUserID(found.ID). - SetToken(util.GenerateUserToken()). - SetUserAgent(userAgent). - Save(ctx) - if err != nil { - return nil, err - } - - if avatarURL != "" && newUser { - avatarData, err := util.LinkToWebp(ctx, avatarURL) - if err != nil { - return nil, err - } - - success, avatarKey := storage.UploadUserAvatar(ctx, found.ID, bytes.NewReader(avatarData)) - if success { - if err := found.Update().SetAvatar(storage.GenerateDownloadLink(avatarKey)).Exec(ctx); err != nil { - return nil, err - } - } - } - - return &session.Token, nil -} diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index 3f4acb86..c38e2696 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -242,7 +242,7 @@ func (r *queryResolver) GetVersion(ctx context.Context, versionID string) (*gene wrapper, ctx := WrapQueryTrace(ctx, "getVersion") defer wrapper.end() - result, err := db.From(ctx).Version.Get(ctx, versionID) + result, err := db.From(ctx).Version.Query().WithTargets().Where(version.ID(versionID)).First(ctx) if err != nil { return nil, err } diff --git a/migrations/code.go b/migrations/code.go index fc5e13ff..9f34a1f5 100644 --- a/migrations/code.go +++ b/migrations/code.go @@ -2,14 +2,17 @@ package migrations import ( "context" + "database/sql" + "fmt" "log/slog" "os" "strings" "github.com/lab259/go-migration" + "github.com/spf13/viper" - postgres2 "github.com/satisfactorymodding/smr-api/db/postgres" - + // Import pgx + _ "github.com/jackc/pgx/v5/stdlib" // Import all migrations _ "github.com/satisfactorymodding/smr-api/migrations/code" ) @@ -24,13 +27,24 @@ func (c codeMigrationLogger) Write(p []byte) (int, error) { return len(p), nil } -func codeMigrations(ctx context.Context) { +func codeMigrations(_ context.Context) { source := migration.DefaultCodeSource() // TODO Custom reporter, this one's very ugly reporter := migration.NewDefaultReporterWithParams(codeMigrationLogger{}, os.Exit) - db, _ := postgres2.DBCtx(ctx).DB() + db, err := sql.Open("pgx", fmt.Sprintf( + "sslmode=disable host=%s port=%d user=%s dbname=%s password=%s", + viper.GetString("database.postgres.host"), + viper.GetInt("database.postgres.port"), + viper.GetString("database.postgres.user"), + viper.GetString("database.postgres.db"), + viper.GetString("database.postgres.pass"), + )) + if err != nil { + panic(err) + } + manager := migration.NewDefaultManager(migration.NewPostgreSQLTarget(db), source) runner := migration.NewArgsRunnerCustom(reporter, manager, os.Exit, "migrate") runner.Run(db) diff --git a/migrations/code/20200426221900_test_new_migration.go b/migrations/code/20200426221900_test_new_migration.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20200426221900_test_new_migration.go +++ b/migrations/code/20200426221900_test_new_migration.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20200501224200_parse_paks.go b/migrations/code/20200501224200_parse_paks.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20200501224200_parse_paks.go +++ b/migrations/code/20200501224200_parse_paks.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20200524203800_after_reference_fix.go b/migrations/code/20200524203800_after_reference_fix.go index 311c6ff2..1fe62003 100644 --- a/migrations/code/20200524203800_after_reference_fix.go +++ b/migrations/code/20200524203800_after_reference_fix.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), false, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, false, nil, nil) }, ) } diff --git a/migrations/code/20200621195500_after_id_length_fix.go b/migrations/code/20200621195500_after_id_length_fix.go index 311c6ff2..1fe62003 100644 --- a/migrations/code/20200621195500_after_id_length_fix.go +++ b/migrations/code/20200621195500_after_id_length_fix.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), false, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, false, nil, nil) }, ) } diff --git a/migrations/code/20200622003600_after_validation_disable.go b/migrations/code/20200622003600_after_validation_disable.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20200622003600_after_validation_disable.go +++ b/migrations/code/20200622003600_after_validation_disable.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20200629093800_copy_to_new_bucket.go b/migrations/code/20200629093800_copy_to_new_bucket.go index e16ce85b..efe9855e 100644 --- a/migrations/code/20200629093800_copy_to_new_bucket.go +++ b/migrations/code/20200629093800_copy_to_new_bucket.go @@ -5,6 +5,7 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/redis/jobs" "github.com/satisfactorymodding/smr-api/storage" ) @@ -12,8 +13,12 @@ import ( func init() { migration.NewCodeMigration( func(executionContext interface{}) error { + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } storage.ScheduleCopyAllObjectsFromOldBucket(func(key string) { - jobs.SubmitJobCopyObjectFromOldBucketTask(context.TODO(), key) + jobs.SubmitJobCopyObjectFromOldBucketTask(ctx, key) }) return nil }, diff --git a/migrations/code/20200707150700_after_sml_version_fix.go b/migrations/code/20200707150700_after_sml_version_fix.go index 9326e632..e61130dc 100644 --- a/migrations/code/20200707150700_after_sml_version_fix.go +++ b/migrations/code/20200707150700_after_sml_version_fix.go @@ -5,17 +5,21 @@ import ( "github.com/lab259/go-migration" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), false, nil, func(version postgres.Version) bool { - return version.SMLVersion == "" + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, false, nil, func(version *ent.Version) bool { + return version.SmlVersion == "" }) - return nil }, ) } diff --git a/migrations/code/20200829171600_after_db_dirty.go b/migrations/code/20200829171600_after_db_dirty.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20200829171600_after_db_dirty.go +++ b/migrations/code/20200829171600_after_db_dirty.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20200829225100_after_broken_datajson.go b/migrations/code/20200829225100_after_broken_datajson.go index 9da63802..0e179c5d 100644 --- a/migrations/code/20200829225100_after_broken_datajson.go +++ b/migrations/code/20200829225100_after_broken_datajson.go @@ -5,17 +5,21 @@ import ( "github.com/lab259/go-migration" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, func(version postgres.Version) bool { - return version.Hash == nil || *version.Hash == "" + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, func(version *ent.Version) bool { + return version.Hash == "" }) - return nil }, ) } diff --git a/migrations/code/20200830011200_after_gorm_hotfix.go b/migrations/code/20200830011200_after_gorm_hotfix.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20200830011200_after_gorm_hotfix.go +++ b/migrations/code/20200830011200_after_gorm_hotfix.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20201014162200_after_bp_fix.go b/migrations/code/20201014162200_after_bp_fix.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20201014162200_after_bp_fix.go +++ b/migrations/code/20201014162200_after_bp_fix.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20201016202600_after_body_enable.go b/migrations/code/20201016202600_after_body_enable.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20201016202600_after_body_enable.go +++ b/migrations/code/20201016202600_after_body_enable.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/code/20201019203800_after_remove_filter.go b/migrations/code/20201019203800_after_remove_filter.go index 488054c0..9f66ec92 100644 --- a/migrations/code/20201019203800_after_remove_filter.go +++ b/migrations/code/20201019203800_after_remove_filter.go @@ -5,14 +5,18 @@ import ( "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - utils.ReindexAllModFiles(context.TODO(), true, nil, nil) - return nil + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, nil) }, ) } diff --git a/migrations/migrations.go b/migrations/migrations.go index 68b6b49e..053ff64d 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -2,6 +2,7 @@ package migrations import ( "context" + "database/sql" "errors" "fmt" "strings" @@ -9,11 +10,12 @@ import ( "github.com/Vilsol/slox" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/postgres" - - postgres2 "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/spf13/viper" // Import migrations _ "github.com/golang-migrate/migrate/v4/source/file" + // Import pgx + _ "github.com/jackc/pgx/v5/stdlib" ) func RunMigrations(ctx context.Context) { @@ -29,8 +31,19 @@ func SetMigrationDir(newMigrationDir string) { } func databaseMigrations(ctx context.Context) { - db, _ := postgres2.DBCtx(ctx).DB() - driver, err := postgres.WithInstance(db, &postgres.Config{}) + connection, err := sql.Open("pgx", fmt.Sprintf( + "sslmode=disable host=%s port=%d user=%s dbname=%s password=%s", + viper.GetString("database.postgres.host"), + viper.GetInt("database.postgres.port"), + viper.GetString("database.postgres.user"), + viper.GetString("database.postgres.db"), + viper.GetString("database.postgres.pass"), + )) + if err != nil { + panic(err) + } + + driver, err := postgres.WithInstance(connection, &postgres.Config{}) if err != nil { panic(err) } diff --git a/migrations/utils/utils.go b/migrations/utils/utils.go index 2c8f2815..f15f9002 100644 --- a/migrations/utils/utils.go +++ b/migrations/utils/utils.go @@ -3,58 +3,58 @@ package utils import ( "context" - "github.com/satisfactorymodding/smr-api/db/postgres" - "github.com/satisfactorymodding/smr-api/generated" - "github.com/satisfactorymodding/smr-api/models" + "entgo.io/ent/dialect/sql" + + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/mod" + "github.com/satisfactorymodding/smr-api/generated/ent/version" "github.com/satisfactorymodding/smr-api/redis/jobs" ) -func ReindexAllModFiles(ctx context.Context, withMetadata bool, modFilter func(postgres.Mod) bool, versionFilter func(version postgres.Version) bool) { +func ReindexAllModFiles(ctx context.Context, withMetadata bool, modFilter func(*ent.Mod) bool, versionFilter func(version *ent.Version) bool) error { offset := 0 - limit := 100 - createdAt := generated.VersionFieldsCreatedAt - orderDesc := generated.OrderDesc - for { - mods := postgres.GetMods(ctx, 100, offset, "created_at", "asc", "", false) - offset += 100 + mods, err := db.From(ctx).Mod.Query().Limit(100).Offset(100).Order(mod.ByCreatedAt(sql.OrderDesc())).All(ctx) + if err != nil { + return err + } + offset += len(mods) if len(mods) == 0 { break } - for _, mod := range mods { + for _, m := range mods { versionOffset := 0 if modFilter != nil { - if !modFilter(mod) { + if !modFilter(m) { continue } } for { - versions := postgres.GetModVersionsNew(ctx, mod.ID, &models.VersionFilter{ - Limit: &limit, - Offset: &versionOffset, - OrderBy: &createdAt, - Order: &orderDesc, - }, false) + versions, err := m.QueryVersions().Limit(100).Offset(versionOffset).Order(version.ByCreatedAt(sql.OrderDesc())).All(ctx) + if err != nil { + return err + } versionOffset += len(versions) if len(versions) > 0 { - for _, version := range versions { + for _, v := range versions { if versionFilter != nil { - if !versionFilter(version) { + if !versionFilter(v) { continue } } if withMetadata { - jobs.SubmitJobUpdateDBFromModVersionFileTask(ctx, mod.ID, version.ID) + jobs.SubmitJobUpdateDBFromModVersionFileTask(ctx, m.ID, v.ID) } else { - jobs.SubmitJobUpdateDBFromModVersionJSONFileTask(ctx, mod.ID, version.ID) + jobs.SubmitJobUpdateDBFromModVersionJSONFileTask(ctx, m.ID, v.ID) } } } else { @@ -63,4 +63,6 @@ func ReindexAllModFiles(ctx context.Context, withMetadata bool, modFilter func(p } } } + + return nil } diff --git a/nodes/mod.go b/nodes/mod.go index ee3b53c6..3eb28980 100644 --- a/nodes/mod.go +++ b/nodes/mod.go @@ -1,12 +1,21 @@ package nodes import ( + "log/slog" "strings" "time" + "entgo.io/ent/dialect/sql" + "github.com/Vilsol/slox" "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated" + "github.com/satisfactorymodding/smr-api/generated/conv" + mod2 "github.com/satisfactorymodding/smr-api/generated/ent/mod" + version2 "github.com/satisfactorymodding/smr-api/generated/ent/version" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" + "github.com/satisfactorymodding/smr-api/models" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/storage" "github.com/satisfactorymodding/smr-api/util" @@ -31,14 +40,27 @@ func getMods(c echo.Context) (interface{}, *ErrorResponse) { order := util.OneOf(c, "order", []string{"asc", "desc"}, "desc") search := c.QueryParam("search") - mods := postgres.GetMods(c.Request().Context(), limit, offset, orderBy, order, search, false) + modFilter := models.DefaultModFilter() + modFilter.Limit = &limit + modFilter.Offset = &offset - converted := make([]*Mod, len(mods)) - for k, v := range mods { - converted[k] = ModToMod(&v, true) + orderByGen := generated.ModFields(orderBy) + modFilter.OrderBy = &orderByGen + + orderGen := generated.Order(order) + modFilter.Order = &orderGen + modFilter.Search = &search + + query := db.From(c.Request().Context()).Mod.Query() + query = db.ConvertModFilter(query, modFilter, false, false) + + mods, err := query.All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed retrieving mods", slog.Any("err", err)) + return nil, &ErrorVersionNotFound } - return converted, nil + return (*conv.ModImpl)(nil).ConvertSlice(mods), nil } // @Summary Retrieve a count of Mods @@ -51,7 +73,20 @@ func getMods(c echo.Context) (interface{}, *ErrorResponse) { // @Router /mods/count [get] func getModCount(c echo.Context) (interface{}, *ErrorResponse) { search := c.QueryParam("search") - return postgres.GetModCount(c.Request().Context(), search, false), nil + + modFilter := models.DefaultModFilter() + modFilter.Search = &search + + query := db.From(c.Request().Context()).Mod.Query() + query = db.ConvertModFilter(query, modFilter, true, false) + + count, err := query.Count(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed retrieving mod count", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } + + return count, nil } // @Summary Retrieve a Mod @@ -65,7 +100,14 @@ func getModCount(c echo.Context) (interface{}, *ErrorResponse) { func getMod(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return nil, &ErrorModNotFound + } if mod == nil { return nil, &ErrorModNotFound @@ -73,11 +115,11 @@ func getMod(c echo.Context) (interface{}, *ErrorResponse) { if _, ok := c.QueryParams()["view"]; ok { if redis.CanIncrement(c.RealIP(), "view", "mod:"+modID, time.Hour*4) { - postgres.IncrementModViews(c.Request().Context(), mod) + _ = mod.Update().AddViews(1).Exec(c.Request().Context()) } } - return ModToMod(mod, false), nil + return (*conv.ModImpl)(nil).Convert(mod), nil } // @Summary Retrieve a list of Mods by ID @@ -94,18 +136,20 @@ func getModsByIds(c echo.Context) (interface{}, *ErrorResponse) { // TODO limit amount of users requestable - mods := postgres.GetModsByID(c.Request().Context(), modIDSplit) + mods, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.IDIn(modIDSplit...)). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mods", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if mods == nil { return nil, &ErrorModNotFound } - converted := make([]*Mod, len(mods)) - for k, v := range mods { - converted[k] = ModToMod(&v, true) - } - - return converted, nil + return (*conv.ModImpl)(nil).ConvertSlice(mods), nil } // @Summary Retrieve a list of latest versions for a mod @@ -119,16 +163,27 @@ func getModsByIds(c echo.Context) (interface{}, *ErrorResponse) { func getModLatestVersions(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") - versions := postgres.GetModsLatestVersions(c.Request().Context(), []string{modID}, false) + versions, err := db.From(c.Request().Context()).Version.Query(). + WithTargets(). + Modify(func(s *sql.Selector) { + s.SelectExpr(sql.ExprP("distinct on (mod_id, stability) *")) + }). + Where(version2.Approved(true), version2.Denied(false), version2.ModID(modID)). + Order(version2.ByStability(sql.OrderDesc()), version2.ByCreatedAt(sql.OrderDesc())). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching versions", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if versions == nil { return nil, &ErrorVersionNotFound } - result := make(map[string]*Version) + result := make(map[string]*generated.Version) - for _, v := range *versions { - result[v.Stability] = VersionToVersion(&v) + for _, v := range versions { + result[string(v.Stability)] = (*conv.VersionImpl)(nil).Convert(v) } return result, nil @@ -148,19 +203,30 @@ func getModsLatestVersions(c echo.Context) (interface{}, *ErrorResponse) { // TODO limit amount of mods requestable - versions := postgres.GetModsLatestVersions(c.Request().Context(), modIDSplit, false) + versions, err := db.From(c.Request().Context()).Version.Query(). + WithTargets(). + Modify(func(s *sql.Selector) { + s.SelectExpr(sql.ExprP("distinct on (mod_id, stability) *")) + }). + Where(version2.Approved(true), version2.Denied(false), version2.ModIDIn(modIDSplit...)). + Order(version2.ByStability(sql.OrderDesc()), version2.ByCreatedAt(sql.OrderDesc())). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching versions", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if versions == nil { return nil, &ErrorVersionNotFound } - result := make(map[string]map[string]*Version) + result := make(map[string]map[string]*generated.Version) - for _, v := range *versions { + for _, v := range versions { if _, ok := result[v.ModID]; !ok { - result[v.ModID] = make(map[string]*Version) + result[v.ModID] = make(map[string]*generated.Version) } - result[v.ModID][v.Stability] = VersionToVersion(&v) + result[v.ModID][string(v.Stability)] = (*conv.VersionImpl)(nil).Convert(v) } return result, nil @@ -186,20 +252,33 @@ func getModVersions(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if mod == nil { return nil, &ErrorModNotFound } - versions := postgres.GetModVersions(c.Request().Context(), mod.ID, limit, offset, orderBy, order, false) - - converted := make([]*Version, len(versions)) - for k, v := range versions { - converted[k] = VersionToVersion(&v) + versions, err := mod.QueryVersions(). + WithDependencies(). + WithTargets(). + Limit(limit). + Offset(offset). + Order(sql.OrderByField(orderBy, db.OrderToOrder(order)).ToFunc()). + Where(version2.Approved(true), version2.Denied(false)). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching versions", slog.Any("err", err)) + return nil, &ErrorVersionNotFound } - return converted, nil + return (*conv.VersionImpl)(nil).ConvertSlice(versions), nil } // @Summary Retrieve a Mod Authors @@ -213,20 +292,26 @@ func getModVersions(c echo.Context) (interface{}, *ErrorResponse) { func getModAuthors(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return nil, &ErrorModNotFound + } if mod == nil { return nil, &ErrorModNotFound } - authors := postgres.GetModAuthors(c.Request().Context(), mod.ID) - - converted := make([]*ModUser, len(authors)) - for k, v := range authors { - converted[k] = ModUserToModUser(&v) + authors, err := mod.QueryUserMods().All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching authors", slog.Any("err", err)) + return nil, &ErrorModNotFound } - return converted, nil + return (*conv.UserModImpl)(nil).ConvertSlice(authors), nil } // @Summary Retrieve a Mod Version @@ -242,19 +327,30 @@ func getModVersion(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") versionID := c.Param("versionId") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if mod == nil { return nil, &ErrorModNotFound } - version := postgres.GetModVersion(c.Request().Context(), mod.ID, versionID) + version, err := mod.QueryVersions().Where(version2.ID(versionID)).First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if version == nil { return nil, &ErrorVersionNotFound } - return VersionToVersion(version), nil + return (*conv.VersionImpl)(nil).Convert(version), nil } // @Summary Download a Mod Version @@ -270,20 +366,31 @@ func downloadModVersion(c echo.Context) error { modID := c.Param("modId") versionID := c.Param("versionId") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return c.String(404, "mod not found, modID:"+modID) + } if mod == nil { return c.String(404, "mod not found, modID:"+modID) } - version := postgres.GetModVersion(c.Request().Context(), mod.ID, versionID) + version, err := mod.QueryVersions().Where(version2.ID(versionID)).First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return c.String(404, "version not found, modID:"+modID+" versionID:"+versionID) + } if version == nil { return c.String(404, "version not found, modID:"+modID+" versionID:"+versionID) } if redis.CanIncrement(c.RealIP(), "download", "version:"+versionID, time.Hour*4) { - postgres.IncrementVersionDownloads(c.Request().Context(), version) + _ = version.Update().AddDownloads(1).Exec(c.Request().Context()) } return c.Redirect(302, storage.GenerateDownloadLink(version.Key)) @@ -304,26 +411,41 @@ func downloadModVersionTarget(c echo.Context) error { versionID := c.Param("versionId") target := c.Param("target") - mod := postgres.GetModByID(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.ID(modID)). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return c.String(404, "mod not found, modID:"+modID) + } if mod == nil { return c.String(404, "mod not found, modID:"+modID) } - version := postgres.GetModVersion(c.Request().Context(), mod.ID, versionID) + version, err := mod.QueryVersions().Where(version2.ID(versionID)).First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return err + } if version == nil { return c.String(404, "version not found, modID:"+modID+" versionID:"+versionID) } - versionTarget := postgres.GetVersionTarget(c.Request().Context(), versionID, target) + versionTarget, err := version.QueryTargets().Where(versiontarget.TargetName(target)).First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching target", slog.Any("err", err)) + return err + } if versionTarget == nil { return c.String(404, "target not found, modID:"+modID+" versionID:"+versionID+" target:"+target) } if redis.CanIncrement(c.RealIP(), "download", "version:"+versionID, time.Hour*4) { - postgres.IncrementVersionDownloads(c.Request().Context(), version) + _ = version.Update().AddDownloads(1).Exec(c.Request().Context()) } return c.Redirect(302, storage.GenerateDownloadLink(versionTarget.Key)) @@ -340,18 +462,29 @@ func downloadModVersionTarget(c echo.Context) error { func getAllModVersions(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modId") - mod := postgres.GetModByIDOrReference(c.Request().Context(), modID) + mod, err := db.From(c.Request().Context()).Mod.Query(). + WithTags(). + Where(mod2.Or(mod2.ID(modID), mod2.ModReference(modID))). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mod", slog.Any("err", err)) + return nil, &ErrorModNotFound + } if mod == nil { return nil, &ErrorModNotFound } - versions := postgres.GetAllModVersionsWithDependencies(c.Request().Context(), mod.ID) - - converted := make([]*Version, len(versions)) - for k, v := range versions { - converted[k] = TinyVersionToVersion(&v) + versions, err := mod.QueryVersions(). + WithDependencies(). + WithTargets(). + Where(version2.Approved(true), version2.Denied(false)). + Select(version2.FieldHash, version2.FieldSize, version2.FieldSmlVersion, version2.FieldVersion). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching versions", slog.Any("err", err)) + return nil, &ErrorVersionNotFound } - return converted, nil + return (*conv.VersionImpl)(nil).ConvertSlice(versions), nil } diff --git a/nodes/mod_types.go b/nodes/mod_types.go deleted file mode 100644 index 25cab078..00000000 --- a/nodes/mod_types.go +++ /dev/null @@ -1,178 +0,0 @@ -package nodes - -import ( - "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" -) - -type Mod struct { - UpdatedAt time.Time `json:"updated_at"` - CreatedAt time.Time `json:"created_at"` - CreatorID string `json:"creator_id"` - FullDescription string `json:"full_description"` - Logo string `json:"logo"` - SourceURL string `json:"source_url"` - ID string `json:"id"` - ShortDescription string `json:"short_description"` - Name string `json:"name"` - Views uint `json:"views"` - Downloads uint `json:"downloads"` - Hotness uint `json:"hotness"` - Popularity uint `json:"popularity"` - Approved bool `json:"approved"` -} - -func ModToMod(mod *postgres.Mod, short bool) *Mod { - result := Mod{ - ID: mod.ID, - Name: mod.Name, - ShortDescription: mod.ShortDescription, - Logo: mod.Logo, - SourceURL: mod.SourceURL, - CreatorID: mod.CreatorID, - Approved: mod.Approved, - Views: mod.Views, - Downloads: mod.Downloads, - Hotness: mod.Hotness, - Popularity: mod.Popularity, - UpdatedAt: mod.UpdatedAt, - CreatedAt: mod.CreatedAt, - } - - if !short { - result.FullDescription = mod.FullDescription - } - - return &result -} - -type Version struct { - UpdatedAt time.Time `json:"updated_at,omitempty"` - CreatedAt time.Time `json:"created_at,omitempty"` - ID string `json:"id,omitempty"` - Version string `json:"version,omitempty"` - SMLVersion string `json:"sml_version,omitempty"` - Changelog string `json:"changelog,omitempty"` - Stability string `json:"stability,omitempty"` - ModID string `json:"mod_id,omitempty"` - Dependencies []VersionDependency `json:"dependencies,omitempty"` - Targets []VersionTarget `json:"targets,omitempty"` - Downloads uint `json:"downloads,omitempty"` - Approved bool `json:"approved,omitempty"` -} - -type VersionDependency struct { - ModID string `json:"mod_id"` - Condition string `json:"condition"` - Optional bool `json:"optional"` -} - -type VersionTarget struct { - VersionID string `json:"version_id"` - TargetName string `json:"target_name"` - Key string `json:"key"` - Hash string `json:"hash"` - Size int64 `json:"size"` -} - -func TinyVersionToVersion(version *postgres.TinyVersion) *Version { - var dependencies []VersionDependency - if version.Dependencies != nil { - dependencies = make([]VersionDependency, len(version.Dependencies)) - for i, v := range version.Dependencies { - dependencies[i] = VersionDependencyToVersionDependency(v) - } - } - - var targets []VersionTarget - if version.Targets != nil { - targets = make([]VersionTarget, len(version.Targets)) - for i, v := range version.Targets { - targets[i] = VersionTargetToVersionTarget(v) - } - } - - return &Version{ - UpdatedAt: version.UpdatedAt, - CreatedAt: version.CreatedAt, - ID: version.ID, - Version: version.Version, - SMLVersion: version.SMLVersion, - Dependencies: dependencies, - Targets: targets, - } -} - -func VersionToVersion(version *postgres.Version) *Version { - return &Version{ - ID: version.ID, - Version: version.Version, - SMLVersion: version.SMLVersion, - Changelog: version.Changelog, - Downloads: version.Downloads, - Stability: version.Stability, - Approved: version.Approved, - UpdatedAt: version.UpdatedAt, - CreatedAt: version.CreatedAt, - ModID: version.ModID, - } -} - -func VersionDependencyToVersionDependency(version postgres.VersionDependency) VersionDependency { - return VersionDependency{ - ModID: version.ModID, - Condition: version.Condition, - Optional: version.Optional, - } -} - -func VersionTargetToVersionTarget(version postgres.VersionTarget) VersionTarget { - return VersionTarget{ - VersionID: version.VersionID, - TargetName: version.TargetName, - Key: version.Key, - Hash: version.Hash, - Size: version.Size, - } -} - -type ModUser struct { - UserID string `json:"user_id"` - Role string `json:"role"` -} - -func ModUserToModUser(userMod *postgres.UserMod) *ModUser { - return &ModUser{ - UserID: userMod.UserID, - Role: userMod.Role, - } -} - -type SMLVersion struct { - Date time.Time `json:"date"` - UpdatedAt time.Time `json:"updated_at"` - CreatedAt time.Time `json:"created_at"` - BootstrapVersion *string `json:"bootstrap_version"` - ID string `json:"id"` - Version string `json:"version"` - Stability string `json:"stability"` - Link string `json:"link"` - Changelog string `json:"changelog"` - SatisfactoryVersion int `json:"satisfactory_version"` -} - -func SMLVersionToSMLVersion(version *postgres.SMLVersion) *SMLVersion { - return &SMLVersion{ - ID: version.ID, - Version: version.Version, - SatisfactoryVersion: version.SatisfactoryVersion, - BootstrapVersion: version.BootstrapVersion, - Stability: version.Stability, - Date: version.Date, - Link: version.Link, - Changelog: version.Changelog, - UpdatedAt: version.UpdatedAt, - CreatedAt: version.CreatedAt, - } -} diff --git a/nodes/oauth.go b/nodes/oauth.go index 9b8877d7..b5852b65 100644 --- a/nodes/oauth.go +++ b/nodes/oauth.go @@ -1,15 +1,12 @@ package nodes import ( - "bytes" "net/url" "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/oauth" - "github.com/satisfactorymodding/smr-api/storage" - "github.com/satisfactorymodding/smr-api/util" ) // @Summary Retrieve a list of OAuth methods @@ -56,23 +53,12 @@ func getGithub(c echo.Context) (interface{}, *ErrorResponse) { userAgent := c.Request().Header.Get("User-Agent") - avatarURL := user.Avatar - user.Avatar = "" - - session, dbUser, newUser := postgres.GetUserSession(c.Request().Context(), user, userAgent) - - if avatarURL != "" && newUser { - avatarData, err := util.LinkToWebp(c.Request().Context(), avatarURL) - if err != nil { - return nil, GenericUserError(err) - } - - success, avatarKey := storage.UploadUserAvatar(c.Request().Context(), session.UserID, bytes.NewReader(avatarData)) - if success { - dbUser.Avatar = storage.GenerateDownloadLink(avatarKey) - postgres.Save(c.Request().Context(), &dbUser) - } + token, err := db.CompleteOAuthFlow(c.Request().Context(), user, userAgent) + if err != nil { + return nil, GenericUserError(err) } - return SessionToSession(session), nil + return &UserSession{ + Token: *token, + }, nil } diff --git a/nodes/oauth_types.go b/nodes/oauth_types.go index 8ea05403..2a550b8c 100755 --- a/nodes/oauth_types.go +++ b/nodes/oauth_types.go @@ -1,15 +1,5 @@ package nodes -import ( - "github.com/satisfactorymodding/smr-api/db/postgres" -) - type UserSession struct { Token string `json:"token"` } - -func SessionToSession(session *postgres.UserSession) *UserSession { - return &UserSession{ - Token: session.Token, - } -} diff --git a/nodes/shared.go b/nodes/shared.go index ddcd60fb..87abce59 100644 --- a/nodes/shared.go +++ b/nodes/shared.go @@ -3,7 +3,7 @@ package nodes import ( "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/generated/ent" ) type DataFunction func(c echo.Context) (data interface{}, err *ErrorResponse) @@ -25,7 +25,7 @@ func dataWrapper(nested DataFunction) func(c echo.Context) error { } } -type AuthorizedDataFunction func(user *postgres.User, c echo.Context) (data interface{}, err *ErrorResponse) +type AuthorizedDataFunction func(user *ent.User, c echo.Context) (data interface{}, err *ErrorResponse) func authorized(nested AuthorizedDataFunction) DataFunction { return func(c echo.Context) (interface{}, *ErrorResponse) { diff --git a/nodes/sml.go b/nodes/sml.go index cc983dce..7f043a4d 100644 --- a/nodes/sml.go +++ b/nodes/sml.go @@ -1,9 +1,15 @@ package nodes import ( + "log/slog" + + "entgo.io/ent/dialect/sql" + "github.com/Vilsol/slox" "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent/smlversion" ) // @Summary Retrieve a list of latest versions for sml @@ -14,17 +20,17 @@ import ( // @Success 200 // @Router /sml/latest-versions [get] func getSMLLatestVersions(c echo.Context) (interface{}, *ErrorResponse) { - smlVersions := postgres.GetSMLLatestVersions(c.Request().Context()) - - if smlVersions == nil { + smlVersions, err := db.From(c.Request().Context()).SmlVersion.Query(). + WithTargets(). + Modify(func(s *sql.Selector) { + s.SelectExpr(sql.ExprP("distinct on (stability) *")) + }). + Order(smlversion.ByStability(sql.OrderDesc()), smlversion.ByCreatedAt(sql.OrderDesc())). + All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching sml versions", slog.Any("err", err)) return nil, &ErrorVersionNotFound } - result := make(map[string]*SMLVersion) - - for _, v := range *smlVersions { - result[v.Stability] = SMLVersionToSMLVersion(&v) - } - - return result, nil + return (*conv.SMLVersionImpl)(nil).ConvertSlice(smlVersions), nil } diff --git a/nodes/user.go b/nodes/user.go index a029ee49..aadb375b 100644 --- a/nodes/user.go +++ b/nodes/user.go @@ -1,21 +1,34 @@ package nodes import ( + "log/slog" "strings" + "github.com/Vilsol/slox" "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent" + "github.com/satisfactorymodding/smr-api/generated/ent/user" + "github.com/satisfactorymodding/smr-api/generated/ent/usermod" + "github.com/satisfactorymodding/smr-api/generated/ent/usersession" ) -func userFromContext(c echo.Context) *postgres.User { +func userFromContext(c echo.Context) *ent.User { authorization := c.Request().Header.Get("Authorization") if authorization == "" { return nil } - user := postgres.GetUserByToken(c.Request().Context(), authorization) + user, err := db.From(c.Request().Context()).User.Query(). + Where(user.HasSessionsWith(usersession.Token(authorization))). + First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mods", slog.Any("err", err)) + return nil + } if user == nil { return nil @@ -31,8 +44,14 @@ func userFromContext(c echo.Context) *postgres.User { // @Produce json // @Success 200 // @Router /user/me [get] -func getMe(user *postgres.User, _ echo.Context) (interface{}, *ErrorResponse) { - return UserToPrivateUser(user), nil +func getMe(user *ent.User, _ echo.Context) (interface{}, *ErrorResponse) { + return &User{ + ID: user.ID, + Email: user.Email, + Username: user.Username, + Avatar: user.Avatar, + CreatedAt: user.CreatedAt, + }, nil } // @Summary Log Out Current User @@ -42,8 +61,13 @@ func getMe(user *postgres.User, _ echo.Context) (interface{}, *ErrorResponse) { // @Produce json // @Success 200 // @Router /user/me/logout [get] -func getLogout(_ *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { - postgres.LogoutSession(c.Request().Context(), c.Request().Header.Get("Authorization")) +func getLogout(_ *ent.User, c echo.Context) (interface{}, *ErrorResponse) { + if _, err := db.From(c.Request().Context()).UserSession.Delete(). + Where(usersession.Token(c.Request().Header.Get("Authorization"))). + Exec(c.Request().Context()); err != nil { + slox.Error(c.Request().Context(), "failed deleting session", slog.Any("err", err)) + return nil, &ErrorUserNotFound + } return nil, nil } @@ -54,15 +78,14 @@ func getLogout(_ *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { // @Produce json // @Success 200 // @Router /user/me/mods [get] -func getMyMods(user *postgres.User, c echo.Context) (interface{}, *ErrorResponse) { - mods := postgres.GetUserMods(c.Request().Context(), user.ID) - - converted := make([]*UserMod, len(mods)) - for k, v := range mods { - converted[k] = UserModToUserMod(&v) +func getMyMods(user *ent.User, c echo.Context) (interface{}, *ErrorResponse) { + mods, err := db.From(c.Request().Context()).UserMod.Query().Where(usermod.UserID(user.ID)).All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching authors", slog.Any("err", err)) + return nil, &ErrorUserNotFound } - return converted, nil + return (*conv.UserModImpl)(nil).ConvertSlice(mods), nil } // @Summary Retrieve a list of Users @@ -80,18 +103,13 @@ func getUsers(c echo.Context) (interface{}, *ErrorResponse) { // TODO limit amount of users requestable - users := postgres.GetUsersByID(c.Request().Context(), userIDSplit) - - if users == nil { - return nil, &ErrorUserNotFound + users, err := db.From(c.Request().Context()).User.Query().Where(user.IDIn(userIDSplit...)).All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching users", slog.Any("err", err)) + return nil, nil } - converted := make([]*PublicUser, len(*users)) - for k, v := range *users { - converted[k] = UserToPublicUser(&v) - } - - return converted, nil + return (*conv.UserImpl)(nil).ConvertSlice(users), nil } // @Summary Retrieve a Users Mods @@ -105,20 +123,23 @@ func getUsers(c echo.Context) (interface{}, *ErrorResponse) { func getUserMods(c echo.Context) (interface{}, *ErrorResponse) { userID := c.Param("userId") - user := postgres.GetUserByID(c.Request().Context(), userID) + user, err := db.From(c.Request().Context()).User.Get(c.Request().Context(), userID) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mods", slog.Any("err", err)) + return nil, &ErrorUserNotFound + } if user == nil { return nil, &ErrorUserNotFound } - mods := postgres.GetUserMods(c.Request().Context(), user.ID) - - converted := make([]*UserMod, len(mods)) - for k, v := range mods { - converted[k] = UserModToUserMod(&v) + mods, err := db.From(c.Request().Context()).UserMod.Query().Where(usermod.UserID(user.ID)).All(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mods", slog.Any("err", err)) + return nil, &ErrorModNotFound } - return converted, nil + return (*conv.UserModImpl)(nil).ConvertSlice(mods), nil } // @Summary Retrieve a User @@ -132,11 +153,20 @@ func getUserMods(c echo.Context) (interface{}, *ErrorResponse) { func getUser(c echo.Context) (interface{}, *ErrorResponse) { userID := c.Param("userId") - user := postgres.GetUserByID(c.Request().Context(), userID) + user, err := db.From(c.Request().Context()).User.Get(c.Request().Context(), userID) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching mods", slog.Any("err", err)) + return nil, &ErrorUserNotFound + } if user == nil { return nil, &ErrorUserNotFound } - return UserToPublicUser(user), nil + return &PublicUser{ + ID: user.ID, + Username: user.Username, + Avatar: user.Avatar, + CreatedAt: user.CreatedAt, + }, nil } diff --git a/nodes/user_types.go b/nodes/user_types.go index f929f531..dcfd4512 100644 --- a/nodes/user_types.go +++ b/nodes/user_types.go @@ -2,8 +2,6 @@ package nodes import ( "time" - - "github.com/satisfactorymodding/smr-api/db/postgres" ) type User struct { @@ -14,40 +12,9 @@ type User struct { Avatar string `json:"avatar"` } -func UserToPrivateUser(user *postgres.User) *User { - return &User{ - ID: user.ID, - Email: user.Email, - Username: user.Username, - Avatar: user.Avatar, - CreatedAt: user.CreatedAt, - } -} - type PublicUser struct { CreatedAt time.Time `json:"created_at"` ID string `json:"id"` Username string `json:"username"` Avatar string `json:"avatar"` } - -func UserToPublicUser(user *postgres.User) *PublicUser { - return &PublicUser{ - ID: user.ID, - Username: user.Username, - Avatar: user.Avatar, - CreatedAt: user.CreatedAt, - } -} - -type UserMod struct { - ModID string `json:"mod_id"` - Role string `json:"role"` -} - -func UserModToUserMod(mod *postgres.UserMod) *UserMod { - return &UserMod{ - ModID: mod.ModID, - Role: mod.Role, - } -} diff --git a/nodes/version.go b/nodes/version.go index 1da2eeef..3302e0e2 100644 --- a/nodes/version.go +++ b/nodes/version.go @@ -1,11 +1,15 @@ package nodes import ( + "log/slog" "time" + "github.com/Vilsol/slox" "github.com/labstack/echo/v4" - "github.com/satisfactorymodding/smr-api/db/postgres" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/conv" + "github.com/satisfactorymodding/smr-api/generated/ent/versiontarget" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/storage" ) @@ -21,13 +25,17 @@ import ( func getVersion(c echo.Context) (interface{}, *ErrorResponse) { versionID := c.Param("versionId") - version := postgres.GetVersion(c.Request().Context(), versionID) + version, err := db.From(c.Request().Context()).Version.Get(c.Request().Context(), versionID) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return nil, &ErrorVersionNotFound + } if version == nil { return nil, &ErrorVersionNotFound } - return VersionToVersion(version), nil + return (*conv.VersionImpl)(nil).Convert(version), nil } // @Summary Download a Version @@ -41,14 +49,18 @@ func getVersion(c echo.Context) (interface{}, *ErrorResponse) { func downloadVersion(c echo.Context) error { versionID := c.Param("versionId") - version := postgres.GetVersion(c.Request().Context(), versionID) + version, err := db.From(c.Request().Context()).Version.Get(c.Request().Context(), versionID) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return err + } if version == nil { return c.String(404, "version not found") } if redis.CanIncrement(c.RealIP(), "download", "version:"+versionID, time.Hour*4) { - postgres.IncrementVersionDownloads(c.Request().Context(), version) + _ = version.Update().AddDownloads(1).Exec(c.Request().Context()) } return c.Redirect(302, storage.GenerateDownloadLink(version.Key)) @@ -68,20 +80,28 @@ func downloadModTarget(c echo.Context) error { versionID := c.Param("versionId") target := c.Param("target") - version := postgres.GetVersion(c.Request().Context(), versionID) + version, err := db.From(c.Request().Context()).Version.Get(c.Request().Context(), versionID) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching version", slog.Any("err", err)) + return err + } if version == nil { return c.String(404, "version not found, versionID:"+versionID) } - versionTarget := postgres.GetVersionTarget(c.Request().Context(), versionID, target) + versionTarget, err := version.QueryTargets().Where(versiontarget.TargetName(target)).First(c.Request().Context()) + if err != nil { + slox.Error(c.Request().Context(), "failed fetching target", slog.Any("err", err)) + return err + } if versionTarget == nil { return c.String(404, "target not found, versionID:"+versionID+" target:"+target) } if redis.CanIncrement(c.RealIP(), "download", "version:"+versionID, time.Hour*4) { - postgres.IncrementVersionDownloads(c.Request().Context(), version) + _ = version.Update().AddDownloads(1).Exec(c.Request().Context()) } return c.Redirect(302, storage.GenerateDownloadLink(versionTarget.Key)) diff --git a/tests/announcements_test.go b/tests/announcements_test.go index c880b350..608fb703 100644 --- a/tests/announcements_test.go +++ b/tests/announcements_test.go @@ -8,7 +8,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -16,7 +15,6 @@ import ( func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") - postgres.EnableDebug() db.EnableDebug() } diff --git a/tests/guides_test.go b/tests/guides_test.go index 6544423c..da5d8369 100644 --- a/tests/guides_test.go +++ b/tests/guides_test.go @@ -8,7 +8,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -16,7 +15,6 @@ import ( func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") - postgres.EnableDebug() db.EnableDebug() } diff --git a/tests/mod_test.go b/tests/mod_test.go index 1b0733e9..7006e507 100644 --- a/tests/mod_test.go +++ b/tests/mod_test.go @@ -8,7 +8,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -16,7 +15,6 @@ import ( func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") - postgres.EnableDebug() db.EnableDebug() } diff --git a/tests/sml_versions_test.go b/tests/sml_versions_test.go index e981a12e..768530a9 100644 --- a/tests/sml_versions_test.go +++ b/tests/sml_versions_test.go @@ -9,7 +9,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -17,7 +16,6 @@ import ( func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") - postgres.EnableDebug() db.EnableDebug() } diff --git a/tests/utils.go b/tests/utils.go index cac3229c..240737cf 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -2,19 +2,24 @@ package tests import ( "context" + "database/sql" + "fmt" "log/slog" "sync" "github.com/Vilsol/slox" "github.com/machinebox/graphql" + "github.com/spf13/viper" smr "github.com/satisfactorymodding/smr-api/api" "github.com/satisfactorymodding/smr-api/auth" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/redis" "github.com/satisfactorymodding/smr-api/util" "github.com/satisfactorymodding/smr-api/validation" + + // Import pgx + _ "github.com/jackc/pgx/v5/stdlib" ) func setup() (context.Context, *graphql.Client, func()) { @@ -30,14 +35,39 @@ func setup() (context.Context, *graphql.Client, func()) { TableName string } - // TODO Replace with ENT - err := postgres.DBCtx(ctx).Raw(`SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'`).Scan(&out).Error + connection, err := sql.Open("pgx", fmt.Sprintf( + "sslmode=disable host=%s port=%d user=%s dbname=%s password=%s", + viper.GetString("database.postgres.host"), + viper.GetInt("database.postgres.port"), + viper.GetString("database.postgres.user"), + viper.GetString("database.postgres.db"), + viper.GetString("database.postgres.pass"), + )) + if err != nil { + panic(err) + } + + query, err := connection.Query(`SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'`) if err != nil { panic(err) } + defer query.Close() + + for query.Next() { + row := struct { + TableName string + }{} + + err = query.Scan(&row.TableName) + if err != nil { + panic(err) + } + + out = append(out, row) + } for _, name := range out { - err := postgres.DBCtx(ctx).Exec(`DROP TABLE IF EXISTS ` + name.TableName + ` CASCADE`).Error + _, err = connection.Exec(`DROP TABLE IF EXISTS ` + name.TableName + ` CASCADE`) if err != nil { panic(err) } diff --git a/tests/version_test.go b/tests/version_test.go index bcc023a3..552667fe 100644 --- a/tests/version_test.go +++ b/tests/version_test.go @@ -21,7 +21,6 @@ import ( "github.com/satisfactorymodding/smr-api/config" "github.com/satisfactorymodding/smr-api/db" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/generated" "github.com/satisfactorymodding/smr-api/migrations" ) @@ -29,7 +28,6 @@ import ( func init() { migrations.SetMigrationDir("../migrations") config.SetConfigDir("../") - postgres.EnableDebug() db.EnableDebug() } diff --git a/validation/validation.go b/validation/validation.go index 1a9113b2..50df00b4 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -170,6 +170,8 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal break } } + } else { + slox.Warn(ctx, "no database context provided to validator") } slox.Info(ctx, "decided engine version", slog.String("version", engineVersion)) From 237f16ed7ba3f02ae95a89534b9ccfd9db2bbe18 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 17 Jun 2024 16:10:09 +0300 Subject: [PATCH 16/19] chore: bump dependency versions --- .direnv/flake-profile | 1 - .direnv/flake-profile-1-link | 1 - .gitignore | 4 +- flake.lock | 22 +- generated/conv/announcement.go | 1 + generated/conv/guide.go | 1 + generated/conv/mod.go | 7 +- generated/conv/sml_version.go | 1 + generated/conv/tag.go | 1 + generated/conv/user.go | 1 + generated/conv/user_mod.go | 1 + generated/conv/version.go | 1 + generated/conv/version_dependency.go | 1 + generated/ent/announcement_update.go | 32 + generated/ent/client.go | 11 +- generated/ent/guide.go | 8 +- generated/ent/guide_update.go | 48 ++ generated/ent/guidetag.go | 16 +- generated/ent/guidetag_update.go | 32 + generated/ent/internal/schema.go | 2 +- generated/ent/mod_update.go | 96 +++ generated/ent/modtag.go | 16 +- generated/ent/modtag_update.go | 32 + generated/ent/runtime/runtime.go | 4 +- generated/ent/smlversion_update.go | 96 +++ generated/ent/smlversiontarget.go | 8 +- generated/ent/smlversiontarget_update.go | 48 ++ generated/ent/tag_update.go | 16 + generated/ent/user_update.go | 32 + generated/ent/usergroup.go | 8 +- generated/ent/usergroup_update.go | 32 + generated/ent/usermod.go | 16 +- generated/ent/usermod_update.go | 48 ++ generated/ent/usersession.go | 8 +- generated/ent/usersession_update.go | 16 + generated/ent/version.go | 8 +- generated/ent/version_update.go | 80 +++ generated/ent/versiondependency.go | 16 +- generated/ent/versiondependency_update.go | 64 ++ generated/ent/versiontarget.go | 8 +- generated/ent/versiontarget_update.go | 32 + generated/generated.go | 818 +++++++++++++--------- generated/models_gen.go | 6 + go.mod | 121 ++-- go.sum | 655 ++++------------- shell.nix | 3 +- tools.go | 6 +- 47 files changed, 1480 insertions(+), 1005 deletions(-) delete mode 120000 .direnv/flake-profile delete mode 120000 .direnv/flake-profile-1-link diff --git a/.direnv/flake-profile b/.direnv/flake-profile deleted file mode 120000 index 0c05709d..00000000 --- a/.direnv/flake-profile +++ /dev/null @@ -1 +0,0 @@ -flake-profile-1-link \ No newline at end of file diff --git a/.direnv/flake-profile-1-link b/.direnv/flake-profile-1-link deleted file mode 120000 index 78a8994c..00000000 --- a/.direnv/flake-profile-1-link +++ /dev/null @@ -1 +0,0 @@ -/nix/store/zx4bs036j9parpd359js7l8nnbx676vf-nix-shell-env \ No newline at end of file diff --git a/.gitignore b/.gitignore index b10762e2..ccdc17c4 100755 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,6 @@ modules.xml config.json vendor/ /paks/ -*.smod \ No newline at end of file +*.smod + +/.direnv diff --git a/flake.lock b/flake.lock index 0c52fe07..01b903b5 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,12 +20,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1700014976, - "narHash": "sha256-dSGpS2YeJrXW5aH9y7Abd235gGufY3RuZFth6vuyVtU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "592047fc9e4f7b74a4dc85d1b9f5243dfe4899e3", - "type": "github" + "lastModified": 0, + "narHash": "sha256-u1fA0DYQYdeG+5kDm1bOoGcHtX0rtC7qs2YA2N1X++I=", + "path": "/nix/store/2yb39wmx10a5lsm4d2jj7c6h94h36spi-source", + "type": "path" }, "original": { "id": "nixpkgs", @@ -34,11 +32,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1701040486, - "narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=", + "lastModified": 1718396522, + "narHash": "sha256-C0re6ZtCqC1ndL7ib7vOqmgwvZDhOhJ1W0wQgX1tTIo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "45827faa2132b8eade424f6bdd48d8828754341a", + "rev": "3e6b9369165397184774a4b7c5e8e5e46531b53f", "type": "github" }, "original": { diff --git a/generated/conv/announcement.go b/generated/conv/announcement.go index cd35261f..bed9beb2 100755 --- a/generated/conv/announcement.go +++ b/generated/conv/announcement.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/guide.go b/generated/conv/guide.go index 03a23dc4..d7b44d47 100755 --- a/generated/conv/guide.go +++ b/generated/conv/guide.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/mod.go b/generated/conv/mod.go index ff36db04..1b7ad916 100755 --- a/generated/conv/mod.go +++ b/generated/conv/mod.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv @@ -83,14 +84,10 @@ func (c *ModImpl) timeTimeToPString(source time.Time) *string { xstring := conversion.TimeToString(source) return &xstring } -func (c *ModImpl) utilCompatibilityToGeneratedCompatibility(source util.Compatibility) generated.Compatibility { +func (c *ModImpl) utilCompatibilityToPGeneratedCompatibility(source util.Compatibility) *generated.Compatibility { var generatedCompatibility generated.Compatibility generatedCompatibility.State = generated.CompatibilityState(source.State) pString := source.Note generatedCompatibility.Note = &pString - return generatedCompatibility -} -func (c *ModImpl) utilCompatibilityToPGeneratedCompatibility(source util.Compatibility) *generated.Compatibility { - generatedCompatibility := c.utilCompatibilityToGeneratedCompatibility(source) return &generatedCompatibility } diff --git a/generated/conv/sml_version.go b/generated/conv/sml_version.go index b283229d..ad7125e0 100755 --- a/generated/conv/sml_version.go +++ b/generated/conv/sml_version.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/tag.go b/generated/conv/tag.go index 0a910610..299f198b 100755 --- a/generated/conv/tag.go +++ b/generated/conv/tag.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/user.go b/generated/conv/user.go index ab2742ae..b94afff1 100755 --- a/generated/conv/user.go +++ b/generated/conv/user.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/user_mod.go b/generated/conv/user_mod.go index d0b8cc78..80a4bdee 100755 --- a/generated/conv/user_mod.go +++ b/generated/conv/user_mod.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/version.go b/generated/conv/version.go index 0e30d461..729e29e6 100755 --- a/generated/conv/version.go +++ b/generated/conv/version.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/conv/version_dependency.go b/generated/conv/version_dependency.go index 730b0d7a..25890cc0 100755 --- a/generated/conv/version_dependency.go +++ b/generated/conv/version_dependency.go @@ -1,4 +1,5 @@ // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. +//go:build !goverter package conv diff --git a/generated/ent/announcement_update.go b/generated/ent/announcement_update.go index 4ce22dd2..524cedc9 100644 --- a/generated/ent/announcement_update.go +++ b/generated/ent/announcement_update.go @@ -61,12 +61,28 @@ func (au *AnnouncementUpdate) SetMessage(s string) *AnnouncementUpdate { return au } +// SetNillableMessage sets the "message" field if the given value is not nil. +func (au *AnnouncementUpdate) SetNillableMessage(s *string) *AnnouncementUpdate { + if s != nil { + au.SetMessage(*s) + } + return au +} + // SetImportance sets the "importance" field. func (au *AnnouncementUpdate) SetImportance(s string) *AnnouncementUpdate { au.mutation.SetImportance(s) return au } +// SetNillableImportance sets the "importance" field if the given value is not nil. +func (au *AnnouncementUpdate) SetNillableImportance(s *string) *AnnouncementUpdate { + if s != nil { + au.SetImportance(*s) + } + return au +} + // Mutation returns the AnnouncementMutation object of the builder. func (au *AnnouncementUpdate) Mutation() *AnnouncementMutation { return au.mutation @@ -198,12 +214,28 @@ func (auo *AnnouncementUpdateOne) SetMessage(s string) *AnnouncementUpdateOne { return auo } +// SetNillableMessage sets the "message" field if the given value is not nil. +func (auo *AnnouncementUpdateOne) SetNillableMessage(s *string) *AnnouncementUpdateOne { + if s != nil { + auo.SetMessage(*s) + } + return auo +} + // SetImportance sets the "importance" field. func (auo *AnnouncementUpdateOne) SetImportance(s string) *AnnouncementUpdateOne { auo.mutation.SetImportance(s) return auo } +// SetNillableImportance sets the "importance" field if the given value is not nil. +func (auo *AnnouncementUpdateOne) SetNillableImportance(s *string) *AnnouncementUpdateOne { + if s != nil { + auo.SetImportance(*s) + } + return auo +} + // Mutation returns the AnnouncementMutation object of the builder. func (auo *AnnouncementUpdateOne) Mutation() *AnnouncementMutation { return auo.mutation diff --git a/generated/ent/client.go b/generated/ent/client.go index 1fd8c57b..c05ee907 100644 --- a/generated/ent/client.go +++ b/generated/ent/client.go @@ -73,9 +73,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -117,6 +115,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { diff --git a/generated/ent/guide.go b/generated/ent/guide.go index 1fbdd27a..a822a264 100644 --- a/generated/ent/guide.go +++ b/generated/ent/guide.go @@ -56,12 +56,10 @@ type GuideEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e GuideEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/generated/ent/guide_update.go b/generated/ent/guide_update.go index 63984888..c7c4f7ba 100644 --- a/generated/ent/guide_update.go +++ b/generated/ent/guide_update.go @@ -83,18 +83,42 @@ func (gu *GuideUpdate) SetName(s string) *GuideUpdate { return gu } +// SetNillableName sets the "name" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableName(s *string) *GuideUpdate { + if s != nil { + gu.SetName(*s) + } + return gu +} + // SetShortDescription sets the "short_description" field. func (gu *GuideUpdate) SetShortDescription(s string) *GuideUpdate { gu.mutation.SetShortDescription(s) return gu } +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableShortDescription(s *string) *GuideUpdate { + if s != nil { + gu.SetShortDescription(*s) + } + return gu +} + // SetGuide sets the "guide" field. func (gu *GuideUpdate) SetGuide(s string) *GuideUpdate { gu.mutation.SetGuide(s) return gu } +// SetNillableGuide sets the "guide" field if the given value is not nil. +func (gu *GuideUpdate) SetNillableGuide(s *string) *GuideUpdate { + if s != nil { + gu.SetGuide(*s) + } + return gu +} + // SetViews sets the "views" field. func (gu *GuideUpdate) SetViews(i int) *GuideUpdate { gu.mutation.ResetViews() @@ -415,18 +439,42 @@ func (guo *GuideUpdateOne) SetName(s string) *GuideUpdateOne { return guo } +// SetNillableName sets the "name" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableName(s *string) *GuideUpdateOne { + if s != nil { + guo.SetName(*s) + } + return guo +} + // SetShortDescription sets the "short_description" field. func (guo *GuideUpdateOne) SetShortDescription(s string) *GuideUpdateOne { guo.mutation.SetShortDescription(s) return guo } +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableShortDescription(s *string) *GuideUpdateOne { + if s != nil { + guo.SetShortDescription(*s) + } + return guo +} + // SetGuide sets the "guide" field. func (guo *GuideUpdateOne) SetGuide(s string) *GuideUpdateOne { guo.mutation.SetGuide(s) return guo } +// SetNillableGuide sets the "guide" field if the given value is not nil. +func (guo *GuideUpdateOne) SetNillableGuide(s *string) *GuideUpdateOne { + if s != nil { + guo.SetGuide(*s) + } + return guo +} + // SetViews sets the "views" field. func (guo *GuideUpdateOne) SetViews(i int) *GuideUpdateOne { guo.mutation.ResetViews() diff --git a/generated/ent/guidetag.go b/generated/ent/guidetag.go index ef3e2e7f..ea8706fc 100644 --- a/generated/ent/guidetag.go +++ b/generated/ent/guidetag.go @@ -40,12 +40,10 @@ type GuideTagEdges struct { // GuideOrErr returns the Guide value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e GuideTagEdges) GuideOrErr() (*Guide, error) { - if e.loadedTypes[0] { - if e.Guide == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: guide.Label} - } + if e.Guide != nil { return e.Guide, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: guide.Label} } return nil, &NotLoadedError{edge: "guide"} } @@ -53,12 +51,10 @@ func (e GuideTagEdges) GuideOrErr() (*Guide, error) { // 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 GuideTagEdges) TagOrErr() (*Tag, error) { - if e.loadedTypes[1] { - if e.Tag == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: tag.Label} - } + if e.Tag != nil { return e.Tag, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: tag.Label} } return nil, &NotLoadedError{edge: "tag"} } diff --git a/generated/ent/guidetag_update.go b/generated/ent/guidetag_update.go index 70bcf034..172120d8 100644 --- a/generated/ent/guidetag_update.go +++ b/generated/ent/guidetag_update.go @@ -36,12 +36,28 @@ func (gtu *GuideTagUpdate) SetGuideID(s string) *GuideTagUpdate { return gtu } +// SetNillableGuideID sets the "guide_id" field if the given value is not nil. +func (gtu *GuideTagUpdate) SetNillableGuideID(s *string) *GuideTagUpdate { + if s != nil { + gtu.SetGuideID(*s) + } + return gtu +} + // SetTagID sets the "tag_id" field. func (gtu *GuideTagUpdate) SetTagID(s string) *GuideTagUpdate { gtu.mutation.SetTagID(s) return gtu } +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (gtu *GuideTagUpdate) SetNillableTagID(s *string) *GuideTagUpdate { + if s != nil { + gtu.SetTagID(*s) + } + return gtu +} + // SetGuide sets the "guide" edge to the Guide entity. func (gtu *GuideTagUpdate) SetGuide(g *Guide) *GuideTagUpdate { return gtu.SetGuideID(g.ID) @@ -211,12 +227,28 @@ func (gtuo *GuideTagUpdateOne) SetGuideID(s string) *GuideTagUpdateOne { return gtuo } +// SetNillableGuideID sets the "guide_id" field if the given value is not nil. +func (gtuo *GuideTagUpdateOne) SetNillableGuideID(s *string) *GuideTagUpdateOne { + if s != nil { + gtuo.SetGuideID(*s) + } + return gtuo +} + // SetTagID sets the "tag_id" field. func (gtuo *GuideTagUpdateOne) SetTagID(s string) *GuideTagUpdateOne { gtuo.mutation.SetTagID(s) return gtuo } +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (gtuo *GuideTagUpdateOne) SetNillableTagID(s *string) *GuideTagUpdateOne { + if s != nil { + gtuo.SetTagID(*s) + } + return gtuo +} + // SetGuide sets the "guide" edge to the Guide entity. func (gtuo *GuideTagUpdateOne) SetGuide(g *Guide) *GuideTagUpdateOne { return gtuo.SetGuideID(g.ID) diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go index fcc3ab33..63b706be 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":["id"]},{"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":["id"]},{"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},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"source_url","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":"approved","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"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":7,"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":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":"downloads","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":"denied","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"last_version_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":13,"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":14,"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":15,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["last_version_date"]}],"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":"SmlVersion","config":{"Table":""},"edges":[{"name":"targets","type":"SmlVersionTarget"}],"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":"version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"satisfactory_version","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"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"}],"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":4,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"bootstrap_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":14,"optional":true,"validators":1,"position":{"Index":6,"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":7,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"hooks":[{"Index":0,"MixedIn":true,"MixinIndex":2}],"interceptors":[{"Index":0,"MixedIn":true,"MixinIndex":2}]},{"name":"SmlVersionTarget","config":{"Table":""},"edges":[{"name":"sml_version","type":"SmlVersion","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":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_name"]}]},{"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}}],"indexes":[{"fields":["id"]},{"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,"unique":true,"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":"joined_from","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"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":5,"MixedIn":false,"MixinIndex":0}},{"name":"github_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}},{"name":"google_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":7,"MixedIn":false,"MixinIndex":0}},{"name":"facebook_id","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"unique":true,"optional":true,"validators":1,"position":{"Index":8,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]},{"fields":["email"]},{"fields":["github_id"]},{"fields":["google_id"]},{"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":["id"]},{"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":256,"unique":true,"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":["id"]},{"fields":["deleted_at"]}],"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"}],"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":"sml_version","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":16,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"changelog","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"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":4,"MixedIn":false,"MixinIndex":0}},{"name":"key","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":5,"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"}],"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":"hotness","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":"denied","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":9,"MixedIn":false,"MixinIndex":0}},{"name":"metadata","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":10,"MixedIn":false,"MixinIndex":0}},{"name":"mod_reference","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":32,"validators":1,"position":{"Index":11,"MixedIn":false,"MixinIndex":0}},{"name":"version_major","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":12,"MixedIn":false,"MixinIndex":0}},{"name":"version_minor","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":13,"MixedIn":false,"MixinIndex":0}},{"name":"version_patch","type":{"Type":12,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":14,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":15,"MixedIn":false,"MixinIndex":0}},{"name":"hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":64,"optional":true,"validators":2,"position":{"Index":16,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["id"]},{"fields":["deleted_at"]}],"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":"sml_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":[{"fields":["id"]},{"unique":true,"fields":["version_id","target_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\":[\"id\"]},{\"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\":[\"id\"]},{\"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},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"source_url\",\"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\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":6,\"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\":7,\"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\":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\":\"downloads\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"last_version_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":13,\"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\":14,\"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\":15,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"last_version_date\"]}],\"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\":\"SmlVersion\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"targets\",\"type\":\"SmlVersionTarget\"}],\"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\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"satisfactory_version\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"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\"}],\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"bootstrap_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"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\":7,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"SmlVersionTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"sml_version\",\"type\":\"SmlVersion\",\"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\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]},{\"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}}],\"indexes\":[{\"fields\":[\"id\"]},{\"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,\"unique\":true,\"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\":\"joined_from\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"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\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"github_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"google_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"facebook_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"email\"]},{\"fields\":[\"github_id\"]},{\"fields\":[\"google_id\"]},{\"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\":[\"id\"]},{\"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\":256,\"unique\":true,\"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\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\"}],\"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\":\"sml_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"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\"}],\"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\":\"hotness\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"metadata\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_major\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_minor\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_patch\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"optional\":true,\"validators\":2,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\":\"sml_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\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]}],\"Features\":[\"sql/modifier\",\"intercept\",\"schema/snapshot\",\"sql/execquery\",\"sql/upsert\"]}" diff --git a/generated/ent/mod_update.go b/generated/ent/mod_update.go index 69e368de..8db066d6 100644 --- a/generated/ent/mod_update.go +++ b/generated/ent/mod_update.go @@ -65,24 +65,56 @@ func (mu *ModUpdate) SetName(s string) *ModUpdate { return mu } +// SetNillableName sets the "name" field if the given value is not nil. +func (mu *ModUpdate) SetNillableName(s *string) *ModUpdate { + if s != nil { + mu.SetName(*s) + } + return mu +} + // SetShortDescription sets the "short_description" field. func (mu *ModUpdate) SetShortDescription(s string) *ModUpdate { mu.mutation.SetShortDescription(s) return mu } +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (mu *ModUpdate) SetNillableShortDescription(s *string) *ModUpdate { + if s != nil { + mu.SetShortDescription(*s) + } + return mu +} + // SetFullDescription sets the "full_description" field. func (mu *ModUpdate) SetFullDescription(s string) *ModUpdate { mu.mutation.SetFullDescription(s) return mu } +// SetNillableFullDescription sets the "full_description" field if the given value is not nil. +func (mu *ModUpdate) SetNillableFullDescription(s *string) *ModUpdate { + if s != nil { + mu.SetFullDescription(*s) + } + return mu +} + // SetLogo sets the "logo" field. func (mu *ModUpdate) SetLogo(s string) *ModUpdate { mu.mutation.SetLogo(s) return mu } +// SetNillableLogo sets the "logo" field if the given value is not nil. +func (mu *ModUpdate) SetNillableLogo(s *string) *ModUpdate { + if s != nil { + mu.SetLogo(*s) + } + return mu +} + // SetSourceURL sets the "source_url" field. func (mu *ModUpdate) SetSourceURL(s string) *ModUpdate { mu.mutation.SetSourceURL(s) @@ -109,6 +141,14 @@ func (mu *ModUpdate) SetCreatorID(s string) *ModUpdate { return mu } +// SetNillableCreatorID sets the "creator_id" field if the given value is not nil. +func (mu *ModUpdate) SetNillableCreatorID(s *string) *ModUpdate { + if s != nil { + mu.SetCreatorID(*s) + } + return mu +} + // SetApproved sets the "approved" field. func (mu *ModUpdate) SetApproved(b bool) *ModUpdate { mu.mutation.SetApproved(b) @@ -247,6 +287,14 @@ func (mu *ModUpdate) SetModReference(s string) *ModUpdate { return mu } +// SetNillableModReference sets the "mod_reference" field if the given value is not nil. +func (mu *ModUpdate) SetNillableModReference(s *string) *ModUpdate { + if s != nil { + mu.SetModReference(*s) + } + return mu +} + // SetHidden sets the "hidden" field. func (mu *ModUpdate) SetHidden(b bool) *ModUpdate { mu.mutation.SetHidden(b) @@ -826,24 +874,56 @@ func (muo *ModUpdateOne) SetName(s string) *ModUpdateOne { return muo } +// SetNillableName sets the "name" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableName(s *string) *ModUpdateOne { + if s != nil { + muo.SetName(*s) + } + return muo +} + // SetShortDescription sets the "short_description" field. func (muo *ModUpdateOne) SetShortDescription(s string) *ModUpdateOne { muo.mutation.SetShortDescription(s) return muo } +// SetNillableShortDescription sets the "short_description" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableShortDescription(s *string) *ModUpdateOne { + if s != nil { + muo.SetShortDescription(*s) + } + return muo +} + // SetFullDescription sets the "full_description" field. func (muo *ModUpdateOne) SetFullDescription(s string) *ModUpdateOne { muo.mutation.SetFullDescription(s) return muo } +// SetNillableFullDescription sets the "full_description" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableFullDescription(s *string) *ModUpdateOne { + if s != nil { + muo.SetFullDescription(*s) + } + return muo +} + // SetLogo sets the "logo" field. func (muo *ModUpdateOne) SetLogo(s string) *ModUpdateOne { muo.mutation.SetLogo(s) return muo } +// SetNillableLogo sets the "logo" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableLogo(s *string) *ModUpdateOne { + if s != nil { + muo.SetLogo(*s) + } + return muo +} + // SetSourceURL sets the "source_url" field. func (muo *ModUpdateOne) SetSourceURL(s string) *ModUpdateOne { muo.mutation.SetSourceURL(s) @@ -870,6 +950,14 @@ func (muo *ModUpdateOne) SetCreatorID(s string) *ModUpdateOne { return muo } +// SetNillableCreatorID sets the "creator_id" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableCreatorID(s *string) *ModUpdateOne { + if s != nil { + muo.SetCreatorID(*s) + } + return muo +} + // SetApproved sets the "approved" field. func (muo *ModUpdateOne) SetApproved(b bool) *ModUpdateOne { muo.mutation.SetApproved(b) @@ -1008,6 +1096,14 @@ func (muo *ModUpdateOne) SetModReference(s string) *ModUpdateOne { return muo } +// SetNillableModReference sets the "mod_reference" field if the given value is not nil. +func (muo *ModUpdateOne) SetNillableModReference(s *string) *ModUpdateOne { + if s != nil { + muo.SetModReference(*s) + } + return muo +} + // SetHidden sets the "hidden" field. func (muo *ModUpdateOne) SetHidden(b bool) *ModUpdateOne { muo.mutation.SetHidden(b) diff --git a/generated/ent/modtag.go b/generated/ent/modtag.go index fec4075b..c896ed28 100644 --- a/generated/ent/modtag.go +++ b/generated/ent/modtag.go @@ -40,12 +40,10 @@ type ModTagEdges struct { // 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 ModTagEdges) ModOrErr() (*Mod, error) { - if e.loadedTypes[0] { - if e.Mod == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: mod.Label} - } + if e.Mod != nil { return e.Mod, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: mod.Label} } return nil, &NotLoadedError{edge: "mod"} } @@ -53,12 +51,10 @@ func (e ModTagEdges) ModOrErr() (*Mod, error) { // 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 ModTagEdges) TagOrErr() (*Tag, error) { - if e.loadedTypes[1] { - if e.Tag == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: tag.Label} - } + if e.Tag != nil { return e.Tag, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: tag.Label} } return nil, &NotLoadedError{edge: "tag"} } diff --git a/generated/ent/modtag_update.go b/generated/ent/modtag_update.go index 597f1630..6b85bccf 100644 --- a/generated/ent/modtag_update.go +++ b/generated/ent/modtag_update.go @@ -36,12 +36,28 @@ func (mtu *ModTagUpdate) SetModID(s string) *ModTagUpdate { return mtu } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (mtu *ModTagUpdate) SetNillableModID(s *string) *ModTagUpdate { + if s != nil { + mtu.SetModID(*s) + } + return mtu +} + // SetTagID sets the "tag_id" field. func (mtu *ModTagUpdate) SetTagID(s string) *ModTagUpdate { mtu.mutation.SetTagID(s) return mtu } +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (mtu *ModTagUpdate) SetNillableTagID(s *string) *ModTagUpdate { + if s != nil { + mtu.SetTagID(*s) + } + return mtu +} + // SetMod sets the "mod" edge to the Mod entity. func (mtu *ModTagUpdate) SetMod(m *Mod) *ModTagUpdate { return mtu.SetModID(m.ID) @@ -211,12 +227,28 @@ func (mtuo *ModTagUpdateOne) SetModID(s string) *ModTagUpdateOne { return mtuo } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (mtuo *ModTagUpdateOne) SetNillableModID(s *string) *ModTagUpdateOne { + if s != nil { + mtuo.SetModID(*s) + } + return mtuo +} + // SetTagID sets the "tag_id" field. func (mtuo *ModTagUpdateOne) SetTagID(s string) *ModTagUpdateOne { mtuo.mutation.SetTagID(s) return mtuo } +// SetNillableTagID sets the "tag_id" field if the given value is not nil. +func (mtuo *ModTagUpdateOne) SetNillableTagID(s *string) *ModTagUpdateOne { + if s != nil { + mtuo.SetTagID(*s) + } + return mtuo +} + // SetMod sets the "mod" edge to the Mod entity. func (mtuo *ModTagUpdateOne) SetMod(m *Mod) *ModTagUpdateOne { return mtuo.SetModID(m.ID) diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go index 3c6ddced..75f7985e 100644 --- a/generated/ent/runtime/runtime.go +++ b/generated/ent/runtime/runtime.go @@ -449,6 +449,6 @@ func init() { } const ( - Version = "v0.12.4" // Version of ent codegen. - Sum = "h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8=" // Sum of ent codegen. + Version = "v0.13.1" // Version of ent codegen. + Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. ) diff --git a/generated/ent/smlversion_update.go b/generated/ent/smlversion_update.go index 840249a9..ebe4f58e 100644 --- a/generated/ent/smlversion_update.go +++ b/generated/ent/smlversion_update.go @@ -63,6 +63,14 @@ func (svu *SmlVersionUpdate) SetVersion(s string) *SmlVersionUpdate { return svu } +// SetNillableVersion sets the "version" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableVersion(s *string) *SmlVersionUpdate { + if s != nil { + svu.SetVersion(*s) + } + return svu +} + // SetSatisfactoryVersion sets the "satisfactory_version" field. func (svu *SmlVersionUpdate) SetSatisfactoryVersion(i int) *SmlVersionUpdate { svu.mutation.ResetSatisfactoryVersion() @@ -70,6 +78,14 @@ func (svu *SmlVersionUpdate) SetSatisfactoryVersion(i int) *SmlVersionUpdate { return svu } +// SetNillableSatisfactoryVersion sets the "satisfactory_version" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableSatisfactoryVersion(i *int) *SmlVersionUpdate { + if i != nil { + svu.SetSatisfactoryVersion(*i) + } + return svu +} + // AddSatisfactoryVersion adds i to the "satisfactory_version" field. func (svu *SmlVersionUpdate) AddSatisfactoryVersion(i int) *SmlVersionUpdate { svu.mutation.AddSatisfactoryVersion(i) @@ -82,24 +98,56 @@ func (svu *SmlVersionUpdate) SetStability(u util.Stability) *SmlVersionUpdate { return svu } +// SetNillableStability sets the "stability" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableStability(u *util.Stability) *SmlVersionUpdate { + if u != nil { + svu.SetStability(*u) + } + return svu +} + // SetDate sets the "date" field. func (svu *SmlVersionUpdate) SetDate(t time.Time) *SmlVersionUpdate { svu.mutation.SetDate(t) return svu } +// SetNillableDate sets the "date" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableDate(t *time.Time) *SmlVersionUpdate { + if t != nil { + svu.SetDate(*t) + } + return svu +} + // SetLink sets the "link" field. func (svu *SmlVersionUpdate) SetLink(s string) *SmlVersionUpdate { svu.mutation.SetLink(s) return svu } +// SetNillableLink sets the "link" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableLink(s *string) *SmlVersionUpdate { + if s != nil { + svu.SetLink(*s) + } + return svu +} + // SetChangelog sets the "changelog" field. func (svu *SmlVersionUpdate) SetChangelog(s string) *SmlVersionUpdate { svu.mutation.SetChangelog(s) return svu } +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (svu *SmlVersionUpdate) SetNillableChangelog(s *string) *SmlVersionUpdate { + if s != nil { + svu.SetChangelog(*s) + } + return svu +} + // SetBootstrapVersion sets the "bootstrap_version" field. func (svu *SmlVersionUpdate) SetBootstrapVersion(s string) *SmlVersionUpdate { svu.mutation.SetBootstrapVersion(s) @@ -398,6 +446,14 @@ func (svuo *SmlVersionUpdateOne) SetVersion(s string) *SmlVersionUpdateOne { return svuo } +// SetNillableVersion sets the "version" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableVersion(s *string) *SmlVersionUpdateOne { + if s != nil { + svuo.SetVersion(*s) + } + return svuo +} + // SetSatisfactoryVersion sets the "satisfactory_version" field. func (svuo *SmlVersionUpdateOne) SetSatisfactoryVersion(i int) *SmlVersionUpdateOne { svuo.mutation.ResetSatisfactoryVersion() @@ -405,6 +461,14 @@ func (svuo *SmlVersionUpdateOne) SetSatisfactoryVersion(i int) *SmlVersionUpdate return svuo } +// SetNillableSatisfactoryVersion sets the "satisfactory_version" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableSatisfactoryVersion(i *int) *SmlVersionUpdateOne { + if i != nil { + svuo.SetSatisfactoryVersion(*i) + } + return svuo +} + // AddSatisfactoryVersion adds i to the "satisfactory_version" field. func (svuo *SmlVersionUpdateOne) AddSatisfactoryVersion(i int) *SmlVersionUpdateOne { svuo.mutation.AddSatisfactoryVersion(i) @@ -417,24 +481,56 @@ func (svuo *SmlVersionUpdateOne) SetStability(u util.Stability) *SmlVersionUpdat return svuo } +// SetNillableStability sets the "stability" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableStability(u *util.Stability) *SmlVersionUpdateOne { + if u != nil { + svuo.SetStability(*u) + } + return svuo +} + // SetDate sets the "date" field. func (svuo *SmlVersionUpdateOne) SetDate(t time.Time) *SmlVersionUpdateOne { svuo.mutation.SetDate(t) return svuo } +// SetNillableDate sets the "date" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableDate(t *time.Time) *SmlVersionUpdateOne { + if t != nil { + svuo.SetDate(*t) + } + return svuo +} + // SetLink sets the "link" field. func (svuo *SmlVersionUpdateOne) SetLink(s string) *SmlVersionUpdateOne { svuo.mutation.SetLink(s) return svuo } +// SetNillableLink sets the "link" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableLink(s *string) *SmlVersionUpdateOne { + if s != nil { + svuo.SetLink(*s) + } + return svuo +} + // SetChangelog sets the "changelog" field. func (svuo *SmlVersionUpdateOne) SetChangelog(s string) *SmlVersionUpdateOne { svuo.mutation.SetChangelog(s) return svuo } +// SetNillableChangelog sets the "changelog" field if the given value is not nil. +func (svuo *SmlVersionUpdateOne) SetNillableChangelog(s *string) *SmlVersionUpdateOne { + if s != nil { + svuo.SetChangelog(*s) + } + return svuo +} + // SetBootstrapVersion sets the "bootstrap_version" field. func (svuo *SmlVersionUpdateOne) SetBootstrapVersion(s string) *SmlVersionUpdateOne { svuo.mutation.SetBootstrapVersion(s) diff --git a/generated/ent/smlversiontarget.go b/generated/ent/smlversiontarget.go index b5fb2374..e9d24931 100644 --- a/generated/ent/smlversiontarget.go +++ b/generated/ent/smlversiontarget.go @@ -41,12 +41,10 @@ type SmlVersionTargetEdges struct { // SmlVersionOrErr returns the SmlVersion value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e SmlVersionTargetEdges) SmlVersionOrErr() (*SmlVersion, error) { - if e.loadedTypes[0] { - if e.SmlVersion == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: smlversion.Label} - } + if e.SmlVersion != nil { return e.SmlVersion, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: smlversion.Label} } return nil, &NotLoadedError{edge: "sml_version"} } diff --git a/generated/ent/smlversiontarget_update.go b/generated/ent/smlversiontarget_update.go index 94bcffab..cf88369e 100644 --- a/generated/ent/smlversiontarget_update.go +++ b/generated/ent/smlversiontarget_update.go @@ -35,18 +35,42 @@ func (svtu *SmlVersionTargetUpdate) SetVersionID(s string) *SmlVersionTargetUpda return svtu } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (svtu *SmlVersionTargetUpdate) SetNillableVersionID(s *string) *SmlVersionTargetUpdate { + if s != nil { + svtu.SetVersionID(*s) + } + return svtu +} + // SetTargetName sets the "target_name" field. func (svtu *SmlVersionTargetUpdate) SetTargetName(s string) *SmlVersionTargetUpdate { svtu.mutation.SetTargetName(s) return svtu } +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (svtu *SmlVersionTargetUpdate) SetNillableTargetName(s *string) *SmlVersionTargetUpdate { + if s != nil { + svtu.SetTargetName(*s) + } + return svtu +} + // SetLink sets the "link" field. func (svtu *SmlVersionTargetUpdate) SetLink(s string) *SmlVersionTargetUpdate { svtu.mutation.SetLink(s) return svtu } +// SetNillableLink sets the "link" field if the given value is not nil. +func (svtu *SmlVersionTargetUpdate) SetNillableLink(s *string) *SmlVersionTargetUpdate { + if s != nil { + svtu.SetLink(*s) + } + return svtu +} + // SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by ID. func (svtu *SmlVersionTargetUpdate) SetSmlVersionID(id string) *SmlVersionTargetUpdate { svtu.mutation.SetSmlVersionID(id) @@ -185,18 +209,42 @@ func (svtuo *SmlVersionTargetUpdateOne) SetVersionID(s string) *SmlVersionTarget return svtuo } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (svtuo *SmlVersionTargetUpdateOne) SetNillableVersionID(s *string) *SmlVersionTargetUpdateOne { + if s != nil { + svtuo.SetVersionID(*s) + } + return svtuo +} + // SetTargetName sets the "target_name" field. func (svtuo *SmlVersionTargetUpdateOne) SetTargetName(s string) *SmlVersionTargetUpdateOne { svtuo.mutation.SetTargetName(s) return svtuo } +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (svtuo *SmlVersionTargetUpdateOne) SetNillableTargetName(s *string) *SmlVersionTargetUpdateOne { + if s != nil { + svtuo.SetTargetName(*s) + } + return svtuo +} + // SetLink sets the "link" field. func (svtuo *SmlVersionTargetUpdateOne) SetLink(s string) *SmlVersionTargetUpdateOne { svtuo.mutation.SetLink(s) return svtuo } +// SetNillableLink sets the "link" field if the given value is not nil. +func (svtuo *SmlVersionTargetUpdateOne) SetNillableLink(s *string) *SmlVersionTargetUpdateOne { + if s != nil { + svtuo.SetLink(*s) + } + return svtuo +} + // SetSmlVersionID sets the "sml_version" edge to the SmlVersion entity by ID. func (svtuo *SmlVersionTargetUpdateOne) SetSmlVersionID(id string) *SmlVersionTargetUpdateOne { svtuo.mutation.SetSmlVersionID(id) diff --git a/generated/ent/tag_update.go b/generated/ent/tag_update.go index 8fd148dd..ace34e95 100644 --- a/generated/ent/tag_update.go +++ b/generated/ent/tag_update.go @@ -63,6 +63,14 @@ func (tu *TagUpdate) SetName(s string) *TagUpdate { return tu } +// SetNillableName sets the "name" field if the given value is not nil. +func (tu *TagUpdate) SetNillableName(s *string) *TagUpdate { + if s != nil { + tu.SetName(*s) + } + return tu +} + // AddModIDs adds the "mods" edge to the Mod entity by IDs. func (tu *TagUpdate) AddModIDs(ids ...string) *TagUpdate { tu.mutation.AddModIDs(ids...) @@ -366,6 +374,14 @@ func (tuo *TagUpdateOne) SetName(s string) *TagUpdateOne { return tuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (tuo *TagUpdateOne) SetNillableName(s *string) *TagUpdateOne { + if s != nil { + tuo.SetName(*s) + } + return tuo +} + // AddModIDs adds the "mods" edge to the Mod entity by IDs. func (tuo *TagUpdateOne) AddModIDs(ids ...string) *TagUpdateOne { tuo.mutation.AddModIDs(ids...) diff --git a/generated/ent/user_update.go b/generated/ent/user_update.go index d015907e..19316f74 100644 --- a/generated/ent/user_update.go +++ b/generated/ent/user_update.go @@ -65,12 +65,28 @@ func (uu *UserUpdate) SetEmail(s string) *UserUpdate { return uu } +// SetNillableEmail sets the "email" field if the given value is not nil. +func (uu *UserUpdate) SetNillableEmail(s *string) *UserUpdate { + if s != nil { + uu.SetEmail(*s) + } + return uu +} + // SetUsername sets the "username" field. func (uu *UserUpdate) SetUsername(s string) *UserUpdate { uu.mutation.SetUsername(s) return uu } +// SetNillableUsername sets the "username" field if the given value is not nil. +func (uu *UserUpdate) SetNillableUsername(s *string) *UserUpdate { + if s != nil { + uu.SetUsername(*s) + } + return uu +} + // SetAvatar sets the "avatar" field. func (uu *UserUpdate) SetAvatar(s string) *UserUpdate { uu.mutation.SetAvatar(s) @@ -733,12 +749,28 @@ func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { return uuo } +// SetNillableEmail sets the "email" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableEmail(s *string) *UserUpdateOne { + if s != nil { + uuo.SetEmail(*s) + } + return uuo +} + // SetUsername sets the "username" field. func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { uuo.mutation.SetUsername(s) return uuo } +// SetNillableUsername sets the "username" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableUsername(s *string) *UserUpdateOne { + if s != nil { + uuo.SetUsername(*s) + } + return uuo +} + // SetAvatar sets the "avatar" field. func (uuo *UserUpdateOne) SetAvatar(s string) *UserUpdateOne { uuo.mutation.SetAvatar(s) diff --git a/generated/ent/usergroup.go b/generated/ent/usergroup.go index 6b41c6d2..59987e84 100644 --- a/generated/ent/usergroup.go +++ b/generated/ent/usergroup.go @@ -46,12 +46,10 @@ type UserGroupEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserGroupEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/generated/ent/usergroup_update.go b/generated/ent/usergroup_update.go index d5bf3f5e..7846844a 100644 --- a/generated/ent/usergroup_update.go +++ b/generated/ent/usergroup_update.go @@ -62,12 +62,28 @@ func (ugu *UserGroupUpdate) SetUserID(s string) *UserGroupUpdate { return ugu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (ugu *UserGroupUpdate) SetNillableUserID(s *string) *UserGroupUpdate { + if s != nil { + ugu.SetUserID(*s) + } + return ugu +} + // SetGroupID sets the "group_id" field. func (ugu *UserGroupUpdate) SetGroupID(s string) *UserGroupUpdate { ugu.mutation.SetGroupID(s) return ugu } +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (ugu *UserGroupUpdate) SetNillableGroupID(s *string) *UserGroupUpdate { + if s != nil { + ugu.SetGroupID(*s) + } + return ugu +} + // SetUser sets the "user" edge to the User entity. func (ugu *UserGroupUpdate) SetUser(u *User) *UserGroupUpdate { return ugu.SetUserID(u.ID) @@ -257,12 +273,28 @@ func (uguo *UserGroupUpdateOne) SetUserID(s string) *UserGroupUpdateOne { return uguo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (uguo *UserGroupUpdateOne) SetNillableUserID(s *string) *UserGroupUpdateOne { + if s != nil { + uguo.SetUserID(*s) + } + return uguo +} + // SetGroupID sets the "group_id" field. func (uguo *UserGroupUpdateOne) SetGroupID(s string) *UserGroupUpdateOne { uguo.mutation.SetGroupID(s) return uguo } +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (uguo *UserGroupUpdateOne) SetNillableGroupID(s *string) *UserGroupUpdateOne { + if s != nil { + uguo.SetGroupID(*s) + } + return uguo +} + // SetUser sets the "user" edge to the User entity. func (uguo *UserGroupUpdateOne) SetUser(u *User) *UserGroupUpdateOne { return uguo.SetUserID(u.ID) diff --git a/generated/ent/usermod.go b/generated/ent/usermod.go index ccd0952c..64f18ba2 100644 --- a/generated/ent/usermod.go +++ b/generated/ent/usermod.go @@ -42,12 +42,10 @@ type UserModEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserModEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } @@ -55,12 +53,10 @@ func (e UserModEdges) UserOrErr() (*User, error) { // 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 UserModEdges) ModOrErr() (*Mod, error) { - if e.loadedTypes[1] { - if e.Mod == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: mod.Label} - } + if e.Mod != nil { return e.Mod, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: mod.Label} } return nil, &NotLoadedError{edge: "mod"} } diff --git a/generated/ent/usermod_update.go b/generated/ent/usermod_update.go index 87177a17..f0b98f02 100644 --- a/generated/ent/usermod_update.go +++ b/generated/ent/usermod_update.go @@ -36,18 +36,42 @@ func (umu *UserModUpdate) SetUserID(s string) *UserModUpdate { return umu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (umu *UserModUpdate) SetNillableUserID(s *string) *UserModUpdate { + if s != nil { + umu.SetUserID(*s) + } + return umu +} + // SetModID sets the "mod_id" field. func (umu *UserModUpdate) SetModID(s string) *UserModUpdate { umu.mutation.SetModID(s) return umu } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (umu *UserModUpdate) SetNillableModID(s *string) *UserModUpdate { + if s != nil { + umu.SetModID(*s) + } + return umu +} + // SetRole sets the "role" field. func (umu *UserModUpdate) SetRole(s string) *UserModUpdate { umu.mutation.SetRole(s) return umu } +// SetNillableRole sets the "role" field if the given value is not nil. +func (umu *UserModUpdate) SetNillableRole(s *string) *UserModUpdate { + if s != nil { + umu.SetRole(*s) + } + return umu +} + // SetUser sets the "user" edge to the User entity. func (umu *UserModUpdate) SetUser(u *User) *UserModUpdate { return umu.SetUserID(u.ID) @@ -220,18 +244,42 @@ func (umuo *UserModUpdateOne) SetUserID(s string) *UserModUpdateOne { return umuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (umuo *UserModUpdateOne) SetNillableUserID(s *string) *UserModUpdateOne { + if s != nil { + umuo.SetUserID(*s) + } + return umuo +} + // SetModID sets the "mod_id" field. func (umuo *UserModUpdateOne) SetModID(s string) *UserModUpdateOne { umuo.mutation.SetModID(s) return umuo } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (umuo *UserModUpdateOne) SetNillableModID(s *string) *UserModUpdateOne { + if s != nil { + umuo.SetModID(*s) + } + return umuo +} + // SetRole sets the "role" field. func (umuo *UserModUpdateOne) SetRole(s string) *UserModUpdateOne { umuo.mutation.SetRole(s) return umuo } +// SetNillableRole sets the "role" field if the given value is not nil. +func (umuo *UserModUpdateOne) SetNillableRole(s *string) *UserModUpdateOne { + if s != nil { + umuo.SetRole(*s) + } + return umuo +} + // SetUser sets the "user" edge to the User entity. func (umuo *UserModUpdateOne) SetUser(u *User) *UserModUpdateOne { return umuo.SetUserID(u.ID) diff --git a/generated/ent/usersession.go b/generated/ent/usersession.go index 0da1f1fe..83c1df7d 100644 --- a/generated/ent/usersession.go +++ b/generated/ent/usersession.go @@ -47,12 +47,10 @@ type UserSessionEdges struct { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserSessionEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/generated/ent/usersession_update.go b/generated/ent/usersession_update.go index ea7bebf8..46631505 100644 --- a/generated/ent/usersession_update.go +++ b/generated/ent/usersession_update.go @@ -62,6 +62,14 @@ func (usu *UserSessionUpdate) SetToken(s string) *UserSessionUpdate { return usu } +// SetNillableToken sets the "token" field if the given value is not nil. +func (usu *UserSessionUpdate) SetNillableToken(s *string) *UserSessionUpdate { + if s != nil { + usu.SetToken(*s) + } + return usu +} + // SetUserAgent sets the "user_agent" field. func (usu *UserSessionUpdate) SetUserAgent(s string) *UserSessionUpdate { usu.mutation.SetUserAgent(s) @@ -278,6 +286,14 @@ func (usuo *UserSessionUpdateOne) SetToken(s string) *UserSessionUpdateOne { return usuo } +// SetNillableToken sets the "token" field if the given value is not nil. +func (usuo *UserSessionUpdateOne) SetNillableToken(s *string) *UserSessionUpdateOne { + if s != nil { + usuo.SetToken(*s) + } + return usuo +} + // SetUserAgent sets the "user_agent" field. func (usuo *UserSessionUpdateOne) SetUserAgent(s string) *UserSessionUpdateOne { usuo.mutation.SetUserAgent(s) diff --git a/generated/ent/version.go b/generated/ent/version.go index 30d37906..677174d6 100644 --- a/generated/ent/version.go +++ b/generated/ent/version.go @@ -83,12 +83,10 @@ type VersionEdges struct { // 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 VersionEdges) ModOrErr() (*Mod, error) { - if e.loadedTypes[0] { - if e.Mod == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: mod.Label} - } + if e.Mod != nil { return e.Mod, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: mod.Label} } return nil, &NotLoadedError{edge: "mod"} } diff --git a/generated/ent/version_update.go b/generated/ent/version_update.go index c2a5fe01..452a7e87 100644 --- a/generated/ent/version_update.go +++ b/generated/ent/version_update.go @@ -64,18 +64,42 @@ func (vu *VersionUpdate) SetModID(s string) *VersionUpdate { return vu } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableModID(s *string) *VersionUpdate { + if s != nil { + vu.SetModID(*s) + } + return vu +} + // SetVersion sets the "version" field. func (vu *VersionUpdate) SetVersion(s string) *VersionUpdate { vu.mutation.SetVersion(s) return vu } +// SetNillableVersion sets the "version" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableVersion(s *string) *VersionUpdate { + if s != nil { + vu.SetVersion(*s) + } + return vu +} + // SetSmlVersion sets the "sml_version" field. func (vu *VersionUpdate) SetSmlVersion(s string) *VersionUpdate { vu.mutation.SetSmlVersion(s) return vu } +// SetNillableSmlVersion sets the "sml_version" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableSmlVersion(s *string) *VersionUpdate { + if s != nil { + vu.SetSmlVersion(*s) + } + return vu +} + // SetChangelog sets the "changelog" field. func (vu *VersionUpdate) SetChangelog(s string) *VersionUpdate { vu.mutation.SetChangelog(s) @@ -143,6 +167,14 @@ func (vu *VersionUpdate) SetStability(u util.Stability) *VersionUpdate { return vu } +// SetNillableStability sets the "stability" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableStability(u *util.Stability) *VersionUpdate { + if u != nil { + vu.SetStability(*u) + } + return vu +} + // SetApproved sets the "approved" field. func (vu *VersionUpdate) SetApproved(b bool) *VersionUpdate { vu.mutation.SetApproved(b) @@ -218,6 +250,14 @@ func (vu *VersionUpdate) SetModReference(s string) *VersionUpdate { return vu } +// SetNillableModReference sets the "mod_reference" field if the given value is not nil. +func (vu *VersionUpdate) SetNillableModReference(s *string) *VersionUpdate { + if s != nil { + vu.SetModReference(*s) + } + return vu +} + // SetVersionMajor sets the "version_major" field. func (vu *VersionUpdate) SetVersionMajor(i int) *VersionUpdate { vu.mutation.ResetVersionMajor() @@ -811,18 +851,42 @@ func (vuo *VersionUpdateOne) SetModID(s string) *VersionUpdateOne { return vuo } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableModID(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetModID(*s) + } + return vuo +} + // SetVersion sets the "version" field. func (vuo *VersionUpdateOne) SetVersion(s string) *VersionUpdateOne { vuo.mutation.SetVersion(s) return vuo } +// SetNillableVersion sets the "version" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableVersion(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetVersion(*s) + } + return vuo +} + // SetSmlVersion sets the "sml_version" field. func (vuo *VersionUpdateOne) SetSmlVersion(s string) *VersionUpdateOne { vuo.mutation.SetSmlVersion(s) return vuo } +// SetNillableSmlVersion sets the "sml_version" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableSmlVersion(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetSmlVersion(*s) + } + return vuo +} + // SetChangelog sets the "changelog" field. func (vuo *VersionUpdateOne) SetChangelog(s string) *VersionUpdateOne { vuo.mutation.SetChangelog(s) @@ -890,6 +954,14 @@ func (vuo *VersionUpdateOne) SetStability(u util.Stability) *VersionUpdateOne { return vuo } +// SetNillableStability sets the "stability" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableStability(u *util.Stability) *VersionUpdateOne { + if u != nil { + vuo.SetStability(*u) + } + return vuo +} + // SetApproved sets the "approved" field. func (vuo *VersionUpdateOne) SetApproved(b bool) *VersionUpdateOne { vuo.mutation.SetApproved(b) @@ -965,6 +1037,14 @@ func (vuo *VersionUpdateOne) SetModReference(s string) *VersionUpdateOne { return vuo } +// SetNillableModReference sets the "mod_reference" field if the given value is not nil. +func (vuo *VersionUpdateOne) SetNillableModReference(s *string) *VersionUpdateOne { + if s != nil { + vuo.SetModReference(*s) + } + return vuo +} + // SetVersionMajor sets the "version_major" field. func (vuo *VersionUpdateOne) SetVersionMajor(i int) *VersionUpdateOne { vuo.mutation.ResetVersionMajor() diff --git a/generated/ent/versiondependency.go b/generated/ent/versiondependency.go index 589b6cc0..2c0d0b28 100644 --- a/generated/ent/versiondependency.go +++ b/generated/ent/versiondependency.go @@ -51,12 +51,10 @@ type VersionDependencyEdges struct { // VersionOrErr returns the Version value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e VersionDependencyEdges) VersionOrErr() (*Version, error) { - if e.loadedTypes[0] { - if e.Version == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: version.Label} - } + if e.Version != nil { return e.Version, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: version.Label} } return nil, &NotLoadedError{edge: "version"} } @@ -64,12 +62,10 @@ func (e VersionDependencyEdges) VersionOrErr() (*Version, error) { // 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 VersionDependencyEdges) ModOrErr() (*Mod, error) { - if e.loadedTypes[1] { - if e.Mod == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: mod.Label} - } + if e.Mod != nil { return e.Mod, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: mod.Label} } return nil, &NotLoadedError{edge: "mod"} } diff --git a/generated/ent/versiondependency_update.go b/generated/ent/versiondependency_update.go index 80e77220..59604287 100644 --- a/generated/ent/versiondependency_update.go +++ b/generated/ent/versiondependency_update.go @@ -63,24 +63,56 @@ func (vdu *VersionDependencyUpdate) SetVersionID(s string) *VersionDependencyUpd return vdu } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (vdu *VersionDependencyUpdate) SetNillableVersionID(s *string) *VersionDependencyUpdate { + if s != nil { + vdu.SetVersionID(*s) + } + return vdu +} + // SetModID sets the "mod_id" field. func (vdu *VersionDependencyUpdate) SetModID(s string) *VersionDependencyUpdate { vdu.mutation.SetModID(s) return vdu } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (vdu *VersionDependencyUpdate) SetNillableModID(s *string) *VersionDependencyUpdate { + if s != nil { + vdu.SetModID(*s) + } + return vdu +} + // SetCondition sets the "condition" field. func (vdu *VersionDependencyUpdate) SetCondition(s string) *VersionDependencyUpdate { vdu.mutation.SetCondition(s) return vdu } +// SetNillableCondition sets the "condition" field if the given value is not nil. +func (vdu *VersionDependencyUpdate) SetNillableCondition(s *string) *VersionDependencyUpdate { + if s != nil { + vdu.SetCondition(*s) + } + return vdu +} + // SetOptional sets the "optional" field. func (vdu *VersionDependencyUpdate) SetOptional(b bool) *VersionDependencyUpdate { vdu.mutation.SetOptional(b) return vdu } +// SetNillableOptional sets the "optional" field if the given value is not nil. +func (vdu *VersionDependencyUpdate) SetNillableOptional(b *bool) *VersionDependencyUpdate { + if b != nil { + vdu.SetOptional(*b) + } + return vdu +} + // SetVersion sets the "version" edge to the Version entity. func (vdu *VersionDependencyUpdate) SetVersion(v *Version) *VersionDependencyUpdate { return vdu.SetVersionID(v.ID) @@ -311,24 +343,56 @@ func (vduo *VersionDependencyUpdateOne) SetVersionID(s string) *VersionDependenc return vduo } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (vduo *VersionDependencyUpdateOne) SetNillableVersionID(s *string) *VersionDependencyUpdateOne { + if s != nil { + vduo.SetVersionID(*s) + } + return vduo +} + // SetModID sets the "mod_id" field. func (vduo *VersionDependencyUpdateOne) SetModID(s string) *VersionDependencyUpdateOne { vduo.mutation.SetModID(s) return vduo } +// SetNillableModID sets the "mod_id" field if the given value is not nil. +func (vduo *VersionDependencyUpdateOne) SetNillableModID(s *string) *VersionDependencyUpdateOne { + if s != nil { + vduo.SetModID(*s) + } + return vduo +} + // SetCondition sets the "condition" field. func (vduo *VersionDependencyUpdateOne) SetCondition(s string) *VersionDependencyUpdateOne { vduo.mutation.SetCondition(s) return vduo } +// SetNillableCondition sets the "condition" field if the given value is not nil. +func (vduo *VersionDependencyUpdateOne) SetNillableCondition(s *string) *VersionDependencyUpdateOne { + if s != nil { + vduo.SetCondition(*s) + } + return vduo +} + // SetOptional sets the "optional" field. func (vduo *VersionDependencyUpdateOne) SetOptional(b bool) *VersionDependencyUpdateOne { vduo.mutation.SetOptional(b) return vduo } +// SetNillableOptional sets the "optional" field if the given value is not nil. +func (vduo *VersionDependencyUpdateOne) SetNillableOptional(b *bool) *VersionDependencyUpdateOne { + if b != nil { + vduo.SetOptional(*b) + } + return vduo +} + // SetVersion sets the "version" edge to the Version entity. func (vduo *VersionDependencyUpdateOne) SetVersion(v *Version) *VersionDependencyUpdateOne { return vduo.SetVersionID(v.ID) diff --git a/generated/ent/versiontarget.go b/generated/ent/versiontarget.go index 6d87097b..391f3764 100644 --- a/generated/ent/versiontarget.go +++ b/generated/ent/versiontarget.go @@ -45,12 +45,10 @@ type VersionTargetEdges struct { // SmlVersionOrErr returns the SmlVersion value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e VersionTargetEdges) SmlVersionOrErr() (*Version, error) { - if e.loadedTypes[0] { - if e.SmlVersion == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: version.Label} - } + if e.SmlVersion != nil { return e.SmlVersion, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: version.Label} } return nil, &NotLoadedError{edge: "sml_version"} } diff --git a/generated/ent/versiontarget_update.go b/generated/ent/versiontarget_update.go index e592b543..9e4a7aaa 100644 --- a/generated/ent/versiontarget_update.go +++ b/generated/ent/versiontarget_update.go @@ -35,12 +35,28 @@ func (vtu *VersionTargetUpdate) SetVersionID(s string) *VersionTargetUpdate { return vtu } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (vtu *VersionTargetUpdate) SetNillableVersionID(s *string) *VersionTargetUpdate { + if s != nil { + vtu.SetVersionID(*s) + } + return vtu +} + // SetTargetName sets the "target_name" field. func (vtu *VersionTargetUpdate) SetTargetName(s string) *VersionTargetUpdate { vtu.mutation.SetTargetName(s) return vtu } +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (vtu *VersionTargetUpdate) SetNillableTargetName(s *string) *VersionTargetUpdate { + if s != nil { + vtu.SetTargetName(*s) + } + return vtu +} + // SetKey sets the "key" field. func (vtu *VersionTargetUpdate) SetKey(s string) *VersionTargetUpdate { vtu.mutation.SetKey(s) @@ -264,12 +280,28 @@ func (vtuo *VersionTargetUpdateOne) SetVersionID(s string) *VersionTargetUpdateO return vtuo } +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (vtuo *VersionTargetUpdateOne) SetNillableVersionID(s *string) *VersionTargetUpdateOne { + if s != nil { + vtuo.SetVersionID(*s) + } + return vtuo +} + // SetTargetName sets the "target_name" field. func (vtuo *VersionTargetUpdateOne) SetTargetName(s string) *VersionTargetUpdateOne { vtuo.mutation.SetTargetName(s) return vtuo } +// SetNillableTargetName sets the "target_name" field if the given value is not nil. +func (vtuo *VersionTargetUpdateOne) SetNillableTargetName(s *string) *VersionTargetUpdateOne { + if s != nil { + vtuo.SetTargetName(*s) + } + return vtuo +} + // SetKey sets the "key" field. func (vtuo *VersionTargetUpdateOne) SetKey(s string) *VersionTargetUpdateOne { vtuo.mutation.SetKey(s) diff --git a/generated/generated.go b/generated/generated.go index dd6be213..6da140b2 100644 --- a/generated/generated.go +++ b/generated/generated.go @@ -2167,6 +2167,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputCompatibilityInfoInput, ec.unmarshalInputCompatibilityInput, + ec.unmarshalInputGuideFilter, + ec.unmarshalInputModFilter, ec.unmarshalInputModVersionConstraint, ec.unmarshalInputNewAnnouncement, ec.unmarshalInputNewGuide, @@ -2174,6 +2176,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputNewSMLVersion, ec.unmarshalInputNewSMLVersionTarget, ec.unmarshalInputNewVersion, + ec.unmarshalInputSMLVersionFilter, ec.unmarshalInputTagFilter, ec.unmarshalInputUpdateAnnouncement, ec.unmarshalInputUpdateGuide, @@ -2183,6 +2186,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputUpdateUser, ec.unmarshalInputUpdateUserMod, ec.unmarshalInputUpdateVersion, + ec.unmarshalInputVersionFilter, ) first := true @@ -2719,7 +2723,7 @@ extend type Query { ### Mutations extend type Mutation { - createTag(tagName: TagName!): Tag @isLoggedIn + createTag(tagName: TagName!): Tag @canManageTags @isLoggedIn createMultipleTags(tagNames: [TagName!]!): [Tag!]! @canManageTags @isLoggedIn updateTag(tagID: TagID!, NewName: TagName!): Tag! @canManageTags @isLoggedIn deleteTag(tagID: TagID!): Boolean! @canManageTags @isLoggedIn @@ -4160,7 +4164,7 @@ func (ec *executionContext) _Announcement_id(ctx context.Context, field graphql. return ec.marshalNAnnouncementID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Announcement_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Announcement_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Announcement", Field: field, @@ -4204,7 +4208,7 @@ func (ec *executionContext) _Announcement_message(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Announcement_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Announcement_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Announcement", Field: field, @@ -4248,7 +4252,7 @@ func (ec *executionContext) _Announcement_importance(ctx context.Context, field return ec.marshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Announcement_importance(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Announcement_importance(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Announcement", Field: field, @@ -4292,7 +4296,7 @@ func (ec *executionContext) _Compatibility_state(ctx context.Context, field grap return ec.marshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Compatibility_state(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Compatibility_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Compatibility", Field: field, @@ -4333,7 +4337,7 @@ func (ec *executionContext) _Compatibility_note(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Compatibility_note(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Compatibility_note(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Compatibility", Field: field, @@ -4377,7 +4381,7 @@ func (ec *executionContext) _CompatibilityInfo_EA(ctx context.Context, field gra return ec.marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CompatibilityInfo_EA(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CompatibilityInfo_EA(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CompatibilityInfo", Field: field, @@ -4427,7 +4431,7 @@ func (ec *executionContext) _CompatibilityInfo_EXP(ctx context.Context, field gr return ec.marshalNCompatibility2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibility(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CompatibilityInfo_EXP(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CompatibilityInfo_EXP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CompatibilityInfo", Field: field, @@ -4477,7 +4481,7 @@ func (ec *executionContext) _CreateVersionResponse_auto_approved(ctx context.Con return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CreateVersionResponse_auto_approved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateVersionResponse_auto_approved(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CreateVersionResponse", Field: field, @@ -4518,7 +4522,7 @@ func (ec *executionContext) _CreateVersionResponse_version(ctx context.Context, return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CreateVersionResponse_version(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateVersionResponse_version(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CreateVersionResponse", Field: field, @@ -4598,7 +4602,7 @@ func (ec *executionContext) _GetGuides_guides(ctx context.Context, field graphql return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetGuides_guides(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetGuides_guides(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetGuides", Field: field, @@ -4664,7 +4668,7 @@ func (ec *executionContext) _GetGuides_count(ctx context.Context, field graphql. return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetGuides_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetGuides_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetGuides", Field: field, @@ -4708,7 +4712,7 @@ func (ec *executionContext) _GetMods_mods(ctx context.Context, field graphql.Col return ec.marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMods_mods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMods_mods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMods", Field: field, @@ -4800,7 +4804,7 @@ func (ec *executionContext) _GetMods_count(ctx context.Context, field graphql.Co return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMods_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMods_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMods", Field: field, @@ -4844,7 +4848,7 @@ func (ec *executionContext) _GetMyMods_mods(ctx context.Context, field graphql.C return ec.marshalNMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMyMods_mods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMyMods_mods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMyMods", Field: field, @@ -4936,7 +4940,7 @@ func (ec *executionContext) _GetMyMods_count(ctx context.Context, field graphql. return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMyMods_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMyMods_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMyMods", Field: field, @@ -4980,7 +4984,7 @@ func (ec *executionContext) _GetMyVersions_versions(ctx context.Context, field g return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMyVersions_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMyVersions_versions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMyVersions", Field: field, @@ -5060,7 +5064,7 @@ func (ec *executionContext) _GetMyVersions_count(ctx context.Context, field grap return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetMyVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetMyVersions_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetMyVersions", Field: field, @@ -5104,7 +5108,7 @@ func (ec *executionContext) _GetSMLVersions_sml_versions(ctx context.Context, fi return ec.marshalNSMLVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetSMLVersions_sml_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetSMLVersions_sml_versions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetSMLVersions", Field: field, @@ -5174,7 +5178,7 @@ func (ec *executionContext) _GetSMLVersions_count(ctx context.Context, field gra return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetSMLVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetSMLVersions_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetSMLVersions", Field: field, @@ -5218,7 +5222,7 @@ func (ec *executionContext) _GetVersions_versions(ctx context.Context, field gra return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetVersions_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetVersions_versions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetVersions", Field: field, @@ -5298,7 +5302,7 @@ func (ec *executionContext) _GetVersions_count(ctx context.Context, field graphq return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetVersions_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetVersions_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "GetVersions", Field: field, @@ -5342,7 +5346,7 @@ func (ec *executionContext) _Group_id(ctx context.Context, field graphql.Collect return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Group_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Group_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Group", Field: field, @@ -5386,7 +5390,7 @@ func (ec *executionContext) _Group_name(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Group_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Group_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Group", Field: field, @@ -5430,7 +5434,7 @@ func (ec *executionContext) _Guide_id(ctx context.Context, field graphql.Collect return ec.marshalNGuideID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5474,7 +5478,7 @@ func (ec *executionContext) _Guide_name(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5518,7 +5522,7 @@ func (ec *executionContext) _Guide_short_description(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_short_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_short_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5562,7 +5566,7 @@ func (ec *executionContext) _Guide_guide(ctx context.Context, field graphql.Coll return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_guide(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_guide(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5606,7 +5610,7 @@ func (ec *executionContext) _Guide_views(ctx context.Context, field graphql.Coll return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_views(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_views(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5650,7 +5654,7 @@ func (ec *executionContext) _Guide_user_id(ctx context.Context, field graphql.Co return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_user_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_user_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5694,7 +5698,7 @@ func (ec *executionContext) _Guide_updated_at(ctx context.Context, field graphql return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_updated_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5738,7 +5742,7 @@ func (ec *executionContext) _Guide_created_at(ctx context.Context, field graphql return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5782,7 +5786,7 @@ func (ec *executionContext) _Guide_tags(ctx context.Context, field graphql.Colle return ec.marshalNTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_tags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5832,7 +5836,7 @@ func (ec *executionContext) _Guide_user(ctx context.Context, field graphql.Colle return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Guide_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Guide_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Guide", Field: field, @@ -5899,7 +5903,7 @@ func (ec *executionContext) _LatestVersions_alpha(ctx context.Context, field gra return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LatestVersions_alpha(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LatestVersions_alpha(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LatestVersions", Field: field, @@ -5976,7 +5980,7 @@ func (ec *executionContext) _LatestVersions_beta(ctx context.Context, field grap return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LatestVersions_beta(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LatestVersions_beta(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LatestVersions", Field: field, @@ -6053,7 +6057,7 @@ func (ec *executionContext) _LatestVersions_release(ctx context.Context, field g return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LatestVersions_release(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LatestVersions_release(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LatestVersions", Field: field, @@ -6133,7 +6137,7 @@ func (ec *executionContext) _Mod_id(ctx context.Context, field graphql.Collected return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6177,7 +6181,7 @@ func (ec *executionContext) _Mod_name(ctx context.Context, field graphql.Collect return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6221,7 +6225,7 @@ func (ec *executionContext) _Mod_short_description(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_short_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_short_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6262,7 +6266,7 @@ func (ec *executionContext) _Mod_full_description(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_full_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_full_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6303,7 +6307,7 @@ func (ec *executionContext) _Mod_logo(ctx context.Context, field graphql.Collect return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_logo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_logo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6344,7 +6348,7 @@ func (ec *executionContext) _Mod_source_url(ctx context.Context, field graphql.C return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_source_url(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_source_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6388,7 +6392,7 @@ func (ec *executionContext) _Mod_creator_id(ctx context.Context, field graphql.C return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_creator_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_creator_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6432,7 +6436,7 @@ func (ec *executionContext) _Mod_approved(ctx context.Context, field graphql.Col return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_approved(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_approved(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6476,7 +6480,7 @@ func (ec *executionContext) _Mod_views(ctx context.Context, field graphql.Collec return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_views(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_views(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6520,7 +6524,7 @@ func (ec *executionContext) _Mod_downloads(ctx context.Context, field graphql.Co return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_downloads(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6564,7 +6568,7 @@ func (ec *executionContext) _Mod_hotness(ctx context.Context, field graphql.Coll return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_hotness(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_hotness(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6608,7 +6612,7 @@ func (ec *executionContext) _Mod_popularity(ctx context.Context, field graphql.C return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_popularity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_popularity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6652,7 +6656,7 @@ func (ec *executionContext) _Mod_updated_at(ctx context.Context, field graphql.C return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_updated_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6696,7 +6700,7 @@ func (ec *executionContext) _Mod_created_at(ctx context.Context, field graphql.C return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_created_at(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6737,7 +6741,7 @@ func (ec *executionContext) _Mod_last_version_date(ctx context.Context, field gr return ec.marshalODate2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_last_version_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_last_version_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6781,7 +6785,7 @@ func (ec *executionContext) _Mod_mod_reference(ctx context.Context, field graphq return ec.marshalNModReference2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_mod_reference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_mod_reference(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6825,7 +6829,7 @@ func (ec *executionContext) _Mod_hidden(ctx context.Context, field graphql.Colle return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_hidden(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_hidden(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6866,7 +6870,7 @@ func (ec *executionContext) _Mod_tags(ctx context.Context, field graphql.Collect return ec.marshalOTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_tags(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6913,7 +6917,7 @@ func (ec *executionContext) _Mod_compatibility(ctx context.Context, field graphq return ec.marshalOCompatibilityInfo2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_compatibility(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_compatibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -6963,7 +6967,7 @@ func (ec *executionContext) _Mod_authors(ctx context.Context, field graphql.Coll return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_authors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_authors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -7198,7 +7202,7 @@ func (ec *executionContext) _Mod_latestVersions(ctx context.Context, field graph return ec.marshalNLatestVersions2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐLatestVersions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mod_latestVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mod_latestVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mod", Field: field, @@ -7250,7 +7254,7 @@ func (ec *executionContext) _ModVersion_id(ctx context.Context, field graphql.Co return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ModVersion_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModVersion_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModVersion", Field: field, @@ -7294,7 +7298,7 @@ func (ec *executionContext) _ModVersion_mod_reference(ctx context.Context, field return ec.marshalNModReference2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ModVersion_mod_reference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModVersion_mod_reference(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModVersion", Field: field, @@ -7338,7 +7342,7 @@ func (ec *executionContext) _ModVersion_versions(ctx context.Context, field grap return ec.marshalNVersion2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ModVersion_versions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ModVersion_versions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModVersion", Field: field, @@ -8971,13 +8975,19 @@ func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graph return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanManageTags == nil { + return nil, errors.New("directive canManageTags is not implemented") + } + return ec.directives.CanManageTags(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { if ec.directives.IsLoggedIn == nil { return nil, 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) } @@ -9452,7 +9462,7 @@ func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql. return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_logout(ctx 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: "Mutation", Field: field, @@ -10347,7 +10357,7 @@ func (ec *executionContext) _OAuthOptions_github(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_github(ctx 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: "OAuthOptions", Field: field, @@ -10391,7 +10401,7 @@ func (ec *executionContext) _OAuthOptions_google(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_google(ctx 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: "OAuthOptions", Field: field, @@ -10435,7 +10445,7 @@ func (ec *executionContext) _OAuthOptions_facebook(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_OAuthOptions_facebook(ctx 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: "OAuthOptions", Field: field, @@ -10602,7 +10612,7 @@ func (ec *executionContext) _Query_getAnnouncements(ctx context.Context, field g return ec.marshalNAnnouncement2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getAnnouncements(ctx 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: "Query", Field: field, @@ -11800,7 +11810,7 @@ func (ec *executionContext) _Query_getMe(ctx context.Context, field graphql.Coll return ec.marshalOUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_getMe(ctx 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: "Query", Field: field, @@ -12586,7 +12596,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx 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: "Query", Field: field, @@ -12644,7 +12654,7 @@ func (ec *executionContext) _SMLVersion_id(ctx context.Context, field graphql.Co return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_id(ctx 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: "SMLVersion", Field: field, @@ -12688,7 +12698,7 @@ func (ec *executionContext) _SMLVersion_version(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_version(ctx 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: "SMLVersion", Field: field, @@ -12732,7 +12742,7 @@ func (ec *executionContext) _SMLVersion_satisfactory_version(ctx context.Context return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_satisfactory_version(ctx 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: "SMLVersion", Field: field, @@ -12776,7 +12786,7 @@ func (ec *executionContext) _SMLVersion_stability(ctx context.Context, field gra return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_stability(ctx 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: "SMLVersion", Field: field, @@ -12820,7 +12830,7 @@ func (ec *executionContext) _SMLVersion_link(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_link(ctx 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: "SMLVersion", Field: field, @@ -12864,7 +12874,7 @@ func (ec *executionContext) _SMLVersion_targets(ctx context.Context, field graph return ec.marshalNSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_targets(ctx 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: "SMLVersion", Field: field, @@ -12916,7 +12926,7 @@ func (ec *executionContext) _SMLVersion_changelog(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_changelog(ctx 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: "SMLVersion", Field: field, @@ -12960,7 +12970,7 @@ func (ec *executionContext) _SMLVersion_date(ctx context.Context, field graphql. return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_date(ctx 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: "SMLVersion", Field: field, @@ -13001,7 +13011,7 @@ func (ec *executionContext) _SMLVersion_bootstrap_version(ctx context.Context, f return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_bootstrap_version(ctx 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: "SMLVersion", Field: field, @@ -13045,7 +13055,7 @@ func (ec *executionContext) _SMLVersion_engine_version(ctx context.Context, fiel return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_engine_version(ctx 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: "SMLVersion", Field: field, @@ -13089,7 +13099,7 @@ func (ec *executionContext) _SMLVersion_updated_at(ctx context.Context, field gr return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_updated_at(ctx 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: "SMLVersion", Field: field, @@ -13133,7 +13143,7 @@ func (ec *executionContext) _SMLVersion_created_at(ctx context.Context, field gr return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersion_created_at(ctx 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: "SMLVersion", Field: field, @@ -13177,7 +13187,7 @@ func (ec *executionContext) _SMLVersionTarget_VersionID(ctx context.Context, fie return ec.marshalNSMLVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_VersionID(ctx 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: "SMLVersionTarget", Field: field, @@ -13221,7 +13231,7 @@ func (ec *executionContext) _SMLVersionTarget_targetName(ctx context.Context, fi return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_targetName(ctx 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: "SMLVersionTarget", Field: field, @@ -13265,7 +13275,7 @@ func (ec *executionContext) _SMLVersionTarget_link(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SMLVersionTarget_link(ctx 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: "SMLVersionTarget", Field: field, @@ -13309,7 +13319,7 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected return ec.marshalNTagID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_id(ctx 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: "Tag", Field: field, @@ -13353,7 +13363,7 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect return ec.marshalNTagName2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_name(ctx 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: "Tag", Field: field, @@ -13397,7 +13407,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(ctx 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: "User", Field: field, @@ -13472,7 +13482,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_email(ctx 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: "User", Field: field, @@ -13516,7 +13526,7 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_username(ctx 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: "User", Field: field, @@ -13557,7 +13567,7 @@ func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_avatar(ctx 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: "User", Field: field, @@ -13601,7 +13611,7 @@ func (ec *executionContext) _User_created_at(ctx context.Context, field graphql. return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_created_at(ctx 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: "User", Field: field, @@ -13676,7 +13686,7 @@ func (ec *executionContext) _User_github_id(ctx context.Context, field graphql.C return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_github_id(ctx 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: "User", Field: field, @@ -13751,7 +13761,7 @@ func (ec *executionContext) _User_google_id(ctx context.Context, field graphql.C return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_google_id(ctx 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: "User", Field: field, @@ -13826,7 +13836,7 @@ func (ec *executionContext) _User_facebook_id(ctx context.Context, field graphql return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_facebook_id(ctx 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: "User", Field: field, @@ -13904,7 +13914,7 @@ func (ec *executionContext) _User_roles(ctx context.Context, field graphql.Colle return ec.marshalNUserRoles2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserRoles(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_roles(ctx 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: "User", Field: field, @@ -14000,7 +14010,7 @@ func (ec *executionContext) _User_groups(ctx context.Context, field graphql.Coll return ec.marshalNGroup2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGroupᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_groups(ctx 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: "User", Field: field, @@ -14050,7 +14060,7 @@ func (ec *executionContext) _User_mods(ctx context.Context, field graphql.Collec return ec.marshalNUserMod2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUserModᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_mods(ctx 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: "User", Field: field, @@ -14106,7 +14116,7 @@ func (ec *executionContext) _User_guides(ctx context.Context, field graphql.Coll return ec.marshalNGuide2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_guides(ctx 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: "User", Field: field, @@ -14172,7 +14182,7 @@ func (ec *executionContext) _UserMod_user_id(ctx context.Context, field graphql. return ec.marshalNUserID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_user_id(ctx 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: "UserMod", Field: field, @@ -14216,7 +14226,7 @@ func (ec *executionContext) _UserMod_mod_id(ctx context.Context, field graphql.C return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_mod_id(ctx 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: "UserMod", Field: field, @@ -14260,7 +14270,7 @@ func (ec *executionContext) _UserMod_role(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_role(ctx 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: "UserMod", Field: field, @@ -14304,7 +14314,7 @@ func (ec *executionContext) _UserMod_user(ctx context.Context, field graphql.Col return ec.marshalNUser2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_user(ctx 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: "UserMod", Field: field, @@ -14374,7 +14384,7 @@ func (ec *executionContext) _UserMod_mod(ctx context.Context, field graphql.Coll return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserMod_mod(ctx 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: "UserMod", Field: field, @@ -14466,7 +14476,7 @@ func (ec *executionContext) _UserRoles_approveMods(ctx context.Context, field gr return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_approveMods(ctx 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: "UserRoles", Field: field, @@ -14510,7 +14520,7 @@ func (ec *executionContext) _UserRoles_approveVersions(ctx context.Context, fiel return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_approveVersions(ctx 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: "UserRoles", Field: field, @@ -14554,7 +14564,7 @@ func (ec *executionContext) _UserRoles_deleteContent(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_deleteContent(ctx 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: "UserRoles", Field: field, @@ -14598,7 +14608,7 @@ func (ec *executionContext) _UserRoles_editContent(ctx context.Context, field gr return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editContent(ctx 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: "UserRoles", Field: field, @@ -14642,7 +14652,7 @@ func (ec *executionContext) _UserRoles_editUsers(ctx context.Context, field grap return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editUsers(ctx 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: "UserRoles", Field: field, @@ -14686,7 +14696,7 @@ func (ec *executionContext) _UserRoles_editSMLVersions(ctx context.Context, fiel return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editSMLVersions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserRoles_editSMLVersions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserRoles", Field: field, @@ -14730,7 +14740,7 @@ func (ec *executionContext) _UserRoles_editBootstrapVersions(ctx context.Context return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editBootstrapVersions(ctx 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: "UserRoles", Field: field, @@ -14774,7 +14784,7 @@ func (ec *executionContext) _UserRoles_editAnyModCompatibility(ctx context.Conte return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserRoles_editAnyModCompatibility(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: "UserRoles", Field: field, @@ -14818,7 +14828,7 @@ func (ec *executionContext) _UserSession_token(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserSession_token(ctx 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: "UserSession", Field: field, @@ -14862,7 +14872,7 @@ func (ec *executionContext) _Version_id(ctx context.Context, field graphql.Colle return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_id(ctx 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: "Version", Field: field, @@ -14906,7 +14916,7 @@ func (ec *executionContext) _Version_mod_id(ctx context.Context, field graphql.C return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_mod_id(ctx 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: "Version", Field: field, @@ -14950,7 +14960,7 @@ func (ec *executionContext) _Version_version(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_version(ctx 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: "Version", Field: field, @@ -14994,7 +15004,7 @@ func (ec *executionContext) _Version_sml_version(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_sml_version(ctx 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: "Version", Field: field, @@ -15038,7 +15048,7 @@ func (ec *executionContext) _Version_changelog(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_changelog(ctx 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: "Version", Field: field, @@ -15082,7 +15092,7 @@ func (ec *executionContext) _Version_downloads(ctx context.Context, field graphq return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_downloads(ctx 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: "Version", Field: field, @@ -15126,7 +15136,7 @@ func (ec *executionContext) _Version_stability(ctx context.Context, field graphq return ec.marshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_stability(ctx 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: "Version", Field: field, @@ -15170,7 +15180,7 @@ func (ec *executionContext) _Version_approved(ctx context.Context, field graphql return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_approved(ctx 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: "Version", Field: field, @@ -15214,7 +15224,7 @@ func (ec *executionContext) _Version_updated_at(ctx context.Context, field graph return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_updated_at(ctx 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: "Version", Field: field, @@ -15258,7 +15268,7 @@ func (ec *executionContext) _Version_created_at(ctx context.Context, field graph return ec.marshalNDate2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_created_at(ctx 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: "Version", Field: field, @@ -15302,7 +15312,7 @@ func (ec *executionContext) _Version_link(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_link(ctx 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: "Version", Field: field, @@ -15346,7 +15356,7 @@ func (ec *executionContext) _Version_targets(ctx context.Context, field graphql. return ec.marshalNVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionTarget(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_targets(ctx 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: "Version", Field: field, @@ -15399,7 +15409,7 @@ func (ec *executionContext) _Version_metadata(ctx context.Context, field graphql return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_metadata(ctx 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: "Version", Field: field, @@ -15440,7 +15450,7 @@ func (ec *executionContext) _Version_size(ctx context.Context, field graphql.Col return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_size(ctx 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: "Version", Field: field, @@ -15481,7 +15491,7 @@ func (ec *executionContext) _Version_hash(ctx context.Context, field graphql.Col return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_hash(ctx 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: "Version", Field: field, @@ -15525,7 +15535,7 @@ func (ec *executionContext) _Version_mod(ctx context.Context, field graphql.Coll return ec.marshalNMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_mod(ctx 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: "Version", Field: field, @@ -15617,7 +15627,7 @@ func (ec *executionContext) _Version_dependencies(ctx context.Context, field gra return ec.marshalNVersionDependency2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionDependencyᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Version_dependencies(ctx 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: "Version", Field: field, @@ -15675,7 +15685,7 @@ func (ec *executionContext) _VersionDependency_version_id(ctx context.Context, f return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_version_id(ctx 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: "VersionDependency", Field: field, @@ -15719,7 +15729,7 @@ func (ec *executionContext) _VersionDependency_mod_id(ctx context.Context, field return ec.marshalNModID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_mod_id(ctx 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: "VersionDependency", Field: field, @@ -15763,7 +15773,7 @@ func (ec *executionContext) _VersionDependency_condition(ctx context.Context, fi return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_condition(ctx 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: "VersionDependency", Field: field, @@ -15807,7 +15817,7 @@ func (ec *executionContext) _VersionDependency_optional(ctx context.Context, fie return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_optional(ctx 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: "VersionDependency", Field: field, @@ -15848,7 +15858,7 @@ func (ec *executionContext) _VersionDependency_mod(ctx context.Context, field gr return ec.marshalOMod2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐMod(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_mod(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: "VersionDependency", Field: field, @@ -15937,7 +15947,7 @@ func (ec *executionContext) _VersionDependency_version(ctx context.Context, fiel return ec.marshalOVersion2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersion(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionDependency_version(ctx 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: "VersionDependency", Field: field, @@ -16017,7 +16027,7 @@ func (ec *executionContext) _VersionTarget_VersionID(ctx context.Context, field return ec.marshalNVersionID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_VersionID(ctx 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: "VersionTarget", Field: field, @@ -16061,7 +16071,7 @@ func (ec *executionContext) _VersionTarget_targetName(ctx context.Context, field return ec.marshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_targetName(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: "VersionTarget", Field: field, @@ -16105,7 +16115,7 @@ func (ec *executionContext) _VersionTarget_link(ctx context.Context, field graph return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_link(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_VersionTarget_link(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VersionTarget", Field: field, @@ -16146,7 +16156,7 @@ func (ec *executionContext) _VersionTarget_size(ctx context.Context, field graph return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_size(ctx 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: "VersionTarget", Field: field, @@ -16187,7 +16197,7 @@ func (ec *executionContext) _VersionTarget_hash(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_VersionTarget_hash(ctx 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: "VersionTarget", Field: field, @@ -16231,7 +16241,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -16272,7 +16282,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -16316,7 +16326,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -16360,7 +16370,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql 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) { +func (ec *executionContext) fieldContext___Directive_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -16414,7 +16424,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -16458,7 +16468,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -16499,7 +16509,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -16543,7 +16553,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -16584,7 +16594,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -16628,7 +16638,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16669,7 +16679,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16713,7 +16723,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col 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) { +func (ec *executionContext) fieldContext___Field_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16767,7 +16777,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16833,7 +16843,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16874,7 +16884,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -16918,7 +16928,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -16959,7 +16969,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -17003,7 +17013,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -17066,7 +17076,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -17107,7 +17117,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17151,7 +17161,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17217,7 +17227,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17280,7 +17290,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17343,7 +17353,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17409,7 +17419,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -17465,7 +17475,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17506,7 +17516,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17547,7 +17557,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17654,7 +17664,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17717,7 +17727,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17842,7 +17852,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17893,7 +17903,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_ofType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17956,7 +17966,7 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -17988,8 +17998,6 @@ func (ec *executionContext) unmarshalInputCompatibilityInfoInput(ctx context.Con } switch k { case "EA": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EA")) data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) if err != nil { @@ -17997,8 +18005,6 @@ func (ec *executionContext) unmarshalInputCompatibilityInfoInput(ctx context.Con } it.Ea = data case "EXP": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("EXP")) data, err := ec.unmarshalNCompatibilityInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInput(ctx, v) if err != nil { @@ -18026,8 +18032,6 @@ func (ec *executionContext) unmarshalInputCompatibilityInput(ctx context.Context } switch k { case "state": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state")) data, err := ec.unmarshalNCompatibilityState2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityState(ctx, v) if err != nil { @@ -18035,8 +18039,6 @@ func (ec *executionContext) unmarshalInputCompatibilityInput(ctx context.Context } it.State = data case "note": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("note")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18049,6 +18051,158 @@ func (ec *executionContext) unmarshalInputCompatibilityInput(ctx context.Context return it, nil } +func (ec *executionContext) unmarshalInputGuideFilter(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + 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 { + 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.unmarshalOGuideFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐGuideFields(ctx, v) + if err != nil { + return it, err + } + it["order_by"] = 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.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it["ids"] = 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) unmarshalInputModFilter(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids", "references", "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.unmarshalOModFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐModFields(ctx, v) + if err != nil { + return it, err + } + it["order_by"] = 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.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it["ids"] = data + case "references": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("references")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it["references"] = 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) unmarshalInputModVersionConstraint(ctx context.Context, obj interface{}) (ModVersionConstraint, error) { var it ModVersionConstraint asMap := map[string]interface{}{} @@ -18064,8 +18218,6 @@ func (ec *executionContext) unmarshalInputModVersionConstraint(ctx context.Conte } switch k { case "modIdOrReference": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modIdOrReference")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18073,8 +18225,6 @@ func (ec *executionContext) unmarshalInputModVersionConstraint(ctx context.Conte } it.ModIDOrReference = data case "version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18102,8 +18252,6 @@ func (ec *executionContext) unmarshalInputNewAnnouncement(ctx context.Context, o } switch k { case "message": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18111,8 +18259,6 @@ func (ec *executionContext) unmarshalInputNewAnnouncement(ctx context.Context, o } it.Message = data case "importance": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("importance")) data, err := ec.unmarshalNAnnouncementImportance2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, v) if err != nil { @@ -18140,8 +18286,6 @@ func (ec *executionContext) unmarshalInputNewGuide(ctx context.Context, obj inte } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18149,8 +18293,6 @@ func (ec *executionContext) unmarshalInputNewGuide(ctx context.Context, obj inte } it.Name = data case "short_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18158,8 +18300,6 @@ func (ec *executionContext) unmarshalInputNewGuide(ctx context.Context, obj inte } it.ShortDescription = data case "guide": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18167,8 +18307,6 @@ func (ec *executionContext) unmarshalInputNewGuide(ctx context.Context, obj inte } it.Guide = data case "tagIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) if err != nil { @@ -18196,8 +18334,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18205,8 +18341,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.Name = data case "short_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18214,8 +18348,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.ShortDescription = data case "full_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("full_description")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18223,8 +18355,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.FullDescription = data case "logo": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logo")) data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) if err != nil { @@ -18232,8 +18362,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.Logo = data case "source_url": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("source_url")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18241,8 +18369,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.SourceURL = data case "mod_reference": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod_reference")) data, err := ec.unmarshalNModReference2string(ctx, v) if err != nil { @@ -18250,8 +18376,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.ModReference = data case "hidden": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hidden")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -18259,8 +18383,6 @@ func (ec *executionContext) unmarshalInputNewMod(ctx context.Context, obj interf } it.Hidden = data case "tagIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) if err != nil { @@ -18288,8 +18410,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } switch k { case "version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18297,8 +18417,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Version = data case "satisfactory_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfactory_version")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { @@ -18306,8 +18424,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.SatisfactoryVersion = data case "stability": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) data, err := ec.unmarshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) if err != nil { @@ -18315,8 +18431,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Stability = data case "link": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18324,8 +18438,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Link = data case "targets": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) data, err := ec.unmarshalNNewSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewSMLVersionTargetᚄ(ctx, v) if err != nil { @@ -18333,8 +18445,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Targets = data case "changelog": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18342,8 +18452,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Changelog = data case "date": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("date")) data, err := ec.unmarshalNDate2string(ctx, v) if err != nil { @@ -18351,8 +18459,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.Date = data case "bootstrap_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bootstrap_version")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18360,8 +18466,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersion(ctx context.Context, obj } it.BootstrapVersion = data case "engine_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("engine_version")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18389,8 +18493,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersionTarget(ctx context.Contex } switch k { case "targetName": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetName")) data, err := ec.unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, v) if err != nil { @@ -18398,8 +18500,6 @@ func (ec *executionContext) unmarshalInputNewSMLVersionTarget(ctx context.Contex } it.TargetName = data case "link": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18427,8 +18527,6 @@ func (ec *executionContext) unmarshalInputNewVersion(ctx context.Context, obj in } switch k { case "changelog": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18436,8 +18534,6 @@ func (ec *executionContext) unmarshalInputNewVersion(ctx context.Context, obj in } it.Changelog = data case "stability": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) data, err := ec.unmarshalNVersionStabilities2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) if err != nil { @@ -18450,6 +18546,68 @@ func (ec *executionContext) unmarshalInputNewVersion(ctx context.Context, obj in return it, nil } +func (ec *executionContext) unmarshalInputSMLVersionFilter(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids"} + 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.unmarshalOSMLVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionFields(ctx, v) + if err != nil { + return it, err + } + it["order_by"] = 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.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it["ids"] = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj interface{}) (TagFilter, error) { var it TagFilter asMap := map[string]interface{}{} @@ -18465,8 +18623,6 @@ func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj int } switch k { case "limit": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { @@ -18474,8 +18630,6 @@ func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj int } it.Limit = data case "offset": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { @@ -18483,8 +18637,6 @@ func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj int } it.Offset = data case "order": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("order")) data, err := ec.unmarshalOOrder2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐOrder(ctx, v) if err != nil { @@ -18492,8 +18644,6 @@ func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj int } it.Order = data case "search": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("search")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18501,8 +18651,6 @@ func (ec *executionContext) unmarshalInputTagFilter(ctx context.Context, obj int } it.Search = data case "ids": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) if err != nil { @@ -18530,8 +18678,6 @@ func (ec *executionContext) unmarshalInputUpdateAnnouncement(ctx context.Context } switch k { case "message": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18539,8 +18685,6 @@ func (ec *executionContext) unmarshalInputUpdateAnnouncement(ctx context.Context } it.Message = data case "importance": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("importance")) data, err := ec.unmarshalOAnnouncementImportance2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐAnnouncementImportance(ctx, v) if err != nil { @@ -18568,8 +18712,6 @@ func (ec *executionContext) unmarshalInputUpdateGuide(ctx context.Context, obj i } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18577,8 +18719,6 @@ func (ec *executionContext) unmarshalInputUpdateGuide(ctx context.Context, obj i } it.Name = data case "short_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18586,8 +18726,6 @@ func (ec *executionContext) unmarshalInputUpdateGuide(ctx context.Context, obj i } it.ShortDescription = data case "guide": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("guide")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18595,8 +18733,6 @@ func (ec *executionContext) unmarshalInputUpdateGuide(ctx context.Context, obj i } it.Guide = data case "tagIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) if err != nil { @@ -18624,8 +18760,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18633,8 +18767,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.Name = data case "short_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("short_description")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18642,8 +18774,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.ShortDescription = data case "full_description": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("full_description")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18651,8 +18781,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.FullDescription = data case "logo": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logo")) data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) if err != nil { @@ -18660,8 +18788,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.Logo = data case "source_url": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("source_url")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18669,8 +18795,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.SourceURL = data case "mod_reference": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mod_reference")) data, err := ec.unmarshalOModReference2ᚖstring(ctx, v) if err != nil { @@ -18678,8 +18802,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.ModReference = data case "authors": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authors")) data, err := ec.unmarshalOUpdateUserMod2ᚕgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateUserModᚄ(ctx, v) if err != nil { @@ -18687,8 +18809,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.Authors = data case "hidden": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hidden")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -18696,8 +18816,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.Hidden = data case "tagIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagIDs")) data, err := ec.unmarshalOTagID2ᚕstringᚄ(ctx, v) if err != nil { @@ -18705,8 +18823,6 @@ func (ec *executionContext) unmarshalInputUpdateMod(ctx context.Context, obj int } it.TagIDs = data case "compatibility": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("compatibility")) data, err := ec.unmarshalOCompatibilityInfoInput2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐCompatibilityInfoInput(ctx, v) if err != nil { @@ -18734,8 +18850,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } switch k { case "version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("version")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18743,8 +18857,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Version = data case "satisfactory_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("satisfactory_version")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { @@ -18752,8 +18864,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.SatisfactoryVersion = data case "stability": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) data, err := ec.unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) if err != nil { @@ -18761,8 +18871,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Stability = data case "link": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18770,8 +18878,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Link = data case "targets": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targets")) data, err := ec.unmarshalNUpdateSMLVersionTarget2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐUpdateSMLVersionTarget(ctx, v) if err != nil { @@ -18779,8 +18885,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Targets = data case "changelog": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18788,8 +18892,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Changelog = data case "date": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("date")) data, err := ec.unmarshalODate2ᚖstring(ctx, v) if err != nil { @@ -18797,8 +18899,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.Date = data case "bootstrap_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bootstrap_version")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18806,8 +18906,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersion(ctx context.Context, } it.BootstrapVersion = data case "engine_version": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("engine_version")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18835,8 +18933,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersionTarget(ctx context.Con } switch k { case "targetName": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("targetName")) data, err := ec.unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx, v) if err != nil { @@ -18844,8 +18940,6 @@ func (ec *executionContext) unmarshalInputUpdateSMLVersionTarget(ctx context.Con } it.TargetName = data case "link": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18873,8 +18967,6 @@ func (ec *executionContext) unmarshalInputUpdateUser(ctx context.Context, obj in } switch k { case "avatar": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("avatar")) data, err := ec.unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) if err != nil { @@ -18882,8 +18974,6 @@ func (ec *executionContext) unmarshalInputUpdateUser(ctx context.Context, obj in } it.Avatar = data case "groups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groups")) directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } directive1 := func(ctx context.Context) (interface{}, error) { @@ -18912,8 +19002,6 @@ func (ec *executionContext) unmarshalInputUpdateUser(ctx context.Context, obj in return it, graphql.ErrorOnPath(ctx, err) } case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18941,8 +19029,6 @@ func (ec *executionContext) unmarshalInputUpdateUserMod(ctx context.Context, obj } switch k { case "user_id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("user_id")) data, err := ec.unmarshalNUserID2string(ctx, v) if err != nil { @@ -18950,8 +19036,6 @@ func (ec *executionContext) unmarshalInputUpdateUserMod(ctx context.Context, obj } it.UserID = data case "role": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { @@ -18979,8 +19063,6 @@ func (ec *executionContext) unmarshalInputUpdateVersion(ctx context.Context, obj } switch k { case "changelog": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changelog")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { @@ -18988,8 +19070,6 @@ func (ec *executionContext) unmarshalInputUpdateVersion(ctx context.Context, obj } it.Changelog = data case "stability": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stability")) data, err := ec.unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx, v) if err != nil { @@ -19002,6 +19082,68 @@ func (ec *executionContext) unmarshalInputUpdateVersion(ctx context.Context, obj return it, nil } +func (ec *executionContext) unmarshalInputVersionFilter(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"limit", "offset", "order_by", "order", "search", "ids"} + 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.unmarshalOVersionFields2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionFields(ctx, v) + if err != nil { + return it, err + } + it["order_by"] = 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.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it["ids"] = data + } + } + + return it, nil +} + // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -20147,7 +20289,7 @@ func (ec *executionContext) _Mod(ctx context.Context, sel ast.SelectionSet, obj 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)) @@ -20660,7 +20802,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getAnnouncement": 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)) @@ -20723,7 +20865,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getGuide": 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)) @@ -20764,7 +20906,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getMod": 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)) @@ -20783,7 +20925,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getModByReference": 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)) @@ -20802,7 +20944,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getModByIdOrReference": 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)) @@ -20931,7 +21073,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getSMLVersion": 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)) @@ -20972,7 +21114,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getTag": 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)) @@ -21013,7 +21155,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getMe": 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)) @@ -21032,7 +21174,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getUser": 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)) @@ -21073,7 +21215,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "getVersion": 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)) @@ -21136,7 +21278,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "checkVersionUploadState": 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)) @@ -21955,7 +22097,7 @@ func (ec *executionContext) _Version(ctx context.Context, sel ast.SelectionSet, case "size": 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)) @@ -21988,7 +22130,7 @@ func (ec *executionContext) _Version(ctx context.Context, sel ast.SelectionSet, case "hash": 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)) @@ -24253,7 +24395,8 @@ func (ec *executionContext) unmarshalOGuideFilter2map(ctx context.Context, v int if v == nil { return nil, nil } - return v.(map[string]interface{}), nil + res, err := ec.unmarshalInputGuideFilter(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { @@ -24299,7 +24442,8 @@ func (ec *executionContext) unmarshalOModFilter2map(ctx context.Context, v inter if v == nil { return nil, nil } - return v.(map[string]interface{}), nil + res, err := ec.unmarshalInputModFilter(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOModReference2ᚖstring(ctx context.Context, v interface{}) (*string, error) { @@ -24361,7 +24505,8 @@ func (ec *executionContext) unmarshalOSMLVersionFilter2map(ctx context.Context, if v == nil { return nil, nil } - return v.(map[string]interface{}), nil + res, err := ec.unmarshalInputSMLVersionFilter(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOSMLVersionTarget2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐSMLVersionTarget(ctx context.Context, sel ast.SelectionSet, v *SMLVersionTarget) graphql.Marshaler { @@ -24610,7 +24755,8 @@ func (ec *executionContext) unmarshalOVersionFilter2map(ctx context.Context, v i if v == nil { return nil, nil } - return v.(map[string]interface{}), nil + res, err := ec.unmarshalInputVersionFilter(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOVersionStabilities2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐVersionStabilities(ctx context.Context, v interface{}) (*VersionStabilities, error) { diff --git a/generated/models_gen.go b/generated/models_gen.go index 87189878..842f8e57 100644 --- a/generated/models_gen.go +++ b/generated/models_gen.go @@ -132,6 +132,9 @@ type ModVersionConstraint struct { Version string `json:"version"` } +type Mutation struct { +} + type NewAnnouncement struct { Message string `json:"message"` Importance AnnouncementImportance `json:"importance"` @@ -172,6 +175,9 @@ type OAuthOptions struct { Facebook string `json:"facebook"` } +type Query struct { +} + type SMLVersion struct { ID string `json:"id"` Version string `json:"version"` diff --git a/go.mod b/go.mod index 8b7fbad0..3e933342 100755 --- a/go.mod +++ b/go.mod @@ -1,35 +1,35 @@ module github.com/satisfactorymodding/smr-api -go 1.21 +go 1.22 -toolchain go1.21.4 +toolchain go1.22.3 require ( ariga.io/entcache v0.1.0 - entgo.io/ent v0.12.4 - github.com/99designs/gqlgen v0.17.39 + entgo.io/ent v0.13.1 + github.com/99designs/gqlgen v0.17.49 github.com/MarvinJWendt/testza v0.5.2 github.com/Masterminds/semver/v3 v3.2.1 github.com/Vilsol/slox v0.0.1 - github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f + github.com/VirusTotal/vt-go v1.0.1 github.com/avast/retry-go v3.0.0+incompatible github.com/avast/retry-go/v3 v3.1.1 - github.com/aws/aws-sdk-go v1.46.1 - github.com/btcsuite/btcd/btcutil v1.1.3 + github.com/aws/aws-sdk-go v1.54.2 + github.com/btcsuite/btcd/btcutil v1.1.5 github.com/cespare/xxhash v1.1.0 github.com/chai2010/webp v1.1.1 github.com/dgraph-io/ristretto v0.1.1 - github.com/felixge/fgprof v0.9.3 + github.com/felixge/fgprof v0.9.4 github.com/finnbear/moderation v0.11.4 github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis/v8 v8.11.5 - github.com/golang-migrate/migrate/v4 v4.16.2 + github.com/golang-migrate/migrate/v4 v4.17.1 github.com/graph-gophers/dataloader/v7 v7.1.0 - github.com/jackc/pgx/v5 v5.4.3 + github.com/jackc/pgx/v5 v5.6.0 github.com/lab259/go-migration v1.3.1 - github.com/labstack/echo-contrib v0.15.0 - github.com/labstack/echo/v4 v4.11.2 - github.com/lmittmann/tint v1.0.2 + github.com/labstack/echo-contrib v0.17.1 + github.com/labstack/echo/v4 v4.12.0 + github.com/lmittmann/tint v1.0.4 github.com/machinebox/graphql v0.2.2 github.com/microcosm-cc/bluemonday v1.0.26 github.com/mitchellh/hashstructure/v2 v2.0.2 @@ -38,36 +38,35 @@ require ( github.com/pkg/errors v0.9.1 github.com/russross/blackfriday v1.6.0 github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591 - github.com/spf13/viper v1.17.0 + github.com/spf13/viper v1.19.0 github.com/swaggo/echo-swagger v1.4.1 - github.com/swaggo/swag v1.16.2 - github.com/vektah/gqlparser/v2 v2.5.10 + github.com/swaggo/swag v1.16.3 + github.com/vektah/gqlparser/v2 v2.5.16 github.com/vmihailenco/taskq/extra/taskqotel/v3 v3.2.9 github.com/vmihailenco/taskq/v3 v3.2.9 github.com/xeipuuv/gojsonschema v1.2.0 - go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 - go.opentelemetry.io/otel v1.19.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 - go.opentelemetry.io/otel/sdk v1.19.0 - go.opentelemetry.io/otel/trace v1.19.0 - golang.org/x/crypto v0.14.0 - golang.org/x/net v0.17.0 - golang.org/x/oauth2 v0.13.0 - golang.org/x/sync v0.4.0 - google.golang.org/grpc v1.59.0 - google.golang.org/protobuf v1.31.0 + go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.52.0 + go.opentelemetry.io/otel v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 + go.opentelemetry.io/otel/sdk v1.27.0 + go.opentelemetry.io/otel/trace v1.27.0 + golang.org/x/crypto v0.24.0 + golang.org/x/net v0.26.0 + golang.org/x/oauth2 v0.21.0 + golang.org/x/sync v0.7.0 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.2 gopkg.in/go-playground/validator.v9 v9.31.0 ) require ( - ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect + ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect atomicgo.dev/assert v0.0.2 // indirect atomicgo.dev/cursor v0.2.0 // indirect atomicgo.dev/keyboard v0.2.9 // indirect atomicgo.dev/schedule v0.1.0 // indirect - cloud.google.com/go/compute v1.23.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29 // indirect @@ -78,19 +77,19 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/bsm/redislock v0.7.2 // indirect github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 // indirect - github.com/cenkalti/backoff/v4 v4.2.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/console v1.0.3 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.15.0 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect @@ -101,16 +100,15 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-redis/redis_rate/v9 v9.1.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/golang/glog v1.1.2 // indirect + github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect - github.com/google/uuid v1.3.1 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect @@ -122,9 +120,9 @@ require ( github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.1 // indirect + github.com/klauspost/compress v1.17.2 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/labstack/gommon v0.4.0 // indirect + github.com/labstack/gommon v0.4.2 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect @@ -136,23 +134,23 @@ require ( github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/mitchellh/hashstructure v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pterm/pterm v0.12.69 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9 // indirect - github.com/sosodev/duration v1.2.0 // indirect + github.com/sosodev/duration v1.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.10.0 // indirect - github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/swaggo/files/v2 v2.0.0 // indirect github.com/thedevsaddam/gojsonq/v2 v2.5.2 // indirect - github.com/urfave/cli/v2 v2.25.7 // indirect + github.com/urfave/cli/v2 v2.27.2 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect @@ -160,22 +158,21 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect github.com/zclconf/go-cty v1.8.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/proto/otlp v1.2.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/mod v0.13.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.14.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect + golang.org/x/mod v0.18.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/time v0.5.0 // indirect + golang.org/x/tools v0.22.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 6756e3d7..b80b0362 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 h1:JnYs/y8RJ3+MiIUp+3RgyyeO48VHLAZimqiaZYnMKk8= -ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935/go.mod h1:isZrlzJ5cpoCoKFoY9knZug7Lq4pP1cm8g3XciLZ0Pw= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU= ariga.io/entcache v0.1.0 h1:nfJXzjB5CEvAK6SmjupHREMJrKLakeqU5tG3s4TO6JA= ariga.io/entcache v0.1.0/go.mod h1:3Z1Sql5bcqPA1YV/jvMlZyh9T+ntSFOclaASAm1TiKQ= atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg= @@ -10,56 +10,15 @@ atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8= atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ= atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs= atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU= -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.23.1 h1:V97tBoDaZHb6leicZ1G6DLK2BAaZLJ/7+9BB/En3hR0= -cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.12.4 h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8= -entgo.io/ent v0.12.4/go.mod h1:Y3JVAjtlIk8xVZYSn3t3mf8xlZIn5SAOXZQxD6kKI+Q= -github.com/99designs/gqlgen v0.17.39 h1:wPTAyc2fqVjAWT5DsJ21k/lLudgnXzURwbsjVNegFpU= -github.com/99designs/gqlgen v0.17.39/go.mod h1:b62q1USk82GYIVjC60h02YguAZLqYZtvWml8KkhJps4= +entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE= +entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= +github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= +github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -80,10 +39,12 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= +github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= github.com/Vilsol/slox v0.0.1 h1:X5iskI+WLDxW5FNxYV9izEEWliFzRUNxcItHWetwnOk= github.com/Vilsol/slox v0.0.1/go.mod h1:1mhhQdJHAzUVobE9RE0k7vxaSn17C0b4WSMPjHCizJo= -github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f h1:49xl3zKS625gxmIRCfmwkXcTzB4cr4FcayRw/RcxhZs= -github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= +github.com/VirusTotal/vt-go v1.0.1 h1:rj/qugIY8XNC6ogwOaeJAGCOsb3nmY63+yuDMtHOx0Q= +github.com/VirusTotal/vt-go v1.0.1/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb/go.mod h1:UzH9IX1MMqOcwhoNOIjmTQeAxrFgzs50j4golQtXXxU= @@ -98,6 +59,8 @@ github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRB github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= +github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= @@ -107,23 +70,24 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/avast/retry-go/v3 v3.1.1 h1:49Scxf4v8PmiQ/nY0aY3p0hDueqSmc7++cBbtiDGu2g= github.com/avast/retry-go/v3 v3.1.1/go.mod h1:6cXRK369RpzFL3UQGqIUp9Q7GDrams+KsYWrfNA1/nQ= -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.54.2 h1:Wo6AVWcleNHrYa48YzfYz60hzxGRqsJrK5s/qePe+3I= +github.com/aws/aws-sdk-go v1.54.2/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/bsm/redislock v0.7.2 h1:jggqOio8JyX9FJBKIfjF3fTxAu/v7zC5mAID9LveqG4= github.com/bsm/redislock v0.7.2/go.mod h1:kS2g0Yvlymc9Dz8V3iVYAtLAaSVruYbAFdYBDrmC5WU= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= -github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= +github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= @@ -135,28 +99,26 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3 h1:IHZ1Le1ejzkmS7Si7dIzJvYDWe+BIoNmqMnfWHBZSVw= github.com/capnm/sysinfo v0.0.0-20130621111458-5909a53897f3/go.mod h1:M5XHQLu90v2JNm/bW2tdsYar+5vhV0gEcBcmDBNAN1Y= -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/webp v1.1.1 h1:jTRmEccAJ4MGrhFOrPMpNGIJ/eybIgwKpcACsrTEapk= github.com/chai2010/webp v1.1.1/go.mod h1:0XVwvZWdjjdxpUEIf7b9g9VkHFnInUSYujwqTLEuldU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= +github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs= +github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= +github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= +github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= +github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -175,12 +137,12 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= -github.com/dhui/dktest v0.3.16 h1:i6gq2YQEtcrjKbeJpBkWjE8MmLZPYllcjOFbTZuPDnw= -github.com/dhui/dktest v0.3.16/go.mod h1:gYaA3LRmM8Z4vJl2MA0THIigJoZrwOansEOsp+kqxp0= +github.com/dhui/dktest v0.4.1 h1:/w+IWuDXVymg3IrRJCHHOkMK10m9aNVMOyD0X12YVTg= +github.com/dhui/dktest v0.4.1/go.mod h1:DdOqcUpL7vgyP4GlF3X3w7HbSlz8cEQzwewPveYEQbA= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= -github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= +github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -188,35 +150,27 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= -github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= +github.com/felixge/fgprof v0.9.4 h1:ocDNwMFlnA0NU0zSB3I52xkO4sFXk80VK9lXjLClu88= +github.com/felixge/fgprof v0.9.4/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= github.com/finnbear/moderation v0.11.4 h1:bqGeFj+sScc3nIFxT3SZDXOqio3+AQ/UtZ+qyVgqiHs= github.com/finnbear/moderation v0.11.4/go.mod h1:IFowm0Qv42lFZkoHzVLYxTGN4CDI0mJRgYk+8BewbVE= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= @@ -252,84 +206,43 @@ github.com/go-redis/redismock/v8 v8.0.6/go.mod h1:sDIF73OVsmaKzYe/1FJXGiCQ4+oHYb github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= +github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-migrate/migrate/v4 v4.16.2 h1:8coYbMKUyInrFk1lfGfRovTLAW7PhWp8qQDT2iKfuoA= -github.com/golang-migrate/migrate/v4 v4.16.2/go.mod h1:pfcJX4nPHaVdc5nmdCikFBWtm+UBpiZjRNNsyBbp0/o= +github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= +github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= +github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ= github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= @@ -340,15 +253,13 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/dataloader/v7 v7.1.0 h1:Wn8HGF/q7MNXcvfaBnLEPEFJttVHR8zuEqP1obys/oc= github.com/graph-gophers/dataloader/v7 v7.1.0/go.mod h1:1bKE0Dm6OUcTB/OAuYVOZctgIz7Q3d0XrYtlIzTgg6Q= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= @@ -358,17 +269,15 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac h1:w5wltlINIIqRTqQ64dASrCo0fM7k9nosPbKCZnkL0W0= github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac/go.mod h1:gyMTRVO+ZkEy7wQDyD++okPsBN2q127EpuShhHMWG54= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY= -github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jamillosantos/macchiato v0.0.0-20171220130318-3be045cc5033 h1:R0efOJW2JdoZ7ValaK6iFhWHrlZFeRvV4alZbHg5hnQ= @@ -382,18 +291,14 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g= -github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -402,17 +307,18 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lab259/go-migration v1.3.1 h1:9ymcS7IywHzcl/6xePMhht9fLUgPeZFUNbrj0f3z2mU= github.com/lab259/go-migration v1.3.1/go.mod h1:9SB2RbONCWrBN7VXFLt/qOU6ar/uJNnaIGnHDkYK+lE= github.com/lab259/rlog/v2 v2.1.0/go.mod h1:Rfy8HYLxXb0s/1F98p8fRtrCiIwxA8q5HqsQmXLvKfM= -github.com/labstack/echo-contrib v0.15.0 h1:9K+oRU265y4Mu9zpRDv3X+DGTqUALY6oRHCSZZKCRVU= -github.com/labstack/echo-contrib v0.15.0/go.mod h1:lei+qt5CLB4oa7VHTE0yEfQSEB9XTJI1LUqko9UWvo4= -github.com/labstack/echo/v4 v4.11.2 h1:T+cTLQxWCDfqDEoydYm5kCobjmHwOwcv4OJAPHilmdE= -github.com/labstack/echo/v4 v4.11.2/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws= -github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= -github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/labstack/echo-contrib v0.17.1 h1:7I/he7ylVKsDUieaGRZ9XxxTYOjfQwVzHzUYrNykfCU= +github.com/labstack/echo-contrib v0.17.1/go.mod h1:SnsCZtwHBAZm5uBSAtQtXQHI3wqEA73hvTn0bYMKnZA= +github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= +github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= +github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= +github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -420,8 +326,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4= github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4= -github.com/lmittmann/tint v1.0.2 h1:9XZ+JvEzjvd3VNVugYqo3j+dl0NRju8k9FquAusJExM= -github.com/lmittmann/tint v1.0.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= +github.com/lmittmann/tint v1.0.4 h1:LeYihpJ9hyGvE0w+K2okPTGUdVLfng1+nDNVR4vWISc= +github.com/lmittmann/tint v1.0.4/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo= github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -434,11 +340,9 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -487,16 +391,15 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI= github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg= github.com/pterm/pterm v0.12.30/go.mod h1:MOqLIyMOgmTDz9yorcYbcw+HsgoZo3BQfg2wtl3HEFE= @@ -509,43 +412,41 @@ github.com/pterm/pterm v0.12.69/go.mod h1:wl06ko9MHnqxz4oDV++IORDpjCzw6+mfrvf0MP github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= -github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= -github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591 h1:dCWBD4Xchp/XFIR/x6D2l74DtQHvIpHsmpPRHgH9oUo= github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591/go.mod h1:IXC7KN2FEuTEISdePm37qcFyXInAh6pfW35yDjbdfOM= github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9 h1:i3LYMwQ0zkh/BJ47vIZN+jBYqV4/f6DFoAsW8rwV490= github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9/go.mod h1:/NQ8ciRuH+vxYhrFlnX70gvXBugMYQbBygCRocFgSZ4= -github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us= -github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= -github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= -github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -556,28 +457,28 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= -github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04= -github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E= +github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= +github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/thedevsaddam/gojsonq/v2 v2.5.2 h1:CoMVaYyKFsVj6TjU6APqAhAvC07hTI6IQen8PHzHYY0= github.com/thedevsaddam/gojsonq/v2 v2.5.2/go.mod h1:bv6Xa7kWy82uT0LnXPE2SzGqTj33TAEeR560MdJkiXs= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= +github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= -github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8= +github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= @@ -598,39 +499,30 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0 h1:JJCIHAxGCB5HM3NxeIwFjHc087Xwk96TG9kaZU6TAec= -go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.45.0/go.mod h1:Px9kH7SJ+NhsgWRtD/eMcs15Tyt4uL3rM7X54qv6pfA= -go.opentelemetry.io/contrib/propagators/b3 v1.20.0 h1:Yty9Vs4F3D6/liF1o6FNt0PvN85h/BJJ6DQKJ3nrcM0= -go.opentelemetry.io/contrib/propagators/b3 v1.20.0/go.mod h1:On4VgbkqYL18kbJlWsa18+cMNe6rYpBnPi1ARI/BrsU= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= -go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= -go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= -go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.52.0 h1:LzwBXd0Ue7aQZend+HsaDQOqMoxOPPuzErESqeoGuFg= +go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.52.0/go.mod h1:+HJOzKJUai3v0cbttYhs/ExlWjPVS6hOEBHXvIVUi3A= +go.opentelemetry.io/contrib/propagators/b3 v1.27.0 h1:IjgxbomVrV9za6bRi8fWCNXENs0co37SZedQilP2hm0= +go.opentelemetry.io/contrib/propagators/b3 v1.27.0/go.mod h1:Dv9obQz25lCisDvvs4dy28UPh974CxkahRDUPsY7y9E= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= +go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= +go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= +go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -640,382 +532,141 @@ golang.org/x/crypto v0.0.0-20181025213731-e84da0312774/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20210220032938-85be41e4509f/go.mod h1:I6l2HNBLBZEcrOoCpyKLdY2lHoRZ8lI4x60KMCQDft4= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= -google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= -google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k= -google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 h1:AgADTJarZTBqgjiUzRgfaBchgYB3/WFTC80GPwsMcRI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= @@ -1037,15 +688,5 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/shell.nix b/shell.nix index b924e10c..fccd3ab9 100644 --- a/shell.nix +++ b/shell.nix @@ -4,9 +4,10 @@ pkgs.mkShell { nativeBuildInputs = with pkgs.buildPackages; [ libwebp libpng - unstable.go_1_21 + unstable.go_1_22 protobuf protoc-gen-go-grpc + protoc-gen-go minio-client unstable.golangci-lint unstable.delve diff --git a/tools.go b/tools.go index 0042c9da..a0caa6d2 100644 --- a/tools.go +++ b/tools.go @@ -12,9 +12,9 @@ import ( // go generate -tags tools -x ./... //go:generate protoc -I./proto --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative proto/parser/parser.proto -//go:generate go run github.com/jmattheis/goverter/cmd/goverter@v1.0.0 gen -g wrapErrors -g ignoreUnexported ./conversion -//go:generate go run github.com/99designs/gqlgen@v0.17.39 generate -//go:generate go run github.com/swaggo/swag/cmd/swag@v1.16.2 init --generalInfo cmd/api/serve.go --output ./generated/docs +//go:generate go run github.com/99designs/gqlgen@v0.17.49 generate +//go:generate go run github.com/jmattheis/goverter/cmd/goverter@v1.4.0 gen -g wrapErrors -g ignoreUnexported ./conversion +//go:generate go run github.com/swaggo/swag/cmd/swag@v1.16.3 init --generalInfo cmd/api/serve.go --output ./generated/docs //go:generate go run tools.go func main() { From 5e6268e9842204177c8de7639eaa1baeac99e523 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 17 Jun 2024 22:06:22 +0300 Subject: [PATCH 17/19] chore: upgrade and fix linter --- .github/workflows/build.yml | 6 ++-- .golangci.yml | 36 +++++++++++++++---- api/api.go | 4 +-- config/config.go | 4 +-- db/ent.go | 2 +- db/mod.go | 4 +-- db/oauth.go | 3 +- db/pgxpooldriver.go | 3 ++ db/schema/mixin_softdelete.go | 11 +++--- db/user.go | 6 ++-- gql/gql_utils.go | 1 + gql/resolver_announcements.go | 2 +- gql/resolver_guides.go | 4 +-- gql/resolver_mods.go | 1 - gql/resolver_sml_versions.go | 11 +++--- gql/resolver_users.go | 4 +-- gql/resolver_versions.go | 5 ++- integrations/discord.go | 4 +-- .../code/20200426221900_test_new_migration.go | 2 +- migrations/code/20200501224200_parse_paks.go | 2 +- .../20200524203800_after_reference_fix.go | 2 +- .../20200621195500_after_id_length_fix.go | 2 +- ...20200622003600_after_validation_disable.go | 2 +- .../code/20200629093800_copy_to_new_bucket.go | 2 +- .../20200707150700_after_sml_version_fix.go | 2 +- .../code/20200829171600_after_db_dirty.go | 2 +- .../20200829225100_after_broken_datajson.go | 2 +- .../code/20200830011200_after_gorm_hotfix.go | 2 +- .../code/20201014162200_after_bp_fix.go | 2 +- .../code/20201016202600_after_body_enable.go | 2 +- .../20201019203800_after_remove_filter.go | 2 +- models/filters.go | 22 ++++++------ nodes/mod.go | 2 +- nodes/routes.go | 2 +- oauth/facebook.go | 1 - oauth/github.go | 4 --- oauth/google.go | 1 - storage/s3.go | 6 ++-- storage/storage.go | 3 -- tests/announcements_test.go | 2 +- tests/guides_test.go | 2 +- tests/mod_test.go | 2 +- tests/sml_versions_test.go | 2 +- tests/version_test.go | 2 +- util/security.go | 1 - validation/validation.go | 8 ++--- validation/virustotal.go | 7 ++-- 47 files changed, 105 insertions(+), 99 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3bfe4c7d..243d9e28 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version: 1.22.3 - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version: 1.22.3 - name: Check out code into the Go module directory uses: actions/checkout@v3 @@ -53,7 +53,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.54.2 + version: v1.59.1 skip-pkg-cache: true skip-build-cache: true args: --timeout 5m diff --git a/.golangci.yml b/.golangci.yml index ba826d15..b365ceaa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,8 +13,6 @@ linters-settings: - github.com/satisfactorymodding/smr-api/* govet: - check-shadowing: true - enable-all: true disable: - shadow @@ -31,14 +29,31 @@ linters-settings: - blank - dot -run: - skip-files: + sloglint: + attr-only: true + context: scope + forbidden-keys: + - time + - level + - msg + - source + + spancheck: + checks: + - end + - record-error + - set-status + extra-start-span-signatures: + - github.com/satisfactorymodding/smr-api/gql.WrapQueryTrace:opentelemetry + - github.com/satisfactorymodding/smr-api/gql.WrapMutationTrace:opentelemetry + + +issues: + exclude-files: - ./generated/generated.go - ./generated/models_gen.go - skip-dirs: + exclude-dirs: - ./generated/ - -issues: exclude: - should pass the context parameter @@ -66,3 +81,10 @@ linters: - gocritic - gofumpt - nonamedreturns + - inamedparam + - sloglint + - spancheck + - intrange + - copyloopvar + - fatcontext + - canonicalheader diff --git a/api/api.go b/api/api.go index 6edcb19d..398c04dc 100644 --- a/api/api.go +++ b/api/api.go @@ -318,7 +318,7 @@ func installExportPipeline(ctx context.Context) func() { client := otlptracehttp.NewClient() exporter, err := otlptrace.New(ctx, client) if err != nil { - slog.Error("creating OTLP trace exporter", slog.Any("err", err)) + slog.ErrorContext(ctx, "creating OTLP trace exporter", slog.Any("err", err)) os.Exit(1) } @@ -331,7 +331,7 @@ func installExportPipeline(ctx context.Context) func() { return func() { if err := tracerProvider.Shutdown(ctx); err != nil { - slog.Error("stopping tracer provider", slog.Any("err", err)) + slog.ErrorContext(ctx, "stopping tracer provider", slog.Any("err", err)) os.Exit(1) } } diff --git a/config/config.go b/config/config.go index 545731f2..95419978 100644 --- a/config/config.go +++ b/config/config.go @@ -42,7 +42,7 @@ func InitializeConfig(baseCtx context.Context) context.Context { Level: slog.LevelDebug, AddSource: true, TimeFormat: time.RFC3339Nano, - ReplaceAttr: func(groups []string, attr slog.Attr) slog.Attr { + ReplaceAttr: func(_ []string, attr slog.Attr) slog.Attr { if attr.Key == slog.LevelKey { level := attr.Value.Any().(slog.Level) if level == slog.LevelDebug { @@ -69,7 +69,7 @@ func InitializeConfig(baseCtx context.Context) context.Context { } if err != nil { - slog.Warn("config initialized using defaults and environment only!", slog.Any("err", err)) + slog.WarnContext(baseCtx, "config initialized using defaults and environment only!", slog.Any("err", err)) } slox.Info(baseCtx, "Config initialized") diff --git a/db/ent.go b/db/ent.go index 9fe3dbb5..b13a0088 100644 --- a/db/ent.go +++ b/db/ent.go @@ -109,7 +109,7 @@ func Tx(ctx context.Context, f func(newCtx context.Context, tx *ent.Tx) error, o newCtx := context.WithValue(ctx, txKey{}, tx) - if err := f(newCtx, tx); err != nil { + if err = f(newCtx, tx); err != nil { finalError := err func() { diff --git a/db/mod.go b/db/mod.go index 61b6f134..36b92356 100644 --- a/db/mod.go +++ b/db/mod.go @@ -15,8 +15,8 @@ import ( func ConvertModFilter(query *ent.ModQuery, filter *models.ModFilter, count bool, unapproved bool) *ent.ModQuery { query = query.WithTags() - if len(filter.Ids) > 0 { - query = query.Where(mod.IDIn(filter.Ids...)) + if len(filter.IDs) > 0 { + query = query.Where(mod.IDIn(filter.IDs...)) } else if len(filter.References) > 0 { query = query.Where(mod.ModReferenceIn(filter.References...)) } else if filter != nil { diff --git a/db/oauth.go b/db/oauth.go index d34976ce..abdf0cde 100644 --- a/db/oauth.go +++ b/db/oauth.go @@ -32,7 +32,6 @@ func CompleteOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string) newUser := false if ent.IsNotFound(err) { - var err error create := From(ctx).User. Create(). SetEmail(u.Email). @@ -67,7 +66,7 @@ func CompleteOAuthFlow(ctx context.Context, u *oauth.UserData, userAgent string) } if update != nil { - if err := update.Exec(ctx); err != nil { + if err = update.Exec(ctx); err != nil { return nil, err } } diff --git a/db/pgxpooldriver.go b/db/pgxpooldriver.go index 8a6641ff..23234109 100644 --- a/db/pgxpooldriver.go +++ b/db/pgxpooldriver.go @@ -12,6 +12,7 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" ) @@ -88,6 +89,8 @@ func (e *EntPgxpoolDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (di pgxOpts, err := getPgxTxOptions(opts) if err != nil { + span.SetStatus(codes.Error, err.Error()) + span.RecordError(err) return nil, err } tx, err := e.pool.BeginTx(ctx, *pgxOpts) diff --git a/db/schema/mixin_softdelete.go b/db/schema/mixin_softdelete.go index 81f5f3d8..b5fd1ed4 100644 --- a/db/schema/mixin_softdelete.go +++ b/db/schema/mixin_softdelete.go @@ -67,10 +67,10 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook { return next.Mutate(ctx, m) // nolint } mx, ok := m.(interface { - SetOp(ent.Op) + SetOp(operation ent.Op) Client() *gen.Client - SetDeletedAt(time.Time) - WhereP(...func(*sql.Selector)) + SetDeletedAt(deleteTime time.Time) + WhereP(selectors ...func(*sql.Selector)) }) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) @@ -87,7 +87,10 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook { } // P adds a storage-level predicate to the queries and mutations. -func (d SoftDeleteMixin) P(w interface{ WhereP(...func(*sql.Selector)) }) { +func (d SoftDeleteMixin) P(w interface { + WhereP(selectors ...func(*sql.Selector)) +}, +) { w.WhereP( sql.FieldIsNull(d.Fields()[0].Descriptor().Name), ) diff --git a/db/user.go b/db/user.go index 20025638..661a8cdd 100644 --- a/db/user.go +++ b/db/user.go @@ -18,12 +18,12 @@ import ( func UserHas(ctx context.Context, role *auth.Role, usr *ent.User) bool { groups := auth.GetRoleGroups(role) - groupIds := make([]string, len(groups)) + groupIDs := make([]string, len(groups)) for i, group := range groups { - groupIds[i] = group.ID + groupIDs[i] = group.ID } - exist, err := usr.QueryGroups().Where(usergroup.GroupIDIn(groupIds...)).Exist(ctx) + exist, err := usr.QueryGroups().Where(usergroup.GroupIDIn(groupIDs...)).Exist(ctx) if err != nil { slox.Error(ctx, "failed retrieving user groups", slog.Any("err", err)) return false diff --git a/gql/gql_utils.go b/gql/gql_utils.go index e489eb4a..597ff7c2 100644 --- a/gql/gql_utils.go +++ b/gql/gql_utils.go @@ -29,6 +29,7 @@ func WrapMutationTrace(ctx context.Context, action string) (TraceWrapper, contex } func wrapTrace(ctx context.Context, action string, actionType string) (TraceWrapper, context.Context) { + //nolint:spancheck spanCtx, span := otel.Tracer("gql").Start(ctx, "GraphQL "+action, trace.WithAttributes( attribute.String("action_type", "API.graphql."+actionType), )) diff --git a/gql/resolver_announcements.go b/gql/resolver_announcements.go index 4c021b36..1352f857 100644 --- a/gql/resolver_announcements.go +++ b/gql/resolver_announcements.go @@ -39,7 +39,7 @@ func (r *mutationResolver) DeleteAnnouncement(ctx context.Context, announcementI wrapper, ctx := WrapMutationTrace(ctx, "deleteAnnouncement") defer wrapper.end() - slog.Info("deleting announcement", slog.String("id", announcementID)) + slog.InfoContext(ctx, "deleting announcement", slog.String("id", announcementID)) if err := db.From(ctx).Announcement.DeleteOneID(announcementID).Exec(ctx); err != nil { return false, err diff --git a/gql/resolver_guides.go b/gql/resolver_guides.go index 68e5e5aa..a5932c31 100644 --- a/gql/resolver_guides.go +++ b/gql/resolver_guides.go @@ -218,8 +218,8 @@ func (r *guideResolver) User(ctx context.Context, obj *generated.Guide) (*genera } func convertGuideFilter(query *ent.GuideQuery, filter *models.GuideFilter) *ent.GuideQuery { - if len(filter.Ids) > 0 { - query = query.Where(guide.IDIn(filter.Ids...)) + if len(filter.IDs) > 0 { + query = query.Where(guide.IDIn(filter.IDs...)) } else if filter != nil { query = query. Limit(*filter.Limit). diff --git a/gql/resolver_mods.go b/gql/resolver_mods.go index 3302d90b..056c384a 100644 --- a/gql/resolver_mods.go +++ b/gql/resolver_mods.go @@ -90,7 +90,6 @@ func (r *mutationResolver) CreateMod(ctx context.Context, newMod generated.NewMo } logoData, err = converter.ConvertAnyImageToWebp(ctx, file) - if err != nil { return nil, fmt.Errorf("failed to convert logo file: %w", err) } diff --git a/gql/resolver_sml_versions.go b/gql/resolver_sml_versions.go index ccfd5a49..913e67f7 100644 --- a/gql/resolver_sml_versions.go +++ b/gql/resolver_sml_versions.go @@ -36,7 +36,7 @@ func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion gene var result *ent.SmlVersion if err := db.Tx(ctx, func(ctx context.Context, tx *ent.Tx) error { - result, err = db.From(ctx).SmlVersion. + result, err = tx.SmlVersion. Create(). SetVersion(smlVersion.Version). SetSatisfactoryVersion(smlVersion.SatisfactoryVersion). @@ -51,16 +51,13 @@ func (r *mutationResolver) CreateSMLVersion(ctx context.Context, smlVersion gene return err } - println(result.ID) - for _, smlVersionTarget := range smlVersion.Targets { - if _, err := db.From(ctx).SmlVersionTarget. + if _, err := tx.SmlVersionTarget. Create(). SetVersionID(result.ID). SetTargetName(string(smlVersionTarget.TargetName)). SetLink(smlVersionTarget.Link). Save(ctx); err != nil { - println("HERE") return err } } @@ -243,8 +240,8 @@ func (r *getSMLVersionsResolver) Count(ctx context.Context, _ *generated.GetSMLV } func convertSMLVersionFilter(query *ent.SmlVersionQuery, filter *models.SMLVersionFilter) *ent.SmlVersionQuery { - if len(filter.Ids) > 0 { - query = query.Where(smlversion.IDIn(filter.Ids...)) + if len(filter.IDs) > 0 { + query = query.Where(smlversion.IDIn(filter.IDs...)) } else if filter != nil { query = query. Limit(*filter.Limit). diff --git a/gql/resolver_users.go b/gql/resolver_users.go index dc60d651..bdc1f451 100644 --- a/gql/resolver_users.go +++ b/gql/resolver_users.go @@ -187,11 +187,11 @@ func (r *queryResolver) GetUser(ctx context.Context, userID string) (*generated. return (*conv.UserImpl)(nil).Convert(result), nil } -func (r *queryResolver) GetUsers(ctx context.Context, userIds []string) ([]*generated.User, error) { +func (r *queryResolver) GetUsers(ctx context.Context, userIDs []string) ([]*generated.User, error) { wrapper, ctx := WrapQueryTrace(ctx, "getUsers") defer wrapper.end() - result, err := db.From(ctx).User.Query().Where(user.IDIn(userIds...)).All(ctx) + result, err := db.From(ctx).User.Query().Where(user.IDIn(userIDs...)).All(ctx) if err != nil { return nil, err } diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index c38e2696..84f60a8b 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -453,7 +453,6 @@ func (r *versionResolver) Dependencies(ctx context.Context, obj *generated.Versi if dependencies == nil { var err error dependencies, err = dataloader.For(ctx).VersionDependenciesByVersionID.Load(ctx, obj.ID)() - if err != nil { return nil, err } @@ -523,8 +522,8 @@ func (r *getMyVersionsResolver) Count(ctx context.Context, _ *generated.GetMyVer } func convertVersionFilter(query *ent.VersionQuery, filter *models.VersionFilter, unapproved bool) *ent.VersionQuery { - if len(filter.Ids) > 0 { - query = query.Where(version.IDIn(filter.Ids...)) + if len(filter.IDs) > 0 { + query = query.Where(version.IDIn(filter.IDs...)) } else if filter != nil { query = query. Limit(*filter.Limit). diff --git a/integrations/discord.go b/integrations/discord.go index b9bacc84..47dfe115 100644 --- a/integrations/discord.go +++ b/integrations/discord.go @@ -72,7 +72,7 @@ func NewMod(ctx context.Context, mod *ent.Mod) { req, _ := http.NewRequest("POST", viper.GetString("discord.webhook_url"), bytes.NewReader(payloadJSON)) req.Header.Add("Content-Type", "application/json") - req.Header.Add("cache-control", "no-cache") + req.Header.Add("Cache-Control", "no-cache") res, _ := http.DefaultClient.Do(req) @@ -156,7 +156,7 @@ func NewVersion(ctx context.Context, version *ent.Version) { req, _ := http.NewRequest("POST", viper.GetString("discord.webhook_url"), bytes.NewReader(payloadJSON)) req.Header.Add("Content-Type", "application/json") - req.Header.Add("cache-control", "no-cache") + req.Header.Add("Cache-Control", "no-cache") res, _ := http.DefaultClient.Do(req) diff --git a/migrations/code/20200426221900_test_new_migration.go b/migrations/code/20200426221900_test_new_migration.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20200426221900_test_new_migration.go +++ b/migrations/code/20200426221900_test_new_migration.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200501224200_parse_paks.go b/migrations/code/20200501224200_parse_paks.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20200501224200_parse_paks.go +++ b/migrations/code/20200501224200_parse_paks.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200524203800_after_reference_fix.go b/migrations/code/20200524203800_after_reference_fix.go index 1fe62003..e683e727 100644 --- a/migrations/code/20200524203800_after_reference_fix.go +++ b/migrations/code/20200524203800_after_reference_fix.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200621195500_after_id_length_fix.go b/migrations/code/20200621195500_after_id_length_fix.go index 1fe62003..e683e727 100644 --- a/migrations/code/20200621195500_after_id_length_fix.go +++ b/migrations/code/20200621195500_after_id_length_fix.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200622003600_after_validation_disable.go b/migrations/code/20200622003600_after_validation_disable.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20200622003600_after_validation_disable.go +++ b/migrations/code/20200622003600_after_validation_disable.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200629093800_copy_to_new_bucket.go b/migrations/code/20200629093800_copy_to_new_bucket.go index efe9855e..3fc5987f 100644 --- a/migrations/code/20200629093800_copy_to_new_bucket.go +++ b/migrations/code/20200629093800_copy_to_new_bucket.go @@ -12,7 +12,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200707150700_after_sml_version_fix.go b/migrations/code/20200707150700_after_sml_version_fix.go index e61130dc..738570af 100644 --- a/migrations/code/20200707150700_after_sml_version_fix.go +++ b/migrations/code/20200707150700_after_sml_version_fix.go @@ -12,7 +12,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200829171600_after_db_dirty.go b/migrations/code/20200829171600_after_db_dirty.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20200829171600_after_db_dirty.go +++ b/migrations/code/20200829171600_after_db_dirty.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200829225100_after_broken_datajson.go b/migrations/code/20200829225100_after_broken_datajson.go index 0e179c5d..0c58ba67 100644 --- a/migrations/code/20200829225100_after_broken_datajson.go +++ b/migrations/code/20200829225100_after_broken_datajson.go @@ -12,7 +12,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20200830011200_after_gorm_hotfix.go b/migrations/code/20200830011200_after_gorm_hotfix.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20200830011200_after_gorm_hotfix.go +++ b/migrations/code/20200830011200_after_gorm_hotfix.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20201014162200_after_bp_fix.go b/migrations/code/20201014162200_after_bp_fix.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20201014162200_after_bp_fix.go +++ b/migrations/code/20201014162200_after_bp_fix.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20201016202600_after_body_enable.go b/migrations/code/20201016202600_after_body_enable.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20201016202600_after_body_enable.go +++ b/migrations/code/20201016202600_after_body_enable.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/migrations/code/20201019203800_after_remove_filter.go b/migrations/code/20201019203800_after_remove_filter.go index 9f66ec92..acffe573 100644 --- a/migrations/code/20201019203800_after_remove_filter.go +++ b/migrations/code/20201019203800_after_remove_filter.go @@ -11,7 +11,7 @@ import ( func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/models/filters.go b/models/filters.go index 2a384999..12c9bd2c 100644 --- a/models/filters.go +++ b/models/filters.go @@ -21,14 +21,14 @@ type VersionFilter struct { OrderBy *generated.VersionFields `json:"order_by"` Order *generated.Order `json:"order"` Search *string `json:"search" validate:"omitempty,min=3"` - Ids []string `json:"ids" validate:"omitempty,max=100"` + IDs []string `json:"ids" validate:"omitempty,max=100"` Fields []string `json:"-"` } func (f *VersionFilter) IsDefault(ignoreLimits bool) bool { return ((f.Limit != nil && *f.Limit == 10) || ignoreLimits) && f.Offset != nil && *f.Offset == 0 && - f.Ids == nil && + f.IDs == nil && f.Order != nil && *f.Order == generated.OrderDesc && f.OrderBy != nil && *f.OrderBy == generated.VersionFieldsCreatedAt } @@ -41,7 +41,7 @@ func DefaultVersionFilter() *VersionFilter { return &VersionFilter{ Limit: &limit, Offset: &offset, - Ids: nil, + IDs: nil, Order: &order, OrderBy: &orderBy, Fields: nil, @@ -101,7 +101,7 @@ type ModFilter struct { OrderBy *generated.ModFields `json:"order_by"` Order *generated.Order `json:"order"` Search *string `json:"search" validate:"omitempty,min=3"` - Ids []string `json:"ids" validate:"omitempty,max=100"` + IDs []string `json:"ids" validate:"omitempty,max=100"` References []string `json:"references" validate:"omitempty,max=100"` Hidden *bool `json:"hidden"` Fields []string `json:"-"` @@ -116,7 +116,7 @@ func DefaultModFilter() *ModFilter { return &ModFilter{ Limit: &limit, Offset: &offset, - Ids: nil, + IDs: nil, Order: &order, OrderBy: &orderBy, Fields: nil, @@ -179,7 +179,7 @@ type GuideFilter struct { OrderBy *generated.GuideFields `json:"order_by"` Order *generated.Order `json:"order"` Search *string `json:"search" validate:"omitempty,min=3"` - Ids []string `json:"ids" validate:"omitempty,max=100"` + IDs []string `json:"ids" validate:"omitempty,max=100"` TagIDs []string `json:"tagIDs" validate:"omitempty,max=100"` } @@ -199,7 +199,7 @@ func DefaultGuideFilter() *GuideFilter { return &GuideFilter{ Limit: &limit, Offset: &offset, - Ids: nil, + IDs: nil, Order: &order, OrderBy: &orderBy, } @@ -229,7 +229,7 @@ type SMLVersionFilter struct { OrderBy *generated.SMLVersionFields `json:"order_by"` Order *generated.Order `json:"order"` Search *string `json:"search" validate:"omitempty,min=3"` - Ids []string `json:"ids" validate:"omitempty,max=100"` + IDs []string `json:"ids" validate:"omitempty,max=100"` } func DefaultSMLVersionFilter() *SMLVersionFilter { @@ -240,7 +240,7 @@ func DefaultSMLVersionFilter() *SMLVersionFilter { return &SMLVersionFilter{ Limit: &limit, Offset: &offset, - Ids: nil, + IDs: nil, Order: &order, OrderBy: &orderBy, } @@ -270,8 +270,8 @@ func ApplyChanges(changes interface{}, to interface{}) error { TagName: "json", Result: to, ZeroFields: true, - DecodeHook: func(a reflect.Type, b reflect.Type, v interface{}) (interface{}, error) { - if reflect.PtrTo(b).Implements(reflect.TypeOf((*graphql.Unmarshaler)(nil)).Elem()) { + DecodeHook: func(_ reflect.Type, b reflect.Type, v interface{}) (interface{}, error) { + if reflect.PointerTo(b).Implements(reflect.TypeOf((*graphql.Unmarshaler)(nil)).Elem()) { resultType := reflect.New(b) result := resultType.MethodByName("UnmarshalGQL").Call([]reflect.Value{reflect.ValueOf(v)}) err, _ := result[0].Interface().(error) diff --git a/nodes/mod.go b/nodes/mod.go index 3eb28980..a01db1d3 100644 --- a/nodes/mod.go +++ b/nodes/mod.go @@ -130,7 +130,7 @@ func getMod(c echo.Context) (interface{}, *ErrorResponse) { // @Param modIds path string true "Mod IDs" // @Success 200 // @Router /mods/{modIds} [get] -func getModsByIds(c echo.Context) (interface{}, *ErrorResponse) { +func getModsByIDs(c echo.Context) (interface{}, *ErrorResponse) { modID := c.Param("modIds") modIDSplit := strings.Split(modID, ",") diff --git a/nodes/routes.go b/nodes/routes.go index b6c6cf6d..cd6bb34e 100755 --- a/nodes/routes.go +++ b/nodes/routes.go @@ -25,7 +25,7 @@ func RegisterModsRoutes(router *echo.Group) { router.GET("/count", dataWrapper(getModCount)) - router.GET("/:modIds", dataWrapper(getModsByIds)) + router.GET("/:modIds", dataWrapper(getModsByIDs)) router.GET("/:modIds/latest-versions", dataWrapper(getModsLatestVersions)) } diff --git a/oauth/facebook.go b/oauth/facebook.go index 8e4a41a3..c84f1889 100644 --- a/oauth/facebook.go +++ b/oauth/facebook.go @@ -38,7 +38,6 @@ func FacebookCallback(code string, state string) (*UserData, error) { var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) - if err != nil { return nil, fmt.Errorf("failed to unmarshal user data: %w", err) } diff --git a/oauth/github.go b/oauth/github.go index e9c9bfc3..97f53966 100644 --- a/oauth/github.go +++ b/oauth/github.go @@ -36,26 +36,22 @@ func GithubCallback(code string, state string) (*UserData, error) { var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) - if err != nil { return nil, fmt.Errorf("failed to unmarshal user data: %w", err) } resp, err = client.Get("https://api.github.com/user/emails") - if err != nil { return nil, fmt.Errorf("failed to get user emails: %w", err) } bytes, err = io.ReadAll(resp.Body) - if err != nil { return nil, fmt.Errorf("failed to read user emails: %w", err) } var userEmailsData []map[string]interface{} err = json.Unmarshal(bytes, &userEmailsData) - if err != nil { return nil, fmt.Errorf("failed to unmarshal user emails: %w", err) } diff --git a/oauth/google.go b/oauth/google.go index e7c4b8b3..ed0c04a5 100644 --- a/oauth/google.go +++ b/oauth/google.go @@ -37,7 +37,6 @@ func GoogleCallback(code string, state string) (*UserData, error) { var userData map[string]interface{} err = json.Unmarshal(bytes, &userData) - if err != nil { return nil, fmt.Errorf("failed to unmarshal user info: %w", err) } diff --git a/storage/s3.go b/storage/s3.go index 185c1f38..4f5efb29 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -170,7 +170,8 @@ func (s3o *S3) Rename(from string, to string) error { func (s3o *S3) Delete(key string) error { cleanedKey := strings.TrimPrefix(key, "/") - for i := 0; i < 10; i++ { + // Check up to 10 object pages + for range 10 { versions, err := s3o.S3Client.ListObjectVersions(&s3.ListObjectVersionsInput{ Bucket: aws.String(viper.GetString("storage.bucket")), KeyMarker: aws.String(cleanedKey), @@ -182,7 +183,6 @@ func (s3o *S3) Delete(key string) error { Bucket: aws.String(viper.GetString("storage.bucket")), Key: aws.String(cleanedKey), }) - if err != nil { return fmt.Errorf("failed to delete objects: %w", err) } @@ -214,7 +214,6 @@ func (s3o *S3) Delete(key string) error { Bucket: aws.String(viper.GetString("storage.bucket")), Key: aws.String(cleanedKey), }) - if err != nil { return fmt.Errorf("failed to delete objects: %w", err) } @@ -228,7 +227,6 @@ func (s3o *S3) Delete(key string) error { Objects: objects, }, }) - if err != nil { return fmt.Errorf("failed to delete objects: %w", err) } diff --git a/storage/storage.go b/storage/storage.go index 1543ca2e..5832180f 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -387,7 +387,6 @@ func SeparateModTarget(ctx context.Context, body []byte, modID, name, modVersion } err = copyModFileToArchZip(file, zipWriter, trimmedName) - if err != nil { slox.Error(ctx, "failed to add file to archive", slog.Any("err", err), slog.String("target", target)) return false, "", "", 0 @@ -429,13 +428,11 @@ func copyModFileToArchZip(file *zip.File, zipWriter *zip.Writer, newName string) buf := new(bytes.Buffer) _, err = buf.ReadFrom(rawFile) - if err != nil { return fmt.Errorf("failed to read file: %w", err) } _, err = zipFile.Write(buf.Bytes()) - if err != nil { return fmt.Errorf("failed to write file: %w", err) } diff --git a/tests/announcements_test.go b/tests/announcements_test.go index 608fb703..d7c6ce57 100644 --- a/tests/announcements_test.go +++ b/tests/announcements_test.go @@ -26,7 +26,7 @@ func TestAnnouncements(t *testing.T) { testza.AssertNoError(t, err) // Run Twice to detect any cache issues - for i := 0; i < 2; i++ { + for i := range 2 { t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var announcementID string diff --git a/tests/guides_test.go b/tests/guides_test.go index da5d8369..3516a54f 100644 --- a/tests/guides_test.go +++ b/tests/guides_test.go @@ -29,7 +29,7 @@ func TestGuides(t *testing.T) { testza.AssertNoError(t, err) // Run Twice to detect any cache issues - for i := 0; i < 2; i++ { + for i := range 2 { t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var guideID string diff --git a/tests/mod_test.go b/tests/mod_test.go index 7006e507..710f7608 100644 --- a/tests/mod_test.go +++ b/tests/mod_test.go @@ -29,7 +29,7 @@ func TestMods(t *testing.T) { testza.AssertNoError(t, err) // Run Twice to detect any cache issues - for i := 0; i < 2; i++ { + for i := range 2 { t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var objID string diff --git a/tests/sml_versions_test.go b/tests/sml_versions_test.go index 768530a9..f968d6df 100644 --- a/tests/sml_versions_test.go +++ b/tests/sml_versions_test.go @@ -32,7 +32,7 @@ func TestSMLVersions(t *testing.T) { } // Run Twice to detect any cache issues - for i := 0; i < 2; i++ { + for i := range 2 { t.Run("Loop"+strconv.Itoa(i), func(t *testing.T) { var objID string diff --git a/tests/version_test.go b/tests/version_test.go index 552667fe..de5fdf27 100644 --- a/tests/version_test.go +++ b/tests/version_test.go @@ -152,7 +152,7 @@ func TestVersions(t *testing.T) { chunkSize := int64(1e+7) chunkCount := int(math.Ceil(float64(stat.Size()) / float64(chunkSize))) // Split in 10MB chunks - for i := 0; i < chunkCount; i++ { + for i := range chunkCount { t.Run("Part"+strconv.Itoa(i), func(t *testing.T) { _, err = f.Seek(int64(i)*chunkSize, 0) testza.AssertNoError(t, err) diff --git a/util/security.go b/util/security.go index 56590c28..5e185116 100644 --- a/util/security.go +++ b/util/security.go @@ -17,7 +17,6 @@ var ( func InitializeSecurity() { var err error privateKey, err = hex.DecodeString(viper.GetString("paseto.private_key")) - if err != nil { panic(err) } diff --git a/validation/validation.go b/validation/validation.go index 50df00b4..b717f8bd 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -77,7 +77,6 @@ func InitializeValidator() { dataJSONSchema = gojsonschema.NewReferenceLoader("file://" + strings.ReplaceAll(absPath, "\\", "/")) absPath, err = filepath.Abs(filepath.Join(StaticPath, "uplugin-json-schema.json")) - if err != nil { panic(err) } @@ -139,7 +138,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal if withMetadata { // Extract all possible metadata - conn, err := grpc.Dial(viper.GetString("extractor_host"), grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err := grpc.NewClient(viper.GetString("extractor_host"), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, fmt.Errorf("failed to connect to metadata server: %w", err) } @@ -229,7 +228,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal retry.DelayType(retry.FixedDelay), retry.OnRetry(func(n uint, err error) { if n > 0 { - slox.Info(ctx, "retrying to extract metadata", slog.Uint64("n", uint64(n))) + slox.Info(ctx, "retrying to extract metadata", slog.Uint64("n", uint64(n)), slog.Any("err", err)) } })); err != nil { return nil, err //nolint @@ -240,7 +239,6 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal hash := sha256.New() _, err = hash.Write(body) - if err != nil { slox.Error(ctx, "error hashing pak", slog.Any("err", err)) } @@ -286,7 +284,6 @@ func validateDataJSON(archive *zip.Reader, dataFile *zip.File, withValidation bo var modInfo ModInfo err = json.Unmarshal(dataJSON, &modInfo) - if err != nil { return nil, errors.New("invalid data.json") } @@ -385,7 +382,6 @@ func validateUPluginJSON(archive *zip.Reader, uPluginFile *zip.File, withValidat var uPlugin UPlugin err = json.Unmarshal(uPluginJSON, &uPlugin) - if err != nil { return nil, errors.New("invalid " + uPluginFile.Name) } diff --git a/validation/virustotal.go b/validation/virustotal.go index 171fb3e3..fe25eabb 100644 --- a/validation/virustotal.go +++ b/validation/virustotal.go @@ -33,13 +33,13 @@ type AnalysisResults struct { } `json:"attributes,omitempty"` } -func ScanFiles(_ context.Context, files []io.Reader, names []string) (bool, error) { - errs, gctx := errgroup.WithContext(context.Background()) +func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, error) { + errs, gctx := errgroup.WithContext(ctx) fileCount := len(files) c := make(chan bool) - for i := 0; i < fileCount; i++ { + for i := range fileCount { count := i errs.Go(func() error { ok, err := scanFile(gctx, files[count], names[count]) @@ -85,7 +85,6 @@ func scanFile(ctx context.Context, file io.Reader, name string) (bool, error) { var target AnalysisResults _, err = client.GetData(vt.URL("analyses/%s", analysisID), &target) - if err != nil { return false, fmt.Errorf("failed to get analysis results: %w", err) } From 90dd27e4aa3c57b4dc6b68462c694dfaafb2a7d7 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 17 Jun 2024 22:37:54 +0300 Subject: [PATCH 18/19] chore: fix rebase issues --- db/schema/tag.go | 1 + generated/conv/guide.go | 1 + generated/conv/mod.go | 1 + generated/conv/tag.go | 1 + generated/ent/internal/schema.go | 2 +- generated/ent/migrate/schema.go | 1 + generated/ent/mutation.go | 56 ++- generated/ent/runtime/runtime.go | 4 + generated/ent/tag.go | 13 +- generated/ent/tag/tag.go | 10 + generated/ent/tag/where.go | 70 ++++ generated/ent/tag_create.go | 58 +++ generated/ent/tag_update.go | 44 +++ generated/generated.go | 374 +++++++++++++++--- generated/models_gen.go | 10 +- gql/resolver_tags.go | 10 +- migrations/code/20240108075200_new_parser.go | 14 +- ...d_rng.down.sql => 000026_add_rng.down.sql} | 0 ...5_add_rng.up.sql => 000026_add_rng.up.sql} | 0 ...own.sql => 000027_add_id_columns.down.sql} | 0 ...ns.up.sql => 000027_add_id_columns.up.sql} | 0 21 files changed, 599 insertions(+), 71 deletions(-) rename migrations/sql/{000025_add_rng.down.sql => 000026_add_rng.down.sql} (100%) rename migrations/sql/{000025_add_rng.up.sql => 000026_add_rng.up.sql} (100%) rename migrations/sql/{000026_add_id_columns.down.sql => 000027_add_id_columns.down.sql} (100%) rename migrations/sql/{000026_add_id_columns.up.sql => 000027_add_id_columns.up.sql} (100%) diff --git a/db/schema/tag.go b/db/schema/tag.go index 89ab737c..696cffde 100644 --- a/db/schema/tag.go +++ b/db/schema/tag.go @@ -21,6 +21,7 @@ func (Tag) Mixin() []ent.Mixin { func (Tag) Fields() []ent.Field { return []ent.Field{ field.String("name").MaxLen(24).Unique(), + field.String("description").MaxLen(512).Unique(), } } diff --git a/generated/conv/guide.go b/generated/conv/guide.go index d7b44d47..c88a0ecd 100755 --- a/generated/conv/guide.go +++ b/generated/conv/guide.go @@ -51,6 +51,7 @@ func (c *GuideImpl) pEntTagToPGeneratedTag(source *ent.Tag) *generated.Tag { 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/mod.go b/generated/conv/mod.go index 1b7ad916..d54bd81b 100755 --- a/generated/conv/mod.go +++ b/generated/conv/mod.go @@ -66,6 +66,7 @@ func (c *ModImpl) pEntTagToPGeneratedTag(source *ent.Tag) *generated.Tag { 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/tag.go b/generated/conv/tag.go index 299f198b..ead3ebfc 100755 --- a/generated/conv/tag.go +++ b/generated/conv/tag.go @@ -16,6 +16,7 @@ func (c *TagImpl) Convert(source *ent.Tag) *generated.Tag { var generatedTag generated.Tag generatedTag.ID = (*source).ID generatedTag.Name = (*source).Name + generatedTag.Description = (*source).Description pGeneratedTag = &generatedTag } return pGeneratedTag diff --git a/generated/ent/internal/schema.go b/generated/ent/internal/schema.go index 63b706be..414b7fdb 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\":[\"id\"]},{\"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\":[\"id\"]},{\"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},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"source_url\",\"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\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":6,\"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\":7,\"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\":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\":\"downloads\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"last_version_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":13,\"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\":14,\"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\":15,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"last_version_date\"]}],\"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\":\"SmlVersion\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"targets\",\"type\":\"SmlVersionTarget\"}],\"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\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"satisfactory_version\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"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\"}],\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"bootstrap_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"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\":7,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"SmlVersionTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"sml_version\",\"type\":\"SmlVersion\",\"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\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]},{\"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}}],\"indexes\":[{\"fields\":[\"id\"]},{\"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,\"unique\":true,\"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\":\"joined_from\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"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\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"github_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"google_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"facebook_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"email\"]},{\"fields\":[\"github_id\"]},{\"fields\":[\"google_id\"]},{\"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\":[\"id\"]},{\"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\":256,\"unique\":true,\"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\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\"}],\"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\":\"sml_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"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\"}],\"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\":\"hotness\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"metadata\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_major\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_minor\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_patch\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"optional\":true,\"validators\":2,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\":\"sml_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\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_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\":[\"id\"]},{\"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\":[\"id\"]},{\"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},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"source_url\",\"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\":\"approved\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":6,\"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\":7,\"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\":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\":\"downloads\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"last_version_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":13,\"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\":14,\"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\":15,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"last_version_date\"]}],\"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\":\"SmlVersion\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"targets\",\"type\":\"SmlVersionTarget\"}],\"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\":\"version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"satisfactory_version\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":1,\"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\"}],\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"bootstrap_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":14,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"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\":7,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2}]},{\"name\":\"SmlVersionTarget\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"sml_version\",\"type\":\"SmlVersion\",\"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\":\"link\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_name\"]}]},{\"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,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"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,\"unique\":true,\"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\":\"joined_from\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"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\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"github_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"google_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"facebook_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"unique\":true,\"optional\":true,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]},{\"fields\":[\"email\"]},{\"fields\":[\"github_id\"]},{\"fields\":[\"google_id\"]},{\"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\":[\"id\"]},{\"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\":256,\"unique\":true,\"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\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\"}],\"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\":\"sml_version\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"changelog\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"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\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"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\"}],\"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\":\"hotness\",\"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\":\"denied\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"metadata\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"mod_reference\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_major\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_minor\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"version_patch\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"size\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"hash\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"optional\":true,\"validators\":2,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0}}],\"indexes\":[{\"fields\":[\"id\"]},{\"fields\":[\"deleted_at\"]}],\"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\":\"sml_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\":[{\"fields\":[\"id\"]},{\"unique\":true,\"fields\":[\"version_id\",\"target_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 25c01af0..416d4467 100644 --- a/generated/ent/migrate/schema.go +++ b/generated/ent/migrate/schema.go @@ -242,6 +242,7 @@ var ( {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "name", Type: field.TypeString, Unique: true, Size: 24}, + {Name: "description", Type: field.TypeString, Unique: true, Size: 512}, } // TagsTable holds the schema information for the "tags" table. TagsTable = &schema.Table{ diff --git a/generated/ent/mutation.go b/generated/ent/mutation.go index 8d527afe..c84637b1 100644 --- a/generated/ent/mutation.go +++ b/generated/ent/mutation.go @@ -5729,6 +5729,7 @@ type TagMutation struct { updated_at *time.Time deleted_at *time.Time name *string + description *string clearedFields map[string]struct{} mods map[string]struct{} removedmods map[string]struct{} @@ -6002,6 +6003,42 @@ func (m *TagMutation) ResetName() { m.name = nil } +// SetDescription sets the "description" field. +func (m *TagMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *TagMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Tag entity. +// If the Tag 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 *TagMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *TagMutation) ResetDescription() { + m.description = nil +} + // AddModIDs adds the "mods" edge to the Mod entity by ids. func (m *TagMutation) AddModIDs(ids ...string) { if m.mods == nil { @@ -6144,7 +6181,7 @@ func (m *TagMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *TagMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 5) if m.created_at != nil { fields = append(fields, tag.FieldCreatedAt) } @@ -6157,6 +6194,9 @@ func (m *TagMutation) Fields() []string { if m.name != nil { fields = append(fields, tag.FieldName) } + if m.description != nil { + fields = append(fields, tag.FieldDescription) + } return fields } @@ -6173,6 +6213,8 @@ func (m *TagMutation) Field(name string) (ent.Value, bool) { return m.DeletedAt() case tag.FieldName: return m.Name() + case tag.FieldDescription: + return m.Description() } return nil, false } @@ -6190,6 +6232,8 @@ func (m *TagMutation) OldField(ctx context.Context, name string) (ent.Value, err return m.OldDeletedAt(ctx) case tag.FieldName: return m.OldName(ctx) + case tag.FieldDescription: + return m.OldDescription(ctx) } return nil, fmt.Errorf("unknown Tag field %s", name) } @@ -6227,6 +6271,13 @@ func (m *TagMutation) SetField(name string, value ent.Value) error { } m.SetName(v) return nil + case tag.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil } return fmt.Errorf("unknown Tag field %s", name) } @@ -6297,6 +6348,9 @@ func (m *TagMutation) ResetField(name string) error { case tag.FieldName: m.ResetName() return nil + case tag.FieldDescription: + m.ResetDescription() + return nil } return fmt.Errorf("unknown Tag field %s", name) } diff --git a/generated/ent/runtime/runtime.go b/generated/ent/runtime/runtime.go index 75f7985e..7dd19905 100644 --- a/generated/ent/runtime/runtime.go +++ b/generated/ent/runtime/runtime.go @@ -224,6 +224,10 @@ func init() { tagDescName := tagFields[0].Descriptor() // tag.NameValidator is a validator for the "name" field. It is called by the builders before save. tag.NameValidator = tagDescName.Validators[0].(func(string) error) + // tagDescDescription is the schema descriptor for description field. + tagDescDescription := tagFields[1].Descriptor() + // tag.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + tag.DescriptionValidator = tagDescDescription.Validators[0].(func(string) error) // tagDescID is the schema descriptor for id field. tagDescID := tagMixinFields0[0].Descriptor() // tag.DefaultID holds the default value on creation for the id field. diff --git a/generated/ent/tag.go b/generated/ent/tag.go index 2ebf8da4..5c0c9f73 100644 --- a/generated/ent/tag.go +++ b/generated/ent/tag.go @@ -25,6 +25,8 @@ type Tag struct { DeletedAt time.Time `json:"deleted_at,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TagQuery when eager-loading is set. Edges TagEdges `json:"edges"` @@ -87,7 +89,7 @@ func (*Tag) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case tag.FieldID, tag.FieldName: + case tag.FieldID, tag.FieldName, tag.FieldDescription: values[i] = new(sql.NullString) case tag.FieldCreatedAt, tag.FieldUpdatedAt, tag.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -136,6 +138,12 @@ func (t *Tag) assignValues(columns []string, values []any) error { } else if value.Valid { t.Name = value.String } + case tag.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + t.Description = value.String + } default: t.selectValues.Set(columns[i], values[i]) } @@ -203,6 +211,9 @@ func (t *Tag) String() string { builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(t.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(t.Description) builder.WriteByte(')') return builder.String() } diff --git a/generated/ent/tag/tag.go b/generated/ent/tag/tag.go index 050d1776..f2b1d4e0 100644 --- a/generated/ent/tag/tag.go +++ b/generated/ent/tag/tag.go @@ -23,6 +23,8 @@ const ( FieldDeletedAt = "deleted_at" // FieldName holds the string denoting the name field in the database. FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" // EdgeMods holds the string denoting the mods edge name in mutations. EdgeMods = "mods" // EdgeGuides holds the string denoting the guides edge name in mutations. @@ -66,6 +68,7 @@ var Columns = []string{ FieldUpdatedAt, FieldDeletedAt, FieldName, + FieldDescription, } var ( @@ -103,6 +106,8 @@ var ( UpdateDefaultUpdatedAt func() time.Time // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error // DefaultID holds the default value on creation for the "id" field. DefaultID func() string ) @@ -135,6 +140,11 @@ func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() } +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + // ByModsCount orders the results by mods count. func ByModsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/generated/ent/tag/where.go b/generated/ent/tag/where.go index d32739d5..972356f6 100644 --- a/generated/ent/tag/where.go +++ b/generated/ent/tag/where.go @@ -85,6 +85,11 @@ func Name(v string) predicate.Tag { return predicate.Tag(sql.FieldEQ(FieldName, v)) } +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldDescription, v)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v time.Time) predicate.Tag { return predicate.Tag(sql.FieldEQ(FieldCreatedAt, v)) @@ -280,6 +285,71 @@ func NameContainsFold(v string) predicate.Tag { return predicate.Tag(sql.FieldContainsFold(FieldName, v)) } +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Tag { + return predicate.Tag(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Tag { + return predicate.Tag(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Tag { + return predicate.Tag(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Tag { + return predicate.Tag(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Tag { + return predicate.Tag(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Tag { + return predicate.Tag(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Tag { + return predicate.Tag(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Tag { + return predicate.Tag(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Tag { + return predicate.Tag(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Tag { + return predicate.Tag(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Tag { + return predicate.Tag(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Tag { + return predicate.Tag(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Tag { + return predicate.Tag(sql.FieldContainsFold(FieldDescription, v)) +} + // HasMods applies the HasEdge predicate on the "mods" edge. func HasMods() predicate.Tag { return predicate.Tag(func(s *sql.Selector) { diff --git a/generated/ent/tag_create.go b/generated/ent/tag_create.go index b6a387b7..ab8005f3 100644 --- a/generated/ent/tag_create.go +++ b/generated/ent/tag_create.go @@ -73,6 +73,12 @@ func (tc *TagCreate) SetName(s string) *TagCreate { return tc } +// SetDescription sets the "description" field. +func (tc *TagCreate) SetDescription(s string) *TagCreate { + tc.mutation.SetDescription(s) + return tc +} + // SetID sets the "id" field. func (tc *TagCreate) SetID(s string) *TagCreate { tc.mutation.SetID(s) @@ -194,6 +200,14 @@ func (tc *TagCreate) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} } } + if _, ok := tc.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Tag.description"`)} + } + if v, ok := tc.mutation.Description(); ok { + if err := tag.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)} + } + } return nil } @@ -246,6 +260,10 @@ func (tc *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) { _spec.SetField(tag.FieldName, field.TypeString, value) _node.Name = value } + if value, ok := tc.mutation.Description(); ok { + _spec.SetField(tag.FieldDescription, field.TypeString, value) + _node.Description = value + } if nodes := tc.mutation.ModsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -372,6 +390,18 @@ func (u *TagUpsert) UpdateName() *TagUpsert { return u } +// SetDescription sets the "description" field. +func (u *TagUpsert) SetDescription(v string) *TagUpsert { + u.Set(tag.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *TagUpsert) UpdateDescription() *TagUpsert { + u.SetExcluded(tag.FieldDescription) + 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: // @@ -472,6 +502,20 @@ func (u *TagUpsertOne) UpdateName() *TagUpsertOne { }) } +// SetDescription sets the "description" field. +func (u *TagUpsertOne) SetDescription(v string) *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *TagUpsertOne) UpdateDescription() *TagUpsertOne { + return u.Update(func(s *TagUpsert) { + s.UpdateDescription() + }) +} + // Exec executes the query. func (u *TagUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -739,6 +783,20 @@ func (u *TagUpsertBulk) UpdateName() *TagUpsertBulk { }) } +// SetDescription sets the "description" field. +func (u *TagUpsertBulk) SetDescription(v string) *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *TagUpsertBulk) UpdateDescription() *TagUpsertBulk { + return u.Update(func(s *TagUpsert) { + s.UpdateDescription() + }) +} + // Exec executes the query. func (u *TagUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/generated/ent/tag_update.go b/generated/ent/tag_update.go index ace34e95..795d3068 100644 --- a/generated/ent/tag_update.go +++ b/generated/ent/tag_update.go @@ -71,6 +71,20 @@ func (tu *TagUpdate) SetNillableName(s *string) *TagUpdate { return tu } +// SetDescription sets the "description" field. +func (tu *TagUpdate) SetDescription(s string) *TagUpdate { + tu.mutation.SetDescription(s) + return tu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (tu *TagUpdate) SetNillableDescription(s *string) *TagUpdate { + if s != nil { + tu.SetDescription(*s) + } + return tu +} + // AddModIDs adds the "mods" edge to the Mod entity by IDs. func (tu *TagUpdate) AddModIDs(ids ...string) *TagUpdate { tu.mutation.AddModIDs(ids...) @@ -197,6 +211,11 @@ func (tu *TagUpdate) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} } } + if v, ok := tu.mutation.Description(); ok { + if err := tag.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)} + } + } return nil } @@ -230,6 +249,9 @@ func (tu *TagUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := tu.mutation.Name(); ok { _spec.SetField(tag.FieldName, field.TypeString, value) } + if value, ok := tu.mutation.Description(); ok { + _spec.SetField(tag.FieldDescription, field.TypeString, value) + } if tu.mutation.ModsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -382,6 +404,20 @@ func (tuo *TagUpdateOne) SetNillableName(s *string) *TagUpdateOne { return tuo } +// SetDescription sets the "description" field. +func (tuo *TagUpdateOne) SetDescription(s string) *TagUpdateOne { + tuo.mutation.SetDescription(s) + return tuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (tuo *TagUpdateOne) SetNillableDescription(s *string) *TagUpdateOne { + if s != nil { + tuo.SetDescription(*s) + } + return tuo +} + // AddModIDs adds the "mods" edge to the Mod entity by IDs. func (tuo *TagUpdateOne) AddModIDs(ids ...string) *TagUpdateOne { tuo.mutation.AddModIDs(ids...) @@ -521,6 +557,11 @@ func (tuo *TagUpdateOne) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)} } } + if v, ok := tuo.mutation.Description(); ok { + if err := tag.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)} + } + } return nil } @@ -571,6 +612,9 @@ func (tuo *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) { if value, ok := tuo.mutation.Name(); ok { _spec.SetField(tag.FieldName, field.TypeString, value) } + if value, ok := tuo.mutation.Description(); ok { + _spec.SetField(tag.FieldDescription, field.TypeString, value) + } if tuo.mutation.ModsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/generated/generated.go b/generated/generated.go index 6da140b2..ed247e62 100644 --- a/generated/generated.go +++ b/generated/generated.go @@ -184,9 +184,9 @@ type ComplexityRoot struct { CreateAnnouncement func(childComplexity int, announcement NewAnnouncement) int CreateGuide func(childComplexity int, guide NewGuide) int CreateMod func(childComplexity int, mod NewMod) int - CreateMultipleTags func(childComplexity int, tagNames []string) int + CreateMultipleTags func(childComplexity int, tagNames []*NewTag) int CreateSMLVersion func(childComplexity int, smlVersion NewSMLVersion) int - CreateTag func(childComplexity int, tagName string) int + CreateTag func(childComplexity int, tagName string, description string) int CreateVersion func(childComplexity int, modID string) int DeleteAnnouncement func(childComplexity int, announcementID string) int DeleteGuide func(childComplexity int, guideID string) int @@ -208,7 +208,7 @@ type ComplexityRoot struct { UpdateModCompatibility func(childComplexity int, modID string, compatibility CompatibilityInfoInput) int UpdateMultipleModCompatibilities func(childComplexity int, modIDs []string, compatibility CompatibilityInfoInput) int UpdateSMLVersion func(childComplexity int, smlVersionID string, smlVersion UpdateSMLVersion) int - UpdateTag func(childComplexity int, tagID string, newName string) int + UpdateTag func(childComplexity int, tagID string, newName string, description string) int UpdateUser func(childComplexity int, userID string, input UpdateUser) int UpdateVersion func(childComplexity int, versionID string, version UpdateVersion) int UploadVersionPart func(childComplexity int, modID string, versionID string, part int, file graphql.Upload) int @@ -229,6 +229,7 @@ type ComplexityRoot struct { GetGuides func(childComplexity int, filter map[string]interface{}) int GetMe func(childComplexity int) int GetMod func(childComplexity int, modID string) int + GetModAssetList func(childComplexity int, modReference string) int GetModByIDOrReference func(childComplexity int, modIDOrReference string) int GetModByReference func(childComplexity int, modReference string) int GetMods func(childComplexity int, filter map[string]interface{}) int @@ -272,8 +273,9 @@ type ComplexityRoot struct { } Tag struct { - ID func(childComplexity int) int - Name func(childComplexity int) int + Description func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int } User struct { @@ -403,9 +405,9 @@ type MutationResolver interface { CreateSMLVersion(ctx context.Context, smlVersion NewSMLVersion) (*SMLVersion, error) UpdateSMLVersion(ctx context.Context, smlVersionID string, smlVersion UpdateSMLVersion) (*SMLVersion, error) DeleteSMLVersion(ctx context.Context, smlVersionID string) (bool, error) - CreateTag(ctx context.Context, tagName string) (*Tag, error) - CreateMultipleTags(ctx context.Context, tagNames []string) ([]*Tag, error) - UpdateTag(ctx context.Context, tagID string, newName string) (*Tag, error) + CreateTag(ctx context.Context, tagName string, description string) (*Tag, error) + CreateMultipleTags(ctx context.Context, tagNames []*NewTag) ([]*Tag, error) + UpdateTag(ctx context.Context, tagID string, newName string, description string) (*Tag, error) DeleteTag(ctx context.Context, tagID string) (bool, error) UpdateUser(ctx context.Context, userID string, input UpdateUser) (*User, error) Logout(ctx context.Context) (bool, error) @@ -435,6 +437,7 @@ type QueryResolver interface { GetMyMods(ctx context.Context, filter map[string]interface{}) (*GetMyMods, error) 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) GetSMLVersion(ctx context.Context, smlVersionID string) (*SMLVersion, error) GetSMLVersions(ctx context.Context, filter map[string]interface{}) (*GetSMLVersions, error) GetTag(ctx context.Context, tagID string) (*Tag, error) @@ -1004,7 +1007,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Mutation.CreateMultipleTags(childComplexity, args["tagNames"].([]string)), true + return e.complexity.Mutation.CreateMultipleTags(childComplexity, args["tagNames"].([]*NewTag)), true case "Mutation.createSMLVersion": if e.complexity.Mutation.CreateSMLVersion == nil { @@ -1028,7 +1031,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Mutation.CreateTag(childComplexity, args["tagName"].(string)), true + return e.complexity.Mutation.CreateTag(childComplexity, args["tagName"].(string), args["description"].(string)), true case "Mutation.createVersion": if e.complexity.Mutation.CreateVersion == nil { @@ -1287,7 +1290,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Mutation.UpdateTag(childComplexity, args["tagID"].(string), args["NewName"].(string)), true + return e.complexity.Mutation.UpdateTag(childComplexity, args["tagID"].(string), args["NewName"].(string), args["description"].(string)), true case "Mutation.updateUser": if e.complexity.Mutation.UpdateUser == nil { @@ -1432,6 +1435,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.GetMod(childComplexity, args["modId"].(string)), true + case "Query.getModAssetList": + if e.complexity.Query.GetModAssetList == nil { + break + } + + args, err := ec.field_Query_getModAssetList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetModAssetList(childComplexity, args["modReference"].(string)), true + case "Query.getModByIdOrReference": if e.complexity.Query.GetModByIDOrReference == nil { break @@ -1765,6 +1780,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.SMLVersionTarget.VersionID(childComplexity), true + case "Tag.description": + if e.complexity.Tag.Description == nil { + break + } + + return e.complexity.Tag.Description(childComplexity), true + case "Tag.id": if e.complexity.Tag.ID == nil { break @@ -2175,6 +2197,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputNewMod, ec.unmarshalInputNewSMLVersion, ec.unmarshalInputNewSMLVersionTarget, + ec.unmarshalInputNewTag, ec.unmarshalInputNewVersion, ec.unmarshalInputSMLVersionFilter, ec.unmarshalInputTagFilter, @@ -2588,6 +2611,8 @@ extend type Query { getMyUnapprovedMods(filter: ModFilter): GetMyMods! @isLoggedIn resolveModVersions(filter: [ModVersionConstraint!]!): [ModVersion!]! + + getModAssetList(modReference: ModID!): [String!]! } ### Mutations @@ -2694,7 +2719,7 @@ extend type Query { ### Mutations extend type Mutation { - createSMLVersion(smlVersion: NewSMLVersion!): SMLVersion @isLoggedIn + createSMLVersion(smlVersion: NewSMLVersion!): SMLVersion @canEditSMLVersions @isLoggedIn updateSMLVersion(smlVersionId: SMLVersionID!, smlVersion: UpdateSMLVersion!): SMLVersion! @canEditSMLVersions @isLoggedIn deleteSMLVersion(smlVersionId: SMLVersionID!): Boolean! @canEditSMLVersions @isLoggedIn } @@ -2705,6 +2730,12 @@ scalar TagName type Tag { id: TagID! name: TagName! + description: String! +} + +input NewTag { + name: TagName! + description: String! } input TagFilter { @@ -2723,9 +2754,9 @@ extend type Query { ### Mutations extend type Mutation { - createTag(tagName: TagName!): Tag @canManageTags @isLoggedIn - createMultipleTags(tagNames: [TagName!]!): [Tag!]! @canManageTags @isLoggedIn - updateTag(tagID: TagID!, NewName: TagName!): Tag! @canManageTags @isLoggedIn + createTag(tagName: TagName!, description: String!): Tag @canManageTags @isLoggedIn + createMultipleTags(tagNames: [NewTag!]!): [Tag!]! @canManageTags @isLoggedIn + updateTag(tagID: TagID!, NewName: TagName!, description: String!): Tag! @canManageTags @isLoggedIn deleteTag(tagID: TagID!): Boolean! @canManageTags @isLoggedIn }`, BuiltIn: false}, {Name: "../schemas/user.graphql", Input: `### Types @@ -3132,10 +3163,10 @@ func (ec *executionContext) field_Mutation_createMod_args(ctx context.Context, r func (ec *executionContext) field_Mutation_createMultipleTags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 []string + var arg0 []*NewTag if tmp, ok := rawArgs["tagNames"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tagNames")) - arg0, err = ec.unmarshalNTagName2ᚕstringᚄ(ctx, tmp) + arg0, err = ec.unmarshalNNewTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewTagᚄ(ctx, tmp) if err != nil { return nil, err } @@ -3171,6 +3202,15 @@ func (ec *executionContext) field_Mutation_createTag_args(ctx context.Context, r } } args["tagName"] = arg0 + var arg1 string + if tmp, ok := rawArgs["description"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["description"] = arg1 return args, nil } @@ -3603,6 +3643,15 @@ func (ec *executionContext) field_Mutation_updateTag_args(ctx context.Context, r } } args["NewName"] = arg1 + var arg2 string + if tmp, ok := rawArgs["description"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + arg2, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["description"] = arg2 return args, nil } @@ -3795,6 +3844,21 @@ func (ec *executionContext) field_Query_getGuides_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_getModAssetList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["modReference"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modReference")) + arg0, err = ec.unmarshalNModID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["modReference"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_getModByIdOrReference_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -5798,6 +5862,8 @@ func (ec *executionContext) fieldContext_Guide_tags(_ context.Context, field gra 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) }, @@ -6882,6 +6948,8 @@ func (ec *executionContext) fieldContext_Mod_tags(_ context.Context, field graph 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) }, @@ -8689,13 +8757,19 @@ func (ec *executionContext) _Mutation_createSMLVersion(ctx context.Context, fiel return ec.resolvers.Mutation().CreateSMLVersion(rctx, fc.Args["smlVersion"].(NewSMLVersion)) } directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.CanEditSMLVersions == nil { + return nil, errors.New("directive canEditSMLVersions is not implemented") + } + return ec.directives.CanEditSMLVersions(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { if ec.directives.IsLoggedIn == nil { return nil, 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) } @@ -8972,7 +9046,7 @@ func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graph resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string)) + return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["tagName"].(string), fc.Args["description"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.CanManageTags == nil { @@ -9023,6 +9097,8 @@ func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, 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) }, @@ -9056,7 +9132,7 @@ func (ec *executionContext) _Mutation_createMultipleTags(ctx context.Context, fi resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateMultipleTags(rctx, fc.Args["tagNames"].([]string)) + return ec.resolvers.Mutation().CreateMultipleTags(rctx, fc.Args["tagNames"].([]*NewTag)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.CanManageTags == nil { @@ -9110,6 +9186,8 @@ func (ec *executionContext) fieldContext_Mutation_createMultipleTags(ctx context 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) }, @@ -9143,7 +9221,7 @@ func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graph resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["tagID"].(string), fc.Args["NewName"].(string)) + return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["tagID"].(string), fc.Args["NewName"].(string), fc.Args["description"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.CanManageTags == nil { @@ -9197,6 +9275,8 @@ func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, 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) }, @@ -11504,6 +11584,61 @@ func (ec *executionContext) fieldContext_Query_resolveModVersions(ctx context.Co 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) + 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) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetModAssetList(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) + fc.Result = res + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getModAssetList(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) { + 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) _Query_getSMLVersion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_getSMLVersion(ctx, field) if err != nil { @@ -11683,6 +11818,8 @@ func (ec *executionContext) fieldContext_Query_getTag(ctx context.Context, 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 Tag", field.Name) }, @@ -11744,6 +11881,8 @@ func (ec *executionContext) fieldContext_Query_getTags(ctx context.Context, fiel 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) }, @@ -13376,6 +13515,50 @@ func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graph 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) + 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) (interface{}, 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 { + 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_Tag_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 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) if err != nil { @@ -18512,6 +18695,40 @@ func (ec *executionContext) unmarshalInputNewSMLVersionTarget(ctx context.Contex return it, nil } +func (ec *executionContext) unmarshalInputNewTag(ctx context.Context, obj interface{}) (NewTag, error) { + var it NewTag + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "description"} + 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.unmarshalNTagName2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Description = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputNewVersion(ctx context.Context, obj interface{}) (NewVersion, error) { var it NewVersion asMap := map[string]interface{}{} @@ -21069,6 +21286,28 @@ 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 "getModAssetList": + 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_getModAssetList(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 "getSMLVersion": field := field @@ -21530,6 +21769,11 @@ func (ec *executionContext) _Tag(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { out.Invalids++ } + case "description": + out.Values[i] = ec._Tag_description(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -23344,6 +23588,28 @@ func (ec *executionContext) unmarshalNNewSMLVersionTarget2ᚖgithubᚗcomᚋsati return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNNewTag2ᚕᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewTagᚄ(ctx context.Context, v interface{}) ([]*NewTag, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*NewTag, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNNewTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewTag(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNNewTag2ᚖgithubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewTag(ctx context.Context, v interface{}) (*NewTag, error) { + res, err := ec.unmarshalInputNewTag(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNNewVersion2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐNewVersion(ctx context.Context, v interface{}) (NewVersion, error) { res, err := ec.unmarshalInputNewVersion(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -23489,6 +23755,38 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return res } +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + 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.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) marshalNTag2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTag(ctx context.Context, sel ast.SelectionSet, v Tag) graphql.Marshaler { return ec._Tag(ctx, sel, &v) } @@ -23577,38 +23875,6 @@ func (ec *executionContext) marshalNTagName2string(ctx context.Context, sel ast. return res } -func (ec *executionContext) unmarshalNTagName2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - 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.unmarshalNTagName2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNTagName2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNTagName2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - func (ec *executionContext) unmarshalNTargetName2githubᚗcomᚋsatisfactorymoddingᚋsmrᚑapiᚋgeneratedᚐTargetName(ctx context.Context, v interface{}) (TargetName, error) { var res TargetName err := res.UnmarshalGQL(v) diff --git a/generated/models_gen.go b/generated/models_gen.go index 842f8e57..5947ad99 100644 --- a/generated/models_gen.go +++ b/generated/models_gen.go @@ -164,6 +164,11 @@ type NewSMLVersionTarget struct { Link string `json:"link"` } +type NewTag struct { + Name string `json:"name"` + Description string `json:"description"` +} + type NewVersion struct { Changelog string `json:"changelog"` Stability VersionStabilities `json:"stability"` @@ -200,8 +205,9 @@ type SMLVersionTarget struct { } type Tag struct { - ID string `json:"id"` - Name string `json:"name"` + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` } type TagFilter struct { diff --git a/gql/resolver_tags.go b/gql/resolver_tags.go index 0f093eb8..6b21657d 100644 --- a/gql/resolver_tags.go +++ b/gql/resolver_tags.go @@ -23,7 +23,7 @@ func (r *mutationResolver) CreateTag(ctx context.Context, tagName string, descri return nil, err } - result, err := db.From(ctx).Tag.Create().SetName(tagName).Save(ctx) + result, err := db.From(ctx).Tag.Create().SetName(tagName).SetDescription(description).Save(ctx) if err != nil { return nil, err } @@ -41,8 +41,8 @@ func (r *mutationResolver) CreateMultipleTags(ctx context.Context, tags []*gener } } - result, err := db.From(ctx).Tag.MapCreateBulk(tagNames, func(create *ent.TagCreate, i int) { - create.SetName(tagNames[i]) + result, err := db.From(ctx).Tag.MapCreateBulk(tags, func(create *ent.TagCreate, i int) { + create.SetName(tags[i].Name).SetDescription(tags[i].Description) }).Save(ctx) if err != nil { return nil, err @@ -72,9 +72,7 @@ func (r *mutationResolver) UpdateTag(ctx context.Context, id string, newName str update := db.From(ctx).Tag.UpdateOneID(id) - SetINNOEF(&newName, update.SetName) - - result, err := update.SetName(newName).Save(ctx) + result, err := update.SetName(newName).SetDescription(description).Save(ctx) if err != nil { return nil, err } diff --git a/migrations/code/20240108075200_new_parser.go b/migrations/code/20240108075200_new_parser.go index 021f9aa0..b77521e6 100644 --- a/migrations/code/20240108075200_new_parser.go +++ b/migrations/code/20240108075200_new_parser.go @@ -5,21 +5,23 @@ import ( "strings" "github.com/lab259/go-migration" - "github.com/rs/zerolog/log" + "github.com/satisfactorymodding/smr-api/db" + "github.com/satisfactorymodding/smr-api/generated/ent" - "github.com/satisfactorymodding/smr-api/db/postgres" "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( func(executionContext interface{}) error { - ctx := log.Logger.WithContext(context.TODO()) - utils.ReindexAllModFiles(ctx, true, nil, func(version postgres.Version) bool { - smlVersion := version.SMLVersion + ctx, err := db.WithDB(context.Background()) + if err != nil { + return err + } + return utils.ReindexAllModFiles(ctx, true, nil, func(version *ent.Version) bool { + smlVersion := version.SmlVersion return strings.Contains(smlVersion, "3.6.1") || strings.Contains(smlVersion, "3.7.0") }) - return nil }, ) } diff --git a/migrations/sql/000025_add_rng.down.sql b/migrations/sql/000026_add_rng.down.sql similarity index 100% rename from migrations/sql/000025_add_rng.down.sql rename to migrations/sql/000026_add_rng.down.sql diff --git a/migrations/sql/000025_add_rng.up.sql b/migrations/sql/000026_add_rng.up.sql similarity index 100% rename from migrations/sql/000025_add_rng.up.sql rename to migrations/sql/000026_add_rng.up.sql diff --git a/migrations/sql/000026_add_id_columns.down.sql b/migrations/sql/000027_add_id_columns.down.sql similarity index 100% rename from migrations/sql/000026_add_id_columns.down.sql rename to migrations/sql/000027_add_id_columns.down.sql diff --git a/migrations/sql/000026_add_id_columns.up.sql b/migrations/sql/000027_add_id_columns.up.sql similarity index 100% rename from migrations/sql/000026_add_id_columns.up.sql rename to migrations/sql/000027_add_id_columns.up.sql From adf0cbe133d44154a59b44fb81c142ddfa4f76c9 Mon Sep 17 00:00:00 2001 From: Vilsol <me@vil.so> Date: Mon, 17 Jun 2024 22:43:18 +0300 Subject: [PATCH 19/19] chore: fix lint --- migrations/code/20240108075200_new_parser.go | 4 ++-- storage/s3.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migrations/code/20240108075200_new_parser.go b/migrations/code/20240108075200_new_parser.go index b77521e6..a09baaa6 100644 --- a/migrations/code/20240108075200_new_parser.go +++ b/migrations/code/20240108075200_new_parser.go @@ -5,15 +5,15 @@ import ( "strings" "github.com/lab259/go-migration" + "github.com/satisfactorymodding/smr-api/db" "github.com/satisfactorymodding/smr-api/generated/ent" - "github.com/satisfactorymodding/smr-api/migrations/utils" ) func init() { migration.NewCodeMigration( - func(executionContext interface{}) error { + func(_ interface{}) error { ctx, err := db.WithDB(context.Background()) if err != nil { return err diff --git a/storage/s3.go b/storage/s3.go index 4f5efb29..19e00648 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -258,7 +258,7 @@ func (s3o *S3) List(prefix string) ([]Object, error) { err := s3o.S3Client.ListObjectsPages(&s3.ListObjectsInput{ Bucket: aws.String(viper.GetString("storage.bucket")), Prefix: aws.String(prefix), - }, func(output *s3.ListObjectsOutput, b bool) bool { + }, func(output *s3.ListObjectsOutput, _ bool) bool { for _, obj := range output.Contents { out = append(out, Object{ Key: obj.Key,