using System.Text.Json.Serialization; using StabilityMatrix.Core.Models.Api.Comfy.NodeTypes; namespace StabilityMatrix.Core.Models.Api.Comfy.Nodes; [JsonSerializable(typeof(NamedComfyNode))] public record NamedComfyNode([property: JsonIgnore] string Name) : ComfyNode, IOutputNode { /// /// Returns { Name, index } for use as a node connection /// public object[] GetOutput(int index) { return new object[] { Name, index }; } /// /// Returns typed { Name, index } for use as a node connection /// public TOutput GetOutput(int index) where TOutput : NodeConnectionBase, new() { return new TOutput { Data = GetOutput(index) }; } } [JsonSerializable(typeof(NamedComfyNode<>))] public record NamedComfyNode(string Name) : NamedComfyNode(Name) where TOutput : NodeConnectionBase, new() { public TOutput Output => new TOutput { Data = GetOutput(0) }; } [JsonSerializable(typeof(NamedComfyNode<>))] public record NamedComfyNode(string Name) : NamedComfyNode(Name) where TOutput1 : NodeConnectionBase, new() where TOutput2 : NodeConnectionBase, new() { public TOutput1 Output1 => new() { Data = GetOutput(0) }; public TOutput2 Output2 => new() { Data = GetOutput(1) }; }