Initial commit: Nexus Mission Control Platform
- ASP.NET Core 10 Backend (JWT Auth, Agent config API) - Vue 3 Frontend (Dashboard, Team, Agents, Config Editor) - PostgreSQL Database - Docker Compose setup - Mission Control Dashboard redesign
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
namespace Nexus.Api.Domain;
|
||||
|
||||
public enum OperationalStatus
|
||||
{
|
||||
Online,
|
||||
Degraded,
|
||||
Offline,
|
||||
Unknown
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strongly-typed task lifecycle states.
|
||||
/// String values (e.g. "In progress") are preserved for API compatibility
|
||||
/// via <see cref="TaskStateHelper"/>; the WorkTask entity continues to store
|
||||
/// state as a string in the database.
|
||||
/// </summary>
|
||||
public enum TaskState
|
||||
{
|
||||
Backlog,
|
||||
InProgress,
|
||||
Blocked,
|
||||
Done
|
||||
}
|
||||
|
||||
public static class TaskStateHelper
|
||||
{
|
||||
private static readonly Dictionary<TaskState, string> StateToString = new()
|
||||
{
|
||||
[TaskState.Backlog] = "Backlog",
|
||||
[TaskState.InProgress] = "In progress",
|
||||
[TaskState.Blocked] = "Blocked",
|
||||
[TaskState.Done] = "Done"
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, TaskState> StringToState = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["Backlog"] = TaskState.Backlog,
|
||||
["In progress"] = TaskState.InProgress,
|
||||
["Blocked"] = TaskState.Blocked,
|
||||
["Done"] = TaskState.Done
|
||||
};
|
||||
|
||||
/// <summary>Valid task-state string values for API validation.</summary>
|
||||
public static readonly string[] AllStates = ["Backlog", "In progress", "Blocked", "Done"];
|
||||
|
||||
/// <summary>Convert a TaskState enum to its API string representation.</summary>
|
||||
public static string ToStateString(this TaskState state) => StateToString[state];
|
||||
|
||||
/// <summary>Parse a string to TaskState; defaults to Backlog for unrecognized input.</summary>
|
||||
public static TaskState ToTaskState(this string state) =>
|
||||
StringToState.TryGetValue(state, out var result) ? result : TaskState.Backlog;
|
||||
|
||||
/// <summary>Returns true if the string is a recognized task state (case-insensitive).</summary>
|
||||
public static bool IsValidState(string? state) =>
|
||||
!string.IsNullOrWhiteSpace(state) && StringToState.ContainsKey(state);
|
||||
|
||||
public static bool IsInProgressOrBlocked(string? state) =>
|
||||
string.Equals(state, "In progress", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(state, "Blocked", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static bool IsDoneOrBacklog(string? state) =>
|
||||
string.Equals(state, "Done", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(state, "Backlog", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public sealed class Project
|
||||
{
|
||||
public Guid Id { get; init; } = Guid.NewGuid();
|
||||
public required string Name { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int Progress { get; set; }
|
||||
public OperationalStatus Status { get; set; } = OperationalStatus.Unknown;
|
||||
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public sealed class WorkTask
|
||||
{
|
||||
public Guid Id { get; init; } = Guid.NewGuid();
|
||||
public required string Title { get; set; }
|
||||
public string State { get; set; } = "Backlog";
|
||||
public string Priority { get; set; } = "Normal";
|
||||
public Guid? ProjectId { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public sealed class ActivityEvent
|
||||
{
|
||||
public long Id { get; init; }
|
||||
public required string Type { get; set; }
|
||||
public required string Message { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Nexus.Api.Domain;
|
||||
|
||||
public class NexusUser
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[MaxLength(120)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[MaxLength(120)]
|
||||
public string NormalizedEmail { get; set; } = string.Empty;
|
||||
|
||||
[MaxLength(100)]
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
public string PasswordHash { get; set; } = string.Empty;
|
||||
|
||||
public string Role { get; set; } = "owner";
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public DateTimeOffset? LastLoginAt { get; set; }
|
||||
|
||||
public ICollection<RefreshToken> RefreshTokens { get; set; } = new List<RefreshToken>();
|
||||
}
|
||||
|
||||
public class RefreshToken
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public Guid UserId { get; set; }
|
||||
[MaxLength(64)]
|
||||
public string TokenHash { get; set; } = string.Empty;
|
||||
public Guid FamilyId { get; set; } = Guid.NewGuid();
|
||||
public DateTimeOffset ExpiresAt { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? RevokedAt { get; set; }
|
||||
[MaxLength(64)]
|
||||
public string? ReplacedByTokenHash { get; set; }
|
||||
public Guid ConcurrencyStamp { get; set; } = Guid.NewGuid();
|
||||
public NexusUser User { get; set; } = null!;
|
||||
}
|
||||
Reference in New Issue
Block a user