[FA-misc] Switches to using DTOs, updates frontend with details and reader page, updates novel import to be an upsert
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using FictionArchive.Service.NovelService.Models.Novels;
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.NovelService.Models.DTOs;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using HotChocolate.Authorization;
|
||||
using HotChocolate.Data;
|
||||
@@ -13,8 +14,186 @@ public class Query
|
||||
[UseProjection]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
public IQueryable<Novel> GetNovels(NovelServiceDbContext dbContext)
|
||||
public IQueryable<NovelDto> GetNovels(
|
||||
NovelServiceDbContext dbContext,
|
||||
Language preferredLanguage = Language.En)
|
||||
{
|
||||
return dbContext.Novels.AsQueryable();
|
||||
return dbContext.Novels.Select(novel => new NovelDto
|
||||
{
|
||||
Id = novel.Id,
|
||||
CreatedTime = novel.CreatedTime,
|
||||
LastUpdatedTime = novel.LastUpdatedTime,
|
||||
Url = novel.Url,
|
||||
RawLanguage = novel.RawLanguage,
|
||||
RawStatus = novel.RawStatus,
|
||||
StatusOverride = novel.StatusOverride,
|
||||
ExternalId = novel.ExternalId,
|
||||
|
||||
Name = novel.Name.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? novel.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
|
||||
Description = novel.Description.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? novel.Description.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
|
||||
Author = new PersonDto
|
||||
{
|
||||
Id = novel.Author.Id,
|
||||
CreatedTime = novel.Author.CreatedTime,
|
||||
LastUpdatedTime = novel.Author.LastUpdatedTime,
|
||||
Name = novel.Author.Name.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? novel.Author.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
ExternalUrl = novel.Author.ExternalUrl
|
||||
},
|
||||
|
||||
Source = new SourceDto
|
||||
{
|
||||
Id = novel.Source.Id,
|
||||
CreatedTime = novel.Source.CreatedTime,
|
||||
LastUpdatedTime = novel.Source.LastUpdatedTime,
|
||||
Name = novel.Source.Name,
|
||||
Key = novel.Source.Key,
|
||||
Url = novel.Source.Url
|
||||
},
|
||||
|
||||
CoverImage = novel.CoverImage != null
|
||||
? new ImageDto
|
||||
{
|
||||
Id = novel.CoverImage.Id,
|
||||
CreatedTime = novel.CoverImage.CreatedTime,
|
||||
LastUpdatedTime = novel.CoverImage.LastUpdatedTime,
|
||||
NewPath = novel.CoverImage.NewPath
|
||||
}
|
||||
: null,
|
||||
|
||||
Chapters = novel.Chapters.Select(chapter => new ChapterDto
|
||||
{
|
||||
Id = chapter.Id,
|
||||
CreatedTime = chapter.CreatedTime,
|
||||
LastUpdatedTime = chapter.LastUpdatedTime,
|
||||
Revision = chapter.Revision,
|
||||
Order = chapter.Order,
|
||||
Url = chapter.Url,
|
||||
Name = chapter.Name.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? chapter.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
Body = chapter.Body.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? chapter.Body.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
Images = chapter.Images.Select(image => new ImageDto
|
||||
{
|
||||
Id = image.Id,
|
||||
CreatedTime = image.CreatedTime,
|
||||
LastUpdatedTime = image.LastUpdatedTime,
|
||||
NewPath = image.NewPath
|
||||
}).ToList()
|
||||
}).ToList(),
|
||||
|
||||
Tags = novel.Tags.Select(tag => new NovelTagDto
|
||||
{
|
||||
Id = tag.Id,
|
||||
CreatedTime = tag.CreatedTime,
|
||||
LastUpdatedTime = tag.LastUpdatedTime,
|
||||
Key = tag.Key,
|
||||
TagType = tag.TagType,
|
||||
DisplayName = tag.DisplayName.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? tag.DisplayName.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
Source = tag.Source != null
|
||||
? new SourceDto
|
||||
{
|
||||
Id = tag.Source.Id,
|
||||
CreatedTime = tag.Source.CreatedTime,
|
||||
LastUpdatedTime = tag.Source.LastUpdatedTime,
|
||||
Name = tag.Source.Name,
|
||||
Key = tag.Source.Key,
|
||||
Url = tag.Source.Url
|
||||
}
|
||||
: null
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[UseFirstOrDefault]
|
||||
[UseProjection]
|
||||
public IQueryable<ChapterReaderDto> GetChapter(
|
||||
NovelServiceDbContext dbContext,
|
||||
uint novelId,
|
||||
uint chapterOrder,
|
||||
Language preferredLanguage = Language.En)
|
||||
{
|
||||
return dbContext.Chapters
|
||||
.Where(c => c.Novel.Id == novelId && c.Order == chapterOrder)
|
||||
.Select(chapter => new ChapterReaderDto
|
||||
{
|
||||
Id = chapter.Id,
|
||||
CreatedTime = chapter.CreatedTime,
|
||||
LastUpdatedTime = chapter.LastUpdatedTime,
|
||||
Revision = chapter.Revision,
|
||||
Order = chapter.Order,
|
||||
Url = chapter.Url,
|
||||
|
||||
Name = chapter.Name.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? chapter.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
|
||||
Body = chapter.Body.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? chapter.Body.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
|
||||
Images = chapter.Images.Select(image => new ImageDto
|
||||
{
|
||||
Id = image.Id,
|
||||
CreatedTime = image.CreatedTime,
|
||||
LastUpdatedTime = image.LastUpdatedTime,
|
||||
NewPath = image.NewPath
|
||||
}).ToList(),
|
||||
|
||||
NovelId = chapter.Novel.Id,
|
||||
NovelName = chapter.Novel.Name.Texts
|
||||
.Where(t => t.Language == preferredLanguage)
|
||||
.Select(t => t.Text)
|
||||
.FirstOrDefault()
|
||||
?? chapter.Novel.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||
?? "",
|
||||
TotalChapters = chapter.Novel.Chapters.Count,
|
||||
PrevChapterOrder = chapter.Novel.Chapters
|
||||
.Where(c => c.Order < chapterOrder)
|
||||
.OrderByDescending(c => c.Order)
|
||||
.Select(c => (uint?)c.Order)
|
||||
.FirstOrDefault(),
|
||||
NextChapterOrder = chapter.Novel.Chapters
|
||||
.Where(c => c.Order > chapterOrder)
|
||||
.OrderBy(c => c.Order)
|
||||
.Select(c => (uint?)c.Order)
|
||||
.FirstOrDefault()
|
||||
});
|
||||
}
|
||||
}
|
||||
547
FictionArchive.Service.NovelService/Migrations/20251208230154_FA-misc_NovelConstraint.Designer.cs
generated
Normal file
547
FictionArchive.Service.NovelService/Migrations/20251208230154_FA-misc_NovelConstraint.Designer.cs
generated
Normal file
@@ -0,0 +1,547 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using NodaTime;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Migrations
|
||||
{
|
||||
[DbContext(typeof(NovelServiceDbContext))]
|
||||
[Migration("20251208230154_FA-misc_NovelConstraint")]
|
||||
partial class FAmisc_NovelConstraint
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Images.Image", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long?>("ChapterId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("NewPath")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OriginalPath")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ChapterId");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LocalizationKeys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationRequest", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("EngineId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<Guid>("KeyRequestedForTranslationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("TranslateTo")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EngineId");
|
||||
|
||||
b.HasIndex("KeyRequestedForTranslationId");
|
||||
|
||||
b.ToTable("LocalizationRequests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationText", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("Language")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("LocalizationKeyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("TranslationEngineId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LocalizationKeyId");
|
||||
|
||||
b.HasIndex("TranslationEngineId");
|
||||
|
||||
b.ToTable("LocalizationText");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Chapter", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Guid>("BodyId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("NameId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long>("NovelId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("Order")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("Revision")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BodyId");
|
||||
|
||||
b.HasIndex("NameId");
|
||||
|
||||
b.HasIndex("NovelId");
|
||||
|
||||
b.ToTable("Chapter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<long>("AuthorId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<Guid?>("CoverImageId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("DescriptionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ExternalId")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("NameId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("RawLanguage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RawStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("SourceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int?>("StatusOverride")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AuthorId");
|
||||
|
||||
b.HasIndex("CoverImageId");
|
||||
|
||||
b.HasIndex("DescriptionId");
|
||||
|
||||
b.HasIndex("NameId");
|
||||
|
||||
b.HasIndex("SourceId");
|
||||
|
||||
b.HasIndex("ExternalId", "SourceId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Novels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.NovelTag", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("DisplayNameId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long?>("SourceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("TagType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DisplayNameId");
|
||||
|
||||
b.HasIndex("SourceId");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Person", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExternalUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("NameId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NameId");
|
||||
|
||||
b.ToTable("Person");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Source", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Sources");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.TranslationEngine", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Instant>("CreatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Instant>("LastUpdatedTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TranslationEngines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NovelNovelTag", b =>
|
||||
{
|
||||
b.Property<long>("NovelsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("TagsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("NovelsId", "TagsId");
|
||||
|
||||
b.HasIndex("TagsId");
|
||||
|
||||
b.ToTable("NovelNovelTag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Images.Image", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Chapter", "Chapter")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ChapterId");
|
||||
|
||||
b.Navigation("Chapter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationRequest", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.TranslationEngine", "Engine")
|
||||
.WithMany()
|
||||
.HasForeignKey("EngineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "KeyRequestedForTranslation")
|
||||
.WithMany()
|
||||
.HasForeignKey("KeyRequestedForTranslationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Engine");
|
||||
|
||||
b.Navigation("KeyRequestedForTranslation");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationText", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", null)
|
||||
.WithMany("Texts")
|
||||
.HasForeignKey("LocalizationKeyId");
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.TranslationEngine", "TranslationEngine")
|
||||
.WithMany()
|
||||
.HasForeignKey("TranslationEngineId");
|
||||
|
||||
b.Navigation("TranslationEngine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Chapter", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "Body")
|
||||
.WithMany()
|
||||
.HasForeignKey("BodyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "Name")
|
||||
.WithMany()
|
||||
.HasForeignKey("NameId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", "Novel")
|
||||
.WithMany("Chapters")
|
||||
.HasForeignKey("NovelId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Body");
|
||||
|
||||
b.Navigation("Name");
|
||||
|
||||
b.Navigation("Novel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Person", "Author")
|
||||
.WithMany()
|
||||
.HasForeignKey("AuthorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Images.Image", "CoverImage")
|
||||
.WithMany()
|
||||
.HasForeignKey("CoverImageId");
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "Description")
|
||||
.WithMany()
|
||||
.HasForeignKey("DescriptionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "Name")
|
||||
.WithMany()
|
||||
.HasForeignKey("NameId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Source", "Source")
|
||||
.WithMany()
|
||||
.HasForeignKey("SourceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Author");
|
||||
|
||||
b.Navigation("CoverImage");
|
||||
|
||||
b.Navigation("Description");
|
||||
|
||||
b.Navigation("Name");
|
||||
|
||||
b.Navigation("Source");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.NovelTag", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "DisplayName")
|
||||
.WithMany()
|
||||
.HasForeignKey("DisplayNameId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Source", "Source")
|
||||
.WithMany()
|
||||
.HasForeignKey("SourceId");
|
||||
|
||||
b.Navigation("DisplayName");
|
||||
|
||||
b.Navigation("Source");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Person", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", "Name")
|
||||
.WithMany()
|
||||
.HasForeignKey("NameId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NovelNovelTag", b =>
|
||||
{
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("NovelsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.NovelTag", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("TagsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Localization.LocalizationKey", b =>
|
||||
{
|
||||
b.Navigation("Texts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Chapter", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||
{
|
||||
b.Navigation("Chapters");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FAmisc_NovelConstraint : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Chapter_Novels_NovelId",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.AlterColumn<long>(
|
||||
name: "NovelId",
|
||||
table: "Chapter",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L,
|
||||
oldClrType: typeof(long),
|
||||
oldType: "bigint",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Novels_ExternalId_SourceId",
|
||||
table: "Novels",
|
||||
columns: new[] { "ExternalId", "SourceId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Chapter_Novels_NovelId",
|
||||
table: "Chapter",
|
||||
column: "NovelId",
|
||||
principalTable: "Novels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Chapter_Novels_NovelId",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Novels_ExternalId_SourceId",
|
||||
table: "Novels");
|
||||
|
||||
migrationBuilder.AlterColumn<long>(
|
||||
name: "NovelId",
|
||||
table: "Chapter",
|
||||
type: "bigint",
|
||||
nullable: true,
|
||||
oldClrType: typeof(long),
|
||||
oldType: "bigint");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Chapter_Novels_NovelId",
|
||||
table: "Chapter",
|
||||
column: "NovelId",
|
||||
principalTable: "Novels",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace FictionArchive.Service.NovelService.Migrations
|
||||
b.Property<Guid>("NameId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long?>("NovelId")
|
||||
b.Property<long>("NovelId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("Order")
|
||||
@@ -234,6 +234,9 @@ namespace FictionArchive.Service.NovelService.Migrations
|
||||
|
||||
b.HasIndex("SourceId");
|
||||
|
||||
b.HasIndex("ExternalId", "SourceId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Novels");
|
||||
});
|
||||
|
||||
@@ -424,13 +427,17 @@ namespace FictionArchive.Service.NovelService.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", null)
|
||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", "Novel")
|
||||
.WithMany("Chapters")
|
||||
.HasForeignKey("NovelId");
|
||||
.HasForeignKey("NovelId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Body");
|
||||
|
||||
b.Navigation("Name");
|
||||
|
||||
b.Navigation("Novel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||
|
||||
10
FictionArchive.Service.NovelService/Models/DTOs/BaseDto.cs
Normal file
10
FictionArchive.Service.NovelService/Models/DTOs/BaseDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public abstract class BaseDto<TKey>
|
||||
{
|
||||
public TKey Id { get; init; }
|
||||
public Instant CreatedTime { get; init; }
|
||||
public Instant LastUpdatedTime { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class ChapterDto : BaseDto<uint>
|
||||
{
|
||||
public uint Revision { get; init; }
|
||||
public uint Order { get; init; }
|
||||
public string? Url { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public required string Body { get; init; }
|
||||
public required List<ImageDto> Images { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class ChapterReaderDto : BaseDto<uint>
|
||||
{
|
||||
public uint Revision { get; init; }
|
||||
public uint Order { get; init; }
|
||||
public string? Url { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public required string Body { get; init; }
|
||||
public required List<ImageDto> Images { get; init; }
|
||||
|
||||
// Navigation context
|
||||
public uint NovelId { get; init; }
|
||||
public required string NovelName { get; init; }
|
||||
public int TotalChapters { get; init; }
|
||||
public uint? PrevChapterOrder { get; init; }
|
||||
public uint? NextChapterOrder { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class ImageDto : BaseDto<Guid>
|
||||
{
|
||||
public string? NewPath { get; init; }
|
||||
}
|
||||
20
FictionArchive.Service.NovelService/Models/DTOs/NovelDto.cs
Normal file
20
FictionArchive.Service.NovelService/Models/DTOs/NovelDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.NovelService.Models.Enums;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class NovelDto : BaseDto<uint>
|
||||
{
|
||||
public required PersonDto Author { get; init; }
|
||||
public required string Url { get; init; }
|
||||
public Language RawLanguage { get; init; }
|
||||
public NovelStatus RawStatus { get; init; }
|
||||
public NovelStatus? StatusOverride { get; init; }
|
||||
public required SourceDto Source { get; init; }
|
||||
public required string ExternalId { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public required string Description { get; init; }
|
||||
public required List<ChapterDto> Chapters { get; init; }
|
||||
public required List<NovelTagDto> Tags { get; init; }
|
||||
public ImageDto? CoverImage { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using FictionArchive.Service.NovelService.Models.Enums;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class NovelTagDto : BaseDto<uint>
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string DisplayName { get; init; }
|
||||
public TagType TagType { get; init; }
|
||||
public SourceDto? Source { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class PersonDto : BaseDto<uint>
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
public string? ExternalUrl { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||
|
||||
public class SourceDto : BaseDto<uint>
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
public required string Key { get; init; }
|
||||
public required string Url { get; init; }
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using FictionArchive.Service.NovelService.Models.Images;
|
||||
using FictionArchive.Service.NovelService.Models.Localization;
|
||||
using FictionArchive.Service.Shared.Models;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Models.Novels;
|
||||
|
||||
[Table("Chapter")]
|
||||
public class Chapter : BaseEntity<uint>
|
||||
{
|
||||
public uint Revision { get; set; }
|
||||
@@ -15,4 +17,10 @@ public class Chapter : BaseEntity<uint>
|
||||
|
||||
// Images appearing in this chapter.
|
||||
public List<Image> Images { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public Novel Novel { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public class Program
|
||||
#region GraphQL
|
||||
|
||||
builder.Services.AddDefaultGraphQl<Query, Mutation>()
|
||||
.ModifyCostOptions(opt => opt.MaxFieldCost = 5000)
|
||||
.AddAuthorization();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -10,10 +10,20 @@ public class NovelServiceDbContext(DbContextOptions options, ILogger<NovelServic
|
||||
: FictionArchiveDbContext(options, logger)
|
||||
{
|
||||
public DbSet<Novel> Novels { get; set; }
|
||||
public DbSet<Chapter> Chapters { get; set; }
|
||||
public DbSet<Source> Sources { get; set; }
|
||||
public DbSet<TranslationEngine> TranslationEngines { get; set; }
|
||||
public DbSet<NovelTag> Tags { get; set; }
|
||||
public DbSet<LocalizationKey> LocalizationKeys { get; set; }
|
||||
public DbSet<LocalizationRequest> LocalizationRequests { get; set; }
|
||||
public DbSet<Image> Images { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Novel>()
|
||||
.HasIndex("ExternalId", "SourceId")
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.FileService.IntegrationEvents;
|
||||
using FictionArchive.Service.NovelService.Models.Configuration;
|
||||
using FictionArchive.Service.NovelService.Models.Enums;
|
||||
@@ -31,14 +32,241 @@ public class NovelUpdateService
|
||||
_novelUpdateServiceConfiguration = novelUpdateServiceConfiguration.Value;
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private async Task<Source> GetOrCreateSource(SourceDescriptor descriptor)
|
||||
{
|
||||
var existingSource = await _dbContext.Sources
|
||||
.FirstOrDefaultAsync(s => s.Key == descriptor.Key);
|
||||
|
||||
if (existingSource != null)
|
||||
{
|
||||
return existingSource;
|
||||
}
|
||||
|
||||
return new Source
|
||||
{
|
||||
Name = descriptor.Name,
|
||||
Url = descriptor.Url,
|
||||
Key = descriptor.Key
|
||||
};
|
||||
}
|
||||
|
||||
private Person GetOrCreateAuthor(
|
||||
string authorName,
|
||||
string? authorUrl,
|
||||
Language rawLanguage,
|
||||
Person? existingAuthor)
|
||||
{
|
||||
// Case 1: No existing author - create new
|
||||
if (existingAuthor == null)
|
||||
{
|
||||
return new Person
|
||||
{
|
||||
Name = LocalizationKey.CreateFromText(authorName, rawLanguage),
|
||||
ExternalUrl = authorUrl
|
||||
};
|
||||
}
|
||||
|
||||
// Case 2: ExternalUrl differs - create new Person
|
||||
if (existingAuthor.ExternalUrl != authorUrl)
|
||||
{
|
||||
return new Person
|
||||
{
|
||||
Name = LocalizationKey.CreateFromText(authorName, rawLanguage),
|
||||
ExternalUrl = authorUrl
|
||||
};
|
||||
}
|
||||
|
||||
// Case 3: Same URL - update name if different
|
||||
UpdateLocalizationKey(existingAuthor.Name, authorName, rawLanguage);
|
||||
return existingAuthor;
|
||||
}
|
||||
|
||||
private static void UpdateLocalizationKey(LocalizationKey key, string newText, Language language)
|
||||
{
|
||||
var existingText = key.Texts.FirstOrDefault(t => t.Language == language);
|
||||
if (existingText != null)
|
||||
{
|
||||
existingText.Text = newText;
|
||||
}
|
||||
else
|
||||
{
|
||||
key.Texts.Add(new LocalizationText
|
||||
{
|
||||
Language = language,
|
||||
Text = newText
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNovelMetadata(Novel novel, NovelMetadata metadata)
|
||||
{
|
||||
UpdateLocalizationKey(novel.Name, metadata.Name, metadata.RawLanguage);
|
||||
UpdateLocalizationKey(novel.Description, metadata.Description, metadata.RawLanguage);
|
||||
novel.RawStatus = metadata.RawStatus;
|
||||
novel.Url = metadata.Url;
|
||||
}
|
||||
|
||||
private async Task<List<NovelTag>> SynchronizeTags(
|
||||
List<string> sourceTags,
|
||||
List<string> systemTags,
|
||||
Language rawLanguage)
|
||||
{
|
||||
var allTagKeys = sourceTags.Concat(systemTags).ToHashSet();
|
||||
|
||||
// Query existing tags from DB by Key
|
||||
var existingTagsInDb = await _dbContext.Tags
|
||||
.Where(t => allTagKeys.Contains(t.Key))
|
||||
.ToListAsync();
|
||||
|
||||
var existingTagKeyMap = existingTagsInDb.ToDictionary(t => t.Key);
|
||||
var result = new List<NovelTag>();
|
||||
|
||||
// Process source tags
|
||||
foreach (var tagKey in sourceTags)
|
||||
{
|
||||
if (existingTagKeyMap.TryGetValue(tagKey, out var existingTag))
|
||||
{
|
||||
result.Add(existingTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(new NovelTag
|
||||
{
|
||||
Key = tagKey,
|
||||
DisplayName = LocalizationKey.CreateFromText(tagKey, rawLanguage),
|
||||
TagType = TagType.External
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Process system tags
|
||||
foreach (var tagKey in systemTags)
|
||||
{
|
||||
if (existingTagKeyMap.TryGetValue(tagKey, out var existingTag))
|
||||
{
|
||||
result.Add(existingTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(new NovelTag
|
||||
{
|
||||
Key = tagKey,
|
||||
DisplayName = LocalizationKey.CreateFromText(tagKey, rawLanguage),
|
||||
TagType = TagType.System
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<Chapter> SynchronizeChapters(
|
||||
List<ChapterMetadata> metadataChapters,
|
||||
Language rawLanguage,
|
||||
List<Chapter>? existingChapters)
|
||||
{
|
||||
existingChapters ??= new List<Chapter>();
|
||||
var existingOrderSet = existingChapters.Select(c => c.Order).ToHashSet();
|
||||
|
||||
// Only add chapters that don't already exist (by Order)
|
||||
var newChapters = metadataChapters
|
||||
.Where(mc => !existingOrderSet.Contains(mc.Order))
|
||||
.Select(mc => new Chapter
|
||||
{
|
||||
Order = mc.Order,
|
||||
Url = mc.Url,
|
||||
Revision = mc.Revision,
|
||||
Name = LocalizationKey.CreateFromText(mc.Name, rawLanguage),
|
||||
Body = new LocalizationKey
|
||||
{
|
||||
Texts = new List<LocalizationText>()
|
||||
}
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// Combine existing chapters with new ones
|
||||
return existingChapters.Concat(newChapters).ToList();
|
||||
}
|
||||
|
||||
private static (Image? image, bool shouldPublishEvent) HandleCoverImage(
|
||||
ImageData? newCoverData,
|
||||
Image? existingCoverImage)
|
||||
{
|
||||
// Case 1: No new cover image - keep existing or null
|
||||
if (newCoverData == null)
|
||||
{
|
||||
return (existingCoverImage, false);
|
||||
}
|
||||
|
||||
// Case 2: New cover, no existing
|
||||
if (existingCoverImage == null)
|
||||
{
|
||||
var newImage = new Image { OriginalPath = newCoverData.Url };
|
||||
return (newImage, true);
|
||||
}
|
||||
|
||||
// Case 3: Both exist - check if URL changed
|
||||
if (existingCoverImage.OriginalPath != newCoverData.Url)
|
||||
{
|
||||
existingCoverImage.OriginalPath = newCoverData.Url;
|
||||
existingCoverImage.NewPath = null; // Reset uploaded path
|
||||
return (existingCoverImage, true);
|
||||
}
|
||||
|
||||
// Case 4: Same cover URL - no change needed
|
||||
return (existingCoverImage, false);
|
||||
}
|
||||
|
||||
private async Task<Novel> CreateNewNovel(NovelMetadata metadata, Source source)
|
||||
{
|
||||
var author = new Person
|
||||
{
|
||||
Name = LocalizationKey.CreateFromText(metadata.AuthorName, metadata.RawLanguage),
|
||||
ExternalUrl = metadata.AuthorUrl
|
||||
};
|
||||
|
||||
var tags = await SynchronizeTags(
|
||||
metadata.SourceTags,
|
||||
metadata.SystemTags,
|
||||
metadata.RawLanguage);
|
||||
|
||||
var chapters = SynchronizeChapters(metadata.Chapters, metadata.RawLanguage, null);
|
||||
|
||||
var novel = new Novel
|
||||
{
|
||||
Author = author,
|
||||
RawLanguage = metadata.RawLanguage,
|
||||
Url = metadata.Url,
|
||||
ExternalId = metadata.ExternalId,
|
||||
CoverImage = metadata.CoverImage != null
|
||||
? new Image { OriginalPath = metadata.CoverImage.Url }
|
||||
: null,
|
||||
Chapters = chapters,
|
||||
Description = LocalizationKey.CreateFromText(metadata.Description, metadata.RawLanguage),
|
||||
Name = LocalizationKey.CreateFromText(metadata.Name, metadata.RawLanguage),
|
||||
RawStatus = metadata.RawStatus,
|
||||
Tags = tags,
|
||||
Source = source
|
||||
};
|
||||
|
||||
_dbContext.Novels.Add(novel);
|
||||
return novel;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task<Novel> ImportNovel(string novelUrl)
|
||||
{
|
||||
// Step 1: Get metadata from source adapter
|
||||
NovelMetadata? metadata = null;
|
||||
foreach (ISourceAdapter sourceAdapter in _sourceAdapters)
|
||||
{
|
||||
if (await sourceAdapter.CanProcessNovel(novelUrl))
|
||||
{
|
||||
metadata = await sourceAdapter.GetMetadata(novelUrl);
|
||||
break; // Stop after finding adapter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,72 +275,82 @@ public class NovelUpdateService
|
||||
throw new NotSupportedException("The provided novel url is currently unsupported.");
|
||||
}
|
||||
|
||||
var systemTags = metadata.SystemTags.Select(tag => new NovelTag()
|
||||
{
|
||||
Key = tag,
|
||||
DisplayName = LocalizationKey.CreateFromText(tag, metadata.RawLanguage),
|
||||
TagType = TagType.System
|
||||
});
|
||||
var sourceTags = metadata.SourceTags.Select(tag => new NovelTag()
|
||||
{
|
||||
Key = tag,
|
||||
DisplayName = LocalizationKey.CreateFromText(tag, metadata.RawLanguage),
|
||||
TagType = TagType.External
|
||||
});
|
||||
// Step 2: Resolve or create Source
|
||||
var source = await GetOrCreateSource(metadata.SourceDescriptor);
|
||||
|
||||
var addedNovel = _dbContext.Novels.Add(new Novel()
|
||||
// Step 3: Check for existing novel by ExternalId + Source.Key
|
||||
var existingNovel = await _dbContext.Novels
|
||||
.Include(n => n.Author)
|
||||
.ThenInclude(a => a.Name)
|
||||
.ThenInclude(lk => lk.Texts)
|
||||
.Include(n => n.Source)
|
||||
.Include(n => n.Name)
|
||||
.ThenInclude(lk => lk.Texts)
|
||||
.Include(n => n.Description)
|
||||
.ThenInclude(lk => lk.Texts)
|
||||
.Include(n => n.Tags)
|
||||
.Include(n => n.Chapters)
|
||||
.Include(n => n.CoverImage)
|
||||
.FirstOrDefaultAsync(n =>
|
||||
n.ExternalId == metadata.ExternalId &&
|
||||
n.Source.Key == metadata.SourceDescriptor.Key);
|
||||
|
||||
Novel novel;
|
||||
bool shouldPublishCoverEvent;
|
||||
|
||||
if (existingNovel == null)
|
||||
{
|
||||
Author = new Person()
|
||||
{
|
||||
Name = LocalizationKey.CreateFromText(metadata.AuthorName, metadata.RawLanguage),
|
||||
ExternalUrl = metadata.AuthorUrl,
|
||||
},
|
||||
RawLanguage = metadata.RawLanguage,
|
||||
Url = metadata.Url,
|
||||
ExternalId = metadata.ExternalId,
|
||||
CoverImage = metadata.CoverImage != null ? new Image()
|
||||
{
|
||||
OriginalPath = metadata.CoverImage.Url,
|
||||
} : null,
|
||||
Chapters = metadata.Chapters.Select(chapter =>
|
||||
{
|
||||
return new Chapter()
|
||||
{
|
||||
Order = chapter.Order,
|
||||
Url = chapter.Url,
|
||||
Revision = chapter.Revision,
|
||||
Name = LocalizationKey.CreateFromText(chapter.Name, metadata.RawLanguage),
|
||||
Body = new LocalizationKey()
|
||||
{
|
||||
Texts = new List<LocalizationText>()
|
||||
}
|
||||
};
|
||||
}).ToList(),
|
||||
Description = LocalizationKey.CreateFromText(metadata.Description, metadata.RawLanguage),
|
||||
Name = LocalizationKey.CreateFromText(metadata.Name, metadata.RawLanguage),
|
||||
RawStatus = metadata.RawStatus,
|
||||
Tags = sourceTags.Concat(systemTags).ToList(),
|
||||
Source = new Source()
|
||||
{
|
||||
Name = metadata.SourceDescriptor.Name,
|
||||
Url = metadata.SourceDescriptor.Url,
|
||||
Key = metadata.SourceDescriptor.Key,
|
||||
}
|
||||
});
|
||||
// CREATE PATH: New novel
|
||||
novel = await CreateNewNovel(metadata, source);
|
||||
shouldPublishCoverEvent = novel.CoverImage != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// UPDATE PATH: Existing novel
|
||||
novel = existingNovel;
|
||||
|
||||
// Update author
|
||||
novel.Author = GetOrCreateAuthor(
|
||||
metadata.AuthorName,
|
||||
metadata.AuthorUrl,
|
||||
metadata.RawLanguage,
|
||||
existingNovel.Author);
|
||||
|
||||
// Update metadata (Name, Description, RawStatus)
|
||||
UpdateNovelMetadata(novel, metadata);
|
||||
|
||||
// Synchronize tags (remove old, add new, reuse existing)
|
||||
novel.Tags = await SynchronizeTags(
|
||||
metadata.SourceTags,
|
||||
metadata.SystemTags,
|
||||
metadata.RawLanguage);
|
||||
|
||||
// Synchronize chapters (add only)
|
||||
novel.Chapters = SynchronizeChapters(
|
||||
metadata.Chapters,
|
||||
metadata.RawLanguage,
|
||||
existingNovel.Chapters);
|
||||
|
||||
// Handle cover image
|
||||
(novel.CoverImage, shouldPublishCoverEvent) = HandleCoverImage(
|
||||
metadata.CoverImage,
|
||||
existingNovel.CoverImage);
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// Signal request for cover image if present
|
||||
if (addedNovel.Entity.CoverImage != null)
|
||||
// Publish cover image event if needed
|
||||
if (shouldPublishCoverEvent && novel.CoverImage != null && metadata.CoverImage != null)
|
||||
{
|
||||
await _eventBus.Publish(new FileUploadRequestCreatedEvent()
|
||||
await _eventBus.Publish(new FileUploadRequestCreatedEvent
|
||||
{
|
||||
RequestId = addedNovel.Entity.CoverImage.Id,
|
||||
RequestId = novel.CoverImage.Id,
|
||||
FileData = metadata.CoverImage.Data,
|
||||
FilePath = $"Novels/{addedNovel.Entity.Id}/Images/cover.jpg"
|
||||
FilePath = $"Novels/{novel.Id}/Images/cover.jpg"
|
||||
});
|
||||
}
|
||||
|
||||
return addedNovel.Entity;
|
||||
return novel;
|
||||
}
|
||||
|
||||
public async Task<Chapter> PullChapterContents(uint novelId, uint chapterNumber)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using FictionArchive.Service.TranslationService.Models;
|
||||
using FictionArchive.Service.TranslationService.Models.Database;
|
||||
using FictionArchive.Service.TranslationService.Models.DTOs;
|
||||
using FictionArchive.Service.TranslationService.Services.Database;
|
||||
using FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
||||
using HotChocolate.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HotChocolate.Data;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.GraphQL;
|
||||
|
||||
@@ -22,8 +22,20 @@ public class Query
|
||||
[UseProjection]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
public IQueryable<TranslationRequest> GetTranslationRequests(TranslationServiceDbContext dbContext)
|
||||
public IQueryable<TranslationRequestDto> GetTranslationRequests(TranslationServiceDbContext dbContext)
|
||||
{
|
||||
return dbContext.TranslationRequests.AsQueryable();
|
||||
return dbContext.TranslationRequests.Select(request => new TranslationRequestDto
|
||||
{
|
||||
Id = request.Id,
|
||||
CreatedTime = request.CreatedTime,
|
||||
LastUpdatedTime = request.LastUpdatedTime,
|
||||
OriginalText = request.OriginalText,
|
||||
TranslatedText = request.TranslatedText,
|
||||
From = request.From,
|
||||
To = request.To,
|
||||
TranslationEngineKey = request.TranslationEngineKey,
|
||||
Status = request.Status,
|
||||
BilledCharacterCount = request.BilledCharacterCount
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.TranslationService.Models.Enums;
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Models.DTOs;
|
||||
|
||||
public class TranslationRequestDto
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public Instant CreatedTime { get; init; }
|
||||
public Instant LastUpdatedTime { get; init; }
|
||||
public required string OriginalText { get; init; }
|
||||
public string? TranslatedText { get; init; }
|
||||
public Language From { get; init; }
|
||||
public Language To { get; init; }
|
||||
public required string TranslationEngineKey { get; init; }
|
||||
public TranslationRequestStatus Status { get; init; }
|
||||
public uint BilledCharacterCount { get; init; }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using FictionArchive.Service.Shared.Constants;
|
||||
using FictionArchive.Service.UserService.Models.Database;
|
||||
using FictionArchive.Service.UserService.Models.DTOs;
|
||||
using FictionArchive.Service.UserService.Services;
|
||||
using HotChocolate.Authorization;
|
||||
|
||||
@@ -8,9 +8,31 @@ namespace FictionArchive.Service.UserService.GraphQL;
|
||||
public class Mutation
|
||||
{
|
||||
[Authorize(Roles = [AuthorizationConstants.Roles.Admin])]
|
||||
public async Task<User> RegisterUser(string username, string email, string oAuthProviderId,
|
||||
public async Task<UserDto> RegisterUser(string username, string email, string oAuthProviderId,
|
||||
string? inviterOAuthProviderId, UserManagementService userManagementService)
|
||||
{
|
||||
return await userManagementService.RegisterUser(username, email, oAuthProviderId, inviterOAuthProviderId);
|
||||
var user = await userManagementService.RegisterUser(username, email, oAuthProviderId, inviterOAuthProviderId);
|
||||
|
||||
return new UserDto
|
||||
{
|
||||
Id = user.Id,
|
||||
CreatedTime = user.CreatedTime,
|
||||
LastUpdatedTime = user.LastUpdatedTime,
|
||||
Username = user.Username,
|
||||
Email = user.Email,
|
||||
Disabled = user.Disabled,
|
||||
Inviter = user.Inviter != null
|
||||
? new UserDto
|
||||
{
|
||||
Id = user.Inviter.Id,
|
||||
CreatedTime = user.Inviter.CreatedTime,
|
||||
LastUpdatedTime = user.Inviter.LastUpdatedTime,
|
||||
Username = user.Inviter.Username,
|
||||
Email = user.Inviter.Email,
|
||||
Disabled = user.Inviter.Disabled,
|
||||
Inviter = null // Limit recursion to one level
|
||||
}
|
||||
: null
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using FictionArchive.Service.UserService.Models.Database;
|
||||
using FictionArchive.Service.UserService.Models.DTOs;
|
||||
using FictionArchive.Service.UserService.Services;
|
||||
using HotChocolate.Authorization;
|
||||
|
||||
@@ -7,8 +7,28 @@ namespace FictionArchive.Service.UserService.GraphQL;
|
||||
public class Query
|
||||
{
|
||||
[Authorize]
|
||||
public async Task<IQueryable<User>> GetUsers(UserManagementService userManagementService)
|
||||
public IQueryable<UserDto> GetUsers(UserManagementService userManagementService)
|
||||
{
|
||||
return userManagementService.GetUsers();
|
||||
return userManagementService.GetUsers().Select(user => new UserDto
|
||||
{
|
||||
Id = user.Id,
|
||||
CreatedTime = user.CreatedTime,
|
||||
LastUpdatedTime = user.LastUpdatedTime,
|
||||
Username = user.Username,
|
||||
Email = user.Email,
|
||||
Disabled = user.Disabled,
|
||||
Inviter = user.Inviter != null
|
||||
? new UserDto
|
||||
{
|
||||
Id = user.Inviter.Id,
|
||||
CreatedTime = user.Inviter.CreatedTime,
|
||||
LastUpdatedTime = user.Inviter.LastUpdatedTime,
|
||||
Username = user.Inviter.Username,
|
||||
Email = user.Inviter.Email,
|
||||
Disabled = user.Inviter.Disabled,
|
||||
Inviter = null // Limit recursion to one level
|
||||
}
|
||||
: null
|
||||
});
|
||||
}
|
||||
}
|
||||
15
FictionArchive.Service.UserService/Models/DTOs/UserDto.cs
Normal file
15
FictionArchive.Service.UserService/Models/DTOs/UserDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.UserService.Models.DTOs;
|
||||
|
||||
public class UserDto
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public Instant CreatedTime { get; init; }
|
||||
public Instant LastUpdatedTime { get; init; }
|
||||
public required string Username { get; init; }
|
||||
public required string Email { get; init; }
|
||||
// OAuthProviderId intentionally omitted for security
|
||||
public bool Disabled { get; init; }
|
||||
public UserDto? Inviter { get; init; }
|
||||
}
|
||||
530
fictionarchive-web-astro/package-lock.json
generated
530
fictionarchive-web-astro/package-lock.json
generated
@@ -19,6 +19,7 @@
|
||||
"date-fns": "^4.1.0",
|
||||
"dompurify": "^3.3.0",
|
||||
"graphql": "^16.12.0",
|
||||
"isomorphic-dompurify": "^2.33.0",
|
||||
"oidc-client-ts": "^3.4.1",
|
||||
"svelte": "^5.45.2",
|
||||
"tailwind-merge": "^3.4.0",
|
||||
@@ -59,6 +60,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@acemir/cssom": {
|
||||
"version": "0.9.28",
|
||||
"resolved": "https://registry.npmjs.org/@acemir/cssom/-/cssom-0.9.28.tgz",
|
||||
"integrity": "sha512-LuS6IVEivI75vKN8S04qRD+YySP0RmU/cV8UNukhQZvprxF+76Z43TNo/a08eCodaGhT1Us8etqS1ZRY9/Or0A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@ardatan/relay-compiler": {
|
||||
"version": "12.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@ardatan/relay-compiler/-/relay-compiler-12.0.3.tgz",
|
||||
@@ -84,6 +91,56 @@
|
||||
"graphql": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@asamuzakjp/css-color": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-4.1.0.tgz",
|
||||
"integrity": "sha512-9xiBAtLn4aNsa4mDnpovJvBn72tNEIACyvlqaNJ+ADemR+yeMJWnBudOi2qGDviJa7SwcDOU/TRh5dnET7qk0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@csstools/css-calc": "^2.1.4",
|
||||
"@csstools/css-color-parser": "^3.1.0",
|
||||
"@csstools/css-parser-algorithms": "^3.0.5",
|
||||
"@csstools/css-tokenizer": "^3.0.4",
|
||||
"lru-cache": "^11.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@asamuzakjp/css-color/node_modules/lru-cache": {
|
||||
"version": "11.2.4",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.4.tgz",
|
||||
"integrity": "sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@asamuzakjp/dom-selector": {
|
||||
"version": "6.7.6",
|
||||
"resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-6.7.6.tgz",
|
||||
"integrity": "sha512-hBaJER6A9MpdG3WgdlOolHmbOYvSk46y7IQN/1+iqiCuUu6iWdQrs9DGKF8ocqsEqWujWf/V7b7vaDgiUmIvUg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@asamuzakjp/nwsapi": "^2.3.9",
|
||||
"bidi-js": "^1.0.3",
|
||||
"css-tree": "^3.1.0",
|
||||
"is-potential-custom-element-name": "^1.0.1",
|
||||
"lru-cache": "^11.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@asamuzakjp/dom-selector/node_modules/lru-cache": {
|
||||
"version": "11.2.4",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.4.tgz",
|
||||
"integrity": "sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@asamuzakjp/nwsapi": {
|
||||
"version": "2.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@asamuzakjp/nwsapi/-/nwsapi-2.3.9.tgz",
|
||||
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@astrojs/compiler": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz",
|
||||
@@ -474,6 +531,140 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/color-helpers": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz",
|
||||
"integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT-0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/css-calc": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz",
|
||||
"integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@csstools/css-parser-algorithms": "^3.0.5",
|
||||
"@csstools/css-tokenizer": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/css-color-parser": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz",
|
||||
"integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@csstools/color-helpers": "^5.1.0",
|
||||
"@csstools/css-calc": "^2.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@csstools/css-parser-algorithms": "^3.0.5",
|
||||
"@csstools/css-tokenizer": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/css-parser-algorithms": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz",
|
||||
"integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@csstools/css-tokenizer": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/css-syntax-patches-for-csstree": {
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.0.14.tgz",
|
||||
"integrity": "sha512-zSlIxa20WvMojjpCSy8WrNpcZ61RqfTfX3XTaOeVlGJrt/8HF3YbzgFZa01yTbT4GWQLwfTcC3EB8i3XnB647Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT-0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@csstools/css-tokenizer": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz",
|
||||
"integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/csstools"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/csstools"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
|
||||
@@ -4207,6 +4398,15 @@
|
||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "7.1.4",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
|
||||
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
@@ -4663,6 +4863,15 @@
|
||||
"baseline-browser-mapping": "dist/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/bidi-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz",
|
||||
"integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"require-from-string": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/bits-ui": {
|
||||
"version": "2.14.4",
|
||||
"resolved": "https://registry.npmjs.org/bits-ui/-/bits-ui-2.14.4.tgz",
|
||||
@@ -5491,6 +5700,20 @@
|
||||
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==",
|
||||
"license": "CC0-1.0"
|
||||
},
|
||||
"node_modules/cssstyle": {
|
||||
"version": "5.3.4",
|
||||
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-5.3.4.tgz",
|
||||
"integrity": "sha512-KyOS/kJMEq5O9GdPnaf82noigg5X5DYn0kZPJTaAsCUaBizp6Xa1y9D4Qoqf/JazEXWuruErHgVXwjN5391ZJw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@asamuzakjp/css-color": "^4.1.0",
|
||||
"@csstools/css-syntax-patches-for-csstree": "1.0.14",
|
||||
"css-tree": "^3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
@@ -5501,6 +5724,53 @@
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-6.0.0.tgz",
|
||||
"integrity": "sha512-BnBS08aLUM+DKamupXs3w2tJJoqU+AkaE/+6vQxi/G/DPmIZFJJp9Dkb1kM03AZx8ADehDUZgsNxju3mPXZYIA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-mimetype": "^4.0.0",
|
||||
"whatwg-url": "^15.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls/node_modules/tr46": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz",
|
||||
"integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls/node_modules/webidl-conversions": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.0.tgz",
|
||||
"integrity": "sha512-n4W4YFyz5JzOfQeA8oN7dUYpR+MBP3PIUsn2jLjWXwK5ASUzt0Jc/A5sAUZoCYFJRGF0FBKJ+1JjN43rNdsQzA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls/node_modules/whatwg-url": {
|
||||
"version": "15.1.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-15.1.0.tgz",
|
||||
"integrity": "sha512-2ytDk0kiEj/yu90JOAp44PVPUkO9+jVhyf+SybKlRHSDlvOOZhdPIrr7xTH64l4WixO2cP+wQIcgujkGBPPz6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "^6.0.0",
|
||||
"webidl-conversions": "^8.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/dataloader": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.3.tgz",
|
||||
@@ -5548,6 +5818,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decimal.js": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
|
||||
"integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/decode-named-character-reference": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz",
|
||||
@@ -7205,6 +7481,18 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/html-encoding-sniffer": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz",
|
||||
"integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-encoding": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/html-escaper": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
||||
@@ -7247,6 +7535,32 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
|
||||
"integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.1.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
||||
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.1.2",
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
||||
@@ -7501,6 +7815,12 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/is-potential-custom-element-name": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-reference": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
||||
@@ -7591,6 +7911,19 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/isomorphic-dompurify": {
|
||||
"version": "2.33.0",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-dompurify/-/isomorphic-dompurify-2.33.0.tgz",
|
||||
"integrity": "sha512-pXGR3rAHAXb5Bvr56pc5aV0Lh8laubLo7/60F+soOzDFmwks6MtgDhL7p46VoxLnwgIsjgmVhQpUt4mUlL/XEw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dompurify": "^3.3.0",
|
||||
"jsdom": "^27.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.5"
|
||||
}
|
||||
},
|
||||
"node_modules/isomorphic-ws": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz",
|
||||
@@ -7645,6 +7978,91 @@
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom": {
|
||||
"version": "27.3.0",
|
||||
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-27.3.0.tgz",
|
||||
"integrity": "sha512-GtldT42B8+jefDUC4yUKAvsaOrH7PDHmZxZXNgF2xMmymjUbRYJvpAybZAKEmXDGTM0mCsz8duOa4vTm5AY2Kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@acemir/cssom": "^0.9.28",
|
||||
"@asamuzakjp/dom-selector": "^6.7.6",
|
||||
"cssstyle": "^5.3.4",
|
||||
"data-urls": "^6.0.0",
|
||||
"decimal.js": "^10.6.0",
|
||||
"html-encoding-sniffer": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"is-potential-custom-element-name": "^1.0.1",
|
||||
"parse5": "^8.0.0",
|
||||
"saxes": "^6.0.0",
|
||||
"symbol-tree": "^3.2.4",
|
||||
"tough-cookie": "^6.0.0",
|
||||
"w3c-xmlserializer": "^5.0.0",
|
||||
"webidl-conversions": "^8.0.0",
|
||||
"whatwg-encoding": "^3.1.1",
|
||||
"whatwg-mimetype": "^4.0.0",
|
||||
"whatwg-url": "^15.1.0",
|
||||
"ws": "^8.18.3",
|
||||
"xml-name-validator": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"canvas": "^3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"canvas": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/parse5": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz",
|
||||
"integrity": "sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"entities": "^6.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/tr46": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz",
|
||||
"integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/webidl-conversions": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.0.tgz",
|
||||
"integrity": "sha512-n4W4YFyz5JzOfQeA8oN7dUYpR+MBP3PIUsn2jLjWXwK5ASUzt0Jc/A5sAUZoCYFJRGF0FBKJ+1JjN43rNdsQzA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/whatwg-url": {
|
||||
"version": "15.1.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-15.1.0.tgz",
|
||||
"integrity": "sha512-2ytDk0kiEj/yu90JOAp44PVPUkO9+jVhyf+SybKlRHSDlvOOZhdPIrr7xTH64l4WixO2cP+wQIcgujkGBPPz6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "^6.0.0",
|
||||
"webidl-conversions": "^8.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/jsesc": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
|
||||
@@ -9940,7 +10358,6 @@
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -10207,6 +10624,15 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve-from": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
|
||||
@@ -10414,7 +10840,6 @@
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sax": {
|
||||
@@ -10423,6 +10848,18 @@
|
||||
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/saxes": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
|
||||
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"xmlchars": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v12.22.7"
|
||||
}
|
||||
},
|
||||
"node_modules/scule": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz",
|
||||
@@ -10945,6 +11382,12 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sync-fetch": {
|
||||
"version": "0.6.0-2",
|
||||
"resolved": "https://registry.npmjs.org/sync-fetch/-/sync-fetch-0.6.0-2.tgz",
|
||||
@@ -11104,6 +11547,24 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/tldts": {
|
||||
"version": "7.0.19",
|
||||
"resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.19.tgz",
|
||||
"integrity": "sha512-8PWx8tvC4jDB39BQw1m4x8y5MH1BcQ5xHeL2n7UVFulMPH/3Q0uiamahFJ3lXA0zO2SUyRXuVVbWSDmstlt9YA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tldts-core": "^7.0.19"
|
||||
},
|
||||
"bin": {
|
||||
"tldts": "bin/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tldts-core": {
|
||||
"version": "7.0.19",
|
||||
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.19.tgz",
|
||||
"integrity": "sha512-lJX2dEWx0SGH4O6p+7FPwYmJ/bu1JbcGJ8RLaG9b7liIgZ85itUVEPbMtWRVrde/0fnDPEPHW10ZsKW3kVsE9A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
@@ -11126,6 +11587,18 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/tough-cookie": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.0.tgz",
|
||||
"integrity": "sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"tldts": "^7.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
@@ -11832,6 +12305,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-xmlserializer": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
|
||||
"integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xml-name-validator": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/web-namespaces": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
|
||||
@@ -11859,11 +12344,34 @@
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/whatwg-encoding": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",
|
||||
"integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iconv-lite": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-encoding/node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-mimetype": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
|
||||
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
@@ -12010,7 +12518,6 @@
|
||||
"version": "8.18.3",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
||||
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
@@ -12029,6 +12536,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xml-name-validator": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",
|
||||
"integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/xmlchars": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xxhash-wasm": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"date-fns": "^4.1.0",
|
||||
"dompurify": "^3.3.0",
|
||||
"graphql": "^16.12.0",
|
||||
"isomorphic-dompurify": "^2.33.0",
|
||||
"oidc-client-ts": "^3.4.1",
|
||||
"svelte": "^5.45.2",
|
||||
"tailwind-merge": "^3.4.0",
|
||||
|
||||
38
fictionarchive-web-astro/src/layouts/GatedLayout.astro
Normal file
38
fictionarchive-web-astro/src/layouts/GatedLayout.astro
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
import AuthInit from '../lib/components/AuthInit.svelte';
|
||||
import GatedAuthDisplay from '../lib/components/GatedAuthDisplay.svelte';
|
||||
import '../styles/global.css';
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
}
|
||||
|
||||
const { title = 'FictionArchive' } = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body class="min-h-screen bg-background">
|
||||
<AuthInit client:load />
|
||||
<header class="border-b bg-white/80 backdrop-blur dark:bg-gray-900/80">
|
||||
<nav class="mx-auto flex max-w-6xl items-center gap-4 px-4 py-3 sm:px-6 lg:px-8">
|
||||
<a href="/" class="flex items-center gap-2">
|
||||
<span class="rounded bg-primary px-2 py-1 font-bold text-primary-foreground">FA</span>
|
||||
<span class="font-semibold">FictionArchive</span>
|
||||
</a>
|
||||
<div class="flex-1"></div>
|
||||
<GatedAuthDisplay client:load />
|
||||
</nav>
|
||||
</header>
|
||||
<main class="mx-auto flex max-w-6xl flex-col gap-6 px-4 py-8 sm:px-6 lg:px-8">
|
||||
<slot />
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -52,6 +52,10 @@ export async function initAuth() {
|
||||
user.set(result ?? null);
|
||||
if (result) {
|
||||
setCookieFromUser(result);
|
||||
// Reload to let server see the new cookie
|
||||
const cleanUrl = `${url.origin}${url.pathname}`;
|
||||
window.location.href = cleanUrl;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to complete sign-in redirect', e);
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
let isOpen = $state(false);
|
||||
|
||||
const email = $derived(
|
||||
$user?.profile?.email ??
|
||||
const name = $derived(
|
||||
$user?.profile?.name ??
|
||||
$user?.profile?.preferred_username ??
|
||||
$user?.profile?.name ??
|
||||
$user?.profile?.email ??
|
||||
$user?.profile?.sub ??
|
||||
'User'
|
||||
);
|
||||
@@ -38,7 +38,7 @@
|
||||
{:else if $user}
|
||||
<div class="auth-dropdown relative">
|
||||
<Button variant="outline" onclick={toggleDropdown}>
|
||||
{email}
|
||||
{name}
|
||||
</Button>
|
||||
{#if isOpen}
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import ChevronLeft from '@lucide/svelte/icons/chevron-left';
|
||||
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||
import List from '@lucide/svelte/icons/list';
|
||||
|
||||
interface Props {
|
||||
novelId: string;
|
||||
prevChapterOrder: number | null | undefined;
|
||||
nextChapterOrder: number | null | undefined;
|
||||
showKeyboardHints?: boolean;
|
||||
}
|
||||
|
||||
let { novelId, prevChapterOrder, nextChapterOrder, showKeyboardHints = true }: Props = $props();
|
||||
|
||||
const hasPrev = $derived(prevChapterOrder != null);
|
||||
const hasNext = $derived(nextChapterOrder != null);
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
href={hasPrev ? `/novels/${novelId}/chapters/${prevChapterOrder}` : undefined}
|
||||
disabled={!hasPrev}
|
||||
class="gap-2"
|
||||
>
|
||||
<ChevronLeft class="h-4 w-4" />
|
||||
<span class="hidden sm:inline">Previous</span>
|
||||
</Button>
|
||||
|
||||
<Button variant="outline" href="/novels/{novelId}" class="gap-2">
|
||||
<List class="h-4 w-4" />
|
||||
<span class="hidden sm:inline">Contents</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
href={hasNext ? `/novels/${novelId}/chapters/${nextChapterOrder}` : undefined}
|
||||
disabled={!hasNext}
|
||||
class="gap-2"
|
||||
>
|
||||
<span class="hidden sm:inline">Next</span>
|
||||
<ChevronRight class="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{#if showKeyboardHints}
|
||||
<p class="text-muted-foreground hidden text-center text-xs md:block">
|
||||
Use <kbd class="bg-muted rounded px-1 py-0.5 text-xs">←</kbd> and
|
||||
<kbd class="bg-muted rounded px-1 py-0.5 text-xs">→</kbd> arrow keys to navigate
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
progress: number;
|
||||
}
|
||||
|
||||
let { progress }: Props = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="fixed top-0 left-0 right-0 z-50 h-1 bg-muted"
|
||||
role="progressbar"
|
||||
aria-valuenow={Math.round(progress)}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-label="Reading progress"
|
||||
>
|
||||
<div
|
||||
class="h-full bg-primary transition-[width] duration-150 ease-out"
|
||||
style="width: {progress}%"
|
||||
></div>
|
||||
</div>
|
||||
@@ -0,0 +1,183 @@
|
||||
<script lang="ts" module>
|
||||
import type { GetChapterQuery } from '$lib/graphql/__generated__/graphql';
|
||||
|
||||
export type ChapterData = NonNullable<GetChapterQuery['chapter']>;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { client } from '$lib/graphql/client';
|
||||
import { GetChapterDocument } from '$lib/graphql/__generated__/graphql';
|
||||
import { Card, CardContent } from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import ChapterNavigation from './ChapterNavigation.svelte';
|
||||
import ChapterProgressBar from './ChapterProgressBar.svelte';
|
||||
import { sanitizeChapterHtml } from '$lib/utils/sanitizeChapter';
|
||||
import ArrowLeft from '@lucide/svelte/icons/arrow-left';
|
||||
|
||||
interface Props {
|
||||
novelId?: string;
|
||||
chapterNumber?: string;
|
||||
}
|
||||
|
||||
let { novelId, chapterNumber }: Props = $props();
|
||||
|
||||
// State
|
||||
let chapter: ChapterData | null = $state(null);
|
||||
let fetching = $state(true);
|
||||
let error: string | null = $state(null);
|
||||
let scrollProgress = $state(0);
|
||||
|
||||
// Derived values
|
||||
const sanitizedBody = $derived(chapter?.body ? sanitizeChapterHtml(chapter.body) : '');
|
||||
|
||||
function handleScroll() {
|
||||
const scrollTop = window.scrollY;
|
||||
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
|
||||
scrollProgress = docHeight > 0 ? Math.min(100, (scrollTop / docHeight) * 100) : 0;
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
// Don't trigger if user is typing in an input
|
||||
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === 'ArrowLeft' && chapter?.prevChapterOrder != null) {
|
||||
window.location.href = `/novels/${novelId}/chapters/${chapter.prevChapterOrder}`;
|
||||
} else if (event.key === 'ArrowRight' && chapter?.nextChapterOrder != null) {
|
||||
window.location.href = `/novels/${novelId}/chapters/${chapter.nextChapterOrder}`;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchChapter() {
|
||||
if (!novelId || !chapterNumber) {
|
||||
error = 'Missing novel ID or chapter number';
|
||||
fetching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fetching = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const result = await client
|
||||
.query(GetChapterDocument, {
|
||||
novelId: parseInt(novelId, 10),
|
||||
chapterOrder: parseInt(chapterNumber, 10)
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
if (result.error) {
|
||||
error = result.error.message;
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.data?.chapter) {
|
||||
chapter = result.data.chapter;
|
||||
} else {
|
||||
error = 'Chapter not found';
|
||||
}
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : 'Unknown error';
|
||||
} finally {
|
||||
fetching = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
fetchChapter();
|
||||
window.addEventListener('scroll', handleScroll, { passive: true });
|
||||
window.addEventListener('keydown', handleKeydown);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener('scroll', handleScroll);
|
||||
window.removeEventListener('keydown', handleKeydown);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<ChapterProgressBar progress={scrollProgress} />
|
||||
|
||||
<div class="space-y-6 pt-2">
|
||||
<!-- Back Navigation -->
|
||||
<Button variant="ghost" href="/novels/{novelId}" class="-ml-2 gap-2">
|
||||
<ArrowLeft class="h-4 w-4" />
|
||||
Back to Novel
|
||||
</Button>
|
||||
|
||||
<!-- Loading State -->
|
||||
{#if fetching}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div
|
||||
class="border-primary h-10 w-10 animate-spin rounded-full border-2 border-t-transparent"
|
||||
aria-label="Loading chapter"
|
||||
></div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
<!-- Error State -->
|
||||
{#if error && !fetching}
|
||||
<Card class="border-destructive/40 bg-destructive/5">
|
||||
<CardContent class="py-8">
|
||||
<div class="text-center">
|
||||
<p class="text-destructive text-lg font-medium">
|
||||
{error === 'Chapter not found' ? 'Chapter Not Found' : 'Error Loading Chapter'}
|
||||
</p>
|
||||
<p class="text-muted-foreground mt-2 text-sm">{error}</p>
|
||||
<Button variant="outline" onclick={fetchChapter} class="mt-4"> Try Again </Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
<!-- Chapter Content -->
|
||||
{#if chapter && !fetching}
|
||||
<!-- Navigation (top) -->
|
||||
<ChapterNavigation
|
||||
novelId={novelId ?? ''}
|
||||
prevChapterOrder={chapter.prevChapterOrder}
|
||||
nextChapterOrder={chapter.nextChapterOrder}
|
||||
/>
|
||||
|
||||
<!-- Chapter Header -->
|
||||
<Card>
|
||||
<CardContent class="py-6">
|
||||
<div class="space-y-2 text-center">
|
||||
<p class="text-muted-foreground text-sm">
|
||||
{chapter.novelName}
|
||||
</p>
|
||||
<h1 class="text-2xl font-bold">Chapter {chapter.order}: {chapter.name}</h1>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<!-- Chapter Body -->
|
||||
<Card>
|
||||
<CardContent class="px-6 py-8 md:px-12">
|
||||
<article
|
||||
class="prose prose-lg dark:prose-invert mx-auto max-w-none whitespace-pre-line
|
||||
prose-p:text-foreground prose-p:mb-4 prose-p:leading-relaxed
|
||||
prose-headings:text-foreground
|
||||
first:prose-p:mt-0 last:prose-p:mb-0"
|
||||
>
|
||||
{@html sanitizedBody}
|
||||
</article>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<!-- Navigation (bottom) -->
|
||||
<ChapterNavigation
|
||||
novelId={novelId ?? ''}
|
||||
prevChapterOrder={chapter.prevChapterOrder}
|
||||
nextChapterOrder={chapter.nextChapterOrder}
|
||||
showKeyboardHints={false}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { isLoading, isConfigured, login } from '$lib/auth/authStore';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
</script>
|
||||
|
||||
{#if $isLoading}
|
||||
<Button variant="outline" disabled>Loading...</Button>
|
||||
{:else if !isConfigured}
|
||||
<span class="text-sm text-yellow-600">Auth not configured</span>
|
||||
{:else}
|
||||
<Button onclick={login}>Sign in</Button>
|
||||
{/if}
|
||||
@@ -38,14 +38,8 @@
|
||||
|
||||
let { novel }: NovelCardProps = $props();
|
||||
|
||||
function pickText(novelText?: NovelNode['name'] | NovelNode['description']) {
|
||||
const texts = novelText?.texts ?? [];
|
||||
const english = texts.find((t) => t.language === 'EN');
|
||||
return (english ?? texts[0])?.text ?? 'No description available.';
|
||||
}
|
||||
|
||||
const title = $derived(pickText(novel.name));
|
||||
const descriptionRaw = $derived(pickText(novel.description));
|
||||
const title = $derived(novel.name || 'Untitled');
|
||||
const descriptionRaw = $derived(novel.description || 'No description available.');
|
||||
const descriptionHtml = $derived(sanitizeHtml(descriptionRaw));
|
||||
const coverSrc = $derived(novel.coverImage?.newPath ?? novel.coverImage?.originalPath);
|
||||
|
||||
|
||||
@@ -1,25 +1,375 @@
|
||||
<script lang="ts" module>
|
||||
import type { NovelQuery, NovelStatus, Language } from '$lib/graphql/__generated__/graphql';
|
||||
|
||||
export type NovelNode = NonNullable<NonNullable<NovelQuery['novels']>['nodes']>[number];
|
||||
|
||||
const statusColors: Record<NovelStatus, string> = {
|
||||
IN_PROGRESS: 'bg-green-500 text-white',
|
||||
COMPLETED: 'bg-blue-500 text-white',
|
||||
HIATUS: 'bg-amber-500 text-white',
|
||||
ABANDONED: 'bg-gray-500 text-white',
|
||||
UNKNOWN: 'bg-gray-500 text-white'
|
||||
};
|
||||
|
||||
const statusLabels: Record<NovelStatus, string> = {
|
||||
IN_PROGRESS: 'Ongoing',
|
||||
COMPLETED: 'Complete',
|
||||
HIATUS: 'Hiatus',
|
||||
ABANDONED: 'Dropped',
|
||||
UNKNOWN: 'Unknown'
|
||||
};
|
||||
|
||||
const languageLabels: Record<Language, string> = {
|
||||
EN: 'English',
|
||||
KR: 'Korean',
|
||||
JA: 'Japanese',
|
||||
CH: 'Chinese'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||
import { onMount } from 'svelte';
|
||||
import { client } from '$lib/graphql/client';
|
||||
import { NovelDocument } from '$lib/graphql/__generated__/graphql';
|
||||
import { Card, CardContent, CardHeader } from '$lib/components/ui/card';
|
||||
import { Badge } from '$lib/components/ui/badge';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '$lib/components/ui/tabs';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipTrigger,
|
||||
TooltipContent,
|
||||
TooltipProvider
|
||||
} from '$lib/components/ui/tooltip';
|
||||
import { formatRelativeTime, formatAbsoluteTime } from '$lib/utils/time';
|
||||
import { sanitizeHtml } from '$lib/utils/sanitize';
|
||||
// Direct imports for faster builds
|
||||
import ArrowLeft from '@lucide/svelte/icons/arrow-left';
|
||||
import ExternalLink from '@lucide/svelte/icons/external-link';
|
||||
import BookOpen from '@lucide/svelte/icons/book-open';
|
||||
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||
import ChevronUp from '@lucide/svelte/icons/chevron-up';
|
||||
|
||||
interface Props {
|
||||
novelId?: string;
|
||||
}
|
||||
|
||||
let { novelId }: Props = $props();
|
||||
|
||||
let novel: NovelNode | null = $state(null);
|
||||
let fetching = $state(true);
|
||||
let error: string | null = $state(null);
|
||||
let descriptionExpanded = $state(false);
|
||||
|
||||
const DESCRIPTION_PREVIEW_LENGTH = 300;
|
||||
|
||||
// Derived values
|
||||
const coverSrc = $derived(novel?.coverImage?.newPath ?? novel?.coverImage?.originalPath);
|
||||
const status = $derived(novel?.rawStatus ?? 'UNKNOWN');
|
||||
const statusColor = $derived(statusColors[status]);
|
||||
const statusLabel = $derived(statusLabels[status]);
|
||||
const language = $derived(novel?.rawLanguage ?? 'EN');
|
||||
const languageLabel = $derived(languageLabels[language]);
|
||||
|
||||
const lastUpdated = $derived(novel?.lastUpdatedTime ? new Date(novel.lastUpdatedTime) : null);
|
||||
const relativeTime = $derived(lastUpdated ? formatRelativeTime(lastUpdated) : null);
|
||||
const absoluteTime = $derived(lastUpdated ? formatAbsoluteTime(lastUpdated) : null);
|
||||
|
||||
const description = $derived(novel?.description ?? '');
|
||||
const descriptionHtml = $derived(sanitizeHtml(description));
|
||||
const isDescriptionLong = $derived(description.length > DESCRIPTION_PREVIEW_LENGTH);
|
||||
const truncatedDescriptionHtml = $derived(
|
||||
isDescriptionLong && !descriptionExpanded
|
||||
? sanitizeHtml(description.slice(0, DESCRIPTION_PREVIEW_LENGTH) + '...')
|
||||
: descriptionHtml
|
||||
);
|
||||
|
||||
const sortedChapters = $derived(
|
||||
[...(novel?.chapters ?? [])].sort((a, b) => a.order - b.order)
|
||||
);
|
||||
|
||||
const chapterCount = $derived(novel?.chapters?.length ?? 0);
|
||||
|
||||
async function fetchNovel() {
|
||||
if (!novelId) {
|
||||
error = 'No novel ID provided';
|
||||
fetching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fetching = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const result = await client
|
||||
.query(NovelDocument, { id: parseInt(novelId, 10) })
|
||||
.toPromise();
|
||||
|
||||
if (result.error) {
|
||||
error = result.error.message;
|
||||
return;
|
||||
}
|
||||
|
||||
const nodes = result.data?.novels?.nodes;
|
||||
if (nodes && nodes.length > 0) {
|
||||
novel = nodes[0];
|
||||
} else {
|
||||
error = 'Novel not found';
|
||||
}
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : 'Unknown error';
|
||||
} finally {
|
||||
fetching = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
fetchNovel();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Card class="shadow-md shadow-primary/10">
|
||||
<CardHeader>
|
||||
<CardTitle>Novel Details</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{#if novelId}
|
||||
Viewing novel ID: <code class="rounded bg-muted px-1 py-0.5">{novelId}</code>
|
||||
{/if}
|
||||
</p>
|
||||
<p class="mt-2 text-sm text-muted-foreground">
|
||||
Detail view coming soon. Select a novel to explore chapters and metadata once implemented.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div class="space-y-6">
|
||||
<!-- Back Navigation -->
|
||||
<Button variant="ghost" href="/novels" class="gap-2 -ml-2">
|
||||
<ArrowLeft class="h-4 w-4" />
|
||||
Back to Novels
|
||||
</Button>
|
||||
|
||||
<!-- Loading State -->
|
||||
{#if fetching}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div
|
||||
class="border-primary h-10 w-10 animate-spin rounded-full border-2 border-t-transparent"
|
||||
aria-label="Loading novel"
|
||||
></div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
<!-- Error State -->
|
||||
{#if error && !fetching}
|
||||
<Card class="border-destructive/40 bg-destructive/5">
|
||||
<CardContent class="py-8">
|
||||
<div class="text-center">
|
||||
<p class="text-destructive text-lg font-medium">
|
||||
{error === 'Novel not found' ? 'Novel Not Found' : 'Error Loading Novel'}
|
||||
</p>
|
||||
<p class="text-muted-foreground mt-2 text-sm">{error}</p>
|
||||
<Button variant="outline" onclick={fetchNovel} class="mt-4">
|
||||
Try Again
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
<!-- Novel Content -->
|
||||
{#if novel && !fetching}
|
||||
<!-- Header Section (Metadata + Tags + Description) -->
|
||||
<Card class="shadow-md shadow-primary/10 overflow-hidden">
|
||||
<CardContent class="p-0">
|
||||
<!-- Cover Image + Metadata + Tags -->
|
||||
<div class="flex flex-col sm:flex-row gap-6 p-6 pb-4">
|
||||
<!-- Cover Image -->
|
||||
<div class="shrink-0 sm:w-40">
|
||||
{#if coverSrc}
|
||||
<div class="aspect-[3/4] w-full overflow-hidden rounded-lg bg-muted/50">
|
||||
<img
|
||||
src={coverSrc}
|
||||
alt={novel.name}
|
||||
class="h-full w-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="aspect-[3/4] w-full rounded-lg bg-muted/50 flex items-center justify-center">
|
||||
<BookOpen class="h-12 w-12 text-muted-foreground/50" />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Metadata + Tags -->
|
||||
<div class="flex-1 space-y-3">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold leading-tight">{novel.name}</h1>
|
||||
{#if novel.author}
|
||||
<p class="text-muted-foreground mt-1">
|
||||
by
|
||||
{#if novel.author.externalUrl}
|
||||
<a
|
||||
href={novel.author.externalUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-primary hover:underline inline-flex items-center gap-1"
|
||||
>
|
||||
{novel.author.name}
|
||||
<ExternalLink class="h-3 w-3" />
|
||||
</a>
|
||||
{:else}
|
||||
<span>{novel.author.name}</span>
|
||||
{/if}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Badges -->
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Badge class={statusColor}>{statusLabel}</Badge>
|
||||
<Badge variant="outline">{languageLabel}</Badge>
|
||||
</div>
|
||||
|
||||
<!-- Stats (inline) -->
|
||||
<div class="text-sm text-muted-foreground flex flex-wrap gap-x-4 gap-y-1">
|
||||
{#if novel.source}
|
||||
<span>
|
||||
Source:
|
||||
<a
|
||||
href={novel.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-primary hover:underline inline-flex items-center gap-1"
|
||||
>
|
||||
{novel.source.name}
|
||||
<ExternalLink class="h-3 w-3" />
|
||||
</a>
|
||||
</span>
|
||||
{/if}
|
||||
{#if relativeTime && absoluteTime}
|
||||
<span>
|
||||
Updated:
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger class="cursor-default hover:text-foreground transition-colors">
|
||||
<time datetime={lastUpdated?.toISOString()}>{relativeTime}</time>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{absoluteTime}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
</span>
|
||||
{/if}
|
||||
<span>{chapterCount} chapters</span>
|
||||
</div>
|
||||
|
||||
<!-- Tags -->
|
||||
{#if novel.tags && novel.tags.length > 0}
|
||||
<div class="flex flex-wrap gap-1.5 pt-1">
|
||||
{#each novel.tags as tag (tag.key)}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
href="/novels?tags={tag.key}"
|
||||
class="cursor-pointer hover:bg-secondary/80 transition-colors text-xs"
|
||||
>
|
||||
{tag.displayName}
|
||||
</Badge>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Description (full width below) -->
|
||||
{#if description}
|
||||
<div class="border-t px-6 py-4">
|
||||
<div class="prose prose-sm dark:prose-invert max-w-none text-muted-foreground">
|
||||
{@html truncatedDescriptionHtml}
|
||||
</div>
|
||||
{#if isDescriptionLong}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onclick={() => (descriptionExpanded = !descriptionExpanded)}
|
||||
class="mt-2 gap-1 -ml-2"
|
||||
>
|
||||
{#if descriptionExpanded}
|
||||
<ChevronUp class="h-4 w-4" />
|
||||
Show less
|
||||
{:else}
|
||||
<ChevronDown class="h-4 w-4" />
|
||||
Show more
|
||||
{/if}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<!-- Tabbed Content -->
|
||||
<Card>
|
||||
<Tabs value="chapters" class="w-full">
|
||||
<CardHeader class="pb-0">
|
||||
<TabsList class="grid w-full grid-cols-3 bg-muted/50 p-1 rounded-lg">
|
||||
<TabsTrigger
|
||||
value="chapters"
|
||||
class="rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm px-3 py-1.5 text-sm font-medium transition-all"
|
||||
>
|
||||
Chapters
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="comments"
|
||||
disabled
|
||||
class="rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm px-3 py-1.5 text-sm font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Comments
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="recommendations"
|
||||
disabled
|
||||
class="rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm px-3 py-1.5 text-sm font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
Recommendations
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent class="pt-4">
|
||||
<TabsContent value="chapters" class="mt-0">
|
||||
{#if sortedChapters.length === 0}
|
||||
<p class="text-muted-foreground text-sm py-4 text-center">
|
||||
No chapters available yet.
|
||||
</p>
|
||||
{:else}
|
||||
<div class="max-h-96 overflow-y-auto -mx-2">
|
||||
{#each sortedChapters as chapter (chapter.id)}
|
||||
{@const chapterDate = chapter.lastUpdatedTime ? new Date(chapter.lastUpdatedTime) : null}
|
||||
<a
|
||||
href="/novels/{novelId}/chapters/{chapter.order}"
|
||||
class="flex items-center justify-between px-3 py-2.5 hover:bg-muted/50 rounded-md transition-colors group"
|
||||
>
|
||||
<div class="flex items-center gap-3 min-w-0">
|
||||
<span class="text-muted-foreground text-sm font-medium shrink-0 w-14">
|
||||
Ch. {chapter.order}
|
||||
</span>
|
||||
<span class="text-sm truncate group-hover:text-primary transition-colors">
|
||||
{chapter.name}
|
||||
</span>
|
||||
</div>
|
||||
{#if chapterDate}
|
||||
<span class="text-xs text-muted-foreground/70 shrink-0 ml-2">
|
||||
{formatRelativeTime(chapterDate)}
|
||||
</span>
|
||||
{/if}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="comments" class="mt-0">
|
||||
<p class="text-muted-foreground text-sm py-8 text-center">
|
||||
Comments coming soon.
|
||||
</p>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="recommendations" class="mt-0">
|
||||
<p class="text-muted-foreground text-sm py-8 text-center">
|
||||
Recommendations coming soon.
|
||||
</p>
|
||||
</TabsContent>
|
||||
</CardContent>
|
||||
</Tabs>
|
||||
</Card>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
222
fictionarchive-web-astro/src/lib/components/NovelFilters.svelte
Normal file
222
fictionarchive-web-astro/src/lib/components/NovelFilters.svelte
Normal file
@@ -0,0 +1,222 @@
|
||||
<script lang="ts">
|
||||
import { Select } from 'bits-ui';
|
||||
// Direct imports for faster Astro builds
|
||||
import Search from '@lucide/svelte/icons/search';
|
||||
import X from '@lucide/svelte/icons/x';
|
||||
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||
import Check from '@lucide/svelte/icons/check';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Badge } from '$lib/components/ui/badge';
|
||||
import { type NovelFilters, hasActiveFilters, EMPTY_FILTERS } from '$lib/utils/filterParams';
|
||||
import { NovelStatus, type NovelTagDto } from '$lib/graphql/__generated__/graphql';
|
||||
|
||||
interface Props {
|
||||
filters: NovelFilters;
|
||||
onFilterChange: (filters: NovelFilters) => void;
|
||||
availableTags: Pick<NovelTagDto, 'key' | 'displayName'>[];
|
||||
}
|
||||
|
||||
let { filters, onFilterChange, availableTags }: Props = $props();
|
||||
|
||||
// Local state for search input (for debouncing)
|
||||
let searchInput = $state(filters.search);
|
||||
let searchTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
// Status options
|
||||
const statusOptions: { value: NovelStatus; label: string }[] = [
|
||||
{ value: NovelStatus.InProgress, label: 'In Progress' },
|
||||
{ value: NovelStatus.Completed, label: 'Completed' },
|
||||
{ value: NovelStatus.Hiatus, label: 'Hiatus' },
|
||||
{ value: NovelStatus.Abandoned, label: 'Abandoned' },
|
||||
{ value: NovelStatus.Unknown, label: 'Unknown' }
|
||||
];
|
||||
|
||||
// Derived state for display
|
||||
const selectedStatusLabels = $derived(
|
||||
filters.statuses.map((s) => statusOptions.find((o) => o.value === s)?.label ?? s).join(', ')
|
||||
);
|
||||
|
||||
const selectedTagLabels = $derived(
|
||||
filters.tags.map((t) => availableTags.find((tag) => tag.key === t)?.displayName ?? t).join(', ')
|
||||
);
|
||||
|
||||
// Debounced search handler
|
||||
function handleSearchInput(value: string) {
|
||||
searchInput = value;
|
||||
if (searchTimeout) clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(() => {
|
||||
onFilterChange({ ...filters, search: value });
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// Status selection handler
|
||||
function handleStatusChange(selected: NovelStatus[]) {
|
||||
onFilterChange({ ...filters, statuses: selected });
|
||||
}
|
||||
|
||||
// Tag selection handler
|
||||
function handleTagChange(selected: string[]) {
|
||||
onFilterChange({ ...filters, tags: selected });
|
||||
}
|
||||
|
||||
// Clear all filters
|
||||
function clearFilters() {
|
||||
searchInput = '';
|
||||
onFilterChange({ ...EMPTY_FILTERS });
|
||||
}
|
||||
|
||||
// Sync search input when filters prop changes externally
|
||||
$effect(() => {
|
||||
if (filters.search !== searchInput && !searchTimeout) {
|
||||
searchInput = filters.search;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<!-- Search Input -->
|
||||
<div class="relative min-w-[200px] flex-1">
|
||||
<Search class="text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Search novels..."
|
||||
value={searchInput}
|
||||
oninput={(e) => handleSearchInput(e.currentTarget.value)}
|
||||
class="pl-9"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Status Filter -->
|
||||
<Select.Root
|
||||
type="multiple"
|
||||
value={filters.statuses}
|
||||
onValueChange={(v) => handleStatusChange(v as NovelStatus[])}
|
||||
>
|
||||
<Select.Trigger
|
||||
class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 min-w-[140px] items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<span class="truncate text-left">
|
||||
{filters.statuses.length > 0 ? selectedStatusLabels : 'Status'}
|
||||
</span>
|
||||
<ChevronDown class="h-4 w-4 opacity-50" />
|
||||
</Select.Trigger>
|
||||
<Select.Content
|
||||
class="bg-popover text-popover-foreground z-50 max-h-60 min-w-[140px] overflow-auto rounded-md border p-1 shadow-md"
|
||||
>
|
||||
{#each statusOptions as option (option.value)}
|
||||
<Select.Item
|
||||
value={option.value}
|
||||
class="hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
||||
>
|
||||
{#snippet children({ selected })}
|
||||
<div
|
||||
class="border-primary flex h-4 w-4 items-center justify-center rounded-sm border {selected
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: ''}"
|
||||
>
|
||||
{#if selected}
|
||||
<Check class="h-3 w-3" />
|
||||
{/if}
|
||||
</div>
|
||||
<span>{option.label}</span>
|
||||
{/snippet}
|
||||
</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
|
||||
<!-- Tags Filter -->
|
||||
{#if availableTags.length > 0}
|
||||
<Select.Root
|
||||
type="multiple"
|
||||
value={filters.tags}
|
||||
onValueChange={(v) => handleTagChange(v as string[])}
|
||||
>
|
||||
<Select.Trigger
|
||||
class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 min-w-[120px] items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<span class="truncate text-left">
|
||||
{filters.tags.length > 0 ? selectedTagLabels : 'Tags'}
|
||||
</span>
|
||||
<ChevronDown class="h-4 w-4 opacity-50" />
|
||||
</Select.Trigger>
|
||||
<Select.Content
|
||||
class="bg-popover text-popover-foreground z-50 max-h-60 min-w-[180px] overflow-auto rounded-md border p-1 shadow-md"
|
||||
>
|
||||
{#each availableTags as tag (tag.key)}
|
||||
<Select.Item
|
||||
value={tag.key}
|
||||
class="hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
||||
>
|
||||
{#snippet children({ selected })}
|
||||
<div
|
||||
class="border-primary flex h-4 w-4 items-center justify-center rounded-sm border {selected
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: ''}"
|
||||
>
|
||||
{#if selected}
|
||||
<Check class="h-3 w-3" />
|
||||
{/if}
|
||||
</div>
|
||||
<span>{tag.displayName}</span>
|
||||
{/snippet}
|
||||
</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
{/if}
|
||||
|
||||
<!-- Clear Filters Button -->
|
||||
{#if hasActiveFilters(filters)}
|
||||
<Button variant="outline" size="sm" onclick={clearFilters} class="gap-1">
|
||||
<X class="h-4 w-4" />
|
||||
Clear
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Active Filter Badges -->
|
||||
{#if hasActiveFilters(filters)}
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
{#if filters.search}
|
||||
<Badge variant="secondary" class="gap-1">
|
||||
Search: {filters.search}
|
||||
<button
|
||||
onclick={() => {
|
||||
searchInput = '';
|
||||
onFilterChange({ ...filters, search: '' });
|
||||
}}
|
||||
class="hover:bg-secondary-foreground/20 ml-1 rounded-full p-0.5"
|
||||
>
|
||||
<X class="h-3 w-3" />
|
||||
</button>
|
||||
</Badge>
|
||||
{/if}
|
||||
|
||||
{#each filters.statuses as status (status)}
|
||||
<Badge variant="secondary" class="gap-1">
|
||||
{statusOptions.find((o) => o.value === status)?.label ?? status}
|
||||
<button
|
||||
onclick={() =>
|
||||
onFilterChange({ ...filters, statuses: filters.statuses.filter((s) => s !== status) })}
|
||||
class="hover:bg-secondary-foreground/20 ml-1 rounded-full p-0.5"
|
||||
>
|
||||
<X class="h-3 w-3" />
|
||||
</button>
|
||||
</Badge>
|
||||
{/each}
|
||||
|
||||
{#each filters.tags as tag (tag)}
|
||||
<Badge variant="secondary" class="gap-1">
|
||||
{availableTags.find((t) => t.key === tag)?.displayName ?? tag}
|
||||
<button
|
||||
onclick={() => onFilterChange({ ...filters, tags: filters.tags.filter((t) => t !== tag) })}
|
||||
class="hover:bg-secondary-foreground/20 ml-1 rounded-full p-0.5"
|
||||
>
|
||||
<X class="h-3 w-3" />
|
||||
</button>
|
||||
</Badge>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,10 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import { client } from '$lib/graphql/client';
|
||||
import { NovelsDocument, type NovelsQuery } from '$lib/graphql/__generated__/graphql';
|
||||
import { NovelsDocument, type NovelsQuery, type NovelTagDto } from '$lib/graphql/__generated__/graphql';
|
||||
import NovelCard from './NovelCard.svelte';
|
||||
import NovelFilters from './NovelFilters.svelte';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||
import {
|
||||
type NovelFilters as NovelFiltersType,
|
||||
parseFiltersFromURL,
|
||||
syncFiltersToURL,
|
||||
filtersToGraphQLWhere,
|
||||
hasActiveFilters,
|
||||
EMPTY_FILTERS
|
||||
} from '$lib/utils/filterParams';
|
||||
|
||||
const PAGE_SIZE = 12;
|
||||
|
||||
@@ -15,16 +25,33 @@
|
||||
let fetching = $state(false);
|
||||
let error: string | null = $state(null);
|
||||
let initialLoad = $state(true);
|
||||
let filters: NovelFiltersType = $state({ ...EMPTY_FILTERS });
|
||||
|
||||
const hasNextPage = $derived(pageInfo?.hasNextPage ?? false);
|
||||
const novels = $derived(edges.map((edge) => edge.node).filter(Boolean));
|
||||
|
||||
// Extract unique tags from loaded novels for the tag filter dropdown
|
||||
const availableTags = $derived(() => {
|
||||
const tagMap = new SvelteMap<string, Pick<NovelTagDto, 'key' | 'displayName'>>();
|
||||
for (const novel of novels) {
|
||||
for (const tag of novel.tags ?? []) {
|
||||
if (!tagMap.has(tag.key)) {
|
||||
tagMap.set(tag.key, { key: tag.key, displayName: tag.displayName });
|
||||
}
|
||||
}
|
||||
}
|
||||
return Array.from(tagMap.values()).sort((a, b) => a.displayName.localeCompare(b.displayName));
|
||||
});
|
||||
|
||||
async function fetchNovels(after: string | null = null) {
|
||||
fetching = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const result = await client.query(NovelsDocument, { first: PAGE_SIZE, after }).toPromise();
|
||||
const where = filtersToGraphQLWhere(filters);
|
||||
const result = await client
|
||||
.query(NovelsDocument, { first: PAGE_SIZE, after, where })
|
||||
.toPromise();
|
||||
|
||||
if (result.error) {
|
||||
error = result.error.message;
|
||||
@@ -36,7 +63,7 @@
|
||||
// Append for pagination
|
||||
edges = [...edges, ...result.data.novels.edges];
|
||||
} else {
|
||||
// Initial load
|
||||
// Initial load or filter change
|
||||
edges = result.data.novels.edges;
|
||||
}
|
||||
pageInfo = result.data.novels.pageInfo;
|
||||
@@ -55,17 +82,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
function handleFilterChange(newFilters: NovelFiltersType) {
|
||||
filters = newFilters;
|
||||
// Reset pagination and refetch
|
||||
edges = [];
|
||||
pageInfo = null;
|
||||
syncFiltersToURL(filters);
|
||||
fetchNovels();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
// Parse filters from URL on initial load
|
||||
filters = parseFiltersFromURL();
|
||||
fetchNovels();
|
||||
|
||||
// Listen for browser back/forward navigation
|
||||
const handlePopState = () => {
|
||||
filters = parseFiltersFromURL();
|
||||
edges = [];
|
||||
pageInfo = null;
|
||||
fetchNovels();
|
||||
};
|
||||
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
return () => window.removeEventListener('popstate', handlePopState);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="space-y-4">
|
||||
<Card class="shadow-md shadow-primary/10">
|
||||
<CardHeader>
|
||||
<CardTitle>Latest Novels</CardTitle>
|
||||
<p class="text-sm text-muted-foreground">Novels that have recently been updated.</p>
|
||||
<CardTitle>Novels</CardTitle>
|
||||
<p class="text-muted-foreground text-sm">
|
||||
{#if hasActiveFilters(filters)}
|
||||
Showing filtered results
|
||||
{:else}
|
||||
Browse all novels
|
||||
{/if}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<NovelFilters {filters} onFilterChange={handleFilterChange} availableTags={availableTags()} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{#if fetching && initialLoad}
|
||||
@@ -73,7 +131,7 @@
|
||||
<CardContent>
|
||||
<div class="flex items-center justify-center py-8">
|
||||
<div
|
||||
class="h-10 w-10 animate-spin rounded-full border-2 border-primary border-t-transparent"
|
||||
class="border-primary h-10 w-10 animate-spin rounded-full border-2 border-t-transparent"
|
||||
aria-label="Loading novels"
|
||||
></div>
|
||||
</div>
|
||||
@@ -84,7 +142,7 @@
|
||||
{#if error}
|
||||
<Card class="border-destructive/40 bg-destructive/5">
|
||||
<CardContent>
|
||||
<p class="py-4 text-sm text-destructive">Could not load novels: {error}</p>
|
||||
<p class="text-destructive py-4 text-sm">Could not load novels: {error}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{/if}
|
||||
@@ -92,8 +150,12 @@
|
||||
{#if !fetching && novels.length === 0 && !error && !initialLoad}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<p class="py-4 text-sm text-muted-foreground">
|
||||
No novels found yet. Try adding content to the gateway.
|
||||
<p class="text-muted-foreground py-4 text-sm">
|
||||
{#if hasActiveFilters(filters)}
|
||||
No novels match your filters. Try adjusting your search criteria.
|
||||
{:else}
|
||||
No novels found yet. Try adding content to the gateway.
|
||||
{/if}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
18
fictionarchive-web-astro/src/lib/components/ui/tabs/index.ts
Normal file
18
fictionarchive-web-astro/src/lib/components/ui/tabs/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Tabs as TabsPrimitive } from 'bits-ui';
|
||||
|
||||
const Root = TabsPrimitive.Root;
|
||||
const List = TabsPrimitive.List;
|
||||
const Trigger = TabsPrimitive.Trigger;
|
||||
const Content = TabsPrimitive.Content;
|
||||
|
||||
export {
|
||||
Root,
|
||||
List,
|
||||
Trigger,
|
||||
Content,
|
||||
//
|
||||
Root as Tabs,
|
||||
List as TabsList,
|
||||
Trigger as TabsTrigger,
|
||||
Content as TabsContent
|
||||
};
|
||||
@@ -29,27 +29,27 @@ export const ApplyPolicy = {
|
||||
} as const;
|
||||
|
||||
export type ApplyPolicy = typeof ApplyPolicy[keyof typeof ApplyPolicy];
|
||||
export type Chapter = {
|
||||
body: LocalizationKey;
|
||||
export type ChapterDto = {
|
||||
body: Scalars['String']['output'];
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
images: Array<Image>;
|
||||
images: Array<ImageDto>;
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
name: LocalizationKey;
|
||||
name: Scalars['String']['output'];
|
||||
order: Scalars['UnsignedInt']['output'];
|
||||
revision: Scalars['UnsignedInt']['output'];
|
||||
url: Maybe<Scalars['String']['output']>;
|
||||
};
|
||||
|
||||
export type ChapterFilterInput = {
|
||||
and?: InputMaybe<Array<ChapterFilterInput>>;
|
||||
body?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
export type ChapterDtoFilterInput = {
|
||||
and?: InputMaybe<Array<ChapterDtoFilterInput>>;
|
||||
body?: InputMaybe<StringOperationFilterInput>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
images?: InputMaybe<ListFilterInputTypeOfImageFilterInput>;
|
||||
images?: InputMaybe<ListFilterInputTypeOfImageDtoFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
or?: InputMaybe<Array<ChapterFilterInput>>;
|
||||
name?: InputMaybe<StringOperationFilterInput>;
|
||||
or?: InputMaybe<Array<ChapterDtoFilterInput>>;
|
||||
order?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
revision?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
url?: InputMaybe<StringOperationFilterInput>;
|
||||
@@ -60,15 +60,21 @@ export type ChapterPullRequestedEvent = {
|
||||
novelId: Scalars['UnsignedInt']['output'];
|
||||
};
|
||||
|
||||
export type ChapterSortInput = {
|
||||
body?: InputMaybe<LocalizationKeySortInput>;
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||
name?: InputMaybe<LocalizationKeySortInput>;
|
||||
order?: InputMaybe<SortEnumType>;
|
||||
revision?: InputMaybe<SortEnumType>;
|
||||
url?: InputMaybe<SortEnumType>;
|
||||
export type ChapterReaderDto = {
|
||||
body: Scalars['String']['output'];
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
images: Array<ImageDto>;
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
name: Scalars['String']['output'];
|
||||
nextChapterOrder: Maybe<Scalars['UnsignedInt']['output']>;
|
||||
novelId: Scalars['UnsignedInt']['output'];
|
||||
novelName: Scalars['String']['output'];
|
||||
order: Scalars['UnsignedInt']['output'];
|
||||
prevChapterOrder: Maybe<Scalars['UnsignedInt']['output']>;
|
||||
revision: Scalars['UnsignedInt']['output'];
|
||||
totalChapters: Scalars['Int']['output'];
|
||||
url: Maybe<Scalars['String']['output']>;
|
||||
};
|
||||
|
||||
export type DeleteJobError = KeyNotFoundError;
|
||||
@@ -103,8 +109,7 @@ export type FormatError = Error & {
|
||||
message: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type Image = {
|
||||
chapter: Maybe<Chapter>;
|
||||
export type ImageDto = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UUID']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
@@ -112,19 +117,17 @@ export type Image = {
|
||||
originalPath: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type ImageFilterInput = {
|
||||
and?: InputMaybe<Array<ImageFilterInput>>;
|
||||
chapter?: InputMaybe<ChapterFilterInput>;
|
||||
export type ImageDtoFilterInput = {
|
||||
and?: InputMaybe<Array<ImageDtoFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UuidOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
newPath?: InputMaybe<StringOperationFilterInput>;
|
||||
or?: InputMaybe<Array<ImageFilterInput>>;
|
||||
or?: InputMaybe<Array<ImageDtoFilterInput>>;
|
||||
originalPath?: InputMaybe<StringOperationFilterInput>;
|
||||
};
|
||||
|
||||
export type ImageSortInput = {
|
||||
chapter?: InputMaybe<ChapterSortInput>;
|
||||
export type ImageDtoSortInput = {
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||
@@ -178,81 +181,25 @@ export type LanguageOperationFilterInput = {
|
||||
nin?: InputMaybe<Array<Language>>;
|
||||
};
|
||||
|
||||
export type ListFilterInputTypeOfChapterFilterInput = {
|
||||
all?: InputMaybe<ChapterFilterInput>;
|
||||
export type ListFilterInputTypeOfChapterDtoFilterInput = {
|
||||
all?: InputMaybe<ChapterDtoFilterInput>;
|
||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
none?: InputMaybe<ChapterFilterInput>;
|
||||
some?: InputMaybe<ChapterFilterInput>;
|
||||
none?: InputMaybe<ChapterDtoFilterInput>;
|
||||
some?: InputMaybe<ChapterDtoFilterInput>;
|
||||
};
|
||||
|
||||
export type ListFilterInputTypeOfImageFilterInput = {
|
||||
all?: InputMaybe<ImageFilterInput>;
|
||||
export type ListFilterInputTypeOfImageDtoFilterInput = {
|
||||
all?: InputMaybe<ImageDtoFilterInput>;
|
||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
none?: InputMaybe<ImageFilterInput>;
|
||||
some?: InputMaybe<ImageFilterInput>;
|
||||
none?: InputMaybe<ImageDtoFilterInput>;
|
||||
some?: InputMaybe<ImageDtoFilterInput>;
|
||||
};
|
||||
|
||||
export type ListFilterInputTypeOfLocalizationTextFilterInput = {
|
||||
all?: InputMaybe<LocalizationTextFilterInput>;
|
||||
export type ListFilterInputTypeOfNovelTagDtoFilterInput = {
|
||||
all?: InputMaybe<NovelTagDtoFilterInput>;
|
||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
none?: InputMaybe<LocalizationTextFilterInput>;
|
||||
some?: InputMaybe<LocalizationTextFilterInput>;
|
||||
};
|
||||
|
||||
export type ListFilterInputTypeOfNovelFilterInput = {
|
||||
all?: InputMaybe<NovelFilterInput>;
|
||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
none?: InputMaybe<NovelFilterInput>;
|
||||
some?: InputMaybe<NovelFilterInput>;
|
||||
};
|
||||
|
||||
export type ListFilterInputTypeOfNovelTagFilterInput = {
|
||||
all?: InputMaybe<NovelTagFilterInput>;
|
||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
none?: InputMaybe<NovelTagFilterInput>;
|
||||
some?: InputMaybe<NovelTagFilterInput>;
|
||||
};
|
||||
|
||||
export type LocalizationKey = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UUID']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
texts: Array<LocalizationText>;
|
||||
};
|
||||
|
||||
export type LocalizationKeyFilterInput = {
|
||||
and?: InputMaybe<Array<LocalizationKeyFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UuidOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
or?: InputMaybe<Array<LocalizationKeyFilterInput>>;
|
||||
texts?: InputMaybe<ListFilterInputTypeOfLocalizationTextFilterInput>;
|
||||
};
|
||||
|
||||
export type LocalizationKeySortInput = {
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||
};
|
||||
|
||||
export type LocalizationText = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UUID']['output'];
|
||||
language: Language;
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
text: Scalars['String']['output'];
|
||||
translationEngine: Maybe<TranslationEngine>;
|
||||
};
|
||||
|
||||
export type LocalizationTextFilterInput = {
|
||||
and?: InputMaybe<Array<LocalizationTextFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UuidOperationFilterInput>;
|
||||
language?: InputMaybe<LanguageOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
or?: InputMaybe<Array<LocalizationTextFilterInput>>;
|
||||
text?: InputMaybe<StringOperationFilterInput>;
|
||||
translationEngine?: InputMaybe<TranslationEngineFilterInput>;
|
||||
none?: InputMaybe<NovelTagDtoFilterInput>;
|
||||
some?: InputMaybe<NovelTagDtoFilterInput>;
|
||||
};
|
||||
|
||||
export type Mutation = {
|
||||
@@ -300,56 +247,56 @@ export type MutationTranslateTextArgs = {
|
||||
input: TranslateTextInput;
|
||||
};
|
||||
|
||||
export type Novel = {
|
||||
author: Person;
|
||||
chapters: Array<Chapter>;
|
||||
coverImage: Maybe<Image>;
|
||||
export type NovelDto = {
|
||||
author: PersonDto;
|
||||
chapters: Array<ChapterDto>;
|
||||
coverImage: Maybe<ImageDto>;
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
description: LocalizationKey;
|
||||
description: Scalars['String']['output'];
|
||||
externalId: Scalars['String']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
name: LocalizationKey;
|
||||
name: Scalars['String']['output'];
|
||||
rawLanguage: Language;
|
||||
rawStatus: NovelStatus;
|
||||
source: Source;
|
||||
source: SourceDto;
|
||||
statusOverride: Maybe<NovelStatus>;
|
||||
tags: Array<NovelTag>;
|
||||
tags: Array<NovelTagDto>;
|
||||
url: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type NovelFilterInput = {
|
||||
and?: InputMaybe<Array<NovelFilterInput>>;
|
||||
author?: InputMaybe<PersonFilterInput>;
|
||||
chapters?: InputMaybe<ListFilterInputTypeOfChapterFilterInput>;
|
||||
coverImage?: InputMaybe<ImageFilterInput>;
|
||||
export type NovelDtoFilterInput = {
|
||||
and?: InputMaybe<Array<NovelDtoFilterInput>>;
|
||||
author?: InputMaybe<PersonDtoFilterInput>;
|
||||
chapters?: InputMaybe<ListFilterInputTypeOfChapterDtoFilterInput>;
|
||||
coverImage?: InputMaybe<ImageDtoFilterInput>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
description?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
description?: InputMaybe<StringOperationFilterInput>;
|
||||
externalId?: InputMaybe<StringOperationFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
or?: InputMaybe<Array<NovelFilterInput>>;
|
||||
name?: InputMaybe<StringOperationFilterInput>;
|
||||
or?: InputMaybe<Array<NovelDtoFilterInput>>;
|
||||
rawLanguage?: InputMaybe<LanguageOperationFilterInput>;
|
||||
rawStatus?: InputMaybe<NovelStatusOperationFilterInput>;
|
||||
source?: InputMaybe<SourceFilterInput>;
|
||||
source?: InputMaybe<SourceDtoFilterInput>;
|
||||
statusOverride?: InputMaybe<NullableOfNovelStatusOperationFilterInput>;
|
||||
tags?: InputMaybe<ListFilterInputTypeOfNovelTagFilterInput>;
|
||||
tags?: InputMaybe<ListFilterInputTypeOfNovelTagDtoFilterInput>;
|
||||
url?: InputMaybe<StringOperationFilterInput>;
|
||||
};
|
||||
|
||||
export type NovelSortInput = {
|
||||
author?: InputMaybe<PersonSortInput>;
|
||||
coverImage?: InputMaybe<ImageSortInput>;
|
||||
export type NovelDtoSortInput = {
|
||||
author?: InputMaybe<PersonDtoSortInput>;
|
||||
coverImage?: InputMaybe<ImageDtoSortInput>;
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
description?: InputMaybe<LocalizationKeySortInput>;
|
||||
description?: InputMaybe<SortEnumType>;
|
||||
externalId?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||
name?: InputMaybe<LocalizationKeySortInput>;
|
||||
name?: InputMaybe<SortEnumType>;
|
||||
rawLanguage?: InputMaybe<SortEnumType>;
|
||||
rawStatus?: InputMaybe<SortEnumType>;
|
||||
source?: InputMaybe<SourceSortInput>;
|
||||
source?: InputMaybe<SourceDtoSortInput>;
|
||||
statusOverride?: InputMaybe<SortEnumType>;
|
||||
url?: InputMaybe<SortEnumType>;
|
||||
};
|
||||
@@ -370,27 +317,25 @@ export type NovelStatusOperationFilterInput = {
|
||||
nin?: InputMaybe<Array<NovelStatus>>;
|
||||
};
|
||||
|
||||
export type NovelTag = {
|
||||
export type NovelTagDto = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
displayName: LocalizationKey;
|
||||
displayName: Scalars['String']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
key: Scalars['String']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
novels: Array<Novel>;
|
||||
source: Maybe<Source>;
|
||||
source: Maybe<SourceDto>;
|
||||
tagType: TagType;
|
||||
};
|
||||
|
||||
export type NovelTagFilterInput = {
|
||||
and?: InputMaybe<Array<NovelTagFilterInput>>;
|
||||
export type NovelTagDtoFilterInput = {
|
||||
and?: InputMaybe<Array<NovelTagDtoFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
displayName?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
displayName?: InputMaybe<StringOperationFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
key?: InputMaybe<StringOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
novels?: InputMaybe<ListFilterInputTypeOfNovelFilterInput>;
|
||||
or?: InputMaybe<Array<NovelTagFilterInput>>;
|
||||
source?: InputMaybe<SourceFilterInput>;
|
||||
or?: InputMaybe<Array<NovelTagDtoFilterInput>>;
|
||||
source?: InputMaybe<SourceDtoFilterInput>;
|
||||
tagType?: InputMaybe<TagTypeOperationFilterInput>;
|
||||
};
|
||||
|
||||
@@ -403,7 +348,7 @@ export type NovelsConnection = {
|
||||
/** A list of edges. */
|
||||
edges: Maybe<Array<NovelsEdge>>;
|
||||
/** A flattened list of the nodes. */
|
||||
nodes: Maybe<Array<Novel>>;
|
||||
nodes: Maybe<Array<NovelDto>>;
|
||||
/** Information to aid in pagination. */
|
||||
pageInfo: PageInfo;
|
||||
};
|
||||
@@ -413,7 +358,7 @@ export type NovelsEdge = {
|
||||
/** A cursor for use in pagination. */
|
||||
cursor: Scalars['String']['output'];
|
||||
/** The item at the end of the edge. */
|
||||
node: Novel;
|
||||
node: NovelDto;
|
||||
};
|
||||
|
||||
export type NullableOfNovelStatusOperationFilterInput = {
|
||||
@@ -435,38 +380,46 @@ export type PageInfo = {
|
||||
startCursor: Maybe<Scalars['String']['output']>;
|
||||
};
|
||||
|
||||
export type Person = {
|
||||
export type PersonDto = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
externalUrl: Maybe<Scalars['String']['output']>;
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
name: LocalizationKey;
|
||||
name: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type PersonFilterInput = {
|
||||
and?: InputMaybe<Array<PersonFilterInput>>;
|
||||
export type PersonDtoFilterInput = {
|
||||
and?: InputMaybe<Array<PersonDtoFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
externalUrl?: InputMaybe<StringOperationFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
||||
or?: InputMaybe<Array<PersonFilterInput>>;
|
||||
name?: InputMaybe<StringOperationFilterInput>;
|
||||
or?: InputMaybe<Array<PersonDtoFilterInput>>;
|
||||
};
|
||||
|
||||
export type PersonSortInput = {
|
||||
export type PersonDtoSortInput = {
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
externalUrl?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||
name?: InputMaybe<LocalizationKeySortInput>;
|
||||
name?: InputMaybe<SortEnumType>;
|
||||
};
|
||||
|
||||
export type Query = {
|
||||
chapter: Maybe<ChapterReaderDto>;
|
||||
jobs: Array<SchedulerJob>;
|
||||
novels: Maybe<NovelsConnection>;
|
||||
translationEngines: Array<TranslationEngineDescriptor>;
|
||||
translationRequests: Maybe<TranslationRequestsConnection>;
|
||||
users: Array<User>;
|
||||
users: Array<UserDto>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryChapterArgs = {
|
||||
chapterOrder: Scalars['UnsignedInt']['input'];
|
||||
novelId: Scalars['UnsignedInt']['input'];
|
||||
preferredLanguage?: Language;
|
||||
};
|
||||
|
||||
|
||||
@@ -475,8 +428,9 @@ export type QueryNovelsArgs = {
|
||||
before?: InputMaybe<Scalars['String']['input']>;
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
last?: InputMaybe<Scalars['Int']['input']>;
|
||||
order?: InputMaybe<Array<NovelSortInput>>;
|
||||
where?: InputMaybe<NovelFilterInput>;
|
||||
order?: InputMaybe<Array<NovelDtoSortInput>>;
|
||||
preferredLanguage?: Language;
|
||||
where?: InputMaybe<NovelDtoFilterInput>;
|
||||
};
|
||||
|
||||
|
||||
@@ -491,8 +445,8 @@ export type QueryTranslationRequestsArgs = {
|
||||
before?: InputMaybe<Scalars['String']['input']>;
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
last?: InputMaybe<Scalars['Int']['input']>;
|
||||
order?: InputMaybe<Array<TranslationRequestSortInput>>;
|
||||
where?: InputMaybe<TranslationRequestFilterInput>;
|
||||
order?: InputMaybe<Array<TranslationRequestDtoSortInput>>;
|
||||
where?: InputMaybe<TranslationRequestDtoFilterInput>;
|
||||
};
|
||||
|
||||
export type RegisterUserInput = {
|
||||
@@ -503,7 +457,7 @@ export type RegisterUserInput = {
|
||||
};
|
||||
|
||||
export type RegisterUserPayload = {
|
||||
user: Maybe<User>;
|
||||
userDto: Maybe<UserDto>;
|
||||
};
|
||||
|
||||
export type RunJobError = JobPersistenceError;
|
||||
@@ -546,7 +500,7 @@ export const SortEnumType = {
|
||||
} as const;
|
||||
|
||||
export type SortEnumType = typeof SortEnumType[keyof typeof SortEnumType];
|
||||
export type Source = {
|
||||
export type SourceDto = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
key: Scalars['String']['output'];
|
||||
@@ -555,18 +509,18 @@ export type Source = {
|
||||
url: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type SourceFilterInput = {
|
||||
and?: InputMaybe<Array<SourceFilterInput>>;
|
||||
export type SourceDtoFilterInput = {
|
||||
and?: InputMaybe<Array<SourceDtoFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
key?: InputMaybe<StringOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
name?: InputMaybe<StringOperationFilterInput>;
|
||||
or?: InputMaybe<Array<SourceFilterInput>>;
|
||||
or?: InputMaybe<Array<SourceDtoFilterInput>>;
|
||||
url?: InputMaybe<StringOperationFilterInput>;
|
||||
};
|
||||
|
||||
export type SourceSortInput = {
|
||||
export type SourceDtoSortInput = {
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
id?: InputMaybe<SortEnumType>;
|
||||
key?: InputMaybe<SortEnumType>;
|
||||
@@ -616,13 +570,6 @@ export type TranslateTextPayload = {
|
||||
translationResult: Maybe<TranslationResult>;
|
||||
};
|
||||
|
||||
export type TranslationEngine = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
id: Scalars['UnsignedInt']['output'];
|
||||
key: Scalars['String']['output'];
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
};
|
||||
|
||||
export type TranslationEngineDescriptor = {
|
||||
displayName: Scalars['String']['output'];
|
||||
key: Scalars['String']['output'];
|
||||
@@ -640,16 +587,7 @@ export type TranslationEngineDescriptorSortInput = {
|
||||
key?: InputMaybe<SortEnumType>;
|
||||
};
|
||||
|
||||
export type TranslationEngineFilterInput = {
|
||||
and?: InputMaybe<Array<TranslationEngineFilterInput>>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
key?: InputMaybe<StringOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
or?: InputMaybe<Array<TranslationEngineFilterInput>>;
|
||||
};
|
||||
|
||||
export type TranslationRequest = {
|
||||
export type TranslationRequestDto = {
|
||||
billedCharacterCount: Scalars['UnsignedInt']['output'];
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
from: Language;
|
||||
@@ -662,14 +600,14 @@ export type TranslationRequest = {
|
||||
translationEngineKey: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
export type TranslationRequestFilterInput = {
|
||||
and?: InputMaybe<Array<TranslationRequestFilterInput>>;
|
||||
export type TranslationRequestDtoFilterInput = {
|
||||
and?: InputMaybe<Array<TranslationRequestDtoFilterInput>>;
|
||||
billedCharacterCount?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||
createdTime?: InputMaybe<InstantFilterInput>;
|
||||
from?: InputMaybe<LanguageOperationFilterInput>;
|
||||
id?: InputMaybe<UuidOperationFilterInput>;
|
||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||
or?: InputMaybe<Array<TranslationRequestFilterInput>>;
|
||||
or?: InputMaybe<Array<TranslationRequestDtoFilterInput>>;
|
||||
originalText?: InputMaybe<StringOperationFilterInput>;
|
||||
status?: InputMaybe<TranslationRequestStatusOperationFilterInput>;
|
||||
to?: InputMaybe<LanguageOperationFilterInput>;
|
||||
@@ -677,7 +615,7 @@ export type TranslationRequestFilterInput = {
|
||||
translationEngineKey?: InputMaybe<StringOperationFilterInput>;
|
||||
};
|
||||
|
||||
export type TranslationRequestSortInput = {
|
||||
export type TranslationRequestDtoSortInput = {
|
||||
billedCharacterCount?: InputMaybe<SortEnumType>;
|
||||
createdTime?: InputMaybe<SortEnumType>;
|
||||
from?: InputMaybe<SortEnumType>;
|
||||
@@ -709,7 +647,7 @@ export type TranslationRequestsConnection = {
|
||||
/** A list of edges. */
|
||||
edges: Maybe<Array<TranslationRequestsEdge>>;
|
||||
/** A flattened list of the nodes. */
|
||||
nodes: Maybe<Array<TranslationRequest>>;
|
||||
nodes: Maybe<Array<TranslationRequestDto>>;
|
||||
/** Information to aid in pagination. */
|
||||
pageInfo: PageInfo;
|
||||
};
|
||||
@@ -719,7 +657,7 @@ export type TranslationRequestsEdge = {
|
||||
/** A cursor for use in pagination. */
|
||||
cursor: Scalars['String']['output'];
|
||||
/** The item at the end of the edge. */
|
||||
node: TranslationRequest;
|
||||
node: TranslationRequestDto;
|
||||
};
|
||||
|
||||
export type TranslationResult = {
|
||||
@@ -747,14 +685,13 @@ export type UnsignedIntOperationFilterInputType = {
|
||||
nlte?: InputMaybe<Scalars['UnsignedInt']['input']>;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
export type UserDto = {
|
||||
createdTime: Scalars['Instant']['output'];
|
||||
disabled: Scalars['Boolean']['output'];
|
||||
email: Scalars['String']['output'];
|
||||
id: Scalars['UUID']['output'];
|
||||
inviter: Maybe<User>;
|
||||
inviter: Maybe<UserDto>;
|
||||
lastUpdatedTime: Scalars['Instant']['output'];
|
||||
oAuthProviderId: Scalars['String']['output'];
|
||||
username: Scalars['String']['output'];
|
||||
};
|
||||
|
||||
@@ -773,13 +710,31 @@ export type UuidOperationFilterInput = {
|
||||
nlte?: InputMaybe<Scalars['UUID']['input']>;
|
||||
};
|
||||
|
||||
export type NovelsQueryVariables = Exact<{
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
after?: InputMaybe<Scalars['String']['input']>;
|
||||
export type GetChapterQueryVariables = Exact<{
|
||||
novelId: Scalars['UnsignedInt']['input'];
|
||||
chapterOrder: Scalars['UnsignedInt']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export type NovelsQuery = { novels: { edges: Array<{ cursor: string, node: { id: any, url: string, rawStatus: NovelStatus, lastUpdatedTime: any, name: { texts: Array<{ language: Language, text: string }> }, description: { texts: Array<{ language: Language, text: string }> }, coverImage: { originalPath: string, newPath: string | null } | null, chapters: Array<{ order: any, name: { texts: Array<{ language: Language, text: string }> } }> } }> | null, pageInfo: { hasNextPage: boolean, endCursor: string | null } } | null };
|
||||
export type GetChapterQuery = { chapter: { id: any, order: any, name: string, body: string, url: string | null, revision: any, createdTime: any, lastUpdatedTime: any, novelId: any, novelName: string, totalChapters: number, prevChapterOrder: any | null, nextChapterOrder: any | null, images: Array<{ id: any, newPath: string | null }> } | null };
|
||||
|
||||
export type NovelQueryVariables = Exact<{
|
||||
id: Scalars['UnsignedInt']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export const NovelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Novels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cursor"}},{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"name"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"texts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"language"}},{"kind":"Field","name":{"kind":"Name","value":"text"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"description"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"texts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"language"}},{"kind":"Field","name":{"kind":"Name","value":"text"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"originalPath"}},{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"rawStatus"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"chapters"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"texts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"language"}},{"kind":"Field","name":{"kind":"Name","value":"text"}}]}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<NovelsQuery, NovelsQueryVariables>;
|
||||
export type NovelQuery = { novels: { nodes: Array<{ id: any, name: string, description: string, url: string, rawLanguage: Language, rawStatus: NovelStatus, statusOverride: NovelStatus | null, externalId: string, createdTime: any, lastUpdatedTime: any, author: { id: any, name: string, externalUrl: string | null }, source: { id: any, name: string, key: string, url: string }, coverImage: { newPath: string | null } | null, tags: Array<{ id: any, key: string, displayName: string, tagType: TagType }>, chapters: Array<{ id: any, order: any, name: string, lastUpdatedTime: any }> }> | null } | null };
|
||||
|
||||
export type NovelsQueryVariables = Exact<{
|
||||
first?: InputMaybe<Scalars['Int']['input']>;
|
||||
after?: InputMaybe<Scalars['String']['input']>;
|
||||
where?: InputMaybe<NovelDtoFilterInput>;
|
||||
}>;
|
||||
|
||||
|
||||
export type NovelsQuery = { novels: { edges: Array<{ cursor: string, node: { id: any, url: string, name: string, description: string, rawStatus: NovelStatus, lastUpdatedTime: any, coverImage: { newPath: string | null } | null, chapters: Array<{ order: any, name: string }>, tags: Array<{ key: string, displayName: string }> } }> | null, pageInfo: { hasNextPage: boolean, endCursor: string | null } } | null };
|
||||
|
||||
|
||||
export const GetChapterDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetChapter"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"novelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chapterOrder"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"chapter"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"novelId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"novelId"}}},{"kind":"Argument","name":{"kind":"Name","value":"chapterOrder"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chapterOrder"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"revision"}},{"kind":"Field","name":{"kind":"Name","value":"createdTime"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"images"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"novelId"}},{"kind":"Field","name":{"kind":"Name","value":"novelName"}},{"kind":"Field","name":{"kind":"Name","value":"totalChapters"}},{"kind":"Field","name":{"kind":"Name","value":"prevChapterOrder"}},{"kind":"Field","name":{"kind":"Name","value":"nextChapterOrder"}}]}}]}}]} as unknown as DocumentNode<GetChapterQuery, GetChapterQueryVariables>;
|
||||
export const NovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Novel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}}]}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"rawLanguage"}},{"kind":"Field","name":{"kind":"Name","value":"rawStatus"}},{"kind":"Field","name":{"kind":"Name","value":"statusOverride"}},{"kind":"Field","name":{"kind":"Name","value":"externalId"}},{"kind":"Field","name":{"kind":"Name","value":"createdTime"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"externalUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"source"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"tagType"}}]}},{"kind":"Field","name":{"kind":"Name","value":"chapters"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}}]}}]}}]}}]}}]} as unknown as DocumentNode<NovelQuery, NovelQueryVariables>;
|
||||
export const NovelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Novels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"where"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"NovelDtoFilterInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"Variable","name":{"kind":"Name","value":"where"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cursor"}},{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"rawStatus"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"chapters"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<NovelsQuery, NovelsQueryVariables>;
|
||||
@@ -0,0 +1,23 @@
|
||||
query GetChapter($novelId: UnsignedInt!, $chapterOrder: UnsignedInt!) {
|
||||
chapter(novelId: $novelId, chapterOrder: $chapterOrder) {
|
||||
id
|
||||
order
|
||||
name
|
||||
body
|
||||
url
|
||||
revision
|
||||
createdTime
|
||||
lastUpdatedTime
|
||||
|
||||
images {
|
||||
id
|
||||
newPath
|
||||
}
|
||||
|
||||
novelId
|
||||
novelName
|
||||
totalChapters
|
||||
prevChapterOrder
|
||||
nextChapterOrder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
query Novel($id: UnsignedInt!) {
|
||||
novels(where: { id: { eq: $id } }, first: 1) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
description
|
||||
url
|
||||
rawLanguage
|
||||
rawStatus
|
||||
statusOverride
|
||||
externalId
|
||||
createdTime
|
||||
lastUpdatedTime
|
||||
|
||||
author {
|
||||
id
|
||||
name
|
||||
externalUrl
|
||||
}
|
||||
|
||||
source {
|
||||
id
|
||||
name
|
||||
key
|
||||
url
|
||||
}
|
||||
|
||||
coverImage {
|
||||
newPath
|
||||
}
|
||||
|
||||
tags {
|
||||
id
|
||||
key
|
||||
displayName
|
||||
tagType
|
||||
}
|
||||
|
||||
chapters {
|
||||
id
|
||||
order
|
||||
name
|
||||
lastUpdatedTime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,24 @@
|
||||
query Novels($first: Int, $after: String) {
|
||||
novels(first: $first, after: $after) {
|
||||
query Novels($first: Int, $after: String, $where: NovelDtoFilterInput) {
|
||||
novels(first: $first, after: $after, where: $where) {
|
||||
edges {
|
||||
cursor
|
||||
node {
|
||||
id
|
||||
url
|
||||
name {
|
||||
texts {
|
||||
language
|
||||
text
|
||||
}
|
||||
}
|
||||
description {
|
||||
texts {
|
||||
language
|
||||
text
|
||||
}
|
||||
}
|
||||
name
|
||||
description
|
||||
coverImage {
|
||||
originalPath
|
||||
newPath
|
||||
}
|
||||
rawStatus
|
||||
lastUpdatedTime
|
||||
chapters {
|
||||
order
|
||||
name {
|
||||
texts {
|
||||
language
|
||||
text
|
||||
}
|
||||
}
|
||||
name
|
||||
}
|
||||
tags {
|
||||
key
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
115
fictionarchive-web-astro/src/lib/utils/filterParams.ts
Normal file
115
fictionarchive-web-astro/src/lib/utils/filterParams.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import type { NovelDtoFilterInput, NovelStatus } from '$lib/graphql/__generated__/graphql';
|
||||
|
||||
export interface NovelFilters {
|
||||
search: string;
|
||||
statuses: NovelStatus[];
|
||||
tags: string[];
|
||||
}
|
||||
|
||||
export const EMPTY_FILTERS: NovelFilters = {
|
||||
search: '',
|
||||
statuses: [],
|
||||
tags: []
|
||||
};
|
||||
|
||||
const VALID_STATUSES: NovelStatus[] = ['ABANDONED', 'COMPLETED', 'HIATUS', 'IN_PROGRESS', 'UNKNOWN'];
|
||||
|
||||
/**
|
||||
* Parse filter state from URL search parameters
|
||||
*/
|
||||
export function parseFiltersFromURL(searchParams?: URLSearchParams): NovelFilters {
|
||||
const params = searchParams ?? new URLSearchParams(window.location.search);
|
||||
|
||||
const search = params.get('search') ?? '';
|
||||
|
||||
const statusParam = params.get('status') ?? '';
|
||||
const statuses = statusParam
|
||||
.split(',')
|
||||
.filter((s) => s && VALID_STATUSES.includes(s as NovelStatus)) as NovelStatus[];
|
||||
|
||||
const tagsParam = params.get('tags') ?? '';
|
||||
const tags = tagsParam.split(',').filter((t) => t.length > 0);
|
||||
|
||||
return { search, statuses, tags };
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert filter state to URL search params string
|
||||
*/
|
||||
export function filtersToURLParams(filters: NovelFilters): string {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (filters.search.trim()) {
|
||||
params.set('search', filters.search.trim());
|
||||
}
|
||||
|
||||
if (filters.statuses.length > 0) {
|
||||
params.set('status', filters.statuses.join(','));
|
||||
}
|
||||
|
||||
if (filters.tags.length > 0) {
|
||||
params.set('tags', filters.tags.join(','));
|
||||
}
|
||||
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update browser URL with current filters (without page reload)
|
||||
*/
|
||||
export function syncFiltersToURL(filters: NovelFilters): void {
|
||||
const params = filtersToURLParams(filters);
|
||||
const newUrl = params ? `${window.location.pathname}?${params}` : window.location.pathname;
|
||||
window.history.replaceState({}, '', newUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert filter state to GraphQL where input
|
||||
* Returns null if no filters are active
|
||||
*/
|
||||
export function filtersToGraphQLWhere(filters: NovelFilters): NovelDtoFilterInput | null {
|
||||
const conditions: NovelDtoFilterInput[] = [];
|
||||
|
||||
// Text search on name (case-insensitive contains)
|
||||
if (filters.search.trim()) {
|
||||
conditions.push({
|
||||
name: { contains: filters.search.trim() }
|
||||
});
|
||||
}
|
||||
|
||||
// Status filter
|
||||
if (filters.statuses.length > 0) {
|
||||
conditions.push({
|
||||
rawStatus: { in: filters.statuses }
|
||||
});
|
||||
}
|
||||
|
||||
// Tag filter (match novels that have ANY of the selected tags)
|
||||
if (filters.tags.length > 0) {
|
||||
conditions.push({
|
||||
tags: {
|
||||
some: {
|
||||
key: { in: filters.tags }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Return null if no filters, single condition if one filter, AND for multiple
|
||||
if (conditions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (conditions.length === 1) {
|
||||
return conditions[0];
|
||||
}
|
||||
|
||||
return { and: conditions };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any filters are active
|
||||
*/
|
||||
export function hasActiveFilters(filters: NovelFilters): boolean {
|
||||
return filters.search.trim().length > 0 || filters.statuses.length > 0 || filters.tags.length > 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import DOMPurify from 'dompurify';
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
|
||||
/**
|
||||
* Sanitizes HTML content, allowing only safe inline formatting elements.
|
||||
|
||||
74
fictionarchive-web-astro/src/lib/utils/sanitizeChapter.ts
Normal file
74
fictionarchive-web-astro/src/lib/utils/sanitizeChapter.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
|
||||
/**
|
||||
* Sanitizes chapter HTML content with extended allowed tags.
|
||||
* More permissive than the description sanitizer to support
|
||||
* formatted novel content including headings, lists, and images.
|
||||
*/
|
||||
export function sanitizeChapterHtml(html: string): string {
|
||||
return DOMPurify.sanitize(html, {
|
||||
ALLOWED_TAGS: [
|
||||
// Basic formatting
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'u',
|
||||
's',
|
||||
'strike',
|
||||
'del',
|
||||
'ins',
|
||||
// Structure
|
||||
'p',
|
||||
'br',
|
||||
'hr',
|
||||
'div',
|
||||
'span',
|
||||
// Headings
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
// Lists
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
// Quotes
|
||||
'blockquote',
|
||||
'q',
|
||||
'cite',
|
||||
// Preformatted
|
||||
'pre',
|
||||
'code',
|
||||
// Ruby (for Asian language annotations)
|
||||
'ruby',
|
||||
'rt',
|
||||
'rp',
|
||||
// Images
|
||||
'img',
|
||||
// Tables
|
||||
'table',
|
||||
'thead',
|
||||
'tbody',
|
||||
'tr',
|
||||
'th',
|
||||
'td'
|
||||
],
|
||||
ALLOWED_ATTR: [
|
||||
// Image attributes
|
||||
'src',
|
||||
'alt',
|
||||
'title',
|
||||
'width',
|
||||
'height',
|
||||
// Table attributes
|
||||
'colspan',
|
||||
'rowspan',
|
||||
// Generic styling (limited)
|
||||
'class'
|
||||
],
|
||||
ALLOW_DATA_ATTR: false
|
||||
});
|
||||
}
|
||||
22
fictionarchive-web-astro/src/middleware.ts
Normal file
22
fictionarchive-web-astro/src/middleware.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineMiddleware } from 'astro:middleware';
|
||||
|
||||
const STATIC_PATHS = ['/_astro/', '/favicon.svg', '/favicon.ico'];
|
||||
|
||||
export const onRequest = defineMiddleware(async (context, next) => {
|
||||
const { request, url } = context;
|
||||
|
||||
// Bypass auth for static assets
|
||||
if (STATIC_PATHS.some((p) => url.pathname.startsWith(p))) {
|
||||
return next();
|
||||
}
|
||||
|
||||
// Simple presence check for fa_session cookie
|
||||
const cookieHeader = request.headers.get('cookie') || '';
|
||||
const hasSession = /fa_session=[^;]+/.test(cookieHeader);
|
||||
|
||||
if (hasSession) {
|
||||
return next();
|
||||
}
|
||||
|
||||
return context.rewrite('/gated-404');
|
||||
});
|
||||
@@ -1,6 +1,4 @@
|
||||
---
|
||||
export const prerender = true; // Static page
|
||||
|
||||
import AppLayout from '../layouts/AppLayout.astro';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '../lib/components/ui/card';
|
||||
import { Button } from '../lib/components/ui/button';
|
||||
|
||||
22
fictionarchive-web-astro/src/pages/gated-404.astro
Normal file
22
fictionarchive-web-astro/src/pages/gated-404.astro
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
// Internal route used by middleware for unauthenticated users
|
||||
Astro.response.status = 404;
|
||||
|
||||
import GatedLayout from '../layouts/GatedLayout.astro';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '../lib/components/ui/card';
|
||||
---
|
||||
|
||||
<GatedLayout title="Not Found - FictionArchive">
|
||||
<div class="flex min-h-[50vh] items-center justify-center">
|
||||
<Card class="mx-auto max-w-md text-center shadow-md shadow-primary/10">
|
||||
<CardHeader>
|
||||
<CardTitle class="text-4xl font-bold">404</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent class="space-y-4">
|
||||
<p class="text-muted-foreground">
|
||||
The page you're looking for doesn't exist or has been moved.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</GatedLayout>
|
||||
@@ -1,6 +1,4 @@
|
||||
---
|
||||
export const prerender = true; // Static page
|
||||
|
||||
import AppLayout from '../layouts/AppLayout.astro';
|
||||
import HomePage from '../lib/components/HomePage.svelte';
|
||||
---
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
import AppLayout from '../../../../layouts/AppLayout.astro';
|
||||
import ChapterReaderPage from '../../../../lib/components/ChapterReaderPage.svelte';
|
||||
|
||||
const { id, chapterNumber } = Astro.params;
|
||||
---
|
||||
|
||||
<AppLayout title="Reading - FictionArchive">
|
||||
<ChapterReaderPage novelId={id} chapterNumber={chapterNumber} client:load />
|
||||
</AppLayout>
|
||||
@@ -1,6 +1,4 @@
|
||||
---
|
||||
export const prerender = true; // Static page
|
||||
|
||||
import AppLayout from '../../layouts/AppLayout.astro';
|
||||
import NovelsPage from '../../lib/components/NovelsPage.svelte';
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user