From 57ce3cce62532bed5032a0a0fe7d17263675452c Mon Sep 17 00:00:00 2001 From: KCarretto Date: Sun, 18 Feb 2024 18:16:48 +0000 Subject: [PATCH 1/6] refactored to TomeImporter interface --- tavern/app.go | 9 ++- tavern/config.go | 21 +++++++ tavern/internal/graphql/api_test.go | 6 +- tavern/internal/graphql/mutation.resolvers.go | 5 +- tavern/internal/graphql/quest_test.go | 6 +- tavern/internal/graphql/resolver.go | 14 ++++- tavern/internal/graphql/tome_test.go | 7 ++- tavern/internal/graphql/user_test.go | 7 ++- tavern/tomes/git.go | 58 ++++++++++++++++--- tavern/tomes/git_test.go | 5 +- 10 files changed, 115 insertions(+), 23 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index abfaadc7c..f906eb75a 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -129,6 +129,9 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return nil, fmt.Errorf("failed to upload default tomes: %w", err) } + // Initialize Git Tome Importer + importer := cfg.NewGitImporter(client) + // Initialize Test Data if cfg.IsTestDataEnabled() { createTestData(ctx, client) @@ -159,7 +162,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { client, "https://www.googleapis.com/oauth2/v3/userinfo", )}, - "/graphql": tavernhttp.Endpoint{Handler: newGraphQLHandler(client)}, + "/graphql": tavernhttp.Endpoint{Handler: newGraphQLHandler(client, importer)}, "/c2.C2/": tavernhttp.Endpoint{Handler: newGRPCHandler(client)}, "/cdn/": tavernhttp.Endpoint{Handler: cdn.NewDownloadHandler(client)}, "/cdn/upload": tavernhttp.Endpoint{Handler: cdn.NewUploadHandler(client)}, @@ -226,8 +229,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client)) +func newGraphQLHandler(client *ent.Client, importer graphql.TomeImporter) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, importer)) srv.Use(entgql.Transactioner{TxOpener: client}) // GraphQL Logging diff --git a/tavern/config.go b/tavern/config.go index 2c93488d5..3888c9abd 100644 --- a/tavern/config.go +++ b/tavern/config.go @@ -1,6 +1,7 @@ package main import ( + "crypto/x509" "fmt" "log" "net/http" @@ -10,6 +11,7 @@ import ( "golang.org/x/oauth2" "golang.org/x/oauth2/google" "realm.pub/tavern/internal/ent" + "realm.pub/tavern/tomes" "entgo.io/ent/dialect/sql" "github.com/go-sql-driver/mysql" @@ -51,6 +53,9 @@ var ( EnvDBMaxOpenConns = EnvInteger{"DB_MAX_OPEN_CONNS", 100} EnvDBMaxConnLifetime = EnvInteger{"DB_MAX_CONN_LIFETIME", 3600} + // EnvGitSSHPrivateKey defines the private key used to import tomes from git repositories when the "ssh" schema is specified. + EnvGitSSHPrivateKey = EnvString{"GIT_SSH_PRIVATE_KEY", ""} + // EnvEnablePProf enables performance profiling and should not be enabled in production. // EnvEnableMetrics enables the /metrics endpoint and HTTP server. It is unauthenticated and should be used carefully. EnvEnablePProf = EnvString{"ENABLE_PPROF", ""} @@ -111,6 +116,22 @@ func (cfg *Config) Connect(options ...ent.Option) (*ent.Client, error) { return ent.NewClient(append(options, ent.Driver(drv))...), nil } +// NewGitImporter configures and returns a new TomeImporter using git. +func (cfg *Config) NewGitImporter(client *ent.Client) *tomes.GitImporter { + var options []tomes.GitImportOption + privKeyStr := EnvGitSSHPrivateKey.String() + if privKeyStr != "" { + privKey, err := x509.ParseECPrivateKey([]byte(privKeyStr)) + if err != nil { + log.Fatalf("[FATAL] Failed to parse git ssh private key: %v", err) + } + options = append(options, tomes.GitWithSSHPrivateKey(privKey)) + } else { + log.Printf("[WARN] No value for %q provided, generating a new ECDSA P256 private key", EnvGitSSHPrivateKey.Key) + } + return tomes.NewGitImporter(client, options...) +} + // IsMetricsEnabled returns true if the /metrics http endpoint has been enabled. func (cfg *Config) IsMetricsEnabled() bool { return EnvEnableMetrics.String() != "" diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index 8377d3b68..e827e9df8 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -14,6 +14,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" @@ -67,10 +68,13 @@ func runTestCase(t *testing.T, path string) { _, dbErr := db.Exec(tc.State) require.NoError(t, dbErr, "failed to setup test db state") + // Initialize Git Importer + importer := tomes.NewGitImporter(graph) + // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 484bcc574..93b121d90 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -14,7 +14,6 @@ import ( "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/graphql/generated" "realm.pub/tavern/internal/graphql/models" - "realm.pub/tavern/tomes" ) // DropAllData is the resolver for the dropAllData field. @@ -169,7 +168,7 @@ func (r *mutationResolver) ImportTomesFromGit(ctx context.Context, input models. } if input.IncludeDirs == nil { - return tomes.ImportFromRepo(ctx, r.client, input.GitURL) + return r.importer.Import(ctx, input.GitURL) } // Filter to only include provided directories @@ -186,7 +185,7 @@ func (r *mutationResolver) ImportTomesFromGit(ctx context.Context, input models. } return false } - return tomes.ImportFromRepo(ctx, r.client, gitURL, filter) + return r.importer.Import(ctx, gitURL, filter) } // CreateTome is the resolver for the createTome field. diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index 56f23ffcf..9ebd00949 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" ) // TestCreateQuest ensures the createQuest mutation functions as expected @@ -27,9 +28,12 @@ func TestCreateQuest(t *testing.T) { graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() + // Initialize Git Importer + importer := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index 104d94ea3..90d943cd1 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -12,13 +12,21 @@ import ( "github.com/99designs/gqlgen/graphql" ) +// A TomeImporter is responsible for importing tomes from the provided URL (filter based on provided filter options). +type TomeImporter interface { + Import(ctx context.Context, srcURL string, filters ...func(path string) bool) ([]*ent.Tome, error) +} + // Resolver is the resolver root. -type Resolver struct{ client *ent.Client } +type Resolver struct { + client *ent.Client + importer TomeImporter +} // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer TomeImporter) graphql.ExecutableSchema { cfg := generated.Config{ - Resolvers: &Resolver{client}, + Resolvers: &Resolver{client, importer}, } cfg.Directives.RequireRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, requiredRole models.Role) (interface{}, error) { // Allow unauthenticated contexts to continue for open endpoints diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index 648cd09bf..c1c3ee549 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -12,6 +12,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" ) func TestTomeMutations(t *testing.T) { @@ -19,9 +20,13 @@ func TestTomeMutations(t *testing.T) { ctx := context.Background() graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() + + // Initialize Git Importer + importer := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index 9e99a6665..b9306f767 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -10,6 +10,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" @@ -22,9 +23,13 @@ func TestUserMutations(t *testing.T) { ctx := context.Background() graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() + + // Initialize Git Importer + importer := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/tomes/git.go b/tavern/tomes/git.go index ec9d8bcb7..cdbe080ad 100644 --- a/tavern/tomes/git.go +++ b/tavern/tomes/git.go @@ -2,6 +2,9 @@ package tomes import ( "context" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" "encoding/json" "fmt" "io" @@ -19,15 +22,52 @@ import ( "realm.pub/tavern/internal/ent/tome" ) -// ImportFromRepo clones a git repository from the provided URL in memory. +// GitImportOption provides configuration for creating a new GitImporter. +type GitImportOption func(*GitImporter) + +// GitWithSSHPrivateKey enables a GitImporter to use an ECDSA private key for ssh clones. +func GitWithSSHPrivateKey(privKey *ecdsa.PrivateKey) GitImportOption { + return func(importer *GitImporter) { + importer.privKey = privKey + } +} + +// NewGitImporter initializes and returns a new GitImporter. +// If no SSH Private Key is provided, a new ECDSA P256 private key is generated. +// This panics if a new SSH Private Key cannot be generated. +func NewGitImporter(graph *ent.Client, options ...GitImportOption) *GitImporter { + importer := &GitImporter{ + graph: graph, + } + for _, opt := range options { + opt(importer) + } + if importer.privKey == nil { + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + panic(fmt.Errorf("failed to generate ECDSA P256 private key: %w", err)) + } + importer.privKey = privKey + } + + return importer +} + +// A GitImporter imports tomes from a provided Git URL. +type GitImporter struct { + privKey *ecdsa.PrivateKey + graph *ent.Client +} + +// Import clones a git repository from the provided URL in memory. // It walks the directory structure, looking for 'main.eldritch' files. // For each 'main.eldritch' file found, it's parent directory is treated as the tome's root. // All files in that directory and it's subdirectories (recursively) aside from the reserved // metadata.yml file are uploaded as the tome's assets. - -// Provided filters on tome paths may be used to exclude directories by returning true if the +// +// Provided filters on tome paths may be used to limit included directories by returning true if the // result should be included. -func ImportFromRepo(ctx context.Context, graph *ent.Client, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) { +func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) { // Clone Repository (In-Memory) storage := memory.NewStorage() repo, err := git.CloneContext(ctx, storage, nil, &git.CloneOptions{ @@ -81,7 +121,7 @@ func ImportFromRepo(ctx context.Context, graph *ent.Client, gitURL string, filte } // Import Tome - tome, err := importFromGitTree(ctx, repo, namespace, tree, path, graph) + tome, err := importer.importFromGitTree(ctx, repo, namespace, tree, path) if err != nil { return nil, fmt.Errorf("failed to import tome (%q): %w", path, err) } @@ -126,7 +166,7 @@ func findTomePaths(tree *object.Tree) ([]string, error) { } // ImportFromGitTree imports a tome based on the provided path -func importFromGitTree(ctx context.Context, repo *git.Repository, namespace string, root *object.Tree, path string, graph *ent.Client) (*ent.Tome, error) { +func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Repository, namespace string, root *object.Tree, path string) (*ent.Tome, error) { tree, err := root.Tree(path) if err != nil { return nil, fmt.Errorf("failed to get tome tree (%q): %w", path, err) @@ -188,7 +228,7 @@ func importFromGitTree(ctx context.Context, repo *git.Repository, namespace stri // Upload other files // TODO: Namespace tomes to prevent multi-repo conflicts - fileID, err := graph.File.Create(). + fileID, err := importer.graph.File.Create(). SetName(fmt.Sprintf("%s/%s", filepath.Base(path), name)). SetContent(data). OnConflict(). @@ -217,7 +257,7 @@ func importFromGitTree(ctx context.Context, repo *git.Repository, namespace stri } // Create the tome - tomeID, err := graph.Tome.Create(). + tomeID, err := importer.graph.Tome.Create(). SetName(fmt.Sprintf("%s::%s", namespace, metadata.Name)). SetDescription(metadata.Description). SetAuthor(metadata.Author). @@ -233,7 +273,7 @@ func importFromGitTree(ctx context.Context, repo *git.Repository, namespace stri return nil, fmt.Errorf("failed to create tome %q: %w", metadata.Name, err) } - return graph.Tome.Get(ctx, tomeID) + return importer.graph.Tome.Get(ctx, tomeID) } // parseNamespaceFromGit attempts to return a shortend namespace for the tome based on the git URL. diff --git a/tavern/tomes/git_test.go b/tavern/tomes/git_test.go index a2ae961ef..3a20238e5 100644 --- a/tavern/tomes/git_test.go +++ b/tavern/tomes/git_test.go @@ -24,10 +24,13 @@ func TestImportFromRepo(t *testing.T) { graph := enttest.Open(t, driverName, dataSourceName, enttest.WithOptions()) defer graph.Close() + // Initialize Git Importer + importer := tomes.NewGitImporter(graph) + filter := func(path string) bool { return strings.Contains(path, "example") } - _, err := tomes.ImportFromRepo(ctx, graph, localGit, filter) + _, err := importer.Import(ctx, localGit, filter) require.NoError(t, err) testTome := graph.Tome.Query(). From 4118c2a604572e2028693c086ef5a6a6a3915de2 Mon Sep 17 00:00:00 2001 From: KCarretto Date: Sun, 18 Feb 2024 19:37:53 +0000 Subject: [PATCH 2/6] it works --- tavern/app.go | 8 +- tavern/config.go | 10 +- tavern/internal/graphql/api_test.go | 4 +- .../graphql/generated/ent.generated.go | 91 ++++++++++++++ .../graphql/generated/root_.generated.go | 33 +++-- tavern/internal/graphql/mutation.resolvers.go | 4 +- tavern/internal/graphql/query.resolvers.go | 5 + tavern/internal/graphql/quest_test.go | 4 +- tavern/internal/graphql/resolver.go | 13 +- tavern/internal/graphql/schema.graphql | 3 + tavern/internal/graphql/schema/query.graphql | 3 + tavern/internal/graphql/tome_test.go | 4 +- tavern/internal/graphql/user_test.go | 4 +- tavern/internal/www/schema.graphql | 3 + tavern/tomes/git.go | 117 +++++++++++------- tavern/tomes/git_test.go | 4 +- 16 files changed, 227 insertions(+), 83 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index f906eb75a..1126e7270 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -130,7 +130,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { } // Initialize Git Tome Importer - importer := cfg.NewGitImporter(client) + git := cfg.NewGitImporter(client) // Initialize Test Data if cfg.IsTestDataEnabled() { @@ -162,7 +162,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { client, "https://www.googleapis.com/oauth2/v3/userinfo", )}, - "/graphql": tavernhttp.Endpoint{Handler: newGraphQLHandler(client, importer)}, + "/graphql": tavernhttp.Endpoint{Handler: newGraphQLHandler(client, git)}, "/c2.C2/": tavernhttp.Endpoint{Handler: newGRPCHandler(client)}, "/cdn/": tavernhttp.Endpoint{Handler: cdn.NewDownloadHandler(client)}, "/cdn/upload": tavernhttp.Endpoint{Handler: cdn.NewUploadHandler(client)}, @@ -229,8 +229,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, importer graphql.TomeImporter) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client, importer)) +func newGraphQLHandler(client *ent.Client, git graphql.GitTomeImporter) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, git)) srv.Use(entgql.Transactioner{TxOpener: client}) // GraphQL Logging diff --git a/tavern/config.go b/tavern/config.go index 3888c9abd..dd449fbf7 100644 --- a/tavern/config.go +++ b/tavern/config.go @@ -1,13 +1,13 @@ package main import ( - "crypto/x509" "fmt" "log" "net/http" "strings" "time" + "golang.org/x/crypto/ssh" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "realm.pub/tavern/internal/ent" @@ -53,7 +53,7 @@ var ( EnvDBMaxOpenConns = EnvInteger{"DB_MAX_OPEN_CONNS", 100} EnvDBMaxConnLifetime = EnvInteger{"DB_MAX_CONN_LIFETIME", 3600} - // EnvGitSSHPrivateKey defines the private key used to import tomes from git repositories when the "ssh" schema is specified. + // EnvGitSSHECDSAPrivateKey defines the ecdsa private key used to import tomes from git repositories when the "ssh" schema is specified. EnvGitSSHPrivateKey = EnvString{"GIT_SSH_PRIVATE_KEY", ""} // EnvEnablePProf enables performance profiling and should not be enabled in production. @@ -121,13 +121,13 @@ func (cfg *Config) NewGitImporter(client *ent.Client) *tomes.GitImporter { var options []tomes.GitImportOption privKeyStr := EnvGitSSHPrivateKey.String() if privKeyStr != "" { - privKey, err := x509.ParseECPrivateKey([]byte(privKeyStr)) + signer, err := ssh.ParsePrivateKey([]byte(privKeyStr)) if err != nil { log.Fatalf("[FATAL] Failed to parse git ssh private key: %v", err) } - options = append(options, tomes.GitWithSSHPrivateKey(privKey)) + options = append(options, tomes.GitWithSSHSigner(signer)) } else { - log.Printf("[WARN] No value for %q provided, generating a new ECDSA P256 private key", EnvGitSSHPrivateKey.Key) + log.Printf("[WARN] No value for %q provided, generating a new key pair", EnvGitSSHPrivateKey.Key) } return tomes.NewGitImporter(client, options...) } diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index e827e9df8..413a55cc3 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -69,12 +69,12 @@ func runTestCase(t *testing.T, path string) { require.NoError(t, dbErr, "failed to setup test db state") // Initialize Git Importer - importer := tomes.NewGitImporter(graph) + git := tomes.NewGitImporter(graph) // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 4d6b771f4..a68ffd76e 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -36,6 +36,7 @@ type QueryResolver interface { Tomes(ctx context.Context, where *ent.TomeWhereInput) ([]*ent.Tome, error) Users(ctx context.Context, where *ent.UserWhereInput) ([]*ent.User, error) Me(ctx context.Context) (*ent.User, error) + GitPublicKey(ctx context.Context) (string, error) } // endregion ************************** generated!.gotpl ************************** @@ -4487,6 +4488,74 @@ func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field gra return fc, nil } +func (ec *executionContext) _Query_gitPublicKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_gitPublicKey(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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().GitPublicKey(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + 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 { + 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_Query_gitPublicKey(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") + }, + } + 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 { @@ -17975,6 +18044,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 "gitPublicKey": + 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_gitPublicKey(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) { diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 64b917be0..859e0c48a 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -148,17 +148,18 @@ type ComplexityRoot struct { } Query struct { - Beacons func(childComplexity int, where *ent.BeaconWhereInput) int - Files func(childComplexity int, where *ent.FileWhereInput) int - Hosts func(childComplexity int, where *ent.HostWhereInput) int - Me func(childComplexity int) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - Quests func(childComplexity int, where *ent.QuestWhereInput) int - Tags func(childComplexity int, where *ent.TagWhereInput) int - Tasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.TaskOrder, where *ent.TaskWhereInput) int - Tomes func(childComplexity int, where *ent.TomeWhereInput) int - Users func(childComplexity int, where *ent.UserWhereInput) int + Beacons func(childComplexity int, where *ent.BeaconWhereInput) int + Files func(childComplexity int, where *ent.FileWhereInput) int + GitPublicKey func(childComplexity int) int + Hosts func(childComplexity int, where *ent.HostWhereInput) int + Me func(childComplexity int) int + Node func(childComplexity int, id int) int + Nodes func(childComplexity int, ids []int) int + Quests func(childComplexity int, where *ent.QuestWhereInput) int + Tags func(childComplexity int, where *ent.TagWhereInput) int + Tasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.TaskOrder, where *ent.TaskWhereInput) int + Tomes func(childComplexity int, where *ent.TomeWhereInput) int + Users func(childComplexity int, where *ent.UserWhereInput) int } Quest struct { @@ -879,6 +880,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Files(childComplexity, args["where"].(*ent.FileWhereInput)), true + case "Query.gitPublicKey": + if e.complexity.Query.GitPublicKey == nil { + break + } + + return e.complexity.Query.GitPublicKey(childComplexity), true + case "Query.hosts": if e.complexity.Query.Hosts == nil { break @@ -3222,6 +3230,9 @@ scalar Uint64 tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! + + """Obtain git ssh public key used for importing tomes from repos via ssh.""" + gitPublicKey: String! @requireRole(role: USER) } `, BuiltIn: false}, {Name: "../schema/mutation.graphql", Input: `type Mutation { diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 93b121d90..041dcfdff 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -168,7 +168,7 @@ func (r *mutationResolver) ImportTomesFromGit(ctx context.Context, input models. } if input.IncludeDirs == nil { - return r.importer.Import(ctx, input.GitURL) + return r.git.Import(ctx, input.GitURL) } // Filter to only include provided directories @@ -185,7 +185,7 @@ func (r *mutationResolver) ImportTomesFromGit(ctx context.Context, input models. } return false } - return r.importer.Import(ctx, gitURL, filter) + return r.git.Import(ctx, gitURL, filter) } // CreateTome is the resolver for the createTome field. diff --git a/tavern/internal/graphql/query.resolvers.go b/tavern/internal/graphql/query.resolvers.go index 84a7faaa4..e86f675c6 100644 --- a/tavern/internal/graphql/query.resolvers.go +++ b/tavern/internal/graphql/query.resolvers.go @@ -148,3 +148,8 @@ func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { } return nil, fmt.Errorf("no authenticated user present in request context") } + +// GitPublicKey is the resolver for the gitPublicKey field. +func (r *queryResolver) GitPublicKey(ctx context.Context) (string, error) { + return r.git.SSHPublicKey(), nil +} diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index 9ebd00949..2afc0f0f6 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -29,11 +29,11 @@ func TestCreateQuest(t *testing.T) { defer graph.Close() // Initialize Git Importer - importer := tomes.NewGitImporter(graph) + git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index 90d943cd1..23a470d21 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -12,19 +12,20 @@ import ( "github.com/99designs/gqlgen/graphql" ) -// A TomeImporter is responsible for importing tomes from the provided URL (filter based on provided filter options). -type TomeImporter interface { - Import(ctx context.Context, srcURL string, filters ...func(path string) bool) ([]*ent.Tome, error) +// A GitTomeImporter is responsible for importing tomes from the provided URL (filter based on provided filter options). +type GitTomeImporter interface { + Import(ctx context.Context, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) + SSHPublicKey() string } // Resolver is the resolver root. type Resolver struct { - client *ent.Client - importer TomeImporter + client *ent.Client + git GitTomeImporter } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer TomeImporter) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer GitTomeImporter) graphql.ExecutableSchema { cfg := generated.Config{ Resolvers: &Resolver{client, importer}, } diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index d0c11d6a0..30a71b51b 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -1838,6 +1838,9 @@ extend type Query { tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! + + """Obtain git ssh public key used for importing tomes from repos via ssh.""" + gitPublicKey: String! @requireRole(role: USER) } scalar Time scalar Uint64 diff --git a/tavern/internal/graphql/schema/query.graphql b/tavern/internal/graphql/schema/query.graphql index d3edef49d..ec46ee74b 100644 --- a/tavern/internal/graphql/schema/query.graphql +++ b/tavern/internal/graphql/schema/query.graphql @@ -26,4 +26,7 @@ extend type Query { tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! + + """Obtain git ssh public key used for importing tomes from repos via ssh.""" + gitSSHPublicKey: String! @requireRole(role: USER) } diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index c1c3ee549..471947794 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -22,11 +22,11 @@ func TestTomeMutations(t *testing.T) { defer graph.Close() // Initialize Git Importer - importer := tomes.NewGitImporter(graph) + git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index b9306f767..d97f9e71d 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -25,11 +25,11 @@ func TestUserMutations(t *testing.T) { defer graph.Close() // Initialize Git Importer - importer := tomes.NewGitImporter(graph) + git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importer)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index d0c11d6a0..30a71b51b 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -1838,6 +1838,9 @@ extend type Query { tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! + + """Obtain git ssh public key used for importing tomes from repos via ssh.""" + gitPublicKey: String! @requireRole(role: USER) } scalar Time scalar Uint64 diff --git a/tavern/tomes/git.go b/tavern/tomes/git.go index cdbe080ad..231a117d7 100644 --- a/tavern/tomes/git.go +++ b/tavern/tomes/git.go @@ -2,8 +2,7 @@ package tomes import ( "context" - "crypto/ecdsa" - "crypto/elliptic" + "crypto/ed25519" "crypto/rand" "encoding/json" "fmt" @@ -16,7 +15,9 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/filemode" "github.com/go-git/go-git/v5/plumbing/object" + gitssh "github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/go-git/go-git/v5/storage/memory" + "golang.org/x/crypto/ssh" "gopkg.in/yaml.v3" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/tome" @@ -25,10 +26,10 @@ import ( // GitImportOption provides configuration for creating a new GitImporter. type GitImportOption func(*GitImporter) -// GitWithSSHPrivateKey enables a GitImporter to use an ECDSA private key for ssh clones. -func GitWithSSHPrivateKey(privKey *ecdsa.PrivateKey) GitImportOption { +// GitWithSSHSigner enables a GitImporter to use a private key for ssh clones. +func GitWithSSHSigner(signer ssh.Signer) GitImportOption { return func(importer *GitImporter) { - importer.privKey = privKey + importer.signer = signer } } @@ -42,12 +43,18 @@ func NewGitImporter(graph *ent.Client, options ...GitImportOption) *GitImporter for _, opt := range options { opt(importer) } - if importer.privKey == nil { - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if importer.signer == nil { + _, privKey, err := ed25519.GenerateKey(rand.Reader) if err != nil { - panic(fmt.Errorf("failed to generate ECDSA P256 private key: %w", err)) + panic(fmt.Errorf("failed to generate ed25519 private key: %w", err)) } - importer.privKey = privKey + + signer, err := ssh.NewSignerFromKey(privKey) + if err != nil { + panic(fmt.Errorf("could not convert private key to ssh signer: %v", err)) + } + + importer.signer = signer } return importer @@ -55,8 +62,8 @@ func NewGitImporter(graph *ent.Client, options ...GitImportOption) *GitImporter // A GitImporter imports tomes from a provided Git URL. type GitImporter struct { - privKey *ecdsa.PrivateKey - graph *ent.Client + signer ssh.Signer + graph *ent.Client } // Import clones a git repository from the provided URL in memory. @@ -68,12 +75,26 @@ type GitImporter struct { // Provided filters on tome paths may be used to limit included directories by returning true if the // result should be included. func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) { + // Use Private Key Auth for SSH + var authMethod *gitssh.PublicKeys + if importer.signer != nil && strings.HasPrefix(gitURL, "ssh://") { + authMethod = &gitssh.PublicKeys{ + User: "git", + Signer: importer.signer, + HostKeyCallbackHelper: gitssh.HostKeyCallbackHelper{ + // Ignore Host Keys + HostKeyCallback: ssh.InsecureIgnoreHostKey(), + }, + } + } + // Clone Repository (In-Memory) storage := memory.NewStorage() repo, err := git.CloneContext(ctx, storage, nil, &git.CloneOptions{ URL: gitURL, SingleBranch: true, Depth: 1, + Auth: authMethod, Tags: git.NoTags, }) if err != nil { @@ -131,40 +152,6 @@ func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters return tomes, nil } -// findTomePaths returns a list of valid paths to the root directory of a Tome. -// This is based on all of the 'main.eldritch' files found in the repository. -func findTomePaths(tree *object.Tree) ([]string, error) { - var tomePaths []string - walker := object.NewTreeWalker(tree, true, make(map[plumbing.Hash]bool)) - defer walker.Close() - for { - // Fetch next entry - name, _, err := walker.Next() - if err == io.EOF { - // No more entries - break - } - if err != nil { - return nil, fmt.Errorf("failed to walk repo tree: %w", err) - } - - // If 'main.eldritch' is present, the parent directory is the tome root - base := filepath.Base(name) - if base == "main.eldritch" { - // Cannot use filepath.Dir on Windows, git does not use \ separators - tomePaths = append( - tomePaths, - strings.TrimSuffix( - strings.TrimSuffix(name, base), // Get the directory name - "/", // Remove the trailing / - ), - ) - } - } - - return tomePaths, nil -} - // ImportFromGitTree imports a tome based on the provided path func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Repository, namespace string, root *object.Tree, path string) (*ent.Tome, error) { tree, err := root.Tree(path) @@ -276,6 +263,46 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re return importer.graph.Tome.Get(ctx, tomeID) } +// SSHPublicKey returns a PEM-Encoded PKIX ASN.1DER encoded public key associated with the private key used for cloning. +func (importer *GitImporter) SSHPublicKey() string { + pubKey := importer.signer.PublicKey() + return string(ssh.MarshalAuthorizedKey(pubKey)) +} + +// findTomePaths returns a list of valid paths to the root directory of a Tome. +// This is based on all of the 'main.eldritch' files found in the repository. +func findTomePaths(tree *object.Tree) ([]string, error) { + var tomePaths []string + walker := object.NewTreeWalker(tree, true, make(map[plumbing.Hash]bool)) + defer walker.Close() + for { + // Fetch next entry + name, _, err := walker.Next() + if err == io.EOF { + // No more entries + break + } + if err != nil { + return nil, fmt.Errorf("failed to walk repo tree: %w", err) + } + + // If 'main.eldritch' is present, the parent directory is the tome root + base := filepath.Base(name) + if base == "main.eldritch" { + // Cannot use filepath.Dir on Windows, git does not use \ separators + tomePaths = append( + tomePaths, + strings.TrimSuffix( + strings.TrimSuffix(name, base), // Get the directory name + "/", // Remove the trailing / + ), + ) + } + } + + return tomePaths, nil +} + // parseNamespaceFromGit attempts to return a shortend namespace for the tome based on the git URL. // If it cannot or something goes wrong, this will return the provided git URL as the namespace. func parseNamespaceFromGit(gitURLStr string) string { diff --git a/tavern/tomes/git_test.go b/tavern/tomes/git_test.go index 3a20238e5..2ca04994a 100644 --- a/tavern/tomes/git_test.go +++ b/tavern/tomes/git_test.go @@ -25,12 +25,12 @@ func TestImportFromRepo(t *testing.T) { defer graph.Close() // Initialize Git Importer - importer := tomes.NewGitImporter(graph) + git := tomes.NewGitImporter(graph) filter := func(path string) bool { return strings.Contains(path, "example") } - _, err := importer.Import(ctx, localGit, filter) + _, err := git.Import(ctx, localGit, filter) require.NoError(t, err) testTome := graph.Tome.Query(). From 333b73754f737ae7655c71878f69518dae009eae Mon Sep 17 00:00:00 2001 From: KCarretto Date: Mon, 19 Feb 2024 18:47:38 +0000 Subject: [PATCH 3/6] tests pass, moved to repository (key per), more testing needed --- tavern/app.go | 4 +- tavern/config.go | 16 +- tavern/internal/ent/client.go | 154 +- tavern/internal/ent/ent.go | 2 + tavern/internal/ent/gql_collection.go | 111 + tavern/internal/ent/gql_mutation_input.go | 16 + tavern/internal/ent/gql_node.go | 32 + tavern/internal/ent/gql_pagination.go | 348 + tavern/internal/ent/gql_where_input.go | 301 + tavern/internal/ent/hook/hook.go | 12 + tavern/internal/ent/migrate/schema.go | 16 + tavern/internal/ent/mutation.go | 544 ++ tavern/internal/ent/predicate/predicate.go | 3 + tavern/internal/ent/privacy/privacy.go | 24 + tavern/internal/ent/repository.go | 149 + tavern/internal/ent/repository/repository.go | 99 + tavern/internal/ent/repository/where.go | 370 + tavern/internal/ent/repository_create.go | 683 ++ tavern/internal/ent/repository_delete.go | 88 + tavern/internal/ent/repository_query.go | 539 ++ tavern/internal/ent/repository_update.go | 304 + tavern/internal/ent/runtime/runtime.go | 22 + tavern/internal/ent/schema/repository.go | 124 + tavern/internal/ent/tx.go | 3 + .../graphql/generated/ent.generated.go | 7774 ++++++++++------- .../graphql/generated/inputs.generated.go | 24 +- .../graphql/generated/mutation.generated.go | 247 +- .../graphql/generated/root_.generated.go | 303 +- .../internal/graphql/models/gqlgen_models.go | 4 +- tavern/internal/graphql/mutation.resolvers.go | 70 +- tavern/internal/graphql/query.resolvers.go | 21 +- tavern/internal/graphql/resolver.go | 13 +- tavern/internal/graphql/schema.graphql | 145 +- tavern/internal/graphql/schema/ent.graphql | 111 + tavern/internal/graphql/schema/inputs.graphql | 5 +- .../internal/graphql/schema/mutation.graphql | 7 +- tavern/internal/graphql/schema/query.graphql | 22 +- tavern/internal/www/schema.graphql | 145 +- tavern/tomes/git.go | 95 +- tavern/tomes/git_test.go | 6 +- 40 files changed, 9513 insertions(+), 3443 deletions(-) create mode 100644 tavern/internal/ent/repository.go create mode 100644 tavern/internal/ent/repository/repository.go create mode 100644 tavern/internal/ent/repository/where.go create mode 100644 tavern/internal/ent/repository_create.go create mode 100644 tavern/internal/ent/repository_delete.go create mode 100644 tavern/internal/ent/repository_query.go create mode 100644 tavern/internal/ent/repository_update.go create mode 100644 tavern/internal/ent/schema/repository.go diff --git a/tavern/app.go b/tavern/app.go index 1126e7270..cdd39a588 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -229,8 +229,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, git graphql.GitTomeImporter) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client, git)) +func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter)) srv.Use(entgql.Transactioner{TxOpener: client}) // GraphQL Logging diff --git a/tavern/config.go b/tavern/config.go index dd449fbf7..8b0364375 100644 --- a/tavern/config.go +++ b/tavern/config.go @@ -7,7 +7,6 @@ import ( "strings" "time" - "golang.org/x/crypto/ssh" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "realm.pub/tavern/internal/ent" @@ -53,9 +52,6 @@ var ( EnvDBMaxOpenConns = EnvInteger{"DB_MAX_OPEN_CONNS", 100} EnvDBMaxConnLifetime = EnvInteger{"DB_MAX_CONN_LIFETIME", 3600} - // EnvGitSSHECDSAPrivateKey defines the ecdsa private key used to import tomes from git repositories when the "ssh" schema is specified. - EnvGitSSHPrivateKey = EnvString{"GIT_SSH_PRIVATE_KEY", ""} - // EnvEnablePProf enables performance profiling and should not be enabled in production. // EnvEnableMetrics enables the /metrics endpoint and HTTP server. It is unauthenticated and should be used carefully. EnvEnablePProf = EnvString{"ENABLE_PPROF", ""} @@ -116,19 +112,9 @@ func (cfg *Config) Connect(options ...ent.Option) (*ent.Client, error) { return ent.NewClient(append(options, ent.Driver(drv))...), nil } -// NewGitImporter configures and returns a new TomeImporter using git. +// NewGitImporter configures and returns a new RepoImporter using git. func (cfg *Config) NewGitImporter(client *ent.Client) *tomes.GitImporter { var options []tomes.GitImportOption - privKeyStr := EnvGitSSHPrivateKey.String() - if privKeyStr != "" { - signer, err := ssh.ParsePrivateKey([]byte(privKeyStr)) - if err != nil { - log.Fatalf("[FATAL] Failed to parse git ssh private key: %v", err) - } - options = append(options, tomes.GitWithSSHSigner(signer)) - } else { - log.Printf("[WARN] No value for %q provided, generating a new key pair", EnvGitSSHPrivateKey.Key) - } return tomes.NewGitImporter(client, options...) } diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 43f5637c0..32733005e 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -22,6 +22,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -47,6 +48,8 @@ type Client struct { HostProcess *HostProcessClient // Quest is the client for interacting with the Quest builders. Quest *QuestClient + // Repository is the client for interacting with the Repository builders. + Repository *RepositoryClient // Tag is the client for interacting with the Tag builders. Tag *TagClient // Task is the client for interacting with the Task builders. @@ -77,6 +80,7 @@ func (c *Client) init() { c.HostFile = NewHostFileClient(c.config) c.HostProcess = NewHostProcessClient(c.config) c.Quest = NewQuestClient(c.config) + c.Repository = NewRepositoryClient(c.config) c.Tag = NewTagClient(c.config) c.Task = NewTaskClient(c.config) c.Tome = NewTomeClient(c.config) @@ -173,6 +177,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { HostFile: NewHostFileClient(cfg), HostProcess: NewHostProcessClient(cfg), Quest: NewQuestClient(cfg), + Repository: NewRepositoryClient(cfg), Tag: NewTagClient(cfg), Task: NewTaskClient(cfg), Tome: NewTomeClient(cfg), @@ -203,6 +208,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) HostFile: NewHostFileClient(cfg), HostProcess: NewHostProcessClient(cfg), Quest: NewQuestClient(cfg), + Repository: NewRepositoryClient(cfg), Tag: NewTagClient(cfg), Task: NewTaskClient(cfg), Tome: NewTomeClient(cfg), @@ -237,7 +243,7 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.Beacon, c.File, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Quest, - c.Tag, c.Task, c.Tome, c.User, + c.Repository, c.Tag, c.Task, c.Tome, c.User, } { n.Use(hooks...) } @@ -248,7 +254,7 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.Beacon, c.File, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Quest, - c.Tag, c.Task, c.Tome, c.User, + c.Repository, c.Tag, c.Task, c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -271,6 +277,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.HostProcess.mutate(ctx, m) case *QuestMutation: return c.Quest.mutate(ctx, m) + case *RepositoryMutation: + return c.Repository.mutate(ctx, m) case *TagMutation: return c.Tag.mutate(ctx, m) case *TaskMutation: @@ -1505,6 +1513,140 @@ func (c *QuestClient) mutate(ctx context.Context, m *QuestMutation) (Value, erro } } +// RepositoryClient is a client for the Repository schema. +type RepositoryClient struct { + config +} + +// NewRepositoryClient returns a client for the Repository from the given config. +func NewRepositoryClient(c config) *RepositoryClient { + return &RepositoryClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `repository.Hooks(f(g(h())))`. +func (c *RepositoryClient) Use(hooks ...Hook) { + c.hooks.Repository = append(c.hooks.Repository, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `repository.Intercept(f(g(h())))`. +func (c *RepositoryClient) Intercept(interceptors ...Interceptor) { + c.inters.Repository = append(c.inters.Repository, interceptors...) +} + +// Create returns a builder for creating a Repository entity. +func (c *RepositoryClient) Create() *RepositoryCreate { + mutation := newRepositoryMutation(c.config, OpCreate) + return &RepositoryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Repository entities. +func (c *RepositoryClient) CreateBulk(builders ...*RepositoryCreate) *RepositoryCreateBulk { + return &RepositoryCreateBulk{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 *RepositoryClient) MapCreateBulk(slice any, setFunc func(*RepositoryCreate, int)) *RepositoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &RepositoryCreateBulk{err: fmt.Errorf("calling to RepositoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*RepositoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &RepositoryCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Repository. +func (c *RepositoryClient) Update() *RepositoryUpdate { + mutation := newRepositoryMutation(c.config, OpUpdate) + return &RepositoryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *RepositoryClient) UpdateOne(r *Repository) *RepositoryUpdateOne { + mutation := newRepositoryMutation(c.config, OpUpdateOne, withRepository(r)) + return &RepositoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *RepositoryClient) UpdateOneID(id int) *RepositoryUpdateOne { + mutation := newRepositoryMutation(c.config, OpUpdateOne, withRepositoryID(id)) + return &RepositoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Repository. +func (c *RepositoryClient) Delete() *RepositoryDelete { + mutation := newRepositoryMutation(c.config, OpDelete) + return &RepositoryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *RepositoryClient) DeleteOne(r *Repository) *RepositoryDeleteOne { + return c.DeleteOneID(r.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *RepositoryClient) DeleteOneID(id int) *RepositoryDeleteOne { + builder := c.Delete().Where(repository.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &RepositoryDeleteOne{builder} +} + +// Query returns a query builder for Repository. +func (c *RepositoryClient) Query() *RepositoryQuery { + return &RepositoryQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeRepository}, + inters: c.Interceptors(), + } +} + +// Get returns a Repository entity by its id. +func (c *RepositoryClient) Get(ctx context.Context, id int) (*Repository, error) { + return c.Query().Where(repository.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *RepositoryClient) GetX(ctx context.Context, id int) *Repository { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *RepositoryClient) Hooks() []Hook { + hooks := c.hooks.Repository + return append(hooks[:len(hooks):len(hooks)], repository.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *RepositoryClient) Interceptors() []Interceptor { + return c.inters.Repository +} + +func (c *RepositoryClient) mutate(ctx context.Context, m *RepositoryMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&RepositoryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&RepositoryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&RepositoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&RepositoryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Repository mutation op: %q", m.Op()) + } +} + // TagClient is a client for the Tag schema. type TagClient struct { config @@ -2186,11 +2328,11 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Beacon, File, Host, HostCredential, HostFile, HostProcess, Quest, Tag, Task, - Tome, User []ent.Hook + Beacon, File, Host, HostCredential, HostFile, HostProcess, Quest, Repository, + Tag, Task, Tome, User []ent.Hook } inters struct { - Beacon, File, Host, HostCredential, HostFile, HostProcess, Quest, Tag, Task, - Tome, User []ent.Interceptor + Beacon, File, Host, HostCredential, HostFile, HostProcess, Quest, Repository, + Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index 0074a889c..7540701b9 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -19,6 +19,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -90,6 +91,7 @@ func checkColumn(table, column string) error { hostfile.Table: hostfile.ValidColumn, hostprocess.Table: hostprocess.ValidColumn, quest.Table: quest.ValidColumn, + repository.Table: repository.ValidColumn, tag.Table: tag.ValidColumn, task.Table: task.ValidColumn, tome.Table: tome.ValidColumn, diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index ec69555a0..21ed183d7 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -15,6 +15,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -1045,6 +1046,116 @@ func newQuestPaginateArgs(rv map[string]any) *questPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (r *RepositoryQuery) CollectFields(ctx context.Context, satisfies ...string) (*RepositoryQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return r, nil + } + if err := r.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return r, nil +} + +func (r *RepositoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(repository.Columns)) + selectedFields = []string{repository.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "createdAt": + if _, ok := fieldSeen[repository.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, repository.FieldCreatedAt) + fieldSeen[repository.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[repository.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, repository.FieldLastModifiedAt) + fieldSeen[repository.FieldLastModifiedAt] = struct{}{} + } + case "url": + if _, ok := fieldSeen[repository.FieldURL]; !ok { + selectedFields = append(selectedFields, repository.FieldURL) + fieldSeen[repository.FieldURL] = struct{}{} + } + case "publicKey": + if _, ok := fieldSeen[repository.FieldPublicKey]; !ok { + selectedFields = append(selectedFields, repository.FieldPublicKey) + fieldSeen[repository.FieldPublicKey] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + r.Select(selectedFields...) + } + return nil +} + +type repositoryPaginateArgs struct { + first, last *int + after, before *Cursor + opts []RepositoryPaginateOption +} + +func newRepositoryPaginateArgs(rv map[string]any) *repositoryPaginateArgs { + args := &repositoryPaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[orderByField]; ok { + switch v := v.(type) { + case []*RepositoryOrder: + args.opts = append(args.opts, WithRepositoryOrder(v)) + case []any: + var orders []*RepositoryOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &RepositoryOrder{Field: &RepositoryOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } + } + args.opts = append(args.opts, WithRepositoryOrder(orders)) + } + } + if v, ok := rv[whereField].(*RepositoryWhereInput); ok { + args.opts = append(args.opts, WithRepositoryFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (t *TagQuery) CollectFields(ctx context.Context, satisfies ...string) (*TagQuery, error) { fc := graphql.GetFieldContext(ctx) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index ab87ac40e..b44c0fdf4 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -151,6 +151,22 @@ func (c *QuestCreate) SetInput(i CreateQuestInput) *QuestCreate { return c } +// CreateRepositoryInput represents a mutation input for creating repositories. +type CreateRepositoryInput struct { + URL string +} + +// Mutate applies the CreateRepositoryInput on the RepositoryMutation builder. +func (i *CreateRepositoryInput) Mutate(m *RepositoryMutation) { + m.SetURL(i.URL) +} + +// SetInput applies the change-set in the CreateRepositoryInput on the RepositoryCreate builder. +func (c *RepositoryCreate) SetInput(i CreateRepositoryInput) *RepositoryCreate { + i.Mutate(c.Mutation()) + return c +} + // CreateTagInput represents a mutation input for creating tags. type CreateTagInput struct { Name string diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 416bef993..b30938469 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -22,6 +22,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -54,6 +55,9 @@ func (n *HostProcess) IsNode() {} // IsNode implements the Node interface check for GQLGen. func (n *Quest) IsNode() {} +// IsNode implements the Node interface check for GQLGen. +func (n *Repository) IsNode() {} + // IsNode implements the Node interface check for GQLGen. func (n *Tag) IsNode() {} @@ -208,6 +212,18 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) return nil, err } return n, nil + case repository.Table: + query := c.Repository.Query(). + Where(repository.ID(id)) + query, err := query.CollectFields(ctx, "Repository") + if err != nil { + return nil, err + } + n, err := query.Only(ctx) + if err != nil { + return nil, err + } + return n, nil case tag.Table: query := c.Tag.Query(). Where(tag.ID(id)) @@ -441,6 +457,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } + case repository.Table: + query := c.Repository.Query(). + Where(repository.IDIn(ids...)) + query, err := query.CollectFields(ctx, "Repository") + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } case tag.Table: query := c.Tag.Query(). Where(tag.IDIn(ids...)) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index e8d65b9c8..73d239e22 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -22,6 +22,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -2501,6 +2502,353 @@ func (q *Quest) ToEdge(order *QuestOrder) *QuestEdge { } } +// RepositoryEdge is the edge representation of Repository. +type RepositoryEdge struct { + Node *Repository `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// RepositoryConnection is the connection containing edges to Repository. +type RepositoryConnection struct { + Edges []*RepositoryEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *RepositoryConnection) build(nodes []*Repository, pager *repositoryPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Repository + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Repository { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Repository { + return nodes[i] + } + } + c.Edges = make([]*RepositoryEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &RepositoryEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// RepositoryPaginateOption enables pagination customization. +type RepositoryPaginateOption func(*repositoryPager) error + +// WithRepositoryOrder configures pagination ordering. +func WithRepositoryOrder(order []*RepositoryOrder) RepositoryPaginateOption { + return func(pager *repositoryPager) error { + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } + } + pager.order = append(pager.order, order...) + return nil + } +} + +// WithRepositoryFilter configures pagination filter. +func WithRepositoryFilter(filter func(*RepositoryQuery) (*RepositoryQuery, error)) RepositoryPaginateOption { + return func(pager *repositoryPager) error { + if filter == nil { + return errors.New("RepositoryQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type repositoryPager struct { + reverse bool + order []*RepositoryOrder + filter func(*RepositoryQuery) (*RepositoryQuery, error) +} + +func newRepositoryPager(opts []RepositoryPaginateOption, reverse bool) (*repositoryPager, error) { + pager := &repositoryPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } + } + return pager, nil +} + +func (p *repositoryPager) applyFilter(query *RepositoryQuery) (*RepositoryQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *repositoryPager) toCursor(r *Repository) Cursor { + cs := make([]any, 0, len(p.order)) + for _, o := range p.order { + cs = append(cs, o.Field.toCursor(r).Value) + } + return Cursor{ID: r.ID, Value: cs} +} + +func (p *repositoryPager) applyCursors(query *RepositoryQuery, after, before *Cursor) (*RepositoryQuery, error) { + idDirection := entgql.OrderDirectionAsc + if p.reverse { + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) + } + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultRepositoryOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { + query = query.Where(predicate) + } + return query, nil +} + +func (p *repositoryPager) applyOrder(query *RepositoryQuery) *RepositoryQuery { + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultRepositoryOrder.Field.column { + defaultOrdered = true + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(DefaultRepositoryOrder.Field.toTerm(direction.OrderTermOption())) + } + return query +} + +func (p *repositoryPager) orderExpr(query *RepositoryQuery) sql.Querier { + if len(query.ctx.Fields) > 0 { + for _, o := range p.order { + query.ctx.AppendFieldOnce(o.Field.column) + } + } + return sql.ExprFunc(func(b *sql.Builder) { + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() + } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultRepositoryOrder.Field.column).Pad().WriteString(string(direction)) + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Repository. +func (r *RepositoryQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...RepositoryPaginateOption, +) (*RepositoryConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newRepositoryPager(opts, last != nil) + if err != nil { + return nil, err + } + if r, err = pager.applyFilter(r); err != nil { + return nil, err + } + conn := &RepositoryConnection{Edges: []*RepositoryEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + if conn.TotalCount, err = r.Clone().Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if r, err = pager.applyCursors(r, after, before); err != nil { + return nil, err + } + if limit := paginateLimit(first, last); limit != 0 { + r.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := r.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + r = pager.applyOrder(r) + nodes, err := r.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // RepositoryOrderFieldCreatedAt orders Repository by created_at. + RepositoryOrderFieldCreatedAt = &RepositoryOrderField{ + Value: func(r *Repository) (ent.Value, error) { + return r.CreatedAt, nil + }, + column: repository.FieldCreatedAt, + toTerm: repository.ByCreatedAt, + toCursor: func(r *Repository) Cursor { + return Cursor{ + ID: r.ID, + Value: r.CreatedAt, + } + }, + } + // RepositoryOrderFieldLastModifiedAt orders Repository by last_modified_at. + RepositoryOrderFieldLastModifiedAt = &RepositoryOrderField{ + Value: func(r *Repository) (ent.Value, error) { + return r.LastModifiedAt, nil + }, + column: repository.FieldLastModifiedAt, + toTerm: repository.ByLastModifiedAt, + toCursor: func(r *Repository) Cursor { + return Cursor{ + ID: r.ID, + Value: r.LastModifiedAt, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f RepositoryOrderField) String() string { + var str string + switch f.column { + case RepositoryOrderFieldCreatedAt.column: + str = "CREATED_AT" + case RepositoryOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f RepositoryOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *RepositoryOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("RepositoryOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *RepositoryOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *RepositoryOrderFieldLastModifiedAt + default: + return fmt.Errorf("%s is not a valid RepositoryOrderField", str) + } + return nil +} + +// RepositoryOrderField defines the ordering field of Repository. +type RepositoryOrderField struct { + // Value extracts the ordering value from the given Repository. + Value func(*Repository) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) repository.OrderOption + toCursor func(*Repository) Cursor +} + +// RepositoryOrder defines the ordering of Repository. +type RepositoryOrder struct { + Direction OrderDirection `json:"direction"` + Field *RepositoryOrderField `json:"field"` +} + +// DefaultRepositoryOrder is the default ordering of Repository. +var DefaultRepositoryOrder = &RepositoryOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &RepositoryOrderField{ + Value: func(r *Repository) (ent.Value, error) { + return r.ID, nil + }, + column: repository.FieldID, + toTerm: repository.ByID, + toCursor: func(r *Repository) Cursor { + return Cursor{ID: r.ID} + }, + }, +} + +// ToEdge converts Repository into RepositoryEdge. +func (r *Repository) ToEdge(order *RepositoryOrder) *RepositoryEdge { + if order == nil { + order = DefaultRepositoryOrder + } + return &RepositoryEdge{ + Node: r, + Cursor: order.Field.toCursor(r), + } +} + // TagEdge is the edge representation of Tag. type TagEdge struct { Node *Tag `json:"node"` diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 37e7846d1..c5815463e 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -17,6 +17,7 @@ import ( "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -3479,6 +3480,306 @@ func (i *QuestWhereInput) P() (predicate.Quest, error) { } } +// RepositoryWhereInput represents a where input for filtering Repository queries. +type RepositoryWhereInput struct { + Predicates []predicate.Repository `json:"-"` + Not *RepositoryWhereInput `json:"not,omitempty"` + Or []*RepositoryWhereInput `json:"or,omitempty"` + And []*RepositoryWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + + // "url" field predicates. + URL *string `json:"url,omitempty"` + URLNEQ *string `json:"urlNEQ,omitempty"` + URLIn []string `json:"urlIn,omitempty"` + URLNotIn []string `json:"urlNotIn,omitempty"` + URLGT *string `json:"urlGT,omitempty"` + URLGTE *string `json:"urlGTE,omitempty"` + URLLT *string `json:"urlLT,omitempty"` + URLLTE *string `json:"urlLTE,omitempty"` + URLContains *string `json:"urlContains,omitempty"` + URLHasPrefix *string `json:"urlHasPrefix,omitempty"` + URLHasSuffix *string `json:"urlHasSuffix,omitempty"` + URLEqualFold *string `json:"urlEqualFold,omitempty"` + URLContainsFold *string `json:"urlContainsFold,omitempty"` + + // "public_key" field predicates. + PublicKey *string `json:"publicKey,omitempty"` + PublicKeyNEQ *string `json:"publicKeyNEQ,omitempty"` + PublicKeyIn []string `json:"publicKeyIn,omitempty"` + PublicKeyNotIn []string `json:"publicKeyNotIn,omitempty"` + PublicKeyGT *string `json:"publicKeyGT,omitempty"` + PublicKeyGTE *string `json:"publicKeyGTE,omitempty"` + PublicKeyLT *string `json:"publicKeyLT,omitempty"` + PublicKeyLTE *string `json:"publicKeyLTE,omitempty"` + PublicKeyContains *string `json:"publicKeyContains,omitempty"` + PublicKeyHasPrefix *string `json:"publicKeyHasPrefix,omitempty"` + PublicKeyHasSuffix *string `json:"publicKeyHasSuffix,omitempty"` + PublicKeyEqualFold *string `json:"publicKeyEqualFold,omitempty"` + PublicKeyContainsFold *string `json:"publicKeyContainsFold,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *RepositoryWhereInput) AddPredicates(predicates ...predicate.Repository) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the RepositoryWhereInput filter on the RepositoryQuery builder. +func (i *RepositoryWhereInput) Filter(q *RepositoryQuery) (*RepositoryQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyRepositoryWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyRepositoryWhereInput is returned in case the RepositoryWhereInput is empty. +var ErrEmptyRepositoryWhereInput = errors.New("ent: empty predicate RepositoryWhereInput") + +// P returns a predicate for filtering repositories. +// An error is returned if the input is empty or invalid. +func (i *RepositoryWhereInput) P() (predicate.Repository, error) { + var predicates []predicate.Repository + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, repository.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Repository, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, repository.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Repository, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, repository.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, repository.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, repository.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, repository.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, repository.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, repository.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, repository.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, repository.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, repository.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, repository.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, repository.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, repository.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, repository.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, repository.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, repository.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, repository.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, repository.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, repository.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, repository.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, repository.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, repository.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, repository.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, repository.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, repository.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, repository.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.URL != nil { + predicates = append(predicates, repository.URLEQ(*i.URL)) + } + if i.URLNEQ != nil { + predicates = append(predicates, repository.URLNEQ(*i.URLNEQ)) + } + if len(i.URLIn) > 0 { + predicates = append(predicates, repository.URLIn(i.URLIn...)) + } + if len(i.URLNotIn) > 0 { + predicates = append(predicates, repository.URLNotIn(i.URLNotIn...)) + } + if i.URLGT != nil { + predicates = append(predicates, repository.URLGT(*i.URLGT)) + } + if i.URLGTE != nil { + predicates = append(predicates, repository.URLGTE(*i.URLGTE)) + } + if i.URLLT != nil { + predicates = append(predicates, repository.URLLT(*i.URLLT)) + } + if i.URLLTE != nil { + predicates = append(predicates, repository.URLLTE(*i.URLLTE)) + } + if i.URLContains != nil { + predicates = append(predicates, repository.URLContains(*i.URLContains)) + } + if i.URLHasPrefix != nil { + predicates = append(predicates, repository.URLHasPrefix(*i.URLHasPrefix)) + } + if i.URLHasSuffix != nil { + predicates = append(predicates, repository.URLHasSuffix(*i.URLHasSuffix)) + } + if i.URLEqualFold != nil { + predicates = append(predicates, repository.URLEqualFold(*i.URLEqualFold)) + } + if i.URLContainsFold != nil { + predicates = append(predicates, repository.URLContainsFold(*i.URLContainsFold)) + } + if i.PublicKey != nil { + predicates = append(predicates, repository.PublicKeyEQ(*i.PublicKey)) + } + if i.PublicKeyNEQ != nil { + predicates = append(predicates, repository.PublicKeyNEQ(*i.PublicKeyNEQ)) + } + if len(i.PublicKeyIn) > 0 { + predicates = append(predicates, repository.PublicKeyIn(i.PublicKeyIn...)) + } + if len(i.PublicKeyNotIn) > 0 { + predicates = append(predicates, repository.PublicKeyNotIn(i.PublicKeyNotIn...)) + } + if i.PublicKeyGT != nil { + predicates = append(predicates, repository.PublicKeyGT(*i.PublicKeyGT)) + } + if i.PublicKeyGTE != nil { + predicates = append(predicates, repository.PublicKeyGTE(*i.PublicKeyGTE)) + } + if i.PublicKeyLT != nil { + predicates = append(predicates, repository.PublicKeyLT(*i.PublicKeyLT)) + } + if i.PublicKeyLTE != nil { + predicates = append(predicates, repository.PublicKeyLTE(*i.PublicKeyLTE)) + } + if i.PublicKeyContains != nil { + predicates = append(predicates, repository.PublicKeyContains(*i.PublicKeyContains)) + } + if i.PublicKeyHasPrefix != nil { + predicates = append(predicates, repository.PublicKeyHasPrefix(*i.PublicKeyHasPrefix)) + } + if i.PublicKeyHasSuffix != nil { + predicates = append(predicates, repository.PublicKeyHasSuffix(*i.PublicKeyHasSuffix)) + } + if i.PublicKeyEqualFold != nil { + predicates = append(predicates, repository.PublicKeyEqualFold(*i.PublicKeyEqualFold)) + } + if i.PublicKeyContainsFold != nil { + predicates = append(predicates, repository.PublicKeyContainsFold(*i.PublicKeyContainsFold)) + } + + switch len(predicates) { + case 0: + return nil, ErrEmptyRepositoryWhereInput + case 1: + return predicates[0], nil + default: + return repository.And(predicates...), nil + } +} + // TagWhereInput represents a where input for filtering Tag queries. type TagWhereInput struct { Predicates []predicate.Tag `json:"-"` diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 750143dc8..fe4e45e5f 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -93,6 +93,18 @@ func (f QuestFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.QuestMutation", m) } +// The RepositoryFunc type is an adapter to allow the use of ordinary +// function as Repository mutator. +type RepositoryFunc func(context.Context, *ent.RepositoryMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f RepositoryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.RepositoryMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RepositoryMutation", 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) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index e9255d501..7833c7ccc 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -222,6 +222,21 @@ var ( }, }, } + // RepositoriesColumns holds the columns for the "repositories" table. + RepositoriesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "url", Type: field.TypeString, Unique: true}, + {Name: "public_key", Type: field.TypeString}, + {Name: "private_key", Type: field.TypeString}, + } + // RepositoriesTable holds the schema information for the "repositories" table. + RepositoriesTable = &schema.Table{ + Name: "repositories", + Columns: RepositoriesColumns, + PrimaryKey: []*schema.Column{RepositoriesColumns[0]}, + } // TagsColumns holds the columns for the "tags" table. TagsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -373,6 +388,7 @@ var ( HostFilesTable, HostProcessesTable, QuestsTable, + RepositoriesTable, TagsTable, TasksTable, TomesTable, diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 36cd03ab6..725db2398 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -21,6 +21,7 @@ import ( "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" "realm.pub/tavern/internal/ent/tome" @@ -43,6 +44,7 @@ const ( TypeHostFile = "HostFile" TypeHostProcess = "HostProcess" TypeQuest = "Quest" + TypeRepository = "Repository" TypeTag = "Tag" TypeTask = "Task" TypeTome = "Tome" @@ -6487,6 +6489,548 @@ func (m *QuestMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Quest edge %s", name) } +// RepositoryMutation represents an operation that mutates the Repository nodes in the graph. +type RepositoryMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + url *string + public_key *string + private_key *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Repository, error) + predicates []predicate.Repository +} + +var _ ent.Mutation = (*RepositoryMutation)(nil) + +// repositoryOption allows management of the mutation configuration using functional options. +type repositoryOption func(*RepositoryMutation) + +// newRepositoryMutation creates new mutation for the Repository entity. +func newRepositoryMutation(c config, op Op, opts ...repositoryOption) *RepositoryMutation { + m := &RepositoryMutation{ + config: c, + op: op, + typ: TypeRepository, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withRepositoryID sets the ID field of the mutation. +func withRepositoryID(id int) repositoryOption { + return func(m *RepositoryMutation) { + var ( + err error + once sync.Once + value *Repository + ) + m.oldValue = func(ctx context.Context) (*Repository, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Repository.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withRepository sets the old Repository of the mutation. +func withRepository(node *Repository) repositoryOption { + return func(m *RepositoryMutation) { + m.oldValue = func(context.Context) (*Repository, 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 RepositoryMutation) 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 RepositoryMutation) 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 +} + +// 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 *RepositoryMutation) ID() (id int, 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 *RepositoryMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Repository.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 *RepositoryMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *RepositoryMutation) 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 Repository entity. +// If the Repository 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 *RepositoryMutation) 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 *RepositoryMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *RepositoryMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *RepositoryMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the Repository entity. +// If the Repository 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 *RepositoryMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *RepositoryMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetURL sets the "url" field. +func (m *RepositoryMutation) SetURL(s string) { + m.url = &s +} + +// URL returns the value of the "url" field in the mutation. +func (m *RepositoryMutation) URL() (r string, exists bool) { + v := m.url + if v == nil { + return + } + return *v, true +} + +// OldURL returns the old "url" field's value of the Repository entity. +// If the Repository 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 *RepositoryMutation) OldURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldURL: %w", err) + } + return oldValue.URL, nil +} + +// ResetURL resets all changes to the "url" field. +func (m *RepositoryMutation) ResetURL() { + m.url = nil +} + +// SetPublicKey sets the "public_key" field. +func (m *RepositoryMutation) SetPublicKey(s string) { + m.public_key = &s +} + +// PublicKey returns the value of the "public_key" field in the mutation. +func (m *RepositoryMutation) PublicKey() (r string, exists bool) { + v := m.public_key + if v == nil { + return + } + return *v, true +} + +// OldPublicKey returns the old "public_key" field's value of the Repository entity. +// If the Repository 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 *RepositoryMutation) OldPublicKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPublicKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPublicKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPublicKey: %w", err) + } + return oldValue.PublicKey, nil +} + +// ResetPublicKey resets all changes to the "public_key" field. +func (m *RepositoryMutation) ResetPublicKey() { + m.public_key = nil +} + +// SetPrivateKey sets the "private_key" field. +func (m *RepositoryMutation) SetPrivateKey(s string) { + m.private_key = &s +} + +// PrivateKey returns the value of the "private_key" field in the mutation. +func (m *RepositoryMutation) PrivateKey() (r string, exists bool) { + v := m.private_key + if v == nil { + return + } + return *v, true +} + +// OldPrivateKey returns the old "private_key" field's value of the Repository entity. +// If the Repository 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 *RepositoryMutation) OldPrivateKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPrivateKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPrivateKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPrivateKey: %w", err) + } + return oldValue.PrivateKey, nil +} + +// ResetPrivateKey resets all changes to the "private_key" field. +func (m *RepositoryMutation) ResetPrivateKey() { + m.private_key = nil +} + +// Where appends a list predicates to the RepositoryMutation builder. +func (m *RepositoryMutation) Where(ps ...predicate.Repository) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the RepositoryMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RepositoryMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Repository, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *RepositoryMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *RepositoryMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Repository). +func (m *RepositoryMutation) 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 *RepositoryMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.created_at != nil { + fields = append(fields, repository.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, repository.FieldLastModifiedAt) + } + if m.url != nil { + fields = append(fields, repository.FieldURL) + } + if m.public_key != nil { + fields = append(fields, repository.FieldPublicKey) + } + if m.private_key != nil { + fields = append(fields, repository.FieldPrivateKey) + } + 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 *RepositoryMutation) Field(name string) (ent.Value, bool) { + switch name { + case repository.FieldCreatedAt: + return m.CreatedAt() + case repository.FieldLastModifiedAt: + return m.LastModifiedAt() + case repository.FieldURL: + return m.URL() + case repository.FieldPublicKey: + return m.PublicKey() + case repository.FieldPrivateKey: + return m.PrivateKey() + } + 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 *RepositoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case repository.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case repository.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case repository.FieldURL: + return m.OldURL(ctx) + case repository.FieldPublicKey: + return m.OldPublicKey(ctx) + case repository.FieldPrivateKey: + return m.OldPrivateKey(ctx) + } + return nil, fmt.Errorf("unknown Repository 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 *RepositoryMutation) SetField(name string, value ent.Value) error { + switch name { + case repository.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 repository.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil + case repository.FieldURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetURL(v) + return nil + case repository.FieldPublicKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPublicKey(v) + return nil + case repository.FieldPrivateKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPrivateKey(v) + return nil + } + return fmt.Errorf("unknown Repository field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RepositoryMutation) 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 *RepositoryMutation) 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 *RepositoryMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Repository numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RepositoryMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RepositoryMutation) 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 *RepositoryMutation) ClearField(name string) error { + return fmt.Errorf("unknown Repository 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 *RepositoryMutation) ResetField(name string) error { + switch name { + case repository.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case repository.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case repository.FieldURL: + m.ResetURL() + return nil + case repository.FieldPublicKey: + m.ResetPublicKey() + return nil + case repository.FieldPrivateKey: + m.ResetPrivateKey() + return nil + } + return fmt.Errorf("unknown Repository field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RepositoryMutation) 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 *RepositoryMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RepositoryMutation) 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 *RepositoryMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RepositoryMutation) 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 *RepositoryMutation) 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 *RepositoryMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Repository 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 *RepositoryMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Repository edge %s", name) +} + // TagMutation represents an operation that mutates the Tag nodes in the graph. type TagMutation struct { config diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 315d2f1e4..3774e65a4 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -27,6 +27,9 @@ type HostProcess func(*sql.Selector) // Quest is the predicate function for quest builders. type Quest func(*sql.Selector) +// Repository is the predicate function for repository builders. +type Repository func(*sql.Selector) + // Tag is the predicate function for tag builders. type Tag func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index 58165136e..54cd2549c 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -278,6 +278,30 @@ func (f QuestMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.QuestMutation", m) } +// The RepositoryQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type RepositoryQueryRuleFunc func(context.Context, *ent.RepositoryQuery) error + +// EvalQuery return f(ctx, q). +func (f RepositoryQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.RepositoryQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.RepositoryQuery", q) +} + +// The RepositoryMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type RepositoryMutationRuleFunc func(context.Context, *ent.RepositoryMutation) error + +// EvalMutation calls f(ctx, m). +func (f RepositoryMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.RepositoryMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.RepositoryMutation", m) +} + // The TagQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type TagQueryRuleFunc func(context.Context, *ent.TagQuery) error diff --git a/tavern/internal/ent/repository.go b/tavern/internal/ent/repository.go new file mode 100644 index 000000000..da124bf14 --- /dev/null +++ b/tavern/internal/ent/repository.go @@ -0,0 +1,149 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/repository" +) + +// Repository is the model entity for the Repository schema. +type Repository struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // URL of the repository + URL string `json:"url,omitempty"` + // Public key associated with this repositories private key + PublicKey string `json:"public_key,omitempty"` + // Private key used for authentication. + PrivateKey string `json:"-"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Repository) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case repository.FieldID: + values[i] = new(sql.NullInt64) + case repository.FieldURL, repository.FieldPublicKey, repository.FieldPrivateKey: + values[i] = new(sql.NullString) + case repository.FieldCreatedAt, repository.FieldLastModifiedAt: + 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 Repository fields. +func (r *Repository) 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 repository.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + r.ID = int(value.Int64) + case repository.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 { + r.CreatedAt = value.Time + } + case repository.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + r.LastModifiedAt = value.Time + } + case repository.FieldURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field url", values[i]) + } else if value.Valid { + r.URL = value.String + } + case repository.FieldPublicKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field public_key", values[i]) + } else if value.Valid { + r.PublicKey = value.String + } + case repository.FieldPrivateKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field private_key", values[i]) + } else if value.Valid { + r.PrivateKey = value.String + } + default: + r.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Repository. +// This includes values selected through modifiers, order, etc. +func (r *Repository) Value(name string) (ent.Value, error) { + return r.selectValues.Get(name) +} + +// Update returns a builder for updating this Repository. +// Note that you need to call Repository.Unwrap() before calling this method if this Repository +// was returned from a transaction, and the transaction was committed or rolled back. +func (r *Repository) Update() *RepositoryUpdateOne { + return NewRepositoryClient(r.config).UpdateOne(r) +} + +// Unwrap unwraps the Repository 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 (r *Repository) Unwrap() *Repository { + _tx, ok := r.config.driver.(*txDriver) + if !ok { + panic("ent: Repository is not a transactional entity") + } + r.config.driver = _tx.drv + return r +} + +// String implements the fmt.Stringer. +func (r *Repository) String() string { + var builder strings.Builder + builder.WriteString("Repository(") + builder.WriteString(fmt.Sprintf("id=%v, ", r.ID)) + builder.WriteString("created_at=") + builder.WriteString(r.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(r.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("url=") + builder.WriteString(r.URL) + builder.WriteString(", ") + builder.WriteString("public_key=") + builder.WriteString(r.PublicKey) + builder.WriteString(", ") + builder.WriteString("private_key=") + builder.WriteByte(')') + return builder.String() +} + +// Repositories is a parsable slice of Repository. +type Repositories []*Repository diff --git a/tavern/internal/ent/repository/repository.go b/tavern/internal/ent/repository/repository.go new file mode 100644 index 000000000..08f06a815 --- /dev/null +++ b/tavern/internal/ent/repository/repository.go @@ -0,0 +1,99 @@ +// Code generated by ent, DO NOT EDIT. + +package repository + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the repository type in the database. + Label = "repository" + // 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" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" + // FieldURL holds the string denoting the url field in the database. + FieldURL = "url" + // FieldPublicKey holds the string denoting the public_key field in the database. + FieldPublicKey = "public_key" + // FieldPrivateKey holds the string denoting the private_key field in the database. + FieldPrivateKey = "private_key" + // Table holds the table name of the repository in the database. + Table = "repositories" +) + +// Columns holds all SQL columns for repository fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldURL, + FieldPublicKey, + FieldPrivateKey, +} + +// 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 _ "realm.pub/tavern/internal/ent/runtime" +var ( + Hooks [1]ent.Hook + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time + // URLValidator is a validator for the "url" field. It is called by the builders before save. + URLValidator func(string) error +) + +// OrderOption defines the ordering options for the Repository 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() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + +// ByURL orders the results by the url field. +func ByURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldURL, opts...).ToFunc() +} + +// ByPublicKey orders the results by the public_key field. +func ByPublicKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPublicKey, opts...).ToFunc() +} + +// ByPrivateKey orders the results by the private_key field. +func ByPrivateKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPrivateKey, opts...).ToFunc() +} diff --git a/tavern/internal/ent/repository/where.go b/tavern/internal/ent/repository/where.go new file mode 100644 index 000000000..51462dd74 --- /dev/null +++ b/tavern/internal/ent/repository/where.go @@ -0,0 +1,370 @@ +// Code generated by ent, DO NOT EDIT. + +package repository + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// URL applies equality check predicate on the "url" field. It's identical to URLEQ. +func URL(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldURL, v)) +} + +// PublicKey applies equality check predicate on the "public_key" field. It's identical to PublicKeyEQ. +func PublicKey(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldPublicKey, v)) +} + +// PrivateKey applies equality check predicate on the "private_key" field. It's identical to PrivateKeyEQ. +func PrivateKey(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldPrivateKey, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// URLEQ applies the EQ predicate on the "url" field. +func URLEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldURL, v)) +} + +// URLNEQ applies the NEQ predicate on the "url" field. +func URLNEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldURL, v)) +} + +// URLIn applies the In predicate on the "url" field. +func URLIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldURL, vs...)) +} + +// URLNotIn applies the NotIn predicate on the "url" field. +func URLNotIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldURL, vs...)) +} + +// URLGT applies the GT predicate on the "url" field. +func URLGT(v string) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldURL, v)) +} + +// URLGTE applies the GTE predicate on the "url" field. +func URLGTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldURL, v)) +} + +// URLLT applies the LT predicate on the "url" field. +func URLLT(v string) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldURL, v)) +} + +// URLLTE applies the LTE predicate on the "url" field. +func URLLTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldURL, v)) +} + +// URLContains applies the Contains predicate on the "url" field. +func URLContains(v string) predicate.Repository { + return predicate.Repository(sql.FieldContains(FieldURL, v)) +} + +// URLHasPrefix applies the HasPrefix predicate on the "url" field. +func URLHasPrefix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasPrefix(FieldURL, v)) +} + +// URLHasSuffix applies the HasSuffix predicate on the "url" field. +func URLHasSuffix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasSuffix(FieldURL, v)) +} + +// URLEqualFold applies the EqualFold predicate on the "url" field. +func URLEqualFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldEqualFold(FieldURL, v)) +} + +// URLContainsFold applies the ContainsFold predicate on the "url" field. +func URLContainsFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldContainsFold(FieldURL, v)) +} + +// PublicKeyEQ applies the EQ predicate on the "public_key" field. +func PublicKeyEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldPublicKey, v)) +} + +// PublicKeyNEQ applies the NEQ predicate on the "public_key" field. +func PublicKeyNEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldPublicKey, v)) +} + +// PublicKeyIn applies the In predicate on the "public_key" field. +func PublicKeyIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldPublicKey, vs...)) +} + +// PublicKeyNotIn applies the NotIn predicate on the "public_key" field. +func PublicKeyNotIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldPublicKey, vs...)) +} + +// PublicKeyGT applies the GT predicate on the "public_key" field. +func PublicKeyGT(v string) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldPublicKey, v)) +} + +// PublicKeyGTE applies the GTE predicate on the "public_key" field. +func PublicKeyGTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldPublicKey, v)) +} + +// PublicKeyLT applies the LT predicate on the "public_key" field. +func PublicKeyLT(v string) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldPublicKey, v)) +} + +// PublicKeyLTE applies the LTE predicate on the "public_key" field. +func PublicKeyLTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldPublicKey, v)) +} + +// PublicKeyContains applies the Contains predicate on the "public_key" field. +func PublicKeyContains(v string) predicate.Repository { + return predicate.Repository(sql.FieldContains(FieldPublicKey, v)) +} + +// PublicKeyHasPrefix applies the HasPrefix predicate on the "public_key" field. +func PublicKeyHasPrefix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasPrefix(FieldPublicKey, v)) +} + +// PublicKeyHasSuffix applies the HasSuffix predicate on the "public_key" field. +func PublicKeyHasSuffix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasSuffix(FieldPublicKey, v)) +} + +// PublicKeyEqualFold applies the EqualFold predicate on the "public_key" field. +func PublicKeyEqualFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldEqualFold(FieldPublicKey, v)) +} + +// PublicKeyContainsFold applies the ContainsFold predicate on the "public_key" field. +func PublicKeyContainsFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldContainsFold(FieldPublicKey, v)) +} + +// PrivateKeyEQ applies the EQ predicate on the "private_key" field. +func PrivateKeyEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldEQ(FieldPrivateKey, v)) +} + +// PrivateKeyNEQ applies the NEQ predicate on the "private_key" field. +func PrivateKeyNEQ(v string) predicate.Repository { + return predicate.Repository(sql.FieldNEQ(FieldPrivateKey, v)) +} + +// PrivateKeyIn applies the In predicate on the "private_key" field. +func PrivateKeyIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldIn(FieldPrivateKey, vs...)) +} + +// PrivateKeyNotIn applies the NotIn predicate on the "private_key" field. +func PrivateKeyNotIn(vs ...string) predicate.Repository { + return predicate.Repository(sql.FieldNotIn(FieldPrivateKey, vs...)) +} + +// PrivateKeyGT applies the GT predicate on the "private_key" field. +func PrivateKeyGT(v string) predicate.Repository { + return predicate.Repository(sql.FieldGT(FieldPrivateKey, v)) +} + +// PrivateKeyGTE applies the GTE predicate on the "private_key" field. +func PrivateKeyGTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldGTE(FieldPrivateKey, v)) +} + +// PrivateKeyLT applies the LT predicate on the "private_key" field. +func PrivateKeyLT(v string) predicate.Repository { + return predicate.Repository(sql.FieldLT(FieldPrivateKey, v)) +} + +// PrivateKeyLTE applies the LTE predicate on the "private_key" field. +func PrivateKeyLTE(v string) predicate.Repository { + return predicate.Repository(sql.FieldLTE(FieldPrivateKey, v)) +} + +// PrivateKeyContains applies the Contains predicate on the "private_key" field. +func PrivateKeyContains(v string) predicate.Repository { + return predicate.Repository(sql.FieldContains(FieldPrivateKey, v)) +} + +// PrivateKeyHasPrefix applies the HasPrefix predicate on the "private_key" field. +func PrivateKeyHasPrefix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasPrefix(FieldPrivateKey, v)) +} + +// PrivateKeyHasSuffix applies the HasSuffix predicate on the "private_key" field. +func PrivateKeyHasSuffix(v string) predicate.Repository { + return predicate.Repository(sql.FieldHasSuffix(FieldPrivateKey, v)) +} + +// PrivateKeyEqualFold applies the EqualFold predicate on the "private_key" field. +func PrivateKeyEqualFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldEqualFold(FieldPrivateKey, v)) +} + +// PrivateKeyContainsFold applies the ContainsFold predicate on the "private_key" field. +func PrivateKeyContainsFold(v string) predicate.Repository { + return predicate.Repository(sql.FieldContainsFold(FieldPrivateKey, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Repository) predicate.Repository { + return predicate.Repository(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Repository) predicate.Repository { + return predicate.Repository(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Repository) predicate.Repository { + return predicate.Repository(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/repository_create.go b/tavern/internal/ent/repository_create.go new file mode 100644 index 000000000..9a3fb7d5d --- /dev/null +++ b/tavern/internal/ent/repository_create.go @@ -0,0 +1,683 @@ +// 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" + "realm.pub/tavern/internal/ent/repository" +) + +// RepositoryCreate is the builder for creating a Repository entity. +type RepositoryCreate struct { + config + mutation *RepositoryMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (rc *RepositoryCreate) SetCreatedAt(t time.Time) *RepositoryCreate { + rc.mutation.SetCreatedAt(t) + return rc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (rc *RepositoryCreate) SetNillableCreatedAt(t *time.Time) *RepositoryCreate { + if t != nil { + rc.SetCreatedAt(*t) + } + return rc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (rc *RepositoryCreate) SetLastModifiedAt(t time.Time) *RepositoryCreate { + rc.mutation.SetLastModifiedAt(t) + return rc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (rc *RepositoryCreate) SetNillableLastModifiedAt(t *time.Time) *RepositoryCreate { + if t != nil { + rc.SetLastModifiedAt(*t) + } + return rc +} + +// SetURL sets the "url" field. +func (rc *RepositoryCreate) SetURL(s string) *RepositoryCreate { + rc.mutation.SetURL(s) + return rc +} + +// SetPublicKey sets the "public_key" field. +func (rc *RepositoryCreate) SetPublicKey(s string) *RepositoryCreate { + rc.mutation.SetPublicKey(s) + return rc +} + +// SetPrivateKey sets the "private_key" field. +func (rc *RepositoryCreate) SetPrivateKey(s string) *RepositoryCreate { + rc.mutation.SetPrivateKey(s) + return rc +} + +// Mutation returns the RepositoryMutation object of the builder. +func (rc *RepositoryCreate) Mutation() *RepositoryMutation { + return rc.mutation +} + +// Save creates the Repository in the database. +func (rc *RepositoryCreate) Save(ctx context.Context) (*Repository, error) { + if err := rc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, rc.sqlSave, rc.mutation, rc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (rc *RepositoryCreate) SaveX(ctx context.Context) *Repository { + v, err := rc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (rc *RepositoryCreate) Exec(ctx context.Context) error { + _, err := rc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (rc *RepositoryCreate) ExecX(ctx context.Context) { + if err := rc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (rc *RepositoryCreate) defaults() error { + if _, ok := rc.mutation.CreatedAt(); !ok { + if repository.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized repository.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := repository.DefaultCreatedAt() + rc.mutation.SetCreatedAt(v) + } + if _, ok := rc.mutation.LastModifiedAt(); !ok { + if repository.DefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized repository.DefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := repository.DefaultLastModifiedAt() + rc.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (rc *RepositoryCreate) check() error { + if _, ok := rc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Repository.created_at"`)} + } + if _, ok := rc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Repository.last_modified_at"`)} + } + if _, ok := rc.mutation.URL(); !ok { + return &ValidationError{Name: "url", err: errors.New(`ent: missing required field "Repository.url"`)} + } + if v, ok := rc.mutation.URL(); ok { + if err := repository.URLValidator(v); err != nil { + return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Repository.url": %w`, err)} + } + } + if _, ok := rc.mutation.PublicKey(); !ok { + return &ValidationError{Name: "public_key", err: errors.New(`ent: missing required field "Repository.public_key"`)} + } + if _, ok := rc.mutation.PrivateKey(); !ok { + return &ValidationError{Name: "private_key", err: errors.New(`ent: missing required field "Repository.private_key"`)} + } + return nil +} + +func (rc *RepositoryCreate) sqlSave(ctx context.Context) (*Repository, error) { + if err := rc.check(); err != nil { + return nil, err + } + _node, _spec := rc.createSpec() + if err := sqlgraph.CreateNode(ctx, rc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + rc.mutation.id = &_node.ID + rc.mutation.done = true + return _node, nil +} + +func (rc *RepositoryCreate) createSpec() (*Repository, *sqlgraph.CreateSpec) { + var ( + _node = &Repository{config: rc.config} + _spec = sqlgraph.NewCreateSpec(repository.Table, sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt)) + ) + _spec.OnConflict = rc.conflict + if value, ok := rc.mutation.CreatedAt(); ok { + _spec.SetField(repository.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := rc.mutation.LastModifiedAt(); ok { + _spec.SetField(repository.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := rc.mutation.URL(); ok { + _spec.SetField(repository.FieldURL, field.TypeString, value) + _node.URL = value + } + if value, ok := rc.mutation.PublicKey(); ok { + _spec.SetField(repository.FieldPublicKey, field.TypeString, value) + _node.PublicKey = value + } + if value, ok := rc.mutation.PrivateKey(); ok { + _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) + _node.PrivateKey = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Repository.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.RepositoryUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (rc *RepositoryCreate) OnConflict(opts ...sql.ConflictOption) *RepositoryUpsertOne { + rc.conflict = opts + return &RepositoryUpsertOne{ + create: rc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (rc *RepositoryCreate) OnConflictColumns(columns ...string) *RepositoryUpsertOne { + rc.conflict = append(rc.conflict, sql.ConflictColumns(columns...)) + return &RepositoryUpsertOne{ + create: rc, + } +} + +type ( + // RepositoryUpsertOne is the builder for "upsert"-ing + // one Repository node. + RepositoryUpsertOne struct { + create *RepositoryCreate + } + + // RepositoryUpsert is the "OnConflict" setter. + RepositoryUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *RepositoryUpsert) SetLastModifiedAt(v time.Time) *RepositoryUpsert { + u.Set(repository.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *RepositoryUpsert) UpdateLastModifiedAt() *RepositoryUpsert { + u.SetExcluded(repository.FieldLastModifiedAt) + return u +} + +// SetURL sets the "url" field. +func (u *RepositoryUpsert) SetURL(v string) *RepositoryUpsert { + u.Set(repository.FieldURL, v) + return u +} + +// UpdateURL sets the "url" field to the value that was provided on create. +func (u *RepositoryUpsert) UpdateURL() *RepositoryUpsert { + u.SetExcluded(repository.FieldURL) + return u +} + +// SetPublicKey sets the "public_key" field. +func (u *RepositoryUpsert) SetPublicKey(v string) *RepositoryUpsert { + u.Set(repository.FieldPublicKey, v) + return u +} + +// UpdatePublicKey sets the "public_key" field to the value that was provided on create. +func (u *RepositoryUpsert) UpdatePublicKey() *RepositoryUpsert { + u.SetExcluded(repository.FieldPublicKey) + return u +} + +// SetPrivateKey sets the "private_key" field. +func (u *RepositoryUpsert) SetPrivateKey(v string) *RepositoryUpsert { + u.Set(repository.FieldPrivateKey, v) + return u +} + +// UpdatePrivateKey sets the "private_key" field to the value that was provided on create. +func (u *RepositoryUpsert) UpdatePrivateKey() *RepositoryUpsert { + u.SetExcluded(repository.FieldPrivateKey) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *RepositoryUpsertOne) UpdateNewValues() *RepositoryUpsertOne { + 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(repository.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *RepositoryUpsertOne) Ignore() *RepositoryUpsertOne { + 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 *RepositoryUpsertOne) DoNothing() *RepositoryUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the RepositoryCreate.OnConflict +// documentation for more info. +func (u *RepositoryUpsertOne) Update(set func(*RepositoryUpsert)) *RepositoryUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&RepositoryUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *RepositoryUpsertOne) SetLastModifiedAt(v time.Time) *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *RepositoryUpsertOne) UpdateLastModifiedAt() *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetURL sets the "url" field. +func (u *RepositoryUpsertOne) SetURL(v string) *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.SetURL(v) + }) +} + +// UpdateURL sets the "url" field to the value that was provided on create. +func (u *RepositoryUpsertOne) UpdateURL() *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.UpdateURL() + }) +} + +// SetPublicKey sets the "public_key" field. +func (u *RepositoryUpsertOne) SetPublicKey(v string) *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.SetPublicKey(v) + }) +} + +// UpdatePublicKey sets the "public_key" field to the value that was provided on create. +func (u *RepositoryUpsertOne) UpdatePublicKey() *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.UpdatePublicKey() + }) +} + +// SetPrivateKey sets the "private_key" field. +func (u *RepositoryUpsertOne) SetPrivateKey(v string) *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.SetPrivateKey(v) + }) +} + +// UpdatePrivateKey sets the "private_key" field to the value that was provided on create. +func (u *RepositoryUpsertOne) UpdatePrivateKey() *RepositoryUpsertOne { + return u.Update(func(s *RepositoryUpsert) { + s.UpdatePrivateKey() + }) +} + +// Exec executes the query. +func (u *RepositoryUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for RepositoryCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *RepositoryUpsertOne) 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 *RepositoryUpsertOne) ID(ctx context.Context) (id int, err error) { + 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 *RepositoryUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// RepositoryCreateBulk is the builder for creating many Repository entities in bulk. +type RepositoryCreateBulk struct { + config + err error + builders []*RepositoryCreate + conflict []sql.ConflictOption +} + +// Save creates the Repository entities in the database. +func (rcb *RepositoryCreateBulk) Save(ctx context.Context) ([]*Repository, error) { + if rcb.err != nil { + return nil, rcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(rcb.builders)) + nodes := make([]*Repository, len(rcb.builders)) + mutators := make([]Mutator, len(rcb.builders)) + for i := range rcb.builders { + func(i int, root context.Context) { + builder := rcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*RepositoryMutation) + 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, rcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = rcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, rcb.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 + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(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, rcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (rcb *RepositoryCreateBulk) SaveX(ctx context.Context) []*Repository { + v, err := rcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (rcb *RepositoryCreateBulk) Exec(ctx context.Context) error { + _, err := rcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (rcb *RepositoryCreateBulk) ExecX(ctx context.Context) { + if err := rcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Repository.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.RepositoryUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (rcb *RepositoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *RepositoryUpsertBulk { + rcb.conflict = opts + return &RepositoryUpsertBulk{ + create: rcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (rcb *RepositoryCreateBulk) OnConflictColumns(columns ...string) *RepositoryUpsertBulk { + rcb.conflict = append(rcb.conflict, sql.ConflictColumns(columns...)) + return &RepositoryUpsertBulk{ + create: rcb, + } +} + +// RepositoryUpsertBulk is the builder for "upsert"-ing +// a bulk of Repository nodes. +type RepositoryUpsertBulk struct { + create *RepositoryCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *RepositoryUpsertBulk) UpdateNewValues() *RepositoryUpsertBulk { + 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(repository.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Repository.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *RepositoryUpsertBulk) Ignore() *RepositoryUpsertBulk { + 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 *RepositoryUpsertBulk) DoNothing() *RepositoryUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the RepositoryCreateBulk.OnConflict +// documentation for more info. +func (u *RepositoryUpsertBulk) Update(set func(*RepositoryUpsert)) *RepositoryUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&RepositoryUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *RepositoryUpsertBulk) SetLastModifiedAt(v time.Time) *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *RepositoryUpsertBulk) UpdateLastModifiedAt() *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetURL sets the "url" field. +func (u *RepositoryUpsertBulk) SetURL(v string) *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.SetURL(v) + }) +} + +// UpdateURL sets the "url" field to the value that was provided on create. +func (u *RepositoryUpsertBulk) UpdateURL() *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.UpdateURL() + }) +} + +// SetPublicKey sets the "public_key" field. +func (u *RepositoryUpsertBulk) SetPublicKey(v string) *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.SetPublicKey(v) + }) +} + +// UpdatePublicKey sets the "public_key" field to the value that was provided on create. +func (u *RepositoryUpsertBulk) UpdatePublicKey() *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.UpdatePublicKey() + }) +} + +// SetPrivateKey sets the "private_key" field. +func (u *RepositoryUpsertBulk) SetPrivateKey(v string) *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.SetPrivateKey(v) + }) +} + +// UpdatePrivateKey sets the "private_key" field to the value that was provided on create. +func (u *RepositoryUpsertBulk) UpdatePrivateKey() *RepositoryUpsertBulk { + return u.Update(func(s *RepositoryUpsert) { + s.UpdatePrivateKey() + }) +} + +// Exec executes the query. +func (u *RepositoryUpsertBulk) 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 RepositoryCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for RepositoryCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *RepositoryUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/repository_delete.go b/tavern/internal/ent/repository_delete.go new file mode 100644 index 000000000..c03ea5459 --- /dev/null +++ b/tavern/internal/ent/repository_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" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/repository" +) + +// RepositoryDelete is the builder for deleting a Repository entity. +type RepositoryDelete struct { + config + hooks []Hook + mutation *RepositoryMutation +} + +// Where appends a list predicates to the RepositoryDelete builder. +func (rd *RepositoryDelete) Where(ps ...predicate.Repository) *RepositoryDelete { + rd.mutation.Where(ps...) + return rd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (rd *RepositoryDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, rd.sqlExec, rd.mutation, rd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (rd *RepositoryDelete) ExecX(ctx context.Context) int { + n, err := rd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (rd *RepositoryDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(repository.Table, sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt)) + if ps := rd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, rd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + rd.mutation.done = true + return affected, err +} + +// RepositoryDeleteOne is the builder for deleting a single Repository entity. +type RepositoryDeleteOne struct { + rd *RepositoryDelete +} + +// Where appends a list predicates to the RepositoryDelete builder. +func (rdo *RepositoryDeleteOne) Where(ps ...predicate.Repository) *RepositoryDeleteOne { + rdo.rd.mutation.Where(ps...) + return rdo +} + +// Exec executes the deletion query. +func (rdo *RepositoryDeleteOne) Exec(ctx context.Context) error { + n, err := rdo.rd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{repository.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (rdo *RepositoryDeleteOne) ExecX(ctx context.Context) { + if err := rdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/repository_query.go b/tavern/internal/ent/repository_query.go new file mode 100644 index 000000000..d5766e1c5 --- /dev/null +++ b/tavern/internal/ent/repository_query.go @@ -0,0 +1,539 @@ +// 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" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/repository" +) + +// RepositoryQuery is the builder for querying Repository entities. +type RepositoryQuery struct { + config + ctx *QueryContext + order []repository.OrderOption + inters []Interceptor + predicates []predicate.Repository + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Repository) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the RepositoryQuery builder. +func (rq *RepositoryQuery) Where(ps ...predicate.Repository) *RepositoryQuery { + rq.predicates = append(rq.predicates, ps...) + return rq +} + +// Limit the number of records to be returned by this query. +func (rq *RepositoryQuery) Limit(limit int) *RepositoryQuery { + rq.ctx.Limit = &limit + return rq +} + +// Offset to start from. +func (rq *RepositoryQuery) Offset(offset int) *RepositoryQuery { + rq.ctx.Offset = &offset + return rq +} + +// 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 (rq *RepositoryQuery) Unique(unique bool) *RepositoryQuery { + rq.ctx.Unique = &unique + return rq +} + +// Order specifies how the records should be ordered. +func (rq *RepositoryQuery) Order(o ...repository.OrderOption) *RepositoryQuery { + rq.order = append(rq.order, o...) + return rq +} + +// First returns the first Repository entity from the query. +// Returns a *NotFoundError when no Repository was found. +func (rq *RepositoryQuery) First(ctx context.Context) (*Repository, error) { + nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{repository.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (rq *RepositoryQuery) FirstX(ctx context.Context) *Repository { + node, err := rq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Repository ID from the query. +// Returns a *NotFoundError when no Repository ID was found. +func (rq *RepositoryQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{repository.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (rq *RepositoryQuery) FirstIDX(ctx context.Context) int { + id, err := rq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Repository entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Repository entity is found. +// Returns a *NotFoundError when no Repository entities are found. +func (rq *RepositoryQuery) Only(ctx context.Context) (*Repository, error) { + nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{repository.Label} + default: + return nil, &NotSingularError{repository.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (rq *RepositoryQuery) OnlyX(ctx context.Context) *Repository { + node, err := rq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Repository ID in the query. +// Returns a *NotSingularError when more than one Repository ID is found. +// Returns a *NotFoundError when no entities are found. +func (rq *RepositoryQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{repository.Label} + default: + err = &NotSingularError{repository.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (rq *RepositoryQuery) OnlyIDX(ctx context.Context) int { + id, err := rq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Repositories. +func (rq *RepositoryQuery) All(ctx context.Context) ([]*Repository, error) { + ctx = setContextOp(ctx, rq.ctx, "All") + if err := rq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Repository, *RepositoryQuery]() + return withInterceptors[[]*Repository](ctx, rq, qr, rq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (rq *RepositoryQuery) AllX(ctx context.Context) []*Repository { + nodes, err := rq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Repository IDs. +func (rq *RepositoryQuery) IDs(ctx context.Context) (ids []int, err error) { + if rq.ctx.Unique == nil && rq.path != nil { + rq.Unique(true) + } + ctx = setContextOp(ctx, rq.ctx, "IDs") + if err = rq.Select(repository.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (rq *RepositoryQuery) IDsX(ctx context.Context) []int { + ids, err := rq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (rq *RepositoryQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, rq.ctx, "Count") + if err := rq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, rq, querierCount[*RepositoryQuery](), rq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (rq *RepositoryQuery) CountX(ctx context.Context) int { + count, err := rq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (rq *RepositoryQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, rq.ctx, "Exist") + switch _, err := rq.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 (rq *RepositoryQuery) ExistX(ctx context.Context) bool { + exist, err := rq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the RepositoryQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (rq *RepositoryQuery) Clone() *RepositoryQuery { + if rq == nil { + return nil + } + return &RepositoryQuery{ + config: rq.config, + ctx: rq.ctx.Clone(), + order: append([]repository.OrderOption{}, rq.order...), + inters: append([]Interceptor{}, rq.inters...), + predicates: append([]predicate.Repository{}, rq.predicates...), + // clone intermediate query. + sql: rq.sql.Clone(), + path: rq.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.Repository.Query(). +// GroupBy(repository.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (rq *RepositoryQuery) GroupBy(field string, fields ...string) *RepositoryGroupBy { + rq.ctx.Fields = append([]string{field}, fields...) + grbuild := &RepositoryGroupBy{build: rq} + grbuild.flds = &rq.ctx.Fields + grbuild.label = repository.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.Repository.Query(). +// Select(repository.FieldCreatedAt). +// Scan(ctx, &v) +func (rq *RepositoryQuery) Select(fields ...string) *RepositorySelect { + rq.ctx.Fields = append(rq.ctx.Fields, fields...) + sbuild := &RepositorySelect{RepositoryQuery: rq} + sbuild.label = repository.Label + sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a RepositorySelect configured with the given aggregations. +func (rq *RepositoryQuery) Aggregate(fns ...AggregateFunc) *RepositorySelect { + return rq.Select().Aggregate(fns...) +} + +func (rq *RepositoryQuery) prepareQuery(ctx context.Context) error { + for _, inter := range rq.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, rq); err != nil { + return err + } + } + } + for _, f := range rq.ctx.Fields { + if !repository.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if rq.path != nil { + prev, err := rq.path(ctx) + if err != nil { + return err + } + rq.sql = prev + } + return nil +} + +func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Repository, error) { + var ( + nodes = []*Repository{} + _spec = rq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Repository).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Repository{config: rq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(rq.modifiers) > 0 { + _spec.Modifiers = rq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, rq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + for i := range rq.loadTotal { + if err := rq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (rq *RepositoryQuery) sqlCount(ctx context.Context) (int, error) { + _spec := rq.querySpec() + if len(rq.modifiers) > 0 { + _spec.Modifiers = rq.modifiers + } + _spec.Node.Columns = rq.ctx.Fields + if len(rq.ctx.Fields) > 0 { + _spec.Unique = rq.ctx.Unique != nil && *rq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, rq.driver, _spec) +} + +func (rq *RepositoryQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(repository.Table, repository.Columns, sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt)) + _spec.From = rq.sql + if unique := rq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if rq.path != nil { + _spec.Unique = true + } + if fields := rq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, repository.FieldID) + for i := range fields { + if fields[i] != repository.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := rq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := rq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := rq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := rq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (rq *RepositoryQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(rq.driver.Dialect()) + t1 := builder.Table(repository.Table) + columns := rq.ctx.Fields + if len(columns) == 0 { + columns = repository.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if rq.sql != nil { + selector = rq.sql + selector.Select(selector.Columns(columns...)...) + } + if rq.ctx.Unique != nil && *rq.ctx.Unique { + selector.Distinct() + } + for _, p := range rq.predicates { + p(selector) + } + for _, p := range rq.order { + p(selector) + } + if offset := rq.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 := rq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// RepositoryGroupBy is the group-by builder for Repository entities. +type RepositoryGroupBy struct { + selector + build *RepositoryQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (rgb *RepositoryGroupBy) Aggregate(fns ...AggregateFunc) *RepositoryGroupBy { + rgb.fns = append(rgb.fns, fns...) + return rgb +} + +// Scan applies the selector query and scans the result into the given value. +func (rgb *RepositoryGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, rgb.build.ctx, "GroupBy") + if err := rgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RepositoryQuery, *RepositoryGroupBy](ctx, rgb.build, rgb, rgb.build.inters, v) +} + +func (rgb *RepositoryGroupBy) sqlScan(ctx context.Context, root *RepositoryQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(rgb.fns)) + for _, fn := range rgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*rgb.flds)+len(rgb.fns)) + for _, f := range *rgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*rgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := rgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// RepositorySelect is the builder for selecting fields of Repository entities. +type RepositorySelect struct { + *RepositoryQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (rs *RepositorySelect) Aggregate(fns ...AggregateFunc) *RepositorySelect { + rs.fns = append(rs.fns, fns...) + return rs +} + +// Scan applies the selector query and scans the result into the given value. +func (rs *RepositorySelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, rs.ctx, "Select") + if err := rs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RepositoryQuery, *RepositorySelect](ctx, rs.RepositoryQuery, rs, rs.inters, v) +} + +func (rs *RepositorySelect) sqlScan(ctx context.Context, root *RepositoryQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(rs.fns)) + for _, fn := range rs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*rs.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 := rs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/repository_update.go b/tavern/internal/ent/repository_update.go new file mode 100644 index 000000000..8a178b004 --- /dev/null +++ b/tavern/internal/ent/repository_update.go @@ -0,0 +1,304 @@ +// 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" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/repository" +) + +// RepositoryUpdate is the builder for updating Repository entities. +type RepositoryUpdate struct { + config + hooks []Hook + mutation *RepositoryMutation +} + +// Where appends a list predicates to the RepositoryUpdate builder. +func (ru *RepositoryUpdate) Where(ps ...predicate.Repository) *RepositoryUpdate { + ru.mutation.Where(ps...) + return ru +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (ru *RepositoryUpdate) SetLastModifiedAt(t time.Time) *RepositoryUpdate { + ru.mutation.SetLastModifiedAt(t) + return ru +} + +// SetURL sets the "url" field. +func (ru *RepositoryUpdate) SetURL(s string) *RepositoryUpdate { + ru.mutation.SetURL(s) + return ru +} + +// SetPublicKey sets the "public_key" field. +func (ru *RepositoryUpdate) SetPublicKey(s string) *RepositoryUpdate { + ru.mutation.SetPublicKey(s) + return ru +} + +// SetPrivateKey sets the "private_key" field. +func (ru *RepositoryUpdate) SetPrivateKey(s string) *RepositoryUpdate { + ru.mutation.SetPrivateKey(s) + return ru +} + +// Mutation returns the RepositoryMutation object of the builder. +func (ru *RepositoryUpdate) Mutation() *RepositoryMutation { + return ru.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ru *RepositoryUpdate) Save(ctx context.Context) (int, error) { + if err := ru.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, ru.sqlSave, ru.mutation, ru.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ru *RepositoryUpdate) SaveX(ctx context.Context) int { + affected, err := ru.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ru *RepositoryUpdate) Exec(ctx context.Context) error { + _, err := ru.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ru *RepositoryUpdate) ExecX(ctx context.Context) { + if err := ru.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ru *RepositoryUpdate) defaults() error { + if _, ok := ru.mutation.LastModifiedAt(); !ok { + if repository.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized repository.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := repository.UpdateDefaultLastModifiedAt() + ru.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (ru *RepositoryUpdate) check() error { + if v, ok := ru.mutation.URL(); ok { + if err := repository.URLValidator(v); err != nil { + return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Repository.url": %w`, err)} + } + } + return nil +} + +func (ru *RepositoryUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ru.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(repository.Table, repository.Columns, sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt)) + if ps := ru.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ru.mutation.LastModifiedAt(); ok { + _spec.SetField(repository.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := ru.mutation.URL(); ok { + _spec.SetField(repository.FieldURL, field.TypeString, value) + } + if value, ok := ru.mutation.PublicKey(); ok { + _spec.SetField(repository.FieldPublicKey, field.TypeString, value) + } + if value, ok := ru.mutation.PrivateKey(); ok { + _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{repository.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ru.mutation.done = true + return n, nil +} + +// RepositoryUpdateOne is the builder for updating a single Repository entity. +type RepositoryUpdateOne struct { + config + fields []string + hooks []Hook + mutation *RepositoryMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (ruo *RepositoryUpdateOne) SetLastModifiedAt(t time.Time) *RepositoryUpdateOne { + ruo.mutation.SetLastModifiedAt(t) + return ruo +} + +// SetURL sets the "url" field. +func (ruo *RepositoryUpdateOne) SetURL(s string) *RepositoryUpdateOne { + ruo.mutation.SetURL(s) + return ruo +} + +// SetPublicKey sets the "public_key" field. +func (ruo *RepositoryUpdateOne) SetPublicKey(s string) *RepositoryUpdateOne { + ruo.mutation.SetPublicKey(s) + return ruo +} + +// SetPrivateKey sets the "private_key" field. +func (ruo *RepositoryUpdateOne) SetPrivateKey(s string) *RepositoryUpdateOne { + ruo.mutation.SetPrivateKey(s) + return ruo +} + +// Mutation returns the RepositoryMutation object of the builder. +func (ruo *RepositoryUpdateOne) Mutation() *RepositoryMutation { + return ruo.mutation +} + +// Where appends a list predicates to the RepositoryUpdate builder. +func (ruo *RepositoryUpdateOne) Where(ps ...predicate.Repository) *RepositoryUpdateOne { + ruo.mutation.Where(ps...) + return ruo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (ruo *RepositoryUpdateOne) Select(field string, fields ...string) *RepositoryUpdateOne { + ruo.fields = append([]string{field}, fields...) + return ruo +} + +// Save executes the query and returns the updated Repository entity. +func (ruo *RepositoryUpdateOne) Save(ctx context.Context) (*Repository, error) { + if err := ruo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, ruo.sqlSave, ruo.mutation, ruo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ruo *RepositoryUpdateOne) SaveX(ctx context.Context) *Repository { + node, err := ruo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (ruo *RepositoryUpdateOne) Exec(ctx context.Context) error { + _, err := ruo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ruo *RepositoryUpdateOne) ExecX(ctx context.Context) { + if err := ruo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ruo *RepositoryUpdateOne) defaults() error { + if _, ok := ruo.mutation.LastModifiedAt(); !ok { + if repository.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized repository.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := repository.UpdateDefaultLastModifiedAt() + ruo.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (ruo *RepositoryUpdateOne) check() error { + if v, ok := ruo.mutation.URL(); ok { + if err := repository.URLValidator(v); err != nil { + return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Repository.url": %w`, err)} + } + } + return nil +} + +func (ruo *RepositoryUpdateOne) sqlSave(ctx context.Context) (_node *Repository, err error) { + if err := ruo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(repository.Table, repository.Columns, sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt)) + id, ok := ruo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Repository.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := ruo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, repository.FieldID) + for _, f := range fields { + if !repository.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != repository.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := ruo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ruo.mutation.LastModifiedAt(); ok { + _spec.SetField(repository.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := ruo.mutation.URL(); ok { + _spec.SetField(repository.FieldURL, field.TypeString, value) + } + if value, ok := ruo.mutation.PublicKey(); ok { + _spec.SetField(repository.FieldPublicKey, field.TypeString, value) + } + if value, ok := ruo.mutation.PrivateKey(); ok { + _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) + } + _node = &Repository{config: ruo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, ruo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{repository.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + ruo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 4fdee078d..7f0a58694 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -12,6 +12,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/schema" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -208,6 +209,27 @@ func init() { questDescParameters := questFields[1].Descriptor() // quest.ParametersValidator is a validator for the "parameters" field. It is called by the builders before save. quest.ParametersValidator = questDescParameters.Validators[0].(func(string) error) + repositoryMixin := schema.Repository{}.Mixin() + repositoryHooks := schema.Repository{}.Hooks() + repository.Hooks[0] = repositoryHooks[0] + repositoryMixinFields0 := repositoryMixin[0].Fields() + _ = repositoryMixinFields0 + repositoryFields := schema.Repository{}.Fields() + _ = repositoryFields + // repositoryDescCreatedAt is the schema descriptor for created_at field. + repositoryDescCreatedAt := repositoryMixinFields0[0].Descriptor() + // repository.DefaultCreatedAt holds the default value on creation for the created_at field. + repository.DefaultCreatedAt = repositoryDescCreatedAt.Default.(func() time.Time) + // repositoryDescLastModifiedAt is the schema descriptor for last_modified_at field. + repositoryDescLastModifiedAt := repositoryMixinFields0[1].Descriptor() + // repository.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + repository.DefaultLastModifiedAt = repositoryDescLastModifiedAt.Default.(func() time.Time) + // repository.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + repository.UpdateDefaultLastModifiedAt = repositoryDescLastModifiedAt.UpdateDefault.(func() time.Time) + // repositoryDescURL is the schema descriptor for url field. + repositoryDescURL := repositoryFields[0].Descriptor() + // repository.URLValidator is a validator for the "url" field. It is called by the builders before save. + repository.URLValidator = repositoryDescURL.Validators[0].(func(string) error) tagFields := schema.Tag{}.Fields() _ = tagFields // tagDescName is the schema descriptor for name field. diff --git a/tavern/internal/ent/schema/repository.go b/tavern/internal/ent/schema/repository.go new file mode 100644 index 000000000..b60501922 --- /dev/null +++ b/tavern/internal/ent/schema/repository.go @@ -0,0 +1,124 @@ +package schema + +import ( + "context" + "crypto/ed25519" + "crypto/rand" + "fmt" + "strings" + + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "golang.org/x/crypto/ssh" + "realm.pub/tavern/internal/ent/hook" +) + +// Repository holds the schema definition for the entity. +type Repository struct { + ent.Schema +} + +// Fields of the ent. +func (Repository) Fields() []ent.Field { + return []ent.Field{ + field.String("url"). + NotEmpty(). + Unique(). + Comment("URL of the repository"), + field.String("public_key"). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput | entgql.SkipMutationUpdateInput), + ). + Comment("Public key associated with this repositories private key"), + field.String("private_key"). + Sensitive(). + Annotations( + entgql.Skip(entgql.SkipAll), + ). + Comment("Private key used for authentication."), + } +} + +// Edges of the ent. +func (Repository) Edges() []ent.Edge { + return []ent.Edge{} +} + +// Annotations describes additional information for the ent. +func (Repository) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.Mutations(entgql.MutationCreate()), + entgql.RelayConnection(), + entgql.MultiOrder(), + } +} + +// Mixin defines common shared properties for the ent. +func (Repository) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // createdAt, lastModifiedAt + } +} + +// Hooks defines middleware for mutations for the ent. +func (Repository) Hooks() []ent.Hook { + return []ent.Hook{ + hook.On(HookCreateRepoPrivateKey(), ent.OpCreate), + } +} + +// HookCreateRepoPrivateKey will update tome info (e.g. hash) whenever it is mutated. +func HookCreateRepoPrivateKey() ent.Hook { + // Get the relevant methods from the Mutation + // See this example: https://github.com/ent/ent/blob/master/entc/integration/hooks/ent/schema/user.go#L98 + type tMutation interface { + URL() (string, bool) + SetURL(string) + PrivateKey() (string, bool) + SetPrivateKey(s string) + SetPublicKey(s string) + } + + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Get the mutation + mut, ok := m.(tMutation) + if !ok { + return nil, fmt.Errorf("expected repository mutation in schema hook, got: %+v", m) + } + + // Prepend https schema if no schema specified + if u, ok := mut.URL(); ok && (!strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "ssh://")) { + mut.SetURL(fmt.Sprintf("https://%s", u)) + } + + // Skip if key already set + if key, ok := mut.PrivateKey(); ok && key != "" { + return next.Mutate(ctx, m) + } + + // Generate new key + _, privKey, err := ed25519.GenerateKey(rand.Reader) + if err != nil { + return nil, fmt.Errorf("failed to generate ed25519 private key: %w", err) + } + + // Marshal Keys + signer, err := ssh.NewSignerFromKey(privKey) + if err != nil { + return nil, fmt.Errorf("could not convert private key to ssh signer: %v", err) + } + block, err := ssh.MarshalPrivateKey(privKey, "") + if err != nil || block == nil { + return nil, fmt.Errorf("failed to marshal ssh private key: %w", err) + } + + mut.SetPrivateKey(string(block.Bytes)) + mut.SetPublicKey(string(ssh.MarshalAuthorizedKey(signer.PublicKey()))) + + return next.Mutate(ctx, m) + }) + } +} diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index cfb11d6a3..6f99c25d9 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -26,6 +26,8 @@ type Tx struct { HostProcess *HostProcessClient // Quest is the client for interacting with the Quest builders. Quest *QuestClient + // Repository is the client for interacting with the Repository builders. + Repository *RepositoryClient // Tag is the client for interacting with the Tag builders. Tag *TagClient // Task is the client for interacting with the Task builders. @@ -172,6 +174,7 @@ func (tx *Tx) init() { tx.HostFile = NewHostFileClient(tx.config) tx.HostProcess = NewHostProcessClient(tx.config) tx.Quest = NewQuestClient(tx.config) + tx.Repository = NewRepositoryClient(tx.config) tx.Tag = NewTagClient(tx.config) tx.Task = NewTaskClient(tx.config) tx.Tome = NewTomeClient(tx.config) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index a68ffd76e..ed51f3ea7 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -30,13 +30,13 @@ type QueryResolver interface { Files(ctx context.Context, where *ent.FileWhereInput) ([]*ent.File, error) Quests(ctx context.Context, where *ent.QuestWhereInput) ([]*ent.Quest, error) Tasks(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.TaskOrder, where *ent.TaskWhereInput) (*ent.TaskConnection, error) + Repositories(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.RepositoryOrder, where *ent.RepositoryWhereInput) (*ent.RepositoryConnection, error) Beacons(ctx context.Context, where *ent.BeaconWhereInput) ([]*ent.Beacon, error) Hosts(ctx context.Context, where *ent.HostWhereInput) ([]*ent.Host, error) Tags(ctx context.Context, where *ent.TagWhereInput) ([]*ent.Tag, error) Tomes(ctx context.Context, where *ent.TomeWhereInput) ([]*ent.Tome, error) Users(ctx context.Context, where *ent.UserWhereInput) ([]*ent.User, error) Me(ctx context.Context) (*ent.User, error) - GitPublicKey(ctx context.Context) (string, error) } // endregion ************************** generated!.gotpl ************************** @@ -148,6 +148,66 @@ func (ec *executionContext) field_Query_quests_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_repositories_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *entgql.Cursor[int] + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg1 + var arg2 *entgql.Cursor[int] + if tmp, ok := rawArgs["before"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["before"] = arg2 + var arg3 *int + if tmp, ok := rawArgs["last"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["last"] = arg3 + var arg4 []*ent.RepositoryOrder + if tmp, ok := rawArgs["orderBy"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + arg4, err = ec.unmarshalORepositoryOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["orderBy"] = arg4 + var arg5 *ent.RepositoryWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg5, err = ec.unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Query_tags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3933,6 +3993,93 @@ func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field return fc, nil } +func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_repositories(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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().Repositories(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.RepositoryOrder), fc.Args["where"].(*ent.RepositoryWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*ent.RepositoryConnection); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.RepositoryConnection`, 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.(*ent.RepositoryConnection) + fc.Result = res + return ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_repositories(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 "edges": + return ec.fieldContext_RepositoryConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", 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_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_beacons(ctx, field) if err != nil { @@ -4488,74 +4635,6 @@ func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field gra return fc, nil } -func (ec *executionContext) _Query_gitPublicKey(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_gitPublicKey(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - 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().GitPublicKey(rctx) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - 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 { - 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_Query_gitPublicKey(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") - }, - } - 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 { @@ -5155,8 +5234,8 @@ func (ec *executionContext) fieldContext_Quest_creator(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_id(ctx, field) +func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_id(ctx, field) if err != nil { return graphql.Null } @@ -5186,9 +5265,9 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected return ec.marshalNID2int(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_Repository_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, @@ -5199,8 +5278,8 @@ func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graph return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_name(ctx, field) +func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -5213,7 +5292,7 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -5225,26 +5304,26 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(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_Repository_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_kind(ctx, field) +func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -5257,7 +5336,7 @@ func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind, nil + return obj.LastModifiedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -5269,26 +5348,26 @@ func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(tag.Kind) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagKind does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_hosts(ctx, field) +func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_url(ctx, field) if err != nil { return graphql.Null } @@ -5301,63 +5380,38 @@ func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Hosts(ctx) + return obj.URL, 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.([]*ent.Host) + res := resTmp.(string) fc.Result = res - return ec.marshalOHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_url(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "files": - return ec.fieldContext_Host_files(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - case "credentials": - return ec.fieldContext_Host_credentials(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_id(ctx, field) +func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_publicKey(ctx, field) if err != nil { return graphql.Null } @@ -5370,7 +5424,7 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.PublicKey, nil }) if err != nil { ec.Error(ctx, err) @@ -5382,26 +5436,26 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_publicKey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_createdAt(ctx, field) +func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RepositoryConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -5414,38 +5468,41 @@ func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Edges, 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.(time.Time) + res := resTmp.([]*ent.RepositoryEdge) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_RepositoryEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_RepositoryEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_lastModifiedAt(ctx, field) +func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -5458,7 +5515,7 @@ func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.LastModifiedAt, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -5470,26 +5527,36 @@ func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(entgql.PageInfo[int]) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_claimedAt(ctx, field) +func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RepositoryConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -5502,35 +5569,38 @@ func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ClaimedAt, nil + return obj.TotalCount, 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.(time.Time) + res := resTmp.(int) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_claimedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_execStartedAt(ctx, field) +func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RepositoryEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -5543,7 +5613,7 @@ func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ExecStartedAt, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -5552,26 +5622,38 @@ func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.Repository) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_execStartedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "RepositoryEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_execFinishedAt(ctx, field) +func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RepositoryEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -5584,35 +5666,38 @@ func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ExecFinishedAt, nil + return obj.Cursor, 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.(time.Time) + res := resTmp.(entgql.Cursor[int]) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_execFinishedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "RepositoryEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_output(ctx, field) +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_id(ctx, field) if err != nil { return graphql.Null } @@ -5625,35 +5710,38 @@ func (ec *executionContext) _Task_output(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Output, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_output(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_outputSize(ctx, field) +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_name(ctx, field) if err != nil { return graphql.Null } @@ -5666,7 +5754,7 @@ func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OutputSize, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -5678,26 +5766,26 @@ func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_outputSize(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + 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 Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_error(ctx, field) +func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_kind(ctx, field) if err != nil { return graphql.Null } @@ -5710,35 +5798,38 @@ func (ec *executionContext) _Task_error(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Error, nil + 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) + res := resTmp.(tag.Kind) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type TagKind does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_quest(ctx, field) +func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_hosts(ctx, field) if err != nil { return graphql.Null } @@ -5751,58 +5842,63 @@ func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Quest(ctx) + return obj.Hosts(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.Quest) + res := resTmp.([]*ent.Host) fc.Result = res - return ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest(ctx, field.Selections, res) + return ec.marshalOHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_quest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Quest_id(ctx, field) + return ec.fieldContext_Host_id(ctx, field) case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) + return ec.fieldContext_Host_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + case "credentials": + return ec.fieldContext_Host_credentials(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_beacon(ctx, field) +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_id(ctx, field) if err != nil { return graphql.Null } @@ -5815,7 +5911,7 @@ func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Beacon(ctx) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -5827,50 +5923,26 @@ func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*ent.Beacon) + res := resTmp.(int) fc.Result = res - return ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_beacon(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_reportedFiles(ctx, field) +func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -5883,59 +5955,38 @@ func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ReportedFiles(ctx) + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - return graphql.Null + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } - res := resTmp.([]*ent.HostFile) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOHostFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_HostFile_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostFile_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_HostFile_path(ctx, field) - case "owner": - return ec.fieldContext_HostFile_owner(ctx, field) - case "group": - return ec.fieldContext_HostFile_group(ctx, field) - case "permissions": - return ec.fieldContext_HostFile_permissions(ctx, field) - case "size": - return ec.fieldContext_HostFile_size(ctx, field) - case "hash": - return ec.fieldContext_HostFile_hash(ctx, field) - case "host": - return ec.fieldContext_HostFile_host(ctx, field) - case "task": - return ec.fieldContext_HostFile_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_reportedProcesses(ctx, field) +func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -5948,65 +5999,38 @@ func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ReportedProcesses(ctx) + return obj.LastModifiedAt, 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.([]*ent.HostProcess) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOHostProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessᚄ(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_HostProcess_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostProcess_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) - case "pid": - return ec.fieldContext_HostProcess_pid(ctx, field) - case "ppid": - return ec.fieldContext_HostProcess_ppid(ctx, field) - case "name": - return ec.fieldContext_HostProcess_name(ctx, field) - case "principal": - return ec.fieldContext_HostProcess_principal(ctx, field) - case "path": - return ec.fieldContext_HostProcess_path(ctx, field) - case "cmd": - return ec.fieldContext_HostProcess_cmd(ctx, field) - case "env": - return ec.fieldContext_HostProcess_env(ctx, field) - case "cwd": - return ec.fieldContext_HostProcess_cwd(ctx, field) - case "status": - return ec.fieldContext_HostProcess_status(ctx, field) - case "host": - return ec.fieldContext_HostProcess_host(ctx, field) - case "task": - return ec.fieldContext_HostProcess_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_reportedCredentials(ctx, field) +func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_claimedAt(ctx, field) if err != nil { return graphql.Null } @@ -6019,7 +6043,7 @@ func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ReportedCredentials(ctx) + return obj.ClaimedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -6028,44 +6052,26 @@ func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.HostCredential) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOHostCredential2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialᚄ(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_claimedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_HostCredential_id(ctx, field) - case "createdAt": - return ec.fieldContext_HostCredential_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) - case "principal": - return ec.fieldContext_HostCredential_principal(ctx, field) - case "secret": - return ec.fieldContext_HostCredential_secret(ctx, field) - case "kind": - return ec.fieldContext_HostCredential_kind(ctx, field) - case "host": - return ec.fieldContext_HostCredential_host(ctx, field) - case "task": - return ec.fieldContext_HostCredential_task(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) +func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_execStartedAt(ctx, field) if err != nil { return graphql.Null } @@ -6078,7 +6084,7 @@ func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.ExecStartedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -6087,32 +6093,26 @@ func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.TaskEdge) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execStartedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) +func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_execFinishedAt(ctx, field) if err != nil { return graphql.Null } @@ -6125,48 +6125,35 @@ func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.ExecFinishedAt, 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.(entgql.PageInfo[int]) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execFinishedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) +func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_output(ctx, field) if err != nil { return graphql.Null } @@ -6179,38 +6166,35 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.Output, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_output(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_node(ctx, field) +func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_outputSize(ctx, field) if err != nil { return graphql.Null } @@ -6223,65 +6207,38 @@ func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.OutputSize, 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.(*ent.Task) + res := resTmp.(int) fc.Result = res - return ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_outputSize(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "Task", 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_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_error(ctx, field) if err != nil { return graphql.Null } @@ -6294,38 +6251,35 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.Error, 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.(entgql.Cursor[int]) + res := resTmp.(string) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_id(ctx, field) +func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_quest(ctx, field) if err != nil { return graphql.Null } @@ -6338,7 +6292,7 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Quest(ctx) }) if err != nil { ec.Error(ctx, err) @@ -6350,26 +6304,46 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*ent.Quest) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_quest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_createdAt(ctx, field) +func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_beacon(ctx, field) if err != nil { return graphql.Null } @@ -6382,7 +6356,7 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Beacon(ctx) }) if err != nil { ec.Error(ctx, err) @@ -6394,26 +6368,50 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.Beacon) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_beacon(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_lastModifiedAt(ctx, field) +func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_reportedFiles(ctx, field) if err != nil { return graphql.Null } @@ -6426,38 +6424,59 @@ func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.LastModifiedAt, nil + return obj.ReportedFiles(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.([]*ent.HostFile) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOHostFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostFile_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostFile_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_HostFile_path(ctx, field) + case "owner": + return ec.fieldContext_HostFile_owner(ctx, field) + case "group": + return ec.fieldContext_HostFile_group(ctx, field) + case "permissions": + return ec.fieldContext_HostFile_permissions(ctx, field) + case "size": + return ec.fieldContext_HostFile_size(ctx, field) + case "hash": + return ec.fieldContext_HostFile_hash(ctx, field) + case "host": + return ec.fieldContext_HostFile_host(ctx, field) + case "task": + return ec.fieldContext_HostFile_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_name(ctx, field) +func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_reportedProcesses(ctx, field) if err != nil { return graphql.Null } @@ -6470,38 +6489,65 @@ func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ReportedProcesses(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.HostProcess) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOHostProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) + case "name": + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_description(ctx, field) +func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_reportedCredentials(ctx, field) if err != nil { return graphql.Null } @@ -6514,38 +6560,53 @@ func (ec *executionContext) _Tome_description(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.ReportedCredentials(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.HostCredential) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOHostCredential2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostCredential_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostCredential_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostCredential_lastModifiedAt(ctx, field) + case "principal": + return ec.fieldContext_HostCredential_principal(ctx, field) + case "secret": + return ec.fieldContext_HostCredential_secret(ctx, field) + case "kind": + return ec.fieldContext_HostCredential_kind(ctx, field) + case "host": + return ec.fieldContext_HostCredential_host(ctx, field) + case "task": + return ec.fieldContext_HostCredential_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostCredential", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_author(ctx, field) +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -6558,38 +6619,41 @@ func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Author, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.TaskEdge) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_author(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskConnection", 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") + switch field.Name { + case "node": + return ec.fieldContext_TaskEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TaskEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_supportModel(ctx, field) +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -6602,7 +6666,7 @@ func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SupportModel, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -6614,26 +6678,36 @@ func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(tome.SupportModel) + res := resTmp.(entgql.PageInfo[int]) fc.Result = res - return ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_supportModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeSupportModel does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_tactic(ctx, field) +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -6646,7 +6720,7 @@ func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Tactic, nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -6658,26 +6732,26 @@ func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(tome.Tactic) + res := resTmp.(int) fc.Result = res - return ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_tactic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeTactic does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_paramDefs(ctx, field) +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -6690,7 +6764,7 @@ func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ParamDefs, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -6699,26 +6773,56 @@ func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Task) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_paramDefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskEdge", 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") + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_eldritch(ctx, field) +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -6731,7 +6835,7 @@ func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Eldritch, nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -6743,26 +6847,26 @@ func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(entgql.Cursor[int]) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_eldritch(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_files(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_files(ctx, field) +func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_id(ctx, field) if err != nil { return graphql.Null } @@ -6775,51 +6879,38 @@ func (ec *executionContext) _Tome_files(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Files(ctx) + 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.([]*ent.File) + res := resTmp.(int) fc.Result = res - return ec.marshalOFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_File_id(ctx, field) - case "createdAt": - return ec.fieldContext_File_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_File_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_File_name(ctx, field) - case "size": - return ec.fieldContext_File_size(ctx, field) - case "hash": - return ec.fieldContext_File_hash(ctx, field) - case "tomes": - return ec.fieldContext_File_tomes(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_uploader(ctx, field) +func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -6832,49 +6923,38 @@ func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Uploader(ctx) + 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.(*ent.User) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_uploader(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -6887,7 +6967,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.LastModifiedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -6899,26 +6979,26 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(int) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(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_Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_name(ctx, field) +func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_name(ctx, field) if err != nil { return graphql.Null } @@ -6948,9 +7028,9 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, @@ -6961,8 +7041,8 @@ func (ec *executionContext) fieldContext_User_name(ctx context.Context, field gr return fc, nil } -func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_photoURL(ctx, field) +func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_description(ctx, field) if err != nil { return graphql.Null } @@ -6975,7 +7055,7 @@ func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PhotoURL, nil + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) @@ -6992,9 +7072,9 @@ func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_photoURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, @@ -7005,8 +7085,8 @@ func (ec *executionContext) fieldContext_User_photoURL(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_isActivated(ctx, field) +func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_author(ctx, field) if err != nil { return graphql.Null } @@ -7019,7 +7099,7 @@ func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsActivated, nil + return obj.Author, nil }) if err != nil { ec.Error(ctx, err) @@ -7031,26 +7111,26 @@ func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_isActivated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_author(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_isAdmin(ctx, field) +func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_supportModel(ctx, field) if err != nil { return graphql.Null } @@ -7063,7 +7143,7 @@ func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsAdmin, nil + return obj.SupportModel, nil }) if err != nil { ec.Error(ctx, err) @@ -7075,26 +7155,26 @@ func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(tome.SupportModel) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_isAdmin(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_supportModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type TomeSupportModel does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_tomes(ctx, field) +func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_tactic(ctx, field) if err != nil { return graphql.Null } @@ -7107,39 +7187,500 @@ func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Tomes(ctx) + return obj.Tactic, 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.([]*ent.Tome) + res := resTmp.(tome.Tactic) fc.Result = res - return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) + return ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_tactic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": + return nil, errors.New("field of type TomeTactic does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_paramDefs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.ParamDefs, 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.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_paramDefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + 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) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_eldritch(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Eldritch, 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_Tome_eldritch(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + 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) _Tome_files(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_files(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Files(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.File) + fc.Result = res + return ec.marshalOFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "createdAt": + return ec.fieldContext_File_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_File_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "size": + return ec.fieldContext_File_size(ctx, field) + case "hash": + return ec.fieldContext_File_hash(ctx, field) + case "tomes": + return ec.fieldContext_File_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_uploader(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Uploader(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.User) + fc.Result = res + return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_uploader(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.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.(int) + fc.Result = res + return ec.marshalNID2int(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 ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_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_User_name(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_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_photoURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.PhotoURL, 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_photoURL(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_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_isActivated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.IsActivated, 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_User_isActivated(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 Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_isAdmin(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.IsAdmin, 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_User_isAdmin(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 Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_tomes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Tomes(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Tome) + fc.Result = res + return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": return ec.fieldContext_Tome_author(ctx, field) case "supportModel": return ec.fieldContext_Tome_supportModel(ctx, field) @@ -7154,18 +7695,1258 @@ func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field g case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) - }, - } - return fc, nil -} + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj interface{}) (ent.BeaconOrder, error) { + var it ent.BeaconOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj interface{}) (ent.BeaconWhereInput, error) { + var it ent.BeaconWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + 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 "nameNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "principal": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Principal = data + case "principalNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNEQ = data + case "principalIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIn = data + case "principalNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotIn = data + case "principalGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGT = data + case "principalGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGTE = data + case "principalLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLT = data + case "principalLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLTE = data + case "principalContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalContains = data + case "principalHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasPrefix = data + case "principalHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasSuffix = data + case "principalIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIsNil = data + case "principalNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotNil = data + case "principalEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalEqualFold = data + case "principalContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalContainsFold = data + case "identifier": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Identifier = data + case "identifierNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNEQ = data + case "identifierIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierIn = data + case "identifierNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNotIn = data + case "identifierGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGT = data + case "identifierGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGTE = data + case "identifierLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLT = data + case "identifierLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLTE = data + case "identifierContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContains = data + case "identifierHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasSuffix = data + case "identifierEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierEqualFold = data + case "identifierContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContainsFold = data + case "agentIdentifier": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifier = data + case "agentIdentifierNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNEQ = data + case "agentIdentifierIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierIn = data + case "agentIdentifierNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNotIn = data + case "agentIdentifierGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierGT = data + case "agentIdentifierGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierGTE = data + case "agentIdentifierLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierLT = data + case "agentIdentifierLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierLTE = data + case "agentIdentifierContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierContains = data + case "agentIdentifierHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierHasPrefix = data + case "agentIdentifierHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierHasSuffix = data + case "agentIdentifierIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierIsNil = data + case "agentIdentifierNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNotNil = data + case "agentIdentifierEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierEqualFold = data + case "agentIdentifierContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierContainsFold = data + case "lastSeenAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAt = data + case "lastSeenAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNEQ = data + case "lastSeenAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIn = data + case "lastSeenAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotIn = data + case "lastSeenAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGT = data + case "lastSeenAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGTE = data + case "lastSeenAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLT = data + case "lastSeenAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotNil = data + case "interval": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.Interval = data + case "intervalNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalNEQ = data + case "intervalIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalIn = data + case "intervalNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotIn = data + case "intervalGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalGT = data + case "intervalGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalGTE = data + case "intervalLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalLT = data + case "intervalLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalLTE = data + case "intervalIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalIsNil = data + case "intervalNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotNil = data + case "hasHost": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasHost = data + case "hasHostWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasHostWith = data + case "hasTasks": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTasks = data + case "hasTasksWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTasksWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateQuestInput(ctx context.Context, obj interface{}) (ent.CreateQuestInput, error) { + var it ent.CreateQuestInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "parameters", "tomeID"} + 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 "parameters": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Parameters = data + case "tomeID": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) + data, err := ec.unmarshalNID2int(ctx, v) + if err != nil { + return it, err + } + it.TomeID = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateRepositoryInput(ctx context.Context, obj interface{}) (ent.CreateRepositoryInput, error) { + var it ent.CreateRepositoryInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"url"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "url": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.URL = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateTagInput(ctx context.Context, obj interface{}) (ent.CreateTagInput, error) { + var it ent.CreateTagInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "kind", "hostIDs"} + 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 "kind": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) + data, err := ec.unmarshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, v) + if err != nil { + return it, err + } + it.Kind = data + case "hostIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.HostIDs = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateTomeInput(ctx context.Context, obj interface{}) (ent.CreateTomeInput, error) { + var it ent.CreateTomeInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "description", "author", "supportModel", "tactic", "paramDefs", "eldritch", "fileIDs"} + 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 "description": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Description = data + case "author": + var err error -// endregion **************************** field.gotpl ***************************** + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("author")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Author = data + case "supportModel": + var err error -// region **************************** input.gotpl ***************************** + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportModel")) + data, err := ec.unmarshalOTomeSupportModel2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, v) + if err != nil { + return it, err + } + it.SupportModel = data + case "tactic": + var err error -func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj interface{}) (ent.BeaconOrder, error) { - var it ent.BeaconOrder + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tactic")) + data, err := ec.unmarshalOTomeTactic2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, v) + if err != nil { + return it, err + } + it.Tactic = data + case "paramDefs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefs = data + case "eldritch": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Eldritch = data + case "fileIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.FileIDs = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj interface{}) (ent.FileOrder, error) { + var it ent.FileOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -7195,7 +8976,7 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + data, err := ec.unmarshalNFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileOrderField(ctx, v) if err != nil { return it, err } @@ -7206,14 +8987,14 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj i return it, nil } -func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj interface{}) (ent.BeaconWhereInput, error) { - var it ent.BeaconWhereInput +func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, obj interface{}) (ent.FileWhereInput, error) { + var it ent.FileWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -7224,7 +9005,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + data, err := ec.unmarshalOFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInput(ctx, v) if err != nil { return it, err } @@ -7233,7 +9014,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -7242,7 +9023,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -7580,803 +9361,832 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, return it, err } it.NameContainsFold = data - case "principal": + case "size": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": + it.Size = data + case "sizeNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": + it.SizeNEQ = data + case "sizeIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": + it.SizeIn = data + case "sizeNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": + it.SizeNotIn = data + case "sizeGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": + it.SizeGT = data + case "sizeGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": + it.SizeGTE = data + case "sizeLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLT = data + case "sizeLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLTE = data + case "hash": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": + it.Hash = data + case "hashNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": + it.HashNEQ = data + case "hashIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashIn = data + case "hashNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashNotIn = data + case "hashGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": + it.HashGT = data + case "hashGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": + it.HashGTE = data + case "hashLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalIsNil": + it.HashLT = data + case "hashLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalIsNil = data - case "principalNotNil": + it.HashLTE = data + case "hashContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNotNil = data - case "principalEqualFold": + it.HashContains = data + case "hashHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": + it.HashHasPrefix = data + case "hashHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "identifier": + it.HashHasSuffix = data + case "hashEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Identifier = data - case "identifierNEQ": + it.HashEqualFold = data + case "hashContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierNEQ = data - case "identifierIn": + it.HashContainsFold = data + case "hasTomes": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierIn = data - case "identifierNotIn": + it.HasTomesWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputHostCredentialOrder(ctx context.Context, obj interface{}) (ent.HostCredentialOrder, error) { + var it ent.HostCredentialOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - it.IdentifierNotIn = data - case "identifierGT": + it.Direction = data + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNHostCredentialOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialOrderField(ctx, v) if err != nil { return it, err } - it.IdentifierGT = data - case "identifierGTE": + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputHostCredentialWhereInput(ctx context.Context, obj interface{}) (ent.HostCredentialWhereInput, error) { + var it ent.HostCredentialWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "secret", "secretNEQ", "secretIn", "secretNotIn", "secretGT", "secretGTE", "secretLT", "secretLTE", "secretContains", "secretHasPrefix", "secretHasSuffix", "secretEqualFold", "secretContainsFold", "kind", "kindNEQ", "kindIn", "kindNotIn", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOHostCredentialWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInput(ctx, v) if err != nil { return it, err } - it.IdentifierGTE = data - case "identifierLT": + it.Not = data + case "and": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierLT = data - case "identifierLTE": + it.And = data + case "or": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierLTE = data - case "identifierContains": + it.Or = data + case "id": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.IdentifierContains = data - case "identifierHasPrefix": + it.ID = data + case "idNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": + it.IDNEQ = data + case "idIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierHasSuffix = data - case "identifierEqualFold": + it.IDIn = data + case "idNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierEqualFold = data - case "identifierContainsFold": + it.IDNotIn = data + case "idGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data - case "agentIdentifier": + it.IDGT = data + case "idGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifier = data - case "agentIdentifierNEQ": + it.IDGTE = data + case "idLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNEQ = data - case "agentIdentifierIn": + it.IDLT = data + case "idLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIn = data - case "agentIdentifierNotIn": + it.IDLTE = data + case "createdAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotIn = data - case "agentIdentifierGT": + it.CreatedAt = data + case "createdAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGT = data - case "agentIdentifierGTE": + it.CreatedAtNEQ = data + case "createdAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGTE = data - case "agentIdentifierLT": + it.CreatedAtIn = data + case "createdAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLT = data - case "agentIdentifierLTE": + it.CreatedAtNotIn = data + case "createdAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLTE = data - case "agentIdentifierContains": + it.CreatedAtGT = data + case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": + it.CreatedAtGTE = data + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": + it.CreatedAtLT = data + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": + it.CreatedAtLTE = data + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": + it.LastModifiedAt = data + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContainsFold = data - case "lastSeenAt": + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": + it.LastModifiedAtLTE = data + case "principal": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": + it.Principal = data + case "principalNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": + it.PrincipalNEQ = data + case "principalIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": + it.PrincipalIn = data + case "principalNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": + it.PrincipalNotIn = data + case "principalGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": + it.PrincipalGT = data + case "principalGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "interval": + it.PrincipalGTE = data + case "principalLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Interval = data - case "intervalNEQ": + it.PrincipalLT = data + case "principalLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNEQ = data - case "intervalIn": + it.PrincipalLTE = data + case "principalContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalIn = data - case "intervalNotIn": + it.PrincipalContains = data + case "principalHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotIn = data - case "intervalGT": + it.PrincipalHasPrefix = data + case "principalHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGT = data - case "intervalGTE": + it.PrincipalHasSuffix = data + case "principalEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGTE = data - case "intervalLT": + it.PrincipalEqualFold = data + case "principalContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLT = data - case "intervalLTE": + it.PrincipalContainsFold = data + case "secret": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLTE = data - case "intervalIsNil": + it.Secret = data + case "secretNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalIsNil = data - case "intervalNotNil": + it.SecretNEQ = data + case "secretIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalNotNil = data - case "hasHost": + it.SecretIn = data + case "secretNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": + it.SecretNotIn = data + case "secretGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTasks": + it.SecretGT = data + case "secretGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasks = data - case "hasTasksWith": + it.SecretGTE = data + case "secretLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasksWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateQuestInput(ctx context.Context, obj interface{}) (ent.CreateQuestInput, error) { - var it ent.CreateQuestInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "parameters", "tomeID"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.SecretLT = data + case "secretLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "parameters": + it.SecretLTE = data + case "secretContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Parameters = data - case "tomeID": + it.SecretContains = data + case "secretHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) - data, err := ec.unmarshalNID2int(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TomeID = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateTagInput(ctx context.Context, obj interface{}) (ent.CreateTagInput, error) { - var it ent.CreateTagInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "kind", "hostIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.SecretHasPrefix = data + case "secretHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "kind": + it.SecretHasSuffix = data + case "secretEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - data, err := ec.unmarshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Kind = data - case "hostIDs": + it.SecretEqualFold = data + case "secretContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIDs")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HostIDs = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateTomeInput(ctx context.Context, obj interface{}) (ent.CreateTomeInput, error) { - var it ent.CreateTomeInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "description", "author", "supportModel", "tactic", "paramDefs", "eldritch", "fileIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.SecretContainsFold = data + case "kind": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) + data, err := ec.unmarshalOHostCredentialKind2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind(ctx, v) if err != nil { return it, err } - it.Name = data - case "description": + it.Kind = data + case "kindNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindNEQ")) + data, err := ec.unmarshalOHostCredentialKind2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind(ctx, v) if err != nil { return it, err } - it.Description = data - case "author": + it.KindNEQ = data + case "kindIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("author")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindIn")) + data, err := ec.unmarshalOHostCredentialKind2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kindᚄ(ctx, v) if err != nil { return it, err } - it.Author = data - case "supportModel": + it.KindIn = data + case "kindNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportModel")) - data, err := ec.unmarshalOTomeSupportModel2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindNotIn")) + data, err := ec.unmarshalOHostCredentialKind2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kindᚄ(ctx, v) if err != nil { return it, err } - it.SupportModel = data - case "tactic": + it.KindNotIn = data + case "hasHost": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tactic")) - data, err := ec.unmarshalOTomeTactic2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Tactic = data - case "paramDefs": + it.HasHost = data + case "hasHostWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.ParamDefs = data - case "eldritch": + it.HasHostWith = data + case "hasTask": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Eldritch = data - case "fileIDs": + it.HasTask = data + case "hasTaskWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.FileIDs = data + it.HasTaskWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj interface{}) (ent.FileOrder, error) { - var it ent.FileOrder +func (ec *executionContext) unmarshalInputHostFileOrder(ctx context.Context, obj interface{}) (ent.HostFileOrder, error) { + var it ent.HostFileOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -8406,7 +10216,7 @@ func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj int var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileOrderField(ctx, v) + data, err := ec.unmarshalNHostFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileOrderField(ctx, v) if err != nil { return it, err } @@ -8417,14 +10227,14 @@ func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj int return it, nil } -func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, obj interface{}) (ent.FileWhereInput, error) { - var it ent.FileWhereInput +func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context, obj interface{}) (ent.HostFileWhereInput, error) { + var it ent.HostFileWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "owner", "ownerNEQ", "ownerIn", "ownerNotIn", "ownerGT", "ownerGTE", "ownerLT", "ownerLTE", "ownerContains", "ownerHasPrefix", "ownerHasSuffix", "ownerIsNil", "ownerNotNil", "ownerEqualFold", "ownerContainsFold", "group", "groupNEQ", "groupIn", "groupNotIn", "groupGT", "groupGTE", "groupLT", "groupLTE", "groupContains", "groupHasPrefix", "groupHasSuffix", "groupIsNil", "groupNotNil", "groupEqualFold", "groupContainsFold", "permissions", "permissionsNEQ", "permissionsIn", "permissionsNotIn", "permissionsGT", "permissionsGTE", "permissionsLT", "permissionsLTE", "permissionsContains", "permissionsHasPrefix", "permissionsHasSuffix", "permissionsIsNil", "permissionsNotNil", "permissionsEqualFold", "permissionsContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashIsNil", "hashNotNil", "hashEqualFold", "hashContainsFold", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8435,7 +10245,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInput(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx, v) if err != nil { return it, err } @@ -8444,7 +10254,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -8453,7 +10263,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -8578,1001 +10388,831 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtGTE = data - case "createdAtLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtLT = data - case "createdAtLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtLTE = data - case "lastModifiedAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLTE = data - 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 "nameNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": + it.CreatedAtGTE = data + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.CreatedAtLT = data + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.CreatedAtLTE = data + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.LastModifiedAt = data + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "size": + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Size = data - case "sizeNEQ": + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeNEQ = data - case "sizeIn": + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeIn = data - case "sizeNotIn": + it.LastModifiedAtLTE = data + case "path": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeNotIn = data - case "sizeGT": + it.Path = data + case "pathNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeGT = data - case "sizeGTE": + it.PathNEQ = data + case "pathIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SizeGTE = data - case "sizeLT": + it.PathIn = data + case "pathNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SizeLT = data - case "sizeLTE": + it.PathNotIn = data + case "pathGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeLTE = data - case "hash": + it.PathGT = data + case "pathGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Hash = data - case "hashNEQ": + it.PathGTE = data + case "pathLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashNEQ = data - case "hashIn": + it.PathLT = data + case "pathLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashIn = data - case "hashNotIn": + it.PathLTE = data + case "pathContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashNotIn = data - case "hashGT": + it.PathContains = data + case "pathHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGT = data - case "hashGTE": + it.PathHasPrefix = data + case "pathHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": + it.PathHasSuffix = data + case "pathEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": + it.PathEqualFold = data + case "pathContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": + it.PathContainsFold = data + case "owner": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": + it.Owner = data + case "ownerNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": + it.OwnerNEQ = data + case "ownerIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashEqualFold": + it.OwnerIn = data + case "ownerNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": + it.OwnerNotIn = data + case "ownerGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasTomes": + it.OwnerGT = data + case "ownerGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomes = data - case "hasTomesWith": + it.OwnerGTE = data + case "ownerLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostCredentialOrder(ctx context.Context, obj interface{}) (ent.HostCredentialOrder, error) { - var it ent.HostCredentialOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } + it.OwnerLT = data + case "ownerLTE": + var err error - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerLTE = data + case "ownerContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": + it.OwnerContains = data + case "ownerHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNHostCredentialOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostCredentialWhereInput(ctx context.Context, obj interface{}) (ent.HostCredentialWhereInput, error) { - var it ent.HostCredentialWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } + it.OwnerHasPrefix = data + case "ownerHasSuffix": + var err error - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "secret", "secretNEQ", "secretIn", "secretNotIn", "secretGT", "secretGTE", "secretLT", "secretLTE", "secretContains", "secretHasPrefix", "secretHasSuffix", "secretEqualFold", "secretContainsFold", "kind", "kindNEQ", "kindIn", "kindNotIn", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.OwnerHasSuffix = data + case "ownerIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOHostCredentialWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": + it.OwnerIsNil = data + case "ownerNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.And = data - case "or": + it.OwnerNotNil = data + case "ownerEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": + it.OwnerEqualFold = data + case "ownerContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": + it.OwnerContainsFold = data + case "group": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("group")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": + it.Group = data + case "groupNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": + it.GroupNEQ = data + case "groupIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": + it.GroupIn = data + case "groupNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": + it.GroupNotIn = data + case "groupGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": + it.GroupGT = data + case "groupGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": + it.GroupGTE = data + case "groupLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": + it.GroupLT = data + case "groupLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": + it.GroupLTE = data + case "groupContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": + it.GroupContains = data + case "groupHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": + it.GroupHasPrefix = data + case "groupHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": + it.GroupHasSuffix = data + case "groupIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAtGT = data - case "createdAtGTE": + it.GroupIsNil = data + case "groupNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAtGTE = data - case "createdAtLT": + it.GroupNotNil = data + case "groupEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtLT = data - case "createdAtLTE": + it.GroupEqualFold = data + case "groupContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtLTE = data - case "lastModifiedAt": + it.GroupContainsFold = data + case "permissions": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissions")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": + it.Permissions = data + case "permissionsNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": + it.PermissionsNEQ = data + case "permissionsIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": + it.PermissionsIn = data + case "permissionsNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": + it.PermissionsNotIn = data + case "permissionsGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": + it.PermissionsGT = data + case "permissionsGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": + it.PermissionsGTE = data + case "permissionsLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": + it.PermissionsLT = data + case "permissionsLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLTE = data - case "principal": + it.PermissionsLTE = data + case "permissionsContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": + it.PermissionsContains = data + case "permissionsHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": + it.PermissionsHasPrefix = data + case "permissionsHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": + it.PermissionsHasSuffix = data + case "permissionsIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": + it.PermissionsIsNil = data + case "permissionsNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": + it.PermissionsNotNil = data + case "permissionsEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": + it.PermissionsEqualFold = data + case "permissionsContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": + it.PermissionsContainsFold = data + case "size": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": + it.Size = data + case "sizeNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": + it.SizeNEQ = data + case "sizeIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": + it.SizeIn = data + case "sizeNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalEqualFold": + it.SizeNotIn = data + case "sizeGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": + it.SizeGT = data + case "sizeGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "secret": + it.SizeGTE = data + case "sizeLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.Secret = data - case "secretNEQ": + it.SizeLT = data + case "sizeLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.SecretNEQ = data - case "secretIn": + it.SizeLTE = data + case "hash": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretIn = data - case "secretNotIn": + it.Hash = data + case "hashNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretNotIn = data - case "secretGT": + it.HashNEQ = data + case "hashIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SecretGT = data - case "secretGTE": + it.HashIn = data + case "hashNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SecretGTE = data - case "secretLT": + it.HashNotIn = data + case "hashGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretLT = data - case "secretLTE": + it.HashGT = data + case "hashGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretLTE = data - case "secretContains": + it.HashGTE = data + case "hashLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretContains = data - case "secretHasPrefix": + it.HashLT = data + case "hashLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretHasPrefix = data - case "secretHasSuffix": + it.HashLTE = data + case "hashContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretHasSuffix = data - case "secretEqualFold": + it.HashContains = data + case "hashHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretEqualFold = data - case "secretContainsFold": + it.HashHasPrefix = data + case "hashHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SecretContainsFold = data - case "kind": + it.HashHasSuffix = data + case "hashIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - data, err := ec.unmarshalOHostCredentialKind2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.Kind = data - case "kindNEQ": + it.HashIsNil = data + case "hashNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindNEQ")) - data, err := ec.unmarshalOHostCredentialKind2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.KindNEQ = data - case "kindIn": + it.HashNotNil = data + case "hashEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindIn")) - data, err := ec.unmarshalOHostCredentialKind2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kindᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.KindIn = data - case "kindNotIn": + it.HashEqualFold = data + case "hashContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kindNotIn")) - data, err := ec.unmarshalOHostCredentialKind2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kindᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.KindNotIn = data + it.HashContainsFold = data case "hasHost": var err error @@ -9594,29 +11234,71 @@ func (ec *executionContext) unmarshalInputHostCredentialWhereInput(ctx context.C case "hasTask": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTask = data + case "hasTaskWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTaskWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputHostOrder(ctx context.Context, obj interface{}) (ent.HostOrder, error) { + var it ent.HostOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - it.HasTask = data - case "hasTaskWith": + it.Direction = data + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostOrderField(ctx, v) if err != nil { return it, err } - it.HasTaskWith = data + it.Field = data } } return it, nil } -func (ec *executionContext) unmarshalInputHostFileOrder(ctx context.Context, obj interface{}) (ent.HostFileOrder, error) { - var it ent.HostFileOrder +func (ec *executionContext) unmarshalInputHostProcessOrder(ctx context.Context, obj interface{}) (ent.HostProcessOrder, error) { + var it ent.HostProcessOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -9646,7 +11328,7 @@ func (ec *executionContext) unmarshalInputHostFileOrder(ctx context.Context, obj var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNHostFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileOrderField(ctx, v) + data, err := ec.unmarshalNHostProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessOrderField(ctx, v) if err != nil { return it, err } @@ -9657,14 +11339,14 @@ func (ec *executionContext) unmarshalInputHostFileOrder(ctx context.Context, obj return it, nil } -func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context, obj interface{}) (ent.HostFileWhereInput, error) { - var it ent.HostFileWhereInput +func (ec *executionContext) unmarshalInputHostProcessWhereInput(ctx context.Context, obj interface{}) (ent.HostProcessWhereInput, error) { + var it ent.HostProcessWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "owner", "ownerNEQ", "ownerIn", "ownerNotIn", "ownerGT", "ownerGTE", "ownerLT", "ownerLTE", "ownerContains", "ownerHasPrefix", "ownerHasSuffix", "ownerIsNil", "ownerNotNil", "ownerEqualFold", "ownerContainsFold", "group", "groupNEQ", "groupIn", "groupNotIn", "groupGT", "groupGTE", "groupLT", "groupLTE", "groupContains", "groupHasPrefix", "groupHasSuffix", "groupIsNil", "groupNotNil", "groupEqualFold", "groupContainsFold", "permissions", "permissionsNEQ", "permissionsIn", "permissionsNotIn", "permissionsGT", "permissionsGTE", "permissionsLT", "permissionsLTE", "permissionsContains", "permissionsHasPrefix", "permissionsHasSuffix", "permissionsIsNil", "permissionsNotNil", "permissionsEqualFold", "permissionsContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashIsNil", "hashNotNil", "hashEqualFold", "hashContainsFold", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "pid", "pidNEQ", "pidIn", "pidNotIn", "pidGT", "pidGTE", "pidLT", "pidLTE", "ppid", "ppidNEQ", "ppidIn", "ppidNotIn", "ppidGT", "ppidGTE", "ppidLT", "ppidLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathIsNil", "pathNotNil", "pathEqualFold", "pathContainsFold", "cmd", "cmdNEQ", "cmdIn", "cmdNotIn", "cmdGT", "cmdGTE", "cmdLT", "cmdLTE", "cmdContains", "cmdHasPrefix", "cmdHasSuffix", "cmdIsNil", "cmdNotNil", "cmdEqualFold", "cmdContainsFold", "env", "envNEQ", "envIn", "envNotIn", "envGT", "envGTE", "envLT", "envLTE", "envContains", "envHasPrefix", "envHasSuffix", "envIsNil", "envNotNil", "envEqualFold", "envContainsFold", "cwd", "cwdNEQ", "cwdIn", "cwdNotIn", "cwdGT", "cwdGTE", "cwdLT", "cwdLTE", "cwdContains", "cwdHasPrefix", "cwdHasSuffix", "cwdIsNil", "cwdNotNil", "cwdEqualFold", "cwdContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -9675,7 +11357,7 @@ func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx, v) if err != nil { return it, err } @@ -9684,7 +11366,7 @@ func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -9693,7 +11375,7 @@ func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -9908,2128 +11590,1924 @@ func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLTE = data - case "path": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Path = data - case "pathNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathNEQ = data - case "pathIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PathIn = data - case "pathNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PathNotIn = data - case "pathGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathGT = data - case "pathGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathGTE = data - case "pathLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathLT = data - case "pathLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathLTE = data - case "pathContains": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathContains = data - case "pathHasPrefix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathHasPrefix = data - case "pathHasSuffix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathHasSuffix = data - case "pathEqualFold": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathEqualFold = data - case "pathContainsFold": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PathContainsFold = data - case "owner": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Owner = data - case "ownerNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerNEQ = data - case "ownerIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.OwnerIn = data - case "ownerNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.OwnerNotIn = data - case "ownerGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerGT = data - case "ownerGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerGTE = data - case "ownerLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerLT = data - case "ownerLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerLTE = data - case "ownerContains": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerContains = data - case "ownerHasPrefix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.OwnerHasPrefix = data - case "ownerHasSuffix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.OwnerHasSuffix = data - case "ownerIsNil": + it.LastModifiedAtLTE = data + case "pid": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pid")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.OwnerIsNil = data - case "ownerNotNil": + it.Pid = data + case "pidNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.OwnerNotNil = data - case "ownerEqualFold": + it.PidNEQ = data + case "pidIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.OwnerEqualFold = data - case "ownerContainsFold": + it.PidIn = data + case "pidNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.OwnerContainsFold = data - case "group": + it.PidNotIn = data + case "pidGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("group")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.Group = data - case "groupNEQ": + it.PidGT = data + case "pidGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupNEQ = data - case "groupIn": + it.PidGTE = data + case "pidLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupIn = data - case "groupNotIn": + it.PidLT = data + case "pidLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupNotIn = data - case "groupGT": + it.PidLTE = data + case "ppid": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppid")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupGT = data - case "groupGTE": + it.Ppid = data + case "ppidNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupGTE = data - case "groupLT": + it.PpidNEQ = data + case "ppidIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.GroupLT = data - case "groupLTE": + it.PpidIn = data + case "ppidNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.GroupLTE = data - case "groupContains": + it.PpidNotIn = data + case "ppidGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupContains = data - case "groupHasPrefix": + it.PpidGT = data + case "ppidGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupHasPrefix = data - case "groupHasSuffix": + it.PpidGTE = data + case "ppidLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupHasSuffix = data - case "groupIsNil": + it.PpidLT = data + case "ppidLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.GroupIsNil = data - case "groupNotNil": + it.PpidLTE = data + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GroupNotNil = data - case "groupEqualFold": + it.Name = data + case "nameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.GroupEqualFold = data - case "groupContainsFold": + it.NameNEQ = data + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.GroupContainsFold = data - case "permissions": + it.NameIn = data + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissions")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Permissions = data - case "permissionsNEQ": + it.NameNotIn = data + case "nameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsNEQ = data - case "permissionsIn": + it.NameGT = data + case "nameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsIn = data - case "permissionsNotIn": + it.NameGTE = data + case "nameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsNotIn = data - case "permissionsGT": + it.NameLT = data + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsGT = data - case "permissionsGTE": + it.NameLTE = data + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsGTE = data - case "permissionsLT": + it.NameContains = data + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsLT = data - case "permissionsLTE": + it.NameHasPrefix = data + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsLTE = data - case "permissionsContains": + it.NameHasSuffix = data + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsContains = data - case "permissionsHasPrefix": + it.NameEqualFold = data + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsHasPrefix = data - case "permissionsHasSuffix": + it.NameContainsFold = data + case "principal": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsHasSuffix = data - case "permissionsIsNil": + it.Principal = data + case "principalNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsIsNil = data - case "permissionsNotNil": + it.PrincipalNEQ = data + case "principalIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PermissionsNotNil = data - case "permissionsEqualFold": + it.PrincipalIn = data + case "principalNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PermissionsEqualFold = data - case "permissionsContainsFold": + it.PrincipalNotIn = data + case "principalGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PermissionsContainsFold = data - case "size": + it.PrincipalGT = data + case "principalGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Size = data - case "sizeNEQ": + it.PrincipalGTE = data + case "principalLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeNEQ = data - case "sizeIn": + it.PrincipalLT = data + case "principalLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeIn = data - case "sizeNotIn": + it.PrincipalLTE = data + case "principalContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeNotIn = data - case "sizeGT": + it.PrincipalContains = data + case "principalHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeGT = data - case "sizeGTE": + it.PrincipalHasPrefix = data + case "principalHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeGTE = data - case "sizeLT": + it.PrincipalHasSuffix = data + case "principalEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeLT = data - case "sizeLTE": + it.PrincipalEqualFold = data + case "principalContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SizeLTE = data - case "hash": + it.PrincipalContainsFold = data + case "path": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Hash = data - case "hashNEQ": + it.Path = data + case "pathNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashNEQ = data - case "hashIn": + it.PathNEQ = data + case "pathIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashIn = data - case "hashNotIn": + it.PathIn = data + case "pathNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashNotIn = data - case "hashGT": + it.PathNotIn = data + case "pathGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGT = data - case "hashGTE": + it.PathGT = data + case "pathGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": + it.PathGTE = data + case "pathLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": + it.PathLT = data + case "pathLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": + it.PathLTE = data + case "pathContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": + it.PathContains = data + case "pathHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": + it.PathHasPrefix = data + case "pathHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashIsNil": + it.PathHasSuffix = data + case "pathIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HashIsNil = data - case "hashNotNil": + it.PathIsNil = data + case "pathNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.HashNotNil = data - case "hashEqualFold": + it.PathNotNil = data + case "pathEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": + it.PathEqualFold = data + case "pathContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasHost": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasHost = data - case "hasHostWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasHostWith = data - case "hasTask": + it.PathContainsFold = data + case "cmd": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmd")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTask = data - case "hasTaskWith": + it.Cmd = data + case "cmdNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTaskWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostOrder(ctx context.Context, obj interface{}) (ent.HostOrder, error) { - var it ent.HostOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": + it.CmdNEQ = data + case "cmdIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": + it.CmdIn = data + case "cmdNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostProcessOrder(ctx context.Context, obj interface{}) (ent.HostProcessOrder, error) { - var it ent.HostProcessOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": + it.CmdNotIn = data + case "cmdGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": + it.CmdGT = data + case "cmdGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNHostProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Field = data - } - } + it.CmdGTE = data + case "cmdLT": + var err error - return it, nil -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CmdLT = data + case "cmdLTE": + var err error -func (ec *executionContext) unmarshalInputHostProcessWhereInput(ctx context.Context, obj interface{}) (ent.HostProcessWhereInput, error) { - var it ent.HostProcessWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CmdLTE = data + case "cmdContains": + var err error - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "pid", "pidNEQ", "pidIn", "pidNotIn", "pidGT", "pidGTE", "pidLT", "pidLTE", "ppid", "ppidNEQ", "ppidIn", "ppidNotIn", "ppidGT", "ppidGTE", "ppidLT", "ppidLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathIsNil", "pathNotNil", "pathEqualFold", "pathContainsFold", "cmd", "cmdNEQ", "cmdIn", "cmdNotIn", "cmdGT", "cmdGTE", "cmdLT", "cmdLTE", "cmdContains", "cmdHasPrefix", "cmdHasSuffix", "cmdIsNil", "cmdNotNil", "cmdEqualFold", "cmdContainsFold", "env", "envNEQ", "envIn", "envNotIn", "envGT", "envGTE", "envLT", "envLTE", "envContains", "envHasPrefix", "envHasSuffix", "envIsNil", "envNotNil", "envEqualFold", "envContainsFold", "cwd", "cwdNEQ", "cwdIn", "cwdNotIn", "cwdGT", "cwdGTE", "cwdLT", "cwdLTE", "cwdContains", "cwdHasPrefix", "cwdHasSuffix", "cwdIsNil", "cwdNotNil", "cwdEqualFold", "cwdContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.CmdContains = data + case "cmdHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": + it.CmdHasPrefix = data + case "cmdHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.And = data - case "or": + it.CmdHasSuffix = data + case "cmdIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": + it.CmdIsNil = data + case "cmdNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": + it.CmdNotNil = data + case "cmdEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": + it.CmdEqualFold = data + case "cmdContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": + it.CmdContainsFold = data + case "env": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("env")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": + it.Env = data + case "envNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": + it.EnvNEQ = data + case "envIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": + it.EnvIn = data + case "envNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": + it.EnvNotIn = data + case "envGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": + it.EnvGT = data + case "envGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": + it.EnvGTE = data + case "envLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": + it.EnvLT = data + case "envLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": + it.EnvLTE = data + case "envContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": + it.EnvContains = data + case "envHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtGT = data - case "createdAtGTE": + it.EnvHasPrefix = data + case "envHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtGTE = data - case "createdAtLT": + it.EnvHasSuffix = data + case "envIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAtLT = data - case "createdAtLTE": + it.EnvIsNil = data + case "envNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAtLTE = data - case "lastModifiedAt": + it.EnvNotNil = data + case "envEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": + it.EnvEqualFold = data + case "envContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": + it.EnvContainsFold = data + case "cwd": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwd")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": + it.Cwd = data + case "cwdNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": + it.CwdNEQ = data + case "cwdIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": + it.CwdIn = data + case "cwdNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.CwdNotIn = data + case "cwdGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": + it.CwdGT = data + case "cwdGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": + it.CwdGTE = data + case "cwdLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLTE = data - case "pid": + it.CwdLT = data + case "cwdLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pid")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Pid = data - case "pidNEQ": + it.CwdLTE = data + case "cwdContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PidNEQ = data - case "pidIn": + it.CwdContains = data + case "cwdHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PidIn = data - case "pidNotIn": + it.CwdHasPrefix = data + case "cwdHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PidNotIn = data - case "pidGT": + it.CwdHasSuffix = data + case "cwdIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PidGT = data - case "pidGTE": + it.CwdIsNil = data + case "cwdNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PidGTE = data - case "pidLT": + it.CwdNotNil = data + case "cwdEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PidLT = data - case "pidLTE": + it.CwdEqualFold = data + case "cwdContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PidLTE = data - case "ppid": + it.CwdContainsFold = data + case "status": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppid")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status(ctx, v) if err != nil { return it, err } - it.Ppid = data - case "ppidNEQ": + it.Status = data + case "statusNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) + data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status(ctx, v) if err != nil { return it, err } - it.PpidNEQ = data - case "ppidIn": + it.StatusNEQ = data + case "statusIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) + data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Statusᚄ(ctx, v) if err != nil { return it, err } - it.PpidIn = data - case "ppidNotIn": + it.StatusIn = data + case "statusNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) + data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Statusᚄ(ctx, v) if err != nil { return it, err } - it.PpidNotIn = data - case "ppidGT": + it.StatusNotIn = data + case "hasHost": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.PpidGT = data - case "ppidGTE": + it.HasHost = data + case "hasHostWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.PpidGTE = data - case "ppidLT": + it.HasHostWith = data + case "hasTask": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.PpidLT = data - case "ppidLTE": + it.HasTask = data + case "hasTaskWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.PpidLTE = data - case "name": + it.HasTaskWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, obj interface{}) (ent.HostWhereInput, error) { + var it ent.HostWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasFiles", "hasFilesWith", "hasProcesses", "hasProcessesWith", "hasCredentials", "hasCredentialsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": + it.Not = data + case "and": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": + it.And = data + case "or": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": + it.Or = data + case "id": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": + it.ID = data + case "idNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": + it.IDNEQ = data + case "idIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": + it.IDIn = data + case "idNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.IDNotIn = data + case "idGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.IDGT = data + case "idGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.IDGTE = data + case "idLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.IDLT = data + case "idLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.IDLTE = data + case "createdAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.CreatedAt = data + case "createdAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "principal": + it.CreatedAtNEQ = data + case "createdAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": + it.CreatedAtIn = data + case "createdAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": + it.CreatedAtNotIn = data + case "createdAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": + it.CreatedAtGT = data + case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": + it.CreatedAtGTE = data + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": + it.CreatedAtLT = data + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": + it.CreatedAtLTE = data + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": + it.LastModifiedAt = data + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalEqualFold": + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "path": + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Path = data - case "pathNEQ": + it.LastModifiedAtLTE = data + case "identifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathNEQ = data - case "pathIn": + it.Identifier = data + case "identifierNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathIn = data - case "pathNotIn": + it.IdentifierNEQ = data + case "identifierIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PathNotIn = data - case "pathGT": + it.IdentifierIn = data + case "identifierNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PathGT = data - case "pathGTE": + it.IdentifierNotIn = data + case "identifierGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathGTE = data - case "pathLT": + it.IdentifierGT = data + case "identifierGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathLT = data - case "pathLTE": + it.IdentifierGTE = data + case "identifierLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathLTE = data - case "pathContains": + it.IdentifierLT = data + case "identifierLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathContains = data - case "pathHasPrefix": + it.IdentifierLTE = data + case "identifierContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathHasPrefix = data - case "pathHasSuffix": + it.IdentifierContains = data + case "identifierHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathHasSuffix = data - case "pathIsNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PathIsNil = data - case "pathNotNil": + it.IdentifierHasPrefix = data + case "identifierHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathNotNil = data - case "pathEqualFold": + it.IdentifierHasSuffix = data + case "identifierEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathEqualFold = data - case "pathContainsFold": + it.IdentifierEqualFold = data + case "identifierContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PathContainsFold = data - case "cmd": + it.IdentifierContainsFold = data + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmd")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Cmd = data - case "cmdNEQ": + it.Name = data + case "nameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdNEQ = data - case "cmdIn": + it.NameNEQ = data + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CmdIn = data - case "cmdNotIn": + it.NameIn = data + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CmdNotIn = data - case "cmdGT": + it.NameNotIn = data + case "nameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdGT = data - case "cmdGTE": + it.NameGT = data + case "nameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdGTE = data - case "cmdLT": + it.NameGTE = data + case "nameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdLT = data - case "cmdLTE": + it.NameLT = data + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdLTE = data - case "cmdContains": + it.NameLTE = data + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdContains = data - case "cmdHasPrefix": + it.NameContains = data + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdHasPrefix = data - case "cmdHasSuffix": + it.NameHasPrefix = data + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdHasSuffix = data - case "cmdIsNil": + it.NameHasSuffix = data + case "nameIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CmdIsNil = data - case "cmdNotNil": + it.NameIsNil = data + case "nameNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CmdNotNil = data - case "cmdEqualFold": + it.NameNotNil = data + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdEqualFold = data - case "cmdContainsFold": + it.NameEqualFold = data + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CmdContainsFold = data - case "env": + it.NameContainsFold = data + case "primaryIP": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("env")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIP")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Env = data - case "envNEQ": + it.PrimaryIP = data + case "primaryIPNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvNEQ = data - case "envIn": + it.PrimaryIPNEQ = data + case "primaryIPIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.EnvIn = data - case "envNotIn": + it.PrimaryIPIn = data + case "primaryIPNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.EnvNotIn = data - case "envGT": + it.PrimaryIPNotIn = data + case "primaryIPGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvGT = data - case "envGTE": + it.PrimaryIPGT = data + case "primaryIPGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvGTE = data - case "envLT": + it.PrimaryIPGTE = data + case "primaryIPLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvLT = data - case "envLTE": + it.PrimaryIPLT = data + case "primaryIPLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvLTE = data - case "envContains": + it.PrimaryIPLTE = data + case "primaryIPContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvContains = data - case "envHasPrefix": + it.PrimaryIPContains = data + case "primaryIPHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvHasPrefix = data - case "envHasSuffix": + it.PrimaryIPHasPrefix = data + case "primaryIPHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvHasSuffix = data - case "envIsNil": + it.PrimaryIPHasSuffix = data + case "primaryIPIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.EnvIsNil = data - case "envNotNil": + it.PrimaryIPIsNil = data + case "primaryIPNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.EnvNotNil = data - case "envEqualFold": + it.PrimaryIPNotNil = data + case "primaryIPEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvEqualFold = data - case "envContainsFold": + it.PrimaryIPEqualFold = data + case "primaryIPContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EnvContainsFold = data - case "cwd": + it.PrimaryIPContainsFold = data + case "platform": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwd")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platform")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.Cwd = data - case "cwdNEQ": + it.Platform = data + case "platformNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNEQ")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.CwdNEQ = data - case "cwdIn": + it.PlatformNEQ = data + case "platformIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.CwdIn = data - case "cwdNotIn": + it.PlatformIn = data + case "platformNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNotIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.CwdNotIn = data - case "cwdGT": + it.PlatformNotIn = data + case "lastSeenAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CwdGT = data - case "cwdGTE": + it.LastSeenAt = data + case "lastSeenAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CwdGTE = data - case "cwdLT": + it.LastSeenAtNEQ = data + case "lastSeenAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.CwdLT = data - case "cwdLTE": + it.LastSeenAtIn = data + case "lastSeenAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.CwdLTE = data - case "cwdContains": + it.LastSeenAtNotIn = data + case "lastSeenAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CwdContains = data - case "cwdHasPrefix": + it.LastSeenAtGT = data + case "lastSeenAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CwdHasPrefix = data - case "cwdHasSuffix": + it.LastSeenAtGTE = data + case "lastSeenAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLT = data + case "lastSeenAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CwdHasSuffix = data - case "cwdIsNil": + it.LastSeenAtNotNil = data + case "hasTags": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.CwdIsNil = data - case "cwdNotNil": + it.HasTags = data + case "hasTagsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) + data, err := ec.unmarshalOTagWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.CwdNotNil = data - case "cwdEqualFold": + it.HasTagsWith = data + case "hasBeacons": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacons")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.CwdEqualFold = data - case "cwdContainsFold": + it.HasBeacons = data + case "hasBeaconsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconsWith")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.CwdContainsFold = data - case "status": + it.HasBeaconsWith = data + case "hasFiles": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFiles")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Status = data - case "statusNEQ": + it.HasFiles = data + case "hasFilesWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFilesWith")) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.StatusNEQ = data - case "statusIn": + it.HasFilesWith = data + case "hasProcesses": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Statusᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcesses")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.StatusIn = data - case "statusNotIn": + it.HasProcesses = data + case "hasProcessesWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Statusᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcessesWith")) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.StatusNotIn = data - case "hasHost": + it.HasProcessesWith = data + case "hasCredentials": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCredentials")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": + it.HasCredentials = data + case "hasCredentialsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCredentialsWith")) + data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTask": + it.HasCredentialsWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj interface{}) (ent.QuestOrder, error) { + var it ent.QuestOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - it.HasTask = data - case "hasTaskWith": + it.Direction = data + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNQuestOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestOrderField(ctx, v) if err != nil { return it, err } - it.HasTaskWith = data + it.Field = data } } return it, nil } -func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, obj interface{}) (ent.HostWhereInput, error) { - var it ent.HostWhereInput +func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, obj interface{}) (ent.QuestWhereInput, error) { + var it ent.QuestWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasFiles", "hasFilesWith", "hasProcesses", "hasProcessesWith", "hasCredentials", "hasCredentialsWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -12040,7 +13518,7 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInput(ctx, v) if err != nil { return it, err } @@ -12049,7 +13527,7 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -12058,7 +13536,7 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -12274,128 +13752,11 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLTE = data - case "identifier": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Identifier = data - case "identifierNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierNEQ = data - case "identifierIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.IdentifierIn = data - case "identifierNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.IdentifierNotIn = data - case "identifierGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierGT = data - case "identifierGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierGTE = data - case "identifierLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierLT = data - case "identifierLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierLTE = data - case "identifierContains": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierContains = data - case "identifierHasPrefix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierHasSuffix = data - case "identifierEqualFold": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IdentifierEqualFold = data - case "identifierContainsFold": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data + it.LastModifiedAtLTE = data case "name": var err error @@ -12495,24 +13856,6 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob return it, err } it.NameHasSuffix = data - case "nameIsNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.NameIsNil = data - case "nameNotNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.NameNotNil = data case "nameEqualFold": var err error @@ -12531,365 +13874,221 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob return it, err } it.NameContainsFold = data - case "primaryIP": + case "parameters": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIP")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIP = data - case "primaryIPNEQ": + it.Parameters = data + case "parametersNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPNEQ = data - case "primaryIPIn": + it.ParametersNEQ = data + case "parametersIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrimaryIPIn = data - case "primaryIPNotIn": + it.ParametersIn = data + case "parametersNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrimaryIPNotIn = data - case "primaryIPGT": + it.ParametersNotIn = data + case "parametersGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPGT = data - case "primaryIPGTE": + it.ParametersGT = data + case "parametersGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPGTE = data - case "primaryIPLT": + it.ParametersGTE = data + case "parametersLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPLT = data - case "primaryIPLTE": + it.ParametersLT = data + case "parametersLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPLTE = data - case "primaryIPContains": + it.ParametersLTE = data + case "parametersContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPContains = data - case "primaryIPHasPrefix": + it.ParametersContains = data + case "parametersHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPHasPrefix = data - case "primaryIPHasSuffix": + it.ParametersHasPrefix = data + case "parametersHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPHasSuffix = data - case "primaryIPIsNil": + it.ParametersHasSuffix = data + case "parametersIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrimaryIPIsNil = data - case "primaryIPNotNil": + it.ParametersIsNil = data + case "parametersNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrimaryIPNotNil = data - case "primaryIPEqualFold": + it.ParametersNotNil = data + case "parametersEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPEqualFold = data - case "primaryIPContainsFold": + it.ParametersEqualFold = data + case "parametersContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPContainsFold = data - case "platform": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platform")) - data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) - if err != nil { - return it, err - } - it.Platform = data - case "platformNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNEQ")) - data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) - if err != nil { - return it, err - } - it.PlatformNEQ = data - case "platformIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformIn")) - data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) - if err != nil { - return it, err - } - it.PlatformIn = data - case "platformNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNotIn")) - data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) - if err != nil { - return it, err - } - it.PlatformNotIn = data - case "lastSeenAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAt = data - case "lastSeenAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtGT = data - case "lastSeenAtGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtGTE = data - case "lastSeenAtLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtLT = data - case "lastSeenAtLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.LastSeenAtNotNil = data - case "hasTags": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasTags = data - case "hasTagsWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) - data, err := ec.unmarshalOTagWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasTagsWith = data - case "hasBeacons": + it.ParametersContainsFold = data + case "hasTome": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacons")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasBeacons = data - case "hasBeaconsWith": + it.HasTome = data + case "hasTomeWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconsWith")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasBeaconsWith = data - case "hasFiles": + it.HasTomeWith = data + case "hasBundle": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFiles")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasFiles = data - case "hasFilesWith": + it.HasBundle = data + case "hasBundleWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFilesWith")) - data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundleWith")) + data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasFilesWith = data - case "hasProcesses": + it.HasBundleWith = data + case "hasTasks": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcesses")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasProcesses = data - case "hasProcessesWith": + it.HasTasks = data + case "hasTasksWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcessesWith")) - data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasProcessesWith = data - case "hasCredentials": + it.HasTasksWith = data + case "hasCreator": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCredentials")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasCredentials = data - case "hasCredentialsWith": + it.HasCreator = data + case "hasCreatorWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCredentialsWith")) - data, err := ec.unmarshalOHostCredentialWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasCredentialsWith = data + it.HasCreatorWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj interface{}) (ent.QuestOrder, error) { - var it ent.QuestOrder +func (ec *executionContext) unmarshalInputRepositoryOrder(ctx context.Context, obj interface{}) (ent.RepositoryOrder, error) { + var it ent.RepositoryOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -12919,7 +14118,7 @@ func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj in var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNQuestOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestOrderField(ctx, v) + data, err := ec.unmarshalNRepositoryOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderField(ctx, v) if err != nil { return it, err } @@ -12930,14 +14129,14 @@ func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj in return it, nil } -func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, obj interface{}) (ent.QuestWhereInput, error) { - var it ent.QuestWhereInput +func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Context, obj interface{}) (ent.RepositoryWhereInput, error) { + var it ent.RepositoryWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -12948,7 +14147,7 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInput(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx, v) if err != nil { return it, err } @@ -12957,7 +14156,7 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -12966,7 +14165,7 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -13187,330 +14386,240 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o return it, err } it.LastModifiedAtLTE = data - case "name": + case "url": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": + it.URL = data + case "urlNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": + it.URLNEQ = data + case "urlIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": + it.URLIn = data + case "urlNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": + it.URLNotIn = data + case "urlGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": + it.URLGT = data + case "urlGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": + it.URLGTE = data + case "urlLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.URLLT = data + case "urlLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.URLLTE = data + case "urlContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.URLContains = data + case "urlHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.URLHasPrefix = data + case "urlHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.URLHasSuffix = data + case "urlEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.URLEqualFold = data + case "urlContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "parameters": + it.URLContainsFold = data + case "publicKey": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKey")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Parameters = data - case "parametersNEQ": + it.PublicKey = data + case "publicKeyNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersNEQ = data - case "parametersIn": + it.PublicKeyNEQ = data + case "publicKeyIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParametersIn = data - case "parametersNotIn": + it.PublicKeyIn = data + case "publicKeyNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParametersNotIn = data - case "parametersGT": + it.PublicKeyNotIn = data + case "publicKeyGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersGT = data - case "parametersGTE": + it.PublicKeyGT = data + case "publicKeyGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersGTE = data - case "parametersLT": + it.PublicKeyGTE = data + case "publicKeyLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersLT = data - case "parametersLTE": + it.PublicKeyLT = data + case "publicKeyLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersLTE = data - case "parametersContains": + it.PublicKeyLTE = data + case "publicKeyContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersContains = data - case "parametersHasPrefix": + it.PublicKeyContains = data + case "publicKeyHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersHasPrefix = data - case "parametersHasSuffix": + it.PublicKeyHasPrefix = data + case "publicKeyHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersHasSuffix = data - case "parametersIsNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParametersIsNil = data - case "parametersNotNil": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParametersNotNil = data - case "parametersEqualFold": + it.PublicKeyHasSuffix = data + case "publicKeyEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersEqualFold = data - case "parametersContainsFold": + it.PublicKeyEqualFold = data + case "publicKeyContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersContainsFold = data - case "hasTome": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasTome = data - case "hasTomeWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasTomeWith = data - case "hasBundle": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasBundle = data - case "hasBundleWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundleWith")) - data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasBundleWith = data - case "hasTasks": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasTasks = data - case "hasTasksWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasTasksWith = data - case "hasCreator": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasCreator = data - case "hasCreatorWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) - data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasCreatorWith = data + it.PublicKeyContainsFold = data } } @@ -16818,6 +17927,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Quest(ctx, sel, obj) + case *ent.Repository: + if obj == nil { + return graphql.Null + } + return ec._Repository(ctx, sel, obj) case *ent.Tag: if obj == nil { return graphql.Null @@ -17913,7 +19027,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "beacons": + case "repositories": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -17922,7 +19036,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_beacons(ctx, field) + res = ec._Query_repositories(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -17935,7 +19049,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "hosts": + case "beacons": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -17944,7 +19058,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_hosts(ctx, field) + res = ec._Query_beacons(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -17957,7 +19071,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "tags": + case "hosts": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -17966,7 +19080,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_tags(ctx, field) + res = ec._Query_hosts(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -17979,7 +19093,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "tomes": + case "tags": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -17988,7 +19102,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_tomes(ctx, field) + res = ec._Query_tags(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -18001,7 +19115,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "users": + case "tomes": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -18010,7 +19124,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_users(ctx, field) + res = ec._Query_tomes(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -18023,7 +19137,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "me": + case "users": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -18032,7 +19146,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_me(ctx, field) + res = ec._Query_users(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -18045,7 +19159,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "gitPublicKey": + case "me": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -18054,7 +19168,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_gitPublicKey(ctx, field) + res = ec._Query_me(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -18289,6 +19403,152 @@ func (ec *executionContext) _Quest(ctx context.Context, sel ast.SelectionSet, ob return out } +var repositoryImplementors = []string{"Repository", "Node"} + +func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSet, obj *ent.Repository) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryImplementors) + + 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("Repository") + case "id": + out.Values[i] = ec._Repository_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._Repository_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "lastModifiedAt": + out.Values[i] = ec._Repository_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "url": + out.Values[i] = ec._Repository_url(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "publicKey": + out.Values[i] = ec._Repository_publicKey(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 repositoryConnectionImplementors = []string{"RepositoryConnection"} + +func (ec *executionContext) _RepositoryConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryConnectionImplementors) + + 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("RepositoryConnection") + case "edges": + out.Values[i] = ec._RepositoryConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._RepositoryConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._RepositoryConnection_totalCount(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 repositoryEdgeImplementors = []string{"RepositoryEdge"} + +func (ec *executionContext) _RepositoryEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryEdgeImplementors) + + 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("RepositoryEdge") + case "node": + out.Values[i] = ec._RepositoryEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._RepositoryEdge_cursor(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", "Node"} func (ec *executionContext) _Tag(ctx context.Context, sel ast.SelectionSet, obj *ent.Tag) graphql.Marshaler { @@ -19020,6 +20280,11 @@ func (ec *executionContext) unmarshalNCreateQuestInput2realmᚗpubᚋtavernᚋin return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNCreateRepositoryInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateRepositoryInput(ctx context.Context, v interface{}) (ent.CreateRepositoryInput, error) { + res, err := ec.unmarshalInputCreateRepositoryInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNCreateTagInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateTagInput(ctx context.Context, v interface{}) (ent.CreateTagInput, error) { res, err := ec.unmarshalInputCreateTagInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -19444,6 +20709,60 @@ func (ec *executionContext) unmarshalNQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋ return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNRepository2realmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx context.Context, sel ast.SelectionSet, v ent.Repository) graphql.Marshaler { + return ec._Repository(ctx, sel, &v) +} + +func (ec *executionContext) marshalNRepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx context.Context, sel ast.SelectionSet, v *ent.Repository) 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._Repository(ctx, sel, v) +} + +func (ec *executionContext) marshalNRepositoryConnection2realmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection(ctx context.Context, sel ast.SelectionSet, v ent.RepositoryConnection) graphql.Marshaler { + return ec._RepositoryConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection(ctx context.Context, sel ast.SelectionSet, v *ent.RepositoryConnection) 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._RepositoryConnection(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNRepositoryOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrder(ctx context.Context, v interface{}) (*ent.RepositoryOrder, error) { + res, err := ec.unmarshalInputRepositoryOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNRepositoryOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderField(ctx context.Context, v interface{}) (*ent.RepositoryOrderField, error) { + var res = new(ent.RepositoryOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNRepositoryOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.RepositoryOrderField) 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 v +} + +func (ec *executionContext) unmarshalNRepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx context.Context, v interface{}) (*ent.RepositoryWhereInput, error) { + res, err := ec.unmarshalInputRepositoryWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNTag2realmᚗpubᚋtavernᚋinternalᚋentᚐTag(ctx context.Context, sel ast.SelectionSet, v ent.Tag) graphql.Marshaler { return ec._Tag(ctx, sel, &v) } @@ -20534,6 +21853,109 @@ func (ec *executionContext) unmarshalOQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋ return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx context.Context, sel ast.SelectionSet, v *ent.Repository) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Repository(ctx, sel, v) +} + +func (ec *executionContext) marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.RepositoryEdge) 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.marshalORepositoryEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalORepositoryEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge(ctx context.Context, sel ast.SelectionSet, v *ent.RepositoryEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._RepositoryEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalORepositoryOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderᚄ(ctx context.Context, v interface{}) ([]*ent.RepositoryOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.RepositoryOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNRepositoryOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.RepositoryWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.RepositoryWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNRepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx context.Context, v interface{}) (*ent.RepositoryWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputRepositoryWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOTag2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Tag) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 3e3f82c52..434e0da1d 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -110,29 +110,20 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o return it, nil } -func (ec *executionContext) unmarshalInputImportTomesFromGitInput(ctx context.Context, obj interface{}) (models.ImportTomesFromGitInput, error) { - var it models.ImportTomesFromGitInput +func (ec *executionContext) unmarshalInputImportRepositoryInput(ctx context.Context, obj interface{}) (models.ImportRepositoryInput, error) { + var it models.ImportRepositoryInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"gitURL", "includeDirs"} + fieldsInOrder := [...]string{"includeDirs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "gitURL": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gitURL")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.GitURL = data case "includeDirs": var err error @@ -225,9 +216,12 @@ func (ec *executionContext) unmarshalInputSubmitTaskResultInput(ctx context.Cont // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNImportTomesFromGitInput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportTomesFromGitInput(ctx context.Context, v interface{}) (models.ImportTomesFromGitInput, error) { - res, err := ec.unmarshalInputImportTomesFromGitInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) +func (ec *executionContext) unmarshalOImportRepositoryInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportRepositoryInput(ctx context.Context, v interface{}) (*models.ImportRepositoryInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputImportRepositoryInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index c283a1656..9f8903549 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -24,10 +24,11 @@ type MutationResolver interface { UpdateHost(ctx context.Context, hostID int, input ent.UpdateHostInput) (*ent.Host, error) CreateTag(ctx context.Context, input ent.CreateTagInput) (*ent.Tag, error) UpdateTag(ctx context.Context, tagID int, input ent.UpdateTagInput) (*ent.Tag, error) - ImportTomesFromGit(ctx context.Context, input models.ImportTomesFromGitInput) ([]*ent.Tome, error) CreateTome(ctx context.Context, input ent.CreateTomeInput) (*ent.Tome, error) UpdateTome(ctx context.Context, tomeID int, input ent.UpdateTomeInput) (*ent.Tome, error) DeleteTome(ctx context.Context, tomeID int) (int, error) + CreateRepository(ctx context.Context, input ent.CreateRepositoryInput) (*ent.Repository, error) + ImportRepository(ctx context.Context, repoID int, input *models.ImportRepositoryInput) (*ent.Repository, error) UpdateUser(ctx context.Context, userID int, input ent.UpdateUserInput) (*ent.User, error) } @@ -59,6 +60,21 @@ func (ec *executionContext) field_Mutation_createQuest_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_createRepository_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 ent.CreateRepositoryInput + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNCreateRepositoryInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateRepositoryInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = 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{}{} @@ -104,18 +120,27 @@ func (ec *executionContext) field_Mutation_deleteTome_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_importTomesFromGit_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_importRepository_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 models.ImportTomesFromGitInput + var arg0 int + if tmp, ok := rawArgs["repoID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("repoID")) + arg0, err = ec.unmarshalNID2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["repoID"] = arg0 + var arg1 *models.ImportRepositoryInput if tmp, ok := rawArgs["input"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNImportTomesFromGitInput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportTomesFromGitInput(ctx, tmp) + arg1, err = ec.unmarshalOImportRepositoryInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportRepositoryInput(ctx, tmp) if err != nil { return nil, err } } - args["input"] = arg0 + args["input"] = arg1 return args, nil } @@ -799,8 +824,8 @@ func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, return fc, nil } -func (ec *executionContext) _Mutation_importTomesFromGit(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_importTomesFromGit(ctx, field) +func (ec *executionContext) _Mutation_createTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTome(ctx, field) if err != nil { return graphql.Null } @@ -814,7 +839,7 @@ func (ec *executionContext) _Mutation_importTomesFromGit(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().ImportTomesFromGit(rctx, fc.Args["input"].(models.ImportTomesFromGitInput)) + return ec.resolvers.Mutation().CreateTome(rctx, fc.Args["input"].(ent.CreateTomeInput)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") @@ -834,24 +859,27 @@ func (ec *executionContext) _Mutation_importTomesFromGit(ctx context.Context, fi if tmp == nil { return nil, nil } - if data, ok := tmp.([]*ent.Tome); ok { + if data, ok := tmp.(*ent.Tome); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Tome`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.Tome`, 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.([]*ent.Tome) + res := resTmp.(*ent.Tome) fc.Result = res - return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) + return ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_importTomesFromGit(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createTome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -894,15 +922,15 @@ func (ec *executionContext) fieldContext_Mutation_importTomesFromGit(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_importTomesFromGit_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createTome(ctx, field) +func (ec *executionContext) _Mutation_updateTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateTome(ctx, field) if err != nil { return graphql.Null } @@ -916,10 +944,10 @@ func (ec *executionContext) _Mutation_createTome(ctx context.Context, field grap 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().CreateTome(rctx, fc.Args["input"].(ent.CreateTomeInput)) + return ec.resolvers.Mutation().UpdateTome(rctx, fc.Args["tomeID"].(int), fc.Args["input"].(ent.UpdateTomeInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") if err != nil { return nil, err } @@ -956,7 +984,7 @@ func (ec *executionContext) _Mutation_createTome(ctx context.Context, field grap return ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createTome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateTome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -999,15 +1027,15 @@ func (ec *executionContext) fieldContext_Mutation_createTome(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateTome(ctx, field) +func (ec *executionContext) _Mutation_deleteTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteTome(ctx, field) if err != nil { return graphql.Null } @@ -1021,7 +1049,7 @@ func (ec *executionContext) _Mutation_updateTome(ctx context.Context, field grap 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().UpdateTome(rctx, fc.Args["tomeID"].(int), fc.Args["input"].(ent.UpdateTomeInput)) + return ec.resolvers.Mutation().DeleteTome(rctx, fc.Args["tomeID"].(int)) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") @@ -1041,10 +1069,10 @@ func (ec *executionContext) _Mutation_updateTome(ctx context.Context, field grap if tmp == nil { return nil, nil } - if data, ok := tmp.(*ent.Tome); ok { + if data, ok := tmp.(int); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.Tome`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1056,12 +1084,91 @@ func (ec *executionContext) _Mutation_updateTome(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*ent.Tome) + res := resTmp.(int) fc.Result = res - return ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateTome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteTome(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 ID 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_deleteTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createRepository(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createRepository(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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().CreateRepository(rctx, fc.Args["input"].(ent.CreateRepositoryInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*ent.Repository); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.Repository`, 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.(*ent.Repository) + fc.Result = res + return ec.marshalNRepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createRepository(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -1070,31 +1177,17 @@ func (ec *executionContext) fieldContext_Mutation_updateTome(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Tome_id(ctx, field) + return ec.fieldContext_Repository_id(ctx, field) case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) + return ec.fieldContext_Repository_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "files": - return ec.fieldContext_Tome_files(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, } defer func() { @@ -1104,15 +1197,15 @@ func (ec *executionContext) fieldContext_Mutation_updateTome(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createRepository_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteTome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteTome(ctx, field) +func (ec *executionContext) _Mutation_importRepository(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_importRepository(ctx, field) if err != nil { return graphql.Null } @@ -1126,10 +1219,10 @@ func (ec *executionContext) _Mutation_deleteTome(ctx context.Context, field grap 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().DeleteTome(rctx, fc.Args["tomeID"].(int)) + return ec.resolvers.Mutation().ImportRepository(rctx, fc.Args["repoID"].(int), fc.Args["input"].(*models.ImportRepositoryInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { return nil, err } @@ -1146,10 +1239,10 @@ func (ec *executionContext) _Mutation_deleteTome(ctx context.Context, field grap if tmp == nil { return nil, nil } - if data, ok := tmp.(int); ok { + if data, ok := tmp.(*ent.Repository); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.Repository`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1161,19 +1254,31 @@ func (ec *executionContext) _Mutation_deleteTome(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*ent.Repository) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNRepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteTome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_importRepository(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 ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, } defer func() { @@ -1183,7 +1288,7 @@ func (ec *executionContext) fieldContext_Mutation_deleteTome(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteTome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_importRepository_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -1350,10 +1455,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "importTomesFromGit": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_importTomesFromGit(ctx, field) - }) case "createTome": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTome(ctx, field) @@ -1375,6 +1476,20 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "createRepository": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createRepository(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "importRepository": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_importRepository(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) diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 859e0c48a..61687a0fc 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -127,17 +127,18 @@ type ComplexityRoot struct { } Mutation struct { - CreateQuest func(childComplexity int, beaconIDs []int, input ent.CreateQuestInput) int - CreateTag func(childComplexity int, input ent.CreateTagInput) int - CreateTome func(childComplexity int, input ent.CreateTomeInput) int - DeleteTome func(childComplexity int, tomeID int) int - DropAllData func(childComplexity int) int - ImportTomesFromGit func(childComplexity int, input models.ImportTomesFromGitInput) int - UpdateBeacon func(childComplexity int, beaconID int, input ent.UpdateBeaconInput) int - UpdateHost func(childComplexity int, hostID int, input ent.UpdateHostInput) int - UpdateTag func(childComplexity int, tagID int, input ent.UpdateTagInput) int - UpdateTome func(childComplexity int, tomeID int, input ent.UpdateTomeInput) int - UpdateUser func(childComplexity int, userID int, input ent.UpdateUserInput) int + CreateQuest func(childComplexity int, beaconIDs []int, input ent.CreateQuestInput) int + CreateRepository func(childComplexity int, input ent.CreateRepositoryInput) int + CreateTag func(childComplexity int, input ent.CreateTagInput) int + CreateTome func(childComplexity int, input ent.CreateTomeInput) int + DeleteTome func(childComplexity int, tomeID int) int + DropAllData func(childComplexity int) int + ImportRepository func(childComplexity int, repoID int, input *models.ImportRepositoryInput) int + UpdateBeacon func(childComplexity int, beaconID int, input ent.UpdateBeaconInput) int + UpdateHost func(childComplexity int, hostID int, input ent.UpdateHostInput) int + UpdateTag func(childComplexity int, tagID int, input ent.UpdateTagInput) int + UpdateTome func(childComplexity int, tomeID int, input ent.UpdateTomeInput) int + UpdateUser func(childComplexity int, userID int, input ent.UpdateUserInput) int } PageInfo struct { @@ -150,12 +151,12 @@ type ComplexityRoot struct { Query struct { Beacons func(childComplexity int, where *ent.BeaconWhereInput) int Files func(childComplexity int, where *ent.FileWhereInput) int - GitPublicKey func(childComplexity int) int Hosts func(childComplexity int, where *ent.HostWhereInput) int Me func(childComplexity int) int Node func(childComplexity int, id int) int Nodes func(childComplexity int, ids []int) int Quests func(childComplexity int, where *ent.QuestWhereInput) int + Repositories func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.RepositoryOrder, where *ent.RepositoryWhereInput) int Tags func(childComplexity int, where *ent.TagWhereInput) int Tasks func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.TaskOrder, where *ent.TaskWhereInput) int Tomes func(childComplexity int, where *ent.TomeWhereInput) int @@ -174,6 +175,25 @@ type ComplexityRoot struct { Tome func(childComplexity int) int } + Repository struct { + CreatedAt func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + PublicKey func(childComplexity int) int + URL func(childComplexity int) int + } + + RepositoryConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + RepositoryEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Tag struct { Hosts func(childComplexity int) int ID func(childComplexity int) int @@ -713,6 +733,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.CreateQuest(childComplexity, args["beaconIDs"].([]int), args["input"].(ent.CreateQuestInput)), true + case "Mutation.createRepository": + if e.complexity.Mutation.CreateRepository == nil { + break + } + + args, err := ec.field_Mutation_createRepository_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateRepository(childComplexity, args["input"].(ent.CreateRepositoryInput)), true + case "Mutation.createTag": if e.complexity.Mutation.CreateTag == nil { break @@ -756,17 +788,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.DropAllData(childComplexity), true - case "Mutation.importTomesFromGit": - if e.complexity.Mutation.ImportTomesFromGit == nil { + case "Mutation.importRepository": + if e.complexity.Mutation.ImportRepository == nil { break } - args, err := ec.field_Mutation_importTomesFromGit_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_importRepository_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.ImportTomesFromGit(childComplexity, args["input"].(models.ImportTomesFromGitInput)), true + return e.complexity.Mutation.ImportRepository(childComplexity, args["repoID"].(int), args["input"].(*models.ImportRepositoryInput)), true case "Mutation.updateBeacon": if e.complexity.Mutation.UpdateBeacon == nil { @@ -880,13 +912,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Files(childComplexity, args["where"].(*ent.FileWhereInput)), true - case "Query.gitPublicKey": - if e.complexity.Query.GitPublicKey == nil { - break - } - - return e.complexity.Query.GitPublicKey(childComplexity), true - case "Query.hosts": if e.complexity.Query.Hosts == nil { break @@ -942,6 +967,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Quests(childComplexity, args["where"].(*ent.QuestWhereInput)), true + case "Query.repositories": + if e.complexity.Query.Repositories == nil { + break + } + + args, err := ec.field_Query_repositories_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Repositories(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.RepositoryOrder), args["where"].(*ent.RepositoryWhereInput)), true + case "Query.tags": if e.complexity.Query.Tags == nil { break @@ -1053,6 +1090,76 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Quest.Tome(childComplexity), true + case "Repository.createdAt": + if e.complexity.Repository.CreatedAt == nil { + break + } + + return e.complexity.Repository.CreatedAt(childComplexity), true + + case "Repository.id": + if e.complexity.Repository.ID == nil { + break + } + + return e.complexity.Repository.ID(childComplexity), true + + case "Repository.lastModifiedAt": + if e.complexity.Repository.LastModifiedAt == nil { + break + } + + return e.complexity.Repository.LastModifiedAt(childComplexity), true + + case "Repository.publicKey": + if e.complexity.Repository.PublicKey == nil { + break + } + + return e.complexity.Repository.PublicKey(childComplexity), true + + case "Repository.url": + if e.complexity.Repository.URL == nil { + break + } + + return e.complexity.Repository.URL(childComplexity), true + + case "RepositoryConnection.edges": + if e.complexity.RepositoryConnection.Edges == nil { + break + } + + return e.complexity.RepositoryConnection.Edges(childComplexity), true + + case "RepositoryConnection.pageInfo": + if e.complexity.RepositoryConnection.PageInfo == nil { + break + } + + return e.complexity.RepositoryConnection.PageInfo(childComplexity), true + + case "RepositoryConnection.totalCount": + if e.complexity.RepositoryConnection.TotalCount == nil { + break + } + + return e.complexity.RepositoryConnection.TotalCount(childComplexity), true + + case "RepositoryEdge.cursor": + if e.complexity.RepositoryEdge.Cursor == nil { + break + } + + return e.complexity.RepositoryEdge.Cursor(childComplexity), true + + case "RepositoryEdge.node": + if e.complexity.RepositoryEdge.Node == nil { + break + } + + return e.complexity.RepositoryEdge.Node(childComplexity), true + case "Tag.hosts": if e.complexity.Tag.Hosts == nil { break @@ -1352,6 +1459,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputBeaconWhereInput, ec.unmarshalInputClaimTasksInput, ec.unmarshalInputCreateQuestInput, + ec.unmarshalInputCreateRepositoryInput, ec.unmarshalInputCreateTagInput, ec.unmarshalInputCreateTomeInput, ec.unmarshalInputFileOrder, @@ -1364,9 +1472,11 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputHostProcessOrder, ec.unmarshalInputHostProcessWhereInput, ec.unmarshalInputHostWhereInput, - ec.unmarshalInputImportTomesFromGitInput, + ec.unmarshalInputImportRepositoryInput, ec.unmarshalInputQuestOrder, ec.unmarshalInputQuestWhereInput, + ec.unmarshalInputRepositoryOrder, + ec.unmarshalInputRepositoryWhereInput, ec.unmarshalInputSubmitTaskResultInput, ec.unmarshalInputTagOrder, ec.unmarshalInputTagWhereInput, @@ -1658,6 +1768,14 @@ input CreateQuestInput { tomeID: ID! } """ +CreateRepositoryInput is used for create Repository object. +Input was generated by ent. +""" +input CreateRepositoryInput { + """URL of the repository""" + url: String! +} +""" CreateTagInput is used for create Tag object. Input was generated by ent. """ @@ -2605,6 +2723,109 @@ input QuestWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } +type Repository implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """URL of the repository""" + url: String! + """Public key associated with this repositories private key""" + publicKey: String! +} +"""A connection to a list of items.""" +type RepositoryConnection { + """A list of edges.""" + edges: [RepositoryEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} +"""An edge in a connection.""" +type RepositoryEdge { + """The item at the end of the edge.""" + node: Repository + """A cursor for use in pagination.""" + cursor: Cursor! +} +"""Ordering options for Repository connections""" +input RepositoryOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Repositories.""" + field: RepositoryOrderField! +} +"""Properties by which Repository connections can be ordered.""" +enum RepositoryOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +RepositoryWhereInput is used for filtering Repository objects. +Input was generated by ent. +""" +input RepositoryWhereInput { + not: RepositoryWhereInput + and: [RepositoryWhereInput!] + or: [RepositoryWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """url field predicates""" + url: String + urlNEQ: String + urlIn: [String!] + urlNotIn: [String!] + urlGT: String + urlGTE: String + urlLT: String + urlLTE: String + urlContains: String + urlHasPrefix: String + urlHasSuffix: String + urlEqualFold: String + urlContainsFold: String + """public_key field predicates""" + publicKey: String + publicKeyNEQ: String + publicKeyIn: [String!] + publicKeyNotIn: [String!] + publicKeyGT: String + publicKeyGTE: String + publicKeyLT: String + publicKeyLTE: String + publicKeyContains: String + publicKeyHasPrefix: String + publicKeyHasSuffix: String + publicKeyEqualFold: String + publicKeyContainsFold: String +} type Tag implements Node { id: ID! """Name of the tag""" @@ -3224,15 +3445,31 @@ scalar Uint64 """Filtering options for Tasks returned from the connection.""" where: TaskWhereInput ): TaskConnection! @requireRole(role: USER) + repositories( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Repositories returned from the connection.""" + orderBy: [RepositoryOrder!] + + """Filtering options for Repositories returned from the connection.""" + where: RepositoryWhereInput + ): RepositoryConnection! @requireRole(role: USER) beacons(where: BeaconWhereInput): [Beacon!]! @requireRole(role: USER) hosts(where: HostWhereInput): [Host!]! @requireRole(role: USER) tags(where: TagWhereInput): [Tag!]! @requireRole(role: USER) tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! - - """Obtain git ssh public key used for importing tomes from repos via ssh.""" - gitPublicKey: String! @requireRole(role: USER) } `, BuiltIn: false}, {Name: "../schema/mutation.graphql", Input: `type Mutation { @@ -3265,11 +3502,16 @@ scalar Uint64 ### # Tome ### - importTomesFromGit(input: ImportTomesFromGitInput!,): [Tome!] @requireRole(role: USER) createTome(input: CreateTomeInput!,): Tome! @requireRole(role: USER) updateTome(tomeID: ID!, input: UpdateTomeInput!,): Tome! @requireRole(role: ADMIN) deleteTome(tomeID: ID!): ID! @requireRole(role: ADMIN) + ### + # Repository + ### + createRepository(input: CreateRepositoryInput!): Repository! @requireRole(role: USER) + importRepository(repoID: ID!, input: ImportRepositoryInput): Repository! @requireRole(role: USER) + ### # User ### @@ -3318,10 +3560,7 @@ input SubmitTaskResultInput { """Error message captured as the result of task execution failure.""" error: String } -input ImportTomesFromGitInput { - """Specify a git URL to obtain the tomes from.""" - gitURL: String! - +input ImportRepositoryInput { """ Optionally, specify directories to include. Only tomes that have a main.eldritch in one of these directory prefixes will be included. diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index cf4eec5b9..ee179ef56 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -28,9 +28,7 @@ type ClaimTasksInput struct { AgentIdentifier string `json:"agentIdentifier"` } -type ImportTomesFromGitInput struct { - // Specify a git URL to obtain the tomes from. - GitURL string `json:"gitURL"` +type ImportRepositoryInput struct { // Optionally, specify directories to include. // Only tomes that have a main.eldritch in one of these directory prefixes will be included. IncludeDirs []string `json:"includeDirs,omitempty"` diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 041dcfdff..bd9783d19 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -159,35 +159,6 @@ func (r *mutationResolver) UpdateTag(ctx context.Context, tagID int, input ent.U return r.client.Tag.UpdateOneID(tagID).SetInput(input).Save(ctx) } -// ImportTomesFromGit is the resolver for the importTomesFromGit field. -func (r *mutationResolver) ImportTomesFromGit(ctx context.Context, input models.ImportTomesFromGitInput) ([]*ent.Tome, error) { - // Ensure a schema is set (or set https:// by default) - gitURL := input.GitURL - if !strings.HasPrefix(gitURL, "http://") && !strings.HasPrefix(gitURL, "ssh://") { - gitURL = fmt.Sprintf("https://%s", gitURL) - } - - if input.IncludeDirs == nil { - return r.git.Import(ctx, input.GitURL) - } - - // Filter to only include provided directories - filter := func(path string) bool { - for _, prefix := range input.IncludeDirs { - // Ignore Leading / - path = strings.TrimPrefix(path, "/") - prefix = strings.TrimPrefix(prefix, "/") - - // Include if matching - if strings.HasPrefix(path, prefix) { - return true - } - } - return false - } - return r.git.Import(ctx, gitURL, filter) -} - // CreateTome is the resolver for the createTome field. func (r *mutationResolver) CreateTome(ctx context.Context, input ent.CreateTomeInput) (*ent.Tome, error) { var uploaderID *int @@ -214,6 +185,47 @@ func (r *mutationResolver) DeleteTome(ctx context.Context, tomeID int) (int, err return tomeID, nil } +// CreateRepository is the resolver for the createRepository field. +func (r *mutationResolver) CreateRepository(ctx context.Context, input ent.CreateRepositoryInput) (*ent.Repository, error) { + return r.client.Repository.Create(). + SetURL(input.URL). + Save(ctx) +} + +// ImportRepository is the resolver for the importRepository field. +func (r *mutationResolver) ImportRepository(ctx context.Context, repoID int, input *models.ImportRepositoryInput) (*ent.Repository, error) { + // Load Repository + repo, err := r.client.Repository.Get(ctx, repoID) + if err != nil { + return nil, err + } + + // Configure Filters + filter := func(string) bool { return true } + if input.IncludeDirs != nil { + filter = func(path string) bool { + for _, prefix := range input.IncludeDirs { + // Ignore Leading / + path = strings.TrimPrefix(path, "/") + prefix = strings.TrimPrefix(prefix, "/") + + // Include if matching + if strings.HasPrefix(path, prefix) { + return true + } + } + return false + } + } + + // Import Tomes + if err := r.importer.Import(ctx, repo, filter); err != nil { + return nil, err + } + + return repo, nil +} + // UpdateUser is the resolver for the updateUser field. func (r *mutationResolver) UpdateUser(ctx context.Context, userID int, input ent.UpdateUserInput) (*ent.User, error) { return r.client.User.UpdateOneID(userID).SetInput(input).Save(ctx) diff --git a/tavern/internal/graphql/query.resolvers.go b/tavern/internal/graphql/query.resolvers.go index e86f675c6..6e64aa1a0 100644 --- a/tavern/internal/graphql/query.resolvers.go +++ b/tavern/internal/graphql/query.resolvers.go @@ -61,6 +61,22 @@ func (r *queryResolver) Tasks(ctx context.Context, after *entgql.Cursor[int], fi return query.Paginate(ctx, after, first, before, last, ent.WithTaskOrder(orderBy)) } +// Repositories is the resolver for the repositories field. +func (r *queryResolver) Repositories(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.RepositoryOrder, where *ent.RepositoryWhereInput) (*ent.RepositoryConnection, error) { + query, err := r.client.Repository.Query().CollectFields(ctx) + if err != nil { + return nil, fmt.Errorf("failed to collect fields: %w", err) + } + if where != nil { + query, err := where.Filter(query) + if err != nil { + return nil, fmt.Errorf("failed to apply filter: %w", err) + } + return query.Paginate(ctx, after, first, before, last, ent.WithRepositoryOrder(orderBy)) + } + return query.Paginate(ctx, after, first, before, last, ent.WithRepositoryOrder(orderBy)) +} + // Beacons is the resolver for the beacons field. func (r *queryResolver) Beacons(ctx context.Context, where *ent.BeaconWhereInput) ([]*ent.Beacon, error) { query, err := r.client.Beacon.Query().CollectFields(ctx) @@ -148,8 +164,3 @@ func (r *queryResolver) Me(ctx context.Context) (*ent.User, error) { } return nil, fmt.Errorf("no authenticated user present in request context") } - -// GitPublicKey is the resolver for the gitPublicKey field. -func (r *queryResolver) GitPublicKey(ctx context.Context) (string, error) { - return r.git.SSHPublicKey(), nil -} diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index 23a470d21..b2ae9ae21 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -12,20 +12,19 @@ import ( "github.com/99designs/gqlgen/graphql" ) -// A GitTomeImporter is responsible for importing tomes from the provided URL (filter based on provided filter options). -type GitTomeImporter interface { - Import(ctx context.Context, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) - SSHPublicKey() string +// A RepoImporter is responsible for importing tomes from the provided URL (filter based on provided filter options). +type RepoImporter interface { + Import(ctx context.Context, repo *ent.Repository, filters ...func(path string) bool) error } // Resolver is the resolver root. type Resolver struct { - client *ent.Client - git GitTomeImporter + client *ent.Client + importer RepoImporter } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer GitTomeImporter) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer RepoImporter) graphql.ExecutableSchema { cfg := generated.Config{ Resolvers: &Resolver{client, importer}, } diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 30a71b51b..0de990c85 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -178,6 +178,14 @@ input CreateQuestInput { tomeID: ID! } """ +CreateRepositoryInput is used for create Repository object. +Input was generated by ent. +""" +input CreateRepositoryInput { + """URL of the repository""" + url: String! +} +""" CreateTagInput is used for create Tag object. Input was generated by ent. """ @@ -1125,6 +1133,109 @@ input QuestWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } +type Repository implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """URL of the repository""" + url: String! + """Public key associated with this repositories private key""" + publicKey: String! +} +"""A connection to a list of items.""" +type RepositoryConnection { + """A list of edges.""" + edges: [RepositoryEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} +"""An edge in a connection.""" +type RepositoryEdge { + """The item at the end of the edge.""" + node: Repository + """A cursor for use in pagination.""" + cursor: Cursor! +} +"""Ordering options for Repository connections""" +input RepositoryOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Repositories.""" + field: RepositoryOrderField! +} +"""Properties by which Repository connections can be ordered.""" +enum RepositoryOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +RepositoryWhereInput is used for filtering Repository objects. +Input was generated by ent. +""" +input RepositoryWhereInput { + not: RepositoryWhereInput + and: [RepositoryWhereInput!] + or: [RepositoryWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """url field predicates""" + url: String + urlNEQ: String + urlIn: [String!] + urlNotIn: [String!] + urlGT: String + urlGTE: String + urlLT: String + urlLTE: String + urlContains: String + urlHasPrefix: String + urlHasSuffix: String + urlEqualFold: String + urlContainsFold: String + """public_key field predicates""" + publicKey: String + publicKeyNEQ: String + publicKeyIn: [String!] + publicKeyNotIn: [String!] + publicKeyGT: String + publicKeyGTE: String + publicKeyLT: String + publicKeyLTE: String + publicKeyContains: String + publicKeyHasPrefix: String + publicKeyHasSuffix: String + publicKeyEqualFold: String + publicKeyContainsFold: String +} type Tag implements Node { id: ID! """Name of the tag""" @@ -1760,10 +1871,7 @@ input SubmitTaskResultInput { """Error message captured as the result of task execution failure.""" error: String } -input ImportTomesFromGitInput { - """Specify a git URL to obtain the tomes from.""" - gitURL: String! - +input ImportRepositoryInput { """ Optionally, specify directories to include. Only tomes that have a main.eldritch in one of these directory prefixes will be included. @@ -1800,11 +1908,16 @@ type Mutation { ### # Tome ### - importTomesFromGit(input: ImportTomesFromGitInput!,): [Tome!] @requireRole(role: USER) createTome(input: CreateTomeInput!,): Tome! @requireRole(role: USER) updateTome(tomeID: ID!, input: UpdateTomeInput!,): Tome! @requireRole(role: ADMIN) deleteTome(tomeID: ID!): ID! @requireRole(role: ADMIN) + ### + # Repository + ### + createRepository(input: CreateRepositoryInput!): Repository! @requireRole(role: USER) + importRepository(repoID: ID!, input: ImportRepositoryInput): Repository! @requireRole(role: USER) + ### # User ### @@ -1832,15 +1945,31 @@ extend type Query { """Filtering options for Tasks returned from the connection.""" where: TaskWhereInput ): TaskConnection! @requireRole(role: USER) + repositories( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Repositories returned from the connection.""" + orderBy: [RepositoryOrder!] + + """Filtering options for Repositories returned from the connection.""" + where: RepositoryWhereInput + ): RepositoryConnection! @requireRole(role: USER) beacons(where: BeaconWhereInput): [Beacon!]! @requireRole(role: USER) hosts(where: HostWhereInput): [Host!]! @requireRole(role: USER) tags(where: TagWhereInput): [Tag!]! @requireRole(role: USER) tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! - - """Obtain git ssh public key used for importing tomes from repos via ssh.""" - gitPublicKey: String! @requireRole(role: USER) } scalar Time scalar Uint64 diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index e8b099200..80830c659 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -173,6 +173,14 @@ input CreateQuestInput { tomeID: ID! } """ +CreateRepositoryInput is used for create Repository object. +Input was generated by ent. +""" +input CreateRepositoryInput { + """URL of the repository""" + url: String! +} +""" CreateTagInput is used for create Tag object. Input was generated by ent. """ @@ -1120,6 +1128,109 @@ input QuestWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } +type Repository implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """URL of the repository""" + url: String! + """Public key associated with this repositories private key""" + publicKey: String! +} +"""A connection to a list of items.""" +type RepositoryConnection { + """A list of edges.""" + edges: [RepositoryEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} +"""An edge in a connection.""" +type RepositoryEdge { + """The item at the end of the edge.""" + node: Repository + """A cursor for use in pagination.""" + cursor: Cursor! +} +"""Ordering options for Repository connections""" +input RepositoryOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Repositories.""" + field: RepositoryOrderField! +} +"""Properties by which Repository connections can be ordered.""" +enum RepositoryOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +RepositoryWhereInput is used for filtering Repository objects. +Input was generated by ent. +""" +input RepositoryWhereInput { + not: RepositoryWhereInput + and: [RepositoryWhereInput!] + or: [RepositoryWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """url field predicates""" + url: String + urlNEQ: String + urlIn: [String!] + urlNotIn: [String!] + urlGT: String + urlGTE: String + urlLT: String + urlLTE: String + urlContains: String + urlHasPrefix: String + urlHasSuffix: String + urlEqualFold: String + urlContainsFold: String + """public_key field predicates""" + publicKey: String + publicKeyNEQ: String + publicKeyIn: [String!] + publicKeyNotIn: [String!] + publicKeyGT: String + publicKeyGTE: String + publicKeyLT: String + publicKeyLTE: String + publicKeyContains: String + publicKeyHasPrefix: String + publicKeyHasSuffix: String + publicKeyEqualFold: String + publicKeyContainsFold: String +} type Tag implements Node { id: ID! """Name of the tag""" diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index a752a22fb..80dac9eb5 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -40,10 +40,7 @@ input SubmitTaskResultInput { """Error message captured as the result of task execution failure.""" error: String } -input ImportTomesFromGitInput { - """Specify a git URL to obtain the tomes from.""" - gitURL: String! - +input ImportRepositoryInput { """ Optionally, specify directories to include. Only tomes that have a main.eldritch in one of these directory prefixes will be included. diff --git a/tavern/internal/graphql/schema/mutation.graphql b/tavern/internal/graphql/schema/mutation.graphql index 418792755..9e315a702 100644 --- a/tavern/internal/graphql/schema/mutation.graphql +++ b/tavern/internal/graphql/schema/mutation.graphql @@ -28,11 +28,16 @@ type Mutation { ### # Tome ### - importTomesFromGit(input: ImportTomesFromGitInput!,): [Tome!] @requireRole(role: USER) createTome(input: CreateTomeInput!,): Tome! @requireRole(role: USER) updateTome(tomeID: ID!, input: UpdateTomeInput!,): Tome! @requireRole(role: ADMIN) deleteTome(tomeID: ID!): ID! @requireRole(role: ADMIN) + ### + # Repository + ### + createRepository(input: CreateRepositoryInput!): Repository! @requireRole(role: USER) + importRepository(repoID: ID!, input: ImportRepositoryInput): Repository! @requireRole(role: USER) + ### # User ### diff --git a/tavern/internal/graphql/schema/query.graphql b/tavern/internal/graphql/schema/query.graphql index ec46ee74b..2690bd00b 100644 --- a/tavern/internal/graphql/schema/query.graphql +++ b/tavern/internal/graphql/schema/query.graphql @@ -20,13 +20,29 @@ extend type Query { """Filtering options for Tasks returned from the connection.""" where: TaskWhereInput ): TaskConnection! @requireRole(role: USER) + repositories( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Repositories returned from the connection.""" + orderBy: [RepositoryOrder!] + + """Filtering options for Repositories returned from the connection.""" + where: RepositoryWhereInput + ): RepositoryConnection! @requireRole(role: USER) beacons(where: BeaconWhereInput): [Beacon!]! @requireRole(role: USER) hosts(where: HostWhereInput): [Host!]! @requireRole(role: USER) tags(where: TagWhereInput): [Tag!]! @requireRole(role: USER) tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! - - """Obtain git ssh public key used for importing tomes from repos via ssh.""" - gitSSHPublicKey: String! @requireRole(role: USER) } diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 30a71b51b..0de990c85 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -178,6 +178,14 @@ input CreateQuestInput { tomeID: ID! } """ +CreateRepositoryInput is used for create Repository object. +Input was generated by ent. +""" +input CreateRepositoryInput { + """URL of the repository""" + url: String! +} +""" CreateTagInput is used for create Tag object. Input was generated by ent. """ @@ -1125,6 +1133,109 @@ input QuestWhereInput { hasCreator: Boolean hasCreatorWith: [UserWhereInput!] } +type Repository implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """URL of the repository""" + url: String! + """Public key associated with this repositories private key""" + publicKey: String! +} +"""A connection to a list of items.""" +type RepositoryConnection { + """A list of edges.""" + edges: [RepositoryEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} +"""An edge in a connection.""" +type RepositoryEdge { + """The item at the end of the edge.""" + node: Repository + """A cursor for use in pagination.""" + cursor: Cursor! +} +"""Ordering options for Repository connections""" +input RepositoryOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order Repositories.""" + field: RepositoryOrderField! +} +"""Properties by which Repository connections can be ordered.""" +enum RepositoryOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +RepositoryWhereInput is used for filtering Repository objects. +Input was generated by ent. +""" +input RepositoryWhereInput { + not: RepositoryWhereInput + and: [RepositoryWhereInput!] + or: [RepositoryWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """url field predicates""" + url: String + urlNEQ: String + urlIn: [String!] + urlNotIn: [String!] + urlGT: String + urlGTE: String + urlLT: String + urlLTE: String + urlContains: String + urlHasPrefix: String + urlHasSuffix: String + urlEqualFold: String + urlContainsFold: String + """public_key field predicates""" + publicKey: String + publicKeyNEQ: String + publicKeyIn: [String!] + publicKeyNotIn: [String!] + publicKeyGT: String + publicKeyGTE: String + publicKeyLT: String + publicKeyLTE: String + publicKeyContains: String + publicKeyHasPrefix: String + publicKeyHasSuffix: String + publicKeyEqualFold: String + publicKeyContainsFold: String +} type Tag implements Node { id: ID! """Name of the tag""" @@ -1760,10 +1871,7 @@ input SubmitTaskResultInput { """Error message captured as the result of task execution failure.""" error: String } -input ImportTomesFromGitInput { - """Specify a git URL to obtain the tomes from.""" - gitURL: String! - +input ImportRepositoryInput { """ Optionally, specify directories to include. Only tomes that have a main.eldritch in one of these directory prefixes will be included. @@ -1800,11 +1908,16 @@ type Mutation { ### # Tome ### - importTomesFromGit(input: ImportTomesFromGitInput!,): [Tome!] @requireRole(role: USER) createTome(input: CreateTomeInput!,): Tome! @requireRole(role: USER) updateTome(tomeID: ID!, input: UpdateTomeInput!,): Tome! @requireRole(role: ADMIN) deleteTome(tomeID: ID!): ID! @requireRole(role: ADMIN) + ### + # Repository + ### + createRepository(input: CreateRepositoryInput!): Repository! @requireRole(role: USER) + importRepository(repoID: ID!, input: ImportRepositoryInput): Repository! @requireRole(role: USER) + ### # User ### @@ -1832,15 +1945,31 @@ extend type Query { """Filtering options for Tasks returned from the connection.""" where: TaskWhereInput ): TaskConnection! @requireRole(role: USER) + repositories( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Ordering options for Repositories returned from the connection.""" + orderBy: [RepositoryOrder!] + + """Filtering options for Repositories returned from the connection.""" + where: RepositoryWhereInput + ): RepositoryConnection! @requireRole(role: USER) beacons(where: BeaconWhereInput): [Beacon!]! @requireRole(role: USER) hosts(where: HostWhereInput): [Host!]! @requireRole(role: USER) tags(where: TagWhereInput): [Tag!]! @requireRole(role: USER) tomes(where: TomeWhereInput): [Tome!]! @requireRole(role: USER) users(where: UserWhereInput): [User!]! @requireRole(role: USER) me: User! - - """Obtain git ssh public key used for importing tomes from repos via ssh.""" - gitPublicKey: String! @requireRole(role: USER) } scalar Time scalar Uint64 diff --git a/tavern/tomes/git.go b/tavern/tomes/git.go index 231a117d7..4ff119148 100644 --- a/tavern/tomes/git.go +++ b/tavern/tomes/git.go @@ -2,8 +2,6 @@ package tomes import ( "context" - "crypto/ed25519" - "crypto/rand" "encoding/json" "fmt" "io" @@ -26,13 +24,6 @@ import ( // GitImportOption provides configuration for creating a new GitImporter. type GitImportOption func(*GitImporter) -// GitWithSSHSigner enables a GitImporter to use a private key for ssh clones. -func GitWithSSHSigner(signer ssh.Signer) GitImportOption { - return func(importer *GitImporter) { - importer.signer = signer - } -} - // NewGitImporter initializes and returns a new GitImporter. // If no SSH Private Key is provided, a new ECDSA P256 private key is generated. // This panics if a new SSH Private Key cannot be generated. @@ -43,27 +34,13 @@ func NewGitImporter(graph *ent.Client, options ...GitImportOption) *GitImporter for _, opt := range options { opt(importer) } - if importer.signer == nil { - _, privKey, err := ed25519.GenerateKey(rand.Reader) - if err != nil { - panic(fmt.Errorf("failed to generate ed25519 private key: %w", err)) - } - - signer, err := ssh.NewSignerFromKey(privKey) - if err != nil { - panic(fmt.Errorf("could not convert private key to ssh signer: %v", err)) - } - - importer.signer = signer - } return importer } // A GitImporter imports tomes from a provided Git URL. type GitImporter struct { - signer ssh.Signer - graph *ent.Client + graph *ent.Client } // Import clones a git repository from the provided URL in memory. @@ -74,13 +51,17 @@ type GitImporter struct { // // Provided filters on tome paths may be used to limit included directories by returning true if the // result should be included. -func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters ...func(path string) bool) ([]*ent.Tome, error) { +func (importer *GitImporter) Import(ctx context.Context, entRepo *ent.Repository, filters ...func(path string) bool) error { // Use Private Key Auth for SSH var authMethod *gitssh.PublicKeys - if importer.signer != nil && strings.HasPrefix(gitURL, "ssh://") { + if strings.HasPrefix(entRepo.URL, "ssh://") { + privKey, err := ssh.ParsePrivateKey([]byte(entRepo.PrivateKey)) + if err != nil { + return fmt.Errorf("failed to parse private key for repository: %w", err) + } authMethod = &gitssh.PublicKeys{ User: "git", - Signer: importer.signer, + Signer: privKey, HostKeyCallbackHelper: gitssh.HostKeyCallbackHelper{ // Ignore Host Keys HostKeyCallback: ssh.InsecureIgnoreHostKey(), @@ -91,43 +72,42 @@ func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters // Clone Repository (In-Memory) storage := memory.NewStorage() repo, err := git.CloneContext(ctx, storage, nil, &git.CloneOptions{ - URL: gitURL, + URL: entRepo.URL, SingleBranch: true, Depth: 1, Auth: authMethod, Tags: git.NoTags, }) if err != nil { - return nil, fmt.Errorf("failed to clone: %w", err) + return fmt.Errorf("failed to clone: %w", err) } // Get HEAD head, err := repo.Head() if err != nil { - return nil, fmt.Errorf("failed to get repository HEAD: %w", err) + return fmt.Errorf("failed to get repository HEAD: %w", err) } // Get Commit commit, err := repo.CommitObject(head.Hash()) if err != nil { - return nil, fmt.Errorf("failed to get commit object (HEAD): %w", err) + return fmt.Errorf("failed to get commit object (HEAD): %w", err) } // Get Root File Tree tree, err := repo.TreeObject(commit.TreeHash) if err != nil { - return nil, fmt.Errorf("failed to get tree (%q): %w", commit.Hash, err) + return fmt.Errorf("failed to get tree (%q): %w", commit.Hash, err) } // Get Tome Paths tomePaths, err := findTomePaths(tree) if err != nil { - return nil, err + return err } // Import Tomes - namespace := parseNamespaceFromGit(gitURL) - tomes := make([]*ent.Tome, 0, len(tomePaths)) + namespace := parseNamespaceFromGit(entRepo.URL) for _, path := range tomePaths { // Apply Filters include := true @@ -142,21 +122,19 @@ func (importer *GitImporter) Import(ctx context.Context, gitURL string, filters } // Import Tome - tome, err := importer.importFromGitTree(ctx, repo, namespace, tree, path) - if err != nil { - return nil, fmt.Errorf("failed to import tome (%q): %w", path, err) + if err := importer.importFromGitTree(ctx, repo, entRepo, namespace, tree, path); err != nil { + return fmt.Errorf("failed to import tome (%q): %w", path, err) } - tomes = append(tomes, tome) } - return tomes, nil + return nil } // ImportFromGitTree imports a tome based on the provided path -func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Repository, namespace string, root *object.Tree, path string) (*ent.Tome, error) { +func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Repository, entRepo *ent.Repository, namespace string, root *object.Tree, path string) error { tree, err := root.Tree(path) if err != nil { - return nil, fmt.Errorf("failed to get tome tree (%q): %w", path, err) + return fmt.Errorf("failed to get tome tree (%q): %w", path, err) } walker := object.NewTreeWalker(tree, true, make(map[plumbing.Hash]bool)) @@ -172,7 +150,7 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re break } if err != nil { - return nil, fmt.Errorf("failed to walk tome tree (%q): %w", name, err) + return fmt.Errorf("failed to walk tome tree (%q): %w", name, err) } // Skip Directory Files @@ -183,25 +161,25 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re // Read File Data blob, err := repo.BlobObject(entry.Hash) if err != nil { - return nil, fmt.Errorf("failed to get tome blob (%q): %w", name, err) + return fmt.Errorf("failed to get tome blob (%q): %w", name, err) } reader, err := blob.Reader() if err != nil { - return nil, fmt.Errorf("failed to get tome blob reader (%q): %w", name, err) + return fmt.Errorf("failed to get tome blob reader (%q): %w", name, err) } defer reader.Close() data, err := io.ReadAll(reader) if err != nil { - return nil, fmt.Errorf("failed to read tome file (%q): %w", name, err) + return fmt.Errorf("failed to read tome file (%q): %w", name, err) } // Parse metadata.yml if filepath.Base(name) == "metadata.yml" { if err := yaml.Unmarshal(data, &metadata); err != nil { - return nil, fmt.Errorf("failed to parse tome metadata %q: %w", name, err) + return fmt.Errorf("failed to parse tome metadata %q: %w", name, err) } if err := metadata.Validate(); err != nil { - return nil, fmt.Errorf("invalid tome metadata %q: %w", name, err) + return fmt.Errorf("invalid tome metadata %q: %w", name, err) } continue @@ -222,29 +200,29 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re UpdateNewValues(). ID(ctx) if err != nil { - return nil, fmt.Errorf("failed to upload tome file %q: %w", name, err) + return fmt.Errorf("failed to upload tome file %q: %w", name, err) } tomeFileIDs = append(tomeFileIDs, fileID) } // Ensure Metadata was found if metadata.Name == "" { - return nil, fmt.Errorf("tome must include 'metadata.yml' file (%q)", path) + return fmt.Errorf("tome must include 'metadata.yml' file (%q)", path) } // Ensure Eldritch not empty if eldritch == "" { - return nil, fmt.Errorf("tome must include non-empty 'eldritch.main' file (%q)", path) + return fmt.Errorf("tome must include non-empty 'eldritch.main' file (%q)", path) } // Marshal Params paramdefs, err := json.Marshal(metadata.ParamDefs) if err != nil { - return nil, fmt.Errorf("failed to marshal param defs for %q: %w", path, err) + return fmt.Errorf("failed to marshal param defs for %q: %w", path, err) } // Create the tome - tomeID, err := importer.graph.Tome.Create(). + _, err = importer.graph.Tome.Create(). SetName(fmt.Sprintf("%s::%s", namespace, metadata.Name)). SetDescription(metadata.Description). SetAuthor(metadata.Author). @@ -257,16 +235,9 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re UpdateNewValues(). ID(ctx) if err != nil { - return nil, fmt.Errorf("failed to create tome %q: %w", metadata.Name, err) + return fmt.Errorf("failed to create tome %q: %w", metadata.Name, err) } - - return importer.graph.Tome.Get(ctx, tomeID) -} - -// SSHPublicKey returns a PEM-Encoded PKIX ASN.1DER encoded public key associated with the private key used for cloning. -func (importer *GitImporter) SSHPublicKey() string { - pubKey := importer.signer.PublicKey() - return string(ssh.MarshalAuthorizedKey(pubKey)) + return nil } // findTomePaths returns a list of valid paths to the root directory of a Tome. diff --git a/tavern/tomes/git_test.go b/tavern/tomes/git_test.go index 2ca04994a..f0161dd6f 100644 --- a/tavern/tomes/git_test.go +++ b/tavern/tomes/git_test.go @@ -27,10 +27,14 @@ func TestImportFromRepo(t *testing.T) { // Initialize Git Importer git := tomes.NewGitImporter(graph) + // Create repository + repo := graph.Repository.Create().SetURL(localGit).SaveX(ctx) + repo.URL = localGit + filter := func(path string) bool { return strings.Contains(path, "example") } - _, err := git.Import(ctx, localGit, filter) + err := git.Import(ctx, repo, filter) require.NoError(t, err) testTome := graph.Tome.Query(). From 6eb969a454e44f2ce56ea7dc99602766c4233717 Mon Sep 17 00:00:00 2001 From: KCarretto Date: Mon, 19 Feb 2024 19:11:56 +0000 Subject: [PATCH 4/6] acceptance tested --- tavern/internal/ent/client.go | 32 +++ tavern/internal/ent/gql_collection.go | 22 ++ tavern/internal/ent/gql_edge.go | 20 ++ tavern/internal/ent/gql_mutation_input.go | 6 +- tavern/internal/ent/gql_where_input.go | 44 +++ tavern/internal/ent/migrate/schema.go | 8 + tavern/internal/ent/mutation.go | 208 ++++++++++++-- tavern/internal/ent/repository.go | 56 +++- tavern/internal/ent/repository/repository.go | 35 +++ tavern/internal/ent/repository/where.go | 24 ++ tavern/internal/ent/repository_create.go | 42 +++ tavern/internal/ent/repository_query.go | 118 +++++++- tavern/internal/ent/repository_update.go | 183 ++++++++++++ tavern/internal/ent/runtime/runtime.go | 8 + tavern/internal/ent/schema/repository.go | 18 +- tavern/internal/ent/schema/tome.go | 6 + tavern/internal/ent/tome.go | 41 ++- tavern/internal/ent/tome/tome.go | 24 ++ tavern/internal/ent/tome/where.go | 23 ++ tavern/internal/ent/tome_create.go | 37 +++ tavern/internal/ent/tome_query.go | 93 ++++++- tavern/internal/ent/tome_update.go | 109 ++++++++ .../graphql/generated/ent.generated.go | 261 +++++++++++++++++- .../graphql/generated/mutation.generated.go | 8 + .../graphql/generated/root_.generated.go | 27 ++ tavern/internal/graphql/mutation.resolvers.go | 2 +- tavern/internal/graphql/schema.graphql | 11 + tavern/internal/graphql/schema/ent.graphql | 11 + tavern/internal/www/schema.graphql | 11 + tavern/tomes/git.go | 1 + tavern/tomes/git_test.go | 2 + 31 files changed, 1427 insertions(+), 64 deletions(-) diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 32733005e..2b5a2967a 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -1621,6 +1621,22 @@ func (c *RepositoryClient) GetX(ctx context.Context, id int) *Repository { return obj } +// QueryTomes queries the tomes edge of a Repository. +func (c *RepositoryClient) QueryTomes(r *Repository) *TomeQuery { + query := (&TomeClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := r.ID + step := sqlgraph.NewStep( + sqlgraph.From(repository.Table, repository.FieldID, id), + sqlgraph.To(tome.Table, tome.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, repository.TomesTable, repository.TomesColumn), + ) + fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *RepositoryClient) Hooks() []Hook { hooks := c.hooks.Repository @@ -2150,6 +2166,22 @@ func (c *TomeClient) QueryUploader(t *Tome) *UserQuery { return query } +// QueryRepository queries the repository edge of a Tome. +func (c *TomeClient) QueryRepository(t *Tome) *RepositoryQuery { + query := (&RepositoryClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tome.Table, tome.FieldID, id), + sqlgraph.To(repository.Table, repository.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, tome.RepositoryTable, tome.RepositoryColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *TomeClient) Hooks() []Hook { hooks := c.hooks.Tome diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 21ed183d7..c3092cc89 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -1067,6 +1067,18 @@ func (r *RepositoryQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "tomes": + var ( + alias = field.Alias + path = append(path, alias) + query = (&TomeClient{config: r.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + r.WithNamedTomes(alias, func(wq *TomeQuery) { + *wq = *query + }) case "createdAt": if _, ok := fieldSeen[repository.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, repository.FieldCreatedAt) @@ -1491,6 +1503,16 @@ func (t *TomeQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo return err } t.withUploader = query + case "repository": + var ( + alias = field.Alias + path = append(path, alias) + query = (&RepositoryClient{config: t.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + t.withRepository = query case "createdAt": if _, ok := fieldSeen[tome.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, tome.FieldCreatedAt) diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index 7ce11df1e..f0e760d21 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -184,6 +184,18 @@ func (q *Quest) Creator(ctx context.Context) (*User, error) { return result, MaskNotFound(err) } +func (r *Repository) Tomes(ctx context.Context) (result []*Tome, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = r.NamedTomes(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = r.Edges.TomesOrErr() + } + if IsNotLoaded(err) { + result, err = r.QueryTomes().All(ctx) + } + return result, err +} + func (t *Tag) Hosts(ctx context.Context) (result []*Host, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = t.NamedHosts(graphql.GetFieldContext(ctx).Field.Alias) @@ -268,6 +280,14 @@ func (t *Tome) Uploader(ctx context.Context) (*User, error) { return result, MaskNotFound(err) } +func (t *Tome) Repository(ctx context.Context) (*Repository, error) { + result, err := t.Edges.RepositoryOrErr() + if IsNotLoaded(err) { + result, err = t.QueryRepository().Only(ctx) + } + return result, MaskNotFound(err) +} + func (u *User) Tomes(ctx context.Context) (result []*Tome, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = u.NamedTomes(graphql.GetFieldContext(ctx).Field.Alias) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index b44c0fdf4..06a855f20 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -153,12 +153,16 @@ func (c *QuestCreate) SetInput(i CreateQuestInput) *QuestCreate { // CreateRepositoryInput represents a mutation input for creating repositories. type CreateRepositoryInput struct { - URL string + URL string + TomeIDs []int } // Mutate applies the CreateRepositoryInput on the RepositoryMutation builder. func (i *CreateRepositoryInput) Mutate(m *RepositoryMutation) { m.SetURL(i.URL) + if v := i.TomeIDs; len(v) > 0 { + m.AddTomeIDs(v...) + } } // SetInput applies the change-set in the CreateRepositoryInput on the RepositoryCreate builder. diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index c5815463e..1406e8b61 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -3546,6 +3546,10 @@ type RepositoryWhereInput struct { PublicKeyHasSuffix *string `json:"publicKeyHasSuffix,omitempty"` PublicKeyEqualFold *string `json:"publicKeyEqualFold,omitempty"` PublicKeyContainsFold *string `json:"publicKeyContainsFold,omitempty"` + + // "tomes" edge predicates. + HasTomes *bool `json:"hasTomes,omitempty"` + HasTomesWith []*TomeWhereInput `json:"hasTomesWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -3770,6 +3774,24 @@ func (i *RepositoryWhereInput) P() (predicate.Repository, error) { predicates = append(predicates, repository.PublicKeyContainsFold(*i.PublicKeyContainsFold)) } + if i.HasTomes != nil { + p := repository.HasTomes() + if !*i.HasTomes { + p = repository.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasTomesWith) > 0 { + with := make([]predicate.Tome, 0, len(i.HasTomesWith)) + for _, w := range i.HasTomesWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasTomesWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, repository.HasTomesWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyRepositoryWhereInput @@ -4717,6 +4739,10 @@ type TomeWhereInput struct { // "uploader" edge predicates. HasUploader *bool `json:"hasUploader,omitempty"` HasUploaderWith []*UserWhereInput `json:"hasUploaderWith,omitempty"` + + // "repository" edge predicates. + HasRepository *bool `json:"hasRepository,omitempty"` + HasRepositoryWith []*RepositoryWhereInput `json:"hasRepositoryWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -5124,6 +5150,24 @@ func (i *TomeWhereInput) P() (predicate.Tome, error) { } predicates = append(predicates, tome.HasUploaderWith(with...)) } + if i.HasRepository != nil { + p := tome.HasRepository() + if !*i.HasRepository { + p = tome.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasRepositoryWith) > 0 { + with := make([]predicate.Repository, 0, len(i.HasRepositoryWith)) + for _, w := range i.HasRepositoryWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasRepositoryWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, tome.HasRepositoryWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyTomeWhereInput diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 7833c7ccc..42acc0a86 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -297,6 +297,7 @@ var ( {Name: "hash", Type: field.TypeString, Size: 100}, {Name: "eldritch", Type: field.TypeString, SchemaType: map[string]string{"mysql": "LONGTEXT"}}, {Name: "tome_uploader", Type: field.TypeInt, Nullable: true}, + {Name: "tome_repository", Type: field.TypeInt, Nullable: true}, } // TomesTable holds the schema information for the "tomes" table. TomesTable = &schema.Table{ @@ -310,6 +311,12 @@ var ( RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, + { + Symbol: "tomes_repositories_repository", + Columns: []*schema.Column{TomesColumns[12]}, + RefColumns: []*schema.Column{RepositoriesColumns[0]}, + OnDelete: schema.SetNull, + }, }, } // UsersColumns holds the columns for the "users" table. @@ -414,6 +421,7 @@ func init() { TasksTable.ForeignKeys[0].RefTable = QuestsTable TasksTable.ForeignKeys[1].RefTable = BeaconsTable TomesTable.ForeignKeys[0].RefTable = UsersTable + TomesTable.ForeignKeys[1].RefTable = RepositoriesTable HostTagsTable.ForeignKeys[0].RefTable = HostsTable HostTagsTable.ForeignKeys[1].RefTable = TagsTable TomeFilesTable.ForeignKeys[0].RefTable = TomesTable diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 725db2398..3570b7e95 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -6501,6 +6501,9 @@ type RepositoryMutation struct { public_key *string private_key *string clearedFields map[string]struct{} + tomes map[int]struct{} + removedtomes map[int]struct{} + clearedtomes bool done bool oldValue func(context.Context) (*Repository, error) predicates []predicate.Repository @@ -6784,6 +6787,60 @@ func (m *RepositoryMutation) ResetPrivateKey() { m.private_key = nil } +// AddTomeIDs adds the "tomes" edge to the Tome entity by ids. +func (m *RepositoryMutation) AddTomeIDs(ids ...int) { + if m.tomes == nil { + m.tomes = make(map[int]struct{}) + } + for i := range ids { + m.tomes[ids[i]] = struct{}{} + } +} + +// ClearTomes clears the "tomes" edge to the Tome entity. +func (m *RepositoryMutation) ClearTomes() { + m.clearedtomes = true +} + +// TomesCleared reports if the "tomes" edge to the Tome entity was cleared. +func (m *RepositoryMutation) TomesCleared() bool { + return m.clearedtomes +} + +// RemoveTomeIDs removes the "tomes" edge to the Tome entity by IDs. +func (m *RepositoryMutation) RemoveTomeIDs(ids ...int) { + if m.removedtomes == nil { + m.removedtomes = make(map[int]struct{}) + } + for i := range ids { + delete(m.tomes, ids[i]) + m.removedtomes[ids[i]] = struct{}{} + } +} + +// RemovedTomes returns the removed IDs of the "tomes" edge to the Tome entity. +func (m *RepositoryMutation) RemovedTomesIDs() (ids []int) { + for id := range m.removedtomes { + ids = append(ids, id) + } + return +} + +// TomesIDs returns the "tomes" edge IDs in the mutation. +func (m *RepositoryMutation) TomesIDs() (ids []int) { + for id := range m.tomes { + ids = append(ids, id) + } + return +} + +// ResetTomes resets all changes to the "tomes" edge. +func (m *RepositoryMutation) ResetTomes() { + m.tomes = nil + m.clearedtomes = false + m.removedtomes = nil +} + // Where appends a list predicates to the RepositoryMutation builder. func (m *RepositoryMutation) Where(ps ...predicate.Repository) { m.predicates = append(m.predicates, ps...) @@ -6985,49 +7042,85 @@ func (m *RepositoryMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *RepositoryMutation) AddedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.tomes != nil { + edges = append(edges, repository.EdgeTomes) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *RepositoryMutation) AddedIDs(name string) []ent.Value { + switch name { + case repository.EdgeTomes: + ids := make([]ent.Value, 0, len(m.tomes)) + for id := range m.tomes { + ids = append(ids, id) + } + return ids + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *RepositoryMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.removedtomes != nil { + edges = append(edges, repository.EdgeTomes) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *RepositoryMutation) RemovedIDs(name string) []ent.Value { + switch name { + case repository.EdgeTomes: + ids := make([]ent.Value, 0, len(m.removedtomes)) + for id := range m.removedtomes { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *RepositoryMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) + edges := make([]string, 0, 1) + if m.clearedtomes { + edges = append(edges, repository.EdgeTomes) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *RepositoryMutation) EdgeCleared(name string) bool { + switch name { + case repository.EdgeTomes: + return m.clearedtomes + } 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 *RepositoryMutation) ClearEdge(name string) error { + switch name { + } return fmt.Errorf("unknown Repository 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 *RepositoryMutation) ResetEdge(name string) error { + switch name { + case repository.EdgeTomes: + m.ResetTomes() + return nil + } return fmt.Errorf("unknown Repository edge %s", name) } @@ -8722,28 +8815,30 @@ func (m *TaskMutation) ResetEdge(name string) error { // TomeMutation represents an operation that mutates the Tome nodes in the graph. type TomeMutation struct { config - op Op - typ string - id *int - created_at *time.Time - last_modified_at *time.Time - name *string - description *string - author *string - support_model *tome.SupportModel - tactic *tome.Tactic - param_defs *string - hash *string - eldritch *string - clearedFields map[string]struct{} - files map[int]struct{} - removedfiles map[int]struct{} - clearedfiles bool - uploader *int - cleareduploader bool - done bool - oldValue func(context.Context) (*Tome, error) - predicates []predicate.Tome + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + name *string + description *string + author *string + support_model *tome.SupportModel + tactic *tome.Tactic + param_defs *string + hash *string + eldritch *string + clearedFields map[string]struct{} + files map[int]struct{} + removedfiles map[int]struct{} + clearedfiles bool + uploader *int + cleareduploader bool + repository *int + clearedrepository bool + done bool + oldValue func(context.Context) (*Tome, error) + predicates []predicate.Tome } var _ ent.Mutation = (*TomeMutation)(nil) @@ -9310,6 +9405,45 @@ func (m *TomeMutation) ResetUploader() { m.cleareduploader = false } +// SetRepositoryID sets the "repository" edge to the Repository entity by id. +func (m *TomeMutation) SetRepositoryID(id int) { + m.repository = &id +} + +// ClearRepository clears the "repository" edge to the Repository entity. +func (m *TomeMutation) ClearRepository() { + m.clearedrepository = true +} + +// RepositoryCleared reports if the "repository" edge to the Repository entity was cleared. +func (m *TomeMutation) RepositoryCleared() bool { + return m.clearedrepository +} + +// RepositoryID returns the "repository" edge ID in the mutation. +func (m *TomeMutation) RepositoryID() (id int, exists bool) { + if m.repository != nil { + return *m.repository, true + } + return +} + +// RepositoryIDs returns the "repository" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RepositoryID instead. It exists only for internal usage by the builders. +func (m *TomeMutation) RepositoryIDs() (ids []int) { + if id := m.repository; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetRepository resets all changes to the "repository" edge. +func (m *TomeMutation) ResetRepository() { + m.repository = nil + m.clearedrepository = false +} + // Where appends a list predicates to the TomeMutation builder. func (m *TomeMutation) Where(ps ...predicate.Tome) { m.predicates = append(m.predicates, ps...) @@ -9605,13 +9739,16 @@ func (m *TomeMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TomeMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.files != nil { edges = append(edges, tome.EdgeFiles) } if m.uploader != nil { edges = append(edges, tome.EdgeUploader) } + if m.repository != nil { + edges = append(edges, tome.EdgeRepository) + } return edges } @@ -9629,13 +9766,17 @@ func (m *TomeMutation) AddedIDs(name string) []ent.Value { if id := m.uploader; id != nil { return []ent.Value{*id} } + case tome.EdgeRepository: + if id := m.repository; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *TomeMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.removedfiles != nil { edges = append(edges, tome.EdgeFiles) } @@ -9658,13 +9799,16 @@ func (m *TomeMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TomeMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearedfiles { edges = append(edges, tome.EdgeFiles) } if m.cleareduploader { edges = append(edges, tome.EdgeUploader) } + if m.clearedrepository { + edges = append(edges, tome.EdgeRepository) + } return edges } @@ -9676,6 +9820,8 @@ func (m *TomeMutation) EdgeCleared(name string) bool { return m.clearedfiles case tome.EdgeUploader: return m.cleareduploader + case tome.EdgeRepository: + return m.clearedrepository } return false } @@ -9687,6 +9833,9 @@ func (m *TomeMutation) ClearEdge(name string) error { case tome.EdgeUploader: m.ClearUploader() return nil + case tome.EdgeRepository: + m.ClearRepository() + return nil } return fmt.Errorf("unknown Tome unique edge %s", name) } @@ -9701,6 +9850,9 @@ func (m *TomeMutation) ResetEdge(name string) error { case tome.EdgeUploader: m.ResetUploader() return nil + case tome.EdgeRepository: + m.ResetRepository() + return nil } return fmt.Errorf("unknown Tome edge %s", name) } diff --git a/tavern/internal/ent/repository.go b/tavern/internal/ent/repository.go index da124bf14..f62a366fe 100644 --- a/tavern/internal/ent/repository.go +++ b/tavern/internal/ent/repository.go @@ -26,10 +26,35 @@ type Repository struct { // Public key associated with this repositories private key PublicKey string `json:"public_key,omitempty"` // Private key used for authentication. - PrivateKey string `json:"-"` + PrivateKey string `json:"-"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the RepositoryQuery when eager-loading is set. + Edges RepositoryEdges `json:"edges"` selectValues sql.SelectValues } +// RepositoryEdges holds the relations/edges for other nodes in the graph. +type RepositoryEdges struct { + // Tomes imported using this repository. + Tomes []*Tome `json:"tomes,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool + // totalCount holds the count of the edges above. + totalCount [1]map[string]int + + namedTomes map[string][]*Tome +} + +// TomesOrErr returns the Tomes value or an error if the edge +// was not loaded in eager-loading. +func (e RepositoryEdges) TomesOrErr() ([]*Tome, error) { + if e.loadedTypes[0] { + return e.Tomes, nil + } + return nil, &NotLoadedError{edge: "tomes"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Repository) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -105,6 +130,11 @@ func (r *Repository) Value(name string) (ent.Value, error) { return r.selectValues.Get(name) } +// QueryTomes queries the "tomes" edge of the Repository entity. +func (r *Repository) QueryTomes() *TomeQuery { + return NewRepositoryClient(r.config).QueryTomes(r) +} + // Update returns a builder for updating this Repository. // Note that you need to call Repository.Unwrap() before calling this method if this Repository // was returned from a transaction, and the transaction was committed or rolled back. @@ -145,5 +175,29 @@ func (r *Repository) String() string { return builder.String() } +// NamedTomes returns the Tomes named value or an error if the edge was not +// loaded in eager-loading with this name. +func (r *Repository) NamedTomes(name string) ([]*Tome, error) { + if r.Edges.namedTomes == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := r.Edges.namedTomes[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (r *Repository) appendNamedTomes(name string, edges ...*Tome) { + if r.Edges.namedTomes == nil { + r.Edges.namedTomes = make(map[string][]*Tome) + } + if len(edges) == 0 { + r.Edges.namedTomes[name] = []*Tome{} + } else { + r.Edges.namedTomes[name] = append(r.Edges.namedTomes[name], edges...) + } +} + // Repositories is a parsable slice of Repository. type Repositories []*Repository diff --git a/tavern/internal/ent/repository/repository.go b/tavern/internal/ent/repository/repository.go index 08f06a815..9e134a188 100644 --- a/tavern/internal/ent/repository/repository.go +++ b/tavern/internal/ent/repository/repository.go @@ -7,6 +7,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" ) const ( @@ -24,8 +25,17 @@ const ( FieldPublicKey = "public_key" // FieldPrivateKey holds the string denoting the private_key field in the database. FieldPrivateKey = "private_key" + // EdgeTomes holds the string denoting the tomes edge name in mutations. + EdgeTomes = "tomes" // Table holds the table name of the repository in the database. Table = "repositories" + // TomesTable is the table that holds the tomes relation/edge. + TomesTable = "tomes" + // TomesInverseTable is the table name for the Tome entity. + // It exists in this package in order to avoid circular dependency with the "tome" package. + TomesInverseTable = "tomes" + // TomesColumn is the table column denoting the tomes relation/edge. + TomesColumn = "tome_repository" ) // Columns holds all SQL columns for repository fields. @@ -63,6 +73,10 @@ var ( UpdateDefaultLastModifiedAt func() time.Time // URLValidator is a validator for the "url" field. It is called by the builders before save. URLValidator func(string) error + // PublicKeyValidator is a validator for the "public_key" field. It is called by the builders before save. + PublicKeyValidator func(string) error + // PrivateKeyValidator is a validator for the "private_key" field. It is called by the builders before save. + PrivateKeyValidator func(string) error ) // OrderOption defines the ordering options for the Repository queries. @@ -97,3 +111,24 @@ func ByPublicKey(opts ...sql.OrderTermOption) OrderOption { func ByPrivateKey(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPrivateKey, opts...).ToFunc() } + +// ByTomesCount orders the results by tomes count. +func ByTomesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newTomesStep(), opts...) + } +} + +// ByTomes orders the results by tomes terms. +func ByTomes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTomesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newTomesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TomesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, TomesTable, TomesColumn), + ) +} diff --git a/tavern/internal/ent/repository/where.go b/tavern/internal/ent/repository/where.go index 51462dd74..b3c49f260 100644 --- a/tavern/internal/ent/repository/where.go +++ b/tavern/internal/ent/repository/where.go @@ -6,6 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/predicate" ) @@ -354,6 +355,29 @@ func PrivateKeyContainsFold(v string) predicate.Repository { return predicate.Repository(sql.FieldContainsFold(FieldPrivateKey, v)) } +// HasTomes applies the HasEdge predicate on the "tomes" edge. +func HasTomes() predicate.Repository { + return predicate.Repository(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, TomesTable, TomesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTomesWith applies the HasEdge predicate on the "tomes" edge with a given conditions (other predicates). +func HasTomesWith(preds ...predicate.Tome) predicate.Repository { + return predicate.Repository(func(s *sql.Selector) { + step := newTomesStep() + 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.Repository) predicate.Repository { return predicate.Repository(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/repository_create.go b/tavern/internal/ent/repository_create.go index 9a3fb7d5d..477c87588 100644 --- a/tavern/internal/ent/repository_create.go +++ b/tavern/internal/ent/repository_create.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/tome" ) // RepositoryCreate is the builder for creating a Repository entity. @@ -68,6 +69,21 @@ func (rc *RepositoryCreate) SetPrivateKey(s string) *RepositoryCreate { return rc } +// AddTomeIDs adds the "tomes" edge to the Tome entity by IDs. +func (rc *RepositoryCreate) AddTomeIDs(ids ...int) *RepositoryCreate { + rc.mutation.AddTomeIDs(ids...) + return rc +} + +// AddTomes adds the "tomes" edges to the Tome entity. +func (rc *RepositoryCreate) AddTomes(t ...*Tome) *RepositoryCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return rc.AddTomeIDs(ids...) +} + // Mutation returns the RepositoryMutation object of the builder. func (rc *RepositoryCreate) Mutation() *RepositoryMutation { return rc.mutation @@ -141,9 +157,19 @@ func (rc *RepositoryCreate) check() error { if _, ok := rc.mutation.PublicKey(); !ok { return &ValidationError{Name: "public_key", err: errors.New(`ent: missing required field "Repository.public_key"`)} } + if v, ok := rc.mutation.PublicKey(); ok { + if err := repository.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "public_key", err: fmt.Errorf(`ent: validator failed for field "Repository.public_key": %w`, err)} + } + } if _, ok := rc.mutation.PrivateKey(); !ok { return &ValidationError{Name: "private_key", err: errors.New(`ent: missing required field "Repository.private_key"`)} } + if v, ok := rc.mutation.PrivateKey(); ok { + if err := repository.PrivateKeyValidator(v); err != nil { + return &ValidationError{Name: "private_key", err: fmt.Errorf(`ent: validator failed for field "Repository.private_key": %w`, err)} + } + } return nil } @@ -191,6 +217,22 @@ func (rc *RepositoryCreate) createSpec() (*Repository, *sqlgraph.CreateSpec) { _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) _node.PrivateKey = value } + if nodes := rc.mutation.TomesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/repository_query.go b/tavern/internal/ent/repository_query.go index d5766e1c5..52ffbcf19 100644 --- a/tavern/internal/ent/repository_query.go +++ b/tavern/internal/ent/repository_query.go @@ -4,6 +4,7 @@ package ent import ( "context" + "database/sql/driver" "fmt" "math" @@ -12,17 +13,20 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/tome" ) // RepositoryQuery is the builder for querying Repository entities. type RepositoryQuery struct { config - ctx *QueryContext - order []repository.OrderOption - inters []Interceptor - predicates []predicate.Repository - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Repository) error + ctx *QueryContext + order []repository.OrderOption + inters []Interceptor + predicates []predicate.Repository + withTomes *TomeQuery + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Repository) error + withNamedTomes map[string]*TomeQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -59,6 +63,28 @@ func (rq *RepositoryQuery) Order(o ...repository.OrderOption) *RepositoryQuery { return rq } +// QueryTomes chains the current query on the "tomes" edge. +func (rq *RepositoryQuery) QueryTomes() *TomeQuery { + query := (&TomeClient{config: rq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := rq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := rq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(repository.Table, repository.FieldID, selector), + sqlgraph.To(tome.Table, tome.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, repository.TomesTable, repository.TomesColumn), + ) + fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Repository entity from the query. // Returns a *NotFoundError when no Repository was found. func (rq *RepositoryQuery) First(ctx context.Context) (*Repository, error) { @@ -251,12 +277,24 @@ func (rq *RepositoryQuery) Clone() *RepositoryQuery { order: append([]repository.OrderOption{}, rq.order...), inters: append([]Interceptor{}, rq.inters...), predicates: append([]predicate.Repository{}, rq.predicates...), + withTomes: rq.withTomes.Clone(), // clone intermediate query. sql: rq.sql.Clone(), path: rq.path, } } +// WithTomes tells the query-builder to eager-load the nodes that are connected to +// the "tomes" edge. The optional arguments are used to configure the query builder of the edge. +func (rq *RepositoryQuery) WithTomes(opts ...func(*TomeQuery)) *RepositoryQuery { + query := (&TomeClient{config: rq.config}).Query() + for _, opt := range opts { + opt(query) + } + rq.withTomes = query + return rq +} + // 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. // @@ -333,8 +371,11 @@ func (rq *RepositoryQuery) prepareQuery(ctx context.Context) error { func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Repository, error) { var ( - nodes = []*Repository{} - _spec = rq.querySpec() + nodes = []*Repository{} + _spec = rq.querySpec() + loadedTypes = [1]bool{ + rq.withTomes != nil, + } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Repository).scanValues(nil, columns) @@ -342,6 +383,7 @@ func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*R _spec.Assign = func(columns []string, values []any) error { node := &Repository{config: rq.config} nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } if len(rq.modifiers) > 0 { @@ -356,6 +398,20 @@ func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*R if len(nodes) == 0 { return nodes, nil } + if query := rq.withTomes; query != nil { + if err := rq.loadTomes(ctx, query, nodes, + func(n *Repository) { n.Edges.Tomes = []*Tome{} }, + func(n *Repository, e *Tome) { n.Edges.Tomes = append(n.Edges.Tomes, e) }); err != nil { + return nil, err + } + } + for name, query := range rq.withNamedTomes { + if err := rq.loadTomes(ctx, query, nodes, + func(n *Repository) { n.appendNamedTomes(name) }, + func(n *Repository, e *Tome) { n.appendNamedTomes(name, e) }); err != nil { + return nil, err + } + } for i := range rq.loadTotal { if err := rq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -364,6 +420,38 @@ func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*R return nodes, nil } +func (rq *RepositoryQuery) loadTomes(ctx context.Context, query *TomeQuery, nodes []*Repository, init func(*Repository), assign func(*Repository, *Tome)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Repository) + 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.Tome(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(repository.TomesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.tome_repository + if fk == nil { + return fmt.Errorf(`foreign-key "tome_repository" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "tome_repository" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + func (rq *RepositoryQuery) sqlCount(ctx context.Context) (int, error) { _spec := rq.querySpec() if len(rq.modifiers) > 0 { @@ -448,6 +536,20 @@ func (rq *RepositoryQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// WithNamedTomes tells the query-builder to eager-load the nodes that are connected to the "tomes" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (rq *RepositoryQuery) WithNamedTomes(name string, opts ...func(*TomeQuery)) *RepositoryQuery { + query := (&TomeClient{config: rq.config}).Query() + for _, opt := range opts { + opt(query) + } + if rq.withNamedTomes == nil { + rq.withNamedTomes = make(map[string]*TomeQuery) + } + rq.withNamedTomes[name] = query + return rq +} + // RepositoryGroupBy is the group-by builder for Repository entities. type RepositoryGroupBy struct { selector diff --git a/tavern/internal/ent/repository_update.go b/tavern/internal/ent/repository_update.go index 8a178b004..284adc133 100644 --- a/tavern/internal/ent/repository_update.go +++ b/tavern/internal/ent/repository_update.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/tome" ) // RepositoryUpdate is the builder for updating Repository entities. @@ -52,11 +53,47 @@ func (ru *RepositoryUpdate) SetPrivateKey(s string) *RepositoryUpdate { return ru } +// AddTomeIDs adds the "tomes" edge to the Tome entity by IDs. +func (ru *RepositoryUpdate) AddTomeIDs(ids ...int) *RepositoryUpdate { + ru.mutation.AddTomeIDs(ids...) + return ru +} + +// AddTomes adds the "tomes" edges to the Tome entity. +func (ru *RepositoryUpdate) AddTomes(t ...*Tome) *RepositoryUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ru.AddTomeIDs(ids...) +} + // Mutation returns the RepositoryMutation object of the builder. func (ru *RepositoryUpdate) Mutation() *RepositoryMutation { return ru.mutation } +// ClearTomes clears all "tomes" edges to the Tome entity. +func (ru *RepositoryUpdate) ClearTomes() *RepositoryUpdate { + ru.mutation.ClearTomes() + return ru +} + +// RemoveTomeIDs removes the "tomes" edge to Tome entities by IDs. +func (ru *RepositoryUpdate) RemoveTomeIDs(ids ...int) *RepositoryUpdate { + ru.mutation.RemoveTomeIDs(ids...) + return ru +} + +// RemoveTomes removes "tomes" edges to Tome entities. +func (ru *RepositoryUpdate) RemoveTomes(t ...*Tome) *RepositoryUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ru.RemoveTomeIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (ru *RepositoryUpdate) Save(ctx context.Context) (int, error) { if err := ru.defaults(); err != nil { @@ -106,6 +143,16 @@ func (ru *RepositoryUpdate) check() error { return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Repository.url": %w`, err)} } } + if v, ok := ru.mutation.PublicKey(); ok { + if err := repository.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "public_key", err: fmt.Errorf(`ent: validator failed for field "Repository.public_key": %w`, err)} + } + } + if v, ok := ru.mutation.PrivateKey(); ok { + if err := repository.PrivateKeyValidator(v); err != nil { + return &ValidationError{Name: "private_key", err: fmt.Errorf(`ent: validator failed for field "Repository.private_key": %w`, err)} + } + } return nil } @@ -133,6 +180,51 @@ func (ru *RepositoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := ru.mutation.PrivateKey(); ok { _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) } + if ru.mutation.TomesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ru.mutation.RemovedTomesIDs(); len(nodes) > 0 && !ru.mutation.TomesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ru.mutation.TomesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{repository.Label} @@ -177,11 +269,47 @@ func (ruo *RepositoryUpdateOne) SetPrivateKey(s string) *RepositoryUpdateOne { return ruo } +// AddTomeIDs adds the "tomes" edge to the Tome entity by IDs. +func (ruo *RepositoryUpdateOne) AddTomeIDs(ids ...int) *RepositoryUpdateOne { + ruo.mutation.AddTomeIDs(ids...) + return ruo +} + +// AddTomes adds the "tomes" edges to the Tome entity. +func (ruo *RepositoryUpdateOne) AddTomes(t ...*Tome) *RepositoryUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ruo.AddTomeIDs(ids...) +} + // Mutation returns the RepositoryMutation object of the builder. func (ruo *RepositoryUpdateOne) Mutation() *RepositoryMutation { return ruo.mutation } +// ClearTomes clears all "tomes" edges to the Tome entity. +func (ruo *RepositoryUpdateOne) ClearTomes() *RepositoryUpdateOne { + ruo.mutation.ClearTomes() + return ruo +} + +// RemoveTomeIDs removes the "tomes" edge to Tome entities by IDs. +func (ruo *RepositoryUpdateOne) RemoveTomeIDs(ids ...int) *RepositoryUpdateOne { + ruo.mutation.RemoveTomeIDs(ids...) + return ruo +} + +// RemoveTomes removes "tomes" edges to Tome entities. +func (ruo *RepositoryUpdateOne) RemoveTomes(t ...*Tome) *RepositoryUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ruo.RemoveTomeIDs(ids...) +} + // Where appends a list predicates to the RepositoryUpdate builder. func (ruo *RepositoryUpdateOne) Where(ps ...predicate.Repository) *RepositoryUpdateOne { ruo.mutation.Where(ps...) @@ -244,6 +372,16 @@ func (ruo *RepositoryUpdateOne) check() error { return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Repository.url": %w`, err)} } } + if v, ok := ruo.mutation.PublicKey(); ok { + if err := repository.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "public_key", err: fmt.Errorf(`ent: validator failed for field "Repository.public_key": %w`, err)} + } + } + if v, ok := ruo.mutation.PrivateKey(); ok { + if err := repository.PrivateKeyValidator(v); err != nil { + return &ValidationError{Name: "private_key", err: fmt.Errorf(`ent: validator failed for field "Repository.private_key": %w`, err)} + } + } return nil } @@ -288,6 +426,51 @@ func (ruo *RepositoryUpdateOne) sqlSave(ctx context.Context) (_node *Repository, if value, ok := ruo.mutation.PrivateKey(); ok { _spec.SetField(repository.FieldPrivateKey, field.TypeString, value) } + if ruo.mutation.TomesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ruo.mutation.RemovedTomesIDs(); len(nodes) > 0 && !ruo.mutation.TomesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ruo.mutation.TomesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: repository.TomesTable, + Columns: []string{repository.TomesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tome.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Repository{config: ruo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 7f0a58694..42209f60b 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -230,6 +230,14 @@ func init() { repositoryDescURL := repositoryFields[0].Descriptor() // repository.URLValidator is a validator for the "url" field. It is called by the builders before save. repository.URLValidator = repositoryDescURL.Validators[0].(func(string) error) + // repositoryDescPublicKey is the schema descriptor for public_key field. + repositoryDescPublicKey := repositoryFields[1].Descriptor() + // repository.PublicKeyValidator is a validator for the "public_key" field. It is called by the builders before save. + repository.PublicKeyValidator = repositoryDescPublicKey.Validators[0].(func(string) error) + // repositoryDescPrivateKey is the schema descriptor for private_key field. + repositoryDescPrivateKey := repositoryFields[2].Descriptor() + // repository.PrivateKeyValidator is a validator for the "private_key" field. It is called by the builders before save. + repository.PrivateKeyValidator = repositoryDescPrivateKey.Validators[0].(func(string) error) tagFields := schema.Tag{}.Fields() _ = tagFields // tagDescName is the schema descriptor for name field. diff --git a/tavern/internal/ent/schema/repository.go b/tavern/internal/ent/schema/repository.go index b60501922..ee8e2251a 100644 --- a/tavern/internal/ent/schema/repository.go +++ b/tavern/internal/ent/schema/repository.go @@ -4,12 +4,14 @@ import ( "context" "crypto/ed25519" "crypto/rand" + "encoding/pem" "fmt" "strings" "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "golang.org/x/crypto/ssh" "realm.pub/tavern/internal/ent/hook" @@ -28,11 +30,13 @@ func (Repository) Fields() []ent.Field { Unique(). Comment("URL of the repository"), field.String("public_key"). + NotEmpty(). Annotations( entgql.Skip(entgql.SkipMutationCreateInput | entgql.SkipMutationUpdateInput), ). Comment("Public key associated with this repositories private key"), field.String("private_key"). + NotEmpty(). Sensitive(). Annotations( entgql.Skip(entgql.SkipAll), @@ -43,7 +47,14 @@ func (Repository) Fields() []ent.Field { // Edges of the ent. func (Repository) Edges() []ent.Edge { - return []ent.Edge{} + return []ent.Edge{ + edge.From("tomes", Tome.Type). + Ref("repository"). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput, entgql.SkipMutationUpdateInput), + ). + Comment("Tomes imported using this repository."), + } } // Annotations describes additional information for the ent. @@ -69,7 +80,7 @@ func (Repository) Hooks() []ent.Hook { } } -// HookCreateRepoPrivateKey will update tome info (e.g. hash) whenever it is mutated. +// HookCreateRepoPrivateKey will generate private key for the repository upon creation. func HookCreateRepoPrivateKey() ent.Hook { // Get the relevant methods from the Mutation // See this example: https://github.com/ent/ent/blob/master/entc/integration/hooks/ent/schema/user.go#L98 @@ -110,12 +121,13 @@ func HookCreateRepoPrivateKey() ent.Hook { if err != nil { return nil, fmt.Errorf("could not convert private key to ssh signer: %v", err) } + block, err := ssh.MarshalPrivateKey(privKey, "") if err != nil || block == nil { return nil, fmt.Errorf("failed to marshal ssh private key: %w", err) } - mut.SetPrivateKey(string(block.Bytes)) + mut.SetPrivateKey(string(pem.EncodeToMemory(block))) mut.SetPublicKey(string(ssh.MarshalAuthorizedKey(signer.PublicKey()))) return next.Mutate(ctx, m) diff --git a/tavern/internal/ent/schema/tome.go b/tavern/internal/ent/schema/tome.go index 0b455950a..5cbb25237 100644 --- a/tavern/internal/ent/schema/tome.go +++ b/tavern/internal/ent/schema/tome.go @@ -90,6 +90,12 @@ func (Tome) Edges() []ent.Edge { entgql.Skip(entgql.SkipMutationCreateInput, entgql.SkipMutationUpdateInput), ). Comment("User who uploaded the tome (may be null)."), + edge.To("repository", Repository.Type). + Unique(). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput, entgql.SkipMutationUpdateInput), + ). + Comment("Repository from which this Tome was imported (may be null)."), } } diff --git a/tavern/internal/ent/tome.go b/tavern/internal/ent/tome.go index dfba08795..19b1eedff 100644 --- a/tavern/internal/ent/tome.go +++ b/tavern/internal/ent/tome.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" "realm.pub/tavern/internal/ent/user" ) @@ -40,9 +41,10 @@ type Tome struct { Eldritch string `json:"eldritch,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TomeQuery when eager-loading is set. - Edges TomeEdges `json:"edges"` - tome_uploader *int - selectValues sql.SelectValues + Edges TomeEdges `json:"edges"` + tome_uploader *int + tome_repository *int + selectValues sql.SelectValues } // TomeEdges holds the relations/edges for other nodes in the graph. @@ -51,11 +53,13 @@ type TomeEdges struct { Files []*File `json:"files,omitempty"` // User who uploaded the tome (may be null). Uploader *User `json:"uploader,omitempty"` + // Repository from which this Tome was imported (may be null). + Repository *Repository `json:"repository,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [3]bool // totalCount holds the count of the edges above. - totalCount [2]map[string]int + totalCount [3]map[string]int namedFiles map[string][]*File } @@ -82,6 +86,19 @@ func (e TomeEdges) UploaderOrErr() (*User, error) { return nil, &NotLoadedError{edge: "uploader"} } +// RepositoryOrErr returns the Repository value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e TomeEdges) RepositoryOrErr() (*Repository, error) { + if e.loadedTypes[2] { + if e.Repository == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: repository.Label} + } + return e.Repository, nil + } + return nil, &NotLoadedError{edge: "repository"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Tome) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -95,6 +112,8 @@ func (*Tome) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullTime) case tome.ForeignKeys[0]: // tome_uploader values[i] = new(sql.NullInt64) + case tome.ForeignKeys[1]: // tome_repository + values[i] = new(sql.NullInt64) default: values[i] = new(sql.UnknownType) } @@ -183,6 +202,13 @@ func (t *Tome) assignValues(columns []string, values []any) error { t.tome_uploader = new(int) *t.tome_uploader = int(value.Int64) } + case tome.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field tome_repository", value) + } else if value.Valid { + t.tome_repository = new(int) + *t.tome_repository = int(value.Int64) + } default: t.selectValues.Set(columns[i], values[i]) } @@ -206,6 +232,11 @@ func (t *Tome) QueryUploader() *UserQuery { return NewTomeClient(t.config).QueryUploader(t) } +// QueryRepository queries the "repository" edge of the Tome entity. +func (t *Tome) QueryRepository() *RepositoryQuery { + return NewTomeClient(t.config).QueryRepository(t) +} + // Update returns a builder for updating this Tome. // Note that you need to call Tome.Unwrap() before calling this method if this Tome // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/tavern/internal/ent/tome/tome.go b/tavern/internal/ent/tome/tome.go index c5029cb58..a35367e5a 100644 --- a/tavern/internal/ent/tome/tome.go +++ b/tavern/internal/ent/tome/tome.go @@ -42,6 +42,8 @@ const ( EdgeFiles = "files" // EdgeUploader holds the string denoting the uploader edge name in mutations. EdgeUploader = "uploader" + // EdgeRepository holds the string denoting the repository edge name in mutations. + EdgeRepository = "repository" // Table holds the table name of the tome in the database. Table = "tomes" // FilesTable is the table that holds the files relation/edge. The primary key declared below. @@ -56,6 +58,13 @@ const ( UploaderInverseTable = "users" // UploaderColumn is the table column denoting the uploader relation/edge. UploaderColumn = "tome_uploader" + // RepositoryTable is the table that holds the repository relation/edge. + RepositoryTable = "tomes" + // RepositoryInverseTable is the table name for the Repository entity. + // It exists in this package in order to avoid circular dependency with the "repository" package. + RepositoryInverseTable = "repositories" + // RepositoryColumn is the table column denoting the repository relation/edge. + RepositoryColumn = "tome_repository" ) // Columns holds all SQL columns for tome fields. @@ -77,6 +86,7 @@ var Columns = []string{ // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "tome_uploader", + "tome_repository", } var ( @@ -265,6 +275,13 @@ func ByUploaderField(field string, opts ...sql.OrderTermOption) OrderOption { sqlgraph.OrderByNeighborTerms(s, newUploaderStep(), sql.OrderByField(field, opts...)) } } + +// ByRepositoryField orders the results by repository field. +func ByRepositoryField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRepositoryStep(), sql.OrderByField(field, opts...)) + } +} func newFilesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -279,6 +296,13 @@ func newUploaderStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, false, UploaderTable, UploaderColumn), ) } +func newRepositoryStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RepositoryInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RepositoryTable, RepositoryColumn), + ) +} // MarshalGQL implements graphql.Marshaler interface. func (e SupportModel) MarshalGQL(w io.Writer) { diff --git a/tavern/internal/ent/tome/where.go b/tavern/internal/ent/tome/where.go index bef67df1c..16e4c2217 100644 --- a/tavern/internal/ent/tome/where.go +++ b/tavern/internal/ent/tome/where.go @@ -661,6 +661,29 @@ func HasUploaderWith(preds ...predicate.User) predicate.Tome { }) } +// HasRepository applies the HasEdge predicate on the "repository" edge. +func HasRepository() predicate.Tome { + return predicate.Tome(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RepositoryTable, RepositoryColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRepositoryWith applies the HasEdge predicate on the "repository" edge with a given conditions (other predicates). +func HasRepositoryWith(preds ...predicate.Repository) predicate.Tome { + return predicate.Tome(func(s *sql.Selector) { + step := newRepositoryStep() + 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.Tome) predicate.Tome { return predicate.Tome(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/tome_create.go b/tavern/internal/ent/tome_create.go index 01665df67..8bd826975 100644 --- a/tavern/internal/ent/tome_create.go +++ b/tavern/internal/ent/tome_create.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/file" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" "realm.pub/tavern/internal/ent/user" ) @@ -158,6 +159,25 @@ func (tc *TomeCreate) SetUploader(u *User) *TomeCreate { return tc.SetUploaderID(u.ID) } +// SetRepositoryID sets the "repository" edge to the Repository entity by ID. +func (tc *TomeCreate) SetRepositoryID(id int) *TomeCreate { + tc.mutation.SetRepositoryID(id) + return tc +} + +// SetNillableRepositoryID sets the "repository" edge to the Repository entity by ID if the given value is not nil. +func (tc *TomeCreate) SetNillableRepositoryID(id *int) *TomeCreate { + if id != nil { + tc = tc.SetRepositoryID(*id) + } + return tc +} + +// SetRepository sets the "repository" edge to the Repository entity. +func (tc *TomeCreate) SetRepository(r *Repository) *TomeCreate { + return tc.SetRepositoryID(r.ID) +} + // Mutation returns the TomeMutation object of the builder. func (tc *TomeCreate) Mutation() *TomeMutation { return tc.mutation @@ -374,6 +394,23 @@ func (tc *TomeCreate) createSpec() (*Tome, *sqlgraph.CreateSpec) { _node.tome_uploader = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.RepositoryIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: tome.RepositoryTable, + Columns: []string{tome.RepositoryColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.tome_repository = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/tome_query.go b/tavern/internal/ent/tome_query.go index 935452e7f..9d8d81e45 100644 --- a/tavern/internal/ent/tome_query.go +++ b/tavern/internal/ent/tome_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" "realm.pub/tavern/internal/ent/user" ) @@ -26,6 +27,7 @@ type TomeQuery struct { predicates []predicate.Tome withFiles *FileQuery withUploader *UserQuery + withRepository *RepositoryQuery withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Tome) error @@ -110,6 +112,28 @@ func (tq *TomeQuery) QueryUploader() *UserQuery { return query } +// QueryRepository chains the current query on the "repository" edge. +func (tq *TomeQuery) QueryRepository() *RepositoryQuery { + query := (&RepositoryClient{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(tome.Table, tome.FieldID, selector), + sqlgraph.To(repository.Table, repository.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, tome.RepositoryTable, tome.RepositoryColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Tome entity from the query. // Returns a *NotFoundError when no Tome was found. func (tq *TomeQuery) First(ctx context.Context) (*Tome, error) { @@ -297,13 +321,14 @@ func (tq *TomeQuery) Clone() *TomeQuery { return nil } return &TomeQuery{ - config: tq.config, - ctx: tq.ctx.Clone(), - order: append([]tome.OrderOption{}, tq.order...), - inters: append([]Interceptor{}, tq.inters...), - predicates: append([]predicate.Tome{}, tq.predicates...), - withFiles: tq.withFiles.Clone(), - withUploader: tq.withUploader.Clone(), + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]tome.OrderOption{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Tome{}, tq.predicates...), + withFiles: tq.withFiles.Clone(), + withUploader: tq.withUploader.Clone(), + withRepository: tq.withRepository.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, @@ -332,6 +357,17 @@ func (tq *TomeQuery) WithUploader(opts ...func(*UserQuery)) *TomeQuery { return tq } +// WithRepository tells the query-builder to eager-load the nodes that are connected to +// the "repository" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TomeQuery) WithRepository(opts ...func(*RepositoryQuery)) *TomeQuery { + query := (&RepositoryClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withRepository = 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. // @@ -411,12 +447,13 @@ func (tq *TomeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tome, e nodes = []*Tome{} withFKs = tq.withFKs _spec = tq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [3]bool{ tq.withFiles != nil, tq.withUploader != nil, + tq.withRepository != nil, } ) - if tq.withUploader != nil { + if tq.withUploader != nil || tq.withRepository != nil { withFKs = true } if withFKs { @@ -456,6 +493,12 @@ func (tq *TomeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tome, e return nil, err } } + if query := tq.withRepository; query != nil { + if err := tq.loadRepository(ctx, query, nodes, nil, + func(n *Tome, e *Repository) { n.Edges.Repository = e }); err != nil { + return nil, err + } + } for name, query := range tq.withNamedFiles { if err := tq.loadFiles(ctx, query, nodes, func(n *Tome) { n.appendNamedFiles(name) }, @@ -564,6 +607,38 @@ func (tq *TomeQuery) loadUploader(ctx context.Context, query *UserQuery, nodes [ } return nil } +func (tq *TomeQuery) loadRepository(ctx context.Context, query *RepositoryQuery, nodes []*Tome, init func(*Tome), assign func(*Tome, *Repository)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Tome) + for i := range nodes { + if nodes[i].tome_repository == nil { + continue + } + fk := *nodes[i].tome_repository + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(repository.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 "tome_repository" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} func (tq *TomeQuery) sqlCount(ctx context.Context) (int, error) { _spec := tq.querySpec() diff --git a/tavern/internal/ent/tome_update.go b/tavern/internal/ent/tome_update.go index b6bf03bb6..deded9ff5 100644 --- a/tavern/internal/ent/tome_update.go +++ b/tavern/internal/ent/tome_update.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" "realm.pub/tavern/internal/ent/user" ) @@ -148,6 +149,25 @@ func (tu *TomeUpdate) SetUploader(u *User) *TomeUpdate { return tu.SetUploaderID(u.ID) } +// SetRepositoryID sets the "repository" edge to the Repository entity by ID. +func (tu *TomeUpdate) SetRepositoryID(id int) *TomeUpdate { + tu.mutation.SetRepositoryID(id) + return tu +} + +// SetNillableRepositoryID sets the "repository" edge to the Repository entity by ID if the given value is not nil. +func (tu *TomeUpdate) SetNillableRepositoryID(id *int) *TomeUpdate { + if id != nil { + tu = tu.SetRepositoryID(*id) + } + return tu +} + +// SetRepository sets the "repository" edge to the Repository entity. +func (tu *TomeUpdate) SetRepository(r *Repository) *TomeUpdate { + return tu.SetRepositoryID(r.ID) +} + // Mutation returns the TomeMutation object of the builder. func (tu *TomeUpdate) Mutation() *TomeMutation { return tu.mutation @@ -180,6 +200,12 @@ func (tu *TomeUpdate) ClearUploader() *TomeUpdate { return tu } +// ClearRepository clears the "repository" edge to the Repository entity. +func (tu *TomeUpdate) ClearRepository() *TomeUpdate { + tu.mutation.ClearRepository() + return tu +} + // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TomeUpdate) Save(ctx context.Context) (int, error) { if err := tu.defaults(); err != nil { @@ -368,6 +394,35 @@ func (tu *TomeUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.RepositoryCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: tome.RepositoryTable, + Columns: []string{tome.RepositoryColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RepositoryIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: tome.RepositoryTable, + Columns: []string{tome.RepositoryColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{tome.Label} @@ -506,6 +561,25 @@ func (tuo *TomeUpdateOne) SetUploader(u *User) *TomeUpdateOne { return tuo.SetUploaderID(u.ID) } +// SetRepositoryID sets the "repository" edge to the Repository entity by ID. +func (tuo *TomeUpdateOne) SetRepositoryID(id int) *TomeUpdateOne { + tuo.mutation.SetRepositoryID(id) + return tuo +} + +// SetNillableRepositoryID sets the "repository" edge to the Repository entity by ID if the given value is not nil. +func (tuo *TomeUpdateOne) SetNillableRepositoryID(id *int) *TomeUpdateOne { + if id != nil { + tuo = tuo.SetRepositoryID(*id) + } + return tuo +} + +// SetRepository sets the "repository" edge to the Repository entity. +func (tuo *TomeUpdateOne) SetRepository(r *Repository) *TomeUpdateOne { + return tuo.SetRepositoryID(r.ID) +} + // Mutation returns the TomeMutation object of the builder. func (tuo *TomeUpdateOne) Mutation() *TomeMutation { return tuo.mutation @@ -538,6 +612,12 @@ func (tuo *TomeUpdateOne) ClearUploader() *TomeUpdateOne { return tuo } +// ClearRepository clears the "repository" edge to the Repository entity. +func (tuo *TomeUpdateOne) ClearRepository() *TomeUpdateOne { + tuo.mutation.ClearRepository() + return tuo +} + // Where appends a list predicates to the TomeUpdate builder. func (tuo *TomeUpdateOne) Where(ps ...predicate.Tome) *TomeUpdateOne { tuo.mutation.Where(ps...) @@ -756,6 +836,35 @@ func (tuo *TomeUpdateOne) sqlSave(ctx context.Context) (_node *Tome, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.RepositoryCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: tome.RepositoryTable, + Columns: []string{tome.RepositoryColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RepositoryIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: tome.RepositoryTable, + Columns: []string{tome.RepositoryColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(repository.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Tome{config: tuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index ed51f3ea7..8310e36e2 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -1172,6 +1172,8 @@ func (ec *executionContext) fieldContext_File_tomes(ctx context.Context, field g return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -4466,6 +4468,8 @@ func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -5044,6 +5048,8 @@ func (ec *executionContext) fieldContext_Quest_tome(ctx context.Context, field g return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -5454,6 +5460,75 @@ func (ec *executionContext) fieldContext_Repository_publicKey(ctx context.Contex return fc, nil } +func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_tomes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Tomes(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Tome) + fc.Result = res + return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Repository", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "files": + return ec.fieldContext_Tome_files(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_RepositoryConnection_edges(ctx, field) if err != nil { @@ -5645,6 +5720,8 @@ func (ec *executionContext) fieldContext_RepositoryEdge_node(ctx context.Context return ec.fieldContext_Repository_url(ctx, field) case "publicKey": return ec.fieldContext_Repository_publicKey(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, @@ -7414,6 +7491,61 @@ func (ec *executionContext) fieldContext_Tome_uploader(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_repository(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Repository(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.Repository) + fc.Result = res + return ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_repository(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { @@ -7694,6 +7826,8 @@ func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field g return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -8784,7 +8918,7 @@ func (ec *executionContext) unmarshalInputCreateRepositoryInput(ctx context.Cont asMap[k] = v } - fieldsInOrder := [...]string{"url"} + fieldsInOrder := [...]string{"url", "tomeIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8800,6 +8934,15 @@ func (ec *executionContext) unmarshalInputCreateRepositoryInput(ctx context.Cont return it, err } it.URL = data + case "tomeIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.TomeIDs = data } } @@ -14136,7 +14279,7 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold", "hasTomes", "hasTomesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -14620,6 +14763,24 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte return it, err } it.PublicKeyContainsFold = data + case "hasTomes": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTomesWith = data } } @@ -16014,7 +16175,7 @@ func (ec *executionContext) unmarshalInputTomeWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionEqualFold", "descriptionContainsFold", "author", "authorNEQ", "authorIn", "authorNotIn", "authorGT", "authorGTE", "authorLT", "authorLTE", "authorContains", "authorHasPrefix", "authorHasSuffix", "authorEqualFold", "authorContainsFold", "supportModel", "supportModelNEQ", "supportModelIn", "supportModelNotIn", "tactic", "tacticNEQ", "tacticIn", "tacticNotIn", "paramDefs", "paramDefsNEQ", "paramDefsIn", "paramDefsNotIn", "paramDefsGT", "paramDefsGTE", "paramDefsLT", "paramDefsLTE", "paramDefsContains", "paramDefsHasPrefix", "paramDefsHasSuffix", "paramDefsIsNil", "paramDefsNotNil", "paramDefsEqualFold", "paramDefsContainsFold", "eldritch", "eldritchNEQ", "eldritchIn", "eldritchNotIn", "eldritchGT", "eldritchGTE", "eldritchLT", "eldritchLTE", "eldritchContains", "eldritchHasPrefix", "eldritchHasSuffix", "eldritchEqualFold", "eldritchContainsFold", "hasFiles", "hasFilesWith", "hasUploader", "hasUploaderWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionEqualFold", "descriptionContainsFold", "author", "authorNEQ", "authorIn", "authorNotIn", "authorGT", "authorGTE", "authorLT", "authorLTE", "authorContains", "authorHasPrefix", "authorHasSuffix", "authorEqualFold", "authorContainsFold", "supportModel", "supportModelNEQ", "supportModelIn", "supportModelNotIn", "tactic", "tacticNEQ", "tacticIn", "tacticNotIn", "paramDefs", "paramDefsNEQ", "paramDefsIn", "paramDefsNotIn", "paramDefsGT", "paramDefsGTE", "paramDefsLT", "paramDefsLTE", "paramDefsContains", "paramDefsHasPrefix", "paramDefsHasSuffix", "paramDefsIsNil", "paramDefsNotNil", "paramDefsEqualFold", "paramDefsContainsFold", "eldritch", "eldritchNEQ", "eldritchIn", "eldritchNotIn", "eldritchGT", "eldritchGTE", "eldritchLT", "eldritchLTE", "eldritchContains", "eldritchHasPrefix", "eldritchHasSuffix", "eldritchEqualFold", "eldritchContainsFold", "hasFiles", "hasFilesWith", "hasUploader", "hasUploaderWith", "hasRepository", "hasRepositoryWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -16975,6 +17136,24 @@ func (ec *executionContext) unmarshalInputTomeWhereInput(ctx context.Context, ob return it, err } it.HasUploaderWith = data + case "hasRepository": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasRepository")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasRepository = data + case "hasRepositoryWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasRepositoryWith")) + data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasRepositoryWith = data } } @@ -19417,28 +19596,61 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe case "id": out.Values[i] = ec._Repository_id(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": out.Values[i] = ec._Repository_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "lastModifiedAt": out.Values[i] = ec._Repository_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "url": out.Values[i] = ec._Repository_url(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) } case "publicKey": out.Values[i] = ec._Repository_publicKey(ctx, field, obj) if out.Values[i] == graphql.Null { - out.Invalids++ + atomic.AddUint32(&out.Invalids, 1) + } + case "tomes": + 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._Repository_tomes(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) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -20076,6 +20288,39 @@ func (ec *executionContext) _Tome(ctx context.Context, sel ast.SelectionSet, obj continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "repository": + 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._Tome_repository(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) }) default: panic("unknown field " + strconv.Quote(field.Name)) diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 9f8903549..e653a2fa6 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -911,6 +911,8 @@ func (ec *executionContext) fieldContext_Mutation_createTome(ctx context.Context return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -1016,6 +1018,8 @@ func (ec *executionContext) fieldContext_Mutation_updateTome(ctx context.Context return ec.fieldContext_Tome_files(ctx, field) case "uploader": return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, @@ -1186,6 +1190,8 @@ func (ec *executionContext) fieldContext_Mutation_createRepository(ctx context.C return ec.fieldContext_Repository_url(ctx, field) case "publicKey": return ec.fieldContext_Repository_publicKey(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, @@ -1277,6 +1283,8 @@ func (ec *executionContext) fieldContext_Mutation_importRepository(ctx context.C return ec.fieldContext_Repository_url(ctx, field) case "publicKey": return ec.fieldContext_Repository_publicKey(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 61687a0fc..b9aedb363 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -180,6 +180,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int LastModifiedAt func(childComplexity int) int PublicKey func(childComplexity int) int + Tomes func(childComplexity int) int URL func(childComplexity int) int } @@ -239,6 +240,7 @@ type ComplexityRoot struct { LastModifiedAt func(childComplexity int) int Name func(childComplexity int) int ParamDefs func(childComplexity int) int + Repository func(childComplexity int) int SupportModel func(childComplexity int) int Tactic func(childComplexity int) int Uploader func(childComplexity int) int @@ -1118,6 +1120,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Repository.PublicKey(childComplexity), true + case "Repository.tomes": + if e.complexity.Repository.Tomes == nil { + break + } + + return e.complexity.Repository.Tomes(childComplexity), true + case "Repository.url": if e.complexity.Repository.URL == nil { break @@ -1384,6 +1393,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Tome.ParamDefs(childComplexity), true + case "Tome.repository": + if e.complexity.Tome.Repository == nil { + break + } + + return e.complexity.Tome.Repository(childComplexity), true + case "Tome.supportModel": if e.complexity.Tome.SupportModel == nil { break @@ -1774,6 +1790,7 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! + tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -2733,6 +2750,8 @@ type Repository implements Node { url: String! """Public key associated with this repositories private key""" publicKey: String! + """Tomes imported using this repository.""" + tomes: [Tome!] } """A connection to a list of items.""" type RepositoryConnection { @@ -2825,6 +2844,9 @@ input RepositoryWhereInput { publicKeyHasSuffix: String publicKeyEqualFold: String publicKeyContainsFold: String + """tomes edge predicates""" + hasTomes: Boolean + hasTomesWith: [TomeWhereInput!] } type Tag implements Node { id: ID! @@ -3098,6 +3120,8 @@ type Tome implements Node { files: [File!] """User who uploaded the tome (may be null).""" uploader: User + """Repository from which this Tome was imported (may be null).""" + repository: Repository } """Ordering options for Tome connections""" input TomeOrder { @@ -3259,6 +3283,9 @@ input TomeWhereInput { """uploader edge predicates""" hasUploader: Boolean hasUploaderWith: [UserWhereInput!] + """repository edge predicates""" + hasRepository: Boolean + hasRepositoryWith: [RepositoryWhereInput!] } """ UpdateBeaconInput is used for update Beacon object. diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index bd9783d19..bc2b6014e 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -202,7 +202,7 @@ func (r *mutationResolver) ImportRepository(ctx context.Context, repoID int, inp // Configure Filters filter := func(string) bool { return true } - if input.IncludeDirs != nil { + if input != nil && input.IncludeDirs != nil { filter = func(path string) bool { for _, prefix := range input.IncludeDirs { // Ignore Leading / diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 0de990c85..e7e2c1660 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -184,6 +184,7 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! + tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1143,6 +1144,8 @@ type Repository implements Node { url: String! """Public key associated with this repositories private key""" publicKey: String! + """Tomes imported using this repository.""" + tomes: [Tome!] } """A connection to a list of items.""" type RepositoryConnection { @@ -1235,6 +1238,9 @@ input RepositoryWhereInput { publicKeyHasSuffix: String publicKeyEqualFold: String publicKeyContainsFold: String + """tomes edge predicates""" + hasTomes: Boolean + hasTomesWith: [TomeWhereInput!] } type Tag implements Node { id: ID! @@ -1508,6 +1514,8 @@ type Tome implements Node { files: [File!] """User who uploaded the tome (may be null).""" uploader: User + """Repository from which this Tome was imported (may be null).""" + repository: Repository } """Ordering options for Tome connections""" input TomeOrder { @@ -1669,6 +1677,9 @@ input TomeWhereInput { """uploader edge predicates""" hasUploader: Boolean hasUploaderWith: [UserWhereInput!] + """repository edge predicates""" + hasRepository: Boolean + hasRepositoryWith: [RepositoryWhereInput!] } """ UpdateBeaconInput is used for update Beacon object. diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 80830c659..ea85c3785 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -179,6 +179,7 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! + tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1138,6 +1139,8 @@ type Repository implements Node { url: String! """Public key associated with this repositories private key""" publicKey: String! + """Tomes imported using this repository.""" + tomes: [Tome!] } """A connection to a list of items.""" type RepositoryConnection { @@ -1230,6 +1233,9 @@ input RepositoryWhereInput { publicKeyHasSuffix: String publicKeyEqualFold: String publicKeyContainsFold: String + """tomes edge predicates""" + hasTomes: Boolean + hasTomesWith: [TomeWhereInput!] } type Tag implements Node { id: ID! @@ -1503,6 +1509,8 @@ type Tome implements Node { files: [File!] """User who uploaded the tome (may be null).""" uploader: User + """Repository from which this Tome was imported (may be null).""" + repository: Repository } """Ordering options for Tome connections""" input TomeOrder { @@ -1664,6 +1672,9 @@ input TomeWhereInput { """uploader edge predicates""" hasUploader: Boolean hasUploaderWith: [UserWhereInput!] + """repository edge predicates""" + hasRepository: Boolean + hasRepositoryWith: [RepositoryWhereInput!] } """ UpdateBeaconInput is used for update Beacon object. diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 0de990c85..e7e2c1660 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -184,6 +184,7 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! + tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1143,6 +1144,8 @@ type Repository implements Node { url: String! """Public key associated with this repositories private key""" publicKey: String! + """Tomes imported using this repository.""" + tomes: [Tome!] } """A connection to a list of items.""" type RepositoryConnection { @@ -1235,6 +1238,9 @@ input RepositoryWhereInput { publicKeyHasSuffix: String publicKeyEqualFold: String publicKeyContainsFold: String + """tomes edge predicates""" + hasTomes: Boolean + hasTomesWith: [TomeWhereInput!] } type Tag implements Node { id: ID! @@ -1508,6 +1514,8 @@ type Tome implements Node { files: [File!] """User who uploaded the tome (may be null).""" uploader: User + """Repository from which this Tome was imported (may be null).""" + repository: Repository } """Ordering options for Tome connections""" input TomeOrder { @@ -1669,6 +1677,9 @@ input TomeWhereInput { """uploader edge predicates""" hasUploader: Boolean hasUploaderWith: [UserWhereInput!] + """repository edge predicates""" + hasRepository: Boolean + hasRepositoryWith: [RepositoryWhereInput!] } """ UpdateBeaconInput is used for update Beacon object. diff --git a/tavern/tomes/git.go b/tavern/tomes/git.go index 4ff119148..71b7cce11 100644 --- a/tavern/tomes/git.go +++ b/tavern/tomes/git.go @@ -230,6 +230,7 @@ func (importer *GitImporter) importFromGitTree(ctx context.Context, repo *git.Re SetSupportModel(tome.SupportModelCOMMUNITY). SetTactic(tome.Tactic(metadata.Tactic)). SetEldritch(eldritch). + SetRepository(entRepo). AddFileIDs(tomeFileIDs...). OnConflict(). UpdateNewValues(). diff --git a/tavern/tomes/git_test.go b/tavern/tomes/git_test.go index f0161dd6f..37c275a2b 100644 --- a/tavern/tomes/git_test.go +++ b/tavern/tomes/git_test.go @@ -31,6 +31,8 @@ func TestImportFromRepo(t *testing.T) { repo := graph.Repository.Create().SetURL(localGit).SaveX(ctx) repo.URL = localGit + assert.NotEmpty(t, repo.PrivateKey) + filter := func(path string) bool { return strings.Contains(path, "example") } From 6acb9d72d40a6fc57f565893bb5c3bf0d5769b5b Mon Sep 17 00:00:00 2001 From: KCarretto Date: Mon, 19 Feb 2024 21:23:47 +0000 Subject: [PATCH 5/6] Added testing --- tavern/internal/ent/client.go | 16 +++ tavern/internal/ent/gql_collection.go | 10 ++ tavern/internal/ent/gql_edge.go | 8 ++ tavern/internal/ent/gql_mutation_input.go | 6 +- tavern/internal/ent/gql_where_input.go | 22 ++++ tavern/internal/ent/migrate/schema.go | 14 ++ tavern/internal/ent/mutation.go | 65 ++++++++- tavern/internal/ent/repository.go | 39 +++++- tavern/internal/ent/repository/repository.go | 34 +++++ tavern/internal/ent/repository/where.go | 23 ++++ tavern/internal/ent/repository_create.go | 37 ++++++ tavern/internal/ent/repository_query.go | 85 +++++++++++- tavern/internal/ent/repository_update.go | 109 ++++++++++++++++ tavern/internal/ent/schema/repository.go | 8 ++ .../graphql/generated/ent.generated.go | 123 ++++++++++++++++-- .../graphql/generated/mutation.generated.go | 4 + .../graphql/generated/root_.generated.go | 14 +- tavern/internal/graphql/mutation.resolvers.go | 8 +- tavern/internal/graphql/schema.graphql | 6 +- tavern/internal/graphql/schema/ent.graphql | 6 +- .../createRepository/URLWithoutSchema.yml | 24 ++++ .../mutations/createRepository/ValidURL.yml | 24 ++++ .../queries/repositories/WithTomes.yml | 35 +++++ tavern/internal/www/schema.graphql | 6 +- tavern/tomes/git_test.go | 2 +- 25 files changed, 698 insertions(+), 30 deletions(-) create mode 100644 tavern/internal/graphql/testdata/mutations/createRepository/URLWithoutSchema.yml create mode 100644 tavern/internal/graphql/testdata/mutations/createRepository/ValidURL.yml create mode 100644 tavern/internal/graphql/testdata/queries/repositories/WithTomes.yml diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 2b5a2967a..3b815fa93 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -1637,6 +1637,22 @@ func (c *RepositoryClient) QueryTomes(r *Repository) *TomeQuery { return query } +// QueryOwner queries the owner edge of a Repository. +func (c *RepositoryClient) QueryOwner(r *Repository) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := r.ID + step := sqlgraph.NewStep( + sqlgraph.From(repository.Table, repository.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, repository.OwnerTable, repository.OwnerColumn), + ) + fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *RepositoryClient) Hooks() []Hook { hooks := c.hooks.Repository diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index c3092cc89..dfc4b6d53 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -1079,6 +1079,16 @@ func (r *RepositoryQuery) collectField(ctx context.Context, opCtx *graphql.Opera r.WithNamedTomes(alias, func(wq *TomeQuery) { *wq = *query }) + case "owner": + var ( + alias = field.Alias + path = append(path, alias) + query = (&UserClient{config: r.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + r.withOwner = query case "createdAt": if _, ok := fieldSeen[repository.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, repository.FieldCreatedAt) diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index f0e760d21..b92c4ca5d 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -196,6 +196,14 @@ func (r *Repository) Tomes(ctx context.Context) (result []*Tome, err error) { return result, err } +func (r *Repository) Owner(ctx context.Context) (*User, error) { + result, err := r.Edges.OwnerOrErr() + if IsNotLoaded(err) { + result, err = r.QueryOwner().Only(ctx) + } + return result, MaskNotFound(err) +} + func (t *Tag) Hosts(ctx context.Context) (result []*Host, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = t.NamedHosts(graphql.GetFieldContext(ctx).Field.Alias) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index 06a855f20..b44c0fdf4 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -153,16 +153,12 @@ func (c *QuestCreate) SetInput(i CreateQuestInput) *QuestCreate { // CreateRepositoryInput represents a mutation input for creating repositories. type CreateRepositoryInput struct { - URL string - TomeIDs []int + URL string } // Mutate applies the CreateRepositoryInput on the RepositoryMutation builder. func (i *CreateRepositoryInput) Mutate(m *RepositoryMutation) { m.SetURL(i.URL) - if v := i.TomeIDs; len(v) > 0 { - m.AddTomeIDs(v...) - } } // SetInput applies the change-set in the CreateRepositoryInput on the RepositoryCreate builder. diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 1406e8b61..6d3134e9e 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -3550,6 +3550,10 @@ type RepositoryWhereInput struct { // "tomes" edge predicates. HasTomes *bool `json:"hasTomes,omitempty"` HasTomesWith []*TomeWhereInput `json:"hasTomesWith,omitempty"` + + // "owner" edge predicates. + HasOwner *bool `json:"hasOwner,omitempty"` + HasOwnerWith []*UserWhereInput `json:"hasOwnerWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -3792,6 +3796,24 @@ func (i *RepositoryWhereInput) P() (predicate.Repository, error) { } predicates = append(predicates, repository.HasTomesWith(with...)) } + if i.HasOwner != nil { + p := repository.HasOwner() + if !*i.HasOwner { + p = repository.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasOwnerWith) > 0 { + with := make([]predicate.User, 0, len(i.HasOwnerWith)) + for _, w := range i.HasOwnerWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasOwnerWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, repository.HasOwnerWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyRepositoryWhereInput diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 42acc0a86..1858e7442 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -3,6 +3,7 @@ package migrate import ( + "entgo.io/ent/dialect/entsql" "entgo.io/ent/dialect/sql/schema" "entgo.io/ent/schema/field" ) @@ -230,12 +231,21 @@ var ( {Name: "url", Type: field.TypeString, Unique: true}, {Name: "public_key", Type: field.TypeString}, {Name: "private_key", Type: field.TypeString}, + {Name: "repository_owner", Type: field.TypeInt, Nullable: true}, } // RepositoriesTable holds the schema information for the "repositories" table. RepositoriesTable = &schema.Table{ Name: "repositories", Columns: RepositoriesColumns, PrimaryKey: []*schema.Column{RepositoriesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "repositories_users_owner", + Columns: []*schema.Column{RepositoriesColumns[6]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.SetNull, + }, + }, } // TagsColumns holds the columns for the "tags" table. TagsColumns = []*schema.Column{ @@ -418,6 +428,10 @@ func init() { QuestsTable.ForeignKeys[0].RefTable = TomesTable QuestsTable.ForeignKeys[1].RefTable = FilesTable QuestsTable.ForeignKeys[2].RefTable = UsersTable + RepositoriesTable.ForeignKeys[0].RefTable = UsersTable + RepositoriesTable.Annotation = &entsql.Annotation{ + Table: "repositories", + } TasksTable.ForeignKeys[0].RefTable = QuestsTable TasksTable.ForeignKeys[1].RefTable = BeaconsTable TomesTable.ForeignKeys[0].RefTable = UsersTable diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 3570b7e95..d03c02172 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -6504,6 +6504,8 @@ type RepositoryMutation struct { tomes map[int]struct{} removedtomes map[int]struct{} clearedtomes bool + owner *int + clearedowner bool done bool oldValue func(context.Context) (*Repository, error) predicates []predicate.Repository @@ -6841,6 +6843,45 @@ func (m *RepositoryMutation) ResetTomes() { m.removedtomes = nil } +// SetOwnerID sets the "owner" edge to the User entity by id. +func (m *RepositoryMutation) SetOwnerID(id int) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the User entity. +func (m *RepositoryMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the User entity was cleared. +func (m *RepositoryMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *RepositoryMutation) OwnerID() (id int, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *RepositoryMutation) OwnerIDs() (ids []int) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOwner resets all changes to the "owner" edge. +func (m *RepositoryMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false +} + // Where appends a list predicates to the RepositoryMutation builder. func (m *RepositoryMutation) Where(ps ...predicate.Repository) { m.predicates = append(m.predicates, ps...) @@ -7042,10 +7083,13 @@ func (m *RepositoryMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *RepositoryMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.tomes != nil { edges = append(edges, repository.EdgeTomes) } + if m.owner != nil { + edges = append(edges, repository.EdgeOwner) + } return edges } @@ -7059,13 +7103,17 @@ func (m *RepositoryMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case repository.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *RepositoryMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.removedtomes != nil { edges = append(edges, repository.EdgeTomes) } @@ -7088,10 +7136,13 @@ func (m *RepositoryMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *RepositoryMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.clearedtomes { edges = append(edges, repository.EdgeTomes) } + if m.clearedowner { + edges = append(edges, repository.EdgeOwner) + } return edges } @@ -7101,6 +7152,8 @@ func (m *RepositoryMutation) EdgeCleared(name string) bool { switch name { case repository.EdgeTomes: return m.clearedtomes + case repository.EdgeOwner: + return m.clearedowner } return false } @@ -7109,6 +7162,9 @@ func (m *RepositoryMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *RepositoryMutation) ClearEdge(name string) error { switch name { + case repository.EdgeOwner: + m.ClearOwner() + return nil } return fmt.Errorf("unknown Repository unique edge %s", name) } @@ -7120,6 +7176,9 @@ func (m *RepositoryMutation) ResetEdge(name string) error { case repository.EdgeTomes: m.ResetTomes() return nil + case repository.EdgeOwner: + m.ResetOwner() + return nil } return fmt.Errorf("unknown Repository edge %s", name) } diff --git a/tavern/internal/ent/repository.go b/tavern/internal/ent/repository.go index f62a366fe..1d1d3547d 100644 --- a/tavern/internal/ent/repository.go +++ b/tavern/internal/ent/repository.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/user" ) // Repository is the model entity for the Repository schema. @@ -29,19 +30,22 @@ type Repository struct { PrivateKey string `json:"-"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the RepositoryQuery when eager-loading is set. - Edges RepositoryEdges `json:"edges"` - selectValues sql.SelectValues + Edges RepositoryEdges `json:"edges"` + repository_owner *int + selectValues sql.SelectValues } // RepositoryEdges holds the relations/edges for other nodes in the graph. type RepositoryEdges struct { // Tomes imported using this repository. Tomes []*Tome `json:"tomes,omitempty"` + // User that created this repository. + Owner *User `json:"owner,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [2]bool // totalCount holds the count of the edges above. - totalCount [1]map[string]int + totalCount [2]map[string]int namedTomes map[string][]*Tome } @@ -55,6 +59,19 @@ func (e RepositoryEdges) TomesOrErr() ([]*Tome, error) { return nil, &NotLoadedError{edge: "tomes"} } +// OwnerOrErr returns the Owner value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e RepositoryEdges) OwnerOrErr() (*User, error) { + if e.loadedTypes[1] { + if e.Owner == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: user.Label} + } + return e.Owner, nil + } + return nil, &NotLoadedError{edge: "owner"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Repository) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -66,6 +83,8 @@ func (*Repository) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullString) case repository.FieldCreatedAt, repository.FieldLastModifiedAt: values[i] = new(sql.NullTime) + case repository.ForeignKeys[0]: // repository_owner + values[i] = new(sql.NullInt64) default: values[i] = new(sql.UnknownType) } @@ -117,6 +136,13 @@ func (r *Repository) assignValues(columns []string, values []any) error { } else if value.Valid { r.PrivateKey = value.String } + case repository.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field repository_owner", value) + } else if value.Valid { + r.repository_owner = new(int) + *r.repository_owner = int(value.Int64) + } default: r.selectValues.Set(columns[i], values[i]) } @@ -135,6 +161,11 @@ func (r *Repository) QueryTomes() *TomeQuery { return NewRepositoryClient(r.config).QueryTomes(r) } +// QueryOwner queries the "owner" edge of the Repository entity. +func (r *Repository) QueryOwner() *UserQuery { + return NewRepositoryClient(r.config).QueryOwner(r) +} + // Update returns a builder for updating this Repository. // Note that you need to call Repository.Unwrap() before calling this method if this Repository // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/tavern/internal/ent/repository/repository.go b/tavern/internal/ent/repository/repository.go index 9e134a188..89f06bb08 100644 --- a/tavern/internal/ent/repository/repository.go +++ b/tavern/internal/ent/repository/repository.go @@ -27,6 +27,8 @@ const ( FieldPrivateKey = "private_key" // EdgeTomes holds the string denoting the tomes edge name in mutations. EdgeTomes = "tomes" + // EdgeOwner holds the string denoting the owner edge name in mutations. + EdgeOwner = "owner" // Table holds the table name of the repository in the database. Table = "repositories" // TomesTable is the table that holds the tomes relation/edge. @@ -36,6 +38,13 @@ const ( TomesInverseTable = "tomes" // TomesColumn is the table column denoting the tomes relation/edge. TomesColumn = "tome_repository" + // OwnerTable is the table that holds the owner relation/edge. + OwnerTable = "repositories" + // OwnerInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + OwnerInverseTable = "users" + // OwnerColumn is the table column denoting the owner relation/edge. + OwnerColumn = "repository_owner" ) // Columns holds all SQL columns for repository fields. @@ -48,6 +57,12 @@ var Columns = []string{ FieldPrivateKey, } +// ForeignKeys holds the SQL foreign-keys that are owned by the "repositories" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "repository_owner", +} + // ValidColumn reports if the column name is valid (part of the table columns). func ValidColumn(column string) bool { for i := range Columns { @@ -55,6 +70,11 @@ func ValidColumn(column string) bool { return true } } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } return false } @@ -125,6 +145,13 @@ func ByTomes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newTomesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByOwnerField orders the results by owner field. +func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...)) + } +} func newTomesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -132,3 +159,10 @@ func newTomesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, TomesTable, TomesColumn), ) } +func newOwnerStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OwnerTable, OwnerColumn), + ) +} diff --git a/tavern/internal/ent/repository/where.go b/tavern/internal/ent/repository/where.go index b3c49f260..6dbe0d724 100644 --- a/tavern/internal/ent/repository/where.go +++ b/tavern/internal/ent/repository/where.go @@ -378,6 +378,29 @@ func HasTomesWith(preds ...predicate.Tome) predicate.Repository { }) } +// HasOwner applies the HasEdge predicate on the "owner" edge. +func HasOwner() predicate.Repository { + return predicate.Repository(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OwnerTable, OwnerColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates). +func HasOwnerWith(preds ...predicate.User) predicate.Repository { + return predicate.Repository(func(s *sql.Selector) { + step := newOwnerStep() + 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.Repository) predicate.Repository { return predicate.Repository(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/repository_create.go b/tavern/internal/ent/repository_create.go index 477c87588..7ac520ee4 100644 --- a/tavern/internal/ent/repository_create.go +++ b/tavern/internal/ent/repository_create.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" + "realm.pub/tavern/internal/ent/user" ) // RepositoryCreate is the builder for creating a Repository entity. @@ -84,6 +85,25 @@ func (rc *RepositoryCreate) AddTomes(t ...*Tome) *RepositoryCreate { return rc.AddTomeIDs(ids...) } +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (rc *RepositoryCreate) SetOwnerID(id int) *RepositoryCreate { + rc.mutation.SetOwnerID(id) + return rc +} + +// SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil. +func (rc *RepositoryCreate) SetNillableOwnerID(id *int) *RepositoryCreate { + if id != nil { + rc = rc.SetOwnerID(*id) + } + return rc +} + +// SetOwner sets the "owner" edge to the User entity. +func (rc *RepositoryCreate) SetOwner(u *User) *RepositoryCreate { + return rc.SetOwnerID(u.ID) +} + // Mutation returns the RepositoryMutation object of the builder. func (rc *RepositoryCreate) Mutation() *RepositoryMutation { return rc.mutation @@ -233,6 +253,23 @@ func (rc *RepositoryCreate) createSpec() (*Repository, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := rc.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: repository.OwnerTable, + Columns: []string{repository.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.repository_owner = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/repository_query.go b/tavern/internal/ent/repository_query.go index 52ffbcf19..75958a8e5 100644 --- a/tavern/internal/ent/repository_query.go +++ b/tavern/internal/ent/repository_query.go @@ -14,6 +14,7 @@ import ( "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" + "realm.pub/tavern/internal/ent/user" ) // RepositoryQuery is the builder for querying Repository entities. @@ -24,6 +25,8 @@ type RepositoryQuery struct { inters []Interceptor predicates []predicate.Repository withTomes *TomeQuery + withOwner *UserQuery + withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Repository) error withNamedTomes map[string]*TomeQuery @@ -85,6 +88,28 @@ func (rq *RepositoryQuery) QueryTomes() *TomeQuery { return query } +// QueryOwner chains the current query on the "owner" edge. +func (rq *RepositoryQuery) QueryOwner() *UserQuery { + query := (&UserClient{config: rq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := rq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := rq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(repository.Table, repository.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, repository.OwnerTable, repository.OwnerColumn), + ) + fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Repository entity from the query. // Returns a *NotFoundError when no Repository was found. func (rq *RepositoryQuery) First(ctx context.Context) (*Repository, error) { @@ -278,6 +303,7 @@ func (rq *RepositoryQuery) Clone() *RepositoryQuery { inters: append([]Interceptor{}, rq.inters...), predicates: append([]predicate.Repository{}, rq.predicates...), withTomes: rq.withTomes.Clone(), + withOwner: rq.withOwner.Clone(), // clone intermediate query. sql: rq.sql.Clone(), path: rq.path, @@ -295,6 +321,17 @@ func (rq *RepositoryQuery) WithTomes(opts ...func(*TomeQuery)) *RepositoryQuery return rq } +// WithOwner tells the query-builder to eager-load the nodes that are connected to +// the "owner" edge. The optional arguments are used to configure the query builder of the edge. +func (rq *RepositoryQuery) WithOwner(opts ...func(*UserQuery)) *RepositoryQuery { + query := (&UserClient{config: rq.config}).Query() + for _, opt := range opts { + opt(query) + } + rq.withOwner = query + return rq +} + // 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. // @@ -372,11 +409,19 @@ func (rq *RepositoryQuery) prepareQuery(ctx context.Context) error { func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Repository, error) { var ( nodes = []*Repository{} + withFKs = rq.withFKs _spec = rq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [2]bool{ rq.withTomes != nil, + rq.withOwner != nil, } ) + if rq.withOwner != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, repository.ForeignKeys...) + } _spec.ScanValues = func(columns []string) ([]any, error) { return (*Repository).scanValues(nil, columns) } @@ -405,6 +450,12 @@ func (rq *RepositoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*R return nil, err } } + if query := rq.withOwner; query != nil { + if err := rq.loadOwner(ctx, query, nodes, nil, + func(n *Repository, e *User) { n.Edges.Owner = e }); err != nil { + return nil, err + } + } for name, query := range rq.withNamedTomes { if err := rq.loadTomes(ctx, query, nodes, func(n *Repository) { n.appendNamedTomes(name) }, @@ -451,6 +502,38 @@ func (rq *RepositoryQuery) loadTomes(ctx context.Context, query *TomeQuery, node } return nil } +func (rq *RepositoryQuery) loadOwner(ctx context.Context, query *UserQuery, nodes []*Repository, init func(*Repository), assign func(*Repository, *User)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Repository) + for i := range nodes { + if nodes[i].repository_owner == nil { + continue + } + fk := *nodes[i].repository_owner + 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 "repository_owner" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} func (rq *RepositoryQuery) sqlCount(ctx context.Context) (int, error) { _spec := rq.querySpec() diff --git a/tavern/internal/ent/repository_update.go b/tavern/internal/ent/repository_update.go index 284adc133..e98c7182b 100644 --- a/tavern/internal/ent/repository_update.go +++ b/tavern/internal/ent/repository_update.go @@ -14,6 +14,7 @@ import ( "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/tome" + "realm.pub/tavern/internal/ent/user" ) // RepositoryUpdate is the builder for updating Repository entities. @@ -68,6 +69,25 @@ func (ru *RepositoryUpdate) AddTomes(t ...*Tome) *RepositoryUpdate { return ru.AddTomeIDs(ids...) } +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (ru *RepositoryUpdate) SetOwnerID(id int) *RepositoryUpdate { + ru.mutation.SetOwnerID(id) + return ru +} + +// SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil. +func (ru *RepositoryUpdate) SetNillableOwnerID(id *int) *RepositoryUpdate { + if id != nil { + ru = ru.SetOwnerID(*id) + } + return ru +} + +// SetOwner sets the "owner" edge to the User entity. +func (ru *RepositoryUpdate) SetOwner(u *User) *RepositoryUpdate { + return ru.SetOwnerID(u.ID) +} + // Mutation returns the RepositoryMutation object of the builder. func (ru *RepositoryUpdate) Mutation() *RepositoryMutation { return ru.mutation @@ -94,6 +114,12 @@ func (ru *RepositoryUpdate) RemoveTomes(t ...*Tome) *RepositoryUpdate { return ru.RemoveTomeIDs(ids...) } +// ClearOwner clears the "owner" edge to the User entity. +func (ru *RepositoryUpdate) ClearOwner() *RepositoryUpdate { + ru.mutation.ClearOwner() + return ru +} + // Save executes the query and returns the number of nodes affected by the update operation. func (ru *RepositoryUpdate) Save(ctx context.Context) (int, error) { if err := ru.defaults(); err != nil { @@ -225,6 +251,35 @@ func (ru *RepositoryUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if ru.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: repository.OwnerTable, + Columns: []string{repository.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ru.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: repository.OwnerTable, + Columns: []string{repository.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{repository.Label} @@ -284,6 +339,25 @@ func (ruo *RepositoryUpdateOne) AddTomes(t ...*Tome) *RepositoryUpdateOne { return ruo.AddTomeIDs(ids...) } +// SetOwnerID sets the "owner" edge to the User entity by ID. +func (ruo *RepositoryUpdateOne) SetOwnerID(id int) *RepositoryUpdateOne { + ruo.mutation.SetOwnerID(id) + return ruo +} + +// SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil. +func (ruo *RepositoryUpdateOne) SetNillableOwnerID(id *int) *RepositoryUpdateOne { + if id != nil { + ruo = ruo.SetOwnerID(*id) + } + return ruo +} + +// SetOwner sets the "owner" edge to the User entity. +func (ruo *RepositoryUpdateOne) SetOwner(u *User) *RepositoryUpdateOne { + return ruo.SetOwnerID(u.ID) +} + // Mutation returns the RepositoryMutation object of the builder. func (ruo *RepositoryUpdateOne) Mutation() *RepositoryMutation { return ruo.mutation @@ -310,6 +384,12 @@ func (ruo *RepositoryUpdateOne) RemoveTomes(t ...*Tome) *RepositoryUpdateOne { return ruo.RemoveTomeIDs(ids...) } +// ClearOwner clears the "owner" edge to the User entity. +func (ruo *RepositoryUpdateOne) ClearOwner() *RepositoryUpdateOne { + ruo.mutation.ClearOwner() + return ruo +} + // Where appends a list predicates to the RepositoryUpdate builder. func (ruo *RepositoryUpdateOne) Where(ps ...predicate.Repository) *RepositoryUpdateOne { ruo.mutation.Where(ps...) @@ -471,6 +551,35 @@ func (ruo *RepositoryUpdateOne) sqlSave(ctx context.Context) (_node *Repository, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if ruo.mutation.OwnerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: repository.OwnerTable, + Columns: []string{repository.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ruo.mutation.OwnerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: repository.OwnerTable, + Columns: []string{repository.OwnerColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Repository{config: ruo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/schema/repository.go b/tavern/internal/ent/schema/repository.go index ee8e2251a..230b732f2 100644 --- a/tavern/internal/ent/schema/repository.go +++ b/tavern/internal/ent/schema/repository.go @@ -10,6 +10,7 @@ import ( "entgo.io/contrib/entgql" "entgo.io/ent" + "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" @@ -54,6 +55,12 @@ func (Repository) Edges() []ent.Edge { entgql.Skip(entgql.SkipMutationCreateInput, entgql.SkipMutationUpdateInput), ). Comment("Tomes imported using this repository."), + edge.To("owner", User.Type). + Unique(). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput, entgql.SkipMutationUpdateInput), + ). + Comment("User that created this repository."), } } @@ -63,6 +70,7 @@ func (Repository) Annotations() []schema.Annotation { entgql.Mutations(entgql.MutationCreate()), entgql.RelayConnection(), entgql.MultiOrder(), + entsql.Annotation{Table: "repositories"}, } } diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 8310e36e2..0ecfbbac9 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -5529,6 +5529,61 @@ func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, f return fc, nil } +func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Repository_owner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + 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.Owner(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.User) + fc.Result = res + return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Repository_owner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Repository", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_RepositoryConnection_edges(ctx, field) if err != nil { @@ -5722,6 +5777,8 @@ func (ec *executionContext) fieldContext_RepositoryEdge_node(ctx context.Context return ec.fieldContext_Repository_publicKey(ctx, field) case "tomes": return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, @@ -7539,6 +7596,8 @@ func (ec *executionContext) fieldContext_Tome_repository(ctx context.Context, fi return ec.fieldContext_Repository_publicKey(ctx, field) case "tomes": return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, @@ -8918,7 +8977,7 @@ func (ec *executionContext) unmarshalInputCreateRepositoryInput(ctx context.Cont asMap[k] = v } - fieldsInOrder := [...]string{"url", "tomeIDs"} + fieldsInOrder := [...]string{"url"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8934,15 +8993,6 @@ func (ec *executionContext) unmarshalInputCreateRepositoryInput(ctx context.Cont return it, err } it.URL = data - case "tomeIDs": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeIDs")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.TomeIDs = data } } @@ -14279,7 +14329,7 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold", "hasTomes", "hasTomesWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold", "hasTomes", "hasTomesWith", "hasOwner", "hasOwnerWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -14781,6 +14831,24 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte return it, err } it.HasTomesWith = data + case "hasOwner": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasOwner = data + case "hasOwnerWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasOwnerWith = data } } @@ -19650,6 +19718,39 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "owner": + 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._Repository_owner(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) }) default: panic("unknown field " + strconv.Quote(field.Name)) diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index e653a2fa6..f552afcd4 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -1192,6 +1192,8 @@ func (ec *executionContext) fieldContext_Mutation_createRepository(ctx context.C return ec.fieldContext_Repository_publicKey(ctx, field) case "tomes": return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, @@ -1285,6 +1287,8 @@ func (ec *executionContext) fieldContext_Mutation_importRepository(ctx context.C return ec.fieldContext_Repository_publicKey(ctx, field) case "tomes": return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) }, diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index b9aedb363..6bdb27e5a 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -179,6 +179,7 @@ type ComplexityRoot struct { CreatedAt func(childComplexity int) int ID func(childComplexity int) int LastModifiedAt func(childComplexity int) int + Owner func(childComplexity int) int PublicKey func(childComplexity int) int Tomes func(childComplexity int) int URL func(childComplexity int) int @@ -1113,6 +1114,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Repository.LastModifiedAt(childComplexity), true + case "Repository.owner": + if e.complexity.Repository.Owner == nil { + break + } + + return e.complexity.Repository.Owner(childComplexity), true + case "Repository.publicKey": if e.complexity.Repository.PublicKey == nil { break @@ -1790,7 +1798,6 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! - tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -2752,6 +2759,8 @@ type Repository implements Node { publicKey: String! """Tomes imported using this repository.""" tomes: [Tome!] + """User that created this repository.""" + owner: User } """A connection to a list of items.""" type RepositoryConnection { @@ -2847,6 +2856,9 @@ input RepositoryWhereInput { """tomes edge predicates""" hasTomes: Boolean hasTomesWith: [TomeWhereInput!] + """owner edge predicates""" + hasOwner: Boolean + hasOwnerWith: [UserWhereInput!] } type Tag implements Node { id: ID! diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index bc2b6014e..91643c245 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -187,8 +187,14 @@ func (r *mutationResolver) DeleteTome(ctx context.Context, tomeID int) (int, err // CreateRepository is the resolver for the createRepository field. func (r *mutationResolver) CreateRepository(ctx context.Context, input ent.CreateRepositoryInput) (*ent.Repository, error) { + var ownerID *int + if owner := auth.UserFromContext(ctx); owner != nil { + ownerID = &owner.ID + } + return r.client.Repository.Create(). - SetURL(input.URL). + SetInput(input). + SetNillableOwnerID(ownerID). Save(ctx) } diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index e7e2c1660..2eabab32f 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -184,7 +184,6 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! - tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1146,6 +1145,8 @@ type Repository implements Node { publicKey: String! """Tomes imported using this repository.""" tomes: [Tome!] + """User that created this repository.""" + owner: User } """A connection to a list of items.""" type RepositoryConnection { @@ -1241,6 +1242,9 @@ input RepositoryWhereInput { """tomes edge predicates""" hasTomes: Boolean hasTomesWith: [TomeWhereInput!] + """owner edge predicates""" + hasOwner: Boolean + hasOwnerWith: [UserWhereInput!] } type Tag implements Node { id: ID! diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index ea85c3785..707561839 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -179,7 +179,6 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! - tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1141,6 +1140,8 @@ type Repository implements Node { publicKey: String! """Tomes imported using this repository.""" tomes: [Tome!] + """User that created this repository.""" + owner: User } """A connection to a list of items.""" type RepositoryConnection { @@ -1236,6 +1237,9 @@ input RepositoryWhereInput { """tomes edge predicates""" hasTomes: Boolean hasTomesWith: [TomeWhereInput!] + """owner edge predicates""" + hasOwner: Boolean + hasOwnerWith: [UserWhereInput!] } type Tag implements Node { id: ID! diff --git a/tavern/internal/graphql/testdata/mutations/createRepository/URLWithoutSchema.yml b/tavern/internal/graphql/testdata/mutations/createRepository/URLWithoutSchema.yml new file mode 100644 index 000000000..e03cda668 --- /dev/null +++ b/tavern/internal/graphql/testdata/mutations/createRepository/URLWithoutSchema.yml @@ -0,0 +1,24 @@ +state: | + INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin) + VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true); +requestor: + session_token: secretToken +query: | + mutation CreateRepository($input: CreateRepositoryInput!) { + createRepository(input: $input) { + url + + owner { + id + } + } + } +variables: + input: + url: "github.com/spellshift/realm" + +expected: + createRepository: + url: "https://github.com/spellshift/realm" + owner: + id: "5" diff --git a/tavern/internal/graphql/testdata/mutations/createRepository/ValidURL.yml b/tavern/internal/graphql/testdata/mutations/createRepository/ValidURL.yml new file mode 100644 index 000000000..2f10a7a9d --- /dev/null +++ b/tavern/internal/graphql/testdata/mutations/createRepository/ValidURL.yml @@ -0,0 +1,24 @@ +state: | + INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin) + VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true); +requestor: + session_token: secretToken +query: | + mutation CreateRepository($input: CreateRepositoryInput!) { + createRepository(input: $input) { + url + + owner { + id + } + } + } +variables: + input: + url: "ssh://github.com/spellshift/realm" + +expected: + createRepository: + url: "ssh://github.com/spellshift/realm" + owner: + id: "5" diff --git a/tavern/internal/graphql/testdata/queries/repositories/WithTomes.yml b/tavern/internal/graphql/testdata/queries/repositories/WithTomes.yml new file mode 100644 index 000000000..a0814ab0d --- /dev/null +++ b/tavern/internal/graphql/testdata/queries/repositories/WithTomes.yml @@ -0,0 +1,35 @@ +state: | + INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin) + VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true); + INSERT INTO `repositories` (id, repository_owner, url, public_key, private_key, created_at, last_modified_at) + VALUES (11000, 5, "ssh://code.google.com/my/repo", "--PUBLIC KEY--", "--PRIVATE KEY--", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `tomes` (id, tome_repository, name, description, author, eldritch, hash, created_at, last_modified_at) + VALUES (2000,11000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `tomes` (id, tome_repository, name, description, author, eldritch, hash, created_at, last_modified_at) + VALUES (2001,11000,"Test Tome 2","Filtered by a unit test :D", "kcarretto", "print('Goodbye World!')", "gfedcba", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); +requestor: + session_token: secretToken +query: | + query Repositories { + repositories { + edges { + node { + id + url + publicKey + owner { + id + } + } + } + } + } +expected: + repositories: + edges: + - node: + id: "11000" + url: "ssh://code.google.com/my/repo" + publicKey: "--PUBLIC KEY--" + owner: + id: "5" diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index e7e2c1660..2eabab32f 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -184,7 +184,6 @@ Input was generated by ent. input CreateRepositoryInput { """URL of the repository""" url: String! - tomeIDs: [ID!] } """ CreateTagInput is used for create Tag object. @@ -1146,6 +1145,8 @@ type Repository implements Node { publicKey: String! """Tomes imported using this repository.""" tomes: [Tome!] + """User that created this repository.""" + owner: User } """A connection to a list of items.""" type RepositoryConnection { @@ -1241,6 +1242,9 @@ input RepositoryWhereInput { """tomes edge predicates""" hasTomes: Boolean hasTomesWith: [TomeWhereInput!] + """owner edge predicates""" + hasOwner: Boolean + hasOwnerWith: [UserWhereInput!] } type Tag implements Node { id: ID! diff --git a/tavern/tomes/git_test.go b/tavern/tomes/git_test.go index 37c275a2b..6010ce524 100644 --- a/tavern/tomes/git_test.go +++ b/tavern/tomes/git_test.go @@ -29,7 +29,7 @@ func TestImportFromRepo(t *testing.T) { // Create repository repo := graph.Repository.Create().SetURL(localGit).SaveX(ctx) - repo.URL = localGit + repo.URL = localGit // Override schema hook to test with local repo assert.NotEmpty(t, repo.PrivateKey) From e79a5b580751cc2c8ef70e42d90a233bb0b272f7 Mon Sep 17 00:00:00 2001 From: KCarretto Date: Mon, 19 Feb 2024 21:39:52 +0000 Subject: [PATCH 6/6] additional importRepository testing --- tavern/internal/graphql/api_test.go | 30 ++++++++++--- .../importRepository/ExistingTomes.yml | 44 +++++++++++++++++++ .../importRepository/NoExistingTomes.yml | 34 ++++++++++++++ 3 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 tavern/internal/graphql/testdata/mutations/importRepository/ExistingTomes.yml create mode 100644 tavern/internal/graphql/testdata/mutations/importRepository/NoExistingTomes.yml diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index 413a55cc3..75046c9e1 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -1,6 +1,7 @@ package graphql_test import ( + "context" "database/sql" "encoding/json" "net/http" @@ -11,10 +12,11 @@ import ( "time" "realm.pub/tavern/internal/auth" + "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/enttest" + "realm.pub/tavern/internal/ent/tome" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" - "realm.pub/tavern/tomes" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" @@ -35,6 +37,27 @@ type testCase struct { ExpectedError string `yaml:"expected_error"` } +type importerFake struct { + graph *ent.Client +} + +// Import fake imports a simple static tome for testing. +func (fake importerFake) Import(ctx context.Context, repo *ent.Repository, filters ...func(path string) bool) error { + _, err := fake.graph.Tome.Create(). + SetName("expected_tome"). + SetDescription("expected_description"). + SetAuthor("expected_author"). + SetParamDefs(""). + SetSupportModel(tome.SupportModelCOMMUNITY). + SetTactic(tome.TacticIMPACT). + SetEldritch(`print("expected")`). + SetRepository(repo). + OnConflict(). + UpdateNewValues(). + ID(ctx) + return err +} + func runTestCase(t *testing.T, path string) { t.Helper() @@ -68,13 +91,10 @@ func runTestCase(t *testing.T, path string) { _, dbErr := db.Exec(tc.State) require.NoError(t, dbErr, "failed to setup test db state") - // Initialize Git Importer - git := tomes.NewGitImporter(graph) - // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph})), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/testdata/mutations/importRepository/ExistingTomes.yml b/tavern/internal/graphql/testdata/mutations/importRepository/ExistingTomes.yml new file mode 100644 index 000000000..4d4d989c1 --- /dev/null +++ b/tavern/internal/graphql/testdata/mutations/importRepository/ExistingTomes.yml @@ -0,0 +1,44 @@ +state: | + INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin) + VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true); + INSERT INTO `repositories` (id, repository_owner, url, public_key, private_key, created_at, last_modified_at) + VALUES (11000, 5, "ssh://code.google.com/my/repo", "--PUBLIC KEY--", "--PRIVATE KEY--", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `tomes` (id, tome_repository, name, description, author, eldritch, hash, created_at, last_modified_at) + VALUES (2000,11000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `tomes` (id, tome_repository, name, description, author, eldritch, hash, created_at, last_modified_at) + VALUES (2001,11000,"expected_tome","Filtered by a unit test :D", "kcarretto", "print('Goodbye World!')", "gfedcba", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); +requestor: + session_token: secretToken +query: | + mutation ImportRepository { + importRepository(repoID: 11000) { + id + url + publicKey + tomes { + id + name + author + eldritch + } + owner { + id + } + } + } +expected: + importRepository: + id: "11000" + url: "ssh://code.google.com/my/repo" + publicKey: "--PUBLIC KEY--" + tomes: + - id: "2000" + name: "Test Tome" + author: kcarretto + eldritch: print('Hello World!') + - id: "2001" + name: "expected_tome" + author: "expected_author" + eldritch: print("expected") + owner: + id: "5" diff --git a/tavern/internal/graphql/testdata/mutations/importRepository/NoExistingTomes.yml b/tavern/internal/graphql/testdata/mutations/importRepository/NoExistingTomes.yml new file mode 100644 index 000000000..b081d80bf --- /dev/null +++ b/tavern/internal/graphql/testdata/mutations/importRepository/NoExistingTomes.yml @@ -0,0 +1,34 @@ +state: | + INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin) + VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true); + INSERT INTO `repositories` (id, repository_owner, url, public_key, private_key, created_at, last_modified_at) + VALUES (11000, 5, "ssh://code.google.com/my/repo", "--PUBLIC KEY--", "--PRIVATE KEY--", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); +requestor: + session_token: secretToken +query: | + mutation ImportRepository { + importRepository(repoID: 11000) { + id + url + publicKey + tomes { + name + author + eldritch + } + owner { + id + } + } + } +expected: + importRepository: + id: "11000" + url: "ssh://code.google.com/my/repo" + publicKey: "--PUBLIC KEY--" + tomes: + - name: "expected_tome" + author: "expected_author" + eldritch: print("expected") + owner: + id: "5"