Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Aspire.Cli/Aspire.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NoWarn>$(NoWarn);CS1591</NoWarn>
<IsAotCompatible>true</IsAotCompatible>
<PublishAot>true</PublishAot>
<DefineConstants>$(DefineConstants);CLI</DefineConstants>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
</PropertyGroup>
Expand Down Expand Up @@ -46,6 +47,7 @@
<Compile Include="$(SharedDir)PathNormalizer.cs" Link="Utils\PathNormalizer.cs" />
<Compile Include="$(SharedDir)CircularBuffer.cs" Link="Utils\CircularBuffer.cs" />
<Compile Include="$(SharedDir)StringComparers.cs" Link="StringComparers.cs" />
<Compile Include="$(RepoRoot)src\Aspire.Hosting\Backchannel\BackchannelDataTypes.cs" Link="Backchannel\CliBackchannelDataTypes.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
178 changes: 0 additions & 178 deletions src/Aspire.Cli/Backchannel/BackchannelDataTypes.cs
Original file line number Diff line number Diff line change
@@ -1,57 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Logging;

namespace Aspire.Cli.Backchannel;

/// <summary>
/// Represents the state of a resource reported via RPC.
/// </summary>
internal sealed class RpcResourceState
{
/// <summary>
/// Gets the name of the resource.
/// </summary>
public required string Resource { get; init; }

/// <summary>
/// Gets the type of the resource.
/// </summary>
public required string Type { get; init; }

/// <summary>
/// Gets the state of the resource.
/// </summary>
public required string State { get; init; }

/// <summary>
/// Gets the endpoints associated with the resource.
/// </summary>
public required string[] Endpoints { get; init; }

/// <summary>
/// Gets the health status of the resource.
/// </summary>
public string? Health { get; init; }
}

/// <summary>
/// Represents dashboard URLs with authentication tokens.
/// </summary>
internal sealed class DashboardUrlsState
{
/// <summary>
/// Gets the base dashboard URL with a login token.
/// </summary>
public required string BaseUrlWithLoginToken { get; init; }

/// <summary>
/// Gets the Codespaces dashboard URL with a login token, if available.
/// </summary>
public string? CodespacesUrlWithLoginToken { get; init; }
}

/// <summary>
/// Represents a single line of output to be displayed, along with its associated stream (such as "stdout" or "stderr").
/// </summary>
Expand All @@ -68,104 +19,6 @@ internal sealed class DisplayLineState(string stream, string line)
public string Line { get; } = line;
}

/// <summary>
/// Envelope for publishing activity items sent over the backchannel.
/// </summary>
internal sealed class PublishingActivity
{
/// <summary>
/// Gets the type discriminator for the publishing activity item.
/// </summary>
public required string Type { get; init; }

/// <summary>
/// Gets the data containing all properties for the publishing activity item.
/// </summary>
public required PublishingActivityData Data { get; init; }
}

/// <summary>
/// Common data for all publishing activity items.
/// </summary>
internal sealed class PublishingActivityData
{
/// <summary>
/// Gets the unique identifier for the publishing activity.
/// </summary>
public required string Id { get; init; }

/// <summary>
/// Gets the status text describing the publishing activity.
/// </summary>
public required string StatusText { get; init; }

/// <summary>
/// Gets the completion state of the publishing activity.
/// </summary>
public string CompletionState { get; init; } = CompletionStates.InProgress;

/// <summary>
/// Gets a value indicating whether the publishing activity is complete.
/// </summary>
public bool IsComplete => CompletionState is not CompletionStates.InProgress;

/// <summary>
/// Gets a value indicating whether the publishing activity encountered an error.
/// </summary>
public bool IsError => CompletionState is CompletionStates.CompletedWithError;

/// <summary>
/// Gets a value indicating whether the publishing activity completed with warnings.
/// </summary>
public bool IsWarning => CompletionState is CompletionStates.CompletedWithWarning;

/// <summary>
/// Gets the identifier of the step this task belongs to (only applicable for tasks).
/// </summary>
public string? StepId { get; init; }

/// <summary>
/// Gets the completion message for the publishing activity (optional).
/// </summary>
public string? CompletionMessage { get; init; }

/// <summary>
/// Gets the input information for prompt activities, if available.
/// </summary>
public IReadOnlyList<PublishingPromptInput>? Inputs { get; init; }
}

/// <summary>
/// Represents an input for a publishing prompt.
/// </summary>
internal sealed class PublishingPromptInput
{
/// <summary>
/// Gets the label for the input.
/// </summary>
public required string Label { get; init; }

/// <summary>
/// Gets the type of the input.
/// </summary>
public required string InputType { get; init; }

/// <summary>
/// Gets a value indicating whether the input is required.
/// </summary>
public bool Required { get; init; }

/// <summary>
/// Gets the options for the input. Only used by select inputs.
/// </summary>
public IReadOnlyList<KeyValuePair<string, string>>? Options { get; init; }

/// <summary>
/// Gets the default value for the input.
/// </summary>
public string? Value { get; init; }
}

/// <summary>
/// Specifies the type of input for a publishing prompt input.
/// </summary>
Expand All @@ -192,34 +45,3 @@ internal enum InputType
/// </summary>
Number
}

/// <summary>
/// Constants for publishing activity item types.
/// </summary>
internal static class PublishingActivityTypes
{
public const string Step = "step";
public const string Task = "task";
public const string PublishComplete = "publish-complete";
public const string Prompt = "prompt";
}

internal class BackchannelLogEntry
{
public required EventId EventId { get; set; }
public required LogLevel LogLevel { get; set; }
public required string Message { get; set; }
public required DateTimeOffset Timestamp { get; set; }
public required string CategoryName { get; set; }
}

/// <summary>
/// Constants for completion state values.
/// </summary>
internal static class CompletionStates
{
public const string InProgress = "InProgress";
public const string Completed = "Completed";
public const string CompletedWithWarning = "CompletedWithWarning";
public const string CompletedWithError = "CompletedWithError";
}
17 changes: 17 additions & 0 deletions src/Aspire.Hosting/Backchannel/BackchannelDataTypes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// These types are source shared between the CLI and the Aspire.Hosting projects.
// The CLI sets the types in its own namespace.
#if CLI
namespace Aspire.Cli.Backchannel;
#else
namespace Aspire.Hosting.Backchannel;
#endif

using Microsoft.Extensions.Logging;

/// <summary>
/// Represents the state of a resource reported via RPC.
Expand Down Expand Up @@ -169,3 +177,12 @@ internal static class CompletionStates
public const string CompletedWithWarning = "CompletedWithWarning";
public const string CompletedWithError = "CompletedWithError";
}

internal class BackchannelLogEntry
{
public required EventId EventId { get; set; }
public required LogLevel LogLevel { get; set; }
public required string Message { get; set; }
public required DateTimeOffset Timestamp { get; set; }
public required string CategoryName { get; set; }
}
9 changes: 0 additions & 9 deletions src/Aspire.Hosting/Backchannel/BackchannelLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,3 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
}
}
}

internal class BackchannelLogEntry
{
public required EventId EventId { get; set; }
public required LogLevel LogLevel { get; set; }
public required string Message { get; set; }
public required DateTimeOffset Timestamp { get; set; }
public required string CategoryName { get; set; }
}