diff --git a/tavern/app.go b/tavern/app.go index 2e9c750d9..98d2f5226 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -3,7 +3,9 @@ package main import ( "context" "crypto/ecdh" + "crypto/ed25519" "crypto/tls" + "crypto/x509" "encoding/base64" "fmt" "log" @@ -23,6 +25,8 @@ import ( "golang.org/x/net/http2/h2c" "google.golang.org/grpc" "realm.pub/tavern/internal/auth" + "realm.pub/tavern/internal/builder" + "realm.pub/tavern/internal/builder/builderpb" "realm.pub/tavern/internal/c2" "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/cdn" @@ -134,6 +138,34 @@ func newApp(ctx context.Context) (app *cli.App) { }, }, }, + { + Name: "builder", + Usage: "Run a builder that compiles agents for target platforms", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "config", + Usage: "Path to the builder YAML configuration file", + }, + }, + Action: func(c *cli.Context) error { + configPath := c.String("config") + if configPath == "" { + return fmt.Errorf("--config flag is required") + } + + cfg, err := builder.ParseConfig(configPath) + if err != nil { + return fmt.Errorf("failed to parse builder config: %w", err) + } + + slog.InfoContext(ctx, "starting builder", + "config", configPath, + "supported_targets", cfg.SupportedTargets, + ) + + return builder.Run(ctx, cfg) + }, + }, } return } @@ -227,6 +259,13 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { // Initialize Git Tome Importer git := cfg.NewGitImporter(client) + // Initialize Builder CA + builderCACert, builderCAKey, err := getBuilderCA() + if err != nil { + client.Close() + return nil, fmt.Errorf("failed to initialize builder CA: %w", err) + } + // Initialize Test Data if cfg.IsTestDataEnabled() { createTestData(ctx, client) @@ -286,7 +325,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { AllowUnactivated: true, }, "/graphql": tavernhttp.Endpoint{ - Handler: newGraphQLHandler(client, git), + Handler: newGraphQLHandler(client, git, graphql.WithBuilderCAKey(builderCAKey), graphql.WithBuilderCA(builderCACert)), AllowUnactivated: true, }, "/c2.C2/": tavernhttp.Endpoint{ @@ -297,6 +336,11 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { "/portal.Portal/": tavernhttp.Endpoint{ Handler: newPortalGRPCHandler(client, portalMux), }, + "/builder.Builder/": tavernhttp.Endpoint{ + Handler: newBuilderGRPCHandler(client, builderCACert), + AllowUnauthenticated: true, + AllowUnactivated: true, + }, "/cdn/": tavernhttp.Endpoint{ Handler: cdn.NewLinkDownloadHandler(client, "/cdn/"), AllowUnauthenticated: true, @@ -380,8 +424,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter)) +func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, options ...func(*graphql.Resolver)) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, options...)) srv.Use(entgql.Transactioner{TxOpener: client}) // Configure Raw Query Logging @@ -497,6 +541,27 @@ func getKeyPairEd25519() (pubKey []byte, privKey []byte, err error) { return pubKey, privKey, nil } +// getBuilderCA returns the Builder CA certificate and private key for signing builder certificates. +// It uses the existing ED25519 key from the secrets manager. +func getBuilderCA() (caCert *x509.Certificate, caKey ed25519.PrivateKey, err error) { + secretsManager, err := newSecretsManager() + if err != nil { + return nil, nil, err + } + + caKey, err = crypto.GetPrivKeyED25519(secretsManager) + if err != nil { + return nil, nil, fmt.Errorf("failed to get ED25519 private key: %w", err) + } + + caCert, err = builder.CreateCA(caKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create builder CA: %w", err) + } + + return caCert, caKey, nil +} + func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { portalSrv := portals.New(graph, portalMux) grpcSrv := grpc.NewServer( @@ -519,6 +584,31 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } +func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Handler { + builderSrv := builder.New(client) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, client), + grpcWithUnaryMetrics, + ), + grpc.StreamInterceptor(grpcWithStreamMetrics), + ) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.ProtoMajor != 2 { + http.Error(w, "grpc requires HTTP/2", http.StatusBadRequest) + return + } + + if contentType := r.Header.Get("Content-Type"); !strings.HasPrefix(contentType, "application/grpc") { + http.Error(w, "must specify Content-Type application/grpc", http.StatusBadRequest) + return + } + + grpcSrv.ServeHTTP(w, r) + }) +} + func newGRPCHandler(client *ent.Client, grpcShellMux *stream.Mux, portalMux *mux.Mux) http.Handler { pub, priv, err := getKeyPairX25519() if err != nil { diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md new file mode 100644 index 000000000..1d914a279 --- /dev/null +++ b/tavern/internal/builder/README.md @@ -0,0 +1,68 @@ +# Builder + +The builder package orchestrates agent compilation for target platforms. It connects to the Tavern server via gRPC and compiles agents based on its configuration. + +## Overview + +- **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate signed by the Tavern Builder CA and a YAML configuration file. +- **mTLS Authentication**: All gRPC requests are authenticated using application-level mTLS. The builder presents its CA-signed certificate and a signed timestamp in gRPC metadata on each request. The server verifies the certificate chain, proof of private key possession, and looks up the builder by the identifier embedded in the certificate CN. +- **gRPC API**: Builders communicate with Tavern over gRPC at the `/builder.Builder/` route. Currently supports a `Ping` health check endpoint. +- **CLI**: Run a builder using the `builder` subcommand with a `--config` flag pointing to a YAML configuration file. + +## Configuration + +Builders are configured via a YAML file with the following schema: + +```yaml +id: +supported_targets: + - linux + - macos + - windows +mtls: +upstream: +``` + +| Field | Description | +|-------|-------------| +| `id` | Unique identifier for this builder, assigned during registration. Embedded in the mTLS certificate CN as `builder-{id}`. | +| `supported_targets` | List of platforms this builder can compile agents for. Valid values: `linux`, `macos`, `windows`. | +| `mtls` | PEM bundle containing the CA-signed mTLS certificate and private key for authenticating with Tavern. | +| `upstream` | The Tavern server address to connect to. | + +## Authentication Flow + +1. An admin registers a builder via the `registerBuilder` GraphQL mutation. +2. Tavern generates a unique identifier and an Ed25519 client certificate signed by the Tavern Builder CA, with CN=`builder-{identifier}`. +3. The builder config YAML is returned containing the certificate, private key, identifier, and upstream address. +4. On each gRPC call, the builder client sends three metadata fields: + - `builder-cert-bin`: DER-encoded certificate (binary metadata) + - `builder-signature-bin`: Ed25519 signature over the timestamp (binary metadata) + - `builder-timestamp`: RFC3339Nano timestamp +5. The server interceptor verifies: + - Certificate was signed by the Tavern Builder CA + - Signature proves private key possession + - Timestamp is within 5 minutes (replay prevention) + - Certificate has not expired + - Builder identifier from CN exists in the database + +## Usage + +```bash +# Register a builder via GraphQL (returns config YAML) +# Then run it: +go run ./tavern builder --config /path/to/builder-config.yaml +``` + +## Package Structure + +| File | Purpose | +|------|---------| +| `auth.go` | gRPC unary interceptor for mTLS authentication | +| `ca.go` | Builder CA generation, persistence, and certificate signing | +| `client.go` | Builder client with `PerRPCCredentials` for mTLS auth | +| `config.go` | YAML configuration parsing and validation | +| `server.go` | gRPC server implementation (Ping) | +| `proto/builder.proto` | Protobuf service definition | +| `builderpb/` | Generated protobuf Go code | +| `integration_test.go` | End-to-end test covering registration, mTLS auth, and unauthenticated rejection | diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go new file mode 100644 index 000000000..eb85a6a6a --- /dev/null +++ b/tavern/internal/builder/auth.go @@ -0,0 +1,128 @@ +package builder + +import ( + "context" + "crypto/ed25519" + "crypto/x509" + "log/slog" + "strings" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + + "realm.pub/tavern/internal/ent" + entbuilder "realm.pub/tavern/internal/ent/builder" +) + +const ( + // Metadata keys for mTLS authentication. + // Keys ending in "-bin" use gRPC binary metadata encoding. + mdKeyBuilderCert = "builder-cert-bin" + mdKeyBuilderSignature = "builder-signature-bin" + mdKeyBuilderTimestamp = "builder-timestamp" + + // Maximum age for a timestamp to be considered valid. + maxTimestampAge = 5 * time.Minute + + // CN prefix used in builder certificates. + builderCNPrefix = "builder-" +) + +type builderContextKey struct{} + +// BuilderFromContext extracts the authenticated builder entity from the context. +func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { + b, ok := ctx.Value(builderContextKey{}).(*ent.Builder) + return b, ok +} + +// NewMTLSAuthInterceptor creates a gRPC unary server interceptor that validates +// builder mTLS credentials. It verifies: +// 1. The certificate was signed by the provided CA +// 2. The signature proves possession of the corresponding private key +// 3. The timestamp is recent (prevents replay) +// 4. The builder identifier from the CN exists in the database +func NewMTLSAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, status.Error(codes.Unauthenticated, "missing metadata") + } + + // Extract metadata values. + // Binary metadata (keys ending in "-bin") is automatically base64 decoded by gRPC. + certDER := getMetadataValue(md, mdKeyBuilderCert) + signature := getMetadataValue(md, mdKeyBuilderSignature) + timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) + + if certDER == "" || signature == "" || timestamp == "" { + return nil, status.Error(codes.Unauthenticated, "missing builder credentials") + } + + // Parse the certificate + cert, err := x509.ParseCertificate([]byte(certDER)) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid certificate") + } + + // Verify certificate was signed by our CA + if err := cert.CheckSignatureFrom(caCert); err != nil { + return nil, status.Error(codes.Unauthenticated, "certificate not signed by trusted CA") + } + + // Verify certificate validity period + now := time.Now() + if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { + return nil, status.Error(codes.Unauthenticated, "certificate expired or not yet valid") + } + + // Verify timestamp freshness + ts, err := time.Parse(time.RFC3339Nano, timestamp) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid timestamp format") + } + if now.Sub(ts).Abs() > maxTimestampAge { + return nil, status.Error(codes.Unauthenticated, "timestamp too old or too far in the future") + } + + // Verify signature (proof of private key possession) + pubKey, ok := cert.PublicKey.(ed25519.PublicKey) + if !ok { + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") + } + if !ed25519.Verify(pubKey, []byte(timestamp), []byte(signature)) { + return nil, status.Error(codes.Unauthenticated, "invalid signature") + } + + // Extract builder identifier from CN + cn := cert.Subject.CommonName + if !strings.HasPrefix(cn, builderCNPrefix) { + return nil, status.Error(codes.Unauthenticated, "invalid certificate CN format") + } + identifier := strings.TrimPrefix(cn, builderCNPrefix) + + // Look up builder in database + b, err := graph.Builder.Query().Where(entbuilder.IdentifierEQ(identifier)).Only(ctx) + if err != nil { + slog.WarnContext(ctx, "builder authentication failed: builder not found", "identifier", identifier, "error", err) + return nil, status.Error(codes.Unauthenticated, "builder not found") + } + + slog.InfoContext(ctx, "builder authenticated", "builder_id", b.ID, "identifier", identifier) + + // Store builder in context for downstream handlers + ctx = context.WithValue(ctx, builderContextKey{}, b) + return handler(ctx, req) + } +} + +func getMetadataValue(md metadata.MD, key string) string { + values := md.Get(key) + if len(values) == 0 { + return "" + } + return values[0] +} diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go new file mode 100644 index 000000000..40d023ccc --- /dev/null +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -0,0 +1,161 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.5 +// protoc v3.21.12 +// source: builder.proto + +package builderpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PingRequest) Reset() { + *x = PingRequest{} + mi := &file_builder_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingRequest) ProtoMessage() {} + +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{0} +} + +type PingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PingResponse) Reset() { + *x = PingResponse{} + mi := &file_builder_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingResponse) ProtoMessage() {} + +func (x *PingResponse) ProtoReflect() protoreflect.Message { + mi := &file_builder_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. +func (*PingResponse) Descriptor() ([]byte, []int) { + return file_builder_proto_rawDescGZIP(), []int{1} +} + +var File_builder_proto protoreflect.FileDescriptor + +var file_builder_proto_rawDesc = string([]byte{ + 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x40, 0x0a, 0x07, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x65, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x2e, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x2b, 0x72, 0x65, 0x61, + 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x2f, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +}) + +var ( + file_builder_proto_rawDescOnce sync.Once + file_builder_proto_rawDescData []byte +) + +func file_builder_proto_rawDescGZIP() []byte { + file_builder_proto_rawDescOnce.Do(func() { + file_builder_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc))) + }) + return file_builder_proto_rawDescData +} + +var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_builder_proto_goTypes = []any{ + (*PingRequest)(nil), // 0: builder.PingRequest + (*PingResponse)(nil), // 1: builder.PingResponse +} +var file_builder_proto_depIdxs = []int32{ + 0, // 0: builder.Builder.Ping:input_type -> builder.PingRequest + 1, // 1: builder.Builder.Ping:output_type -> builder.PingResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_builder_proto_init() } +func file_builder_proto_init() { + if File_builder_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_builder_proto_rawDesc), len(file_builder_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_builder_proto_goTypes, + DependencyIndexes: file_builder_proto_depIdxs, + MessageInfos: file_builder_proto_msgTypes, + }.Build() + File_builder_proto = out.File + file_builder_proto_goTypes = nil + file_builder_proto_depIdxs = nil +} diff --git a/tavern/internal/builder/builderpb/builder_grpc.pb.go b/tavern/internal/builder/builderpb/builder_grpc.pb.go new file mode 100644 index 000000000..febce446b --- /dev/null +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -0,0 +1,110 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.21.12 +// source: builder.proto + +package builderpb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 + +const ( + Builder_Ping_FullMethodName = "/builder.Builder/Ping" +) + +// BuilderClient is the client API for Builder service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BuilderClient interface { + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) +} + +type builderClient struct { + cc grpc.ClientConnInterface +} + +func NewBuilderClient(cc grpc.ClientConnInterface) BuilderClient { + return &builderClient{cc} +} + +func (c *builderClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PingResponse) + err := c.cc.Invoke(ctx, Builder_Ping_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// BuilderServer is the server API for Builder service. +// All implementations must embed UnimplementedBuilderServer +// for forward compatibility +type BuilderServer interface { + Ping(context.Context, *PingRequest) (*PingResponse, error) + mustEmbedUnimplementedBuilderServer() +} + +// UnimplementedBuilderServer must be embedded to have forward compatible implementations. +type UnimplementedBuilderServer struct { +} + +func (UnimplementedBuilderServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (UnimplementedBuilderServer) mustEmbedUnimplementedBuilderServer() {} + +// UnsafeBuilderServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BuilderServer will +// result in compilation errors. +type UnsafeBuilderServer interface { + mustEmbedUnimplementedBuilderServer() +} + +func RegisterBuilderServer(s grpc.ServiceRegistrar, srv BuilderServer) { + s.RegisterService(&Builder_ServiceDesc, srv) +} + +func _Builder_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BuilderServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Builder_Ping_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BuilderServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Builder_ServiceDesc is the grpc.ServiceDesc for Builder service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Builder_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "builder.Builder", + HandlerType: (*BuilderServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Ping", + Handler: _Builder_Ping_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "builder.proto", +} diff --git a/tavern/internal/builder/ca.go b/tavern/internal/builder/ca.go new file mode 100644 index 000000000..b482d76bf --- /dev/null +++ b/tavern/internal/builder/ca.go @@ -0,0 +1,91 @@ +package builder + +import ( + "crypto/ed25519" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "fmt" + "math/big" + "time" +) + +// CreateCA creates a self-signed CA certificate from the provided ED25519 private key. +// The certificate is generated in-memory each time — only the private key needs to be persisted. +func CreateCA(privKey ed25519.PrivateKey) (*x509.Certificate, error) { + pubKey := privKey.Public().(ed25519.PublicKey) + + serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) + if err != nil { + return nil, fmt.Errorf("failed to generate serial number: %w", err) + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: "Realm Builder CA", + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(10 * 365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageCRLSign, + BasicConstraintsValid: true, + IsCA: true, + MaxPathLen: 0, + } + + caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, pubKey, privKey) + if err != nil { + return nil, fmt.Errorf("failed to create CA certificate: %w", err) + } + + cert, err := x509.ParseCertificate(caDER) + if err != nil { + return nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) + } + + return cert, nil +} + +// SignBuilderCertificate generates a client certificate for a builder, signed by the CA. +// The certificate CN is set to "builder-{identifier}" for identity attribution. +func SignBuilderCertificate(ca *x509.Certificate, caKey ed25519.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { + builderPub, builderPriv, err := ed25519.GenerateKey(rand.Reader) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate builder key pair: %w", err) + } + + serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate serial number: %w", err) + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: fmt.Sprintf("builder-%s", builderIdentifier), + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageDigitalSignature, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + BasicConstraintsValid: true, + } + + certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, builderPub, caKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create builder certificate: %w", err) + } + + certPEM = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) + + keyDER, err := x509.MarshalPKCS8PrivateKey(builderPriv) + if err != nil { + return nil, nil, fmt.Errorf("failed to marshal builder private key: %w", err) + } + keyPEM = pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyDER}) + + return certPEM, keyPEM, nil +} diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go new file mode 100644 index 000000000..3d310d63d --- /dev/null +++ b/tavern/internal/builder/client.go @@ -0,0 +1,128 @@ +package builder + +import ( + "context" + "crypto/ed25519" + "crypto/x509" + "encoding/pem" + "fmt" + "log/slog" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" + + "realm.pub/tavern/internal/builder/builderpb" +) + +// builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. +type builderCredentials struct { + certDER []byte + privKey ed25519.PrivateKey +} + +// GetRequestMetadata generates fresh authentication metadata for each RPC call. +// It signs the current timestamp with the builder's private key to prove possession. +// Binary metadata (keys ending in "-bin") is automatically base64 encoded by gRPC. +func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + timestamp := time.Now().UTC().Format(time.RFC3339Nano) + + sig := ed25519.Sign(c.privKey, []byte(timestamp)) + + return map[string]string{ + mdKeyBuilderCert: string(c.certDER), + mdKeyBuilderSignature: string(sig), + mdKeyBuilderTimestamp: timestamp, + }, nil +} + +// RequireTransportSecurity returns false since Tavern uses h2c (HTTP/2 cleartext) +// with TLS terminated at the reverse proxy level. +func (c *builderCredentials) RequireTransportSecurity() bool { + return false +} + +// NewCredentialsFromConfig creates gRPC per-RPC credentials from a builder config. +func NewCredentialsFromConfig(cfg *Config) (credentials.PerRPCCredentials, error) { + return parseMTLSCredentials(cfg.MTLS) +} + +// parseMTLSCredentials loads the certificate and private key from the config's +// PEM bundle string. +func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { + pemBundle := []byte(mtlsPEM) + + var certDER []byte + var privKey ed25519.PrivateKey + + for { + block, rest := pem.Decode(pemBundle) + if block == nil { + break + } + switch block.Type { + case "CERTIFICATE": + certDER = block.Bytes + case "PRIVATE KEY": + key, err := x509.ParsePKCS8PrivateKey(block.Bytes) + if err != nil { + return nil, fmt.Errorf("failed to parse private key: %w", err) + } + edKey, ok := key.(ed25519.PrivateKey) + if !ok { + return nil, fmt.Errorf("private key is not ED25519") + } + privKey = edKey + } + pemBundle = rest + } + + if certDER == nil { + return nil, fmt.Errorf("no certificate found in mTLS bundle") + } + if privKey == nil { + return nil, fmt.Errorf("no private key found in mTLS bundle") + } + + return &builderCredentials{ + certDER: certDER, + privKey: privKey, + }, nil +} + +// Run starts the builder process using the provided configuration. +// It connects to the configured upstream server with mTLS credentials and sends a ping request. +func Run(ctx context.Context, cfg *Config) error { + slog.InfoContext(ctx, "builder started", + "id", cfg.ID, + "supported_targets", cfg.SupportedTargets, + "upstream", cfg.Upstream, + ) + + creds, err := parseMTLSCredentials(cfg.MTLS) + if err != nil { + return fmt.Errorf("failed to parse mTLS credentials: %w", err) + } + + conn, err := grpc.NewClient(cfg.Upstream, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + if err != nil { + return fmt.Errorf("failed to connect to upstream %q: %w", cfg.Upstream, err) + } + defer conn.Close() + + client := builderpb.NewBuilderClient(conn) + _, err = client.Ping(ctx, &builderpb.PingRequest{}) + if err != nil { + return fmt.Errorf("failed to ping upstream: %w", err) + } + + slog.InfoContext(ctx, "successfully pinged upstream", "upstream", cfg.Upstream) + + // Wait for context cancellation + <-ctx.Done() + return ctx.Err() +} diff --git a/tavern/internal/builder/config.go b/tavern/internal/builder/config.go new file mode 100644 index 000000000..ffbe7776e --- /dev/null +++ b/tavern/internal/builder/config.go @@ -0,0 +1,60 @@ +package builder + +import ( + "fmt" + "os" + + "gopkg.in/yaml.v3" +) + +// Config represents the YAML configuration for a builder. +type Config struct { + ID string `yaml:"id"` + SupportedTargets []string `yaml:"supported_targets"` + MTLS string `yaml:"mtls"` + Upstream string `yaml:"upstream"` +} + +// ParseConfig reads and parses a builder YAML configuration file. +func ParseConfig(path string) (*Config, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read config file %q: %w", path, err) + } + return ParseConfigBytes(data) +} + +// ParseConfigBytes parses builder YAML configuration from bytes. +func ParseConfigBytes(data []byte) (*Config, error) { + var cfg Config + if err := yaml.Unmarshal(data, &cfg); err != nil { + return nil, fmt.Errorf("failed to parse config: %w", err) + } + + if err := cfg.validate(); err != nil { + return nil, err + } + + return &cfg, nil +} + +func (cfg *Config) validate() error { + if cfg.ID == "" { + return fmt.Errorf("config must specify a builder id") + } + if len(cfg.SupportedTargets) == 0 { + return fmt.Errorf("config must specify at least one supported_target") + } + for _, target := range cfg.SupportedTargets { + switch target { + case "macos", "linux", "windows": + // valid + default: + return fmt.Errorf("unsupported target %q, must be one of: macos, linux, windows", target) + } + } + if cfg.Upstream == "" { + return fmt.Errorf("config must specify an upstream server address") + } + return nil +} diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go new file mode 100644 index 000000000..11fefe513 --- /dev/null +++ b/tavern/internal/builder/integration_test.go @@ -0,0 +1,148 @@ +package builder_test + +import ( + "context" + "crypto/ed25519" + "crypto/rand" + "net" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" + _ "github.com/mattn/go-sqlite3" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + "google.golang.org/grpc/test/bufconn" + + "realm.pub/tavern/internal/builder" + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/ent/enttest" + "realm.pub/tavern/internal/graphql" + tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/tomes" +) + +func TestBuilderE2E(t *testing.T) { + ctx := context.Background() + + // 1. Setup in-memory SQLite database + graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + // 2. Generate ED25519 key pair and create Builder CA + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) + require.NoError(t, err) + caCert, err := builder.CreateCA(caPrivKey) + require.NoError(t, err) + require.NotNil(t, caCert) + + // 3. Setup GraphQL server with authentication bypass and Builder CA + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + // 4. Register a builder via GraphQL mutation + var registerResp struct { + RegisterBuilder struct { + Builder struct { + ID string + } + MtlsCert string + Config string + } + } + + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + registerBuilder(input: $input) { + builder { id } + mtlsCert + config + } + }`, ®isterResp, client.Var("input", map[string]any{ + "supportedTargets": []string{"PLATFORM_LINUX", "PLATFORM_MACOS"}, + "upstream": "https://tavern.example.com:443", + })) + require.NoError(t, err) + require.NotEmpty(t, registerResp.RegisterBuilder.Builder.ID) + require.NotEmpty(t, registerResp.RegisterBuilder.MtlsCert) + require.NotEmpty(t, registerResp.RegisterBuilder.Config) + + // 5. Parse the returned YAML config + cfg, err := builder.ParseConfigBytes([]byte(registerResp.RegisterBuilder.Config)) + require.NoError(t, err) + assert.Contains(t, cfg.SupportedTargets, "linux") + assert.Contains(t, cfg.SupportedTargets, "macos") + assert.NotEmpty(t, cfg.MTLS) + assert.NotEmpty(t, cfg.ID) + assert.Equal(t, "https://tavern.example.com:443", cfg.Upstream) + + // 6. Verify builder exists in DB + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + assert.Equal(t, cfg.ID, builders[0].Identifier) + + // 7. Setup builder gRPC server via bufconn with mTLS auth interceptor + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewMTLSAuthInterceptor(caCert, graph), + ), + ) + builderSrv := builder.New(graph) + builderpb.RegisterBuilderServer(grpcSrv, builderSrv) + + go func() { + if err := grpcSrv.Serve(lis); err != nil { + t.Logf("gRPC server exited: %v", err) + } + }() + defer grpcSrv.Stop() + + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } + + // 8. Test: Unauthenticated request should be rejected + t.Run("unauthenticated request rejected", func(t *testing.T) { + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + require.NoError(t, err) + defer conn.Close() + + unauthClient := builderpb.NewBuilderClient(conn) + _, err = unauthClient.Ping(ctx, &builderpb.PingRequest{}) + require.Error(t, err) + assert.Equal(t, codes.Unauthenticated, status.Code(err)) + }) + + // 9. Test: Authenticated request should succeed + t.Run("authenticated request succeeds", func(t *testing.T) { + creds, err := builder.NewCredentialsFromConfig(cfg) + require.NoError(t, err) + + conn, err := grpc.NewClient("passthrough:///bufnet", + grpc.WithContextDialer(bufDialer), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithPerRPCCredentials(creds), + ) + require.NoError(t, err) + defer conn.Close() + + authClient := builderpb.NewBuilderClient(conn) + pingResp, err := authClient.Ping(ctx, &builderpb.PingRequest{}) + require.NoError(t, err) + require.NotNil(t, pingResp) + }) +} diff --git a/tavern/internal/builder/proto/builder.proto b/tavern/internal/builder/proto/builder.proto new file mode 100644 index 000000000..138641bc3 --- /dev/null +++ b/tavern/internal/builder/proto/builder.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package builder; + +option go_package = "realm.pub/tavern/internal/builder/builderpb"; + +message PingRequest {} +message PingResponse {} + +service Builder { + rpc Ping(PingRequest) returns (PingResponse) {} +} diff --git a/tavern/internal/builder/server.go b/tavern/internal/builder/server.go new file mode 100644 index 000000000..c7f2d4c2c --- /dev/null +++ b/tavern/internal/builder/server.go @@ -0,0 +1,28 @@ +package builder + +import ( + "context" + "log/slog" + + "realm.pub/tavern/internal/builder/builderpb" + "realm.pub/tavern/internal/ent" +) + +// Server implements the Builder gRPC service. +type Server struct { + graph *ent.Client + builderpb.UnimplementedBuilderServer +} + +// New creates a new Builder gRPC server. +func New(graph *ent.Client) *Server { + return &Server{ + graph: graph, + } +} + +// Ping is a simple health check endpoint. +func (s *Server) Ping(ctx context.Context, req *builderpb.PingRequest) (*builderpb.PingResponse, error) { + slog.Info("ping!") + return &builderpb.PingResponse{}, nil +} diff --git a/tavern/internal/ent/builder.go b/tavern/internal/ent/builder.go new file mode 100644 index 000000000..527ec31a2 --- /dev/null +++ b/tavern/internal/ent/builder.go @@ -0,0 +1,156 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" +) + +// Builder is the model entity for the Builder schema. +type Builder 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"` + // Unique identifier for the builder, embedded in its mTLS certificate CN. + Identifier string `json:"identifier,omitempty"` + // The platforms this builder can build agents for. + SupportedTargets []c2pb.Host_Platform `json:"supported_targets,omitempty"` + // The server address that the builder should connect to. + Upstream string `json:"upstream,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Builder) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case builder.FieldSupportedTargets: + values[i] = new([]byte) + case builder.FieldID: + values[i] = new(sql.NullInt64) + case builder.FieldIdentifier, builder.FieldUpstream: + values[i] = new(sql.NullString) + case builder.FieldCreatedAt, builder.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 Builder fields. +func (b *Builder) 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 builder.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + b.ID = int(value.Int64) + case builder.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 { + b.CreatedAt = value.Time + } + case builder.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 { + b.LastModifiedAt = value.Time + } + case builder.FieldIdentifier: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field identifier", values[i]) + } else if value.Valid { + b.Identifier = value.String + } + case builder.FieldSupportedTargets: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field supported_targets", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &b.SupportedTargets); err != nil { + return fmt.Errorf("unmarshal field supported_targets: %w", err) + } + } + case builder.FieldUpstream: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field upstream", values[i]) + } else if value.Valid { + b.Upstream = value.String + } + default: + b.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Builder. +// This includes values selected through modifiers, order, etc. +func (b *Builder) Value(name string) (ent.Value, error) { + return b.selectValues.Get(name) +} + +// Update returns a builder for updating this Builder. +// Note that you need to call Builder.Unwrap() before calling this method if this Builder +// was returned from a transaction, and the transaction was committed or rolled back. +func (b *Builder) Update() *BuilderUpdateOne { + return NewBuilderClient(b.config).UpdateOne(b) +} + +// Unwrap unwraps the Builder 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 (b *Builder) Unwrap() *Builder { + _tx, ok := b.config.driver.(*txDriver) + if !ok { + panic("ent: Builder is not a transactional entity") + } + b.config.driver = _tx.drv + return b +} + +// String implements the fmt.Stringer. +func (b *Builder) String() string { + var builder strings.Builder + builder.WriteString("Builder(") + builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("created_at=") + builder.WriteString(b.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(b.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("identifier=") + builder.WriteString(b.Identifier) + builder.WriteString(", ") + builder.WriteString("supported_targets=") + builder.WriteString(fmt.Sprintf("%v", b.SupportedTargets)) + builder.WriteString(", ") + builder.WriteString("upstream=") + builder.WriteString(b.Upstream) + builder.WriteByte(')') + return builder.String() +} + +// Builders is a parsable slice of Builder. +type Builders []*Builder diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go new file mode 100644 index 000000000..19caff758 --- /dev/null +++ b/tavern/internal/ent/builder/builder.go @@ -0,0 +1,89 @@ +// Code generated by ent, DO NOT EDIT. + +package builder + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the builder type in the database. + Label = "builder" + // 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" + // FieldIdentifier holds the string denoting the identifier field in the database. + FieldIdentifier = "identifier" + // FieldSupportedTargets holds the string denoting the supported_targets field in the database. + FieldSupportedTargets = "supported_targets" + // FieldUpstream holds the string denoting the upstream field in the database. + FieldUpstream = "upstream" + // Table holds the table name of the builder in the database. + Table = "builders" +) + +// Columns holds all SQL columns for builder fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldIdentifier, + FieldSupportedTargets, + FieldUpstream, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // 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 + // DefaultIdentifier holds the default value on creation for the "identifier" field. + DefaultIdentifier func() string + // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + IdentifierValidator func(string) error +) + +// OrderOption defines the ordering options for the Builder 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() +} + +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + +// ByUpstream orders the results by the upstream field. +func ByUpstream(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpstream, opts...).ToFunc() +} diff --git a/tavern/internal/ent/builder/where.go b/tavern/internal/ent/builder/where.go new file mode 100644 index 000000000..fcf05be32 --- /dev/null +++ b/tavern/internal/ent/builder/where.go @@ -0,0 +1,300 @@ +// Code generated by ent, DO NOT EDIT. + +package builder + +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.Builder { + return predicate.Builder(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Builder { + return predicate.Builder(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.Builder { + return predicate.Builder(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.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldIdentifier, v)) +} + +// Upstream applies equality check predicate on the "upstream" field. It's identical to UpstreamEQ. +func Upstream(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldIdentifier, v)) +} + +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldIdentifier, v)) +} + +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldIdentifier, vs...)) +} + +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldIdentifier, vs...)) +} + +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldIdentifier, v)) +} + +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldIdentifier, v)) +} + +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldIdentifier, v)) +} + +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldIdentifier, v)) +} + +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.Builder { + return predicate.Builder(sql.FieldContains(FieldIdentifier, v)) +} + +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasPrefix(FieldIdentifier, v)) +} + +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasSuffix(FieldIdentifier, v)) +} + +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldEqualFold(FieldIdentifier, v)) +} + +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldContainsFold(FieldIdentifier, v)) +} + +// UpstreamEQ applies the EQ predicate on the "upstream" field. +func UpstreamEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldEQ(FieldUpstream, v)) +} + +// UpstreamNEQ applies the NEQ predicate on the "upstream" field. +func UpstreamNEQ(v string) predicate.Builder { + return predicate.Builder(sql.FieldNEQ(FieldUpstream, v)) +} + +// UpstreamIn applies the In predicate on the "upstream" field. +func UpstreamIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldIn(FieldUpstream, vs...)) +} + +// UpstreamNotIn applies the NotIn predicate on the "upstream" field. +func UpstreamNotIn(vs ...string) predicate.Builder { + return predicate.Builder(sql.FieldNotIn(FieldUpstream, vs...)) +} + +// UpstreamGT applies the GT predicate on the "upstream" field. +func UpstreamGT(v string) predicate.Builder { + return predicate.Builder(sql.FieldGT(FieldUpstream, v)) +} + +// UpstreamGTE applies the GTE predicate on the "upstream" field. +func UpstreamGTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldGTE(FieldUpstream, v)) +} + +// UpstreamLT applies the LT predicate on the "upstream" field. +func UpstreamLT(v string) predicate.Builder { + return predicate.Builder(sql.FieldLT(FieldUpstream, v)) +} + +// UpstreamLTE applies the LTE predicate on the "upstream" field. +func UpstreamLTE(v string) predicate.Builder { + return predicate.Builder(sql.FieldLTE(FieldUpstream, v)) +} + +// UpstreamContains applies the Contains predicate on the "upstream" field. +func UpstreamContains(v string) predicate.Builder { + return predicate.Builder(sql.FieldContains(FieldUpstream, v)) +} + +// UpstreamHasPrefix applies the HasPrefix predicate on the "upstream" field. +func UpstreamHasPrefix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasPrefix(FieldUpstream, v)) +} + +// UpstreamHasSuffix applies the HasSuffix predicate on the "upstream" field. +func UpstreamHasSuffix(v string) predicate.Builder { + return predicate.Builder(sql.FieldHasSuffix(FieldUpstream, v)) +} + +// UpstreamEqualFold applies the EqualFold predicate on the "upstream" field. +func UpstreamEqualFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldEqualFold(FieldUpstream, v)) +} + +// UpstreamContainsFold applies the ContainsFold predicate on the "upstream" field. +func UpstreamContainsFold(v string) predicate.Builder { + return predicate.Builder(sql.FieldContainsFold(FieldUpstream, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Builder) predicate.Builder { + return predicate.Builder(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Builder) predicate.Builder { + return predicate.Builder(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Builder) predicate.Builder { + return predicate.Builder(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go new file mode 100644 index 000000000..371beb2c0 --- /dev/null +++ b/tavern/internal/ent/builder_create.go @@ -0,0 +1,653 @@ +// 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/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" +) + +// BuilderCreate is the builder for creating a Builder entity. +type BuilderCreate struct { + config + mutation *BuilderMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (bc *BuilderCreate) SetCreatedAt(t time.Time) *BuilderCreate { + bc.mutation.SetCreatedAt(t) + return bc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableCreatedAt(t *time.Time) *BuilderCreate { + if t != nil { + bc.SetCreatedAt(*t) + } + return bc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (bc *BuilderCreate) SetLastModifiedAt(t time.Time) *BuilderCreate { + bc.mutation.SetLastModifiedAt(t) + return bc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableLastModifiedAt(t *time.Time) *BuilderCreate { + if t != nil { + bc.SetLastModifiedAt(*t) + } + return bc +} + +// SetIdentifier sets the "identifier" field. +func (bc *BuilderCreate) SetIdentifier(s string) *BuilderCreate { + bc.mutation.SetIdentifier(s) + return bc +} + +// SetNillableIdentifier sets the "identifier" field if the given value is not nil. +func (bc *BuilderCreate) SetNillableIdentifier(s *string) *BuilderCreate { + if s != nil { + bc.SetIdentifier(*s) + } + return bc +} + +// SetSupportedTargets sets the "supported_targets" field. +func (bc *BuilderCreate) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderCreate { + bc.mutation.SetSupportedTargets(cp) + return bc +} + +// SetUpstream sets the "upstream" field. +func (bc *BuilderCreate) SetUpstream(s string) *BuilderCreate { + bc.mutation.SetUpstream(s) + return bc +} + +// Mutation returns the BuilderMutation object of the builder. +func (bc *BuilderCreate) Mutation() *BuilderMutation { + return bc.mutation +} + +// Save creates the Builder in the database. +func (bc *BuilderCreate) Save(ctx context.Context) (*Builder, error) { + bc.defaults() + return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bc *BuilderCreate) SaveX(ctx context.Context) *Builder { + v, err := bc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bc *BuilderCreate) Exec(ctx context.Context) error { + _, err := bc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bc *BuilderCreate) ExecX(ctx context.Context) { + if err := bc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bc *BuilderCreate) defaults() { + if _, ok := bc.mutation.CreatedAt(); !ok { + v := builder.DefaultCreatedAt() + bc.mutation.SetCreatedAt(v) + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + v := builder.DefaultLastModifiedAt() + bc.mutation.SetLastModifiedAt(v) + } + if _, ok := bc.mutation.Identifier(); !ok { + v := builder.DefaultIdentifier() + bc.mutation.SetIdentifier(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bc *BuilderCreate) check() error { + if _, ok := bc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Builder.created_at"`)} + } + if _, ok := bc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Builder.last_modified_at"`)} + } + if _, ok := bc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "Builder.identifier"`)} + } + if v, ok := bc.mutation.Identifier(); ok { + if err := builder.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Builder.identifier": %w`, err)} + } + } + if _, ok := bc.mutation.SupportedTargets(); !ok { + return &ValidationError{Name: "supported_targets", err: errors.New(`ent: missing required field "Builder.supported_targets"`)} + } + if _, ok := bc.mutation.Upstream(); !ok { + return &ValidationError{Name: "upstream", err: errors.New(`ent: missing required field "Builder.upstream"`)} + } + return nil +} + +func (bc *BuilderCreate) sqlSave(ctx context.Context) (*Builder, error) { + if err := bc.check(); err != nil { + return nil, err + } + _node, _spec := bc.createSpec() + if err := sqlgraph.CreateNode(ctx, bc.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) + bc.mutation.id = &_node.ID + bc.mutation.done = true + return _node, nil +} + +func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { + var ( + _node = &Builder{config: bc.config} + _spec = sqlgraph.NewCreateSpec(builder.Table, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + ) + _spec.OnConflict = bc.conflict + if value, ok := bc.mutation.CreatedAt(); ok { + _spec.SetField(builder.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := bc.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := bc.mutation.Identifier(); ok { + _spec.SetField(builder.FieldIdentifier, field.TypeString, value) + _node.Identifier = value + } + if value, ok := bc.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + _node.SupportedTargets = value + } + if value, ok := bc.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + _node.Upstream = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Builder.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.BuilderUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (bc *BuilderCreate) OnConflict(opts ...sql.ConflictOption) *BuilderUpsertOne { + bc.conflict = opts + return &BuilderUpsertOne{ + create: bc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bc *BuilderCreate) OnConflictColumns(columns ...string) *BuilderUpsertOne { + bc.conflict = append(bc.conflict, sql.ConflictColumns(columns...)) + return &BuilderUpsertOne{ + create: bc, + } +} + +type ( + // BuilderUpsertOne is the builder for "upsert"-ing + // one Builder node. + BuilderUpsertOne struct { + create *BuilderCreate + } + + // BuilderUpsert is the "OnConflict" setter. + BuilderUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsert) SetLastModifiedAt(v time.Time) *BuilderUpsert { + u.Set(builder.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateLastModifiedAt() *BuilderUpsert { + u.SetExcluded(builder.FieldLastModifiedAt) + return u +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsert) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsert { + u.Set(builder.FieldSupportedTargets, v) + return u +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateSupportedTargets() *BuilderUpsert { + u.SetExcluded(builder.FieldSupportedTargets) + return u +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsert) SetUpstream(v string) *BuilderUpsert { + u.Set(builder.FieldUpstream, v) + return u +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsert) UpdateUpstream() *BuilderUpsert { + u.SetExcluded(builder.FieldUpstream) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuilderUpsertOne) UpdateNewValues() *BuilderUpsertOne { + 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(builder.FieldCreatedAt) + } + if _, exists := u.create.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuilderUpsertOne) Ignore() *BuilderUpsertOne { + 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 *BuilderUpsertOne) DoNothing() *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuilderCreate.OnConflict +// documentation for more info. +func (u *BuilderUpsertOne) Update(set func(*BuilderUpsert)) *BuilderUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuilderUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsertOne) SetLastModifiedAt(v time.Time) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateLastModifiedAt() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsertOne) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetSupportedTargets(v) + }) +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateSupportedTargets() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateSupportedTargets() + }) +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsertOne) SetUpstream(v string) *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.SetUpstream(v) + }) +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsertOne) UpdateUpstream() *BuilderUpsertOne { + return u.Update(func(s *BuilderUpsert) { + s.UpdateUpstream() + }) +} + +// Exec executes the query. +func (u *BuilderUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuilderCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuilderUpsertOne) 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 *BuilderUpsertOne) 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 *BuilderUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// BuilderCreateBulk is the builder for creating many Builder entities in bulk. +type BuilderCreateBulk struct { + config + err error + builders []*BuilderCreate + conflict []sql.ConflictOption +} + +// Save creates the Builder entities in the database. +func (bcb *BuilderCreateBulk) Save(ctx context.Context) ([]*Builder, error) { + if bcb.err != nil { + return nil, bcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) + nodes := make([]*Builder, len(bcb.builders)) + mutators := make([]Mutator, len(bcb.builders)) + for i := range bcb.builders { + func(i int, root context.Context) { + builder := bcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BuilderMutation) + 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, bcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = bcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bcb.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, bcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bcb *BuilderCreateBulk) SaveX(ctx context.Context) []*Builder { + v, err := bcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bcb *BuilderCreateBulk) Exec(ctx context.Context) error { + _, err := bcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bcb *BuilderCreateBulk) ExecX(ctx context.Context) { + if err := bcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Builder.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.BuilderUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (bcb *BuilderCreateBulk) OnConflict(opts ...sql.ConflictOption) *BuilderUpsertBulk { + bcb.conflict = opts + return &BuilderUpsertBulk{ + create: bcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bcb *BuilderCreateBulk) OnConflictColumns(columns ...string) *BuilderUpsertBulk { + bcb.conflict = append(bcb.conflict, sql.ConflictColumns(columns...)) + return &BuilderUpsertBulk{ + create: bcb, + } +} + +// BuilderUpsertBulk is the builder for "upsert"-ing +// a bulk of Builder nodes. +type BuilderUpsertBulk struct { + create *BuilderCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BuilderUpsertBulk) UpdateNewValues() *BuilderUpsertBulk { + 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(builder.FieldCreatedAt) + } + if _, exists := b.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Builder.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BuilderUpsertBulk) Ignore() *BuilderUpsertBulk { + 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 *BuilderUpsertBulk) DoNothing() *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BuilderCreateBulk.OnConflict +// documentation for more info. +func (u *BuilderUpsertBulk) Update(set func(*BuilderUpsert)) *BuilderUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BuilderUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *BuilderUpsertBulk) SetLastModifiedAt(v time.Time) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateLastModifiedAt() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetSupportedTargets sets the "supported_targets" field. +func (u *BuilderUpsertBulk) SetSupportedTargets(v []c2pb.Host_Platform) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetSupportedTargets(v) + }) +} + +// UpdateSupportedTargets sets the "supported_targets" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateSupportedTargets() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateSupportedTargets() + }) +} + +// SetUpstream sets the "upstream" field. +func (u *BuilderUpsertBulk) SetUpstream(v string) *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.SetUpstream(v) + }) +} + +// UpdateUpstream sets the "upstream" field to the value that was provided on create. +func (u *BuilderUpsertBulk) UpdateUpstream() *BuilderUpsertBulk { + return u.Update(func(s *BuilderUpsert) { + s.UpdateUpstream() + }) +} + +// Exec executes the query. +func (u *BuilderUpsertBulk) 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 BuilderCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BuilderCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BuilderUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/builder_delete.go b/tavern/internal/ent/builder_delete.go new file mode 100644 index 000000000..463510b4a --- /dev/null +++ b/tavern/internal/ent/builder_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/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderDelete is the builder for deleting a Builder entity. +type BuilderDelete struct { + config + hooks []Hook + mutation *BuilderMutation +} + +// Where appends a list predicates to the BuilderDelete builder. +func (bd *BuilderDelete) Where(ps ...predicate.Builder) *BuilderDelete { + bd.mutation.Where(ps...) + return bd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bd *BuilderDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bd *BuilderDelete) ExecX(ctx context.Context) int { + n, err := bd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bd *BuilderDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(builder.Table, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + if ps := bd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bd.mutation.done = true + return affected, err +} + +// BuilderDeleteOne is the builder for deleting a single Builder entity. +type BuilderDeleteOne struct { + bd *BuilderDelete +} + +// Where appends a list predicates to the BuilderDelete builder. +func (bdo *BuilderDeleteOne) Where(ps ...predicate.Builder) *BuilderDeleteOne { + bdo.bd.mutation.Where(ps...) + return bdo +} + +// Exec executes the deletion query. +func (bdo *BuilderDeleteOne) Exec(ctx context.Context) error { + n, err := bdo.bd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{builder.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bdo *BuilderDeleteOne) ExecX(ctx context.Context) { + if err := bdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/builder_query.go b/tavern/internal/ent/builder_query.go new file mode 100644 index 000000000..71412c4b0 --- /dev/null +++ b/tavern/internal/ent/builder_query.go @@ -0,0 +1,540 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderQuery is the builder for querying Builder entities. +type BuilderQuery struct { + config + ctx *QueryContext + order []builder.OrderOption + inters []Interceptor + predicates []predicate.Builder + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Builder) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BuilderQuery builder. +func (bq *BuilderQuery) Where(ps ...predicate.Builder) *BuilderQuery { + bq.predicates = append(bq.predicates, ps...) + return bq +} + +// Limit the number of records to be returned by this query. +func (bq *BuilderQuery) Limit(limit int) *BuilderQuery { + bq.ctx.Limit = &limit + return bq +} + +// Offset to start from. +func (bq *BuilderQuery) Offset(offset int) *BuilderQuery { + bq.ctx.Offset = &offset + return bq +} + +// 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 (bq *BuilderQuery) Unique(unique bool) *BuilderQuery { + bq.ctx.Unique = &unique + return bq +} + +// Order specifies how the records should be ordered. +func (bq *BuilderQuery) Order(o ...builder.OrderOption) *BuilderQuery { + bq.order = append(bq.order, o...) + return bq +} + +// First returns the first Builder entity from the query. +// Returns a *NotFoundError when no Builder was found. +func (bq *BuilderQuery) First(ctx context.Context) (*Builder, error) { + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{builder.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bq *BuilderQuery) FirstX(ctx context.Context) *Builder { + node, err := bq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Builder ID from the query. +// Returns a *NotFoundError when no Builder ID was found. +func (bq *BuilderQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{builder.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bq *BuilderQuery) FirstIDX(ctx context.Context) int { + id, err := bq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Builder entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Builder entity is found. +// Returns a *NotFoundError when no Builder entities are found. +func (bq *BuilderQuery) Only(ctx context.Context) (*Builder, error) { + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{builder.Label} + default: + return nil, &NotSingularError{builder.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bq *BuilderQuery) OnlyX(ctx context.Context) *Builder { + node, err := bq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Builder ID in the query. +// Returns a *NotSingularError when more than one Builder ID is found. +// Returns a *NotFoundError when no entities are found. +func (bq *BuilderQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{builder.Label} + default: + err = &NotSingularError{builder.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bq *BuilderQuery) OnlyIDX(ctx context.Context) int { + id, err := bq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Builders. +func (bq *BuilderQuery) All(ctx context.Context) ([]*Builder, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll) + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Builder, *BuilderQuery]() + return withInterceptors[[]*Builder](ctx, bq, qr, bq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bq *BuilderQuery) AllX(ctx context.Context) []*Builder { + nodes, err := bq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Builder IDs. +func (bq *BuilderQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs) + if err = bq.Select(builder.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bq *BuilderQuery) IDsX(ctx context.Context) []int { + ids, err := bq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bq *BuilderQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount) + if err := bq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bq, querierCount[*BuilderQuery](), bq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bq *BuilderQuery) CountX(ctx context.Context) int { + count, err := bq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bq *BuilderQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist) + switch _, err := bq.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 (bq *BuilderQuery) ExistX(ctx context.Context) bool { + exist, err := bq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BuilderQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bq *BuilderQuery) Clone() *BuilderQuery { + if bq == nil { + return nil + } + return &BuilderQuery{ + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]builder.OrderOption{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Builder{}, bq.predicates...), + // clone intermediate query. + sql: bq.sql.Clone(), + path: bq.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.Builder.Query(). +// GroupBy(builder.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bq *BuilderQuery) GroupBy(field string, fields ...string) *BuilderGroupBy { + bq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BuilderGroupBy{build: bq} + grbuild.flds = &bq.ctx.Fields + grbuild.label = builder.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.Builder.Query(). +// Select(builder.FieldCreatedAt). +// Scan(ctx, &v) +func (bq *BuilderQuery) Select(fields ...string) *BuilderSelect { + bq.ctx.Fields = append(bq.ctx.Fields, fields...) + sbuild := &BuilderSelect{BuilderQuery: bq} + sbuild.label = builder.Label + sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BuilderSelect configured with the given aggregations. +func (bq *BuilderQuery) Aggregate(fns ...AggregateFunc) *BuilderSelect { + return bq.Select().Aggregate(fns...) +} + +func (bq *BuilderQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bq.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, bq); err != nil { + return err + } + } + } + for _, f := range bq.ctx.Fields { + if !builder.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bq.path != nil { + prev, err := bq.path(ctx) + if err != nil { + return err + } + bq.sql = prev + } + return nil +} + +func (bq *BuilderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Builder, error) { + var ( + nodes = []*Builder{} + _spec = bq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Builder).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Builder{config: bq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + for i := range bq.loadTotal { + if err := bq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (bq *BuilderQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bq.querySpec() + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + _spec.Node.Columns = bq.ctx.Fields + if len(bq.ctx.Fields) > 0 { + _spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bq.driver, _spec) +} + +func (bq *BuilderQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + _spec.From = bq.sql + if unique := bq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true + } + if fields := bq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, builder.FieldID) + for i := range fields { + if fields[i] != builder.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bq *BuilderQuery) sqlQuery(ctx context.Context) *sql.Selector { + builderC := sql.Dialect(bq.driver.Dialect()) + t1 := builderC.Table(builder.Table) + columns := bq.ctx.Fields + if len(columns) == 0 { + columns = builder.Columns + } + selector := builderC.Select(t1.Columns(columns...)...).From(t1) + if bq.sql != nil { + selector = bq.sql + selector.Select(selector.Columns(columns...)...) + } + if bq.ctx.Unique != nil && *bq.ctx.Unique { + selector.Distinct() + } + for _, p := range bq.predicates { + p(selector) + } + for _, p := range bq.order { + p(selector) + } + if offset := bq.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 := bq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// BuilderGroupBy is the group-by builder for Builder entities. +type BuilderGroupBy struct { + selector + build *BuilderQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bgb *BuilderGroupBy) Aggregate(fns ...AggregateFunc) *BuilderGroupBy { + bgb.fns = append(bgb.fns, fns...) + return bgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bgb *BuilderGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy) + if err := bgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuilderQuery, *BuilderGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v) +} + +func (bgb *BuilderGroupBy) sqlScan(ctx context.Context, root *BuilderQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bgb.fns)) + for _, fn := range bgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns)) + for _, f := range *bgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BuilderSelect is the builder for selecting fields of Builder entities. +type BuilderSelect struct { + *BuilderQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bs *BuilderSelect) Aggregate(fns ...AggregateFunc) *BuilderSelect { + bs.fns = append(bs.fns, fns...) + return bs +} + +// Scan applies the selector query and scans the result into the given value. +func (bs *BuilderSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect) + if err := bs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BuilderQuery, *BuilderSelect](ctx, bs.BuilderQuery, bs, bs.inters, v) +} + +func (bs *BuilderSelect) sqlScan(ctx context.Context, root *BuilderQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bs.fns)) + for _, fn := range bs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bs.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 := bs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/builder_update.go b/tavern/internal/ent/builder_update.go new file mode 100644 index 000000000..bb70a9a18 --- /dev/null +++ b/tavern/internal/ent/builder_update.go @@ -0,0 +1,288 @@ +// 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/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/builder" + "realm.pub/tavern/internal/ent/predicate" +) + +// BuilderUpdate is the builder for updating Builder entities. +type BuilderUpdate struct { + config + hooks []Hook + mutation *BuilderMutation +} + +// Where appends a list predicates to the BuilderUpdate builder. +func (bu *BuilderUpdate) Where(ps ...predicate.Builder) *BuilderUpdate { + bu.mutation.Where(ps...) + return bu +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (bu *BuilderUpdate) SetLastModifiedAt(t time.Time) *BuilderUpdate { + bu.mutation.SetLastModifiedAt(t) + return bu +} + +// SetSupportedTargets sets the "supported_targets" field. +func (bu *BuilderUpdate) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdate { + bu.mutation.SetSupportedTargets(cp) + return bu +} + +// AppendSupportedTargets appends cp to the "supported_targets" field. +func (bu *BuilderUpdate) AppendSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdate { + bu.mutation.AppendSupportedTargets(cp) + return bu +} + +// SetUpstream sets the "upstream" field. +func (bu *BuilderUpdate) SetUpstream(s string) *BuilderUpdate { + bu.mutation.SetUpstream(s) + return bu +} + +// SetNillableUpstream sets the "upstream" field if the given value is not nil. +func (bu *BuilderUpdate) SetNillableUpstream(s *string) *BuilderUpdate { + if s != nil { + bu.SetUpstream(*s) + } + return bu +} + +// Mutation returns the BuilderMutation object of the builder. +func (bu *BuilderUpdate) Mutation() *BuilderMutation { + return bu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bu *BuilderUpdate) Save(ctx context.Context) (int, error) { + bu.defaults() + return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bu *BuilderUpdate) SaveX(ctx context.Context) int { + affected, err := bu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bu *BuilderUpdate) Exec(ctx context.Context) error { + _, err := bu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bu *BuilderUpdate) ExecX(ctx context.Context) { + if err := bu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bu *BuilderUpdate) defaults() { + if _, ok := bu.mutation.LastModifiedAt(); !ok { + v := builder.UpdateDefaultLastModifiedAt() + bu.mutation.SetLastModifiedAt(v) + } +} + +func (bu *BuilderUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + if ps := bu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bu.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := bu.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + } + if value, ok := bu.mutation.AppendedSupportedTargets(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, builder.FieldSupportedTargets, value) + }) + } + if value, ok := bu.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{builder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bu.mutation.done = true + return n, nil +} + +// BuilderUpdateOne is the builder for updating a single Builder entity. +type BuilderUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BuilderMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (buo *BuilderUpdateOne) SetLastModifiedAt(t time.Time) *BuilderUpdateOne { + buo.mutation.SetLastModifiedAt(t) + return buo +} + +// SetSupportedTargets sets the "supported_targets" field. +func (buo *BuilderUpdateOne) SetSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdateOne { + buo.mutation.SetSupportedTargets(cp) + return buo +} + +// AppendSupportedTargets appends cp to the "supported_targets" field. +func (buo *BuilderUpdateOne) AppendSupportedTargets(cp []c2pb.Host_Platform) *BuilderUpdateOne { + buo.mutation.AppendSupportedTargets(cp) + return buo +} + +// SetUpstream sets the "upstream" field. +func (buo *BuilderUpdateOne) SetUpstream(s string) *BuilderUpdateOne { + buo.mutation.SetUpstream(s) + return buo +} + +// SetNillableUpstream sets the "upstream" field if the given value is not nil. +func (buo *BuilderUpdateOne) SetNillableUpstream(s *string) *BuilderUpdateOne { + if s != nil { + buo.SetUpstream(*s) + } + return buo +} + +// Mutation returns the BuilderMutation object of the builder. +func (buo *BuilderUpdateOne) Mutation() *BuilderMutation { + return buo.mutation +} + +// Where appends a list predicates to the BuilderUpdate builder. +func (buo *BuilderUpdateOne) Where(ps ...predicate.Builder) *BuilderUpdateOne { + buo.mutation.Where(ps...) + return buo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (buo *BuilderUpdateOne) Select(field string, fields ...string) *BuilderUpdateOne { + buo.fields = append([]string{field}, fields...) + return buo +} + +// Save executes the query and returns the updated Builder entity. +func (buo *BuilderUpdateOne) Save(ctx context.Context) (*Builder, error) { + buo.defaults() + return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (buo *BuilderUpdateOne) SaveX(ctx context.Context) *Builder { + node, err := buo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (buo *BuilderUpdateOne) Exec(ctx context.Context) error { + _, err := buo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (buo *BuilderUpdateOne) ExecX(ctx context.Context) { + if err := buo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (buo *BuilderUpdateOne) defaults() { + if _, ok := buo.mutation.LastModifiedAt(); !ok { + v := builder.UpdateDefaultLastModifiedAt() + buo.mutation.SetLastModifiedAt(v) + } +} + +func (buo *BuilderUpdateOne) sqlSave(ctx context.Context) (_node *Builder, err error) { + _spec := sqlgraph.NewUpdateSpec(builder.Table, builder.Columns, sqlgraph.NewFieldSpec(builder.FieldID, field.TypeInt)) + id, ok := buo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Builder.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := buo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, builder.FieldID) + for _, f := range fields { + if !builder.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != builder.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := buo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := buo.mutation.LastModifiedAt(); ok { + _spec.SetField(builder.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := buo.mutation.SupportedTargets(); ok { + _spec.SetField(builder.FieldSupportedTargets, field.TypeJSON, value) + } + if value, ok := buo.mutation.AppendedSupportedTargets(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, builder.FieldSupportedTargets, value) + }) + } + if value, ok := buo.mutation.Upstream(); ok { + _spec.SetField(builder.FieldUpstream, field.TypeString, value) + } + _node = &Builder{config: buo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{builder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + buo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 0a1a7b2f4..e0db6a50b 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -17,6 +17,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -41,6 +42,8 @@ type Client struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // Builder is the client for interacting with the Builder builders. + Builder *BuilderClient // Host is the client for interacting with the Host builders. Host *HostClient // HostCredential is the client for interacting with the HostCredential builders. @@ -82,6 +85,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Asset = NewAssetClient(c.config) c.Beacon = NewBeaconClient(c.config) + c.Builder = NewBuilderClient(c.config) c.Host = NewHostClient(c.config) c.HostCredential = NewHostCredentialClient(c.config) c.HostFile = NewHostFileClient(c.config) @@ -189,6 +193,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), HostFile: NewHostFileClient(cfg), @@ -223,6 +228,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, Asset: NewAssetClient(cfg), Beacon: NewBeaconClient(cfg), + Builder: NewBuilderClient(cfg), Host: NewHostClient(cfg), HostCredential: NewHostCredentialClient(cfg), HostFile: NewHostFileClient(cfg), @@ -265,8 +271,9 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Asset, c.Beacon, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, - c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, + c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, + c.Tome, c.User, } { n.Use(hooks...) } @@ -276,8 +283,9 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Asset, c.Beacon, c.Host, c.HostCredential, c.HostFile, c.HostProcess, c.Link, - c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, c.Tome, c.User, + c.Asset, c.Beacon, c.Builder, c.Host, c.HostCredential, c.HostFile, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.Tag, c.Task, + c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -290,6 +298,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Asset.mutate(ctx, m) case *BeaconMutation: return c.Beacon.mutate(ctx, m) + case *BuilderMutation: + return c.Builder.mutate(ctx, m) case *HostMutation: return c.Host.mutate(ctx, m) case *HostCredentialMutation: @@ -684,6 +694,139 @@ func (c *BeaconClient) mutate(ctx context.Context, m *BeaconMutation) (Value, er } } +// BuilderClient is a client for the Builder schema. +type BuilderClient struct { + config +} + +// NewBuilderClient returns a client for the Builder from the given config. +func NewBuilderClient(c config) *BuilderClient { + return &BuilderClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `builder.Hooks(f(g(h())))`. +func (c *BuilderClient) Use(hooks ...Hook) { + c.hooks.Builder = append(c.hooks.Builder, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `builder.Intercept(f(g(h())))`. +func (c *BuilderClient) Intercept(interceptors ...Interceptor) { + c.inters.Builder = append(c.inters.Builder, interceptors...) +} + +// Create returns a builder for creating a Builder entity. +func (c *BuilderClient) Create() *BuilderCreate { + mutation := newBuilderMutation(c.config, OpCreate) + return &BuilderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Builder entities. +func (c *BuilderClient) CreateBulk(builders ...*BuilderCreate) *BuilderCreateBulk { + return &BuilderCreateBulk{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 *BuilderClient) MapCreateBulk(slice any, setFunc func(*BuilderCreate, int)) *BuilderCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BuilderCreateBulk{err: fmt.Errorf("calling to BuilderClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BuilderCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BuilderCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Builder. +func (c *BuilderClient) Update() *BuilderUpdate { + mutation := newBuilderMutation(c.config, OpUpdate) + return &BuilderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BuilderClient) UpdateOne(b *Builder) *BuilderUpdateOne { + mutation := newBuilderMutation(c.config, OpUpdateOne, withBuilder(b)) + return &BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BuilderClient) UpdateOneID(id int) *BuilderUpdateOne { + mutation := newBuilderMutation(c.config, OpUpdateOne, withBuilderID(id)) + return &BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Builder. +func (c *BuilderClient) Delete() *BuilderDelete { + mutation := newBuilderMutation(c.config, OpDelete) + return &BuilderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BuilderClient) DeleteOne(b *Builder) *BuilderDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BuilderClient) DeleteOneID(id int) *BuilderDeleteOne { + builderC := c.Delete().Where(builder.ID(id)) + builderC.mutation.id = &id + builderC.mutation.op = OpDeleteOne + return &BuilderDeleteOne{builderC} +} + +// Query returns a query builder for Builder. +func (c *BuilderClient) Query() *BuilderQuery { + return &BuilderQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBuilder}, + inters: c.Interceptors(), + } +} + +// Get returns a Builder entity by its id. +func (c *BuilderClient) Get(ctx context.Context, id int) (*Builder, error) { + return c.Query().Where(builder.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BuilderClient) GetX(ctx context.Context, id int) *Builder { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *BuilderClient) Hooks() []Hook { + return c.hooks.Builder +} + +// Interceptors returns the client interceptors. +func (c *BuilderClient) Interceptors() []Interceptor { + return c.inters.Builder +} + +func (c *BuilderClient) mutate(ctx context.Context, m *BuilderMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BuilderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BuilderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BuilderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BuilderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Builder mutation op: %q", m.Op()) + } +} + // HostClient is a client for the Host schema. type HostClient struct { config @@ -3060,11 +3203,11 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Asset, Beacon, Host, HostCredential, HostFile, HostProcess, Link, Portal, Quest, - Repository, Shell, Tag, Task, Tome, User []ent.Hook + Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, + Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Hook } inters struct { - Asset, Beacon, Host, HostCredential, HostFile, HostProcess, Link, Portal, Quest, - Repository, Shell, Tag, Task, Tome, User []ent.Interceptor + Asset, Beacon, Builder, Host, HostCredential, HostFile, HostProcess, Link, + Portal, Quest, Repository, Shell, Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index a21bd7f8d..b3c89e42e 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -89,6 +90,7 @@ func checkColumn(table, column string) error { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ asset.Table: asset.ValidColumn, beacon.Table: beacon.ValidColumn, + builder.Table: builder.ValidColumn, host.Table: host.ValidColumn, hostcredential.Table: hostcredential.ValidColumn, hostfile.Table: hostfile.ValidColumn, diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index fc19b6774..4b54f9dc5 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -12,6 +12,7 @@ import ( "github.com/99designs/gqlgen/graphql" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -664,6 +665,121 @@ func newBeaconPaginateArgs(rv map[string]any) *beaconPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (b *BuilderQuery) CollectFields(ctx context.Context, satisfies ...string) (*BuilderQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return b, nil + } + if err := b.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return b, nil +} + +func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, 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(builder.Columns)) + selectedFields = []string{builder.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "createdAt": + if _, ok := fieldSeen[builder.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, builder.FieldCreatedAt) + fieldSeen[builder.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[builder.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, builder.FieldLastModifiedAt) + fieldSeen[builder.FieldLastModifiedAt] = struct{}{} + } + case "identifier": + if _, ok := fieldSeen[builder.FieldIdentifier]; !ok { + selectedFields = append(selectedFields, builder.FieldIdentifier) + fieldSeen[builder.FieldIdentifier] = struct{}{} + } + case "supportedTargets": + if _, ok := fieldSeen[builder.FieldSupportedTargets]; !ok { + selectedFields = append(selectedFields, builder.FieldSupportedTargets) + fieldSeen[builder.FieldSupportedTargets] = struct{}{} + } + case "upstream": + if _, ok := fieldSeen[builder.FieldUpstream]; !ok { + selectedFields = append(selectedFields, builder.FieldUpstream) + fieldSeen[builder.FieldUpstream] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + b.Select(selectedFields...) + } + return nil +} + +type builderPaginateArgs struct { + first, last *int + after, before *Cursor + opts []BuilderPaginateOption +} + +func newBuilderPaginateArgs(rv map[string]any) *builderPaginateArgs { + args := &builderPaginateArgs{} + 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 []*BuilderOrder: + args.opts = append(args.opts, WithBuilderOrder(v)) + case []any: + var orders []*BuilderOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &BuilderOrder{Field: &BuilderOrderField{}, 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, WithBuilderOrder(orders)) + } + } + if v, ok := rv[whereField].(*BuilderWhereInput); ok { + args.opts = append(args.opts, WithBuilderFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (h *HostQuery) CollectFields(ctx context.Context, satisfies ...string) (*HostQuery, error) { fc := graphql.GetFieldContext(ctx) diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index cd1e4894d..13b2bcf7a 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -5,6 +5,7 @@ package ent import ( "time" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/tome" @@ -38,6 +39,26 @@ func (c *BeaconUpdateOne) SetInput(i UpdateBeaconInput) *BeaconUpdateOne { return c } +// CreateBuilderInput represents a mutation input for creating builders. +type CreateBuilderInput struct { + SupportedTargets []c2pb.Host_Platform + Upstream string +} + +// Mutate applies the CreateBuilderInput on the BuilderMutation builder. +func (i *CreateBuilderInput) Mutate(m *BuilderMutation) { + if v := i.SupportedTargets; v != nil { + m.SetSupportedTargets(v) + } + m.SetUpstream(i.Upstream) +} + +// SetInput applies the change-set in the CreateBuilderInput on the BuilderCreate builder. +func (c *BuilderCreate) SetInput(i CreateBuilderInput) *BuilderCreate { + i.Mutate(c.Mutation()) + return c +} + // UpdateHostInput represents a mutation input for updating hosts. type UpdateHostInput struct { LastModifiedAt *time.Time diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 5b34d5212..1e4248275 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -17,6 +17,7 @@ import ( "golang.org/x/sync/semaphore" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -47,6 +48,11 @@ var beaconImplementors = []string{"Beacon", "Node"} // IsNode implements the Node interface check for GQLGen. func (*Beacon) IsNode() {} +var builderImplementors = []string{"Builder", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*Builder) IsNode() {} + var hostImplementors = []string{"Host", "Node"} // IsNode implements the Node interface check for GQLGen. @@ -188,6 +194,15 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) } } return query.Only(ctx) + case builder.Table: + query := c.Builder.Query(). + Where(builder.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, builderImplementors...); err != nil { + return nil, err + } + } + return query.Only(ctx) case host.Table: query := c.Host.Query(). Where(host.ID(id)) @@ -410,6 +425,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } + case builder.Table: + query := c.Builder.Query(). + Where(builder.IDIn(ids...)) + query, err := query.CollectFields(ctx, builderImplementors...) + 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 host.Table: query := c.Host.Query(). Where(host.IDIn(ids...)) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 49265c99d..96107fe76 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -17,6 +17,7 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -902,6 +903,356 @@ func (b *Beacon) ToEdge(order *BeaconOrder) *BeaconEdge { } } +// BuilderEdge is the edge representation of Builder. +type BuilderEdge struct { + Node *Builder `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// BuilderConnection is the connection containing edges to Builder. +type BuilderConnection struct { + Edges []*BuilderEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *BuilderConnection) build(nodes []*Builder, pager *builderPager, 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) *Builder + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Builder { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Builder { + return nodes[i] + } + } + c.Edges = make([]*BuilderEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &BuilderEdge{ + 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) + } +} + +// BuilderPaginateOption enables pagination customization. +type BuilderPaginateOption func(*builderPager) error + +// WithBuilderOrder configures pagination ordering. +func WithBuilderOrder(order []*BuilderOrder) BuilderPaginateOption { + return func(pager *builderPager) error { + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } + } + pager.order = append(pager.order, order...) + return nil + } +} + +// WithBuilderFilter configures pagination filter. +func WithBuilderFilter(filter func(*BuilderQuery) (*BuilderQuery, error)) BuilderPaginateOption { + return func(pager *builderPager) error { + if filter == nil { + return errors.New("BuilderQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type builderPager struct { + reverse bool + order []*BuilderOrder + filter func(*BuilderQuery) (*BuilderQuery, error) +} + +func newBuilderPager(opts []BuilderPaginateOption, reverse bool) (*builderPager, error) { + pager := &builderPager{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 *builderPager) applyFilter(query *BuilderQuery) (*BuilderQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *builderPager) toCursor(b *Builder) Cursor { + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(b).Value) + } + return Cursor{ID: b.ID, Value: cs_} +} + +func (p *builderPager) applyCursors(query *BuilderQuery, after, before *Cursor) (*BuilderQuery, 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: DefaultBuilderOrder.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 *builderPager) applyOrder(query *BuilderQuery) *BuilderQuery { + 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 == DefaultBuilderOrder.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(DefaultBuilderOrder.Field.toTerm(direction.OrderTermOption())) + } + return query +} + +func (p *builderPager) orderExpr(query *BuilderQuery) 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(DefaultBuilderOrder.Field.column).Pad().WriteString(string(direction)) + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Builder. +func (b *BuilderQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...BuilderPaginateOption, +) (*BuilderConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newBuilderPager(opts, last != nil) + if err != nil { + return nil, err + } + if b, err = pager.applyFilter(b); err != nil { + return nil, err + } + conn := &BuilderConnection{Edges: []*BuilderEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := b.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.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 b, err = pager.applyCursors(b, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + b.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := b.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + b = pager.applyOrder(b) + nodes, err := b.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // BuilderOrderFieldCreatedAt orders Builder by created_at. + BuilderOrderFieldCreatedAt = &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.CreatedAt, nil + }, + column: builder.FieldCreatedAt, + toTerm: builder.ByCreatedAt, + toCursor: func(b *Builder) Cursor { + return Cursor{ + ID: b.ID, + Value: b.CreatedAt, + } + }, + } + // BuilderOrderFieldLastModifiedAt orders Builder by last_modified_at. + BuilderOrderFieldLastModifiedAt = &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.LastModifiedAt, nil + }, + column: builder.FieldLastModifiedAt, + toTerm: builder.ByLastModifiedAt, + toCursor: func(b *Builder) Cursor { + return Cursor{ + ID: b.ID, + Value: b.LastModifiedAt, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f BuilderOrderField) String() string { + var str string + switch f.column { + case BuilderOrderFieldCreatedAt.column: + str = "CREATED_AT" + case BuilderOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f BuilderOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *BuilderOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("BuilderOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *BuilderOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *BuilderOrderFieldLastModifiedAt + default: + return fmt.Errorf("%s is not a valid BuilderOrderField", str) + } + return nil +} + +// BuilderOrderField defines the ordering field of Builder. +type BuilderOrderField struct { + // Value extracts the ordering value from the given Builder. + Value func(*Builder) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) builder.OrderOption + toCursor func(*Builder) Cursor +} + +// BuilderOrder defines the ordering of Builder. +type BuilderOrder struct { + Direction OrderDirection `json:"direction"` + Field *BuilderOrderField `json:"field"` +} + +// DefaultBuilderOrder is the default ordering of Builder. +var DefaultBuilderOrder = &BuilderOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &BuilderOrderField{ + Value: func(b *Builder) (ent.Value, error) { + return b.ID, nil + }, + column: builder.FieldID, + toTerm: builder.ByID, + toCursor: func(b *Builder) Cursor { + return Cursor{ID: b.ID} + }, + }, +} + +// ToEdge converts Builder into BuilderEdge. +func (b *Builder) ToEdge(order *BuilderOrder) *BuilderEdge { + if order == nil { + order = DefaultBuilderOrder + } + return &BuilderEdge{ + Node: b, + Cursor: order.Field.toCursor(b), + } +} + // HostEdge is the edge representation of Host. type HostEdge struct { Node *Host `json:"node"` diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 1d93873ae..dc6db4529 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -11,6 +11,7 @@ import ( "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -1061,6 +1062,306 @@ func (i *BeaconWhereInput) P() (predicate.Beacon, error) { } } +// BuilderWhereInput represents a where input for filtering Builder queries. +type BuilderWhereInput struct { + Predicates []predicate.Builder `json:"-"` + Not *BuilderWhereInput `json:"not,omitempty"` + Or []*BuilderWhereInput `json:"or,omitempty"` + And []*BuilderWhereInput `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"` + + // "identifier" field predicates. + Identifier *string `json:"identifier,omitempty"` + IdentifierNEQ *string `json:"identifierNEQ,omitempty"` + IdentifierIn []string `json:"identifierIn,omitempty"` + IdentifierNotIn []string `json:"identifierNotIn,omitempty"` + IdentifierGT *string `json:"identifierGT,omitempty"` + IdentifierGTE *string `json:"identifierGTE,omitempty"` + IdentifierLT *string `json:"identifierLT,omitempty"` + IdentifierLTE *string `json:"identifierLTE,omitempty"` + IdentifierContains *string `json:"identifierContains,omitempty"` + IdentifierHasPrefix *string `json:"identifierHasPrefix,omitempty"` + IdentifierHasSuffix *string `json:"identifierHasSuffix,omitempty"` + IdentifierEqualFold *string `json:"identifierEqualFold,omitempty"` + IdentifierContainsFold *string `json:"identifierContainsFold,omitempty"` + + // "upstream" field predicates. + Upstream *string `json:"upstream,omitempty"` + UpstreamNEQ *string `json:"upstreamNEQ,omitempty"` + UpstreamIn []string `json:"upstreamIn,omitempty"` + UpstreamNotIn []string `json:"upstreamNotIn,omitempty"` + UpstreamGT *string `json:"upstreamGT,omitempty"` + UpstreamGTE *string `json:"upstreamGTE,omitempty"` + UpstreamLT *string `json:"upstreamLT,omitempty"` + UpstreamLTE *string `json:"upstreamLTE,omitempty"` + UpstreamContains *string `json:"upstreamContains,omitempty"` + UpstreamHasPrefix *string `json:"upstreamHasPrefix,omitempty"` + UpstreamHasSuffix *string `json:"upstreamHasSuffix,omitempty"` + UpstreamEqualFold *string `json:"upstreamEqualFold,omitempty"` + UpstreamContainsFold *string `json:"upstreamContainsFold,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *BuilderWhereInput) AddPredicates(predicates ...predicate.Builder) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the BuilderWhereInput filter on the BuilderQuery builder. +func (i *BuilderWhereInput) Filter(q *BuilderQuery) (*BuilderQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyBuilderWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyBuilderWhereInput is returned in case the BuilderWhereInput is empty. +var ErrEmptyBuilderWhereInput = errors.New("ent: empty predicate BuilderWhereInput") + +// P returns a predicate for filtering builders. +// An error is returned if the input is empty or invalid. +func (i *BuilderWhereInput) P() (predicate.Builder, error) { + var predicates []predicate.Builder + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, builder.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.Builder, 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, builder.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.Builder, 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, builder.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, builder.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, builder.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, builder.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, builder.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, builder.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, builder.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, builder.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, builder.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, builder.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, builder.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, builder.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, builder.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, builder.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, builder.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, builder.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, builder.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, builder.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, builder.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, builder.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, builder.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, builder.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, builder.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, builder.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, builder.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.Identifier != nil { + predicates = append(predicates, builder.IdentifierEQ(*i.Identifier)) + } + if i.IdentifierNEQ != nil { + predicates = append(predicates, builder.IdentifierNEQ(*i.IdentifierNEQ)) + } + if len(i.IdentifierIn) > 0 { + predicates = append(predicates, builder.IdentifierIn(i.IdentifierIn...)) + } + if len(i.IdentifierNotIn) > 0 { + predicates = append(predicates, builder.IdentifierNotIn(i.IdentifierNotIn...)) + } + if i.IdentifierGT != nil { + predicates = append(predicates, builder.IdentifierGT(*i.IdentifierGT)) + } + if i.IdentifierGTE != nil { + predicates = append(predicates, builder.IdentifierGTE(*i.IdentifierGTE)) + } + if i.IdentifierLT != nil { + predicates = append(predicates, builder.IdentifierLT(*i.IdentifierLT)) + } + if i.IdentifierLTE != nil { + predicates = append(predicates, builder.IdentifierLTE(*i.IdentifierLTE)) + } + if i.IdentifierContains != nil { + predicates = append(predicates, builder.IdentifierContains(*i.IdentifierContains)) + } + if i.IdentifierHasPrefix != nil { + predicates = append(predicates, builder.IdentifierHasPrefix(*i.IdentifierHasPrefix)) + } + if i.IdentifierHasSuffix != nil { + predicates = append(predicates, builder.IdentifierHasSuffix(*i.IdentifierHasSuffix)) + } + if i.IdentifierEqualFold != nil { + predicates = append(predicates, builder.IdentifierEqualFold(*i.IdentifierEqualFold)) + } + if i.IdentifierContainsFold != nil { + predicates = append(predicates, builder.IdentifierContainsFold(*i.IdentifierContainsFold)) + } + if i.Upstream != nil { + predicates = append(predicates, builder.UpstreamEQ(*i.Upstream)) + } + if i.UpstreamNEQ != nil { + predicates = append(predicates, builder.UpstreamNEQ(*i.UpstreamNEQ)) + } + if len(i.UpstreamIn) > 0 { + predicates = append(predicates, builder.UpstreamIn(i.UpstreamIn...)) + } + if len(i.UpstreamNotIn) > 0 { + predicates = append(predicates, builder.UpstreamNotIn(i.UpstreamNotIn...)) + } + if i.UpstreamGT != nil { + predicates = append(predicates, builder.UpstreamGT(*i.UpstreamGT)) + } + if i.UpstreamGTE != nil { + predicates = append(predicates, builder.UpstreamGTE(*i.UpstreamGTE)) + } + if i.UpstreamLT != nil { + predicates = append(predicates, builder.UpstreamLT(*i.UpstreamLT)) + } + if i.UpstreamLTE != nil { + predicates = append(predicates, builder.UpstreamLTE(*i.UpstreamLTE)) + } + if i.UpstreamContains != nil { + predicates = append(predicates, builder.UpstreamContains(*i.UpstreamContains)) + } + if i.UpstreamHasPrefix != nil { + predicates = append(predicates, builder.UpstreamHasPrefix(*i.UpstreamHasPrefix)) + } + if i.UpstreamHasSuffix != nil { + predicates = append(predicates, builder.UpstreamHasSuffix(*i.UpstreamHasSuffix)) + } + if i.UpstreamEqualFold != nil { + predicates = append(predicates, builder.UpstreamEqualFold(*i.UpstreamEqualFold)) + } + if i.UpstreamContainsFold != nil { + predicates = append(predicates, builder.UpstreamContainsFold(*i.UpstreamContainsFold)) + } + + switch len(predicates) { + case 0: + return nil, ErrEmptyBuilderWhereInput + case 1: + return predicates[0], nil + default: + return builder.And(predicates...), nil + } +} + // HostWhereInput represents a where input for filtering Host queries. type HostWhereInput struct { Predicates []predicate.Host `json:"-"` diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 3f2677073..6c3f39320 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -33,6 +33,18 @@ func (f BeaconFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, erro return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BeaconMutation", m) } +// The BuilderFunc type is an adapter to allow the use of ordinary +// function as Builder mutator. +type BuilderFunc func(context.Context, *ent.BuilderMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BuilderFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BuilderMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BuilderMutation", m) +} + // The HostFunc type is an adapter to allow the use of ordinary // function as Host mutator. type HostFunc func(context.Context, *ent.HostMutation) (ent.Value, error) diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 9478dbfc0..2cc90f21b 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -63,6 +63,21 @@ var ( }, }, } + // BuildersColumns holds the columns for the "builders" table. + BuildersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "identifier", Type: field.TypeString, Unique: true}, + {Name: "supported_targets", Type: field.TypeJSON}, + {Name: "upstream", Type: field.TypeString}, + } + // BuildersTable holds the schema information for the "builders" table. + BuildersTable = &schema.Table{ + Name: "builders", + Columns: BuildersColumns, + PrimaryKey: []*schema.Column{BuildersColumns[0]}, + } // HostsColumns holds the columns for the "hosts" table. HostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -567,6 +582,7 @@ var ( Tables = []*schema.Table{ AssetsTable, BeaconsTable, + BuildersTable, HostsTable, HostCredentialsTable, HostFilesTable, @@ -595,6 +611,9 @@ func init() { BeaconsTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", } + BuildersTable.Annotation = &entsql.Annotation{ + Collation: "utf8mb4_general_ci", + } HostsTable.ForeignKeys[0].RefTable = TomesTable HostsTable.Annotation = &entsql.Annotation{ Collation: "utf8mb4_general_ci", diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index bfeaec2d6..0090293fe 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -15,6 +15,7 @@ import ( "realm.pub/tavern/internal/c2/epb" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -42,6 +43,7 @@ const ( // Node types. TypeAsset = "Asset" TypeBeacon = "Beacon" + TypeBuilder = "Builder" TypeHost = "Host" TypeHostCredential = "HostCredential" TypeHostFile = "HostFile" @@ -2106,6 +2108,564 @@ func (m *BeaconMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Beacon edge %s", name) } +// BuilderMutation represents an operation that mutates the Builder nodes in the graph. +type BuilderMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + identifier *string + supported_targets *[]c2pb.Host_Platform + appendsupported_targets []c2pb.Host_Platform + upstream *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Builder, error) + predicates []predicate.Builder +} + +var _ ent.Mutation = (*BuilderMutation)(nil) + +// builderOption allows management of the mutation configuration using functional options. +type builderOption func(*BuilderMutation) + +// newBuilderMutation creates new mutation for the Builder entity. +func newBuilderMutation(c config, op Op, opts ...builderOption) *BuilderMutation { + m := &BuilderMutation{ + config: c, + op: op, + typ: TypeBuilder, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withBuilderID sets the ID field of the mutation. +func withBuilderID(id int) builderOption { + return func(m *BuilderMutation) { + var ( + err error + once sync.Once + value *Builder + ) + m.oldValue = func(ctx context.Context) (*Builder, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Builder.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withBuilder sets the old Builder of the mutation. +func withBuilder(node *Builder) builderOption { + return func(m *BuilderMutation) { + m.oldValue = func(context.Context) (*Builder, 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 BuilderMutation) 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 BuilderMutation) 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 *BuilderMutation) 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 *BuilderMutation) 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().Builder.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 *BuilderMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *BuilderMutation) 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 Builder entity. +// If the Builder 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 *BuilderMutation) 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 *BuilderMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *BuilderMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *BuilderMutation) 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 Builder entity. +// If the Builder 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 *BuilderMutation) 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 *BuilderMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetIdentifier sets the "identifier" field. +func (m *BuilderMutation) SetIdentifier(s string) { + m.identifier = &s +} + +// Identifier returns the value of the "identifier" field in the mutation. +func (m *BuilderMutation) Identifier() (r string, exists bool) { + v := m.identifier + if v == nil { + return + } + return *v, true +} + +// OldIdentifier returns the old "identifier" field's value of the Builder entity. +// If the Builder 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 *BuilderMutation) OldIdentifier(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIdentifier requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) + } + return oldValue.Identifier, nil +} + +// ResetIdentifier resets all changes to the "identifier" field. +func (m *BuilderMutation) ResetIdentifier() { + m.identifier = nil +} + +// SetSupportedTargets sets the "supported_targets" field. +func (m *BuilderMutation) SetSupportedTargets(cp []c2pb.Host_Platform) { + m.supported_targets = &cp + m.appendsupported_targets = nil +} + +// SupportedTargets returns the value of the "supported_targets" field in the mutation. +func (m *BuilderMutation) SupportedTargets() (r []c2pb.Host_Platform, exists bool) { + v := m.supported_targets + if v == nil { + return + } + return *v, true +} + +// OldSupportedTargets returns the old "supported_targets" field's value of the Builder entity. +// If the Builder 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 *BuilderMutation) OldSupportedTargets(ctx context.Context) (v []c2pb.Host_Platform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupportedTargets is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupportedTargets requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupportedTargets: %w", err) + } + return oldValue.SupportedTargets, nil +} + +// AppendSupportedTargets adds cp to the "supported_targets" field. +func (m *BuilderMutation) AppendSupportedTargets(cp []c2pb.Host_Platform) { + m.appendsupported_targets = append(m.appendsupported_targets, cp...) +} + +// AppendedSupportedTargets returns the list of values that were appended to the "supported_targets" field in this mutation. +func (m *BuilderMutation) AppendedSupportedTargets() ([]c2pb.Host_Platform, bool) { + if len(m.appendsupported_targets) == 0 { + return nil, false + } + return m.appendsupported_targets, true +} + +// ResetSupportedTargets resets all changes to the "supported_targets" field. +func (m *BuilderMutation) ResetSupportedTargets() { + m.supported_targets = nil + m.appendsupported_targets = nil +} + +// SetUpstream sets the "upstream" field. +func (m *BuilderMutation) SetUpstream(s string) { + m.upstream = &s +} + +// Upstream returns the value of the "upstream" field in the mutation. +func (m *BuilderMutation) Upstream() (r string, exists bool) { + v := m.upstream + if v == nil { + return + } + return *v, true +} + +// OldUpstream returns the old "upstream" field's value of the Builder entity. +// If the Builder 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 *BuilderMutation) OldUpstream(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpstream is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpstream requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpstream: %w", err) + } + return oldValue.Upstream, nil +} + +// ResetUpstream resets all changes to the "upstream" field. +func (m *BuilderMutation) ResetUpstream() { + m.upstream = nil +} + +// Where appends a list predicates to the BuilderMutation builder. +func (m *BuilderMutation) Where(ps ...predicate.Builder) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BuilderMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BuilderMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Builder, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *BuilderMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *BuilderMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Builder). +func (m *BuilderMutation) 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 *BuilderMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.created_at != nil { + fields = append(fields, builder.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, builder.FieldLastModifiedAt) + } + if m.identifier != nil { + fields = append(fields, builder.FieldIdentifier) + } + if m.supported_targets != nil { + fields = append(fields, builder.FieldSupportedTargets) + } + if m.upstream != nil { + fields = append(fields, builder.FieldUpstream) + } + 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 *BuilderMutation) Field(name string) (ent.Value, bool) { + switch name { + case builder.FieldCreatedAt: + return m.CreatedAt() + case builder.FieldLastModifiedAt: + return m.LastModifiedAt() + case builder.FieldIdentifier: + return m.Identifier() + case builder.FieldSupportedTargets: + return m.SupportedTargets() + case builder.FieldUpstream: + return m.Upstream() + } + 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 *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case builder.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case builder.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case builder.FieldIdentifier: + return m.OldIdentifier(ctx) + case builder.FieldSupportedTargets: + return m.OldSupportedTargets(ctx) + case builder.FieldUpstream: + return m.OldUpstream(ctx) + } + return nil, fmt.Errorf("unknown Builder 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 *BuilderMutation) SetField(name string, value ent.Value) error { + switch name { + case builder.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 builder.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 builder.FieldIdentifier: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIdentifier(v) + return nil + case builder.FieldSupportedTargets: + v, ok := value.([]c2pb.Host_Platform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSupportedTargets(v) + return nil + case builder.FieldUpstream: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpstream(v) + return nil + } + return fmt.Errorf("unknown Builder field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BuilderMutation) 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 *BuilderMutation) 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 *BuilderMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Builder numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BuilderMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BuilderMutation) 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 *BuilderMutation) ClearField(name string) error { + return fmt.Errorf("unknown Builder 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 *BuilderMutation) ResetField(name string) error { + switch name { + case builder.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case builder.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case builder.FieldIdentifier: + m.ResetIdentifier() + return nil + case builder.FieldSupportedTargets: + m.ResetSupportedTargets() + return nil + case builder.FieldUpstream: + m.ResetUpstream() + return nil + } + return fmt.Errorf("unknown Builder field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BuilderMutation) 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 *BuilderMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BuilderMutation) 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 *BuilderMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BuilderMutation) 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 *BuilderMutation) 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 *BuilderMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Builder 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 *BuilderMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Builder edge %s", name) +} + // HostMutation represents an operation that mutates the Host nodes in the graph. type HostMutation struct { config diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 349ef9c68..307d53f64 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -12,6 +12,9 @@ type Asset func(*sql.Selector) // Beacon is the predicate function for beacon builders. type Beacon func(*sql.Selector) +// Builder is the predicate function for builder builders. +type Builder func(*sql.Selector) + // Host is the predicate function for host builders. type Host func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index 42918df69..28cc3463a 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -158,6 +158,30 @@ func (f BeaconMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BeaconMutation", m) } +// The BuilderQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type BuilderQueryRuleFunc func(context.Context, *ent.BuilderQuery) error + +// EvalQuery return f(ctx, q). +func (f BuilderQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.BuilderQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.BuilderQuery", q) +} + +// The BuilderMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type BuilderMutationRuleFunc func(context.Context, *ent.BuilderMutation) error + +// EvalMutation calls f(ctx, m). +func (f BuilderMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.BuilderMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BuilderMutation", m) +} + // The HostQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type HostQueryRuleFunc func(context.Context, *ent.HostQuery) error diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index e89494406..b6a41a928 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -7,6 +7,7 @@ import ( "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/builder" "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" @@ -93,6 +94,27 @@ func init() { beaconDescAgentIdentifier := beaconFields[3].Descriptor() // beacon.AgentIdentifierValidator is a validator for the "agent_identifier" field. It is called by the builders before save. beacon.AgentIdentifierValidator = beaconDescAgentIdentifier.Validators[0].(func(string) error) + builderMixin := schema.Builder{}.Mixin() + builderMixinFields0 := builderMixin[0].Fields() + _ = builderMixinFields0 + builderFields := schema.Builder{}.Fields() + _ = builderFields + // builderDescCreatedAt is the schema descriptor for created_at field. + builderDescCreatedAt := builderMixinFields0[0].Descriptor() + // builder.DefaultCreatedAt holds the default value on creation for the created_at field. + builder.DefaultCreatedAt = builderDescCreatedAt.Default.(func() time.Time) + // builderDescLastModifiedAt is the schema descriptor for last_modified_at field. + builderDescLastModifiedAt := builderMixinFields0[1].Descriptor() + // builder.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + builder.DefaultLastModifiedAt = builderDescLastModifiedAt.Default.(func() time.Time) + // builder.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + builder.UpdateDefaultLastModifiedAt = builderDescLastModifiedAt.UpdateDefault.(func() time.Time) + // builderDescIdentifier is the schema descriptor for identifier field. + builderDescIdentifier := builderFields[0].Descriptor() + // builder.DefaultIdentifier holds the default value on creation for the identifier field. + builder.DefaultIdentifier = builderDescIdentifier.Default.(func() string) + // builder.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + builder.IdentifierValidator = builderDescIdentifier.Validators[0].(func(string) error) hostMixin := schema.Host{}.Mixin() hostMixinFields0 := hostMixin[0].Fields() _ = hostMixinFields0 diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go new file mode 100644 index 000000000..7fee66808 --- /dev/null +++ b/tavern/internal/ent/schema/builder.go @@ -0,0 +1,65 @@ +package schema + +import ( + "github.com/google/uuid" + + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" +) + +// Builder holds the schema definition for the Builder entity. +type Builder struct { + ent.Schema +} + +// Fields of the Builder. +func (Builder) Fields() []ent.Field { + return []ent.Field{ + field.String("identifier"). + DefaultFunc(uuid.New().String). + NotEmpty(). + Unique(). + Immutable(). + Annotations( + entgql.Skip(entgql.SkipMutationCreateInput), + ). + Comment("Unique identifier for the builder, embedded in its mTLS certificate CN."), + field.JSON("supported_targets", []c2pb.Host_Platform{}). + Annotations( + entgql.Type("[HostPlatform!]"), + ). + Comment("The platforms this builder can build agents for."), + field.String("upstream"). + Comment("The server address that the builder should connect to."), + } +} + +// Edges of the Builder. +func (Builder) Edges() []ent.Edge { + return nil +} + +// Annotations describes additional information for the ent. +func (Builder) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.RelayConnection(), + entgql.MultiOrder(), + entgql.Mutations( + entgql.MutationCreate(), + ), + entsql.Annotation{ + Collation: "utf8mb4_general_ci", + }, + } +} + +// Mixin defines common shared properties for the ent. +func (Builder) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index 0ac7520ee..1fb27f5b7 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { Asset *AssetClient // Beacon is the client for interacting with the Beacon builders. Beacon *BeaconClient + // Builder is the client for interacting with the Builder builders. + Builder *BuilderClient // Host is the client for interacting with the Host builders. Host *HostClient // HostCredential is the client for interacting with the HostCredential builders. @@ -175,6 +177,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Asset = NewAssetClient(tx.config) tx.Beacon = NewBeaconClient(tx.config) + tx.Builder = NewBuilderClient(tx.config) tx.Host = NewHostClient(tx.config) tx.HostCredential = NewHostCredentialClient(tx.config) tx.HostFile = NewHostFileClient(tx.config) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 50588aa28..7c953ef9a 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2439,12 +2439,12 @@ func (ec *executionContext) fieldContext_BeaconEdge_cursor(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_id(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_id, + ec.fieldContext_Builder_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -2455,9 +2455,9 @@ func (ec *executionContext) _Host_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2468,12 +2468,12 @@ func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_createdAt, + ec.fieldContext_Builder_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -2484,9 +2484,9 @@ func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2497,12 +2497,12 @@ func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastModifiedAt, + ec.fieldContext_Builder_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -2513,9 +2513,9 @@ func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2526,12 +2526,12 @@ func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_identifier, + ec.fieldContext_Builder_identifier, func(ctx context.Context) (any, error) { return obj.Identifier, nil }, @@ -2542,9 +2542,9 @@ func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2555,54 +2555,54 @@ func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_name, + ec.fieldContext_Builder_supportedTargets, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.SupportedTargets, nil }, nil, - ec.marshalOString2string, + ec.marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_supportedTargets(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", 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 HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Builder_upstream(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_primaryIP, + ec.fieldContext_Builder_upstream, func(ctx context.Context) (any, error) { - return obj.PrimaryIP, nil + return obj.Upstream, nil }, nil, - ec.marshalOString2string, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Builder_upstream(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "Builder", Field: field, IsMethod: false, IsResolver: false, @@ -2613,518 +2613,432 @@ func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field return fc, nil } -func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_externalIP, + ec.fieldContext_BuilderConnection_edges, func(ctx context.Context) (any, error) { - return obj.ExternalIP, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge, true, false, ) } -func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", 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_BuilderEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_BuilderEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuilderEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_platform, + ec.fieldContext_BuilderConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Platform, nil + return obj.PageInfo, nil }, nil, - ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostPlatform 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) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_lastSeenAt, + ec.fieldContext_BuilderConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.LastSeenAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderConnection", 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) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_nextSeenAt, + ec.fieldContext_BuilderEdge_node, func(ctx context.Context) (any, error) { - return obj.NextSeenAt, nil + return obj.Node, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, true, false, ) } -func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderEdge", 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_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, } return fc, nil } -func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.BuilderEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_tags, + ec.fieldContext_BuilderEdge_cursor, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return obj.Cursor, nil }, nil, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BuilderEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Host", + Object: "BuilderEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, errors.New("field of type Cursor 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_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_id(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_beacons, + ec.fieldContext_Host_id, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) + return obj.ID, nil }, nil, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + 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_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_files, + ec.fieldContext_Host_createdAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) + return obj.CreatedAt, nil }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostFileConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostFileConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", field.Name) + return nil, errors.New("field of type Time 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_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_processes, + ec.fieldContext_Host_lastModifiedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, errors.New("field of type Time 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_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_identifier(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Host_credentials, + ec.fieldContext_Host_identifier, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) + return obj.Identifier, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostCredentialConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_name(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_edges, + ec.fieldContext_Host_name, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Name, nil }, nil, - ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", 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_HostEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_primaryIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_pageInfo, + ec.fieldContext_Host_primaryIP, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.PrimaryIP, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_primaryIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_externalIP(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostConnection_totalCount, + ec.fieldContext_Host_externalIP, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.ExternalIP, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_externalIP(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostConnection", + Object: "Host", 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) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_id, + ec.fieldContext_Host_platform, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Platform, nil }, nil, - ec.marshalNID2int, + ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_platform(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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 HostPlatform does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_createdAt, + ec.fieldContext_Host_lastSeenAt, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.LastSeenAt, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3135,25 +3049,25 @@ func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Cont return fc, nil } -func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_nextSeenAt(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_lastModifiedAt, + ec.fieldContext_Host_nextSeenAt, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.NextSeenAt, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3164,256 +3078,292 @@ func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context return fc, nil } -func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_tags(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_principal, + ec.fieldContext_Host_tags, func(ctx context.Context) (any, error) { - return obj.Principal, nil + fc := graphql.GetFieldContext(ctx) + return obj.Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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 "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TagConnection", 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_Host_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_beacons(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_secret, + ec.fieldContext_Host_beacons, func(ctx context.Context) (any, error) { - return obj.Secret, nil + fc := graphql.GetFieldContext(ctx) + return obj.Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, nil, - ec.marshalNString2string, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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 "edges": + return ec.fieldContext_BeaconConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", 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_Host_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_kind, + ec.fieldContext_Host_files, func(ctx context.Context) (any, error) { - return obj.Kind, nil + fc := graphql.GetFieldContext(ctx) + return obj.Files(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostFileOrder), fc.Args["where"].(*ent.HostFileWhereInput)) }, nil, - ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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 HostCredentialKind does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_HostFileConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostFileConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostFileConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileConnection", 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_Host_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_host, + ec.fieldContext_Host_processes, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.Processes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostProcessOrder), fc.Args["where"].(*ent.HostProcessWhereInput)) }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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_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 "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(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) + case "edges": + return ec.fieldContext_HostProcessConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", 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_Host_processes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { +func (ec *executionContext) _Host_credentials(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredential_task, + ec.fieldContext_Host_credentials, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.Credentials(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostCredentialOrder), fc.Args["where"].(*ent.HostCredentialWhereInput)) }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", 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_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) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) + case "edges": + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostCredentialConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", 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_Host_credentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_edges, + ec.fieldContext_HostConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, + ec.marshalOHostEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", 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_HostCredentialEdge_node(ctx, field) + return ec.fieldContext_HostEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) + return ec.fieldContext_HostEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_pageInfo, + ec.fieldContext_HostConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -3424,9 +3374,9 @@ func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Conte ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, @@ -3447,12 +3397,12 @@ func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ con return fc, nil } -func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialConnection_totalCount, + ec.fieldContext_HostConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -3463,9 +3413,9 @@ func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Con ) } -func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialConnection", + Object: "HostConnection", Field: field, IsMethod: false, IsResolver: false, @@ -3476,454 +3426,502 @@ func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ c return fc, nil } -func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_node, + ec.fieldContext_HostCredential_id, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.ID, nil }, nil, - ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "HostCredential", 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_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 ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostCredentialEdge_cursor, + ec.fieldContext_HostCredential_createdAt, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredentialEdge", + Object: "HostCredential", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_node, + ec.fieldContext_HostCredential_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "HostCredential", 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_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 "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostEdge_cursor, + ec.fieldContext_HostCredential_principal, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Principal, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostEdge", + Object: "HostCredential", 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) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_secret(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_id, + ec.fieldContext_HostCredential_secret, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Secret, nil }, nil, - ec.marshalNID2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_secret(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", 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) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_kind(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_createdAt, + ec.fieldContext_HostCredential_kind, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Kind, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", 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 HostCredentialKind does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_lastModifiedAt, + ec.fieldContext_HostCredential_host, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Host(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", 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_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 "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(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 fc, nil } -func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredential_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredential) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_path, + ec.fieldContext_HostCredential_task, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Task(ctx) }, nil, - ec.marshalNString2string, - true, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredential", 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_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) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_owner, + ec.fieldContext_HostCredentialConnection_edges, func(ctx context.Context) (any, error) { - return obj.Owner, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOHostCredentialEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", 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_HostCredentialEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostCredentialEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostCredentialEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_group, + ec.fieldContext_HostCredentialConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Group, nil + return obj.PageInfo, nil }, nil, - ec.marshalOString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", 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 "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) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_permissions, + ec.fieldContext_HostCredentialConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Permissions, nil + return obj.TotalCount, nil }, nil, - ec.marshalOString2string, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialConnection", 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 Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_size, + ec.fieldContext_HostCredentialEdge_node, func(ctx context.Context) (any, error) { - return obj.Size, nil + return obj.Node, nil }, nil, - ec.marshalNUint642uint64, - true, + ec.marshalOHostCredential2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredential, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 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) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostCredentialEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostCredentialEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_hash, + ec.fieldContext_HostCredentialEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Hash, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostCredentialEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostCredentialEdge", 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) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_host, + ec.fieldContext_HostEdge_node, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + return obj.Node, nil }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, - true, + ec.marshalOHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, + false, ) } -func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -3964,2216 +3962,2172 @@ func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field return fc, nil } -func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { +func (ec *executionContext) _HostEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFile_task, + ec.fieldContext_HostEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Cursor, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFile", + Object: "HostEdge", 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_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) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_edges, + ec.fieldContext_HostFile_id, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.ID, nil }, nil, - ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostFile", 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_HostFileEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostFileEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_pageInfo, + ec.fieldContext_HostFile_createdAt, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostFile", 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) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileConnection_totalCount, + ec.fieldContext_HostFile_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNInt2int, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostFile", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_node, + ec.fieldContext_HostFile_path, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Path, nil }, nil, - ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostFile", 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_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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostFileEdge_cursor, + ec.fieldContext_HostFile_owner, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Owner, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileEdge", + Object: "HostFile", 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) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_id, + ec.fieldContext_HostFile_group, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Group, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_group(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", 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) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_createdAt, + ec.fieldContext_HostFile_permissions, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Permissions, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_permissions(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_lastModifiedAt, + ec.fieldContext_HostFile_size, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Size, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", 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 Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_pid, + ec.fieldContext_HostFile_hash, func(ctx context.Context) (any, error) { - return obj.Pid, nil + return obj.Hash, nil }, nil, - ec.marshalNUint642uint64, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint64 does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_ppid, + ec.fieldContext_HostFile_host, func(ctx context.Context) (any, error) { - return obj.Ppid, nil + return obj.Host(ctx) }, nil, - ec.marshalNUint642uint64, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", 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 Uint64 does not have child fields") + 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 "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(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 fc, nil } -func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_name, + ec.fieldContext_HostFile_task, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Task(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", + 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_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) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HostFileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_HostFileConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HostFileConnection", 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_HostFileEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostFileEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_principal, + ec.fieldContext_HostFileConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Principal, nil + return obj.PageInfo, nil }, nil, - ec.marshalNString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFileConnection", 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 "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) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_path, + ec.fieldContext_HostFileConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.TotalCount, nil }, nil, - ec.marshalOString2string, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFileConnection", 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 Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_cmd, + ec.fieldContext_HostFileEdge_node, func(ctx context.Context) (any, error) { - return obj.Cmd, nil + return obj.Node, nil }, nil, - ec.marshalOString2string, + ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, true, false, ) } -func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFileEdge", 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_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) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostFileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostFileEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_env, + ec.fieldContext_HostFileEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Env, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFileEdge", 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) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_cwd, + ec.fieldContext_HostProcess_id, func(ctx context.Context) (any, error) { - return obj.Cwd, nil + return obj.ID, nil }, nil, - ec.marshalOString2string, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", 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) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_status, + ec.fieldContext_HostProcess_createdAt, func(ctx context.Context) (any, error) { - return obj.Status, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type HostProcessStatus does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_host, + ec.fieldContext_HostProcess_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Host(ctx) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", 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 "externalIP": - return ec.fieldContext_Host_externalIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "nextSeenAt": - return ec.fieldContext_Host_nextSeenAt(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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcess_task, + ec.fieldContext_HostProcess_pid, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Pid, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", 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_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) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_edges, + ec.fieldContext_HostProcess_ppid, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Ppid, nil }, nil, - ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, + ec.marshalNUint642uint64, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_ppid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostProcess", 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_HostProcessEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_HostProcessEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_pageInfo, + ec.fieldContext_HostProcess_name, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Name, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostProcess", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessConnection_totalCount, + ec.fieldContext_HostProcess_principal, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Principal, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_principal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostProcess", 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) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_node, + ec.fieldContext_HostProcess_path, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Path, nil }, nil, - ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostProcess", 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_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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_HostProcessEdge_cursor, + ec.fieldContext_HostProcess_cmd, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Cmd, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cmd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessEdge", + Object: "HostProcess", 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) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_id, + ec.fieldContext_HostProcess_env, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Env, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_env(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", 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) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_createdAt, + ec.fieldContext_HostProcess_cwd, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Cwd, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_cwd(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_lastModifiedAt, + ec.fieldContext_HostProcess_status, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Status, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, true, true, ) } -func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", 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 HostProcessStatus does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_path, + ec.fieldContext_HostProcess_host, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Host(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", 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_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 "externalIP": + return ec.fieldContext_Host_externalIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "nextSeenAt": + return ec.fieldContext_Host_nextSeenAt(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 fc, nil } -func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_expiresAt, + ec.fieldContext_HostProcess_task, func(ctx context.Context) (any, error) { - return obj.ExpiresAt, nil + return obj.Task(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcess", 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_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) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + }, } return fc, nil } -func (ec *executionContext) _Link_downloadLimit(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_downloadLimit, + ec.fieldContext_HostProcessConnection_edges, func(ctx context.Context) (any, error) { - return obj.DownloadLimit, nil + return obj.Edges, nil }, nil, - ec.marshalOInt2ᚖint, + ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, true, false, ) } -func (ec *executionContext) fieldContext_Link_downloadLimit(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcessConnection", 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") + switch field.Name { + case "node": + return ec.fieldContext_HostProcessEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Link_downloads(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_downloads, + ec.fieldContext_HostProcessConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Downloads, nil + return obj.PageInfo, nil }, nil, - ec.marshalNInt2int, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Link_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcessConnection", 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") + 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) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_asset, + ec.fieldContext_HostProcessConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Asset(ctx) + return obj.TotalCount, nil }, nil, - ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcessConnection", 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_Asset_id(ctx, field) - case "createdAt": - return ec.fieldContext_Asset_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Asset_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Asset_name(ctx, field) - case "size": - return ec.fieldContext_Asset_size(ctx, field) - case "hash": - return ec.fieldContext_Asset_hash(ctx, field) - case "tomes": - return ec.fieldContext_Asset_tomes(ctx, field) - case "links": - return ec.fieldContext_Asset_links(ctx, field) - case "creator": - return ec.fieldContext_Asset_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Link_creator, + ec.fieldContext_HostProcessEdge_node, func(ctx context.Context) (any, error) { - return obj.Creator(ctx) + return obj.Node, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, true, false, ) } -func (ec *executionContext) fieldContext_Link_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Link", + Object: "HostProcessEdge", 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) + 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_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) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + 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 User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_edges, + ec.fieldContext_HostProcessEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Cursor, nil }, nil, - ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "HostProcessEdge", 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_LinkEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_LinkEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_pageInfo, + ec.fieldContext_Link_id, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.ID, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "Link", 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 ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_totalCount, + ec.fieldContext_Link_createdAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNInt2int, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkConnection", + Object: "Link", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_node, + ec.fieldContext_Link_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "Link", 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_Link_id(ctx, field) - case "createdAt": - return ec.fieldContext_Link_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Link_lastModifiedAt(ctx, field) - case "path": - return ec.fieldContext_Link_path(ctx, field) - case "expiresAt": - return ec.fieldContext_Link_expiresAt(ctx, field) - case "downloadLimit": - return ec.fieldContext_Link_downloadLimit(ctx, field) - case "downloads": - return ec.fieldContext_Link_downloads(ctx, field) - case "asset": - return ec.fieldContext_Link_asset(ctx, field) - case "creator": - return ec.fieldContext_Link_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_cursor, + ec.fieldContext_Link_path, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Path, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_path(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LinkEdge", + Object: "Link", 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) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasNextPage, + ec.fieldContext_Link_expiresAt, func(ctx context.Context) (any, error) { - return obj.HasNextPage, nil + return obj.ExpiresAt, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_expiresAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Link", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_downloadLimit(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasPreviousPage, + ec.fieldContext_Link_downloadLimit, func(ctx context.Context) (any, error) { - return obj.HasPreviousPage, nil + return obj.DownloadLimit, nil }, nil, - ec.marshalNBoolean2bool, - true, + ec.marshalOInt2ᚖint, true, + false, ) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_downloadLimit(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Link", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_downloads(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_startCursor, + ec.fieldContext_Link_downloads, func(ctx context.Context) (any, error) { - return obj.StartCursor, nil + return obj.Downloads, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_downloads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Link", 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 Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_endCursor, + ec.fieldContext_Link_asset, func(ctx context.Context) (any, error) { - return obj.EndCursor, nil + return obj.Asset(ctx) }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Link", 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 Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Asset_id(ctx, field) + case "createdAt": + return ec.fieldContext_Asset_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Asset_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Asset_name(ctx, field) + case "size": + return ec.fieldContext_Asset_size(ctx, field) + case "hash": + return ec.fieldContext_Asset_hash(ctx, field) + case "tomes": + return ec.fieldContext_Asset_tomes(ctx, field) + case "links": + return ec.fieldContext_Asset_links(ctx, field) + case "creator": + return ec.fieldContext_Asset_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _Link_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_id, + ec.fieldContext_Link_creator, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Creator(ctx) }, nil, - ec.marshalNID2int, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Link_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "Link", 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_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) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_createdAt, + ec.fieldContext_LinkConnection_edges, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Edges, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "LinkConnection", 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_LinkEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_LinkEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_lastModifiedAt, + ec.fieldContext_LinkConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "LinkConnection", 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) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_closedAt, + ec.fieldContext_LinkConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "LinkConnection", 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) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_task, + ec.fieldContext_LinkEdge_node, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Node, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, - true, + ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "LinkEdge", 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_Task_id(ctx, field) + return ec.fieldContext_Link_id(ctx, field) case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) + return ec.fieldContext_Link_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) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { - return graphql.ResolveField( + return ec.fieldContext_Link_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_Link_path(ctx, field) + case "expiresAt": + return ec.fieldContext_Link_expiresAt(ctx, field) + case "downloadLimit": + return ec.fieldContext_Link_downloadLimit(ctx, field) + case "downloads": + return ec.fieldContext_Link_downloads(ctx, field) + case "asset": + return ec.fieldContext_Link_asset(ctx, field) + case "creator": + return ec.fieldContext_Link_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LinkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_beacon, + ec.fieldContext_LinkEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.Cursor, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LinkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "LinkEdge", 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 "nextSeenAt": - return ec.fieldContext_Beacon_nextSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "transport": - return ec.fieldContext_Beacon_transport(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - case "shells": - return ec.fieldContext_Beacon_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_owner, + ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.HasNextPage, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "PageInfo", 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) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_activeUsers, + ec.fieldContext_PageInfo_hasPreviousPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return obj.HasPreviousPage, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Portal", + Object: "PageInfo", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_edges, + ec.fieldContext_PageInfo_startCursor, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.StartCursor, nil }, nil, - ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, false, ) } -func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "PageInfo", 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_PortalEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_PortalEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_pageInfo, + ec.fieldContext_PageInfo_endCursor, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.EndCursor, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "PageInfo", 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 Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_totalCount, + ec.fieldContext_Portal_id, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.ID, nil }, nil, - ec.marshalNInt2int, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalConnection", + Object: "Portal", 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 ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_node, + ec.fieldContext_Portal_createdAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.CreatedAt, nil }, nil, - ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "Portal", 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_Portal_id(ctx, field) - case "createdAt": - return ec.fieldContext_Portal_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Portal_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Portal_closedAt(ctx, field) - case "task": - return ec.fieldContext_Portal_task(ctx, field) - case "beacon": - return ec.fieldContext_Portal_beacon(ctx, field) - case "owner": - return ec.fieldContext_Portal_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Portal_activeUsers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalEdge_cursor, + ec.fieldContext_Portal_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PortalEdge", + Object: "Portal", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_node, + ec.fieldContext_Portal_closedAt, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) + return obj.ClosedAt, nil }, nil, - ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalOTime2timeᚐTime, true, false, ) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_nodes, + ec.fieldContext_Portal_task, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) + return obj.Task(ctx) }, nil, - ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + 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) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", 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_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_assets, + ec.fieldContext_Portal_beacon, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) + return obj.Beacon(ctx) }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next + nil, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + true, + true, + ) +} - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.AssetConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.AssetConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) +func (ec *executionContext) fieldContext_Portal_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Portal", + 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_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 "nextSeenAt": + return ec.fieldContext_Beacon_nextSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "transport": + return ec.fieldContext_Beacon_transport(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + case "shells": + return ec.fieldContext_Beacon_shells(ctx, field) } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + }, + } + return fc, nil +} - next = directive1 - return next +func (ec *executionContext) _Portal_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Portal_owner, + func(ctx context.Context) (any, error) { + return obj.Owner(ctx) }, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + nil, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_AssetConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) + 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) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_quests, + ec.fieldContext_Portal_activeUsers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.QuestConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.QuestConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ActiveUsers(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, - ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, + nil, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Portal_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Portal", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_QuestConnection_edges(ctx, field) + return ec.fieldContext_UserConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_QuestConnection_pageInfo(ctx, field) + return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_QuestConnection_totalCount(ctx, field) + return ec.fieldContext_UserConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } defer func() { @@ -6183,64 +6137,217 @@ func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Portal_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tasks, + ec.fieldContext_PortalConnection_edges, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) + return obj.Edges, nil }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next + nil, + ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, + true, + false, + ) +} - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.TaskConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TaskConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) +func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PortalConnection", + 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_PortalEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_PortalEdge_cursor(ctx, field) } + return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) + }, + } + return fc, nil +} - next = directive1 - return next +func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_PortalConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil }, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PortalConnection", + 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 fc, nil +} + +func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_PortalConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PortalConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_PortalEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PortalEdge", + 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_Portal_id(ctx, field) + case "createdAt": + return ec.fieldContext_Portal_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Portal_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Portal_closedAt(ctx, field) + case "task": + return ec.fieldContext_Portal_task(ctx, field) + case "beacon": + return ec.fieldContext_Portal_beacon(ctx, field) + case "owner": + return ec.fieldContext_Portal_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Portal_activeUsers(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_PortalEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PortalEdge", + 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 fc, nil +} + +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_node, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) + }, + nil, + ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query_node(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_TaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { @@ -6250,64 +6357,38 @@ func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_repositories, + ec.fieldContext_Query_nodes, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Repositories(ctx, 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)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.RepositoryConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) }, - ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, + nil, + ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, true, ) } -func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(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) + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { @@ -6317,22 +6398,22 @@ func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_nodes_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) { +func (ec *executionContext) _Query_assets(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_beacons, + ec.fieldContext_Query_assets, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) + return ec.resolvers.Query().Assets(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AssetOrder), fc.Args["where"].(*ent.AssetWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6340,11 +6421,11 @@ func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.Co directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.BeaconConnection + var zeroVal *ent.AssetConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.BeaconConnection + var zeroVal *ent.AssetConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6353,13 +6434,13 @@ func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.Co next = directive1 return next }, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6368,13 +6449,13 @@ func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, fiel Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_BeaconConnection_edges(ctx, field) + return ec.fieldContext_AssetConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) + return ec.fieldContext_AssetConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_BeaconConnection_totalCount(ctx, field) + return ec.fieldContext_AssetConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", field.Name) }, } defer func() { @@ -6384,22 +6465,22 @@ func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_hosts, + ec.fieldContext_Query_quests, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) + return ec.resolvers.Query().Quests(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.QuestOrder), fc.Args["where"].(*ent.QuestWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6407,11 +6488,11 @@ func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.Coll directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.HostConnection + var zeroVal *ent.QuestConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.HostConnection + var zeroVal *ent.QuestConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6420,13 +6501,13 @@ func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.Coll next = directive1 return next }, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6435,13 +6516,13 @@ func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) + return ec.fieldContext_QuestConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) + return ec.fieldContext_QuestConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) + return ec.fieldContext_QuestConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type QuestConnection", field.Name) }, } defer func() { @@ -6451,22 +6532,22 @@ func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tags, + ec.fieldContext_Query_tasks, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return ec.resolvers.Query().Tasks(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6474,11 +6555,11 @@ func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.Colle directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.TagConnection + var zeroVal *ent.TaskConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.TagConnection + var zeroVal *ent.TaskConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6487,13 +6568,13 @@ func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.Colle next = directive1 return next }, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6502,13 +6583,13 @@ func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field g Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) + return ec.fieldContext_TaskConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) + return ec.fieldContext_TaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } defer func() { @@ -6518,22 +6599,22 @@ func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_repositories(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tomes, + ec.fieldContext_Query_repositories, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) + return ec.resolvers.Query().Repositories(ctx, 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)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6541,11 +6622,11 @@ func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.Coll directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.TomeConnection + var zeroVal *ent.RepositoryConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.TomeConnection + var zeroVal *ent.RepositoryConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6554,13 +6635,13 @@ func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.Coll next = directive1 return next }, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_repositories(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6569,13 +6650,13 @@ func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_TomeConnection_edges(ctx, field) + return ec.fieldContext_RepositoryConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_TomeConnection_totalCount(ctx, field) + return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TomeConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) }, } defer func() { @@ -6585,22 +6666,22 @@ func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + 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_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_users, + ec.fieldContext_Query_beacons, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) + return ec.resolvers.Query().Beacons(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BeaconOrder), fc.Args["where"].(*ent.BeaconWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6608,11 +6689,11 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.UserConnection + var zeroVal *ent.BeaconConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.UserConnection + var zeroVal *ent.BeaconConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6621,13 +6702,13 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll next = directive1 return next }, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6636,13 +6717,13 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) + return ec.fieldContext_BeaconConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) + return ec.fieldContext_BeaconConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) + return ec.fieldContext_BeaconConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BeaconConnection", field.Name) }, } defer func() { @@ -6652,22 +6733,22 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_portals, + ec.fieldContext_Query_hosts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) + return ec.resolvers.Query().Hosts(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.HostOrder), fc.Args["where"].(*ent.HostWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6675,11 +6756,11 @@ func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.Co directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.PortalConnection + var zeroVal *ent.HostConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.PortalConnection + var zeroVal *ent.HostConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6688,13 +6769,13 @@ func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.Co next = directive1 return next }, - ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6703,13 +6784,13 @@ func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, fiel Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_PortalConnection_edges(ctx, field) + return ec.fieldContext_HostConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_PortalConnection_pageInfo(ctx, field) + return ec.fieldContext_HostConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_PortalConnection_totalCount(ctx, field) + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PortalConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } defer func() { @@ -6719,22 +6800,22 @@ func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_shells, + ec.fieldContext_Query_tags, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + return ec.resolvers.Query().Tags(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -6742,11 +6823,11 @@ func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.Col directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") if err != nil { - var zeroVal *ent.ShellConnection + var zeroVal *ent.TagConnection return zeroVal, err } if ec.directives.RequireRole == nil { - var zeroVal *ent.ShellConnection + var zeroVal *ent.TagConnection return zeroVal, errors.New("directive requireRole is not implemented") } return ec.directives.RequireRole(ctx, nil, directive0, role) @@ -6755,13 +6836,13 @@ func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.Col next = directive1 return next }, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6770,13 +6851,13 @@ func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_ShellConnection_edges(ctx, field) + return ec.fieldContext_TagConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + return ec.fieldContext_TagConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_ShellConnection_totalCount(ctx, field) + return ec.fieldContext_TagConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShellConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) }, } defer func() { @@ -6786,30 +6867,49 @@ func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_me, + ec.fieldContext_Query_tomes, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().Me(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Tomes(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TomeOrder), fc.Args["where"].(*ent.TomeWhereInput)) }, - nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.TomeConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TomeConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6817,58 +6917,307 @@ func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graph IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "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) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + case "edges": + return ec.fieldContext_TomeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TomeConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TomeConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TomeConnection", 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_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query___type, + ec.fieldContext_Query_users, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().Users(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.UserOrder), fc.Args["where"].(*ent.UserWhereInput)) }, - nil, - ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.UserConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.UserConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_UserConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserConnection", 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_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_portals, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Portals(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PortalOrder), fc.Args["where"].(*ent.PortalWhereInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.PortalConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.PortalConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_portals(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_PortalConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_PortalConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_PortalConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PortalConnection", 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_portals_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_shells, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Shells(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShellOrder), fc.Args["where"].(*ent.ShellWhereInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + var zeroVal *ent.ShellConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.ShellConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_shells(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_ShellConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellConnection", 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_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_me, + func(ctx context.Context) (any, error) { + return ec.resolvers.Query().Me(ctx) + }, + nil, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "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) + case "activeShells": + return ec.fieldContext_User_activeShells(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query___type, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.introspectType(fc.Args["name"].(string)) + }, + nil, + ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) case "specifiedByURL": return ec.fieldContext___Type_specifiedByURL(ctx, field) case "fields": @@ -11851,350 +12200,813 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, if err != nil { return it, err } - it.AgentIdentifierGTE = data - case "agentIdentifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.AgentIdentifierGTE = data + case "agentIdentifierLT": + 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": + 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": + 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": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierIsNil = data + case "agentIdentifierNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNotNil = data + case "agentIdentifierEqualFold": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotNil = data + case "nextSeenAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAt = data + case "nextSeenAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtNEQ = data + case "nextSeenAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtIn = data + case "nextSeenAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtNotIn = data + case "nextSeenAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtGT = data + case "nextSeenAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtGTE = data + case "nextSeenAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtLT = data + case "nextSeenAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtLTE = data + case "nextSeenAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtIsNil = data + case "nextSeenAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.NextSeenAtNotNil = data + case "interval": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalIsNil = data + case "intervalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotNil = data + case "transport": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + if err != nil { + return it, err + } + it.Transport = data + case "transportNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + if err != nil { + return it, err + } + it.TransportNEQ = data + case "transportIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + if err != nil { + return it, err + } + it.TransportIn = data + case "transportNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) + data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + if err != nil { + return it, err + } + it.TransportNotIn = data + case "hasHost": + 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": + 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": + 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": + 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 "hasShells": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasShells = data + case "hasShellsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) + data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasShellsWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBuilderOrder(ctx context.Context, obj any) (ent.BuilderOrder, error) { + var it ent.BuilderOrder + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, obj any) (ent.BuilderWhereInput, error) { + var it ent.BuilderWhereInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + 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", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + 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": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLT = data - case "agentIdentifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLTE = data - case "agentIdentifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContainsFold = data - case "lastSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + it.CreatedAtNotIn = data + case "createdAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + it.CreatedAtGT = data + case "createdAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.CreatedAtGTE = data + case "createdAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.CreatedAtLT = data + case "createdAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + it.CreatedAtLTE = data + case "lastModifiedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "nextSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAt = data - case "nextSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NextSeenAtNEQ = data - case "nextSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.LastModifiedAtLTE = data + case "identifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtIn = data - case "nextSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.Identifier = data + case "identifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotIn = data - case "nextSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierNEQ = data + case "identifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtGT = data - case "nextSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierIn = data + case "identifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NextSeenAtGTE = data - case "nextSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierNotIn = data + case "identifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtLT = data - case "nextSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IdentifierGT = data + case "identifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtLTE = data - case "nextSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.IdentifierGTE = data + case "identifierLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtIsNil = data - case "nextSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.IdentifierLT = data + case "identifierLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NextSeenAtNotNil = data - case "interval": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.IdentifierLTE = data + case "identifierContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Interval = data - case "intervalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.IdentifierContains = data + case "identifierHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNEQ = data - case "intervalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalIn = data - case "intervalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + it.IdentifierHasSuffix = data + case "identifierEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotIn = data - case "intervalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.IdentifierEqualFold = data + case "identifierContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGT = data - case "intervalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.IdentifierContainsFold = data + case "upstream": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalGTE = data - case "intervalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.Upstream = data + case "upstreamNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLT = data - case "intervalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.UpstreamNEQ = data + case "upstreamIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalLTE = data - case "intervalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.UpstreamIn = data + case "upstreamNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalIsNil = data - case "intervalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.UpstreamNotIn = data + case "upstreamGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalNotNil = data - case "transport": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transport")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.UpstreamGT = data + case "upstreamGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Transport = data - case "transportNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNEQ")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Type(ctx, v) + it.UpstreamGTE = data + case "upstreamLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNEQ = data - case "transportIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.UpstreamLT = data + case "upstreamLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportIn = data - case "transportNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("transportNotIn")) - data, err := ec.unmarshalOBeaconTransport_Type2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐTransport_Typeᚄ(ctx, v) + it.UpstreamLTE = data + case "upstreamContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TransportNotIn = data - case "hasHost": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamContains = data + case "upstreamHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + it.UpstreamHasPrefix = data + case "upstreamHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTasks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamHasSuffix = data + case "upstreamEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasks = data - case "hasTasksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + it.UpstreamEqualFold = data + case "upstreamContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstreamContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasksWith = data - case "hasShells": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShells")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.UpstreamContainsFold = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateBuilderInput(ctx context.Context, obj any) (ent.CreateBuilderInput, error) { + var it ent.CreateBuilderInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"supportedTargets", "upstream"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "supportedTargets": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportedTargets")) + data, err := ec.unmarshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.HasShells = data - case "hasShellsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellsWith")) - data, err := ec.unmarshalOShellWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellWhereInputᚄ(ctx, v) + it.SupportedTargets = data + case "upstream": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.HasShellsWith = data + it.Upstream = data } } @@ -21304,6 +22116,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Host(ctx, sel, obj) + case *ent.Builder: + if obj == nil { + return graphql.Null + } + return ec._Builder(ctx, sel, obj) case *ent.Beacon: if obj == nil { return graphql.Null @@ -21686,62 +22503,213 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o 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) - }) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "shells": + 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._Beacon_shells(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var beaconConnectionImplementors = []string{"BeaconConnection"} + +func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) + + 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("BeaconConnection") + case "edges": + out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._BeaconConnection_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 beaconEdgeImplementors = []string{"BeaconEdge"} + +func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) + + 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("BeaconEdge") + case "node": + out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._BeaconEdge_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))) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "shells": - field := field + return out +} - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Beacon_shells(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } +var builderImplementors = []string{"Builder", "Node"} - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) +func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, obj *ent.Builder) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderImplementors) - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Builder") + case "id": + out.Values[i] = ec._Builder_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._Builder_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "lastModifiedAt": + out.Values[i] = ec._Builder_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "identifier": + out.Values[i] = ec._Builder_identifier(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "supportedTargets": + out.Values[i] = ec._Builder_supportedTargets(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "upstream": + out.Values[i] = ec._Builder_upstream(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -21765,26 +22733,26 @@ func (ec *executionContext) _Beacon(ctx context.Context, sel ast.SelectionSet, o return out } -var beaconConnectionImplementors = []string{"BeaconConnection"} +var builderConnectionImplementors = []string{"BuilderConnection"} -func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconConnectionImplementors) +func (ec *executionContext) _BuilderConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.BuilderConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderConnectionImplementors) 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("BeaconConnection") + out.Values[i] = graphql.MarshalString("BuilderConnection") case "edges": - out.Values[i] = ec._BeaconConnection_edges(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_edges(ctx, field, obj) case "pageInfo": - out.Values[i] = ec._BeaconConnection_pageInfo(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": - out.Values[i] = ec._BeaconConnection_totalCount(ctx, field, obj) + out.Values[i] = ec._BuilderConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -21811,21 +22779,21 @@ func (ec *executionContext) _BeaconConnection(ctx context.Context, sel ast.Selec return out } -var beaconEdgeImplementors = []string{"BeaconEdge"} +var builderEdgeImplementors = []string{"BuilderEdge"} -func (ec *executionContext) _BeaconEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BeaconEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, beaconEdgeImplementors) +func (ec *executionContext) _BuilderEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.BuilderEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderEdgeImplementors) 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("BeaconEdge") + out.Values[i] = graphql.MarshalString("BuilderEdge") case "node": - out.Values[i] = ec._BeaconEdge_node(ctx, field, obj) + out.Values[i] = ec._BuilderEdge_node(ctx, field, obj) case "cursor": - out.Values[i] = ec._BeaconEdge_cursor(ctx, field, obj) + out.Values[i] = ec._BuilderEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -25762,6 +26730,42 @@ func (ec *executionContext) unmarshalNBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Builder(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx context.Context, v any) (*ent.BuilderOrderField, error) { + var res = new(ent.BuilderOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBuilderOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.BuilderOrderField) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalNBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx context.Context, v any) (*ent.BuilderWhereInput, error) { + res, err := ec.unmarshalInputBuilderWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNCreateBuilderInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateBuilderInput(ctx context.Context, v any) (ent.CreateBuilderInput, error) { + res, err := ec.unmarshalInputCreateBuilderInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNCreateHostCredentialInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateHostCredentialInput(ctx context.Context, v any) (ent.CreateHostCredentialInput, error) { res, err := ec.unmarshalInputCreateHostCredentialInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -25957,6 +26961,65 @@ func (ec *executionContext) marshalNHostPlatform2realmᚗpubᚋtavernᚋinternal return v } +func (ec *executionContext) unmarshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, v any) ([]c2pb.Host_Platform, error) { + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]c2pb.Host_Platform, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, sel ast.SelectionSet, v []c2pb.Host_Platform) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection(ctx context.Context, sel ast.SelectionSet, v *ent.HostProcessConnection) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -26845,6 +27908,87 @@ func (ec *executionContext) unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavern return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder(ctx context.Context, sel ast.SelectionSet, v *ent.Builder) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Builder(ctx, sel, v) +} + +func (ec *executionContext) marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.BuilderEdge) 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.marshalOBuilderEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOBuilderEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge(ctx context.Context, sel ast.SelectionSet, v *ent.BuilderEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BuilderEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOBuilderWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInputᚄ(ctx context.Context, v any) ([]*ent.BuilderWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.BuilderWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOBuilderWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderWhereInput(ctx context.Context, v any) (*ent.BuilderWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBuilderWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v any) (*entgql.Cursor[int], error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 96524e087..0fbd94e21 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -4,8 +4,13 @@ package generated import ( "context" + "errors" + "fmt" + "strconv" + "sync/atomic" "github.com/99designs/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" "realm.pub/tavern/internal/graphql/models" ) @@ -23,6 +28,107 @@ import ( // region **************************** field.gotpl ***************************** +func (ec *executionContext) _RegisterBuilderOutput_builder(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_builder, + func(ctx context.Context) (any, error) { + return obj.Builder, nil + }, + nil, + ec.marshalNBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + 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_Builder_id(ctx, field) + case "createdAt": + return ec.fieldContext_Builder_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Builder_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Builder_identifier(ctx, field) + case "supportedTargets": + return ec.fieldContext_Builder_supportedTargets(ctx, field) + case "upstream": + return ec.fieldContext_Builder_upstream(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _RegisterBuilderOutput_mtlsCert(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_mtlsCert, + func(ctx context.Context) (any, error) { + return obj.MtlsCert, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_mtlsCert(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + 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) _RegisterBuilderOutput_config(ctx context.Context, field graphql.CollectedField, obj *models.RegisterBuilderOutput) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_RegisterBuilderOutput_config, + func(ctx context.Context) (any, error) { + return obj.Config, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_RegisterBuilderOutput_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RegisterBuilderOutput", + 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 +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -186,10 +292,73 @@ func (ec *executionContext) unmarshalInputSubmitTaskResultInput(ctx context.Cont // region **************************** object.gotpl **************************** +var registerBuilderOutputImplementors = []string{"RegisterBuilderOutput"} + +func (ec *executionContext) _RegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, obj *models.RegisterBuilderOutput) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, registerBuilderOutputImplementors) + + 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("RegisterBuilderOutput") + case "builder": + out.Values[i] = ec._RegisterBuilderOutput_builder(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mtlsCert": + out.Values[i] = ec._RegisterBuilderOutput_mtlsCert(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "config": + out.Values[i] = ec._RegisterBuilderOutput_config(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 +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** +func (ec *executionContext) marshalNRegisterBuilderOutput2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, v models.RegisterBuilderOutput) graphql.Marshaler { + return ec._RegisterBuilderOutput(ctx, sel, &v) +} + +func (ec *executionContext) marshalNRegisterBuilderOutput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput(ctx context.Context, sel ast.SelectionSet, v *models.RegisterBuilderOutput) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._RegisterBuilderOutput(ctx, sel, v) +} + func (ec *executionContext) unmarshalOImportRepositoryInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐImportRepositoryInput(ctx context.Context, v any) (*models.ImportRepositoryInput, error) { if v == nil { return nil, nil diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 809b3387c..406082cb5 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -34,6 +34,7 @@ type MutationResolver interface { CreateLink(ctx context.Context, input ent.CreateLinkInput) (*ent.Link, error) UpdateLink(ctx context.Context, linkID int, input ent.UpdateLinkInput) (*ent.Link, error) DisableLink(ctx context.Context, linkID int) (*ent.Link, error) + RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) } // endregion ************************** generated!.gotpl ************************** @@ -149,6 +150,17 @@ func (ec *executionContext) field_Mutation_importRepository_args(ctx context.Con return args, nil } +func (ec *executionContext) field_Mutation_registerBuilder_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNCreateBuilderInput2realmᚗpubᚋtavernᚋinternalᚋentᚐCreateBuilderInput) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_updateBeacon_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -1493,6 +1505,73 @@ func (ec *executionContext) fieldContext_Mutation_disableLink(ctx context.Contex return fc, nil } +func (ec *executionContext) _Mutation_registerBuilder(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_registerBuilder, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Mutation().RegisterBuilder(ctx, fc.Args["input"].(ent.CreateBuilderInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "ADMIN") + if err != nil { + var zeroVal *models.RegisterBuilderOutput + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *models.RegisterBuilderOutput + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNRegisterBuilderOutput2ᚖrealmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRegisterBuilderOutput, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_registerBuilder(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "builder": + return ec.fieldContext_RegisterBuilderOutput_builder(ctx, field) + case "mtlsCert": + return ec.fieldContext_RegisterBuilderOutput_mtlsCert(ctx, field) + case "config": + return ec.fieldContext_RegisterBuilderOutput_config(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RegisterBuilderOutput", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_registerBuilder_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -1630,6 +1709,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "registerBuilder": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_registerBuilder(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index a7b007e44..e3474e9a5 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -95,6 +95,26 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Builder struct { + CreatedAt func(childComplexity int) int + ID func(childComplexity int) int + Identifier func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + SupportedTargets func(childComplexity int) int + Upstream func(childComplexity int) int + } + + BuilderConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + BuilderEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Host struct { Beacons func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.BeaconOrder, where *ent.BeaconWhereInput) int CreatedAt func(childComplexity int) int @@ -233,6 +253,7 @@ type ComplexityRoot struct { DisableLink func(childComplexity int, linkID int) int DropAllData func(childComplexity int) int ImportRepository func(childComplexity int, repoID int, input *models.ImportRepositoryInput) int + RegisterBuilder func(childComplexity int, input ent.CreateBuilderInput) int UpdateBeacon func(childComplexity int, beaconID int, input ent.UpdateBeaconInput) int UpdateHost func(childComplexity int, hostID int, input ent.UpdateHostInput) int UpdateLink func(childComplexity int, linkID int, input ent.UpdateLinkInput) int @@ -312,6 +333,12 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + RegisterBuilderOutput struct { + Builder func(childComplexity int) int + Config func(childComplexity int) int + MtlsCert func(childComplexity int) int + } + Repository struct { CreatedAt func(childComplexity int) int ID func(childComplexity int) int @@ -726,6 +753,83 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.BeaconEdge.Node(childComplexity), true + case "Builder.createdAt": + if e.complexity.Builder.CreatedAt == nil { + break + } + + return e.complexity.Builder.CreatedAt(childComplexity), true + + case "Builder.id": + if e.complexity.Builder.ID == nil { + break + } + + return e.complexity.Builder.ID(childComplexity), true + + case "Builder.identifier": + if e.complexity.Builder.Identifier == nil { + break + } + + return e.complexity.Builder.Identifier(childComplexity), true + + case "Builder.lastModifiedAt": + if e.complexity.Builder.LastModifiedAt == nil { + break + } + + return e.complexity.Builder.LastModifiedAt(childComplexity), true + + case "Builder.supportedTargets": + if e.complexity.Builder.SupportedTargets == nil { + break + } + + return e.complexity.Builder.SupportedTargets(childComplexity), true + + case "Builder.upstream": + if e.complexity.Builder.Upstream == nil { + break + } + + return e.complexity.Builder.Upstream(childComplexity), true + + case "BuilderConnection.edges": + if e.complexity.BuilderConnection.Edges == nil { + break + } + + return e.complexity.BuilderConnection.Edges(childComplexity), true + + case "BuilderConnection.pageInfo": + if e.complexity.BuilderConnection.PageInfo == nil { + break + } + + return e.complexity.BuilderConnection.PageInfo(childComplexity), true + + case "BuilderConnection.totalCount": + if e.complexity.BuilderConnection.TotalCount == nil { + break + } + + return e.complexity.BuilderConnection.TotalCount(childComplexity), true + + case "BuilderEdge.cursor": + if e.complexity.BuilderEdge.Cursor == nil { + break + } + + return e.complexity.BuilderEdge.Cursor(childComplexity), true + + case "BuilderEdge.node": + if e.complexity.BuilderEdge.Node == nil { + break + } + + return e.complexity.BuilderEdge.Node(childComplexity), true + case "Host.beacons": if e.complexity.Host.Beacons == nil { break @@ -1440,6 +1544,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.ImportRepository(childComplexity, args["repoID"].(int), args["input"].(*models.ImportRepositoryInput)), true + case "Mutation.registerBuilder": + if e.complexity.Mutation.RegisterBuilder == nil { + break + } + + args, err := ec.field_Mutation_registerBuilder_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.RegisterBuilder(childComplexity, args["input"].(ent.CreateBuilderInput)), true + case "Mutation.updateBeacon": if e.complexity.Mutation.UpdateBeacon == nil { break @@ -1916,6 +2032,27 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.QuestEdge.Node(childComplexity), true + case "RegisterBuilderOutput.builder": + if e.complexity.RegisterBuilderOutput.Builder == nil { + break + } + + return e.complexity.RegisterBuilderOutput.Builder(childComplexity), true + + case "RegisterBuilderOutput.config": + if e.complexity.RegisterBuilderOutput.Config == nil { + break + } + + return e.complexity.RegisterBuilderOutput.Config(childComplexity), true + + case "RegisterBuilderOutput.mtlsCert": + if e.complexity.RegisterBuilderOutput.MtlsCert == nil { + break + } + + return e.complexity.RegisterBuilderOutput.MtlsCert(childComplexity), true + case "Repository.createdAt": if e.complexity.Repository.CreatedAt == nil { break @@ -2606,7 +2743,10 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputAssetWhereInput, ec.unmarshalInputBeaconOrder, ec.unmarshalInputBeaconWhereInput, + ec.unmarshalInputBuilderOrder, + ec.unmarshalInputBuilderWhereInput, ec.unmarshalInputClaimTasksInput, + ec.unmarshalInputCreateBuilderInput, ec.unmarshalInputCreateHostCredentialInput, ec.unmarshalInputCreateLinkInput, ec.unmarshalInputCreateQuestInput, @@ -3335,6 +3475,167 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + 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 + """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -7271,6 +7572,11 @@ scalar Uint64 createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } `, BuiltIn: false}, {Name: "../schema/inputs.graphql", Input: `input ClaimTasksInput { @@ -7322,6 +7628,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index 6ac3402e4..b8bffa6ce 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -10,6 +10,7 @@ import ( "time" "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent" ) type ClaimTasksInput struct { @@ -35,6 +36,16 @@ type ImportRepositoryInput struct { IncludeDirs []string `json:"includeDirs,omitempty"` } +// Output returned when registering a new builder. +type RegisterBuilderOutput struct { + // The created builder entity. + Builder *ent.Builder `json:"builder"` + // mTLS certificate in base64 encoding for the builder to authenticate. + MtlsCert string `json:"mtlsCert"` + // YAML-formatted configuration for the builder. + Config string `json:"config"` +} + type SubmitTaskResultInput struct { // ID of the task to submit results for. TaskID int `json:"taskID"` diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 02f1ed592..058b06a88 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -11,7 +11,9 @@ import ( "strings" "time" + yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/auth" + "realm.pub/tavern/internal/builder" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/asset" "realm.pub/tavern/internal/graphql/generated" @@ -56,6 +58,9 @@ func (r *mutationResolver) DropAllData(ctx context.Context) (bool, error) { if _, err := client.Tag.Delete().Exec(ctx); err != nil { return false, rollback(tx, fmt.Errorf("failed to delete tags: %w", err)) } + if _, err := client.Builder.Delete().Exec(ctx); err != nil { + return false, rollback(tx, fmt.Errorf("failed to delete builders: %w", err)) + } // Commit if err := tx.Commit(); err != nil { @@ -282,6 +287,54 @@ func (r *mutationResolver) DisableLink(ctx context.Context, linkID int) (*ent.Li Save(ctx) } +// RegisterBuilder is the resolver for the registerBuilder field. +func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.CreateBuilderInput) (*models.RegisterBuilderOutput, error) { + // 1. Create builder ent (identifier is auto-generated) + b, err := r.client.Builder.Create().SetInput(input).Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create builder: %w", err) + } + + // 2. Generate CA-signed X.509 certificate for mTLS + certPEM, keyPEM, err := builder.SignBuilderCertificate(r.builderCA, r.builderCAKey, b.Identifier) + if err != nil { + return nil, fmt.Errorf("failed to sign builder certificate: %w", err) + } + + // Combine cert and key into a single PEM bundle + combinedPEM := append(certPEM, keyPEM...) + mtlsCert := string(combinedPEM) + + // 3. Build YAML config + targetNames := make([]string, len(b.SupportedTargets)) + for i, t := range b.SupportedTargets { + targetNames[i] = strings.ToLower(strings.TrimPrefix(t.String(), "PLATFORM_")) + } + + configData := struct { + ID string `yaml:"id"` + SupportedTargets []string `yaml:"supported_targets"` + MTLS string `yaml:"mtls"` + Upstream string `yaml:"upstream"` + }{ + ID: b.Identifier, + SupportedTargets: targetNames, + MTLS: mtlsCert, + Upstream: b.Upstream, + } + + configBytes, err := yaml.Marshal(configData) + if err != nil { + return nil, fmt.Errorf("failed to marshal builder config: %w", err) + } + + return &models.RegisterBuilderOutput{ + Builder: b, + MtlsCert: mtlsCert, + Config: string(configBytes), + }, nil +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index b2ae9ae21..470034358 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -2,6 +2,8 @@ package graphql import ( "context" + "crypto/ed25519" + "crypto/x509" "fmt" "realm.pub/tavern/internal/auth" @@ -12,6 +14,9 @@ import ( "github.com/99designs/gqlgen/graphql" ) +// An option to configure the graphql resolver. +type Option func(*Resolver) + // 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 @@ -19,15 +24,39 @@ type RepoImporter interface { // Resolver is the resolver root. type Resolver struct { - client *ent.Client - importer RepoImporter + client *ent.Client + importer RepoImporter + builderCA *x509.Certificate + builderCAKey ed25519.PrivateKey +} + + +func WithBuilderCAKey(builderCAKey ed25519.PrivateKey) Option { + return Option(func(resolver *Resolver) { + resolver.builderCAKey = builderCAKey + }) +} + +func WithBuilderCA(builderCA *x509.Certificate) Option { + return Option(func(resolver *Resolver) { + resolver.builderCA = builderCA + }) } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter) graphql.ExecutableSchema { +// builderCA *x509.Certificate, builderCAKey ed25519.PrivateKey +func NewSchema(client *ent.Client, importer RepoImporter, options ...func(*Resolver)) graphql.ExecutableSchema { + resolver := &Resolver{ + client: client, + importer: importer, + } + for _, opt := range options { + opt(resolver) + } cfg := generated.Config{ - Resolvers: &Resolver{client, importer}, + Resolvers: resolver, } + 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 if requiredRole != models.RoleAdmin && requiredRole != models.RoleUser { diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index d087c4e32..3970a63e4 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -588,6 +588,167 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + 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 + """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -4300,6 +4461,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} type Mutation { #### # Admin @@ -4356,6 +4529,11 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } extend type Query { assets( diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 5b790a6a6..6d4cf986d 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -583,6 +583,167 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + 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 + """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 80dac9eb5..b8f8234b9 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -47,3 +47,15 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate PEM bundle for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} diff --git a/tavern/internal/graphql/schema/mutation.graphql b/tavern/internal/graphql/schema/mutation.graphql index 743d223d9..e2de39ca3 100644 --- a/tavern/internal/graphql/schema/mutation.graphql +++ b/tavern/internal/graphql/schema/mutation.graphql @@ -54,4 +54,9 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index d087c4e32..3970a63e4 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -588,6 +588,167 @@ input BeaconWhereInput { hasShells: Boolean hasShellsWith: [ShellWhereInput!] } +type Builder implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Unique identifier for the builder, embedded in its mTLS certificate CN. + """ + identifier: String! + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} +""" +A connection to a list of items. +""" +type BuilderConnection { + """ + A list of edges. + """ + edges: [BuilderEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type BuilderEdge { + """ + The item at the end of the edge. + """ + node: Builder + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Builder connections +""" +input BuilderOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Builders. + """ + field: BuilderOrderField! +} +""" +Properties by which Builder connections can be ordered. +""" +enum BuilderOrderField { + CREATED_AT + LAST_MODIFIED_AT +} +""" +BuilderWhereInput is used for filtering Builder objects. +Input was generated by ent. +""" +input BuilderWhereInput { + not: BuilderWhereInput + and: [BuilderWhereInput!] + or: [BuilderWhereInput!] + """ + 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 + """ + identifier field predicates + """ + identifier: String + identifierNEQ: String + identifierIn: [String!] + identifierNotIn: [String!] + identifierGT: String + identifierGTE: String + identifierLT: String + identifierLTE: String + identifierContains: String + identifierHasPrefix: String + identifierHasSuffix: String + identifierEqualFold: String + identifierContainsFold: String + """ + upstream field predicates + """ + upstream: String + upstreamNEQ: String + upstreamIn: [String!] + upstreamNotIn: [String!] + upstreamGT: String + upstreamGTE: String + upstreamLT: String + upstreamLTE: String + upstreamContains: String + upstreamHasPrefix: String + upstreamHasSuffix: String + upstreamEqualFold: String + upstreamContainsFold: String +} +""" +CreateBuilderInput is used for create Builder object. +Input was generated by ent. +""" +input CreateBuilderInput { + """ + The platforms this builder can build agents for. + """ + supportedTargets: [HostPlatform!]! + """ + The server address that the builder should connect to. + """ + upstream: String! +} """ CreateHostCredentialInput is used for create HostCredential object. Input was generated by ent. @@ -4300,6 +4461,18 @@ input ImportRepositoryInput { """ includeDirs: [String!] } + +"""Output returned when registering a new builder.""" +type RegisterBuilderOutput { + """The created builder entity.""" + builder: Builder! + + """mTLS certificate in base64 encoding for the builder to authenticate.""" + mtlsCert: String! + + """YAML-formatted configuration for the builder.""" + config: String! +} type Mutation { #### # Admin @@ -4356,6 +4529,11 @@ type Mutation { createLink(input: CreateLinkInput!): Link! @requireRole(role: USER) updateLink(linkID: ID!, input: UpdateLinkInput!): Link! @requireRole(role: USER) disableLink(linkID: ID!): Link! @requireRole(role: USER) + + ### + # Builder + ### + registerBuilder(input: CreateBuilderInput!): RegisterBuilderOutput! @requireRole(role: ADMIN) } extend type Query { assets(