From 6385b3e1b120241983c47fdf207ff9dc121a9357 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 04:28:24 +0000 Subject: [PATCH 1/8] ping works --- tavern/app.go | 57 + tavern/internal/builder/README.md | 45 + .../internal/builder/builderpb/builder.pb.go | 161 + .../builder/builderpb/builder_grpc.pb.go | 110 + tavern/internal/builder/client.go | 41 + tavern/internal/builder/config.go | 56 + tavern/internal/builder/integration_test.go | 109 + tavern/internal/builder/proto/builder.proto | 12 + tavern/internal/builder/server.go | 28 + tavern/internal/ent/builder.go | 145 + tavern/internal/ent/builder/builder.go | 77 + tavern/internal/ent/builder/where.go | 230 + tavern/internal/ent/builder_create.go | 617 + tavern/internal/ent/builder_delete.go | 88 + tavern/internal/ent/builder_query.go | 540 + tavern/internal/ent/builder_update.go | 288 + tavern/internal/ent/client.go | 159 +- tavern/internal/ent/ent.go | 2 + tavern/internal/ent/gql_collection.go | 111 + tavern/internal/ent/gql_mutation_input.go | 21 + tavern/internal/ent/gql_node.go | 31 + tavern/internal/ent/gql_pagination.go | 351 + tavern/internal/ent/gql_where_input.go | 247 + tavern/internal/ent/hook/hook.go | 12 + tavern/internal/ent/migrate/schema.go | 18 + tavern/internal/ent/mutation.go | 506 + tavern/internal/ent/predicate/predicate.go | 3 + tavern/internal/ent/privacy/privacy.go | 24 + tavern/internal/ent/runtime/runtime.go | 16 + tavern/internal/ent/schema/builder.go | 54 + tavern/internal/ent/tx.go | 3 + .../graphql/generated/ent.generated.go | 9873 +++++++++-------- .../graphql/generated/inputs.generated.go | 167 + .../graphql/generated/mutation.generated.go | 86 + .../graphql/generated/root_.generated.go | 290 + .../internal/graphql/models/gqlgen_models.go | 11 + tavern/internal/graphql/mutation.resolvers.go | 88 + tavern/internal/graphql/schema.graphql | 158 + tavern/internal/graphql/schema/ent.graphql | 141 + tavern/internal/graphql/schema/inputs.graphql | 12 + .../internal/graphql/schema/mutation.graphql | 5 + tavern/internal/www/schema.graphql | 158 + 42 files changed, 10715 insertions(+), 4436 deletions(-) create mode 100644 tavern/internal/builder/README.md create mode 100644 tavern/internal/builder/builderpb/builder.pb.go create mode 100644 tavern/internal/builder/builderpb/builder_grpc.pb.go create mode 100644 tavern/internal/builder/client.go create mode 100644 tavern/internal/builder/config.go create mode 100644 tavern/internal/builder/integration_test.go create mode 100644 tavern/internal/builder/proto/builder.proto create mode 100644 tavern/internal/builder/server.go create mode 100644 tavern/internal/ent/builder.go create mode 100644 tavern/internal/ent/builder/builder.go create mode 100644 tavern/internal/ent/builder/where.go create mode 100644 tavern/internal/ent/builder_create.go create mode 100644 tavern/internal/ent/builder_delete.go create mode 100644 tavern/internal/ent/builder_query.go create mode 100644 tavern/internal/ent/builder_update.go create mode 100644 tavern/internal/ent/schema/builder.go diff --git a/tavern/app.go b/tavern/app.go index 30df0f83b..7027ba2df 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -22,6 +22,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" @@ -117,6 +119,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 } @@ -280,6 +310,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), + AllowUnauthenticated: true, + AllowUnactivated: true, + }, "/cdn/": tavernhttp.Endpoint{ Handler: cdn.NewLinkDownloadHandler(client, "/cdn/"), AllowUnauthenticated: true, @@ -499,6 +534,28 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } +func newBuilderGRPCHandler(client *ent.Client) http.Handler { + builderSrv := builder.New(client) + grpcSrv := grpc.NewServer( + grpc.UnaryInterceptor(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..50d238fb7 --- /dev/null +++ b/tavern/internal/builder/README.md @@ -0,0 +1,45 @@ +# 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 and a YAML configuration file. +- **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 +supported_targets: + - linux + - macos + - windows +mtls: +``` + +| Field | Description | +|-------|-------------| +| `supported_targets` | List of platforms this builder can compile agents for. Valid values: `linux`, `macos`, `windows`. | +| `mtls` | Base64-encoded PEM bundle containing the mTLS certificate and private key for authenticating with Tavern. | + +## 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 | +|------|---------| +| `config.go` | YAML configuration parsing and validation | +| `server.go` | gRPC server implementation (Ping) | +| `run.go` | Builder run loop (connects to Tavern and awaits work) | +| `proto/builder.proto` | Protobuf service definition | +| `builderpb/` | Generated protobuf Go code | +| `integration_test.go` | End-to-end test covering registration and gRPC communication | 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/client.go b/tavern/internal/builder/client.go new file mode 100644 index 000000000..33674348b --- /dev/null +++ b/tavern/internal/builder/client.go @@ -0,0 +1,41 @@ +package builder + +import ( + "context" + "fmt" + "log/slog" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + "realm.pub/tavern/internal/builder/builderpb" +) + +// Run starts the builder process using the provided configuration. +// It connects to the configured upstream server and sends a ping request. +func Run(ctx context.Context, cfg *Config) error { + slog.InfoContext(ctx, "builder started", + "supported_targets", cfg.SupportedTargets, + "upstream", cfg.Upstream, + ) + + conn, err := grpc.NewClient(cfg.Upstream, + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + 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..ba618463c --- /dev/null +++ b/tavern/internal/builder/config.go @@ -0,0 +1,56 @@ +package builder + +import ( + "fmt" + "os" + + "gopkg.in/yaml.v3" +) + +// Config represents the YAML configuration for a builder. +type Config struct { + 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 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..ab3e2f993 --- /dev/null +++ b/tavern/internal/builder/integration_test.go @@ -0,0 +1,109 @@ +package builder_test + +import ( + "context" + "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/credentials/insecure" + "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. Setup GraphQL server with authentication bypass + git := tomes.NewGitImporter(graph) + srv := tavernhttp.NewServer( + tavernhttp.RouteMap{ + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + }, + tavernhttp.WithAuthenticationBypass(graph), + ) + gqlClient := client.New(srv, client.Path("/graphql")) + + // 3. 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) + + // 4. 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.Equal(t, "https://tavern.example.com:443", cfg.Upstream) + + // 5. Verify builder exists in DB + builders, err := graph.Builder.Query().All(ctx) + require.NoError(t, err) + require.Len(t, builders, 1) + + // 6. Setup builder gRPC server via bufconn + lis := bufconn.Listen(1024 * 1024) + grpcSrv := grpc.NewServer() + 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() + + // 7. Connect gRPC client via bufconn + conn, err := grpc.DialContext(ctx, "bufnet", + grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { + return lis.Dial() + }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + require.NoError(t, err) + defer conn.Close() + + // 8. Call Ping on the builder gRPC service + builderClient := builderpb.NewBuilderClient(conn) + pingResp, err := builderClient.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..dd2ea785a --- /dev/null +++ b/tavern/internal/ent/builder.go @@ -0,0 +1,145 @@ +// 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"` + // 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.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.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("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..00716d2dd --- /dev/null +++ b/tavern/internal/ent/builder/builder.go @@ -0,0 +1,77 @@ +// 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" + // 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, + 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 +) + +// 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() +} + +// 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..d23885e58 --- /dev/null +++ b/tavern/internal/ent/builder/where.go @@ -0,0 +1,230 @@ +// 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)) +} + +// 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)) +} + +// 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..c0fc84575 --- /dev/null +++ b/tavern/internal/ent/builder_create.go @@ -0,0 +1,617 @@ +// 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 +} + +// 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) + } +} + +// 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.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.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) + } + })) + 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) + } + } + })) + 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 357480932..c7d03463c 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: @@ -668,6 +678,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 @@ -3028,11 +3171,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 fa01756e4..2bc7ba9a9 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" @@ -653,6 +654,116 @@ 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 "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 8ab4bcc58..4ee249556 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 8e1cbd0ea..074020ae7 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 02b6a5e6c..6fa734934 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" @@ -1039,6 +1040,252 @@ 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"` + + // "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.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 e5000572d..0822396a8 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -54,6 +54,20 @@ 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: "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}, @@ -550,6 +564,7 @@ var ( Tables = []*schema.Table{ AssetsTable, BeaconsTable, + BuildersTable, HostsTable, HostCredentialsTable, HostFilesTable, @@ -577,6 +592,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 e82aeaf85..08b2e6411 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" @@ -2047,6 +2049,510 @@ 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 + 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 +} + +// 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, 4) + if m.created_at != nil { + fields = append(fields, builder.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, builder.FieldLastModifiedAt) + } + 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.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.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.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.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 bd7b6009e..6c0d5633d 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,21 @@ 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) 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..484c5be3d --- /dev/null +++ b/tavern/internal/ent/schema/builder.go @@ -0,0 +1,54 @@ +package schema + +import ( + "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.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 30071cd37..18ee7e36f 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2392,12 +2392,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 }, @@ -2408,9 +2408,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, @@ -2421,12 +2421,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 }, @@ -2437,9 +2437,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, @@ -2450,12 +2450,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 }, @@ -2466,9 +2466,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, @@ -2479,54 +2479,54 @@ 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_supportedTargets(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_supportedTargets, func(ctx context.Context) (any, error) { - return obj.Identifier, nil + return obj.SupportedTargets, nil }, nil, - ec.marshalNString2string, + ec.marshalNHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ, true, true, ) } -func (ec *executionContext) fieldContext_Host_identifier(_ 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_name(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_name, + ec.fieldContext_Builder_upstream, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Upstream, nil }, nil, - ec.marshalOString2string, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_name(_ 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, @@ -2537,547 +2537,459 @@ func (ec *executionContext) fieldContext_Host_name(_ context.Context, field grap return fc, nil } -func (ec *executionContext) _Host_primaryIP(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_primaryIP, + ec.fieldContext_BuilderConnection_edges, func(ctx context.Context) (any, error) { - return obj.PrimaryIP, nil + return obj.Edges, nil }, nil, - ec.marshalOString2string, + ec.marshalOBuilderEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilderEdge, true, false, ) } -func (ec *executionContext) fieldContext_Host_primaryIP(_ 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_externalIP(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_externalIP, + ec.fieldContext_BuilderConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.ExternalIP, nil + return obj.PageInfo, nil }, nil, - ec.marshalOString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_externalIP(_ 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 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) _Host_platform(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_platform, + ec.fieldContext_BuilderConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Platform, nil + return obj.TotalCount, nil }, nil, - ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_platform(_ 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 HostPlatform 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_lastSeenAt(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_lastSeenAt, + ec.fieldContext_BuilderEdge_node, func(ctx context.Context) (any, error) { - return obj.LastSeenAt, nil + return obj.Node, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOBuilder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBuilder, true, false, ) } -func (ec *executionContext) fieldContext_Host_lastSeenAt(_ 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 "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_nextSeenAt(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_nextSeenAt, + ec.fieldContext_BuilderEdge_cursor, func(ctx context.Context) (any, error) { - return obj.NextSeenAt, nil + return obj.Cursor, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Host_nextSeenAt(_ 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: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Host_tags(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_tags, + ec.fieldContext_Host_id, 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.ID, nil }, nil, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Host_tags(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_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 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_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_createdAt(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_createdAt, 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.CreatedAt, nil }, nil, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Host_beacons(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_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 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_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_lastModifiedAt(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_lastModifiedAt, 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.LastModifiedAt, 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_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_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_identifier(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_identifier, 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.Identifier, nil }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Host_processes(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_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 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_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_name(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_name, 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.Name, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Host_credentials(ctx 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: "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_primaryIP(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_primaryIP, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.PrimaryIP, 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_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 "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_externalIP(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_externalIP, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.ExternalIP, 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_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) { - 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_platform(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_platform, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Platform, nil }, nil, - ec.marshalNInt2int, + ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform, true, true, ) } -func (ec *executionContext) fieldContext_HostConnection_totalCount(_ 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: "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 HostPlatform 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_lastSeenAt(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_lastSeenAt, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.LastSeenAt, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_HostCredential_id(_ 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, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _HostCredential_createdAt(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_createdAt, + ec.fieldContext_Host_nextSeenAt, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.NextSeenAt, 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_nextSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostCredential", + Object: "Host", Field: field, IsMethod: false, IsResolver: false, @@ -3088,285 +3000,292 @@ 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_tags(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_tags, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, 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.marshalNTime2timeᚐTime, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_lastModifiedAt(_ 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 Time 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_principal(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_principal, + ec.fieldContext_Host_beacons, func(ctx context.Context) (any, error) { - return obj.Principal, 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_principal(_ 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_secret(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_secret, + ec.fieldContext_Host_files, func(ctx context.Context) (any, error) { - return obj.Secret, 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.marshalNString2string, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_secret(_ 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 String 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_kind(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_kind, + ec.fieldContext_Host_processes, func(ctx context.Context) (any, error) { - return obj.Kind, nil + 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.marshalNHostCredentialKind2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐCredential_Kind, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_kind(_ 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: 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_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) }, } + 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_host(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_host, + ec.fieldContext_Host_credentials, func(ctx context.Context) (any, error) { - return obj.Host(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.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_HostCredential_host(_ 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_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_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 Host", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) }, } - return fc, nil -} - -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_HostCredential_task, - func(ctx context.Context) (any, error) { - return obj.Task(ctx) - }, - nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostCredential", - 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) - }, + 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 }, @@ -3377,9 +3296,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, @@ -3400,12 +3319,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 }, @@ -3416,9 +3335,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, @@ -3429,454 +3348,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 { @@ -3917,347 +3884,246 @@ 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, - true, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, - ) -} - -func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - 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) { +func (ec *executionContext) fieldContext_HostEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostFileConnection", + Object: "HostEdge", 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 Cursor 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_id(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_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_HostFileConnection_pageInfo(_ 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 "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) _HostFileConnection_totalCount(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_totalCount, + ec.fieldContext_HostFile_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_HostFileConnection_totalCount(_ 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) { - 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_lastModifiedAt(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_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_HostFileEdge_node(_ 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: "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 Time 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_path(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_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_HostFileEdge_cursor(_ 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) { - 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_owner(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_owner, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Owner, 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_owner(_ 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_group(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_group, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Group, 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_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 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_permissions(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_permissions, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Permissions, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(_ 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_pid(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_pid, + ec.fieldContext_HostFile_size, func(ctx context.Context) (any, error) { - return obj.Pid, nil + return obj.Size, nil }, nil, ec.marshalNUint642uint64, @@ -4266,9 +4132,9 @@ func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_HostProcess_pid(_ 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, @@ -4279,257 +4145,54 @@ func (ec *executionContext) fieldContext_HostProcess_pid(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _HostProcess_ppid(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_ppid, + ec.fieldContext_HostFile_hash, func(ctx context.Context) (any, error) { - return obj.Ppid, nil + return obj.Hash, nil }, nil, - ec.marshalNUint642uint64, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_HostProcess_ppid(_ 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_name(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_name, + ec.fieldContext_HostFile_host, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.Host(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_HostProcess_name(_ 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", - 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) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_HostProcess_principal, - func(ctx context.Context) (any, error) { - return obj.Principal, nil - }, - nil, - ec.marshalNString2string, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_principal(_ 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 fc, nil -} - -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_HostProcess_path, - func(ctx context.Context) (any, error) { - return obj.Path, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_path(_ 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 fc, nil -} - -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_HostProcess_cmd, - func(ctx context.Context) (any, error) { - return obj.Cmd, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_cmd(_ 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 fc, nil -} - -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_HostProcess_env, - func(ctx context.Context) (any, error) { - return obj.Env, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_env(_ 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 fc, nil -} - -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_HostProcess_cwd, - func(ctx context.Context) (any, error) { - return obj.Cwd, nil - }, - nil, - ec.marshalOString2string, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_cwd(_ 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 fc, nil -} - -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_HostProcess_status, - func(ctx context.Context) (any, error) { - return obj.Status, nil - }, - nil, - ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_status(_ 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 fc, nil -} - -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_HostProcess_host, - func(ctx context.Context) (any, error) { - return obj.Host(ctx) - }, - nil, - ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "HostProcess", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -4572,12 +4235,12 @@ func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcess_task(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_task, + ec.fieldContext_HostFile_task, func(ctx context.Context) (any, error) { return obj.Task(ctx) }, @@ -4588,9 +4251,9 @@ func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_HostProcess_task(_ 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, @@ -4633,47 +4296,47 @@ func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, fie return fc, nil } -func (ec *executionContext) _HostProcessConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (ret graphql.Marshaler) { +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_HostProcessConnection_edges, + ec.fieldContext_HostFileConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, + ec.marshalOHostFileEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileEdge, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "HostProcessConnection", + Object: "HostFileConnection", 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) + return ec.fieldContext_HostFileEdge_node(ctx, field) case "cursor": - return ec.fieldContext_HostProcessEdge_cursor(ctx, field) + return ec.fieldContext_HostFileEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFileEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (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_HostProcessConnection_pageInfo, + ec.fieldContext_HostFileConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -4684,9 +4347,9 @@ func (ec *executionContext) _HostProcessConnection_pageInfo(ctx context.Context, ) } -func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ 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: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4707,12 +4370,12 @@ func (ec *executionContext) fieldContext_HostProcessConnection_pageInfo(_ contex return fc, nil } -func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessConnection) (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_HostProcessConnection_totalCount, + ec.fieldContext_HostFileConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -4723,9 +4386,9 @@ func (ec *executionContext) _HostProcessConnection_totalCount(ctx context.Contex ) } -func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ 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: "HostProcessConnection", + Object: "HostFileConnection", Field: field, IsMethod: false, IsResolver: false, @@ -4736,71 +4399,65 @@ func (ec *executionContext) fieldContext_HostProcessConnection_totalCount(_ cont return fc, nil } -func (ec *executionContext) _HostProcessEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (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_HostProcessEdge_node, + ec.fieldContext_HostFileEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, + ec.marshalOHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile, true, false, ) } -func (ec *executionContext) fieldContext_HostProcessEdge_node(_ 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: "HostProcessEdge", + Object: "HostFileEdge", 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) + return ec.fieldContext_HostFile_id(ctx, field) case "createdAt": - return ec.fieldContext_HostProcess_createdAt(ctx, field) + return ec.fieldContext_HostFile_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) + return ec.fieldContext_HostFile_lastModifiedAt(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) + 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_HostProcess_host(ctx, field) + return ec.fieldContext_HostFile_host(ctx, field) case "task": - return ec.fieldContext_HostProcess_task(ctx, field) + return ec.fieldContext_HostFile_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcessEdge) (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_HostProcessEdge_cursor, + ec.fieldContext_HostFileEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -4811,9 +4468,9 @@ func (ec *executionContext) _HostProcessEdge_cursor(ctx context.Context, field g ) } -func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ 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: "HostProcessEdge", + Object: "HostFileEdge", Field: field, IsMethod: false, IsResolver: false, @@ -4824,12 +4481,12 @@ func (ec *executionContext) fieldContext_HostProcessEdge_cursor(_ context.Contex return fc, nil } -func (ec *executionContext) _Link_id(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_id, + ec.fieldContext_HostProcess_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -4840,9 +4497,9 @@ func (ec *executionContext) _Link_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Link_id(_ 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: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4853,12 +4510,12 @@ func (ec *executionContext) fieldContext_Link_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_createdAt, + ec.fieldContext_HostProcess_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -4869,9 +4526,9 @@ func (ec *executionContext) _Link_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Link_createdAt(_ 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: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4882,12 +4539,12 @@ func (ec *executionContext) fieldContext_Link_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_lastModifiedAt, + ec.fieldContext_HostProcess_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -4898,9 +4555,9 @@ func (ec *executionContext) _Link_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ 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: "Link", + Object: "HostProcess", Field: field, IsMethod: false, IsResolver: false, @@ -4911,804 +4568,842 @@ func (ec *executionContext) fieldContext_Link_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_path, + ec.fieldContext_HostProcess_pid, func(ctx context.Context) (any, error) { - return obj.Path, nil + return obj.Pid, nil }, nil, - ec.marshalNString2string, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_path(_ 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: "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 String does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_expiresAt, + ec.fieldContext_HostProcess_ppid, func(ctx context.Context) (any, error) { - return obj.ExpiresAt, nil + return obj.Ppid, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUint642uint64, true, true, ) } -func (ec *executionContext) fieldContext_Link_expiresAt(_ 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: "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 Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Link_downloadsRemaining(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_downloadsRemaining, + ec.fieldContext_HostProcess_name, func(ctx context.Context) (any, error) { - return obj.DownloadsRemaining, nil + return obj.Name, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Link_downloadsRemaining(_ 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: "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 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) _Link_asset(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (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_Link_asset, + ec.fieldContext_HostProcess_principal, func(ctx context.Context) (any, error) { - return obj.Asset(ctx) + return obj.Principal, nil }, nil, - ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Link_asset(_ 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: "Link", + 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_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) - } - return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (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_LinkConnection_edges, + ec.fieldContext_HostProcess_path, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Path, nil }, nil, - ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_LinkConnection_edges(_ 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: "LinkConnection", + 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_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 String 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) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkConnection_pageInfo, + ec.fieldContext_HostProcess_cmd, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Cmd, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_LinkConnection_pageInfo(_ 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: "LinkConnection", + 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) _LinkConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (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_LinkConnection_totalCount, + ec.fieldContext_HostProcess_env, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Env, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_LinkConnection_totalCount(_ 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: "LinkConnection", + 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) _LinkEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LinkEdge) (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_LinkEdge_node, + ec.fieldContext_HostProcess_cwd, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.Cwd, nil }, nil, - ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_LinkEdge_node(_ 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: "LinkEdge", + 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_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 "downloadsRemaining": - return ec.fieldContext_Link_downloadsRemaining(ctx, field) - case "asset": - return ec.fieldContext_Link_asset(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) + return nil, errors.New("field of type String 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) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_LinkEdge_cursor, + ec.fieldContext_HostProcess_status, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Status, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋepbᚐProcess_Status, true, true, ) } -func (ec *executionContext) fieldContext_LinkEdge_cursor(_ 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: "LinkEdge", + 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 HostProcessStatus 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) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PageInfo_hasNextPage, + ec.fieldContext_HostProcess_host, func(ctx context.Context) (any, error) { - return obj.HasNextPage, nil + return obj.Host(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ 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: "PageInfo", + 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 Boolean 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) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (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_PageInfo_hasPreviousPage, + ec.fieldContext_HostProcess_task, func(ctx context.Context) (any, error) { - return obj.HasPreviousPage, nil + return obj.Task(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ 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: "PageInfo", + 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 Boolean 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) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (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_PageInfo_startCursor, + ec.fieldContext_HostProcessConnection_edges, func(ctx context.Context) (any, error) { - return obj.StartCursor, nil + return obj.Edges, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalOHostProcessEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessEdge, true, false, ) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(_ 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: "PageInfo", + 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 Cursor 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) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (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_PageInfo_endCursor, + ec.fieldContext_HostProcessConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.EndCursor, nil + return obj.PageInfo, nil }, nil, - ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(_ 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: "PageInfo", + 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 Cursor 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_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (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_Portal_id, + ec.fieldContext_HostProcessConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.TotalCount, nil }, nil, - ec.marshalNID2int, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Portal_id(_ 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: "Portal", + 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 ID 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_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (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_Portal_createdAt, + ec.fieldContext_HostProcessEdge_node, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Node, nil }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalOHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess, true, + false, ) } -func (ec *executionContext) fieldContext_Portal_createdAt(_ 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: "Portal", + Object: "HostProcessEdge", 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_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) + case "name": + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _Portal_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (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_Portal_lastModifiedAt, + ec.fieldContext_HostProcessEdge_cursor, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Cursor, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Portal_lastModifiedAt(_ 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: "Portal", + Object: "HostProcessEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (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_Portal_closedAt, + ec.fieldContext_Link_id, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.ID, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNID2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Portal_closedAt(_ 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: "Portal", + 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 Time does not have child fields") + return nil, errors.New("field of type ID 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) _Link_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_task, + ec.fieldContext_Link_createdAt, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.CreatedAt, nil }, nil, - ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_task(_ 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: "Portal", + Object: "Link", 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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (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_Portal_beacon, + ec.fieldContext_Link_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.LastModifiedAt, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_beacon(_ 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: "Portal", + Object: "Link", 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 Time 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) _Link_path(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_owner, + ec.fieldContext_Link_path, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.Path, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Portal_owner(_ 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: "Portal", + Object: "Link", 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 String 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) _Link_expiresAt(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Portal_activeUsers, + ec.fieldContext_Link_expiresAt, 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.ExpiresAt, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Portal_activeUsers(ctx 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: "Portal", + 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 Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Link_downloadsRemaining(ctx context.Context, field graphql.CollectedField, obj *ent.Link) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Link_downloadsRemaining, + func(ctx context.Context) (any, error) { + return obj.DownloadsRemaining, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Link_downloadsRemaining(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 fc, nil +} + +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_Link_asset, + func(ctx context.Context) (any, error) { + return obj.Asset(ctx) + }, + nil, + ec.marshalNAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Link_asset(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Link", Field: field, IsMethod: true, 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) + 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) } - 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 Asset", 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_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) _LinkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LinkConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_PortalConnection_edges, + ec.fieldContext_LinkConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, + ec.marshalOLinkEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkEdge, true, false, ) } -func (ec *executionContext) fieldContext_PortalConnection_edges(_ 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: "PortalConnection", + Object: "LinkConnection", 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) + return ec.fieldContext_LinkEdge_node(ctx, field) case "cursor": - return ec.fieldContext_PortalEdge_cursor(ctx, field) + return ec.fieldContext_LinkEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PortalEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type LinkEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (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_PortalConnection_pageInfo, + ec.fieldContext_LinkConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -5719,9 +5414,9 @@ func (ec *executionContext) _PortalConnection_pageInfo(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ 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: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5742,12 +5437,12 @@ func (ec *executionContext) fieldContext_PortalConnection_pageInfo(_ context.Con return fc, nil } -func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (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_PortalConnection_totalCount, + ec.fieldContext_LinkConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -5758,9 +5453,9 @@ func (ec *executionContext) _PortalConnection_totalCount(ctx context.Context, fi ) } -func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ 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: "PortalConnection", + Object: "LinkConnection", Field: field, IsMethod: false, IsResolver: false, @@ -5771,59 +5466,57 @@ func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.C return fc, nil } -func (ec *executionContext) _PortalEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (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_PortalEdge_node, + ec.fieldContext_LinkEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, + ec.marshalOLink2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLink, true, false, ) } -func (ec *executionContext) fieldContext_PortalEdge_node(_ 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: "PortalEdge", + Object: "LinkEdge", 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) + return ec.fieldContext_Link_id(ctx, field) case "createdAt": - return ec.fieldContext_Portal_createdAt(ctx, field) + return ec.fieldContext_Link_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 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 "downloadsRemaining": + return ec.fieldContext_Link_downloadsRemaining(ctx, field) + case "asset": + return ec.fieldContext_Link_asset(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Link", field.Name) }, } return fc, nil } -func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PortalEdge) (ret graphql.Marshaler) { +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_PortalEdge_cursor, + ec.fieldContext_LinkEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -5834,9 +5527,9 @@ func (ec *executionContext) _PortalEdge_cursor(ctx context.Context, field graphq ) } -func (ec *executionContext) fieldContext_PortalEdge_cursor(_ 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: "PortalEdge", + Object: "LinkEdge", Field: field, IsMethod: false, IsResolver: false, @@ -5847,665 +5540,426 @@ func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, fi return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (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_Query_node, + ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) + return obj.HasNextPage, nil }, nil, - ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNBoolean2bool, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_node(ctx 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: "Query", + Object: "PageInfo", 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 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_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) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_nodes, + ec.fieldContext_PageInfo_hasPreviousPage, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) + return obj.HasPreviousPage, nil }, nil, - ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Query_nodes(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: "Query", + Object: "PageInfo", 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 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_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) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_assets, + ec.fieldContext_PageInfo_startCursor, 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)) - }, - 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.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) - } - - next = directive1 - return next + return obj.StartCursor, nil }, - ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_assets(ctx 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: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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) - } - return nil, fmt.Errorf("no field named %q was found under type AssetConnection", 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_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) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_quests, + ec.fieldContext_PageInfo_endCursor, 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.EndCursor, nil }, - ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, - true, + nil, + ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor, true, + false, ) } -func (ec *executionContext) fieldContext_Query_quests(ctx 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: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_QuestConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_QuestConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_QuestConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type QuestConnection", 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_Query_quests_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) _Portal_id(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tasks, + ec.fieldContext_Portal_id, 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)) - }, - 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.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) - } - - next = directive1 - return next + return obj.ID, nil }, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + nil, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Query_tasks(ctx 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: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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("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_Query_tasks_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) _Portal_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_repositories, + ec.fieldContext_Portal_createdAt, 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 obj.CreatedAt, nil }, - ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_repositories(ctx 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: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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("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_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +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_Query_beacons, + ec.fieldContext_Portal_lastModifiedAt, 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)) - }, - 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.BeaconConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.BeaconConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.LastModifiedAt, nil }, - ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + nil, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Query_beacons(ctx 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: "Query", + Object: "Portal", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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 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_beacons_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) _Portal_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_hosts, + ec.fieldContext_Portal_closedAt, 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)) - }, - 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.HostConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.HostConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.ClosedAt, nil }, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, + nil, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Query_hosts(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) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", 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_Query_hosts_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) _Portal_task(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tags, + ec.fieldContext_Portal_task, 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)) - }, - 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.TagConnection - return zeroVal, err - } - if ec.directives.RequireRole == nil { - var zeroVal *ent.TagConnection - return zeroVal, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - next = directive1 - return next + return obj.Task(ctx) }, - ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + nil, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Query_tags(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) { 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) + 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 TagConnection", field.Name) + 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_tags_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) _Portal_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_tomes, + ec.fieldContext_Portal_beacon, 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 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.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) +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.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + nil, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Query_tomes(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_TomeConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TomeConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TomeConnection_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 TomeConnection", 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_tomes_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) _Portal_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Portal) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_users, + ec.fieldContext_Portal_activeUsers, 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)) - }, - 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 + 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)) }, + nil, ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, true, true, ) } -func (ec *executionContext) fieldContext_Query_users(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": @@ -6525,648 +5979,660 @@ 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_Portal_activeUsers_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) _PortalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PortalConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_portals, + ec.fieldContext_PortalConnection_edges, 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 + return obj.Edges, nil }, - ec.marshalNPortalConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalConnection, - true, + nil, + ec.marshalOPortalEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "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) + 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 PortalConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PortalEdge", 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) { +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_Query_shells, + ec.fieldContext_PortalConnection_pageInfo, 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 + return obj.PageInfo, nil }, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Query_shells(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: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "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) + 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 ShellConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", 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) { +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_Query_me, + ec.fieldContext_PortalConnection_totalCount, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().Me(ctx) + return obj.TotalCount, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, - true, + ec.marshalNInt2int, 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) { +func (ec *executionContext) fieldContext_PortalConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +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_Query___schema, + ec.fieldContext_PortalEdge_node, func(ctx context.Context) (any, error) { - return ec.introspectSchema() + return obj.Node, nil }, nil, - ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, + ec.marshalOPortal2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortal, true, false, ) } -func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PortalEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) + 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 __Schema", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) }, } return fc, nil } -func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +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_Quest_id, + ec.fieldContext_PortalEdge_cursor, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Cursor, nil }, nil, - ec.marshalNID2int, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, true, true, ) } -func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PortalEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + 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 ID does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Quest_createdAt, + ec.fieldContext_Query_node, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Node(ctx, fc.Args["id"].(int)) }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, + false, ) } -func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + 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) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_lastModifiedAt, + ec.fieldContext_Query_nodes, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Query().Nodes(ctx, fc.Args["ids"].([]int)) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder, true, true, ) } -func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ 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: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + 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) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_name, + ec.fieldContext_Query_assets, func(ctx context.Context) (any, error) { - return obj.Name, nil + 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)) }, - nil, - ec.marshalNString2string, + 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.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) + } + + next = directive1 + return next + }, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_name(_ 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: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "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) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", 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) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_parameters, + ec.fieldContext_Query_quests, func(ctx context.Context) (any, error) { - return obj.Parameters, nil + 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)) }, - nil, - ec.marshalOString2string, + 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 + }, + ec.marshalNQuestConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_parameters(_ 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: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_QuestConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_QuestConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_QuestConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type QuestConnection", 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_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_paramDefsAtCreation, + ec.fieldContext_Query_tasks, func(ctx context.Context) (any, error) { - return obj.ParamDefsAtCreation, nil + 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)) }, - nil, - ec.marshalOString2string, + 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.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) + } + + next = directive1 + return next + }, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ 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: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "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) }, } + 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_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_eldritchAtCreation, + ec.fieldContext_Query_repositories, func(ctx context.Context) (any, error) { - return obj.EldritchAtCreation, nil + 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)) }, - nil, - ec.marshalOString2string, + 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 + }, + ec.marshalNRepositoryConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ 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: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_RepositoryConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_RepositoryConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_RepositoryConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_repositories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_tome, + ec.fieldContext_Query_beacons, func(ctx context.Context) (any, error) { - return obj.Tome(ctx) + 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)) }, - nil, - ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, - true, - true, - ) -} + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next -func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Quest", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + 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 + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.BeaconConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) - }, - } - return fc, nil -} -func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Quest_bundle, - func(ctx context.Context) (any, error) { - return obj.Bundle(ctx) + next = directive1 + return next }, - nil, - ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, + ec.marshalNBeaconConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_bundle(_ 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: "Quest", + 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 "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 "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 Asset", field.Name) + 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_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_tasks, + ec.fieldContext_Query_hosts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.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 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)) }, - nil, - ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + 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.HostConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.HostConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, true, true, ) } -func (ec *executionContext) fieldContext_Quest_tasks(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: "Quest", + 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 "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) + return ec.fieldContext_HostConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + return ec.fieldContext_HostConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } defer func() { @@ -7176,1961 +6642,2171 @@ func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Quest_tasks_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) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (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_Quest_creator, + ec.fieldContext_Query_tags, func(ctx context.Context) (any, error) { - return obj.Creator(ctx) + 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)) }, - nil, - ec.marshalOUser2ᚖ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.TagConnection + return zeroVal, err + } + if ec.directives.RequireRole == nil { + var zeroVal *ent.TagConnection + return zeroVal, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + next = directive1 + return next + }, + ec.marshalNTagConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Quest_creator(_ 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: "Quest", + 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 "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_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 User", field.Name) + 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_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (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_QuestConnection_edges, + ec.fieldContext_Query_tomes, func(ctx context.Context) (any, error) { - return obj.Edges, nil + 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.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, + 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, - false, ) } -func (ec *executionContext) fieldContext_QuestConnection_edges(_ 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: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_QuestEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_QuestEdge_cursor(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 QuestEdge", 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) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (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_QuestConnection_pageInfo, + ec.fieldContext_Query_users, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + 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)) }, - nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + 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, ) } -func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ 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: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "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) + 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 PageInfo", field.Name) + 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) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_portals(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestConnection_totalCount, + ec.fieldContext_Query_portals, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + 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)) }, - nil, - ec.marshalNInt2int, + 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_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_portals(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "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) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_shells(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_node, + ec.fieldContext_Query_shells, func(ctx context.Context) (any, error) { - return obj.Node, nil + 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)) }, - nil, - ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + 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, - false, ) } -func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) + 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 Quest", field.Name) + 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) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_QuestEdge_cursor, + ec.fieldContext_Query_me, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return ec.resolvers.Query().Me(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "QuestEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Repository_id, + 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) { - return obj.ID, nil + fc := graphql.GetFieldContext(ctx) + return ec.introspectType(fc.Args["name"].(string)) }, nil, - ec.marshalNID2int, - true, + ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_createdAt, + ec.fieldContext_Query___schema, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return ec.introspectSchema() }, nil, - ec.marshalNTime2timeᚐTime, - true, + ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastModifiedAt, + ec.fieldContext_Quest_id, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.ID, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", 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 ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_url, + ec.fieldContext_Quest_createdAt, func(ctx context.Context) (any, error) { - return obj.URL, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_publicKey, + ec.fieldContext_Quest_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.PublicKey, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_lastImportedAt, + ec.fieldContext_Quest_name, func(ctx context.Context) (any, error) { - return obj.LastImportedAt, nil + return obj.Name, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", 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) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_tomes, + ec.fieldContext_Quest_parameters, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.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 obj.Parameters, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_parameters(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", 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_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 TomeConnection", 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_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_paramDefsAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Repository_owner, + ec.fieldContext_Quest_paramDefsAtCreation, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.ParamDefsAtCreation, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_paramDefsAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Repository", + Object: "Quest", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_eldritchAtCreation(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_edges, + ec.fieldContext_Quest_eldritchAtCreation, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.EldritchAtCreation, nil }, nil, - ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_eldritchAtCreation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", 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_RepositoryEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_RepositoryEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_pageInfo, + ec.fieldContext_Quest_tome, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.Tome(ctx) }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, true, true, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tome(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, 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) + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } return fc, nil } -func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryConnection_totalCount, + ec.fieldContext_Quest_bundle, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.Bundle(ctx) }, nil, - ec.marshalNInt2int, - true, + ec.marshalOAsset2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAsset, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_bundle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryConnection", + Object: "Quest", 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 Int 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) + } + return nil, fmt.Errorf("no field named %q was found under type Asset", field.Name) }, } return fc, nil } -func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_node, + ec.fieldContext_Quest_tasks, func(ctx context.Context) (any, error) { - return obj.Node, nil + fc := graphql.GetFieldContext(ctx) + return obj.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)) }, nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) + 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 Repository", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", 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_Quest_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_RepositoryEdge_cursor, + ec.fieldContext_Quest_creator, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Creator(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_creator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "RepositoryEdge", + Object: "Quest", 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_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) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_id, + ec.fieldContext_QuestConnection_edges, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Edges, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalOQuestEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", 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") + switch field.Name { + case "node": + return ec.fieldContext_QuestEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_QuestEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type QuestEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_createdAt, + ec.fieldContext_QuestConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", 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) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.QuestConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_lastModifiedAt, + ec.fieldContext_QuestConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestConnection", 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) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_closedAt, + ec.fieldContext_QuestEdge_node, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.Node, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, false, ) } -func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", 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_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + }, } return fc, nil } -func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _QuestEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.QuestEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_task, + ec.fieldContext_QuestEdge_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_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_QuestEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "QuestEdge", 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) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_id(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_beacon, + ec.fieldContext_Repository_id, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.ID, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_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 ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_owner, + ec.fieldContext_Repository_createdAt, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.CreatedAt, nil }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_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 Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_activeUsers, + ec.fieldContext_Repository_lastModifiedAt, 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.LastModifiedAt, nil }, nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Repository", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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 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_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_url(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_edges, + ec.fieldContext_Repository_url, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.URL, nil }, nil, - ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", 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_ShellEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_ShellEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_publicKey(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_pageInfo, + ec.fieldContext_Repository_publicKey, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.PublicKey, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_publicKey(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", 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) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_lastImportedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_totalCount, + ec.fieldContext_Repository_lastImportedAt, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.LastImportedAt, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_lastImportedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "Repository", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type 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) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_node, + ec.fieldContext_Repository_tomes, func(ctx context.Context) (any, error) { - return obj.Node, nil - }, + fc := graphql.GetFieldContext(ctx) + return obj.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.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, + ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Shell_id(ctx, field) - case "createdAt": - return ec.fieldContext_Shell_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Shell_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Shell_closedAt(ctx, field) - case "task": - return ec.fieldContext_Shell_task(ctx, field) - case "beacon": - return ec.fieldContext_Shell_beacon(ctx, field) - case "owner": - return ec.fieldContext_Shell_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Shell_activeUsers(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 Shell", 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_Repository_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Repository_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Repository) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_cursor, + ec.fieldContext_Repository_owner, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.Owner(ctx) }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, + false, ) } -func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Repository_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "Repository", 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_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) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_id, + ec.fieldContext_RepositoryConnection_edges, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Edges, nil }, nil, - ec.marshalNID2int, - true, + ec.marshalORepositoryEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_RepositoryEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_RepositoryEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RepositoryEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_name, + ec.fieldContext_RepositoryConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.PageInfo, nil }, nil, - ec.marshalNString2string, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type 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) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_kind, + ec.fieldContext_RepositoryConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Kind, nil + return obj.TotalCount, nil }, nil, - ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagKind does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tag_hosts, + ec.fieldContext_RepositoryEdge_node, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.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 obj.Node, nil }, nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, true, + false, ) } -func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "RepositoryEdge", 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_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Repository", 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_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _RepositoryEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.RepositoryEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_edges, + ec.fieldContext_RepositoryEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Cursor, nil }, nil, - ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "RepositoryEdge", 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_TagEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TagEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_pageInfo, + ec.fieldContext_Shell_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_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shell", 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) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagConnection_totalCount, + ec.fieldContext_Shell_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_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shell", 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) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_node, + ec.fieldContext_Shell_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, + ec.marshalNTime2timeᚐTime, + true, true, - false, ) } -func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "kind": - return ec.fieldContext_Tag_kind(ctx, field) - case "hosts": - return ec.fieldContext_Tag_hosts(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TagEdge_cursor, + ec.fieldContext_Shell_closedAt, func(ctx context.Context) (any, error) { - return obj.Cursor, nil + return obj.ClosedAt, nil }, nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shell", 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) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_id, + ec.fieldContext_Shell_task, func(ctx context.Context) (any, error) { - return obj.ID, nil + return obj.Task(ctx) }, nil, - ec.marshalNID2int, + ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, true, ) } -func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", 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_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) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_createdAt, + ec.fieldContext_Shell_beacon, func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil + return obj.Beacon(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "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 } -func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_lastModifiedAt, + ec.fieldContext_Shell_owner, func(ctx context.Context) (any, error) { - return obj.LastModifiedAt, nil + return obj.Owner(ctx) }, nil, - ec.marshalNTime2timeᚐTime, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, true, true, ) } -func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", 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_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) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_claimedAt, + ec.fieldContext_Shell_activeUsers, func(ctx context.Context) (any, error) { - return obj.ClaimedAt, nil + 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)) }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shell", 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 "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_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execStartedAt, + ec.fieldContext_ShellConnection_edges, func(ctx context.Context) (any, error) { - return obj.ExecStartedAt, nil + return obj.Edges, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, true, false, ) } -func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", 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_ShellEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_ShellEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_execFinishedAt, + ec.fieldContext_ShellConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.ExecFinishedAt, nil + return obj.PageInfo, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_output, + ec.fieldContext_ShellConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.Output, nil + return obj.TotalCount, nil }, nil, - ec.marshalOString2string, + ec.marshalNInt2int, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellConnection", 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) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_outputSize, + ec.fieldContext_ShellEdge_node, func(ctx context.Context) (any, error) { - return obj.OutputSize, nil + return obj.Node, nil }, nil, - ec.marshalNInt2int, - true, + ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, true, + false, ) } -func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", 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 "id": + return ec.fieldContext_Shell_id(ctx, field) + case "createdAt": + return ec.fieldContext_Shell_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Shell_lastModifiedAt(ctx, field) + case "closedAt": + return ec.fieldContext_Shell_closedAt(ctx, field) + case "task": + return ec.fieldContext_Shell_task(ctx, field) + case "beacon": + return ec.fieldContext_Shell_beacon(ctx, field) + case "owner": + return ec.fieldContext_Shell_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Shell_activeUsers(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_error, + ec.fieldContext_ShellEdge_cursor, func(ctx context.Context) (any, error) { - return obj.Error, nil + return obj.Cursor, nil }, nil, - ec.marshalOString2string, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShellEdge", 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) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_quest, + ec.fieldContext_Tag_id, func(ctx context.Context) (any, error) { - return obj.Quest(ctx) + return obj.ID, nil }, nil, - ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, + ec.marshalNID2int, true, true, ) } -func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", 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_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "paramDefsAtCreation": - return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) - case "eldritchAtCreation": - return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_beacon, + ec.fieldContext_Tag_name, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.Name, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", 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 String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedFiles, + ec.fieldContext_Tag_kind, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedFiles(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.Kind, nil }, nil, - ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", 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 TagKind 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_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedProcesses, + ec.fieldContext_Tag_hosts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.ReportedProcesses(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.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)) }, nil, - ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, true, true, ) } -func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_HostProcessConnection_edges(ctx, field) + return ec.fieldContext_HostConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_HostProcessConnection_pageInfo(ctx, field) + return ec.fieldContext_HostConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_HostProcessConnection_totalCount(ctx, field) + return ec.fieldContext_HostConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostProcessConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostConnection", field.Name) }, } defer func() { @@ -9140,165 +8816,67 @@ func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Tag_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_reportedCredentials, + ec.fieldContext_TagConnection_edges, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ReportedCredentials(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.Edges, nil }, nil, - ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, - true, + ec.marshalOTagEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagEdge, true, + false, ) } -func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "TagConnection", 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) + case "node": + return ec.fieldContext_TagEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TagEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HostCredentialConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagEdge", 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_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Task_shells, + ec.fieldContext_TagConnection_pageInfo, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.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 obj.PageInfo, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, true, true, ) } -func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", - Field: field, - IsMethod: true, - IsResolver: false, - 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_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TaskConnection_edges, - func(ctx context.Context) (any, error) { - return obj.Edges, nil - }, - nil, - ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TaskConnection_pageInfo, - func(ctx context.Context) (any, error) { - return obj.PageInfo, nil - }, - nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9319,12 +8897,12 @@ func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskConnection_totalCount, + ec.fieldContext_TagConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -9335,9 +8913,9 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -9348,73 +8926,51 @@ func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_node, + ec.fieldContext_TagEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalOTag2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTag, true, false, ) } -func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "kind": + return ec.fieldContext_Tag_kind(ctx, field) + case "hosts": + return ec.fieldContext_Tag_hosts(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 Tag", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TaskEdge_cursor, + ec.fieldContext_TagEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -9425,9 +8981,9 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, @@ -9438,12 +8994,12 @@ func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_id, + ec.fieldContext_Task_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -9454,9 +9010,9 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9467,12 +9023,12 @@ func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_createdAt, + ec.fieldContext_Task_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -9483,9 +9039,9 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C ) } -func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9496,12 +9052,12 @@ func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_lastModifiedAt, + ec.fieldContext_Task_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -9512,9 +9068,9 @@ func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -9525,329 +9081,423 @@ func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_name, + ec.fieldContext_Task_claimedAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.ClaimedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_claimedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_description, + ec.fieldContext_Task_execStartedAt, func(ctx context.Context) (any, error) { - return obj.Description, nil + return obj.ExecStartedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execStartedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_author, + ec.fieldContext_Task_execFinishedAt, func(ctx context.Context) (any, error) { - return obj.Author, nil + return obj.ExecFinishedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execFinishedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_supportModel, + ec.fieldContext_Task_output, func(ctx context.Context) (any, error) { - return obj.SupportModel, nil + return obj.Output, nil }, nil, - ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_output(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeSupportModel does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_tactic, + ec.fieldContext_Task_outputSize, func(ctx context.Context) (any, error) { - return obj.Tactic, nil + return obj.OutputSize, nil }, nil, - ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + ec.marshalNInt2int, true, true, ) } -func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_outputSize(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeTactic does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnNewBeaconCallback, + ec.fieldContext_Task_error, func(ctx context.Context) (any, error) { - return obj.RunOnNewBeaconCallback, nil + return obj.Error, nil }, nil, - ec.marshalNBoolean2bool, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnFirstHostCallback, + ec.fieldContext_Task_quest, func(ctx context.Context) (any, error) { - return obj.RunOnFirstHostCallback, nil + return obj.Quest(ctx) }, nil, - ec.marshalNBoolean2bool, + ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_quest(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "paramDefsAtCreation": + return ec.fieldContext_Quest_paramDefsAtCreation(ctx, field) + case "eldritchAtCreation": + return ec.fieldContext_Quest_eldritchAtCreation(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_runOnSchedule, + ec.fieldContext_Task_beacon, func(ctx context.Context) (any, error) { - return obj.RunOnSchedule, nil + return obj.Beacon(ctx) }, nil, - ec.marshalNString2string, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, true, true, ) } -func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_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 } -func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_paramDefs, + ec.fieldContext_Task_reportedFiles, func(ctx context.Context) (any, error) { - return obj.ParamDefs, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedFiles(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.marshalOString2string, + ec.marshalNHostFileConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String 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_Task_reportedFiles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_eldritch, + ec.fieldContext_Task_reportedProcesses, func(ctx context.Context) (any, error) { - return obj.Eldritch, nil + fc := graphql.GetFieldContext(ctx) + return obj.ReportedProcesses(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.marshalNString2string, + ec.marshalNHostProcessConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "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) }, } + 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_Task_reportedProcesses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_reportedCredentials(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_assets, + ec.fieldContext_Task_reportedCredentials, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return obj.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.ReportedCredentials(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.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + ec.marshalNHostCredentialConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostCredentialConnection, true, true, ) } -func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedCredentials(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: 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) + return ec.fieldContext_HostCredentialConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_AssetConnection_pageInfo(ctx, field) + return ec.fieldContext_HostCredentialConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_AssetConnection_totalCount(ctx, field) + return ec.fieldContext_HostCredentialConnection_totalCount(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 HostCredentialConnection", field.Name) }, } defer func() { @@ -9857,195 +9507,103 @@ func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Task_reportedCredentials_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _Task_shells(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_uploader, + ec.fieldContext_Task_shells, func(ctx context.Context) (any, error) { - return obj.Uploader(ctx) + fc := graphql.GetFieldContext(ctx) + return obj.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)) }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + 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 User", field.Name) + 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_Task_shells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Tome_repository, + ec.fieldContext_TaskConnection_edges, func(ctx context.Context) (any, error) { - return obj.Repository(ctx) + return obj.Edges, nil }, nil, - ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge, true, false, ) } -func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "TaskConnection", Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Repository_id(ctx, field) - case "createdAt": - return ec.fieldContext_Repository_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Repository_lastModifiedAt(ctx, field) - case "url": - return ec.fieldContext_Repository_url(ctx, field) - case "publicKey": - return ec.fieldContext_Repository_publicKey(ctx, field) - case "lastImportedAt": - return ec.fieldContext_Repository_lastImportedAt(ctx, field) - case "tomes": - return ec.fieldContext_Repository_tomes(ctx, field) - case "owner": - return ec.fieldContext_Repository_owner(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Tome_scheduledHosts, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ScheduledHosts(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)) - }, - nil, - ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tome", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_HostConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_HostConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_HostConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HostConnection", 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_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_TomeConnection_edges, - func(ctx context.Context) (any, error) { - return obj.Edges, nil - }, - nil, - ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, - true, - false, - ) -} - -func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "TomeConnection", - Field: field, - IsMethod: false, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TomeEdge_node(ctx, field) + return ec.fieldContext_TaskEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TomeEdge_cursor(ctx, field) + return ec.fieldContext_TaskEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_pageInfo, + ec.fieldContext_TaskConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -10056,9 +9614,9 @@ func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10079,12 +9637,12 @@ func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Conte return fc, nil } -func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeConnection_totalCount, + ec.fieldContext_TaskConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -10095,9 +9653,9 @@ func (ec *executionContext) _TomeConnection_totalCount(ctx context.Context, fiel ) } -func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeConnection", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10108,77 +9666,73 @@ func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Con return fc, nil } -func (ec *executionContext) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_node, + ec.fieldContext_TaskEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, false, ) } -func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", 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_Tome_id(ctx, field) + return ec.fieldContext_Task_id(ctx, field) case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) + return ec.fieldContext_Task_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "runOnNewBeaconCallback": - return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) - case "runOnFirstHostCallback": - return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) - case "runOnSchedule": - return ec.fieldContext_Tome_runOnSchedule(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "assets": - return ec.fieldContext_Tome_assets(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - case "repository": - return ec.fieldContext_Tome_repository(ctx, field) - case "scheduledHosts": - return ec.fieldContext_Tome_scheduledHosts(ctx, field) + 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 Tome", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_TomeEdge_cursor, + ec.fieldContext_TaskEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -10189,9 +9743,9 @@ func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TomeEdge", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, @@ -10202,12 +9756,12 @@ func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_id, + ec.fieldContext_Tome_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -10218,9 +9772,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ) } -func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, @@ -10231,403 +9785,1680 @@ func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphq return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_name, + ec.fieldContext_Tome_createdAt, func(ctx context.Context) (any, error) { - return obj.Name, nil + return obj.CreatedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_photoURL, + ec.fieldContext_Tome_lastModifiedAt, func(ctx context.Context) (any, error) { - return obj.PhotoURL, nil + return obj.LastModifiedAt, nil }, nil, - ec.marshalNString2string, + ec.marshalNTime2timeᚐTime, true, true, ) } -func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isActivated, + ec.fieldContext_Tome_name, func(ctx context.Context) (any, error) { - return obj.IsActivated, nil + return obj.Name, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_isAdmin, + ec.fieldContext_Tome_description, func(ctx context.Context) (any, error) { - return obj.IsAdmin, nil + return obj.Description, nil }, nil, - ec.marshalNBoolean2bool, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_tomes, + ec.fieldContext_Tome_author, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.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 obj.Author, nil }, nil, - ec.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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 TomeConnection", 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_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_User_activeShells, + ec.fieldContext_Tome_supportModel, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ActiveShells(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 obj.SupportModel, nil }, nil, - ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel, true, true, ) } -func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_supportModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Tome", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "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) + return nil, errors.New("field of type TomeSupportModel 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_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err + return fc, nil +} + +func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_tactic, + func(ctx context.Context) (any, error) { + return obj.Tactic, nil + }, + nil, + ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_tactic(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TomeTactic does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnNewBeaconCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_edges, + ec.fieldContext_Tome_runOnNewBeaconCallback, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.RunOnNewBeaconCallback, nil }, nil, - ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + ec.marshalNBoolean2bool, + true, true, - false, ) } -func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnNewBeaconCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", 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_UserEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_UserEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnFirstHostCallback(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_pageInfo, + ec.fieldContext_Tome_runOnFirstHostCallback, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.RunOnFirstHostCallback, nil }, nil, - ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnFirstHostCallback(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", 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 Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_runOnSchedule(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserConnection_totalCount, + ec.fieldContext_Tome_runOnSchedule, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.RunOnSchedule, nil }, nil, - ec.marshalNInt2int, + ec.marshalNString2string, true, true, ) } -func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_runOnSchedule(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type 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) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_UserEdge_node, + ec.fieldContext_Tome_paramDefs, func(ctx context.Context) (any, error) { - return obj.Node, nil + return obj.ParamDefs, nil }, nil, - ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalOString2string, true, false, ) } -func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tome_paramDefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_eldritch, + func(ctx context.Context) (any, error) { + return obj.Eldritch, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_eldritch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", Field: field, IsMethod: false, IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_assets(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_assets, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.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)) + }, + nil, + ec.marshalNAssetConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_assets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + 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) + } + return nil, fmt.Errorf("no field named %q was found under type AssetConnection", 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_Tome_assets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_uploader, + func(ctx context.Context) (any, error) { + return obj.Uploader(ctx) + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_uploader(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + 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) _Tome_repository(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_repository, + func(ctx context.Context) (any, error) { + return obj.Repository(ctx) + }, + nil, + ec.marshalORepository2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepository, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Tome_repository(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Repository_id(ctx, field) + case "createdAt": + return ec.fieldContext_Repository_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Repository_lastModifiedAt(ctx, field) + case "url": + return ec.fieldContext_Repository_url(ctx, field) + case "publicKey": + return ec.fieldContext_Repository_publicKey(ctx, field) + case "lastImportedAt": + return ec.fieldContext_Repository_lastImportedAt(ctx, field) + case "tomes": + return ec.fieldContext_Repository_tomes(ctx, field) + case "owner": + return ec.fieldContext_Repository_owner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Repository", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Tome_scheduledHosts, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ScheduledHosts(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)) + }, + nil, + ec.marshalNHostConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Tome_scheduledHosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_HostConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_HostConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_HostConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostConnection", 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_Tome_scheduledHosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOTomeEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + 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_TomeEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TomeEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TomeEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + 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) _TomeConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TomeConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeConnection", + 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) _TomeEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + 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_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "runOnNewBeaconCallback": + return ec.fieldContext_Tome_runOnNewBeaconCallback(ctx, field) + case "runOnFirstHostCallback": + return ec.fieldContext_Tome_runOnFirstHostCallback(ctx, field) + case "runOnSchedule": + return ec.fieldContext_Tome_runOnSchedule(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "assets": + return ec.fieldContext_Tome_assets(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + case "repository": + return ec.fieldContext_Tome_repository(ctx, field) + case "scheduledHosts": + return ec.fieldContext_Tome_scheduledHosts(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TomeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TomeEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_TomeEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_TomeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TomeEdge", + 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) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_name, + func(ctx context.Context) (any, error) { + return obj.Name, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_photoURL, + func(ctx context.Context) (any, error) { + return obj.PhotoURL, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_photoURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isActivated, + func(ctx context.Context) (any, error) { + return obj.IsActivated, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isActivated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_isAdmin, + func(ctx context.Context) (any, error) { + return obj.IsAdmin, nil + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_isAdmin(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_tomes, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.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.marshalNTomeConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "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 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_User_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _User_activeShells(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_User_activeShells, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ActiveShells(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)) + }, + nil, + ec.marshalNShellConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_User_activeShells(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "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_User_activeShells_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOUserEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + 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_UserEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_UserEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + 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) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + 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) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + 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_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) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_UserEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserEdge", + 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 +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { + var it ent.AssetOrder + 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.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { + var it ent.AssetWhereInput + 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", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith"} + 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.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLTE = data + case "hash": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "hashNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashNEQ = data + case "hashIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashIn = data + case "hashNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashNotIn = data + case "hashGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGT = data + case "hashGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGTE = data + case "hashLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLT = data + case "hashLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLTE = data + case "hashContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContains = data + case "hashHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasPrefix = data + case "hashHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasSuffix = data + case "hashEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashEqualFold = data + case "hashContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContainsFold = data + case "hasTomes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + if err != nil { + return it, err } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) - }, + it.HasTomesWith = data + case "hasLinks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasLinks = data + case "hasLinksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) + data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasLinksWith = data + } } - return fc, nil -} - -func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.UserEdge) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_UserEdge_cursor, - func(ctx context.Context) (any, error) { - return obj.Cursor, nil - }, - nil, - ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, - true, - true, - ) -} -func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "UserEdge", - 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 + return it, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj any) (ent.AssetOrder, error) { - var it ent.AssetOrder +func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { + var it ent.BeaconOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -10653,7 +11484,7 @@ func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj an it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAssetOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetOrderField(ctx, v) + data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) if err != nil { return it, err } @@ -10664,14 +11495,14 @@ func (ec *executionContext) unmarshalInputAssetOrder(ctx context.Context, obj an return it, nil } -func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, obj any) (ent.AssetWhereInput, error) { - var it ent.AssetWhereInput +func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { + var it ent.BeaconWhereInput 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", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith", "hasLinks", "hasLinksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -10680,21 +11511,21 @@ func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, o switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAssetWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInput(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -10852,1206 +11683,1065 @@ func (ec *executionContext) unmarshalInputAssetWhereInput(ctx context.Context, o if err != nil { return it, err } - 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.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.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContainsFold = data - case "size": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.Size = data - case "sizeNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeNEQ = data - case "sizeIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.SizeIn = data - case "sizeNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.SizeNotIn = data - case "sizeGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeGT = data - case "sizeGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeGTE = data - case "sizeLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeLT = data - case "sizeLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SizeLTE = data - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Hash = data - case "hashNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.HashNEQ = data - case "hashIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.HashIn = data - case "hashNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.HashNotIn = data - case "hashGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.HashGT = data - case "hashGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + it.LastModifiedAtLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasTomes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomes = data - case "hasTomesWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - case "hasLinks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasLinks = data - case "hasLinksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasLinksWith")) - data, err := ec.unmarshalOLinkWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐLinkWhereInputᚄ(ctx, v) + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasLinksWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj any) (ent.BeaconOrder, error) { - var it ent.BeaconOrder - 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) + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + it.NameContainsFold = data + case "principal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj any) (ent.BeaconWhereInput, error) { - var it ent.BeaconWhereInput - 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", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "transport", "transportNEQ", "transportIn", "transportNotIn", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith", "hasShells", "hasShellsWith"} - 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.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + it.Principal = data + case "principalNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + it.PrincipalNEQ = data + case "principalIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + it.PrincipalIn = data + case "principalNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(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) + it.PrincipalNotIn = data + case "principalGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(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) + it.PrincipalGT = data + case "principalGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(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) + it.PrincipalGTE = data + case "principalLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(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) + it.PrincipalLT = data + case "principalLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalLTE = data + case "principalContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalContains = data + case "principalHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalHasPrefix = data + case "principalHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + it.PrincipalHasSuffix = data + case "principalIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.PrincipalIsNil = data + case "principalNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.PrincipalNotNil = data + case "principalEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.PrincipalEqualFold = data + case "principalContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.PrincipalContainsFold = data + case "identifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - 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.CreatedAtGT = data - case "createdAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - 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.CreatedAtGTE = data - case "createdAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - 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.CreatedAtLT = data - case "createdAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - 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.CreatedAtLTE = data - case "lastModifiedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - 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.LastModifiedAt = data - case "lastModifiedAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastModifiedAtNEQ = data - case "lastModifiedAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(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.LastModifiedAtIn = data - case "lastModifiedAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(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.LastModifiedAtNotIn = data - case "lastModifiedAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastModifiedAtGT = data - case "lastModifiedAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastModifiedAtGTE = data - case "lastModifiedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastModifiedAtLT = data - case "lastModifiedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastModifiedAtLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + it.IdentifierContainsFold = data + case "agentIdentifier": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + it.AgentIdentifier = data + case "agentIdentifierNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + it.AgentIdentifierNEQ = data + case "agentIdentifierIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + it.AgentIdentifierIn = data + case "agentIdentifierNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + it.AgentIdentifierNotIn = data + case "agentIdentifierGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + it.AgentIdentifierGT = data + case "agentIdentifierGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + 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.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + 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.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + 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.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + 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.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + 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.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.NameContainsFold = data - case "principal": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + 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.Principal = data - case "principalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + 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.PrincipalNEQ = data - case "principalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.PrincipalIn = data - case "principalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.PrincipalNotIn = data - case "principalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalGT = data - case "principalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalGTE = data - case "principalLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalLT = data - case "principalLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalLTE = data - case "principalContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalContains = data - case "principalHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalHasPrefix = data - case "principalHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalHasSuffix = data - case "principalIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.PrincipalIsNil = data - case "principalNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.PrincipalNotNil = data - case "principalEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalEqualFold = data - case "principalContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.PrincipalContainsFold = data - case "identifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.Identifier = data - case "identifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierNEQ = data - case "identifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.IdentifierIn = data - case "identifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.IdentifierNotIn = data - case "identifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierGT = data - case "identifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierGTE = data - case "identifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierLT = data - case "identifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierLTE = data - case "identifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierContains = data - case "identifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierHasPrefix = data - case "identifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierHasSuffix = data - case "identifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierEqualFold = data - case "identifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.IdentifierContainsFold = data - case "agentIdentifier": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifier = data - case "agentIdentifierNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierNEQ = data - case "agentIdentifierIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.AgentIdentifierIn = data - case "agentIdentifierNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + 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.AgentIdentifierNotIn = data - case "agentIdentifierGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierGT = data - case "agentIdentifierGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierGTE = data - case "agentIdentifierLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierLT = data - case "agentIdentifierLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierLTE = data - case "agentIdentifierContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + 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", "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.AgentIdentifierContainsFold = data - case "lastSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastSeenAt = data - case "lastSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastSeenAtNEQ = data - case "lastSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + 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.LastSeenAtIn = data - case "lastSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + 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.LastSeenAtNotIn = data - case "lastSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastSeenAtGT = data - case "lastSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastSeenAtGTE = data - case "lastSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastSeenAtLT = data - case "lastSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(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.LastSeenAtLTE = data - case "lastSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(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.LastSeenAtIsNil = data - case "lastSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(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.LastSeenAtNotNil = data - case "nextSeenAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAt")) + 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.NextSeenAt = data - case "nextSeenAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNEQ")) + 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.NextSeenAtNEQ = data - case "nextSeenAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIn")) + 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.NextSeenAtIn = data - case "nextSeenAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotIn")) + 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.NextSeenAtNotIn = data - case "nextSeenAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGT")) + 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.NextSeenAtGT = data - case "nextSeenAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtGTE")) + 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.NextSeenAtGTE = data - case "nextSeenAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLT")) + 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.NextSeenAtLT = data - case "nextSeenAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtLTE")) + 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.NextSeenAtLTE = data - case "nextSeenAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.NextSeenAtIsNil = data - case "nextSeenAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nextSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + 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.NextSeenAtNotNil = data - case "interval": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(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.Interval = data - case "intervalNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(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.IntervalNEQ = data - case "intervalIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(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.IntervalIn = data - case "intervalNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(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.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.IntervalNotIn = data - case "intervalGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + 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.IntervalGT = data - case "intervalGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + it.LastModifiedAtLTE = 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 } } @@ -21042,6 +21732,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 @@ -21391,62 +22086,208 @@ 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 "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)) } @@ -21470,26 +22311,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++ } @@ -21516,21 +22357,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++ } @@ -25432,6 +26273,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) @@ -25627,6 +26504,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)) { @@ -26515,6 +27451,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..fc4665f32 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,105 @@ 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 "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 +290,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 b22b79b6b..8e01c2aa7 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{} @@ -1481,6 +1493,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 ***************************** @@ -1618,6 +1697,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 87c914b73..54b2a86d5 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -94,6 +94,25 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Builder struct { + CreatedAt func(childComplexity int) int + ID 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 @@ -230,6 +249,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 @@ -309,6 +329,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 @@ -716,6 +742,76 @@ 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.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 @@ -1416,6 +1512,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 @@ -1892,6 +2000,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 @@ -2582,7 +2711,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, @@ -3302,6 +3434,147 @@ 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! + """ + 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 + """ + 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. @@ -7200,6 +7473,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 { @@ -7251,6 +7529,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 0d3534cf2..b37416a4c 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,10 +7,19 @@ package graphql import ( "context" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/base64" + "encoding/pem" "fmt" + "math/big" "strings" "time" + yaml "gopkg.in/yaml.v3" "realm.pub/tavern/internal/auth" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/asset" @@ -56,6 +65,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 { @@ -276,6 +288,82 @@ 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 + builder, err := r.client.Builder.Create().SetInput(input).Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to create builder: %w", err) + } + + // 2. Generate self-signed X.509 certificate for mTLS + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, fmt.Errorf("failed to generate private key: %w", err) + } + + 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: fmt.Sprintf("builder-%d", builder.ID), + Organization: []string{"Realm"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(365 * 24 * time.Hour), + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + BasicConstraintsValid: true, + } + + certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) + if err != nil { + return nil, fmt.Errorf("failed to create certificate: %w", err) + } + + certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) + keyDER, err := x509.MarshalECPrivateKey(privKey) + if err != nil { + return nil, fmt.Errorf("failed to marshal private key: %w", err) + } + keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + // Combine cert and key into a single PEM bundle, base64-encode it + combinedPEM := append(certPEM, keyPEM...) + mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) + + // 3. Build YAML config + targetNames := make([]string, len(builder.SupportedTargets)) + for i, t := range builder.SupportedTargets { + targetNames[i] = strings.ToLower(strings.TrimPrefix(t.String(), "PLATFORM_")) + } + + configData := struct { + SupportedTargets []string `yaml:"supported_targets"` + MTLS string `yaml:"mtls"` + Upstream string `yaml:"upstream"` + }{ + SupportedTargets: targetNames, + MTLS: mtlsCert, + Upstream: builder.Upstream, + } + + configBytes, err := yaml.Marshal(configData) + if err != nil { + return nil, fmt.Errorf("failed to marshal builder config: %w", err) + } + + return &models.RegisterBuilderOutput{ + Builder: builder, + 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/schema.graphql b/tavern/internal/graphql/schema.graphql index b3f9ccea1..4c3dbc9d7 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -579,6 +579,147 @@ 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! + """ + 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 + """ + 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. @@ -4253,6 +4394,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 @@ -4309,6 +4462,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 7f2d7f666..635caf269 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -574,6 +574,147 @@ 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! + """ + 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 + """ + 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..460afcc30 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 in base64 encoding 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 b3f9ccea1..4c3dbc9d7 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -579,6 +579,147 @@ 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! + """ + 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 + """ + 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. @@ -4253,6 +4394,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 @@ -4309,6 +4462,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( From b29e77de3af9581e1f2b2271c921cbe61e09aed6 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:18:09 +0000 Subject: [PATCH 2/8] encrypted ping --- tavern/app.go | 34 ++++- tavern/internal/builder/README.md | 31 +++- tavern/internal/builder/auth.go | 139 +++++++++++++++++ tavern/internal/builder/ca.go | 144 ++++++++++++++++++ tavern/internal/builder/client.go | 93 ++++++++++- tavern/internal/builder/config.go | 4 + tavern/internal/builder/integration_test.go | 84 +++++++--- tavern/internal/ent/builder.go | 13 +- tavern/internal/ent/builder/builder.go | 12 ++ tavern/internal/ent/builder/where.go | 70 +++++++++ tavern/internal/ent/builder_create.go | 36 +++++ tavern/internal/ent/gql_collection.go | 5 + tavern/internal/ent/gql_where_input.go | 54 +++++++ tavern/internal/ent/migrate/schema.go | 1 + tavern/internal/ent/mutation.go | 56 ++++++- tavern/internal/ent/runtime/runtime.go | 6 + tavern/internal/ent/schema/builder.go | 9 ++ tavern/internal/graphql/api_test.go | 2 +- .../graphql/generated/ent.generated.go | 129 +++++++++++++++- .../graphql/generated/inputs.generated.go | 2 + .../graphql/generated/root_.generated.go | 28 ++++ tavern/internal/graphql/mutation.resolvers.go | 58 ++----- tavern/internal/graphql/quest_test.go | 2 +- tavern/internal/graphql/resolver.go | 17 ++- tavern/internal/graphql/schema.graphql | 20 +++ tavern/internal/graphql/schema/ent.graphql | 20 +++ tavern/internal/graphql/tome_test.go | 2 +- tavern/internal/graphql/user_test.go | 2 +- tavern/internal/www/schema.graphql | 20 +++ 29 files changed, 1003 insertions(+), 90 deletions(-) create mode 100644 tavern/internal/builder/auth.go create mode 100644 tavern/internal/builder/ca.go diff --git a/tavern/app.go b/tavern/app.go index 7027ba2df..4a7227598 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -3,6 +3,8 @@ package main import ( "context" "crypto/ecdh" + "crypto/ecdsa" + "crypto/x509" "encoding/base64" "fmt" "log" @@ -240,6 +242,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) @@ -299,7 +308,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { AllowUnactivated: true, }, "/graphql": tavernhttp.Endpoint{ - Handler: newGraphQLHandler(client, git), + Handler: newGraphQLHandler(client, git, builderCACert, builderCAKey), AllowUnactivated: true, }, "/c2.C2/": tavernhttp.Endpoint{ @@ -311,7 +320,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { Handler: newPortalGRPCHandler(client, portalMux), }, "/builder.Builder/": tavernhttp.Endpoint{ - Handler: newBuilderGRPCHandler(client), + Handler: newBuilderGRPCHandler(client, builderCACert), AllowUnauthenticated: true, AllowUnactivated: true, }, @@ -395,8 +404,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, builderCACert *x509.Certificate, builderCAKey *ecdsa.PrivateKey) http.Handler { + srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, builderCACert, builderCAKey)) srv.Use(entgql.Transactioner{TxOpener: client}) // Configure Raw Query Logging @@ -512,6 +521,16 @@ 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. +func getBuilderCA() (caCert *x509.Certificate, caKey *ecdsa.PrivateKey, err error) { + secretsManager, err := newSecretsManager() + if err != nil { + return nil, nil, err + } + + return builder.GetOrCreateCA(secretsManager) +} + func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { portalSrv := portals.New(graph, portalMux) grpcSrv := grpc.NewServer( @@ -534,10 +553,13 @@ func newPortalGRPCHandler(graph *ent.Client, portalMux *mux.Mux) http.Handler { }) } -func newBuilderGRPCHandler(client *ent.Client) http.Handler { +func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Handler { builderSrv := builder.New(client) grpcSrv := grpc.NewServer( - grpc.UnaryInterceptor(grpcWithUnaryMetrics), + grpc.ChainUnaryInterceptor( + builder.NewAuthInterceptor(caCert, client), + grpcWithUnaryMetrics, + ), grpc.StreamInterceptor(grpcWithStreamMetrics), ) builderpb.RegisterBuilderServer(grpcSrv, builderSrv) diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 50d238fb7..00558fa7b 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -4,7 +4,8 @@ The builder package orchestrates agent compilation for target platforms. It conn ## Overview -- **Registration**: Builders register with Tavern via the `registerBuilder` GraphQL mutation, which returns an mTLS certificate and a YAML configuration file. +- **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. @@ -13,17 +14,37 @@ The builder package orchestrates agent compilation for target platforms. It conn 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` | Base64-encoded PEM bundle containing the mTLS certificate and private key for authenticating with Tavern. | +| `mtls` | Base64-encoded 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 ECDSA P-256 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`: Base64-encoded DER certificate + - `builder-signature`: Base64-encoded ECDSA signature over the timestamp + - `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 @@ -37,9 +58,11 @@ go run ./tavern builder --config /path/to/builder-config.yaml | 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) | -| `run.go` | Builder run loop (connects to Tavern and awaits work) | | `proto/builder.proto` | Protobuf service definition | | `builderpb/` | Generated protobuf Go code | -| `integration_test.go` | End-to-end test covering registration and gRPC communication | +| `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..be479da6e --- /dev/null +++ b/tavern/internal/builder/auth.go @@ -0,0 +1,139 @@ +package builder + +import ( + "context" + "crypto/ecdsa" + "crypto/sha256" + "crypto/x509" + "encoding/base64" + "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. + mdKeyBuilderCert = "builder-cert" + mdKeyBuilderSignature = "builder-signature" + 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 +} + +// NewAuthInterceptor 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 NewAuthInterceptor(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 + certB64 := getMetadataValue(md, mdKeyBuilderCert) + sigB64 := getMetadataValue(md, mdKeyBuilderSignature) + timestamp := getMetadataValue(md, mdKeyBuilderTimestamp) + + if certB64 == "" || sigB64 == "" || timestamp == "" { + return nil, status.Error(codes.Unauthenticated, "missing builder credentials") + } + + // Parse the certificate + certDER, err := base64.StdEncoding.DecodeString(certB64) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid certificate encoding") + } + + cert, err := x509.ParseCertificate(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) + sigBytes, err := base64.StdEncoding.DecodeString(sigB64) + if err != nil { + return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") + } + + hash := sha256.Sum256([]byte(timestamp)) + pubKey, ok := cert.PublicKey.(*ecdsa.PublicKey) + if !ok { + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ECDSA public key") + } + if !ecdsa.VerifyASN1(pubKey, hash[:], sigBytes) { + 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/ca.go b/tavern/internal/builder/ca.go new file mode 100644 index 000000000..6764ab6bd --- /dev/null +++ b/tavern/internal/builder/ca.go @@ -0,0 +1,144 @@ +package builder + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "fmt" + "math/big" + "time" + + "realm.pub/tavern/internal/secrets" +) + +// GetOrCreateCA retrieves or generates the Builder CA certificate and private key. +// The CA is persisted via the secrets manager so it survives restarts. +// Data is stored as PEM (text-safe) to avoid binary corruption in YAML-based secrets managers. +func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *ecdsa.PrivateKey, error) { + if secretsManager == nil { + return nil, nil, fmt.Errorf("secrets manager is nil") + } + + // Try to load existing CA (stored as PEM for text-safety) + certPEMBytes, certErr := secretsManager.GetValue("builder_ca_certificate") + keyPEMBytes, keyErr := secretsManager.GetValue("builder_ca_private_key") + + if certErr == nil && keyErr == nil && len(certPEMBytes) > 0 && len(keyPEMBytes) > 0 { + certBlock, _ := pem.Decode(certPEMBytes) + if certBlock == nil { + return nil, nil, fmt.Errorf("failed to decode stored CA certificate PEM") + } + cert, err := x509.ParseCertificate(certBlock.Bytes) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse stored CA certificate: %w", err) + } + + keyBlock, _ := pem.Decode(keyPEMBytes) + if keyBlock == nil { + return nil, nil, fmt.Errorf("failed to decode stored CA private key PEM") + } + key, err := x509.ParseECPrivateKey(keyBlock.Bytes) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse stored CA private key: %w", err) + } + return cert, key, nil + } + + // Generate new CA + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate CA private key: %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: "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, &privKey.PublicKey, privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to create CA certificate: %w", err) + } + + keyDER, err := x509.MarshalECPrivateKey(privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to marshal CA private key: %w", err) + } + + // Store as PEM to avoid binary corruption in text-based secrets managers + certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}) + keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + if _, err := secretsManager.SetValue("builder_ca_certificate", certPEM); err != nil { + return nil, nil, fmt.Errorf("failed to store CA certificate: %w", err) + } + if _, err := secretsManager.SetValue("builder_ca_private_key", keyPEM); err != nil { + return nil, nil, fmt.Errorf("failed to store CA private key: %w", err) + } + + cert, err := x509.ParseCertificate(caDER) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) + } + + return cert, privKey, 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 *ecdsa.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { + privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, nil, fmt.Errorf("failed to generate builder private key: %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 | x509.KeyUsageKeyEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + BasicConstraintsValid: true, + } + + certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, &privKey.PublicKey, 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.MarshalECPrivateKey(privKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to marshal builder private key: %w", err) + } + keyPEM = pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) + + return certPEM, keyPEM, nil +} diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 33674348b..aebdcc2b0 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -2,25 +2,116 @@ package builder import ( "context" + "crypto/ecdsa" + "crypto/rand" + "crypto/sha256" + "crypto/x509" + "encoding/base64" + "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 { + certDERBase64 string + privKey *ecdsa.PrivateKey +} + +// GetRequestMetadata generates fresh authentication metadata for each RPC call. +// It signs the current timestamp with the builder's private key to prove possession. +func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + timestamp := time.Now().UTC().Format(time.RFC3339Nano) + + hash := sha256.Sum256([]byte(timestamp)) + sig, err := ecdsa.SignASN1(rand.Reader, c.privKey, hash[:]) + if err != nil { + return nil, fmt.Errorf("failed to sign timestamp: %w", err) + } + + return map[string]string{ + mdKeyBuilderCert: c.certDERBase64, + mdKeyBuilderSignature: base64.StdEncoding.EncodeToString(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 +// base64-encoded PEM bundle. +func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { + pemBundle, err := base64.StdEncoding.DecodeString(mtlsBase64) + if err != nil { + return nil, fmt.Errorf("failed to decode mTLS base64: %w", err) + } + + var certDER []byte + var privKey *ecdsa.PrivateKey + + for { + block, rest := pem.Decode(pemBundle) + if block == nil { + break + } + switch block.Type { + case "CERTIFICATE": + certDER = block.Bytes + case "EC PRIVATE KEY": + privKey, err = x509.ParseECPrivateKey(block.Bytes) + if err != nil { + return nil, fmt.Errorf("failed to parse EC private key: %w", err) + } + } + 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{ + certDERBase64: base64.StdEncoding.EncodeToString(certDER), + privKey: privKey, + }, nil +} + // Run starts the builder process using the provided configuration. -// It connects to the configured upstream server and sends a ping request. +// 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) diff --git a/tavern/internal/builder/config.go b/tavern/internal/builder/config.go index ba618463c..ffbe7776e 100644 --- a/tavern/internal/builder/config.go +++ b/tavern/internal/builder/config.go @@ -9,6 +9,7 @@ import ( // 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"` @@ -38,6 +39,9 @@ func ParseConfigBytes(data []byte) (*Config, error) { } 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") } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index ab3e2f993..673c73721 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -11,7 +11,9 @@ import ( "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" @@ -19,6 +21,7 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" + "realm.pub/tavern/internal/secrets" "realm.pub/tavern/tomes" ) @@ -29,17 +32,26 @@ func TestBuilderE2E(t *testing.T) { graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() - // 2. Setup GraphQL server with authentication bypass + // 2. Initialize Builder CA + secretsDir := t.TempDir() + secretsManager, err := secrets.NewDebugFileSecrets(secretsDir + "/secrets.yaml") + require.NoError(t, err) + caCert, caKey, err := builder.GetOrCreateCA(secretsManager) + require.NoError(t, err) + require.NotNil(t, caCert) + require.NotNil(t, caKey) + + // 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": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caKey)), }, tavernhttp.WithAuthenticationBypass(graph), ) gqlClient := client.New(srv, client.Path("/graphql")) - // 3. Register a builder via GraphQL mutation + // 4. Register a builder via GraphQL mutation var registerResp struct { RegisterBuilder struct { Builder struct { @@ -50,7 +62,7 @@ func TestBuilderE2E(t *testing.T) { } } - err := gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { + err = gqlClient.Post(`mutation registerNewBuilder($input: CreateBuilderInput!) { registerBuilder(input: $input) { builder { id } mtlsCert @@ -65,22 +77,28 @@ func TestBuilderE2E(t *testing.T) { require.NotEmpty(t, registerResp.RegisterBuilder.MtlsCert) require.NotEmpty(t, registerResp.RegisterBuilder.Config) - // 4. Parse the returned YAML 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) - // 5. Verify builder exists in DB + // 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) - // 6. Setup builder gRPC server via bufconn + // 7. Setup builder gRPC server via bufconn with mTLS auth interceptor lis := bufconn.Listen(1024 * 1024) - grpcSrv := grpc.NewServer() + grpcSrv := grpc.NewServer( + grpc.ChainUnaryInterceptor( + builder.NewAuthInterceptor(caCert, graph), + ), + ) builderSrv := builder.New(graph) builderpb.RegisterBuilderServer(grpcSrv, builderSrv) @@ -91,19 +109,41 @@ func TestBuilderE2E(t *testing.T) { }() defer grpcSrv.Stop() - // 7. Connect gRPC client via bufconn - conn, err := grpc.DialContext(ctx, "bufnet", - grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { - return lis.Dial() - }), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - require.NoError(t, err) - defer conn.Close() + bufDialer := func(context.Context, string) (net.Conn, error) { + return lis.Dial() + } - // 8. Call Ping on the builder gRPC service - builderClient := builderpb.NewBuilderClient(conn) - pingResp, err := builderClient.Ping(ctx, &builderpb.PingRequest{}) - require.NoError(t, err) - require.NotNil(t, pingResp) + // 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/ent/builder.go b/tavern/internal/ent/builder.go index dd2ea785a..527ec31a2 100644 --- a/tavern/internal/ent/builder.go +++ b/tavern/internal/ent/builder.go @@ -23,6 +23,8 @@ type Builder struct { 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. @@ -39,7 +41,7 @@ func (*Builder) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case builder.FieldID: values[i] = new(sql.NullInt64) - case builder.FieldUpstream: + case builder.FieldIdentifier, builder.FieldUpstream: values[i] = new(sql.NullString) case builder.FieldCreatedAt, builder.FieldLastModifiedAt: values[i] = new(sql.NullTime) @@ -76,6 +78,12 @@ func (b *Builder) assignValues(columns []string, values []any) error { } 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]) @@ -132,6 +140,9 @@ func (b *Builder) String() string { 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(", ") diff --git a/tavern/internal/ent/builder/builder.go b/tavern/internal/ent/builder/builder.go index 00716d2dd..19caff758 100644 --- a/tavern/internal/ent/builder/builder.go +++ b/tavern/internal/ent/builder/builder.go @@ -17,6 +17,8 @@ const ( 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. @@ -30,6 +32,7 @@ var Columns = []string{ FieldID, FieldCreatedAt, FieldLastModifiedAt, + FieldIdentifier, FieldSupportedTargets, FieldUpstream, } @@ -51,6 +54,10 @@ var ( 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. @@ -71,6 +78,11 @@ 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 index d23885e58..fcf05be32 100644 --- a/tavern/internal/ent/builder/where.go +++ b/tavern/internal/ent/builder/where.go @@ -64,6 +64,11 @@ 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)) @@ -149,6 +154,71 @@ 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)) diff --git a/tavern/internal/ent/builder_create.go b/tavern/internal/ent/builder_create.go index c0fc84575..371beb2c0 100644 --- a/tavern/internal/ent/builder_create.go +++ b/tavern/internal/ent/builder_create.go @@ -51,6 +51,20 @@ func (bc *BuilderCreate) SetNillableLastModifiedAt(t *time.Time) *BuilderCreate 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) @@ -106,6 +120,10 @@ func (bc *BuilderCreate) defaults() { 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. @@ -116,6 +134,14 @@ func (bc *BuilderCreate) check() error { 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"`)} } @@ -157,6 +183,10 @@ func (bc *BuilderCreate) createSpec() (*Builder, *sqlgraph.CreateSpec) { _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 @@ -267,6 +297,9 @@ func (u *BuilderUpsertOne) UpdateNewValues() *BuilderUpsertOne { if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(builder.FieldCreatedAt) } + if _, exists := u.create.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } })) return u } @@ -519,6 +552,9 @@ func (u *BuilderUpsertBulk) UpdateNewValues() *BuilderUpsertBulk { if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(builder.FieldCreatedAt) } + if _, exists := b.mutation.Identifier(); exists { + s.SetIgnore(builder.FieldIdentifier) + } } })) return u diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 2bc7ba9a9..948088580 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -685,6 +685,11 @@ func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *gr 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) diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 6fa734934..982b0efb0 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -1077,6 +1077,21 @@ type BuilderWhereInput struct { 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"` @@ -1236,6 +1251,45 @@ func (i *BuilderWhereInput) P() (predicate.Builder, error) { 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)) } diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 0822396a8..ca0e810bc 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -59,6 +59,7 @@ var ( {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}, } diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 08b2e6411..16365537a 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -2057,6 +2057,7 @@ type BuilderMutation struct { 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 @@ -2236,6 +2237,42 @@ 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 @@ -2357,13 +2394,16 @@ func (m *BuilderMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BuilderMutation) Fields() []string { - fields := make([]string, 0, 4) + 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) } @@ -2382,6 +2422,8 @@ func (m *BuilderMutation) Field(name string) (ent.Value, bool) { return m.CreatedAt() case builder.FieldLastModifiedAt: return m.LastModifiedAt() + case builder.FieldIdentifier: + return m.Identifier() case builder.FieldSupportedTargets: return m.SupportedTargets() case builder.FieldUpstream: @@ -2399,6 +2441,8 @@ func (m *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, 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: @@ -2426,6 +2470,13 @@ func (m *BuilderMutation) SetField(name string, value ent.Value) error { } 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 { @@ -2495,6 +2546,9 @@ func (m *BuilderMutation) ResetField(name string) error { case builder.FieldLastModifiedAt: m.ResetLastModifiedAt() return nil + case builder.FieldIdentifier: + m.ResetIdentifier() + return nil case builder.FieldSupportedTargets: m.ResetSupportedTargets() return nil diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 6c0d5633d..2f34f548b 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -109,6 +109,12 @@ func init() { 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 index 484c5be3d..8613d5f26 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -17,6 +17,15 @@ type Builder struct { // Fields of the Builder. func (Builder) Fields() []ent.Field { return []ent.Field{ + field.String("identifier"). + DefaultFunc(newRandomIdentifier). + 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!]"), diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index 75046c9e1..b8ad58a76 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -94,7 +94,7 @@ func runTestCase(t *testing.T, path string) { // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph})), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph}, nil, nil)), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 18ee7e36f..f8c914387 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -2479,6 +2479,35 @@ func (ec *executionContext) fieldContext_Builder_lastModifiedAt(_ context.Contex return fc, nil } +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_Builder_identifier, + func(ctx context.Context) (any, error) { + return obj.Identifier, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Builder_identifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 fc, nil +} + func (ec *executionContext) _Builder_supportedTargets(ctx context.Context, field graphql.CollectedField, obj *ent.Builder) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2670,6 +2699,8 @@ func (ec *executionContext) fieldContext_BuilderEdge_node(_ context.Context, fie 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": @@ -12421,7 +12452,7 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, 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", "upstream", "upstreamNEQ", "upstreamIn", "upstreamNotIn", "upstreamGT", "upstreamGTE", "upstreamLT", "upstreamLTE", "upstreamContains", "upstreamHasPrefix", "upstreamHasSuffix", "upstreamEqualFold", "upstreamContainsFold"} + 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 { @@ -12617,6 +12648,97 @@ func (ec *executionContext) unmarshalInputBuilderWhereInput(ctx context.Context, return it, err } 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.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.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.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.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.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.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.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.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.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.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.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.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.IdentifierContainsFold = data case "upstream": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("upstream")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -22278,6 +22400,11 @@ func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, 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 { diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index fc4665f32..0fbd94e21 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -58,6 +58,8 @@ func (ec *executionContext) fieldContext_RegisterBuilderOutput_builder(_ context 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": diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 54b2a86d5..8e7bf9ecf 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -97,6 +97,7 @@ type ComplexityRoot struct { 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 @@ -756,6 +757,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin 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 @@ -3445,6 +3453,10 @@ type Builder implements Node { """ 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!]! @@ -3545,6 +3557,22 @@ input BuilderWhereInput { 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 diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index b37416a4c..2b397c363 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,20 +7,14 @@ package graphql import ( "context" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/x509" - "crypto/x509/pkix" "encoding/base64" - "encoding/pem" "fmt" - "math/big" "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" @@ -290,66 +284,38 @@ func (r *mutationResolver) DisableLink(ctx context.Context, linkID int) (*ent.Li // 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 - builder, err := r.client.Builder.Create().SetInput(input).Save(ctx) + // 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 self-signed X.509 certificate for mTLS - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + // 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 generate private key: %w", err) + return nil, fmt.Errorf("failed to sign builder certificate: %w", err) } - 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: fmt.Sprintf("builder-%d", builder.ID), - Organization: []string{"Realm"}, - }, - NotBefore: time.Now(), - NotAfter: time.Now().Add(365 * 24 * time.Hour), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, - BasicConstraintsValid: true, - } - - certDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) - if err != nil { - return nil, fmt.Errorf("failed to create certificate: %w", err) - } - - certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) - keyDER, err := x509.MarshalECPrivateKey(privKey) - if err != nil { - return nil, fmt.Errorf("failed to marshal private key: %w", err) - } - keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) - // Combine cert and key into a single PEM bundle, base64-encode it combinedPEM := append(certPEM, keyPEM...) mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) // 3. Build YAML config - targetNames := make([]string, len(builder.SupportedTargets)) - for i, t := range builder.SupportedTargets { + 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: builder.Upstream, + Upstream: b.Upstream, } configBytes, err := yaml.Marshal(configData) @@ -358,7 +324,7 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create } return &models.RegisterBuilderOutput{ - Builder: builder, + Builder: b, MtlsCert: mtlsCert, Config: string(configBytes), }, nil diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index b02df15b1..0734bae8d 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -33,7 +33,7 @@ func TestCreateQuest(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index b2ae9ae21..c7175c07f 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -2,6 +2,8 @@ package graphql import ( "context" + "crypto/ecdsa" + "crypto/x509" "fmt" "realm.pub/tavern/internal/auth" @@ -19,14 +21,21 @@ 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 *ecdsa.PrivateKey } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey *ecdsa.PrivateKey) graphql.ExecutableSchema { cfg := generated.Config{ - Resolvers: &Resolver{client, importer}, + Resolvers: &Resolver{ + client: client, + importer: importer, + builderCA: builderCA, + builderCAKey: builderCAKey, + }, } cfg.Directives.RequireRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, requiredRole models.Role) (interface{}, error) { // Allow unauthenticated contexts to continue for open endpoints diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 4c3dbc9d7..7748635f4 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -590,6 +590,10 @@ type Builder implements Node { """ 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!]! @@ -690,6 +694,22 @@ input BuilderWhereInput { 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 diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 635caf269..6bc1b41c6 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -585,6 +585,10 @@ type Builder implements Node { """ 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!]! @@ -685,6 +689,22 @@ input BuilderWhereInput { 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 diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index 2d342b7cf..1278bea24 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -26,7 +26,7 @@ func TestTomeMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index d97f9e71d..e6cedeb54 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -29,7 +29,7 @@ func TestUserMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 4c3dbc9d7..7748635f4 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -590,6 +590,10 @@ type Builder implements Node { """ 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!]! @@ -690,6 +694,22 @@ input BuilderWhereInput { 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 From 19a647a4b9cf57f496ce817acf0e7e1ac3276987 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:43:41 +0000 Subject: [PATCH 3/8] Replace b64 ID with uuid --- tavern/internal/builder/client.go | 10 ++++------ tavern/internal/ent/schema/beacon.go | 12 ++---------- tavern/internal/graphql/mutation.resolvers.go | 5 ++--- tavern/internal/graphql/schema/inputs.graphql | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index aebdcc2b0..b5507497d 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -55,12 +55,9 @@ func NewCredentialsFromConfig(cfg *Config) (credentials.PerRPCCredentials, error } // parseMTLSCredentials loads the certificate and private key from the config's -// base64-encoded PEM bundle. -func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { - pemBundle, err := base64.StdEncoding.DecodeString(mtlsBase64) - if err != nil { - return nil, fmt.Errorf("failed to decode mTLS base64: %w", err) - } +// PEM bundle string. +func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { + pemBundle := []byte(mtlsPEM) var certDER []byte var privKey *ecdsa.PrivateKey @@ -74,6 +71,7 @@ func parseMTLSCredentials(mtlsBase64 string) (*builderCredentials, error) { case "CERTIFICATE": certDER = block.Bytes case "EC PRIVATE KEY": + var err error privKey, err = x509.ParseECPrivateKey(block.Bytes) if err != nil { return nil, fmt.Errorf("failed to parse EC private key: %w", err) diff --git a/tavern/internal/ent/schema/beacon.go b/tavern/internal/ent/schema/beacon.go index 1f36fe8c9..660f4f123 100644 --- a/tavern/internal/ent/schema/beacon.go +++ b/tavern/internal/ent/schema/beacon.go @@ -1,10 +1,7 @@ package schema import ( - "crypto/rand" - "encoding/base64" - "fmt" - "io" + "github.com/google/uuid" "entgo.io/contrib/entgql" "entgo.io/ent" @@ -134,10 +131,5 @@ func (Beacon) Mixin() []ent.Mixin { } func newRandomIdentifier() string { - buf := make([]byte, 64) - _, err := io.ReadFull(rand.Reader, buf) - if err != nil { - panic(fmt.Errorf("failed to generate random identifier: %w", err)) - } - return base64.StdEncoding.EncodeToString(buf) + return uuid.New().String() } diff --git a/tavern/internal/graphql/mutation.resolvers.go b/tavern/internal/graphql/mutation.resolvers.go index 2b397c363..187fe3aa6 100644 --- a/tavern/internal/graphql/mutation.resolvers.go +++ b/tavern/internal/graphql/mutation.resolvers.go @@ -7,7 +7,6 @@ package graphql import ( "context" - "encoding/base64" "fmt" "strings" "time" @@ -296,9 +295,9 @@ func (r *mutationResolver) RegisterBuilder(ctx context.Context, input ent.Create return nil, fmt.Errorf("failed to sign builder certificate: %w", err) } - // Combine cert and key into a single PEM bundle, base64-encode it + // Combine cert and key into a single PEM bundle combinedPEM := append(certPEM, keyPEM...) - mtlsCert := base64.StdEncoding.EncodeToString(combinedPEM) + mtlsCert := string(combinedPEM) // 3. Build YAML config targetNames := make([]string, len(b.SupportedTargets)) diff --git a/tavern/internal/graphql/schema/inputs.graphql b/tavern/internal/graphql/schema/inputs.graphql index 460afcc30..b8f8234b9 100644 --- a/tavern/internal/graphql/schema/inputs.graphql +++ b/tavern/internal/graphql/schema/inputs.graphql @@ -53,7 +53,7 @@ type RegisterBuilderOutput { """The created builder entity.""" builder: Builder! - """mTLS certificate in base64 encoding for the builder to authenticate.""" + """mTLS certificate PEM bundle for the builder to authenticate.""" mtlsCert: String! """YAML-formatted configuration for the builder.""" From 26ea646257f2a5c475a2d77a082d5be39451827f Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:02:55 +0000 Subject: [PATCH 4/8] Update to use ed25519 key --- tavern/app.go | 19 ++++- tavern/internal/builder/auth.go | 10 +-- tavern/internal/builder/ca.go | 87 ++++----------------- tavern/internal/builder/client.go | 26 +++--- tavern/internal/builder/integration_test.go | 13 ++- tavern/internal/graphql/resolver.go | 18 ++--- 6 files changed, 63 insertions(+), 110 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index 4a7227598..75b00f688 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -3,7 +3,7 @@ package main import ( "context" "crypto/ecdh" - "crypto/ecdsa" + "crypto/ed25519" "crypto/x509" "encoding/base64" "fmt" @@ -404,7 +404,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey *ecdsa.PrivateKey) http.Handler { +func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey ed25519.PrivateKey) http.Handler { srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, builderCACert, builderCAKey)) srv.Use(entgql.Transactioner{TxOpener: client}) @@ -522,13 +522,24 @@ func getKeyPairEd25519() (pubKey []byte, privKey []byte, err error) { } // getBuilderCA returns the Builder CA certificate and private key for signing builder certificates. -func getBuilderCA() (caCert *x509.Certificate, caKey *ecdsa.PrivateKey, err error) { +// 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 } - return builder.GetOrCreateCA(secretsManager) + 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 { diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go index be479da6e..2d2517cde 100644 --- a/tavern/internal/builder/auth.go +++ b/tavern/internal/builder/auth.go @@ -2,8 +2,7 @@ package builder import ( "context" - "crypto/ecdsa" - "crypto/sha256" + "crypto/ed25519" "crypto/x509" "encoding/base64" "log/slog" @@ -99,12 +98,11 @@ func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryS return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") } - hash := sha256.Sum256([]byte(timestamp)) - pubKey, ok := cert.PublicKey.(*ecdsa.PublicKey) + pubKey, ok := cert.PublicKey.(ed25519.PublicKey) if !ok { - return nil, status.Error(codes.Unauthenticated, "certificate does not contain ECDSA public key") + return nil, status.Error(codes.Unauthenticated, "certificate does not contain ED25519 public key") } - if !ecdsa.VerifyASN1(pubKey, hash[:], sigBytes) { + if !ed25519.Verify(pubKey, []byte(timestamp), sigBytes) { return nil, status.Error(codes.Unauthenticated, "invalid signature") } diff --git a/tavern/internal/builder/ca.go b/tavern/internal/builder/ca.go index 6764ab6bd..b482d76bf 100644 --- a/tavern/internal/builder/ca.go +++ b/tavern/internal/builder/ca.go @@ -1,8 +1,7 @@ package builder import ( - "crypto/ecdsa" - "crypto/elliptic" + "crypto/ed25519" "crypto/rand" "crypto/x509" "crypto/x509/pkix" @@ -10,52 +9,16 @@ import ( "fmt" "math/big" "time" - - "realm.pub/tavern/internal/secrets" ) -// GetOrCreateCA retrieves or generates the Builder CA certificate and private key. -// The CA is persisted via the secrets manager so it survives restarts. -// Data is stored as PEM (text-safe) to avoid binary corruption in YAML-based secrets managers. -func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *ecdsa.PrivateKey, error) { - if secretsManager == nil { - return nil, nil, fmt.Errorf("secrets manager is nil") - } - - // Try to load existing CA (stored as PEM for text-safety) - certPEMBytes, certErr := secretsManager.GetValue("builder_ca_certificate") - keyPEMBytes, keyErr := secretsManager.GetValue("builder_ca_private_key") - - if certErr == nil && keyErr == nil && len(certPEMBytes) > 0 && len(keyPEMBytes) > 0 { - certBlock, _ := pem.Decode(certPEMBytes) - if certBlock == nil { - return nil, nil, fmt.Errorf("failed to decode stored CA certificate PEM") - } - cert, err := x509.ParseCertificate(certBlock.Bytes) - if err != nil { - return nil, nil, fmt.Errorf("failed to parse stored CA certificate: %w", err) - } - - keyBlock, _ := pem.Decode(keyPEMBytes) - if keyBlock == nil { - return nil, nil, fmt.Errorf("failed to decode stored CA private key PEM") - } - key, err := x509.ParseECPrivateKey(keyBlock.Bytes) - if err != nil { - return nil, nil, fmt.Errorf("failed to parse stored CA private key: %w", err) - } - return cert, key, nil - } - - // Generate new CA - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, nil, fmt.Errorf("failed to generate CA private key: %w", err) - } +// 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, nil, fmt.Errorf("failed to generate serial number: %w", err) + return nil, fmt.Errorf("failed to generate serial number: %w", err) } template := x509.Certificate{ @@ -72,41 +35,25 @@ func GetOrCreateCA(secretsManager secrets.SecretsManager) (*x509.Certificate, *e MaxPathLen: 0, } - caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) - if err != nil { - return nil, nil, fmt.Errorf("failed to create CA certificate: %w", err) - } - - keyDER, err := x509.MarshalECPrivateKey(privKey) + caDER, err := x509.CreateCertificate(rand.Reader, &template, &template, pubKey, privKey) if err != nil { - return nil, nil, fmt.Errorf("failed to marshal CA private key: %w", err) - } - - // Store as PEM to avoid binary corruption in text-based secrets managers - certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}) - keyPEM := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER}) - - if _, err := secretsManager.SetValue("builder_ca_certificate", certPEM); err != nil { - return nil, nil, fmt.Errorf("failed to store CA certificate: %w", err) - } - if _, err := secretsManager.SetValue("builder_ca_private_key", keyPEM); err != nil { - return nil, nil, fmt.Errorf("failed to store CA private key: %w", err) + return nil, fmt.Errorf("failed to create CA certificate: %w", err) } cert, err := x509.ParseCertificate(caDER) if err != nil { - return nil, nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) + return nil, fmt.Errorf("failed to parse generated CA certificate: %w", err) } - return cert, privKey, nil + 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 *ecdsa.PrivateKey, builderIdentifier string) (certPEM []byte, keyPEM []byte, err error) { - privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) +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 private key: %w", err) + 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)) @@ -122,23 +69,23 @@ func SignBuilderCertificate(ca *x509.Certificate, caKey *ecdsa.PrivateKey, build }, NotBefore: time.Now(), NotAfter: time.Now().Add(365 * 24 * time.Hour), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, + KeyUsage: x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, BasicConstraintsValid: true, } - certDER, err := x509.CreateCertificate(rand.Reader, &template, ca, &privKey.PublicKey, caKey) + 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.MarshalECPrivateKey(privKey) + 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: "EC PRIVATE KEY", Bytes: keyDER}) + 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 index b5507497d..4596133fb 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -2,9 +2,7 @@ package builder import ( "context" - "crypto/ecdsa" - "crypto/rand" - "crypto/sha256" + "crypto/ed25519" "crypto/x509" "encoding/base64" "encoding/pem" @@ -22,7 +20,7 @@ import ( // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. type builderCredentials struct { certDERBase64 string - privKey *ecdsa.PrivateKey + privKey ed25519.PrivateKey } // GetRequestMetadata generates fresh authentication metadata for each RPC call. @@ -30,11 +28,7 @@ type builderCredentials struct { func (c *builderCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { timestamp := time.Now().UTC().Format(time.RFC3339Nano) - hash := sha256.Sum256([]byte(timestamp)) - sig, err := ecdsa.SignASN1(rand.Reader, c.privKey, hash[:]) - if err != nil { - return nil, fmt.Errorf("failed to sign timestamp: %w", err) - } + sig := ed25519.Sign(c.privKey, []byte(timestamp)) return map[string]string{ mdKeyBuilderCert: c.certDERBase64, @@ -60,7 +54,7 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { pemBundle := []byte(mtlsPEM) var certDER []byte - var privKey *ecdsa.PrivateKey + var privKey ed25519.PrivateKey for { block, rest := pem.Decode(pemBundle) @@ -70,12 +64,16 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { switch block.Type { case "CERTIFICATE": certDER = block.Bytes - case "EC PRIVATE KEY": - var err error - privKey, err = x509.ParseECPrivateKey(block.Bytes) + case "PRIVATE KEY": + key, err := x509.ParsePKCS8PrivateKey(block.Bytes) if err != nil { - return nil, fmt.Errorf("failed to parse EC private key: %w", err) + 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 } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 673c73721..072b143a2 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -2,6 +2,8 @@ package builder_test import ( "context" + "crypto/ed25519" + "crypto/rand" "net" "testing" @@ -21,7 +23,6 @@ import ( "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" tavernhttp "realm.pub/tavern/internal/http" - "realm.pub/tavern/internal/secrets" "realm.pub/tavern/tomes" ) @@ -32,20 +33,18 @@ func TestBuilderE2E(t *testing.T) { graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") defer graph.Close() - // 2. Initialize Builder CA - secretsDir := t.TempDir() - secretsManager, err := secrets.NewDebugFileSecrets(secretsDir + "/secrets.yaml") + // 2. Generate ED25519 key pair and create Builder CA + _, caPrivKey, err := ed25519.GenerateKey(rand.Reader) require.NoError(t, err) - caCert, caKey, err := builder.GetOrCreateCA(secretsManager) + caCert, err := builder.CreateCA(caPrivKey) require.NoError(t, err) require.NotNil(t, caCert) - require.NotNil(t, caKey) // 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, caCert, caKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index c7175c07f..0d60c3f8e 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -2,7 +2,7 @@ package graphql import ( "context" - "crypto/ecdsa" + "crypto/ed25519" "crypto/x509" "fmt" @@ -21,19 +21,19 @@ type RepoImporter interface { // Resolver is the resolver root. type Resolver struct { - client *ent.Client - importer RepoImporter - builderCA *x509.Certificate - builderCAKey *ecdsa.PrivateKey + client *ent.Client + importer RepoImporter + builderCA *x509.Certificate + builderCAKey ed25519.PrivateKey } // NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey *ecdsa.PrivateKey) graphql.ExecutableSchema { +func NewSchema(client *ent.Client, importer RepoImporter, builderCA *x509.Certificate, builderCAKey ed25519.PrivateKey) graphql.ExecutableSchema { cfg := generated.Config{ Resolvers: &Resolver{ - client: client, - importer: importer, - builderCA: builderCA, + client: client, + importer: importer, + builderCA: builderCA, builderCAKey: builderCAKey, }, } From e9561bf8e51eb6f8adef5dae3655d2c0faa932cc Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:45:27 +0000 Subject: [PATCH 5/8] Address feedback --- tavern/app.go | 2 +- tavern/internal/builder/README.md | 10 +++---- tavern/internal/builder/auth.go | 33 ++++++++------------- tavern/internal/builder/client.go | 14 ++++----- tavern/internal/builder/integration_test.go | 2 +- tavern/internal/ent/schema/beacon.go | 12 ++++++-- tavern/internal/ent/schema/builder.go | 4 ++- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index 75b00f688..040d2161e 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -568,7 +568,7 @@ func newBuilderGRPCHandler(client *ent.Client, caCert *x509.Certificate) http.Ha builderSrv := builder.New(client) grpcSrv := grpc.NewServer( grpc.ChainUnaryInterceptor( - builder.NewAuthInterceptor(caCert, client), + builder.NewMTLSAuthInterceptor(caCert, client), grpcWithUnaryMetrics, ), grpc.StreamInterceptor(grpcWithStreamMetrics), diff --git a/tavern/internal/builder/README.md b/tavern/internal/builder/README.md index 00558fa7b..1d914a279 100644 --- a/tavern/internal/builder/README.md +++ b/tavern/internal/builder/README.md @@ -19,7 +19,7 @@ supported_targets: - linux - macos - windows -mtls: +mtls: upstream: ``` @@ -27,17 +27,17 @@ upstream: |-------|-------------| | `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` | Base64-encoded PEM bundle containing the CA-signed mTLS certificate and private key for authenticating with Tavern. | +| `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 ECDSA P-256 client certificate signed by the Tavern Builder CA, with CN=`builder-{identifier}`. +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`: Base64-encoded DER certificate - - `builder-signature`: Base64-encoded ECDSA signature over the timestamp + - `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 diff --git a/tavern/internal/builder/auth.go b/tavern/internal/builder/auth.go index 2d2517cde..eb85a6a6a 100644 --- a/tavern/internal/builder/auth.go +++ b/tavern/internal/builder/auth.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ed25519" "crypto/x509" - "encoding/base64" "log/slog" "strings" "time" @@ -20,8 +19,9 @@ import ( const ( // Metadata keys for mTLS authentication. - mdKeyBuilderCert = "builder-cert" - mdKeyBuilderSignature = "builder-signature" + // 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. @@ -39,35 +39,31 @@ func BuilderFromContext(ctx context.Context) (*ent.Builder, bool) { return b, ok } -// NewAuthInterceptor creates a gRPC unary server interceptor that validates +// 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 NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryServerInterceptor { +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 - certB64 := getMetadataValue(md, mdKeyBuilderCert) - sigB64 := getMetadataValue(md, mdKeyBuilderSignature) + // 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 certB64 == "" || sigB64 == "" || timestamp == "" { + if certDER == "" || signature == "" || timestamp == "" { return nil, status.Error(codes.Unauthenticated, "missing builder credentials") } // Parse the certificate - certDER, err := base64.StdEncoding.DecodeString(certB64) - if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid certificate encoding") - } - - cert, err := x509.ParseCertificate(certDER) + cert, err := x509.ParseCertificate([]byte(certDER)) if err != nil { return nil, status.Error(codes.Unauthenticated, "invalid certificate") } @@ -93,16 +89,11 @@ func NewAuthInterceptor(caCert *x509.Certificate, graph *ent.Client) grpc.UnaryS } // Verify signature (proof of private key possession) - sigBytes, err := base64.StdEncoding.DecodeString(sigB64) - if err != nil { - return nil, status.Error(codes.Unauthenticated, "invalid signature encoding") - } - 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), sigBytes) { + if !ed25519.Verify(pubKey, []byte(timestamp), []byte(signature)) { return nil, status.Error(codes.Unauthenticated, "invalid signature") } diff --git a/tavern/internal/builder/client.go b/tavern/internal/builder/client.go index 4596133fb..3d310d63d 100644 --- a/tavern/internal/builder/client.go +++ b/tavern/internal/builder/client.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ed25519" "crypto/x509" - "encoding/base64" "encoding/pem" "fmt" "log/slog" @@ -19,20 +18,21 @@ import ( // builderCredentials implements grpc.PerRPCCredentials for mTLS authentication. type builderCredentials struct { - certDERBase64 string - privKey ed25519.PrivateKey + 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: c.certDERBase64, - mdKeyBuilderSignature: base64.StdEncoding.EncodeToString(sig), + mdKeyBuilderCert: string(c.certDER), + mdKeyBuilderSignature: string(sig), mdKeyBuilderTimestamp: timestamp, }, nil } @@ -86,8 +86,8 @@ func parseMTLSCredentials(mtlsPEM string) (*builderCredentials, error) { } return &builderCredentials{ - certDERBase64: base64.StdEncoding.EncodeToString(certDER), - privKey: privKey, + certDER: certDER, + privKey: privKey, }, nil } diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 072b143a2..4e0cbc7af 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -95,7 +95,7 @@ func TestBuilderE2E(t *testing.T) { lis := bufconn.Listen(1024 * 1024) grpcSrv := grpc.NewServer( grpc.ChainUnaryInterceptor( - builder.NewAuthInterceptor(caCert, graph), + builder.NewMTLSAuthInterceptor(caCert, graph), ), ) builderSrv := builder.New(graph) diff --git a/tavern/internal/ent/schema/beacon.go b/tavern/internal/ent/schema/beacon.go index 660f4f123..1f36fe8c9 100644 --- a/tavern/internal/ent/schema/beacon.go +++ b/tavern/internal/ent/schema/beacon.go @@ -1,7 +1,10 @@ package schema import ( - "github.com/google/uuid" + "crypto/rand" + "encoding/base64" + "fmt" + "io" "entgo.io/contrib/entgql" "entgo.io/ent" @@ -131,5 +134,10 @@ func (Beacon) Mixin() []ent.Mixin { } func newRandomIdentifier() string { - return uuid.New().String() + buf := make([]byte, 64) + _, err := io.ReadFull(rand.Reader, buf) + if err != nil { + panic(fmt.Errorf("failed to generate random identifier: %w", err)) + } + return base64.StdEncoding.EncodeToString(buf) } diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index 8613d5f26..d29e5269d 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -1,6 +1,8 @@ package schema import ( + "github.com/google/uuid" + "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/dialect/entsql" @@ -18,7 +20,7 @@ type Builder struct { func (Builder) Fields() []ent.Field { return []ent.Field{ field.String("identifier"). - DefaultFunc(newRandomIdentifier). + DefaultFunc(func() string { return uuid.New().String() }). NotEmpty(). Unique(). Immutable(). From 50c5355a103261cccaca1bbda38d94aafd1276e0 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:55:51 +0000 Subject: [PATCH 6/8] fix --- tavern/app.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tavern/app.go b/tavern/app.go index 3fd555144..658c347a4 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -4,6 +4,7 @@ import ( "context" "crypto/ecdh" "crypto/ed25519" + "crypto/tls" "crypto/x509" "encoding/base64" "fmt" From f4ce41662b66da8be5b972014a3a730308559732 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Sun, 15 Feb 2026 22:15:42 +0000 Subject: [PATCH 7/8] Address feedback --- tavern/app.go | 6 ++-- tavern/internal/builder/integration_test.go | 2 +- tavern/internal/ent/schema/builder.go | 2 +- tavern/internal/graphql/resolver.go | 34 ++++++++++++++++----- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/tavern/app.go b/tavern/app.go index 658c347a4..98d2f5226 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -325,7 +325,7 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { AllowUnactivated: true, }, "/graphql": tavernhttp.Endpoint{ - Handler: newGraphQLHandler(client, git, builderCACert, builderCAKey), + Handler: newGraphQLHandler(client, git, graphql.WithBuilderCAKey(builderCAKey), graphql.WithBuilderCA(builderCACert)), AllowUnactivated: true, }, "/c2.C2/": tavernhttp.Endpoint{ @@ -424,8 +424,8 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { return tSrv, nil } -func newGraphQLHandler(client *ent.Client, repoImporter graphql.RepoImporter, builderCACert *x509.Certificate, builderCAKey ed25519.PrivateKey) http.Handler { - srv := handler.NewDefaultServer(graphql.NewSchema(client, repoImporter, builderCACert, builderCAKey)) +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 diff --git a/tavern/internal/builder/integration_test.go b/tavern/internal/builder/integration_test.go index 4e0cbc7af..11fefe513 100644 --- a/tavern/internal/builder/integration_test.go +++ b/tavern/internal/builder/integration_test.go @@ -44,7 +44,7 @@ func TestBuilderE2E(t *testing.T) { git := tomes.NewGitImporter(graph) srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, caCert, caPrivKey)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, graphql.WithBuilderCA(caCert), graphql.WithBuilderCAKey(caPrivKey))), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/ent/schema/builder.go b/tavern/internal/ent/schema/builder.go index d29e5269d..7fee66808 100644 --- a/tavern/internal/ent/schema/builder.go +++ b/tavern/internal/ent/schema/builder.go @@ -20,7 +20,7 @@ type Builder struct { func (Builder) Fields() []ent.Field { return []ent.Field{ field.String("identifier"). - DefaultFunc(func() string { return uuid.New().String() }). + DefaultFunc(uuid.New().String). NotEmpty(). Unique(). Immutable(). diff --git a/tavern/internal/graphql/resolver.go b/tavern/internal/graphql/resolver.go index 0d60c3f8e..470034358 100644 --- a/tavern/internal/graphql/resolver.go +++ b/tavern/internal/graphql/resolver.go @@ -14,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 @@ -27,16 +30,33 @@ type Resolver struct { 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, builderCA *x509.Certificate, builderCAKey ed25519.PrivateKey) 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: client, - importer: importer, - builderCA: builderCA, - builderCAKey: builderCAKey, - }, + 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 { From c2e6419fc80f7fdc9391f151a09207b463aa261e Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Sun, 15 Feb 2026 22:50:21 +0000 Subject: [PATCH 8/8] fix tests --- tavern/internal/graphql/api_test.go | 2 +- tavern/internal/graphql/quest_test.go | 2 +- tavern/internal/graphql/tome_test.go | 2 +- tavern/internal/graphql/user_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tavern/internal/graphql/api_test.go b/tavern/internal/graphql/api_test.go index b8ad58a76..75046c9e1 100644 --- a/tavern/internal/graphql/api_test.go +++ b/tavern/internal/graphql/api_test.go @@ -94,7 +94,7 @@ func runTestCase(t *testing.T, path string) { // Server srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph}, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, importerFake{graph})), }, tavernhttp.WithAuthentication(graph), ) diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index 0734bae8d..b02df15b1 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -33,7 +33,7 @@ func TestCreateQuest(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/tome_test.go b/tavern/internal/graphql/tome_test.go index 1278bea24..2d342b7cf 100644 --- a/tavern/internal/graphql/tome_test.go +++ b/tavern/internal/graphql/tome_test.go @@ -26,7 +26,7 @@ func TestTomeMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), ) diff --git a/tavern/internal/graphql/user_test.go b/tavern/internal/graphql/user_test.go index e6cedeb54..d97f9e71d 100644 --- a/tavern/internal/graphql/user_test.go +++ b/tavern/internal/graphql/user_test.go @@ -29,7 +29,7 @@ func TestUserMutations(t *testing.T) { srv := tavernhttp.NewServer( tavernhttp.RouteMap{ - "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git, nil, nil)), + "/graphql": handler.NewDefaultServer(graphql.NewSchema(graph, git)), }, tavernhttp.WithAuthenticationBypass(graph), )