Files
novelly/src/Novelly.Api/Imports/ImportContracts.cs
T
James Wampler 4313c8f206 Rename Project concept to Novel across the stack
Renames the domain concept from Project to Novel throughout the backend
(entities, DTOs, services, endpoints, ProjectAccessService/Permission,
ProjectId foreign keys), MCP server (tool names and routes), and the
React/Vite frontend (types, hooks, routes, components). Adds a new EF
Core migration (RenameProjectToNovel) using RenameTable/RenameColumn to
preserve existing data instead of dropping/recreating tables. Updates
CLAUDE.md's structure section to reference Novels/ instead of Projects/.
2026-08-17 23:03:09 -07:00

73 lines
1.7 KiB
C#

using Novelly.Api.Common.Validation;
namespace Novelly.Api.Imports;
public record ImportJobResponse(
Guid Id,
string SourceRoot,
Guid? NovelId,
ImportJobStatus Status,
string? StatusMessage,
int ChaptersCompleted,
int ChaptersTotal,
DateTimeOffset CreatedAt,
DateTimeOffset UpdatedAt);
public enum ImportReadiness
{
Fresh,
Resumable,
Complete
}
public record ImportInspectionResponse(
ImportReadiness Readiness,
Guid? NovelId,
int ChaptersCompleted,
int ChaptersTotal,
IReadOnlyList<string> CompletedPasses);
public record InspectImportRequest(string SourceRoot);
public class InspectImportRequestValidator : IModelValidator<InspectImportRequest>
{
public ValidationResult Validate(InspectImportRequest model)
{
var result = new ValidationResult();
if (string.IsNullOrWhiteSpace(model.SourceRoot))
result.AddError("SourceRoot", "'Source Root' must not be empty.");
return result;
}
}
public record StartImportRequest(string SourceRoot, bool ForceRestart = false);
public class StartImportRequestValidator : IModelValidator<StartImportRequest>
{
public ValidationResult Validate(StartImportRequest model)
{
var result = new ValidationResult();
if (string.IsNullOrWhiteSpace(model.SourceRoot))
result.AddError("SourceRoot", "'Source Root' must not be empty.");
return result;
}
}
public static class ImportMapping
{
public static ImportJobResponse ToResponse(this ImportJob job) => new(
job.Id,
job.SourceRoot,
job.NovelId,
job.Status,
job.StatusMessage,
job.ChaptersCompleted,
job.ChaptersTotal,
job.CreatedAt,
job.UpdatedAt);
}