Compare commits
42 Commits
feature/FA
...
b5d4694f12
| Author | SHA1 | Date | |
|---|---|---|---|
| b5d4694f12 | |||
|
|
6d47153a42 | ||
| dbbc2fd8dc | |||
|
|
176c94297b | ||
|
|
8b3faa8f6c | ||
|
|
d87bd81190 | ||
|
|
bee805c441 | ||
| d8e3ec7ec9 | |||
|
|
3612c89b99 | ||
|
|
ebb2e6e7fc | ||
|
|
01d3b94050 | ||
|
|
c0290cc5af | ||
| 1d950b7721 | |||
|
|
7738bcf438 | ||
| 61e0cb69d8 | |||
|
|
02525d611a | ||
| c21fe0fbd5 | |||
|
|
bbc0b5ec7d | ||
| 5527c15ae7 | |||
|
|
1e374e6eeb | ||
| c710f14257 | |||
|
|
6c10077505 | ||
| fecb3e6f43 | |||
|
|
f0ea71e00e | ||
| 45afb57df5 | |||
|
|
6fd76f6787 | ||
| baad092f07 | |||
|
|
4fb34bdef7 | ||
| 89a2cf6db1 | |||
|
|
f830773af5 | ||
| 7185b95c65 | |||
|
|
8b44cf2f0c | ||
| ac48889f4c | |||
|
|
5c52d29da9 | ||
| 16004ad938 | |||
|
|
d109db2155 | ||
| 89dff0980b | |||
|
|
e70c39ea75 | ||
|
|
81e4e88ad4 | ||
| c9d93a4e55 | |||
| 9527d94928 | |||
| aae17021af |
@@ -1,49 +0,0 @@
|
|||||||
name: Claude PR Assistant
|
|
||||||
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created]
|
|
||||||
pull_request_review_comment:
|
|
||||||
types: [created]
|
|
||||||
issues:
|
|
||||||
types: [opened, assigned]
|
|
||||||
pull_request_review:
|
|
||||||
types: [submitted]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
claude-code-action:
|
|
||||||
if: |
|
|
||||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
||||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
||||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
|
||||||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
issues: write
|
|
||||||
id-token: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Run Claude PR Action
|
|
||||||
uses: markwylde/claude-code-gitea-action@v1.0.20
|
|
||||||
with:
|
|
||||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
||||||
gitea_token: ${{ secrets.CLAUDE_GITEA_TOKEN }}
|
|
||||||
# Or use OAuth token instead:
|
|
||||||
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
||||||
timeout_minutes: "60"
|
|
||||||
# mode: tag # Default: responds to @claude mentions
|
|
||||||
# Optional: Restrict network access to specific domains only
|
|
||||||
# experimental_allowed_domains: |
|
|
||||||
# .anthropic.com
|
|
||||||
# .github.com
|
|
||||||
# api.github.com
|
|
||||||
# .githubusercontent.com
|
|
||||||
# bun.sh
|
|
||||||
# registry.npmjs.org
|
|
||||||
# .blob.core.windows.net
|
|
||||||
9977
Documentation/sample_novel_page.html
Normal file
9977
Documentation/sample_novel_page.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,8 @@ RUN dotnet build "./FictionArchive.API.csproj" -c $BUILD_CONFIGURATION -o /app/b
|
|||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
RUN dotnet publish "./FictionArchive.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:SkipFusionBuild=true
|
RUN dotnet publish "./FictionArchive.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:SkipFusionBuild=true
|
||||||
|
# Copy pre-composed gateway.fgp from CI build
|
||||||
|
COPY FictionArchive.API/gateway.fgp /app/publish/
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ public class Program
|
|||||||
.ConfigureFromFile("gateway.fgp")
|
.ConfigureFromFile("gateway.fgp")
|
||||||
.CoreBuilder.ApplySaneDefaults();
|
.CoreBuilder.ApplySaneDefaults();
|
||||||
|
|
||||||
builder.Services.AddOidcAuthentication(builder.Configuration);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var allowedOrigin = builder.Configuration["Cors:AllowedOrigin"] ?? "http://localhost:4321";
|
var allowedOrigin = builder.Configuration["Cors:AllowedOrigin"] ?? "http://localhost:4321";
|
||||||
|
|||||||
@@ -35,8 +35,16 @@ namespace FictionArchive.Service.FileService.Controllers
|
|||||||
BucketName = _s3Configuration.Bucket,
|
BucketName = _s3Configuration.Bucket,
|
||||||
Key = decodedPath
|
Key = decodedPath
|
||||||
});
|
});
|
||||||
|
|
||||||
return new FileStreamResult(s3Response.ResponseStream, s3Response.Headers.ContentType);
|
Response.Headers.CacheControl = "public, max-age=604800"; // 7 days
|
||||||
|
Response.Headers.LastModified = s3Response.LastModified?.ToString("R");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(s3Response.ETag))
|
||||||
|
{
|
||||||
|
Response.Headers.ETag = s3Response.ETag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return File(s3Response.ResponseStream, s3Response.Headers.ContentType);
|
||||||
}
|
}
|
||||||
catch (AmazonS3Exception e)
|
catch (AmazonS3Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ public class NovelUpdateServiceTests
|
|||||||
Images = new List<Image>()
|
Images = new List<Image>()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var volume = new Volume
|
||||||
|
{
|
||||||
|
Order = 1,
|
||||||
|
Name = LocalizationKey.CreateFromText("Main Story", Language.En),
|
||||||
|
Chapters = new List<Chapter> { chapter }
|
||||||
|
};
|
||||||
|
|
||||||
var novel = new Novel
|
var novel = new Novel
|
||||||
{
|
{
|
||||||
Url = "http://demo/novel",
|
Url = "http://demo/novel",
|
||||||
@@ -52,14 +59,14 @@ public class NovelUpdateServiceTests
|
|||||||
Source = source,
|
Source = source,
|
||||||
Name = LocalizationKey.CreateFromText("Demo Novel", Language.En),
|
Name = LocalizationKey.CreateFromText("Demo Novel", Language.En),
|
||||||
Description = LocalizationKey.CreateFromText("Description", Language.En),
|
Description = LocalizationKey.CreateFromText("Description", Language.En),
|
||||||
Chapters = new List<Chapter> { chapter },
|
Volumes = new List<Volume> { volume },
|
||||||
Tags = new List<NovelTag>()
|
Tags = new List<NovelTag>()
|
||||||
};
|
};
|
||||||
|
|
||||||
dbContext.Novels.Add(novel);
|
dbContext.Novels.Add(novel);
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
return new NovelCreateResult(novel, chapter);
|
return new NovelCreateResult(novel, volume, chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NovelUpdateService CreateService(
|
private static NovelUpdateService CreateService(
|
||||||
@@ -81,7 +88,7 @@ public class NovelUpdateServiceTests
|
|||||||
{
|
{
|
||||||
using var dbContext = CreateDbContext();
|
using var dbContext = CreateDbContext();
|
||||||
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
||||||
var (novel, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
var (novel, volume, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
||||||
|
|
||||||
var rawHtml = "<p>Hello</p><img src=\"http://img/x1.jpg\" alt=\"first\" /><img src=\"http://img/x2.jpg\" alt=\"second\" />";
|
var rawHtml = "<p>Hello</p><img src=\"http://img/x1.jpg\" alt=\"first\" /><img src=\"http://img/x2.jpg\" alt=\"second\" />";
|
||||||
var image1 = new ImageData { Url = "http://img/x1.jpg", Data = new byte[] { 1, 2, 3 } };
|
var image1 = new ImageData { Url = "http://img/x1.jpg", Data = new byte[] { 1, 2, 3 } };
|
||||||
@@ -103,7 +110,7 @@ public class NovelUpdateServiceTests
|
|||||||
var pendingImageUrl = "https://pending/placeholder.jpg";
|
var pendingImageUrl = "https://pending/placeholder.jpg";
|
||||||
var service = CreateService(dbContext, adapter, eventBus, pendingImageUrl);
|
var service = CreateService(dbContext, adapter, eventBus, pendingImageUrl);
|
||||||
|
|
||||||
var updatedChapter = await service.PullChapterContents(novel.Id, chapter.Order);
|
var updatedChapter = await service.PullChapterContents(novel.Id, volume.Id, chapter.Order);
|
||||||
|
|
||||||
updatedChapter.Images.Should().HaveCount(2);
|
updatedChapter.Images.Should().HaveCount(2);
|
||||||
updatedChapter.Images.Select(i => i.OriginalPath).Should().BeEquivalentTo(new[] { image1.Url, image2.Url });
|
updatedChapter.Images.Select(i => i.OriginalPath).Should().BeEquivalentTo(new[] { image1.Url, image2.Url });
|
||||||
@@ -131,7 +138,7 @@ public class NovelUpdateServiceTests
|
|||||||
{
|
{
|
||||||
using var dbContext = CreateDbContext();
|
using var dbContext = CreateDbContext();
|
||||||
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
||||||
var (novel, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
var (novel, volume, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
||||||
|
|
||||||
var rawHtml = "<p>Hi</p><img src=\"http://img/x1.jpg\">";
|
var rawHtml = "<p>Hi</p><img src=\"http://img/x1.jpg\">";
|
||||||
var image = new ImageData { Url = "http://img/x1.jpg", Data = new byte[] { 7, 8, 9 } };
|
var image = new ImageData { Url = "http://img/x1.jpg", Data = new byte[] { 7, 8, 9 } };
|
||||||
@@ -150,7 +157,7 @@ public class NovelUpdateServiceTests
|
|||||||
|
|
||||||
var service = CreateService(dbContext, adapter, eventBus);
|
var service = CreateService(dbContext, adapter, eventBus);
|
||||||
|
|
||||||
var updatedChapter = await service.PullChapterContents(novel.Id, chapter.Order);
|
var updatedChapter = await service.PullChapterContents(novel.Id, volume.Id, chapter.Order);
|
||||||
|
|
||||||
var storedHtml = updatedChapter.Body.Texts.Single().Text;
|
var storedHtml = updatedChapter.Body.Texts.Single().Text;
|
||||||
var doc = new HtmlDocument();
|
var doc = new HtmlDocument();
|
||||||
@@ -161,5 +168,139 @@ public class NovelUpdateServiceTests
|
|||||||
imgNode.GetAttributeValue("src", string.Empty).Should().Be("https://pending/placeholder.jpg");
|
imgNode.GetAttributeValue("src", string.Empty).Should().Be("https://pending/placeholder.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
private record NovelCreateResult(Novel Novel, Chapter Chapter);
|
private record NovelCreateResult(Novel Novel, Volume Volume, Chapter Chapter);
|
||||||
|
|
||||||
|
#region UpdateImage Tests
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateImage_sets_NewPath_on_image_without_chapter()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var image = new Image
|
||||||
|
{
|
||||||
|
OriginalPath = "http://original/cover.jpg",
|
||||||
|
NewPath = null
|
||||||
|
};
|
||||||
|
dbContext.Images.Add(image);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var adapter = Substitute.For<ISourceAdapter>();
|
||||||
|
var eventBus = Substitute.For<IEventBus>();
|
||||||
|
var service = CreateService(dbContext, adapter, eventBus);
|
||||||
|
|
||||||
|
var newUrl = "https://cdn.example.com/uploaded/cover.jpg";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await service.UpdateImage(image.Id, newUrl);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var updatedImage = await dbContext.Images.FindAsync(image.Id);
|
||||||
|
updatedImage!.NewPath.Should().Be(newUrl);
|
||||||
|
updatedImage.OriginalPath.Should().Be("http://original/cover.jpg");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateImage_updates_chapter_body_html_with_new_url()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
||||||
|
var (novel, _, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
||||||
|
|
||||||
|
var image = new Image
|
||||||
|
{
|
||||||
|
OriginalPath = "http://original/image.jpg",
|
||||||
|
NewPath = null,
|
||||||
|
Chapter = chapter
|
||||||
|
};
|
||||||
|
chapter.Images.Add(image);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Set up the chapter body with an img tag referencing the image by ID (as PullChapterContents does)
|
||||||
|
var pendingUrl = "https://pending/placeholder.jpg";
|
||||||
|
var bodyHtml = $"<p>Content</p><img src=\"{pendingUrl}\" alt=\"{image.Id}\" />";
|
||||||
|
chapter.Body.Texts.Add(new LocalizationText
|
||||||
|
{
|
||||||
|
Language = Language.En,
|
||||||
|
Text = bodyHtml
|
||||||
|
});
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var adapter = Substitute.For<ISourceAdapter>();
|
||||||
|
var eventBus = Substitute.For<IEventBus>();
|
||||||
|
var service = CreateService(dbContext, adapter, eventBus, pendingUrl);
|
||||||
|
|
||||||
|
var newUrl = "https://cdn.example.com/uploaded/image.jpg";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await service.UpdateImage(image.Id, newUrl);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var updatedImage = await dbContext.Images
|
||||||
|
.Include(i => i.Chapter)
|
||||||
|
.ThenInclude(c => c.Body)
|
||||||
|
.ThenInclude(b => b.Texts)
|
||||||
|
.FirstAsync(i => i.Id == image.Id);
|
||||||
|
|
||||||
|
updatedImage.NewPath.Should().Be(newUrl);
|
||||||
|
|
||||||
|
var updatedBodyText = updatedImage.Chapter!.Body.Texts.Single().Text;
|
||||||
|
var doc = new HtmlDocument();
|
||||||
|
doc.LoadHtml(updatedBodyText);
|
||||||
|
var imgNode = doc.DocumentNode.SelectSingleNode("//img");
|
||||||
|
imgNode.Should().NotBeNull();
|
||||||
|
imgNode!.GetAttributeValue("src", string.Empty).Should().Be(newUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateImage_does_not_modify_other_images_in_chapter_body()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var source = new Source { Name = "Demo", Key = "demo", Url = "http://demo" };
|
||||||
|
var (_, _, chapter) = CreateNovelWithSingleChapter(dbContext, source);
|
||||||
|
|
||||||
|
var image1 = new Image { OriginalPath = "http://original/img1.jpg", Chapter = chapter };
|
||||||
|
var image2 = new Image { OriginalPath = "http://original/img2.jpg", Chapter = chapter };
|
||||||
|
chapter.Images.Add(image1);
|
||||||
|
chapter.Images.Add(image2);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var pendingUrl = "https://pending/placeholder.jpg";
|
||||||
|
var bodyHtml = $"<p>Content</p><img src=\"{pendingUrl}\" alt=\"{image1.Id}\" /><img src=\"{pendingUrl}\" alt=\"{image2.Id}\" />";
|
||||||
|
chapter.Body.Texts.Add(new LocalizationText
|
||||||
|
{
|
||||||
|
Language = Language.En,
|
||||||
|
Text = bodyHtml
|
||||||
|
});
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var adapter = Substitute.For<ISourceAdapter>();
|
||||||
|
var eventBus = Substitute.For<IEventBus>();
|
||||||
|
var service = CreateService(dbContext, adapter, eventBus, pendingUrl);
|
||||||
|
|
||||||
|
var newUrl = "https://cdn.example.com/uploaded/img1.jpg";
|
||||||
|
|
||||||
|
// Act - only update image1
|
||||||
|
await service.UpdateImage(image1.Id, newUrl);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var updatedChapter = await dbContext.Chapters
|
||||||
|
.Include(c => c.Body)
|
||||||
|
.ThenInclude(b => b.Texts)
|
||||||
|
.FirstAsync(c => c.Id == chapter.Id);
|
||||||
|
|
||||||
|
var updatedBodyText = updatedChapter.Body.Texts.Single().Text;
|
||||||
|
var doc = new HtmlDocument();
|
||||||
|
doc.LoadHtml(updatedBodyText);
|
||||||
|
|
||||||
|
var img1Node = doc.DocumentNode.SelectSingleNode($"//img[@alt='{image1.Id}']");
|
||||||
|
var img2Node = doc.DocumentNode.SelectSingleNode($"//img[@alt='{image2.Id}']");
|
||||||
|
|
||||||
|
img1Node!.GetAttributeValue("src", string.Empty).Should().Be(newUrl);
|
||||||
|
img2Node!.GetAttributeValue("src", string.Empty).Should().Be(pendingUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using FictionArchive.Service.NovelService.Services;
|
|||||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||||
using FictionArchive.Service.Shared.Services.EventBus;
|
using FictionArchive.Service.Shared.Services.EventBus;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
|
using HotChocolate.Types;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace FictionArchive.Service.NovelService.GraphQL;
|
namespace FictionArchive.Service.NovelService.GraphQL;
|
||||||
@@ -20,10 +21,20 @@ public class Mutation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ChapterPullRequestedEvent> FetchChapterContents(uint novelId,
|
public async Task<ChapterPullRequestedEvent> FetchChapterContents(
|
||||||
uint chapterNumber,
|
uint novelId,
|
||||||
|
uint volumeId,
|
||||||
|
uint chapterOrder,
|
||||||
NovelUpdateService service)
|
NovelUpdateService service)
|
||||||
{
|
{
|
||||||
return await service.QueueChapterPull(novelId, chapterNumber);
|
return await service.QueueChapterPull(novelId, volumeId, chapterOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Error<KeyNotFoundException>]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<bool> DeleteNovel(uint novelId, NovelUpdateService service)
|
||||||
|
{
|
||||||
|
await service.DeleteNovel(novelId);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 FictionArchive.Service.NovelService.Services;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
using HotChocolate.Data;
|
using HotChocolate.Data;
|
||||||
@@ -13,8 +14,250 @@ public class Query
|
|||||||
[UseProjection]
|
[UseProjection]
|
||||||
[UseFiltering]
|
[UseFiltering]
|
||||||
[UseSorting]
|
[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,
|
||||||
|
|
||||||
|
Volumes = novel.Volumes.OrderBy(v => v.Order).Select(volume => new VolumeDto
|
||||||
|
{
|
||||||
|
Id = volume.Id,
|
||||||
|
CreatedTime = volume.CreatedTime,
|
||||||
|
LastUpdatedTime = volume.LastUpdatedTime,
|
||||||
|
Order = volume.Order,
|
||||||
|
Name = volume.Name.Texts
|
||||||
|
.Where(t => t.Language == preferredLanguage)
|
||||||
|
.Select(t => t.Text)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? volume.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||||
|
?? "",
|
||||||
|
Chapters = volume.Chapters.OrderBy(c => c.Order).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()
|
||||||
|
}).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 volumeOrder,
|
||||||
|
uint chapterOrder,
|
||||||
|
Language preferredLanguage = Language.En)
|
||||||
|
{
|
||||||
|
return dbContext.Chapters
|
||||||
|
.Where(c => c.Volume.Novel.Id == novelId && c.Volume.Order == volumeOrder && 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.Volume.Novel.Id,
|
||||||
|
NovelName = chapter.Volume.Novel.Name.Texts
|
||||||
|
.Where(t => t.Language == preferredLanguage)
|
||||||
|
.Select(t => t.Text)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Novel.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||||
|
?? "",
|
||||||
|
|
||||||
|
// Volume context
|
||||||
|
VolumeId = chapter.Volume.Id,
|
||||||
|
VolumeName = chapter.Volume.Name.Texts
|
||||||
|
.Where(t => t.Language == preferredLanguage)
|
||||||
|
.Select(t => t.Text)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Name.Texts.Select(t => t.Text).FirstOrDefault()
|
||||||
|
?? "",
|
||||||
|
VolumeOrder = chapter.Volume.Order,
|
||||||
|
TotalChaptersInVolume = chapter.Volume.Chapters.Count,
|
||||||
|
|
||||||
|
// Previous chapter: first try same volume, then last chapter of previous volume
|
||||||
|
PrevChapterVolumeOrder = chapter.Volume.Chapters
|
||||||
|
.Where(c => c.Order < chapterOrder)
|
||||||
|
.OrderByDescending(c => c.Order)
|
||||||
|
.Select(c => (int?)chapter.Volume.Order)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Novel.Volumes
|
||||||
|
.Where(v => v.Order < chapter.Volume.Order)
|
||||||
|
.OrderByDescending(v => v.Order)
|
||||||
|
.SelectMany(v => v.Chapters.OrderByDescending(c => c.Order).Take(1))
|
||||||
|
.Select(c => (int?)c.Volume.Order)
|
||||||
|
.FirstOrDefault(),
|
||||||
|
|
||||||
|
PrevChapterOrder = chapter.Volume.Chapters
|
||||||
|
.Where(c => c.Order < chapterOrder)
|
||||||
|
.OrderByDescending(c => c.Order)
|
||||||
|
.Select(c => (uint?)c.Order)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Novel.Volumes
|
||||||
|
.Where(v => v.Order < chapter.Volume.Order)
|
||||||
|
.OrderByDescending(v => v.Order)
|
||||||
|
.SelectMany(v => v.Chapters.OrderByDescending(c => c.Order).Take(1))
|
||||||
|
.Select(c => (uint?)c.Order)
|
||||||
|
.FirstOrDefault(),
|
||||||
|
|
||||||
|
// Next chapter: first try same volume, then first chapter of next volume
|
||||||
|
NextChapterVolumeOrder = chapter.Volume.Chapters
|
||||||
|
.Where(c => c.Order > chapterOrder)
|
||||||
|
.OrderBy(c => c.Order)
|
||||||
|
.Select(c => (int?)chapter.Volume.Order)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Novel.Volumes
|
||||||
|
.Where(v => v.Order > chapter.Volume.Order)
|
||||||
|
.OrderBy(v => v.Order)
|
||||||
|
.SelectMany(v => v.Chapters.OrderBy(c => c.Order).Take(1))
|
||||||
|
.Select(c => (int?)c.Volume.Order)
|
||||||
|
.FirstOrDefault(),
|
||||||
|
|
||||||
|
NextChapterOrder = chapter.Volume.Chapters
|
||||||
|
.Where(c => c.Order > chapterOrder)
|
||||||
|
.OrderBy(c => c.Order)
|
||||||
|
.Select(c => (uint?)c.Order)
|
||||||
|
.FirstOrDefault()
|
||||||
|
?? chapter.Volume.Novel.Volumes
|
||||||
|
.Where(v => v.Order > chapter.Volume.Order)
|
||||||
|
.OrderBy(v => v.Order)
|
||||||
|
.SelectMany(v => v.Chapters.OrderBy(c => c.Order).Take(1))
|
||||||
|
.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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
605
FictionArchive.Service.NovelService/Migrations/20251229203027_AddVolumes.Designer.cs
generated
Normal file
605
FictionArchive.Service.NovelService/Migrations/20251229203027_AddVolumes.Designer.cs
generated
Normal file
@@ -0,0 +1,605 @@
|
|||||||
|
// <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("20251229203027_AddVolumes")]
|
||||||
|
partial class AddVolumes
|
||||||
|
{
|
||||||
|
/// <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>("Order")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("Revision")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("VolumeId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("BodyId");
|
||||||
|
|
||||||
|
b.HasIndex("NameId");
|
||||||
|
|
||||||
|
b.HasIndex("VolumeId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
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("FictionArchive.Service.NovelService.Models.Novels.Volume", 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<Instant>("LastUpdatedTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("NameId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long>("NovelId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Order")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NameId");
|
||||||
|
|
||||||
|
b.HasIndex("NovelId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Volume");
|
||||||
|
});
|
||||||
|
|
||||||
|
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.Volume", "Volume")
|
||||||
|
.WithMany("Chapters")
|
||||||
|
.HasForeignKey("VolumeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Body");
|
||||||
|
|
||||||
|
b.Navigation("Name");
|
||||||
|
|
||||||
|
b.Navigation("Volume");
|
||||||
|
});
|
||||||
|
|
||||||
|
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("FictionArchive.Service.NovelService.Models.Novels.Volume", b =>
|
||||||
|
{
|
||||||
|
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("Volumes")
|
||||||
|
.HasForeignKey("NovelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Name");
|
||||||
|
|
||||||
|
b.Navigation("Novel");
|
||||||
|
});
|
||||||
|
|
||||||
|
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("Volumes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Volume", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Chapters");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using NodaTime;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.NovelService.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddVolumes : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
// 1. Create the Volume table
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Volume",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Order = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
NameId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
NovelId = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||||
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Volume", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Volume_LocalizationKeys_NameId",
|
||||||
|
column: x => x.NameId,
|
||||||
|
principalTable: "LocalizationKeys",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Volume_Novels_NovelId",
|
||||||
|
column: x => x.NovelId,
|
||||||
|
principalTable: "Novels",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Volume_NameId",
|
||||||
|
table: "Volume",
|
||||||
|
column: "NameId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Volume_NovelId_Order",
|
||||||
|
table: "Volume",
|
||||||
|
columns: new[] { "NovelId", "Order" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
// 2. Add nullable VolumeId column to Chapter (keep NovelId for now)
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "VolumeId",
|
||||||
|
table: "Chapter",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
// 3. Data migration: Create volumes and link chapters for each novel
|
||||||
|
migrationBuilder.Sql(@"
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
novel_rec RECORD;
|
||||||
|
loc_key_id uuid;
|
||||||
|
volume_id bigint;
|
||||||
|
BEGIN
|
||||||
|
FOR novel_rec IN SELECT ""Id"", ""RawLanguage"" FROM ""Novels"" LOOP
|
||||||
|
-- Create LocalizationKey for volume name
|
||||||
|
loc_key_id := gen_random_uuid();
|
||||||
|
INSERT INTO ""LocalizationKeys"" (""Id"", ""CreatedTime"", ""LastUpdatedTime"")
|
||||||
|
VALUES (loc_key_id, NOW(), NOW());
|
||||||
|
|
||||||
|
-- Create LocalizationText for 'Main Story' in novel's raw language
|
||||||
|
INSERT INTO ""LocalizationText"" (""Id"", ""LocalizationKeyId"", ""Language"", ""Text"", ""CreatedTime"", ""LastUpdatedTime"")
|
||||||
|
VALUES (gen_random_uuid(), loc_key_id, novel_rec.""RawLanguage"", 'Main Story', NOW(), NOW());
|
||||||
|
|
||||||
|
-- Create Volume for this novel
|
||||||
|
INSERT INTO ""Volume"" (""Order"", ""NameId"", ""NovelId"", ""CreatedTime"", ""LastUpdatedTime"")
|
||||||
|
VALUES (1, loc_key_id, novel_rec.""Id"", NOW(), NOW())
|
||||||
|
RETURNING ""Id"" INTO volume_id;
|
||||||
|
|
||||||
|
-- Link all chapters of this novel to the new volume
|
||||||
|
UPDATE ""Chapter"" SET ""VolumeId"" = volume_id WHERE ""NovelId"" = novel_rec.""Id"";
|
||||||
|
END LOOP;
|
||||||
|
END $$;
|
||||||
|
");
|
||||||
|
|
||||||
|
// 4. Drop old FK and index for NovelId
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Chapter_Novels_NovelId",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Chapter_NovelId",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
// 5. Drop NovelId column from Chapter
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "NovelId",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
// 6. Make VolumeId non-nullable
|
||||||
|
migrationBuilder.AlterColumn<long>(
|
||||||
|
name: "VolumeId",
|
||||||
|
table: "Chapter",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(long),
|
||||||
|
oldType: "bigint",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
// 7. Add unique index and FK for VolumeId
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Chapter_VolumeId_Order",
|
||||||
|
table: "Chapter",
|
||||||
|
columns: new[] { "VolumeId", "Order" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Chapter_Volume_VolumeId",
|
||||||
|
table: "Chapter",
|
||||||
|
column: "VolumeId",
|
||||||
|
principalTable: "Volume",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
// Add back NovelId column
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "NovelId",
|
||||||
|
table: "Chapter",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
// Migrate data back: set NovelId from Volume
|
||||||
|
migrationBuilder.Sql(@"
|
||||||
|
UPDATE ""Chapter"" c
|
||||||
|
SET ""NovelId"" = v.""NovelId""
|
||||||
|
FROM ""Volume"" v
|
||||||
|
WHERE c.""VolumeId"" = v.""Id"";
|
||||||
|
");
|
||||||
|
|
||||||
|
// Make NovelId non-nullable
|
||||||
|
migrationBuilder.AlterColumn<long>(
|
||||||
|
name: "NovelId",
|
||||||
|
table: "Chapter",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(long),
|
||||||
|
oldType: "bigint",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
// Drop VolumeId FK and index
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Chapter_Volume_VolumeId",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Chapter_VolumeId_Order",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
// Drop VolumeId column
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "VolumeId",
|
||||||
|
table: "Chapter");
|
||||||
|
|
||||||
|
// Recreate NovelId index and FK
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Chapter_NovelId",
|
||||||
|
table: "Chapter",
|
||||||
|
column: "NovelId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Chapter_Novels_NovelId",
|
||||||
|
table: "Chapter",
|
||||||
|
column: "NovelId",
|
||||||
|
principalTable: "Novels",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
// Note: Volume LocalizationKeys are not cleaned up in Down migration
|
||||||
|
// as they may have been modified. Manual cleanup may be needed.
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Volume");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,9 +153,6 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
b.Property<Guid>("NameId")
|
b.Property<Guid>("NameId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<long?>("NovelId")
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
b.Property<long>("Order")
|
b.Property<long>("Order")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
@@ -165,13 +162,17 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
b.Property<string>("Url")
|
b.Property<string>("Url")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("VolumeId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("BodyId");
|
b.HasIndex("BodyId");
|
||||||
|
|
||||||
b.HasIndex("NameId");
|
b.HasIndex("NameId");
|
||||||
|
|
||||||
b.HasIndex("NovelId");
|
b.HasIndex("VolumeId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("Chapter");
|
b.ToTable("Chapter");
|
||||||
});
|
});
|
||||||
@@ -234,6 +235,9 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SourceId");
|
b.HasIndex("SourceId");
|
||||||
|
|
||||||
|
b.HasIndex("ExternalId", "SourceId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("Novels");
|
b.ToTable("Novels");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -354,6 +358,39 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
b.ToTable("TranslationEngines");
|
b.ToTable("TranslationEngines");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Volume", 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<Instant>("LastUpdatedTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("NameId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long>("NovelId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Order")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NameId");
|
||||||
|
|
||||||
|
b.HasIndex("NovelId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Volume");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("NovelNovelTag", b =>
|
modelBuilder.Entity("NovelNovelTag", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("NovelsId")
|
b.Property<long>("NovelsId")
|
||||||
@@ -424,13 +461,17 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", null)
|
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Volume", "Volume")
|
||||||
.WithMany("Chapters")
|
.WithMany("Chapters")
|
||||||
.HasForeignKey("NovelId");
|
.HasForeignKey("VolumeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Body");
|
b.Navigation("Body");
|
||||||
|
|
||||||
b.Navigation("Name");
|
b.Navigation("Name");
|
||||||
|
|
||||||
|
b.Navigation("Volume");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||||
@@ -502,6 +543,25 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
b.Navigation("Name");
|
b.Navigation("Name");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Volume", b =>
|
||||||
|
{
|
||||||
|
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("Volumes")
|
||||||
|
.HasForeignKey("NovelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Name");
|
||||||
|
|
||||||
|
b.Navigation("Novel");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("NovelNovelTag", b =>
|
modelBuilder.Entity("NovelNovelTag", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", null)
|
b.HasOne("FictionArchive.Service.NovelService.Models.Novels.Novel", null)
|
||||||
@@ -528,6 +588,11 @@ namespace FictionArchive.Service.NovelService.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Novel", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Volumes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FictionArchive.Service.NovelService.Models.Novels.Volume", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Chapters");
|
b.Navigation("Chapters");
|
||||||
});
|
});
|
||||||
|
|||||||
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,27 @@
|
|||||||
|
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; }
|
||||||
|
|
||||||
|
// Volume context
|
||||||
|
public uint VolumeId { get; init; }
|
||||||
|
public required string VolumeName { get; init; }
|
||||||
|
public int VolumeOrder { get; init; }
|
||||||
|
public int TotalChaptersInVolume { get; init; }
|
||||||
|
|
||||||
|
// Cross-volume navigation (VolumeOrder + ChapterOrder identify a chapter)
|
||||||
|
public int? PrevChapterVolumeOrder { get; init; }
|
||||||
|
public uint? PrevChapterOrder { get; init; }
|
||||||
|
public int? NextChapterVolumeOrder { 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<VolumeDto> Volumes { 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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace FictionArchive.Service.NovelService.Models.DTOs;
|
||||||
|
|
||||||
|
public class VolumeDto : BaseDto<uint>
|
||||||
|
{
|
||||||
|
public int Order { get; init; }
|
||||||
|
public required string Name { get; init; }
|
||||||
|
public required List<ChapterDto> Chapters { get; init; }
|
||||||
|
}
|
||||||
@@ -5,5 +5,6 @@ namespace FictionArchive.Service.NovelService.Models.IntegrationEvents;
|
|||||||
public class ChapterPullRequestedEvent : IIntegrationEvent
|
public class ChapterPullRequestedEvent : IIntegrationEvent
|
||||||
{
|
{
|
||||||
public uint NovelId { get; set; }
|
public uint NovelId { get; set; }
|
||||||
public uint ChapterNumber { get; set; }
|
public uint VolumeId { get; set; }
|
||||||
|
public uint ChapterOrder { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using FictionArchive.Service.NovelService.Models.Images;
|
using FictionArchive.Service.NovelService.Models.Images;
|
||||||
using FictionArchive.Service.NovelService.Models.Localization;
|
using FictionArchive.Service.NovelService.Models.Localization;
|
||||||
using FictionArchive.Service.Shared.Models;
|
using FictionArchive.Service.Shared.Models;
|
||||||
|
|
||||||
namespace FictionArchive.Service.NovelService.Models.Novels;
|
namespace FictionArchive.Service.NovelService.Models.Novels;
|
||||||
|
|
||||||
|
[Table("Chapter")]
|
||||||
public class Chapter : BaseEntity<uint>
|
public class Chapter : BaseEntity<uint>
|
||||||
{
|
{
|
||||||
public uint Revision { get; set; }
|
public uint Revision { get; set; }
|
||||||
@@ -15,4 +17,10 @@ public class Chapter : BaseEntity<uint>
|
|||||||
|
|
||||||
// Images appearing in this chapter.
|
// Images appearing in this chapter.
|
||||||
public List<Image> Images { get; set; }
|
public List<Image> Images { get; set; }
|
||||||
|
|
||||||
|
#region Navigation Properties
|
||||||
|
|
||||||
|
public Volume Volume { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ public class Novel : BaseEntity<uint>
|
|||||||
public LocalizationKey Name { get; set; }
|
public LocalizationKey Name { get; set; }
|
||||||
public LocalizationKey Description { get; set; }
|
public LocalizationKey Description { get; set; }
|
||||||
|
|
||||||
public List<Chapter> Chapters { get; set; }
|
public List<Volume> Volumes { get; set; }
|
||||||
public List<NovelTag> Tags { get; set; }
|
public List<NovelTag> Tags { get; set; }
|
||||||
public Image? CoverImage { get; set; }
|
public Image? CoverImage { get; set; }
|
||||||
}
|
}
|
||||||
24
FictionArchive.Service.NovelService/Models/Novels/Volume.cs
Normal file
24
FictionArchive.Service.NovelService/Models/Novels/Volume.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using FictionArchive.Service.NovelService.Models.Localization;
|
||||||
|
using FictionArchive.Service.Shared.Models;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.NovelService.Models.Novels;
|
||||||
|
|
||||||
|
[Table("Volume")]
|
||||||
|
public class Volume : BaseEntity<uint>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Signed int to allow special ordering like -1 for "Author Notes" at top.
|
||||||
|
/// </summary>
|
||||||
|
public int Order { get; set; }
|
||||||
|
|
||||||
|
public LocalizationKey Name { get; set; }
|
||||||
|
|
||||||
|
public List<Chapter> Chapters { get; set; }
|
||||||
|
|
||||||
|
#region Navigation Properties
|
||||||
|
|
||||||
|
public Novel Novel { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ public class NovelMetadata
|
|||||||
public Language RawLanguage { get; set; }
|
public Language RawLanguage { get; set; }
|
||||||
public NovelStatus RawStatus { get; set; }
|
public NovelStatus RawStatus { get; set; }
|
||||||
|
|
||||||
public List<ChapterMetadata> Chapters { get; set; }
|
public List<VolumeMetadata> Volumes { get; set; }
|
||||||
public List<string> SourceTags { get; set; }
|
public List<string> SourceTags { get; set; }
|
||||||
public List<string> SystemTags { get; set; }
|
public List<string> SystemTags { get; set; }
|
||||||
public SourceDescriptor SourceDescriptor { get; set; }
|
public SourceDescriptor SourceDescriptor { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace FictionArchive.Service.NovelService.Models.SourceAdapters;
|
||||||
|
|
||||||
|
public class VolumeMetadata
|
||||||
|
{
|
||||||
|
public int Order { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public List<ChapterMetadata> Chapters { get; set; }
|
||||||
|
}
|
||||||
@@ -62,12 +62,14 @@ public class Program
|
|||||||
builder.Services.AddHttpClient<NovelpiaAuthMessageHandler>(client =>
|
builder.Services.AddHttpClient<NovelpiaAuthMessageHandler>(client =>
|
||||||
{
|
{
|
||||||
client.BaseAddress = new Uri("https://novelpia.com");
|
client.BaseAddress = new Uri("https://novelpia.com");
|
||||||
});
|
})
|
||||||
|
.AddStandardResilienceHandler();
|
||||||
builder.Services.AddHttpClient<ISourceAdapter, NovelpiaAdapter>(client =>
|
builder.Services.AddHttpClient<ISourceAdapter, NovelpiaAdapter>(client =>
|
||||||
{
|
{
|
||||||
client.BaseAddress = new Uri("https://novelpia.com");
|
client.BaseAddress = new Uri("https://novelpia.com");
|
||||||
})
|
})
|
||||||
.AddHttpMessageHandler<NovelpiaAuthMessageHandler>();
|
.AddHttpMessageHandler<NovelpiaAuthMessageHandler>()
|
||||||
|
.AddStandardResilienceHandler();
|
||||||
|
|
||||||
builder.Services.Configure<NovelUpdateServiceConfiguration>(builder.Configuration.GetSection("UpdateService"));
|
builder.Services.Configure<NovelUpdateServiceConfiguration>(builder.Configuration.GetSection("UpdateService"));
|
||||||
builder.Services.AddTransient<NovelUpdateService>();
|
builder.Services.AddTransient<NovelUpdateService>();
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ public class ChapterPullRequestedEventHandler : IIntegrationEventHandler<Chapter
|
|||||||
|
|
||||||
public async Task Handle(ChapterPullRequestedEvent @event)
|
public async Task Handle(ChapterPullRequestedEvent @event)
|
||||||
{
|
{
|
||||||
await _novelUpdateService.PullChapterContents(@event.NovelId, @event.ChapterNumber);
|
await _novelUpdateService.PullChapterContents(@event.NovelId, @event.VolumeId, @event.ChapterOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,10 +10,31 @@ public class NovelServiceDbContext(DbContextOptions options, ILogger<NovelServic
|
|||||||
: FictionArchiveDbContext(options, logger)
|
: FictionArchiveDbContext(options, logger)
|
||||||
{
|
{
|
||||||
public DbSet<Novel> Novels { get; set; }
|
public DbSet<Novel> Novels { get; set; }
|
||||||
|
public DbSet<Volume> Volumes { get; set; }
|
||||||
|
public DbSet<Chapter> Chapters { get; set; }
|
||||||
public DbSet<Source> Sources { get; set; }
|
public DbSet<Source> Sources { get; set; }
|
||||||
public DbSet<TranslationEngine> TranslationEngines { get; set; }
|
public DbSet<TranslationEngine> TranslationEngines { get; set; }
|
||||||
public DbSet<NovelTag> Tags { get; set; }
|
public DbSet<NovelTag> Tags { get; set; }
|
||||||
public DbSet<LocalizationKey> LocalizationKeys { get; set; }
|
public DbSet<LocalizationKey> LocalizationKeys { get; set; }
|
||||||
public DbSet<LocalizationRequest> LocalizationRequests { get; set; }
|
public DbSet<LocalizationRequest> LocalizationRequests { get; set; }
|
||||||
public DbSet<Image> Images { get; set; }
|
public DbSet<Image> Images { get; set; }
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Novel>()
|
||||||
|
.HasIndex("ExternalId", "SourceId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
// Volume.Order is unique per Novel
|
||||||
|
modelBuilder.Entity<Volume>()
|
||||||
|
.HasIndex("NovelId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
// Chapter.Order is unique per Volume
|
||||||
|
modelBuilder.Entity<Chapter>()
|
||||||
|
.HasIndex("VolumeId", "Order")
|
||||||
|
.IsUnique();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using FictionArchive.Common.Enums;
|
||||||
using FictionArchive.Service.FileService.IntegrationEvents;
|
using FictionArchive.Service.FileService.IntegrationEvents;
|
||||||
using FictionArchive.Service.NovelService.Models.Configuration;
|
using FictionArchive.Service.NovelService.Models.Configuration;
|
||||||
using FictionArchive.Service.NovelService.Models.Enums;
|
using FictionArchive.Service.NovelService.Models.Enums;
|
||||||
@@ -31,14 +32,283 @@ public class NovelUpdateService
|
|||||||
_novelUpdateServiceConfiguration = novelUpdateServiceConfiguration.Value;
|
_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 List<Volume> SynchronizeVolumes(
|
||||||
|
List<VolumeMetadata> metadataVolumes,
|
||||||
|
Language rawLanguage,
|
||||||
|
List<Volume>? existingVolumes)
|
||||||
|
{
|
||||||
|
existingVolumes ??= new List<Volume>();
|
||||||
|
var result = new List<Volume>();
|
||||||
|
|
||||||
|
foreach (var metaVolume in metadataVolumes)
|
||||||
|
{
|
||||||
|
// Match volumes by Order (unique per novel)
|
||||||
|
var existingVolume = existingVolumes.FirstOrDefault(v => v.Order == metaVolume.Order);
|
||||||
|
|
||||||
|
if (existingVolume != null)
|
||||||
|
{
|
||||||
|
// Volume exists - sync its chapters
|
||||||
|
existingVolume.Chapters = SynchronizeChapters(
|
||||||
|
metaVolume.Chapters,
|
||||||
|
rawLanguage,
|
||||||
|
existingVolume.Chapters);
|
||||||
|
result.Add(existingVolume);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// New volume - create it with synced chapters
|
||||||
|
var newVolume = new Volume
|
||||||
|
{
|
||||||
|
Order = metaVolume.Order,
|
||||||
|
Name = LocalizationKey.CreateFromText(metaVolume.Name, rawLanguage),
|
||||||
|
Chapters = SynchronizeChapters(metaVolume.Chapters, rawLanguage, null)
|
||||||
|
};
|
||||||
|
result.Add(newVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep existing volumes not in metadata (user-created volumes)
|
||||||
|
var metaOrders = metadataVolumes.Select(v => v.Order).ToHashSet();
|
||||||
|
result.AddRange(existingVolumes.Where(v => !metaOrders.Contains(v.Order)));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 volumes = SynchronizeVolumes(metadata.Volumes, 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,
|
||||||
|
Volumes = volumes,
|
||||||
|
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)
|
public async Task<Novel> ImportNovel(string novelUrl)
|
||||||
{
|
{
|
||||||
|
// Step 1: Get metadata from source adapter
|
||||||
NovelMetadata? metadata = null;
|
NovelMetadata? metadata = null;
|
||||||
foreach (ISourceAdapter sourceAdapter in _sourceAdapters)
|
foreach (ISourceAdapter sourceAdapter in _sourceAdapters)
|
||||||
{
|
{
|
||||||
if (await sourceAdapter.CanProcessNovel(novelUrl))
|
if (await sourceAdapter.CanProcessNovel(novelUrl))
|
||||||
{
|
{
|
||||||
metadata = await sourceAdapter.GetMetadata(novelUrl);
|
metadata = await sourceAdapter.GetMetadata(novelUrl);
|
||||||
|
break; // Stop after finding adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,91 +317,138 @@ public class NovelUpdateService
|
|||||||
throw new NotSupportedException("The provided novel url is currently unsupported.");
|
throw new NotSupportedException("The provided novel url is currently unsupported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var systemTags = metadata.SystemTags.Select(tag => new NovelTag()
|
// Step 2: Resolve or create Source
|
||||||
{
|
var source = await GetOrCreateSource(metadata.SourceDescriptor);
|
||||||
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
|
|
||||||
});
|
|
||||||
|
|
||||||
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.Volumes)
|
||||||
|
.ThenInclude(volume => volume.Chapters)
|
||||||
|
.ThenInclude(chapter => chapter.Body)
|
||||||
|
.ThenInclude(localizationKey => localizationKey.Texts)
|
||||||
|
.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()
|
// CREATE PATH: New novel
|
||||||
{
|
novel = await CreateNewNovel(metadata, source);
|
||||||
Name = LocalizationKey.CreateFromText(metadata.AuthorName, metadata.RawLanguage),
|
shouldPublishCoverEvent = novel.CoverImage != null;
|
||||||
ExternalUrl = metadata.AuthorUrl,
|
}
|
||||||
},
|
else
|
||||||
RawLanguage = metadata.RawLanguage,
|
{
|
||||||
Url = metadata.Url,
|
// UPDATE PATH: Existing novel
|
||||||
ExternalId = metadata.ExternalId,
|
novel = existingNovel;
|
||||||
CoverImage = metadata.CoverImage != null ? new Image()
|
|
||||||
{
|
// Update author
|
||||||
OriginalPath = metadata.CoverImage.Url,
|
novel.Author = GetOrCreateAuthor(
|
||||||
} : null,
|
metadata.AuthorName,
|
||||||
Chapters = metadata.Chapters.Select(chapter =>
|
metadata.AuthorUrl,
|
||||||
{
|
metadata.RawLanguage,
|
||||||
return new Chapter()
|
existingNovel.Author);
|
||||||
{
|
|
||||||
Order = chapter.Order,
|
// Update metadata (Name, Description, RawStatus)
|
||||||
Url = chapter.Url,
|
UpdateNovelMetadata(novel, metadata);
|
||||||
Revision = chapter.Revision,
|
|
||||||
Name = LocalizationKey.CreateFromText(chapter.Name, metadata.RawLanguage),
|
// Synchronize tags (remove old, add new, reuse existing)
|
||||||
Body = new LocalizationKey()
|
novel.Tags = await SynchronizeTags(
|
||||||
{
|
metadata.SourceTags,
|
||||||
Texts = new List<LocalizationText>()
|
metadata.SystemTags,
|
||||||
}
|
metadata.RawLanguage);
|
||||||
};
|
|
||||||
}).ToList(),
|
// Synchronize volumes (and their chapters)
|
||||||
Description = LocalizationKey.CreateFromText(metadata.Description, metadata.RawLanguage),
|
novel.Volumes = SynchronizeVolumes(
|
||||||
Name = LocalizationKey.CreateFromText(metadata.Name, metadata.RawLanguage),
|
metadata.Volumes,
|
||||||
RawStatus = metadata.RawStatus,
|
metadata.RawLanguage,
|
||||||
Tags = sourceTags.Concat(systemTags).ToList(),
|
existingNovel.Volumes);
|
||||||
Source = new Source()
|
|
||||||
{
|
// Handle cover image
|
||||||
Name = metadata.SourceDescriptor.Name,
|
(novel.CoverImage, shouldPublishCoverEvent) = HandleCoverImage(
|
||||||
Url = metadata.SourceDescriptor.Url,
|
metadata.CoverImage,
|
||||||
Key = metadata.SourceDescriptor.Key,
|
existingNovel.CoverImage);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
// Signal request for cover image if present
|
// Publish cover image event if needed
|
||||||
if (addedNovel.Entity.CoverImage != null)
|
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,
|
FileData = metadata.CoverImage.Data,
|
||||||
FilePath = $"Novels/{addedNovel.Entity.Id}/Images/cover.jpg"
|
FilePath = $"Novels/{novel.Id}/Images/cover.jpg"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return addedNovel.Entity;
|
// Publish chapter pull events for chapters without body content
|
||||||
|
foreach (var volume in novel.Volumes)
|
||||||
|
{
|
||||||
|
var chaptersNeedingPull = volume.Chapters
|
||||||
|
.Where(c => c.Body?.Texts == null || !c.Body.Texts.Any())
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var chapter in chaptersNeedingPull)
|
||||||
|
{
|
||||||
|
await _eventBus.Publish(new ChapterPullRequestedEvent
|
||||||
|
{
|
||||||
|
NovelId = novel.Id,
|
||||||
|
VolumeId = volume.Id,
|
||||||
|
ChapterOrder = chapter.Order
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Chapter> PullChapterContents(uint novelId, uint chapterNumber)
|
public async Task<Chapter> PullChapterContents(uint novelId, uint volumeId, uint chapterOrder)
|
||||||
{
|
{
|
||||||
var novel = await _dbContext.Novels.Where(novel => novel.Id == novelId)
|
var novel = await _dbContext.Novels.Where(novel => novel.Id == novelId)
|
||||||
.Include(novel => novel.Chapters)
|
.Include(novel => novel.Volumes)
|
||||||
|
.ThenInclude(volume => volume.Chapters)
|
||||||
.ThenInclude(chapter => chapter.Body)
|
.ThenInclude(chapter => chapter.Body)
|
||||||
.ThenInclude(body => body.Texts)
|
.ThenInclude(body => body.Texts)
|
||||||
.Include(novel => novel.Source).Include(novel => novel.Chapters).ThenInclude(chapter => chapter.Images)
|
.Include(novel => novel.Source)
|
||||||
|
.Include(novel => novel.Volumes)
|
||||||
|
.ThenInclude(volume => volume.Chapters)
|
||||||
|
.ThenInclude(chapter => chapter.Images)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
var chapter = novel.Chapters.Where(chapter => chapter.Order == chapterNumber).FirstOrDefault();
|
var volume = novel.Volumes.FirstOrDefault(v => v.Id == volumeId);
|
||||||
|
var chapter = volume.Chapters.FirstOrDefault(c => c.Order == chapterOrder);
|
||||||
var adapter = _sourceAdapters.FirstOrDefault(adapter => adapter.SourceDescriptor.Key == novel.Source.Key);
|
var adapter = _sourceAdapters.FirstOrDefault(adapter => adapter.SourceDescriptor.Key == novel.Source.Key);
|
||||||
var rawChapter = await adapter.GetRawChapter(chapter.Url);
|
var rawChapter = await adapter.GetRawChapter(chapter.Url);
|
||||||
var localizationText = new LocalizationText()
|
|
||||||
|
// If we already have the raw for this, overwrite it for now. Revisions will come later.
|
||||||
|
var localizationText = chapter.Body.Texts.FirstOrDefault(text => text.Language == novel.RawLanguage);
|
||||||
|
if (localizationText == null)
|
||||||
{
|
{
|
||||||
Text = rawChapter.Text,
|
localizationText = new LocalizationText()
|
||||||
Language = novel.RawLanguage
|
{
|
||||||
};
|
Text = rawChapter.Text,
|
||||||
chapter.Body.Texts.Add(localizationText);
|
Language = novel.RawLanguage
|
||||||
|
};
|
||||||
|
chapter.Body.Texts.Add(localizationText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localizationText.Text = rawChapter.Text;
|
||||||
|
}
|
||||||
|
|
||||||
chapter.Images = rawChapter.ImageData.Select(img => new Image()
|
chapter.Images = rawChapter.ImageData.Select(img => new Image()
|
||||||
{
|
{
|
||||||
OriginalPath = img.Url
|
OriginalPath = img.Url
|
||||||
@@ -196,6 +513,7 @@ public class NovelUpdateService
|
|||||||
if (match != null)
|
if (match != null)
|
||||||
{
|
{
|
||||||
match.Attributes["src"].Value = newUrl;
|
match.Attributes["src"].Value = newUrl;
|
||||||
|
bodyText.Text = chapterDoc.DocumentNode.OuterHtml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,14 +531,72 @@ public class NovelUpdateService
|
|||||||
return importNovelRequestEvent;
|
return importNovelRequestEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ChapterPullRequestedEvent> QueueChapterPull(uint novelId, uint chapterNumber)
|
public async Task<ChapterPullRequestedEvent> QueueChapterPull(uint novelId, uint volumeId, uint chapterOrder)
|
||||||
{
|
{
|
||||||
var chapterPullEvent = new ChapterPullRequestedEvent()
|
var chapterPullEvent = new ChapterPullRequestedEvent()
|
||||||
{
|
{
|
||||||
NovelId = novelId,
|
NovelId = novelId,
|
||||||
ChapterNumber = chapterNumber
|
VolumeId = volumeId,
|
||||||
|
ChapterOrder = chapterOrder
|
||||||
};
|
};
|
||||||
await _eventBus.Publish(chapterPullEvent);
|
await _eventBus.Publish(chapterPullEvent);
|
||||||
return chapterPullEvent;
|
return chapterPullEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteNovel(uint novelId)
|
||||||
|
{
|
||||||
|
var novel = await _dbContext.Novels
|
||||||
|
.Include(n => n.CoverImage)
|
||||||
|
.Include(n => n.Name).ThenInclude(k => k.Texts)
|
||||||
|
.Include(n => n.Description).ThenInclude(k => k.Texts)
|
||||||
|
.Include(n => n.Volumes).ThenInclude(v => v.Name).ThenInclude(k => k.Texts)
|
||||||
|
.Include(n => n.Volumes).ThenInclude(v => v.Chapters).ThenInclude(c => c.Images)
|
||||||
|
.Include(n => n.Volumes).ThenInclude(v => v.Chapters).ThenInclude(c => c.Name).ThenInclude(k => k.Texts)
|
||||||
|
.Include(n => n.Volumes).ThenInclude(v => v.Chapters).ThenInclude(c => c.Body).ThenInclude(k => k.Texts)
|
||||||
|
.FirstOrDefaultAsync(n => n.Id == novelId);
|
||||||
|
|
||||||
|
if (novel == null)
|
||||||
|
throw new KeyNotFoundException($"Novel with ID '{novelId}' not found");
|
||||||
|
|
||||||
|
// Collect all LocalizationKey IDs for cleanup
|
||||||
|
var locKeyIds = new List<Guid> { novel.Name.Id, novel.Description.Id };
|
||||||
|
foreach (var volume in novel.Volumes)
|
||||||
|
{
|
||||||
|
locKeyIds.Add(volume.Name.Id);
|
||||||
|
locKeyIds.AddRange(volume.Chapters.Select(c => c.Name.Id));
|
||||||
|
locKeyIds.AddRange(volume.Chapters.Select(c => c.Body.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Remove LocalizationRequests referencing these keys
|
||||||
|
var locRequests = await _dbContext.LocalizationRequests
|
||||||
|
.Where(r => locKeyIds.Contains(r.KeyRequestedForTranslation.Id))
|
||||||
|
.ToListAsync();
|
||||||
|
_dbContext.LocalizationRequests.RemoveRange(locRequests);
|
||||||
|
|
||||||
|
// 2. Remove LocalizationTexts (NO ACTION FK - won't cascade)
|
||||||
|
_dbContext.RemoveRange(novel.Name.Texts);
|
||||||
|
_dbContext.RemoveRange(novel.Description.Texts);
|
||||||
|
foreach (var volume in novel.Volumes)
|
||||||
|
{
|
||||||
|
_dbContext.RemoveRange(volume.Name.Texts);
|
||||||
|
foreach (var chapter in volume.Chapters)
|
||||||
|
{
|
||||||
|
_dbContext.RemoveRange(chapter.Name.Texts);
|
||||||
|
_dbContext.RemoveRange(chapter.Body.Texts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Remove Images (NO ACTION FK - won't cascade)
|
||||||
|
if (novel.CoverImage != null)
|
||||||
|
_dbContext.Images.Remove(novel.CoverImage);
|
||||||
|
foreach (var volume in novel.Volumes)
|
||||||
|
{
|
||||||
|
foreach (var chapter in volume.Chapters)
|
||||||
|
_dbContext.Images.RemoveRange(chapter.Images);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Remove novel - cascades: volumes, chapters, localization keys, tag mappings
|
||||||
|
_dbContext.Novels.Remove(novel);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class NovelpiaAdapter : ISourceAdapter
|
|||||||
ExternalId = novelId.ToString(),
|
ExternalId = novelId.ToString(),
|
||||||
SystemTags = new List<string>(),
|
SystemTags = new List<string>(),
|
||||||
SourceTags = new List<string>(),
|
SourceTags = new List<string>(),
|
||||||
Chapters = new List<ChapterMetadata>(),
|
Volumes = new List<VolumeMetadata>(),
|
||||||
SourceDescriptor = SourceDescriptor
|
SourceDescriptor = SourceDescriptor
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -132,16 +132,17 @@ public class NovelpiaAdapter : ISourceAdapter
|
|||||||
{
|
{
|
||||||
novel.SourceTags.Add(tag);
|
novel.SourceTags.Add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Author's posts (from notice_table in the page HTML)
|
||||||
|
var authorsPosts = ParseAuthorsPosts(novelData);
|
||||||
|
|
||||||
// Chapters
|
// Chapters
|
||||||
uint page = 0;
|
uint page = 0;
|
||||||
List<ChapterMetadata> chapters = new List<ChapterMetadata>();
|
List<ChapterMetadata> chapters = new List<ChapterMetadata>();
|
||||||
List<uint> seenChapterIds = new List<uint>();
|
List<uint> seenChapterIds = new List<uint>();
|
||||||
uint chapterOrder = 0;
|
uint chapterOrder = 1;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await Task.Delay(500);
|
|
||||||
_logger.LogInformation("Next chapter batch");
|
|
||||||
var response = await _httpClient.PostAsync(EpisodeListEndpoint, new FormUrlEncodedContent(new Dictionary<string, string>
|
var response = await _httpClient.PostAsync(EpisodeListEndpoint, new FormUrlEncodedContent(new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{"novel_no", novelId.ToString()},
|
{"novel_no", novelId.ToString()},
|
||||||
@@ -170,8 +171,26 @@ public class NovelpiaAdapter : ISourceAdapter
|
|||||||
}
|
}
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
novel.Chapters = chapters;
|
|
||||||
|
// Add Author's Posts volume if there are any
|
||||||
|
if (authorsPosts.Count > 0)
|
||||||
|
{
|
||||||
|
novel.Volumes.Add(new VolumeMetadata
|
||||||
|
{
|
||||||
|
Order = 0,
|
||||||
|
Name = "Author's Posts",
|
||||||
|
Chapters = authorsPosts
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main Story volume
|
||||||
|
novel.Volumes.Add(new VolumeMetadata
|
||||||
|
{
|
||||||
|
Order = 1,
|
||||||
|
Name = "Main Story",
|
||||||
|
Chapters = chapters
|
||||||
|
});
|
||||||
|
|
||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,4 +262,40 @@ public class NovelpiaAdapter : ISourceAdapter
|
|||||||
}
|
}
|
||||||
return await image.Content.ReadAsByteArrayAsync();
|
return await image.Content.ReadAsByteArrayAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ChapterMetadata> ParseAuthorsPosts(string novelHtml)
|
||||||
|
{
|
||||||
|
var posts = new List<ChapterMetadata>();
|
||||||
|
|
||||||
|
// Find the notice_table section
|
||||||
|
var noticeTableMatch = Regex.Match(novelHtml,
|
||||||
|
@"(?s)<table[^>]*class=""notice_table[^""]*""[^>]*>(.*?)</table>");
|
||||||
|
if (!noticeTableMatch.Success)
|
||||||
|
return posts;
|
||||||
|
|
||||||
|
var tableContent = noticeTableMatch.Groups[1].Value;
|
||||||
|
|
||||||
|
// Find all td elements with onclick containing viewer URL and extract title from <b>
|
||||||
|
// HTML structure: <td ... onclick="...location='/viewer/3330612';"><b>Title</b>
|
||||||
|
var postMatches = Regex.Matches(tableContent,
|
||||||
|
@"onclick=""[^""]*location='/viewer/(\d+)'[^""]*""[^>]*><b>([^<]+)</b>");
|
||||||
|
|
||||||
|
uint order = 1;
|
||||||
|
foreach (Match match in postMatches)
|
||||||
|
{
|
||||||
|
string viewerId = match.Groups[1].Value;
|
||||||
|
string title = WebUtility.HtmlDecode(match.Groups[2].Value.Trim());
|
||||||
|
|
||||||
|
posts.Add(new ChapterMetadata
|
||||||
|
{
|
||||||
|
Revision = 0,
|
||||||
|
Order = order,
|
||||||
|
Url = $"https://novelpia.com/viewer/{viewerId}",
|
||||||
|
Name = title
|
||||||
|
});
|
||||||
|
order++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using FictionArchive.Service.Shared.Constants;
|
using FictionArchive.Service.Shared.Constants;
|
||||||
using FictionArchive.Service.Shared.Models.Authentication;
|
using FictionArchive.Service.Shared.Models.Authentication;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace FictionArchive.Service.Shared.Extensions;
|
namespace FictionArchive.Service.Shared.Extensions;
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ public static class AuthenticationExtensions
|
|||||||
|
|
||||||
logger.LogDebug(
|
logger.LogDebug(
|
||||||
"JWT token validated for subject: {Subject}",
|
"JWT token validated for subject: {Subject}",
|
||||||
context.Principal?.FindFirst("sub")?.Value ?? "unknown");
|
context.Principal?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? "unknown");
|
||||||
|
|
||||||
return existingEvents?.OnTokenValidated?.Invoke(context) ?? Task.CompletedTask;
|
return existingEvents?.OnTokenValidated?.Invoke(context) ?? Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public static class GraphQLExtensions
|
|||||||
.AddErrorFilter<LoggingErrorFilter>()
|
.AddErrorFilter<LoggingErrorFilter>()
|
||||||
.AddType<UnsignedIntType>()
|
.AddType<UnsignedIntType>()
|
||||||
.AddType<InstantType>()
|
.AddType<InstantType>()
|
||||||
|
.ModifyCostOptions(opt => opt.MaxFieldCost = 10000)
|
||||||
.AddMutationConventions(applyToAllMutations: true)
|
.AddMutationConventions(applyToAllMutations: true)
|
||||||
.AddFiltering(opt => opt.AddDefaults().BindRuntimeType<uint, UnsignedIntOperationFilterInputType>())
|
.AddFiltering(opt => opt.AddDefaults().BindRuntimeType<uint, UnsignedIntOperationFilterInputType>())
|
||||||
.AddSorting()
|
.AddSorting()
|
||||||
|
|||||||
@@ -25,10 +25,12 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.2.0" />
|
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.2.0" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
||||||
|
<PackageReference Include="Polly" Version="8.6.5" />
|
||||||
<PackageReference Include="RabbitMQ.Client" Version="7.2.0" />
|
<PackageReference Include="RabbitMQ.Client" Version="7.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class RabbitMQEventBus : IEventBus, IHostedService
|
|||||||
await channel.ExchangeDeclareAsync(ExchangeName, ExchangeType.Direct,
|
await channel.ExchangeDeclareAsync(ExchangeName, ExchangeType.Direct,
|
||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
await channel.BasicQosAsync(prefetchSize: 0, prefetchCount: 1, global: false, cancellationToken: cancellationToken);
|
||||||
await channel.QueueDeclareAsync(_options.ClientIdentifier, true, false, false,
|
await channel.QueueDeclareAsync(_options.ClientIdentifier, true, false, false,
|
||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using FictionArchive.Service.TranslationService.Models;
|
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.Database;
|
||||||
using FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
using FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using HotChocolate.Data;
|
||||||
|
|
||||||
namespace FictionArchive.Service.TranslationService.GraphQL;
|
namespace FictionArchive.Service.TranslationService.GraphQL;
|
||||||
|
|
||||||
@@ -22,8 +22,20 @@ public class Query
|
|||||||
[UseProjection]
|
[UseProjection]
|
||||||
[UseFiltering]
|
[UseFiltering]
|
||||||
[UseSorting]
|
[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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||||
|
<PackageReference Include="NSubstitute" Version="5.1.0" />
|
||||||
|
<PackageReference Include="xunit" Version="2.9.2" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FictionArchive.Service.UserService\FictionArchive.Service.UserService.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,329 @@
|
|||||||
|
using FictionArchive.Service.Shared.Services.EventBus;
|
||||||
|
using FictionArchive.Service.UserService.Models.Database;
|
||||||
|
using FictionArchive.Service.UserService.Services;
|
||||||
|
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||||
|
using FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
using NSubstitute;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Tests;
|
||||||
|
|
||||||
|
public class UserManagementServiceTests
|
||||||
|
{
|
||||||
|
#region Helper Methods
|
||||||
|
|
||||||
|
private static UserServiceDbContext CreateDbContext()
|
||||||
|
{
|
||||||
|
var options = new DbContextOptionsBuilder<UserServiceDbContext>()
|
||||||
|
.UseInMemoryDatabase($"UserManagementServiceTests-{Guid.NewGuid()}")
|
||||||
|
.Options;
|
||||||
|
|
||||||
|
return new UserServiceDbContext(options, NullLogger<UserServiceDbContext>.Instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UserManagementService CreateService(
|
||||||
|
UserServiceDbContext dbContext,
|
||||||
|
IAuthenticationServiceClient authClient,
|
||||||
|
IEventBus? eventBus = null)
|
||||||
|
{
|
||||||
|
return new UserManagementService(
|
||||||
|
dbContext,
|
||||||
|
NullLogger<UserManagementService>.Instance,
|
||||||
|
authClient,
|
||||||
|
eventBus ?? Substitute.For<IEventBus>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static User CreateTestUser(string username, string email, int availableInvites = 5)
|
||||||
|
{
|
||||||
|
return new User
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
Email = email,
|
||||||
|
OAuthProviderId = Guid.NewGuid().ToString(),
|
||||||
|
Disabled = false,
|
||||||
|
AvailableInvites = availableInvites
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region InviteUserAsync Tests
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WithValidInviter_CreatesUserAndDecrementsInvites()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 3);
|
||||||
|
dbContext.Users.Add(inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
authClient.CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
|
||||||
|
.Returns(new AuthentikUserResponse { Pk = 123, Uid = "authentik-uid-456" });
|
||||||
|
authClient.SendRecoveryEmailAsync(Arg.Any<int>()).Returns(true);
|
||||||
|
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "new@test.com", "newuser");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result!.Username.Should().Be("newuser");
|
||||||
|
result.Email.Should().Be("new@test.com");
|
||||||
|
result.InviterId.Should().Be(inviter.Id);
|
||||||
|
result.AvailableInvites.Should().Be(0);
|
||||||
|
inviter.AvailableInvites.Should().Be(2);
|
||||||
|
|
||||||
|
await authClient.Received(1).CreateUserAsync("newuser", "new@test.com", "newuser");
|
||||||
|
await authClient.Received(1).SendRecoveryEmailAsync(123);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WithNoAvailableInvites_ReturnsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 0);
|
||||||
|
dbContext.Users.Add(inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "new@test.com", "newuser");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeNull();
|
||||||
|
await authClient.DidNotReceive().CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WithDuplicateEmail_ReturnsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var existingUser = CreateTestUser("existing", "existing@test.com");
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 3);
|
||||||
|
dbContext.Users.AddRange(existingUser, inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "existing@test.com", "newuser");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeNull();
|
||||||
|
await authClient.DidNotReceive().CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
|
||||||
|
inviter.AvailableInvites.Should().Be(3); // Not decremented
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WithDuplicateUsername_ReturnsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var existingUser = CreateTestUser("existinguser", "existing@test.com");
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 3);
|
||||||
|
dbContext.Users.AddRange(existingUser, inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "new@test.com", "existinguser");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeNull();
|
||||||
|
await authClient.DidNotReceive().CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
|
||||||
|
inviter.AvailableInvites.Should().Be(3); // Not decremented
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WhenAuthentikFails_ReturnsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 3);
|
||||||
|
dbContext.Users.Add(inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
authClient.CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
|
||||||
|
.Returns((AuthentikUserResponse?)null);
|
||||||
|
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "new@test.com", "newuser");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeNull();
|
||||||
|
await authClient.DidNotReceive().SendRecoveryEmailAsync(Arg.Any<int>());
|
||||||
|
|
||||||
|
// Verify no user was added to the database
|
||||||
|
var usersInDb = await dbContext.Users.ToListAsync();
|
||||||
|
usersInDb.Should().HaveCount(1); // Only the inviter
|
||||||
|
inviter.AvailableInvites.Should().Be(3); // Not decremented
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_WhenRecoveryEmailFails_StillCreatesUser()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 3);
|
||||||
|
dbContext.Users.Add(inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
authClient.CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
|
||||||
|
.Returns(new AuthentikUserResponse { Pk = 123, Uid = "authentik-uid-456" });
|
||||||
|
authClient.SendRecoveryEmailAsync(Arg.Any<int>()).Returns(false); // Email fails
|
||||||
|
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "new@test.com", "newuser");
|
||||||
|
|
||||||
|
// Assert - User should still be created despite email failure
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result!.Username.Should().Be("newuser");
|
||||||
|
inviter.AvailableInvites.Should().Be(2);
|
||||||
|
|
||||||
|
// Verify user was added to database
|
||||||
|
var usersInDb = await dbContext.Users.ToListAsync();
|
||||||
|
usersInDb.Should().HaveCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task InviteUserAsync_SetsCorrectUserProperties()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var inviter = CreateTestUser("inviter", "inviter@test.com", availableInvites: 5);
|
||||||
|
dbContext.Users.Add(inviter);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authentikUid = "authentik-uid-789";
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
authClient.CreateUserAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
|
||||||
|
.Returns(new AuthentikUserResponse { Pk = 456, Uid = authentikUid });
|
||||||
|
authClient.SendRecoveryEmailAsync(Arg.Any<int>()).Returns(true);
|
||||||
|
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.InviteUserAsync(inviter, "newuser@test.com", "newusername");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result!.Username.Should().Be("newusername");
|
||||||
|
result.Email.Should().Be("newuser@test.com");
|
||||||
|
result.OAuthProviderId.Should().Be(authentikUid);
|
||||||
|
result.InviterId.Should().Be(inviter.Id);
|
||||||
|
result.AvailableInvites.Should().Be(0);
|
||||||
|
result.Disabled.Should().BeFalse();
|
||||||
|
result.Id.Should().NotBeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetUserByOAuthProviderIdAsync Tests
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetUserByOAuthProviderIdAsync_WithExistingUser_ReturnsUser()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var oAuthProviderId = "oauth-provider-123";
|
||||||
|
var user = new User
|
||||||
|
{
|
||||||
|
Username = "testuser",
|
||||||
|
Email = "test@test.com",
|
||||||
|
OAuthProviderId = oAuthProviderId,
|
||||||
|
Disabled = false,
|
||||||
|
AvailableInvites = 5
|
||||||
|
};
|
||||||
|
dbContext.Users.Add(user);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.GetUserByOAuthProviderIdAsync(oAuthProviderId);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result!.Id.Should().Be(user.Id);
|
||||||
|
result.Username.Should().Be("testuser");
|
||||||
|
result.OAuthProviderId.Should().Be(oAuthProviderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetUserByOAuthProviderIdAsync_WithNonExistingUser_ReturnsNull()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.GetUserByOAuthProviderIdAsync("non-existing-id");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GetUsers Tests
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetUsers_ReturnsAllUsers()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var user1 = CreateTestUser("user1", "user1@test.com");
|
||||||
|
var user2 = CreateTestUser("user2", "user2@test.com");
|
||||||
|
var user3 = CreateTestUser("user3", "user3@test.com");
|
||||||
|
dbContext.Users.AddRange(user1, user2, user3);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.GetUsers().ToListAsync();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().HaveCount(3);
|
||||||
|
result.Select(u => u.Username).Should().BeEquivalentTo(new[] { "user1", "user2", "user3" });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetUsers_WithEmptyDb_ReturnsEmptyQueryable()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var dbContext = CreateDbContext();
|
||||||
|
var authClient = Substitute.For<IAuthenticationServiceClient>();
|
||||||
|
var service = CreateService(dbContext, authClient);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await service.GetUsers().ToListAsync();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -22,6 +22,12 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Models\IntegrationEvents\" />
|
||||||
|
<Folder Include="Services\EventHandlers\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,16 +1,53 @@
|
|||||||
using FictionArchive.Service.Shared.Constants;
|
using System.Security.Claims;
|
||||||
using FictionArchive.Service.UserService.Models.Database;
|
using FictionArchive.Service.UserService.Models.DTOs;
|
||||||
using FictionArchive.Service.UserService.Services;
|
using FictionArchive.Service.UserService.Services;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
|
using HotChocolate.Types;
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService.GraphQL;
|
namespace FictionArchive.Service.UserService.GraphQL;
|
||||||
|
|
||||||
public class Mutation
|
public class Mutation
|
||||||
{
|
{
|
||||||
[Authorize(Roles = [AuthorizationConstants.Roles.Admin])]
|
[Authorize]
|
||||||
public async Task<User> RegisterUser(string username, string email, string oAuthProviderId,
|
[Error<InvalidOperationException>]
|
||||||
string? inviterOAuthProviderId, UserManagementService userManagementService)
|
public async Task<UserDto> InviteUser(
|
||||||
|
string email,
|
||||||
|
string username,
|
||||||
|
UserManagementService userManagementService,
|
||||||
|
ClaimsPrincipal claimsPrincipal)
|
||||||
{
|
{
|
||||||
return await userManagementService.RegisterUser(username, email, oAuthProviderId, inviterOAuthProviderId);
|
// Get the current user's OAuth provider ID from claims
|
||||||
|
var oAuthProviderId = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
if (string.IsNullOrEmpty(oAuthProviderId))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Unable to determine current user identity");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the inviter from the database
|
||||||
|
var inviter = await userManagementService.GetUserByOAuthProviderIdAsync(oAuthProviderId);
|
||||||
|
if (inviter == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Current user not found in the system");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invite the new user
|
||||||
|
var newUser = await userManagementService.InviteUserAsync(inviter, email, username);
|
||||||
|
if (newUser == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Failed to invite user. Either you have no available invites, or the email/username is already in use.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserDto
|
||||||
|
{
|
||||||
|
Id = newUser.Id,
|
||||||
|
CreatedTime = newUser.CreatedTime,
|
||||||
|
LastUpdatedTime = newUser.LastUpdatedTime,
|
||||||
|
Username = newUser.Username,
|
||||||
|
Email = newUser.Email,
|
||||||
|
Disabled = newUser.Disabled,
|
||||||
|
AvailableInvites = newUser.AvailableInvites,
|
||||||
|
InviterId = newUser.InviterId
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,43 @@
|
|||||||
using FictionArchive.Service.UserService.Models.Database;
|
using System.Security.Claims;
|
||||||
|
using FictionArchive.Service.UserService.Models.DTOs;
|
||||||
using FictionArchive.Service.UserService.Services;
|
using FictionArchive.Service.UserService.Services;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
|
using HotChocolate.Data;
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService.GraphQL;
|
namespace FictionArchive.Service.UserService.GraphQL;
|
||||||
|
|
||||||
public class Query
|
public class Query
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IQueryable<User>> GetUsers(UserManagementService userManagementService)
|
[UseProjection]
|
||||||
|
[UseFirstOrDefault]
|
||||||
|
public IQueryable<UserDto> GetCurrentUser(
|
||||||
|
UserServiceDbContext dbContext,
|
||||||
|
ClaimsPrincipal claimsPrincipal)
|
||||||
{
|
{
|
||||||
return userManagementService.GetUsers();
|
var oAuthProviderId = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
if (string.IsNullOrEmpty(oAuthProviderId))
|
||||||
|
{
|
||||||
|
return Enumerable.Empty<UserDto>().AsQueryable();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dbContext.Users
|
||||||
|
.Where(u => u.OAuthProviderId == oAuthProviderId)
|
||||||
|
.Select(u => new UserDto
|
||||||
|
{
|
||||||
|
Id = u.Id,
|
||||||
|
CreatedTime = u.CreatedTime,
|
||||||
|
LastUpdatedTime = u.LastUpdatedTime,
|
||||||
|
Username = u.Username,
|
||||||
|
Email = u.Email,
|
||||||
|
Disabled = u.Disabled,
|
||||||
|
AvailableInvites = u.AvailableInvites,
|
||||||
|
InviterId = u.InviterId,
|
||||||
|
InvitedUsers = u.InvitedUsers.Select(iu => new InvitedUserDto
|
||||||
|
{
|
||||||
|
Username = iu.Username,
|
||||||
|
Email = iu.Email
|
||||||
|
}).ToList()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
83
FictionArchive.Service.UserService/Migrations/20251229151921_AddAvailableInvites.Designer.cs
generated
Normal file
83
FictionArchive.Service.UserService/Migrations/20251229151921_AddAvailableInvites.Designer.cs
generated
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FictionArchive.Service.UserService.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.UserService.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(UserServiceDbContext))]
|
||||||
|
[Migration("20251229151921_AddAvailableInvites")]
|
||||||
|
partial class AddAvailableInvites
|
||||||
|
{
|
||||||
|
/// <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.UserService.Models.Database.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("AvailableInvites")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Instant>("CreatedTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Disabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("InviterId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Instant>("LastUpdatedTime")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("OAuthProviderId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("InviterId");
|
||||||
|
|
||||||
|
b.HasIndex("OAuthProviderId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FictionArchive.Service.UserService.Models.Database.User", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FictionArchive.Service.UserService.Models.Database.User", "Inviter")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InviterId");
|
||||||
|
|
||||||
|
b.Navigation("Inviter");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddAvailableInvites : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "AvailableInvites",
|
||||||
|
table: "Users",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AvailableInvites",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ namespace FictionArchive.Service.UserService.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("AvailableInvites")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<Instant>("CreatedTime")
|
b.Property<Instant>("CreatedTime")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace FictionArchive.Service.UserService.Models.DTOs;
|
||||||
|
|
||||||
|
public class InvitedUserDto
|
||||||
|
{
|
||||||
|
public required string Username { get; init; }
|
||||||
|
public required string Email { get; init; }
|
||||||
|
}
|
||||||
17
FictionArchive.Service.UserService/Models/DTOs/UserDto.cs
Normal file
17
FictionArchive.Service.UserService/Models/DTOs/UserDto.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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; }
|
||||||
|
public bool Disabled { get; init; }
|
||||||
|
public int AvailableInvites { get; init; }
|
||||||
|
public Guid? InviterId { get; init; }
|
||||||
|
public List<InvitedUserDto>? InvitedUsers { get; init; }
|
||||||
|
}
|
||||||
@@ -6,15 +6,14 @@ namespace FictionArchive.Service.UserService.Models.Database;
|
|||||||
[Index(nameof(OAuthProviderId), IsUnique = true)]
|
[Index(nameof(OAuthProviderId), IsUnique = true)]
|
||||||
public class User : BaseEntity<Guid>
|
public class User : BaseEntity<Guid>
|
||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public required string Username { get; set; }
|
||||||
public string Email { get; set; }
|
public required string Email { get; set; }
|
||||||
public string OAuthProviderId { get; set; }
|
public required string OAuthProviderId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public bool Disabled { get; set; }
|
public bool Disabled { get; set; }
|
||||||
|
public int AvailableInvites { get; set; } = 0;
|
||||||
/// <summary>
|
|
||||||
/// The user that generated an invite used by this user.
|
// Navigation properties
|
||||||
/// </summary>
|
public Guid? InviterId { get; set; }
|
||||||
public User? Inviter { get; set; }
|
public User? Inviter { get; set; }
|
||||||
|
public ICollection<User> InvitedUsers { get; set; } = new List<User>();
|
||||||
}
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using FictionArchive.Service.Shared.Services.EventBus;
|
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService.Models.IntegrationEvents;
|
|
||||||
|
|
||||||
public class AuthUserAddedEvent : IIntegrationEvent
|
|
||||||
{
|
|
||||||
public string OAuthProviderId { get; set; }
|
|
||||||
|
|
||||||
public string InviterOAuthProviderId { get; set; }
|
|
||||||
|
|
||||||
// The email of the user that created the event
|
|
||||||
public string EventUserEmail { get; set; }
|
|
||||||
|
|
||||||
// The username of the user that created the event
|
|
||||||
public string EventUserUsername { get; set; }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using FictionArchive.Service.Shared.Services.EventBus;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Models.IntegrationEvents;
|
||||||
|
|
||||||
|
public class UserInvitedEvent : IIntegrationEvent
|
||||||
|
{
|
||||||
|
// Invited user info
|
||||||
|
public Guid InvitedUserId { get; set; }
|
||||||
|
public required string InvitedUsername { get; set; }
|
||||||
|
public required string InvitedEmail { get; set; }
|
||||||
|
public required string InvitedOAuthProviderId { get; set; }
|
||||||
|
|
||||||
|
// Inviter info
|
||||||
|
public Guid InviterId { get; set; }
|
||||||
|
public required string InviterUsername { get; set; }
|
||||||
|
public required string InviterOAuthProviderId { get; set; }
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
|
using System.Net.Http.Headers;
|
||||||
using FictionArchive.Common.Extensions;
|
using FictionArchive.Common.Extensions;
|
||||||
using FictionArchive.Service.Shared;
|
using FictionArchive.Service.Shared;
|
||||||
using FictionArchive.Service.Shared.Extensions;
|
using FictionArchive.Service.Shared.Extensions;
|
||||||
using FictionArchive.Service.Shared.Services.EventBus.Implementations;
|
using FictionArchive.Service.Shared.Services.EventBus.Implementations;
|
||||||
using FictionArchive.Service.UserService.GraphQL;
|
using FictionArchive.Service.UserService.GraphQL;
|
||||||
using FictionArchive.Service.UserService.Models.IntegrationEvents;
|
|
||||||
using FictionArchive.Service.UserService.Services;
|
using FictionArchive.Service.UserService.Services;
|
||||||
using FictionArchive.Service.UserService.Services.EventHandlers;
|
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||||
|
using FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService;
|
namespace FictionArchive.Service.UserService;
|
||||||
|
|
||||||
@@ -25,19 +26,34 @@ public class Program
|
|||||||
builder.Services.AddRabbitMQ(opt =>
|
builder.Services.AddRabbitMQ(opt =>
|
||||||
{
|
{
|
||||||
builder.Configuration.GetSection("RabbitMQ").Bind(opt);
|
builder.Configuration.GetSection("RabbitMQ").Bind(opt);
|
||||||
})
|
});
|
||||||
.Subscribe<AuthUserAddedEvent, AuthUserAddedEventHandler>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GraphQL
|
#region GraphQL
|
||||||
|
|
||||||
builder.Services.AddDefaultGraphQl<Query, Mutation>()
|
builder.Services.AddDefaultGraphQl<Query, Mutation>()
|
||||||
.AddAuthorization();
|
.AddAuthorization();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Authentik Client
|
||||||
|
|
||||||
|
builder.Services.Configure<AuthentikConfiguration>(
|
||||||
|
builder.Configuration.GetSection("Authentik"));
|
||||||
|
|
||||||
|
var authentikConfig = builder.Configuration.GetSection("Authentik").Get<AuthentikConfiguration>();
|
||||||
|
builder.Services.AddHttpClient<IAuthenticationServiceClient, AuthentikClient>(client =>
|
||||||
|
{
|
||||||
|
client.BaseAddress = new Uri(authentikConfig?.BaseUrl ?? "https://localhost");
|
||||||
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new AuthenticationHeaderValue("Bearer", authentikConfig?.ApiToken ?? "");
|
||||||
|
})
|
||||||
|
.AddStandardResilienceHandler();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
builder.Services.RegisterDbContext<UserServiceDbContext>(
|
builder.Services.RegisterDbContext<UserServiceDbContext>(
|
||||||
builder.Configuration.GetConnectionString("DefaultConnection"),
|
builder.Configuration.GetConnectionString("DefaultConnection"),
|
||||||
skipInfrastructure: isSchemaExport);
|
skipInfrastructure: isSchemaExport);
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
|
public class AuthentikAddUserRequest
|
||||||
|
{
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public required string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public required string DisplayName { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("email")]
|
||||||
|
public required string Email { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("is_active")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public string Type { get; } = "external";
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
|
public class AuthentikClient : IAuthenticationServiceClient
|
||||||
|
{
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
private readonly ILogger<AuthentikClient> _logger;
|
||||||
|
private readonly AuthentikConfiguration _configuration;
|
||||||
|
|
||||||
|
public AuthentikClient(
|
||||||
|
HttpClient httpClient,
|
||||||
|
ILogger<AuthentikClient> logger,
|
||||||
|
IOptions<AuthentikConfiguration> configuration)
|
||||||
|
{
|
||||||
|
_httpClient = httpClient;
|
||||||
|
_logger = logger;
|
||||||
|
_configuration = configuration.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthentikUserResponse?> CreateUserAsync(string username, string email, string displayName)
|
||||||
|
{
|
||||||
|
var request = new AuthentikAddUserRequest
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
Email = email,
|
||||||
|
DisplayName = displayName,
|
||||||
|
IsActive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(request);
|
||||||
|
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
var response = await _httpClient.PostAsync("/api/v3/core/users/", content);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var errorContent = await response.Content.ReadAsStringAsync();
|
||||||
|
_logger.LogError(
|
||||||
|
"Failed to create user in Authentik. Status: {StatusCode}, Error: {Error}",
|
||||||
|
response.StatusCode, errorContent);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var responseJson = await response.Content.ReadAsStringAsync();
|
||||||
|
var userResponse = JsonConvert.DeserializeObject<AuthentikUserResponse>(responseJson);
|
||||||
|
_logger.LogInformation("Successfully created user {Username} in Authentik with pk {Pk}",
|
||||||
|
username, userResponse?.Pk);
|
||||||
|
|
||||||
|
return userResponse;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception while creating user {Username} in Authentik", username);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SendRecoveryEmailAsync(int authentikUserId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await _httpClient.PostAsync(
|
||||||
|
$"/api/v3/core/users/{authentikUserId}/recovery_email/?email_stage={_configuration.EmailStageId}",
|
||||||
|
null);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var errorContent = await response.Content.ReadAsStringAsync();
|
||||||
|
_logger.LogError(
|
||||||
|
"Failed to send recovery email for user {UserId}. Status: {StatusCode}, Error: {Error}",
|
||||||
|
authentikUserId, response.StatusCode, errorContent);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Successfully sent recovery email to Authentik user {UserId}", authentikUserId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception while sending recovery email to Authentik user {UserId}", authentikUserId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
|
public class AuthentikConfiguration
|
||||||
|
{
|
||||||
|
public string BaseUrl { get; set; } = string.Empty;
|
||||||
|
public string ApiToken { get; set; } = string.Empty;
|
||||||
|
public string EmailStageId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
|
public class AuthentikUserResponse
|
||||||
|
{
|
||||||
|
[JsonProperty("pk")]
|
||||||
|
public int Pk { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("email")]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("is_active")]
|
||||||
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("is_superuser")]
|
||||||
|
public bool IsSuperuser { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("uid")]
|
||||||
|
public string Uid { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
|
||||||
|
|
||||||
|
namespace FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||||
|
|
||||||
|
public interface IAuthenticationServiceClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new user in the authentication provider.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">The username for the new user</param>
|
||||||
|
/// <param name="email">The email address for the new user</param>
|
||||||
|
/// <param name="displayName">The display name for the new user</param>
|
||||||
|
/// <returns>The created user response, or null if creation failed</returns>
|
||||||
|
Task<AuthentikUserResponse?> CreateUserAsync(string username, string email, string displayName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a password recovery email to the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="authentikUserId">The Authentik user ID (pk)</param>
|
||||||
|
/// <returns>True if the email was sent successfully, false otherwise</returns>
|
||||||
|
Task<bool> SendRecoveryEmailAsync(int authentikUserId);
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using FictionArchive.Service.Shared.Services.EventBus;
|
|
||||||
using FictionArchive.Service.UserService.Models.IntegrationEvents;
|
|
||||||
using FictionArchive.Service.UserService.Models.Database;
|
|
||||||
using Microsoft.EntityFrameworkCore; // Add this line to include the UserModel
|
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService.Services.EventHandlers;
|
|
||||||
|
|
||||||
public class AuthUserAddedEventHandler : IIntegrationEventHandler<AuthUserAddedEvent>
|
|
||||||
{
|
|
||||||
private readonly UserManagementService _userManagementService;
|
|
||||||
private readonly ILogger<AuthUserAddedEventHandler> _logger;
|
|
||||||
|
|
||||||
public AuthUserAddedEventHandler(UserServiceDbContext dbContext, ILogger<AuthUserAddedEventHandler> logger, UserManagementService userManagementService)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_userManagementService = userManagementService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Handle(AuthUserAddedEvent @event)
|
|
||||||
{
|
|
||||||
await _userManagementService.RegisterUser(@event.EventUserUsername, @event.EventUserEmail, @event.OAuthProviderId, @event.InviterOAuthProviderId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
|
using FictionArchive.Service.Shared.Services.EventBus;
|
||||||
using FictionArchive.Service.UserService.Models.Database;
|
using FictionArchive.Service.UserService.Models.Database;
|
||||||
|
using FictionArchive.Service.UserService.Models.IntegrationEvents;
|
||||||
|
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace FictionArchive.Service.UserService.Services;
|
namespace FictionArchive.Service.UserService.Services;
|
||||||
@@ -7,39 +10,142 @@ public class UserManagementService
|
|||||||
{
|
{
|
||||||
private readonly ILogger<UserManagementService> _logger;
|
private readonly ILogger<UserManagementService> _logger;
|
||||||
private readonly UserServiceDbContext _dbContext;
|
private readonly UserServiceDbContext _dbContext;
|
||||||
|
private readonly IAuthenticationServiceClient _authClient;
|
||||||
|
private readonly IEventBus _eventBus;
|
||||||
|
|
||||||
public UserManagementService(UserServiceDbContext dbContext, ILogger<UserManagementService> logger)
|
public UserManagementService(
|
||||||
|
UserServiceDbContext dbContext,
|
||||||
|
ILogger<UserManagementService> logger,
|
||||||
|
IAuthenticationServiceClient authClient,
|
||||||
|
IEventBus eventBus)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_authClient = authClient;
|
||||||
|
_eventBus = eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User> RegisterUser(string username, string email, string oAuthProviderId,
|
/// <summary>
|
||||||
string? inviterOAuthProviderId)
|
/// Invites a new user by creating them in Authentik, saving to the database, and sending a recovery email.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inviter">The user sending the invite</param>
|
||||||
|
/// <param name="email">Email address of the invitee</param>
|
||||||
|
/// <param name="username">Username for the invitee</param>
|
||||||
|
/// <returns>The created user, or null if the invite failed</returns>
|
||||||
|
public async Task<User?> InviteUserAsync(User inviter, string email, string username)
|
||||||
{
|
{
|
||||||
var newUser = new User();
|
// Check if inviter has available invites
|
||||||
User? inviter =
|
if (inviter.AvailableInvites <= 0)
|
||||||
await _dbContext.Users.FirstOrDefaultAsync(user => user.OAuthProviderId == inviterOAuthProviderId);
|
|
||||||
if (inviter == null && inviterOAuthProviderId != null)
|
|
||||||
{
|
{
|
||||||
_logger.LogCritical(
|
_logger.LogWarning("User {InviterId} has no available invites", inviter.Id);
|
||||||
"A user with OAuthProviderId {OAuthProviderId} was marked as having inviter with OAuthProviderId {inviterOAuthProviderId}, but no user was found with that value.",
|
return null;
|
||||||
inviterOAuthProviderId, inviterOAuthProviderId);
|
|
||||||
newUser.Disabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newUser.Username = username;
|
// Check if email is already in use
|
||||||
newUser.Email = email;
|
var existingUser = await _dbContext.Users
|
||||||
newUser.OAuthProviderId = oAuthProviderId;
|
.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(u => u.Email == email);
|
||||||
|
|
||||||
|
if (existingUser != null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Email {Email} is already in use", email);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if username is already in use
|
||||||
|
var existingUsername = await _dbContext.Users
|
||||||
|
.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(u => u.Username == username);
|
||||||
|
|
||||||
|
if (existingUsername != null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Username {Username} is already in use", username);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create user in Authentik
|
||||||
|
var authentikUser = await _authClient.CreateUserAsync(username, email, username);
|
||||||
|
if (authentikUser == null)
|
||||||
|
{
|
||||||
|
_logger.LogError("Failed to create user {Username} in Authentik", username);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send recovery email via Authentik
|
||||||
|
var emailSent = await _authClient.SendRecoveryEmailAsync(authentikUser.Pk);
|
||||||
|
if (!emailSent)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(
|
||||||
|
"User {Username} was created in Authentik but recovery email failed to send. Authentik pk: {Pk}",
|
||||||
|
username, authentikUser.Pk);
|
||||||
|
// Continue anyway - the user is created, admin can resend email manually
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create user in local database
|
||||||
|
var newUser = new User
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
Email = email,
|
||||||
|
OAuthProviderId = authentikUser.Uid,
|
||||||
|
Disabled = false,
|
||||||
|
AvailableInvites = 0,
|
||||||
|
InviterId = inviter.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
_dbContext.Users.Add(newUser);
|
||||||
|
|
||||||
|
// Decrement inviter's available invites
|
||||||
|
inviter.AvailableInvites--;
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
await _eventBus.Publish(new UserInvitedEvent
|
||||||
|
{
|
||||||
|
InvitedUserId = newUser.Id,
|
||||||
|
InvitedUsername = newUser.Username,
|
||||||
|
InvitedEmail = newUser.Email,
|
||||||
|
InvitedOAuthProviderId = newUser.OAuthProviderId,
|
||||||
|
InviterId = inviter.Id,
|
||||||
|
InviterUsername = inviter.Username,
|
||||||
|
InviterOAuthProviderId = inviter.OAuthProviderId
|
||||||
|
});
|
||||||
|
|
||||||
|
_logger.LogInformation(
|
||||||
|
"User {Username} was successfully invited by {InviterId}. New user id: {NewUserId}",
|
||||||
|
username, inviter.Id, newUser.Id);
|
||||||
|
|
||||||
_dbContext.Users.Add(newUser); // Add the new user to the DbContext
|
|
||||||
await _dbContext.SaveChangesAsync(); // Save changes to the database
|
|
||||||
|
|
||||||
return newUser;
|
return newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a user by their OAuth provider ID (Authentik UID).
|
||||||
|
/// </summary>
|
||||||
|
public async Task<User?> GetUserByOAuthProviderIdAsync(string oAuthProviderId)
|
||||||
|
{
|
||||||
|
return await _dbContext.Users
|
||||||
|
.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(u => u.OAuthProviderId == oAuthProviderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all users as a queryable for GraphQL.
|
||||||
|
/// </summary>
|
||||||
public IQueryable<User> GetUsers()
|
public IQueryable<User> GetUsers()
|
||||||
{
|
{
|
||||||
return _dbContext.Users.AsQueryable();
|
return _dbContext.Users.AsQueryable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all users invited by a specific user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inviterId">The ID of the user who sent the invites</param>
|
||||||
|
/// <returns>List of users invited by the specified user</returns>
|
||||||
|
public async Task<List<User>> GetInvitedByUserAsync(Guid inviterId)
|
||||||
|
{
|
||||||
|
return await _dbContext.Users
|
||||||
|
.AsQueryable()
|
||||||
|
.Where(u => u.InviterId == inviterId)
|
||||||
|
.OrderByDescending(u => u.CreatedTime)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace FictionArchive.Service.UserService.Services;
|
|||||||
public class UserServiceDbContext : FictionArchiveDbContext
|
public class UserServiceDbContext : FictionArchiveDbContext
|
||||||
{
|
{
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
public UserServiceDbContext(DbContextOptions options, ILogger<UserServiceDbContext> logger) : base(options, logger)
|
public UserServiceDbContext(DbContextOptions options, ILogger<UserServiceDbContext> logger) : base(options, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
"ConnectionString": "amqp://localhost",
|
"ConnectionString": "amqp://localhost",
|
||||||
"ClientIdentifier": "UserService"
|
"ClientIdentifier": "UserService"
|
||||||
},
|
},
|
||||||
|
"Authentik": {
|
||||||
|
"BaseUrl": "https://auth.orfl.xyz",
|
||||||
|
"ApiToken": "REPLACE_ME",
|
||||||
|
"EmailStageId": "10df0c18-8802-4ec7-852e-3cdd355514d3"
|
||||||
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
#
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Common", "FictionArchive.Common\FictionArchive.Common.csproj", "{ABF1BA10-9E76-45BE-9947-E20445A68147}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Common", "FictionArchive.Common\FictionArchive.Common.csproj", "{ABF1BA10-9E76-45BE-9947-E20445A68147}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.API", "FictionArchive.API\FictionArchive.API.csproj", "{420CC1A1-9DBC-40EC-B9E3-D4B25D71B9A9}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.API", "FictionArchive.API\FictionArchive.API.csproj", "{420CC1A1-9DBC-40EC-B9E3-D4B25D71B9A9}"
|
||||||
@@ -14,12 +15,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.Sche
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.UserService", "FictionArchive.Service.UserService\FictionArchive.Service.UserService.csproj", "{EE4D4795-2F79-4614-886D-AF8DA77120AC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.UserService", "FictionArchive.Service.UserService\FictionArchive.Service.UserService.csproj", "{EE4D4795-2F79-4614-886D-AF8DA77120AC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.AuthenticationService", "FictionArchive.Service.AuthenticationService\FictionArchive.Service.AuthenticationService.csproj", "{70C4AE82-B01E-421D-B590-C0F47E63CD0C}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.FileService", "FictionArchive.Service.FileService\FictionArchive.Service.FileService.csproj", "{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.FileService", "FictionArchive.Service.FileService\FictionArchive.Service.FileService.csproj", "{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.NovelService.Tests", "FictionArchive.Service.NovelService.Tests\FictionArchive.Service.NovelService.Tests.csproj", "{166E645E-9DFB-44E8-8CC8-FA249A11679F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.NovelService.Tests", "FictionArchive.Service.NovelService.Tests\FictionArchive.Service.NovelService.Tests.csproj", "{166E645E-9DFB-44E8-8CC8-FA249A11679F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.UserService.Tests", "FictionArchive.Service.UserService.Tests\FictionArchive.Service.UserService.Tests.csproj", "{10C38C89-983D-4544-8911-F03099F66AB8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -54,10 +55,6 @@ Global
|
|||||||
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EE4D4795-2F79-4614-886D-AF8DA77120AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{70C4AE82-B01E-421D-B590-C0F47E63CD0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{70C4AE82-B01E-421D-B590-C0F47E63CD0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{70C4AE82-B01E-421D-B590-C0F47E63CD0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{70C4AE82-B01E-421D-B590-C0F47E63CD0C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EC64A336-F8A0-4BED-9CA3-1B05AD00631D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@@ -66,5 +63,9 @@ Global
|
|||||||
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{166E645E-9DFB-44E8-8CC8-FA249A11679F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{10C38C89-983D-4544-8911-F03099F66AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{10C38C89-983D-4544-8911-F03099F66AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{10C38C89-983D-4544-8911-F03099F66AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{10C38C89-983D-4544-8911-F03099F66AB8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -4,25 +4,31 @@ services:
|
|||||||
# ===========================================
|
# ===========================================
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
|
networks:
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- /srv/docker_volumes/fictionarchive/postgres:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 4321:5432
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
image: rabbitmq:3-management-alpine
|
image: rabbitmq:3-management-alpine
|
||||||
|
networks:
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-guest}
|
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-guest}
|
||||||
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-guest}
|
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-guest}
|
||||||
volumes:
|
volumes:
|
||||||
- rabbitmq_data:/var/lib/rabbitmq
|
- /srv/docker_volumes/fictionarchive/rabbitmq:/var/lib/rabbitmq
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "rabbitmq-diagnostics", "check_running"]
|
test: ["CMD", "rabbitmq-diagnostics", "check_running"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
@@ -30,6 +36,20 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
vpn:
|
||||||
|
image: dperson/openvpn-client # or gluetun, wireguard, etc.
|
||||||
|
networks:
|
||||||
|
fictionarchive:
|
||||||
|
aliases:
|
||||||
|
- novel-service
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN
|
||||||
|
devices:
|
||||||
|
- /dev/net/tun
|
||||||
|
volumes:
|
||||||
|
- /srv/docker_volumes/korean_vpn:/vpn
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Backend Services
|
# Backend Services
|
||||||
# ===========================================
|
# ===========================================
|
||||||
@@ -37,50 +57,27 @@ services:
|
|||||||
image: git.orfl.xyz/conco/fictionarchive-novel-service:latest
|
image: git.orfl.xyz/conco/fictionarchive-novel-service:latest
|
||||||
environment:
|
environment:
|
||||||
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_NovelService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_NovelService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
RabbitMQ__ConnectionString: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
||||||
Novelpia__Username: ${NOVELPIA_USERNAME}
|
Novelpia__Username: ${NOVELPIA_USERNAME}
|
||||||
Novelpia__Password: ${NOVELPIA_PASSWORD}
|
Novelpia__Password: ${NOVELPIA_PASSWORD}
|
||||||
NovelUpdateService__PendingImageUrl: https://files.fictionarchive.orfl.xyz/api/pendingupload.png
|
UpdateService__PendingImageUrl: https://files.fictionarchive.orfl.xyz/api/pendingupload.png
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
depends_on:
|
|
||||||
postgres:
|
|
||||||
condition: service_healthy
|
|
||||||
rabbitmq:
|
|
||||||
condition: service_healthy
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
translation-service:
|
|
||||||
image: git.orfl.xyz/conco/fictionarchive-translation-service:latest
|
|
||||||
environment:
|
|
||||||
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_TranslationService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
|
||||||
DeepL__ApiKey: ${DEEPL_API_KEY}
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
vpn:
|
||||||
|
condition: service_started
|
||||||
|
network_mode: "service:vpn"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
scheduler-service:
|
scheduler-service:
|
||||||
image: git.orfl.xyz/conco/fictionarchive-scheduler-service:latest
|
image: git.orfl.xyz/conco/fictionarchive-scheduler-service:latest
|
||||||
|
networks:
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_SchedulerService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_SchedulerService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
RabbitMQ__ConnectionString: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -90,14 +87,14 @@ services:
|
|||||||
|
|
||||||
user-service:
|
user-service:
|
||||||
image: git.orfl.xyz/conco/fictionarchive-user-service:latest
|
image: git.orfl.xyz/conco/fictionarchive-user-service:latest
|
||||||
|
networks:
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_UserService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_UserService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
RabbitMQ__ConnectionString: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
||||||
healthcheck:
|
Authentik__BaseUrl: https://auth.orfl.xyz
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
Authentik__ApiToken: ${AUTHENTIK_API_TOKEN}
|
||||||
interval: 30s
|
Authentik__EmailStageId: 10df0c18-8802-4ec7-852e-3cdd355514d3
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -105,42 +102,21 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
authentication-service:
|
|
||||||
image: git.orfl.xyz/conco/fictionarchive-authentication-service:latest
|
|
||||||
environment:
|
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
depends_on:
|
|
||||||
rabbitmq:
|
|
||||||
condition: service_healthy
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
file-service:
|
file-service:
|
||||||
image: git.orfl.xyz/conco/fictionarchive-file-service:latest
|
image: git.orfl.xyz/conco/fictionarchive-file-service:latest
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
RabbitMQ__ConnectionString: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
||||||
S3__Endpoint: ${S3_ENDPOINT:-https://s3.orfl.xyz}
|
|
||||||
S3__Bucket: ${S3_BUCKET:-fictionarchive}
|
|
||||||
S3__AccessKey: ${S3_ACCESS_KEY}
|
S3__AccessKey: ${S3_ACCESS_KEY}
|
||||||
S3__SecretKey: ${S3_SECRET_KEY}
|
S3__SecretKey: ${S3_SECRET_KEY}
|
||||||
Proxy__BaseUrl: https://files.orfl.xyz/api
|
ProxyConfiguration__BaseUrl: https://files.fictionarchive.orfl.xyz/api
|
||||||
OIDC__Authority: https://auth.orfl.xyz/application/o/fictionarchive/
|
|
||||||
OIDC__ClientId: fictionarchive-files
|
|
||||||
OIDC__Audience: fictionarchive-api
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.file-service.rule=Host(`files.orfl.xyz`)"
|
- "traefik.http.routers.file-service.rule=Host(`files.fictionarchive.orfl.xyz`)"
|
||||||
- "traefik.http.routers.file-service.entrypoints=websecure"
|
- "traefik.http.routers.file-service.tls=true"
|
||||||
- "traefik.http.routers.file-service.tls.certresolver=letsencrypt"
|
- "traefik.http.routers.file-service.tls.certresolver=lets-encrypt"
|
||||||
- "traefik.http.services.file-service.loadbalancer.server.port=8080"
|
- "traefik.http.services.file-service.loadbalancer.server.port=8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
@@ -152,30 +128,22 @@ services:
|
|||||||
# ===========================================
|
# ===========================================
|
||||||
api-gateway:
|
api-gateway:
|
||||||
image: git.orfl.xyz/conco/fictionarchive-api:latest
|
image: git.orfl.xyz/conco/fictionarchive-api:latest
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
- fictionarchive
|
||||||
environment:
|
environment:
|
||||||
ConnectionStrings__RabbitMQ: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
|
||||||
OIDC__Authority: https://auth.orfl.xyz/application/o/fictionarchive/
|
|
||||||
OIDC__ClientId: fictionarchive-api
|
|
||||||
OIDC__Audience: fictionarchive-api
|
|
||||||
Cors__AllowedOrigin: https://fictionarchive.orfl.xyz
|
Cors__AllowedOrigin: https://fictionarchive.orfl.xyz
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.api-gateway.rule=Host(`api.fictionarchive.orfl.xyz`)"
|
- "traefik.http.routers.api-gateway.rule=Host(`api.fictionarchive.orfl.xyz`)"
|
||||||
- "traefik.http.routers.api-gateway.entrypoints=websecure"
|
- "traefik.http.routers.api-gateway.tls=true"
|
||||||
- "traefik.http.routers.api-gateway.tls.certresolver=letsencrypt"
|
- "traefik.http.routers.api-gateway.tls.certresolver=lets-encrypt"
|
||||||
- "traefik.http.services.api-gateway.loadbalancer.server.port=8080"
|
- "traefik.http.services.api-gateway.loadbalancer.server.port=8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
- novel-service
|
- novel-service
|
||||||
- translation-service
|
|
||||||
- scheduler-service
|
- scheduler-service
|
||||||
- user-service
|
|
||||||
- authentication-service
|
|
||||||
- file-service
|
- file-service
|
||||||
|
- user-service
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
@@ -183,20 +151,17 @@ services:
|
|||||||
# ===========================================
|
# ===========================================
|
||||||
frontend:
|
frontend:
|
||||||
image: git.orfl.xyz/conco/fictionarchive-frontend:latest
|
image: git.orfl.xyz/conco/fictionarchive-frontend:latest
|
||||||
healthcheck:
|
networks:
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/"]
|
- web
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- traefik.http.routers.fafrontend.rule=Host(`fictionarchive.orfl.xyz`)
|
||||||
- "traefik.http.routers.frontend.rule=Host(`fictionarchive.orfl.xyz`)"
|
- traefik.http.routers.fafrontend.tls=true
|
||||||
- "traefik.http.routers.frontend.entrypoints=websecure"
|
- traefik.http.routers.fafrontend.tls.certresolver=lets-encrypt
|
||||||
- "traefik.http.routers.frontend.tls.certresolver=letsencrypt"
|
- traefik.http.services.fafrontend.loadbalancer.server.port=80
|
||||||
- "traefik.http.services.frontend.loadbalancer.server.port=80"
|
- traefik.enable=true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
networks:
|
||||||
postgres_data:
|
web:
|
||||||
rabbitmq_data:
|
external: yes
|
||||||
letsencrypt:
|
fictionarchive:
|
||||||
|
|||||||
544
fictionarchive-web-astro/package-lock.json
generated
544
fictionarchive-web-astro/package-lock.json
generated
@@ -12,6 +12,7 @@
|
|||||||
"@astrojs/svelte": "^7.2.2",
|
"@astrojs/svelte": "^7.2.2",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@urql/core": "^6.0.1",
|
"@urql/core": "^6.0.1",
|
||||||
|
"@urql/exchange-auth": "^3.0.0",
|
||||||
"@urql/svelte": "^5.0.0",
|
"@urql/svelte": "^5.0.0",
|
||||||
"astro": "^5.16.2",
|
"astro": "^5.16.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"dompurify": "^3.3.0",
|
"dompurify": "^3.3.0",
|
||||||
"graphql": "^16.12.0",
|
"graphql": "^16.12.0",
|
||||||
|
"isomorphic-dompurify": "^2.33.0",
|
||||||
"oidc-client-ts": "^3.4.1",
|
"oidc-client-ts": "^3.4.1",
|
||||||
"svelte": "^5.45.2",
|
"svelte": "^5.45.2",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
@@ -59,6 +61,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": {
|
"node_modules/@ardatan/relay-compiler": {
|
||||||
"version": "12.0.3",
|
"version": "12.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@ardatan/relay-compiler/-/relay-compiler-12.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@ardatan/relay-compiler/-/relay-compiler-12.0.3.tgz",
|
||||||
@@ -84,6 +92,56 @@
|
|||||||
"graphql": "*"
|
"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": {
|
"node_modules/@astrojs/compiler": {
|
||||||
"version": "2.13.0",
|
"version": "2.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz",
|
||||||
@@ -474,6 +532,140 @@
|
|||||||
"node": ">=18"
|
"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": {
|
"node_modules/@emnapi/runtime": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
|
||||||
@@ -4113,6 +4305,19 @@
|
|||||||
"wonka": "^6.3.2"
|
"wonka": "^6.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@urql/exchange-auth": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@urql/exchange-auth/-/exchange-auth-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-tj09xiOR2f1J2h8TE9uZWjRZipCdmDoTewEytOacDQ+0Teo+yIZxm3ppHxolQtiA51OHrGYiNTkMte8HtfvaBw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@urql/core": "^6.0.0",
|
||||||
|
"wonka": "^6.3.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@urql/core": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@urql/svelte": {
|
"node_modules/@urql/svelte": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@urql/svelte/-/svelte-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@urql/svelte/-/svelte-5.0.0.tgz",
|
||||||
@@ -4207,6 +4412,15 @@
|
|||||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
"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": {
|
"node_modules/ajv": {
|
||||||
"version": "6.12.6",
|
"version": "6.12.6",
|
||||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||||
@@ -4663,6 +4877,15 @@
|
|||||||
"baseline-browser-mapping": "dist/cli.js"
|
"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": {
|
"node_modules/bits-ui": {
|
||||||
"version": "2.14.4",
|
"version": "2.14.4",
|
||||||
"resolved": "https://registry.npmjs.org/bits-ui/-/bits-ui-2.14.4.tgz",
|
"resolved": "https://registry.npmjs.org/bits-ui/-/bits-ui-2.14.4.tgz",
|
||||||
@@ -5491,6 +5714,20 @@
|
|||||||
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==",
|
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==",
|
||||||
"license": "CC0-1.0"
|
"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": {
|
"node_modules/data-uri-to-buffer": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||||
@@ -5501,6 +5738,53 @@
|
|||||||
"node": ">= 12"
|
"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": {
|
"node_modules/dataloader": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.3.tgz",
|
||||||
@@ -5548,6 +5832,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": {
|
"node_modules/decode-named-character-reference": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz",
|
||||||
@@ -7205,6 +7495,18 @@
|
|||||||
"tslib": "^2.0.3"
|
"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": {
|
"node_modules/html-escaper": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz",
|
||||||
@@ -7247,6 +7549,32 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"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": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
||||||
@@ -7501,6 +7829,12 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"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": {
|
"node_modules/is-reference": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
||||||
@@ -7591,6 +7925,19 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"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": {
|
"node_modules/isomorphic-ws": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz",
|
||||||
@@ -7645,6 +7992,91 @@
|
|||||||
"js-yaml": "bin/js-yaml.js"
|
"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": {
|
"node_modules/jsesc": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
|
||||||
@@ -9940,7 +10372,6 @@
|
|||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
@@ -10207,6 +10638,15 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/resolve-from": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
|
||||||
@@ -10414,7 +10854,6 @@
|
|||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/sax": {
|
"node_modules/sax": {
|
||||||
@@ -10423,6 +10862,18 @@
|
|||||||
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
|
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
|
||||||
"license": "BlueOak-1.0.0"
|
"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": {
|
"node_modules/scule": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz",
|
||||||
@@ -10945,6 +11396,12 @@
|
|||||||
"tslib": "^2.0.3"
|
"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": {
|
"node_modules/sync-fetch": {
|
||||||
"version": "0.6.0-2",
|
"version": "0.6.0-2",
|
||||||
"resolved": "https://registry.npmjs.org/sync-fetch/-/sync-fetch-0.6.0-2.tgz",
|
"resolved": "https://registry.npmjs.org/sync-fetch/-/sync-fetch-0.6.0-2.tgz",
|
||||||
@@ -11104,6 +11561,24 @@
|
|||||||
"tslib": "^2.0.3"
|
"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": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
@@ -11126,6 +11601,18 @@
|
|||||||
"node": ">=0.6"
|
"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": {
|
"node_modules/tr46": {
|
||||||
"version": "0.0.3",
|
"version": "0.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
@@ -11832,6 +12319,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": {
|
"node_modules/web-namespaces": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
|
||||||
@@ -11859,11 +12358,34 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause"
|
"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": {
|
"node_modules/whatwg-mimetype": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
|
||||||
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
|
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
@@ -12010,7 +12532,6 @@
|
|||||||
"version": "8.18.3",
|
"version": "8.18.3",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
||||||
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -12029,6 +12550,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": {
|
"node_modules/xxhash-wasm": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"@astrojs/svelte": "^7.2.2",
|
"@astrojs/svelte": "^7.2.2",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@urql/core": "^6.0.1",
|
"@urql/core": "^6.0.1",
|
||||||
|
"@urql/exchange-auth": "^3.0.0",
|
||||||
"@urql/svelte": "^5.0.0",
|
"@urql/svelte": "^5.0.0",
|
||||||
"astro": "^5.16.2",
|
"astro": "^5.16.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"dompurify": "^3.3.0",
|
"dompurify": "^3.3.0",
|
||||||
"graphql": "^16.12.0",
|
"graphql": "^16.12.0",
|
||||||
|
"isomorphic-dompurify": "^2.33.0",
|
||||||
"oidc-client-ts": "^3.4.1",
|
"oidc-client-ts": "^3.4.1",
|
||||||
"svelte": "^5.45.2",
|
"svelte": "^5.45.2",
|
||||||
"tailwind-merge": "^3.4.0",
|
"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);
|
user.set(result ?? null);
|
||||||
if (result) {
|
if (result) {
|
||||||
setCookieFromUser(result);
|
setCookieFromUser(result);
|
||||||
|
// Reload to let server see the new cookie
|
||||||
|
const cleanUrl = `${url.origin}${url.pathname}`;
|
||||||
|
window.location.href = cleanUrl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to complete sign-in redirect', e);
|
console.error('Failed to complete sign-in redirect', e);
|
||||||
@@ -113,3 +117,14 @@ export async function logout() {
|
|||||||
user.set(null);
|
user.set(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function refreshToken(): Promise<User | null> {
|
||||||
|
if (!userManager) return null;
|
||||||
|
try {
|
||||||
|
const newUser = await userManager.signinSilent();
|
||||||
|
return newUser;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Token refresh failed:', e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const authority = import.meta.env.PUBLIC_OIDC_AUTHORITY;
|
|||||||
const clientId = import.meta.env.PUBLIC_OIDC_CLIENT_ID;
|
const clientId = import.meta.env.PUBLIC_OIDC_CLIENT_ID;
|
||||||
const redirectUri = import.meta.env.PUBLIC_OIDC_REDIRECT_URI;
|
const redirectUri = import.meta.env.PUBLIC_OIDC_REDIRECT_URI;
|
||||||
const postLogoutRedirectUri = import.meta.env.PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI ?? redirectUri;
|
const postLogoutRedirectUri = import.meta.env.PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI ?? redirectUri;
|
||||||
const scope = import.meta.env.PUBLIC_OIDC_SCOPE ?? 'openid profile email';
|
const scope = import.meta.env.PUBLIC_OIDC_SCOPE ?? 'openid profile email offline_access';
|
||||||
|
|
||||||
export const isOidcConfigured =
|
export const isOidcConfigured =
|
||||||
Boolean(authority) && Boolean(clientId) && Boolean(redirectUri);
|
Boolean(authority) && Boolean(clientId) && Boolean(redirectUri);
|
||||||
@@ -20,7 +20,7 @@ function buildSettings(): UserManagerSettings | null {
|
|||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
scope,
|
scope,
|
||||||
loadUserInfo: true,
|
loadUserInfo: true,
|
||||||
automaticSilentRenew: true,
|
automaticSilentRenew: false, // We handle refresh reactively via authExchange
|
||||||
userStore:
|
userStore:
|
||||||
typeof window !== 'undefined'
|
typeof window !== 'undefined'
|
||||||
? new WebStorageStateStore({ store: window.localStorage })
|
? new WebStorageStateStore({ store: window.localStorage })
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
let isOpen = $state(false);
|
let isOpen = $state(false);
|
||||||
|
|
||||||
const email = $derived(
|
const name = $derived(
|
||||||
$user?.profile?.email ??
|
$user?.profile?.name ??
|
||||||
$user?.profile?.preferred_username ??
|
$user?.profile?.preferred_username ??
|
||||||
$user?.profile?.name ??
|
$user?.profile?.email ??
|
||||||
$user?.profile?.sub ??
|
$user?.profile?.sub ??
|
||||||
'User'
|
'User'
|
||||||
);
|
);
|
||||||
@@ -38,12 +38,18 @@
|
|||||||
{:else if $user}
|
{:else if $user}
|
||||||
<div class="auth-dropdown relative">
|
<div class="auth-dropdown relative">
|
||||||
<Button variant="outline" onclick={toggleDropdown}>
|
<Button variant="outline" onclick={toggleDropdown}>
|
||||||
{email}
|
{name}
|
||||||
</Button>
|
</Button>
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
<div
|
<div
|
||||||
class="absolute right-0 z-50 mt-2 w-48 rounded-md bg-white p-2 shadow-lg dark:bg-gray-800"
|
class="absolute right-0 z-50 mt-2 w-48 rounded-md bg-white p-2 shadow-lg dark:bg-gray-800"
|
||||||
>
|
>
|
||||||
|
<a
|
||||||
|
href="/settings"
|
||||||
|
class="flex w-full items-center justify-start rounded-md px-4 py-2 text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-700"
|
||||||
|
>
|
||||||
|
Settings
|
||||||
|
</a>
|
||||||
<Button variant="ghost" class="w-full justify-start" onclick={handleLogout}>
|
<Button variant="ghost" class="w-full justify-start" onclick={handleLogout}>
|
||||||
Sign out
|
Sign out
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<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;
|
||||||
|
prevChapterVolumeOrder: number | null | undefined;
|
||||||
|
prevChapterOrder: number | null | undefined;
|
||||||
|
nextChapterVolumeOrder: number | null | undefined;
|
||||||
|
nextChapterOrder: number | null | undefined;
|
||||||
|
showKeyboardHints?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
novelId,
|
||||||
|
prevChapterVolumeOrder,
|
||||||
|
prevChapterOrder,
|
||||||
|
nextChapterVolumeOrder,
|
||||||
|
nextChapterOrder,
|
||||||
|
showKeyboardHints = true
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
const hasPrev = $derived(prevChapterOrder != null && prevChapterVolumeOrder != null);
|
||||||
|
const hasNext = $derived(nextChapterOrder != null && nextChapterVolumeOrder != 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}/volumes/${prevChapterVolumeOrder}/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}/volumes/${nextChapterVolumeOrder}/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';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
novelId?: string;
|
||||||
|
volumeOrder?: string;
|
||||||
|
chapterNumber?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { novelId, volumeOrder, 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 && chapter?.prevChapterVolumeOrder != null) {
|
||||||
|
window.location.href = `/novels/${novelId}/volumes/${chapter.prevChapterVolumeOrder}/chapters/${chapter.prevChapterOrder}`;
|
||||||
|
} else if (event.key === 'ArrowRight' && chapter?.nextChapterOrder != null && chapter?.nextChapterVolumeOrder != null) {
|
||||||
|
window.location.href = `/novels/${novelId}/volumes/${chapter.nextChapterVolumeOrder}/chapters/${chapter.nextChapterOrder}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchChapter() {
|
||||||
|
if (!novelId || !volumeOrder || !chapterNumber) {
|
||||||
|
error = 'Missing novel ID, volume order, or chapter number';
|
||||||
|
fetching = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetching = true;
|
||||||
|
error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.query(GetChapterDocument, {
|
||||||
|
novelId: parseInt(novelId, 10),
|
||||||
|
volumeOrder: parseInt(volumeOrder, 10),
|
||||||
|
chapterOrder: parseInt(chapterNumber, 10)
|
||||||
|
})
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
error = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data?.chapter) {
|
||||||
|
chapter = result.data.chapter;
|
||||||
|
// Update the page title with chapter info
|
||||||
|
document.title = `${chapter.novelName} - ${chapter.order}`;
|
||||||
|
} 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">
|
||||||
|
<!-- 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 ?? ''}
|
||||||
|
prevChapterVolumeOrder={chapter.prevChapterVolumeOrder}
|
||||||
|
prevChapterOrder={chapter.prevChapterOrder}
|
||||||
|
nextChapterVolumeOrder={chapter.nextChapterVolumeOrder}
|
||||||
|
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
|
||||||
|
prose-headings:text-foreground
|
||||||
|
[&>p]:text-foreground [&>p]:mb-6 [&>p]:leading-relaxed"
|
||||||
|
>
|
||||||
|
{@html sanitizedBody}
|
||||||
|
</article>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<!-- Navigation (bottom) -->
|
||||||
|
<ChapterNavigation
|
||||||
|
novelId={novelId ?? ''}
|
||||||
|
prevChapterVolumeOrder={chapter.prevChapterVolumeOrder}
|
||||||
|
prevChapterOrder={chapter.prevChapterOrder}
|
||||||
|
nextChapterVolumeOrder={chapter.nextChapterVolumeOrder}
|
||||||
|
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}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { client } from '$lib/graphql/client';
|
||||||
|
import { ImportNovelDocument } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
import { Input } from '$lib/components/ui/input';
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
onSuccess?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { open = $bindable(), onClose, onSuccess }: Props = $props();
|
||||||
|
|
||||||
|
let novelUrl = $state('');
|
||||||
|
let submitting = $state(false);
|
||||||
|
let error: string | null = $state(null);
|
||||||
|
let success = $state(false);
|
||||||
|
|
||||||
|
async function handleSubmit(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!novelUrl.trim()) {
|
||||||
|
error = 'Please enter a URL';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitting = true;
|
||||||
|
error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.mutation(ImportNovelDocument, { input: { novelUrl: novelUrl.trim() } })
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
error = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data?.importNovel?.novelUpdateRequestedEvent) {
|
||||||
|
success = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
handleClose();
|
||||||
|
onSuccess?.();
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = e instanceof Error ? e.message : 'Unknown error occurred';
|
||||||
|
} finally {
|
||||||
|
submitting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
novelUrl = '';
|
||||||
|
error = null;
|
||||||
|
success = false;
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBackdropClick(e: MouseEvent) {
|
||||||
|
if (e.target === e.currentTarget) {
|
||||||
|
handleClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeydown(e: KeyboardEvent) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
handleClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window onkeydown={handleKeydown} />
|
||||||
|
|
||||||
|
{#if open}
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"
|
||||||
|
onclick={handleBackdropClick}
|
||||||
|
onkeydown={handleKeydown}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="import-modal-title"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<Card class="w-full max-w-md mx-4 shadow-xl">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle id="import-modal-title">Import Novel</CardTitle>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
Enter the URL of the novel you want to import
|
||||||
|
</p>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onsubmit={handleSubmit} class="space-y-4">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label for="novel-url" class="text-sm font-medium">Novel URL</label>
|
||||||
|
<Input
|
||||||
|
id="novel-url"
|
||||||
|
type="url"
|
||||||
|
placeholder="https://example.com/novel/..."
|
||||||
|
bind:value={novelUrl}
|
||||||
|
disabled={submitting || success}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if error}
|
||||||
|
<p class="text-destructive text-sm">{error}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if success}
|
||||||
|
<p class="text-green-600 dark:text-green-400 text-sm">
|
||||||
|
Import request submitted successfully!
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="flex justify-end gap-2 pt-2">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
onclick={handleClose}
|
||||||
|
disabled={submitting}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button type="submit" disabled={submitting || success || !novelUrl.trim()}>
|
||||||
|
{#if submitting}
|
||||||
|
Importing...
|
||||||
|
{:else if success}
|
||||||
|
Done
|
||||||
|
{:else}
|
||||||
|
Import
|
||||||
|
{/if}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Input } from '$lib/components/ui/input';
|
|
||||||
import * as NavigationMenu from '$lib/components/ui/navigation-menu';
|
import * as NavigationMenu from '$lib/components/ui/navigation-menu';
|
||||||
import AuthenticationDisplay from './AuthenticationDisplay.svelte';
|
import AuthenticationDisplay from './AuthenticationDisplay.svelte';
|
||||||
|
import SearchBar from './SearchBar.svelte';
|
||||||
|
|
||||||
let pathname = $state(typeof window !== 'undefined' ? window.location.pathname : '/');
|
let pathname = $state(typeof window !== 'undefined' ? window.location.pathname : '/');
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</NavigationMenu.List>
|
</NavigationMenu.List>
|
||||||
</NavigationMenu.Root>
|
</NavigationMenu.Root>
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
<Input type="search" placeholder="Search..." class="max-w-xs" />
|
<SearchBar />
|
||||||
<AuthenticationDisplay />
|
<AuthenticationDisplay />
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
import type { NovelsQuery, NovelStatus } from '$lib/graphql/__generated__/graphql';
|
import type { NovelsQuery, NovelStatus } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { SystemTags } from '$lib/constants/systemTags';
|
||||||
|
|
||||||
export type NovelNode = NonNullable<NonNullable<NovelsQuery['novels']>['edges']>[number]['node'];
|
export type NovelNode = NonNullable<NonNullable<NovelsQuery['novels']>['edges']>[number]['node'];
|
||||||
|
|
||||||
@@ -38,14 +39,8 @@
|
|||||||
|
|
||||||
let { novel }: NovelCardProps = $props();
|
let { novel }: NovelCardProps = $props();
|
||||||
|
|
||||||
function pickText(novelText?: NovelNode['name'] | NovelNode['description']) {
|
const title = $derived(novel.name || 'Untitled');
|
||||||
const texts = novelText?.texts ?? [];
|
const descriptionRaw = $derived(novel.description || 'No description available.');
|
||||||
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 descriptionHtml = $derived(sanitizeHtml(descriptionRaw));
|
const descriptionHtml = $derived(sanitizeHtml(descriptionRaw));
|
||||||
const coverSrc = $derived(novel.coverImage?.newPath ?? novel.coverImage?.originalPath);
|
const coverSrc = $derived(novel.coverImage?.newPath ?? novel.coverImage?.originalPath);
|
||||||
|
|
||||||
@@ -61,6 +56,8 @@
|
|||||||
const status = $derived(novel.rawStatus ?? 'UNKNOWN');
|
const status = $derived(novel.rawStatus ?? 'UNKNOWN');
|
||||||
const statusColor = $derived(statusColors[status]);
|
const statusColor = $derived(statusColors[status]);
|
||||||
const statusLabel = $derived(statusLabels[status]);
|
const statusLabel = $derived(statusLabels[status]);
|
||||||
|
|
||||||
|
const isNsfw = $derived(novel.tags?.some((tag) => tag.key === SystemTags.Nsfw) ?? false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
@@ -82,6 +79,9 @@
|
|||||||
>
|
>
|
||||||
{statusLabel}
|
{statusLabel}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{#if isNsfw}
|
||||||
|
<Badge class="absolute top-9 right-2 bg-red-600 text-white shadow-sm">NSFW</Badge>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<CardHeader class="space-y-2 pt-4">
|
<CardHeader class="space-y-2 pt-4">
|
||||||
<CardTitle class="line-clamp-2 text-lg leading-tight" title={title}>
|
<CardTitle class="line-clamp-2 text-lg leading-tight" title={title}>
|
||||||
|
|||||||
@@ -1,25 +1,776 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
import type { NovelQuery, NovelStatus, Language } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { TagType } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { SystemTags } from '$lib/constants/systemTags';
|
||||||
|
|
||||||
|
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">
|
<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, ImportNovelDocument, DeleteNovelDocument } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { isAuthenticated } from '$lib/auth/authStore';
|
||||||
|
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 {
|
||||||
|
Accordion,
|
||||||
|
AccordionItem,
|
||||||
|
AccordionTrigger,
|
||||||
|
AccordionContent
|
||||||
|
} from '$lib/components/ui/accordion';
|
||||||
|
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';
|
||||||
|
import RefreshCw from '@lucide/svelte/icons/refresh-cw';
|
||||||
|
import Trash2 from '@lucide/svelte/icons/trash-2';
|
||||||
|
import X from '@lucide/svelte/icons/x';
|
||||||
|
import ChevronLeft from '@lucide/svelte/icons/chevron-left';
|
||||||
|
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
novelId?: string;
|
novelId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { novelId }: Props = $props();
|
let { novelId }: Props = $props();
|
||||||
|
|
||||||
|
let novel: NovelNode | null = $state(null);
|
||||||
|
let fetching = $state(true);
|
||||||
|
let error: string | null = $state(null);
|
||||||
|
let descriptionExpanded = $state(false);
|
||||||
|
let refreshing = $state(false);
|
||||||
|
let refreshError: string | null = $state(null);
|
||||||
|
let refreshSuccess = $state(false);
|
||||||
|
|
||||||
|
// Delete state
|
||||||
|
let showDeleteConfirm = $state(false);
|
||||||
|
let deleting = $state(false);
|
||||||
|
let deleteError: string | null = $state(null);
|
||||||
|
|
||||||
|
// Image viewer state
|
||||||
|
type GalleryImage = {
|
||||||
|
src: string;
|
||||||
|
alt: string;
|
||||||
|
volumeOrder?: number;
|
||||||
|
chapterId?: number;
|
||||||
|
chapterOrder?: number;
|
||||||
|
chapterName?: string;
|
||||||
|
isCover: boolean;
|
||||||
|
};
|
||||||
|
let viewerOpen = $state(false);
|
||||||
|
let viewerIndex = $state(0);
|
||||||
|
let activeTab = $state('chapters');
|
||||||
|
let galleryLoaded = $state(false);
|
||||||
|
|
||||||
|
const DESCRIPTION_PREVIEW_LENGTH = 300;
|
||||||
|
|
||||||
|
// Derived values
|
||||||
|
const coverSrc = $derived(novel?.coverImage?.newPath);
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
// Volume-aware chapter organization
|
||||||
|
const sortedVolumes = $derived(
|
||||||
|
[...(novel?.volumes ?? [])].sort((a, b) => a.order - b.order)
|
||||||
|
);
|
||||||
|
|
||||||
|
const isSingleVolume = $derived(sortedVolumes.length === 1);
|
||||||
|
|
||||||
|
const chapterCount = $derived(
|
||||||
|
sortedVolumes.reduce((sum, v) => sum + v.chapters.length, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Filter out system tags for display, check for NSFW
|
||||||
|
const displayTags = $derived(novel?.tags?.filter((tag) => tag.tagType !== TagType.System) ?? []);
|
||||||
|
const isNsfw = $derived(novel?.tags?.some((tag) => tag.key === SystemTags.Nsfw) ?? false);
|
||||||
|
|
||||||
|
const canRefresh = $derived(() => {
|
||||||
|
if (!lastUpdated) return true;
|
||||||
|
const sixHoursAgo = Date.now() - 6 * 60 * 60 * 1000;
|
||||||
|
return lastUpdated.getTime() < sixHoursAgo;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gallery images - cover + chapter images
|
||||||
|
const galleryImages = $derived.by(() => {
|
||||||
|
const images: GalleryImage[] = [];
|
||||||
|
|
||||||
|
// Add cover image first
|
||||||
|
if (coverSrc && novel) {
|
||||||
|
images.push({ src: coverSrc, alt: `${novel.name} cover`, isCover: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add chapter images (loop through volumes to preserve volumeOrder)
|
||||||
|
for (const volume of sortedVolumes) {
|
||||||
|
const volumeChapters = [...volume.chapters].sort((a, b) => a.order - b.order);
|
||||||
|
for (const chapter of volumeChapters) {
|
||||||
|
for (const img of chapter.images ?? []) {
|
||||||
|
if (img.newPath) {
|
||||||
|
images.push({
|
||||||
|
src: img.newPath,
|
||||||
|
alt: `Image from ${chapter.name}`,
|
||||||
|
volumeOrder: volume.order,
|
||||||
|
chapterId: chapter.id,
|
||||||
|
chapterOrder: chapter.order,
|
||||||
|
chapterName: chapter.name,
|
||||||
|
isCover: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return images;
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentImage = $derived(galleryImages[viewerIndex]);
|
||||||
|
const imageCount = $derived(galleryImages.length);
|
||||||
|
|
||||||
|
// Load gallery images when tab is first activated
|
||||||
|
$effect(() => {
|
||||||
|
if (activeTab === 'gallery' && !galleryLoaded) {
|
||||||
|
galleryLoaded = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Image viewer functions
|
||||||
|
function openImageViewer(index: number) {
|
||||||
|
viewerIndex = index;
|
||||||
|
viewerOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeViewer() {
|
||||||
|
viewerOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextImage() {
|
||||||
|
if (galleryImages.length > 0) {
|
||||||
|
viewerIndex = (viewerIndex + 1) % galleryImages.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prevImage() {
|
||||||
|
if (galleryImages.length > 0) {
|
||||||
|
viewerIndex = (viewerIndex - 1 + galleryImages.length) % galleryImages.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleViewerKeydown(e: KeyboardEvent) {
|
||||||
|
if (!viewerOpen) return;
|
||||||
|
if (e.key === 'Escape') closeViewer();
|
||||||
|
if (e.key === 'ArrowRight') nextImage();
|
||||||
|
if (e.key === 'ArrowLeft') prevImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
document.title = novel.name;
|
||||||
|
} else {
|
||||||
|
error = 'Novel not found';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = e instanceof Error ? e.message : 'Unknown error';
|
||||||
|
} finally {
|
||||||
|
fetching = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshNovel() {
|
||||||
|
if (!novel?.url) return;
|
||||||
|
|
||||||
|
refreshing = true;
|
||||||
|
refreshError = null;
|
||||||
|
refreshSuccess = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.mutation(ImportNovelDocument, { input: { novelUrl: novel.url } })
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
refreshError = result.error.message;
|
||||||
|
} else {
|
||||||
|
refreshSuccess = true;
|
||||||
|
setTimeout(() => (refreshSuccess = false), 2000);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
refreshError = e instanceof Error ? e.message : 'Failed to refresh';
|
||||||
|
} finally {
|
||||||
|
refreshing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteNovel() {
|
||||||
|
if (!novel) return;
|
||||||
|
|
||||||
|
deleting = true;
|
||||||
|
deleteError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.mutation(DeleteNovelDocument, { input: { novelId: novel.id } })
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
deleteError = result.error.message;
|
||||||
|
} else if (result.data?.deleteNovel?.errors?.length) {
|
||||||
|
deleteError = result.data.deleteNovel.errors[0].message;
|
||||||
|
} else {
|
||||||
|
// Successfully deleted - redirect to novels list
|
||||||
|
window.location.href = '/novels';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
deleteError = e instanceof Error ? e.message : 'Failed to delete';
|
||||||
|
} finally {
|
||||||
|
deleting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
fetchNovel();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="shadow-md shadow-primary/10">
|
<div class="space-y-6">
|
||||||
<CardHeader>
|
<!-- Back Navigation -->
|
||||||
<CardTitle>Novel Details</CardTitle>
|
<Button variant="ghost" href="/novels" class="gap-2 -ml-2">
|
||||||
</CardHeader>
|
<ArrowLeft class="h-4 w-4" />
|
||||||
<CardContent>
|
Back to Novels
|
||||||
<p class="text-sm text-muted-foreground">
|
</Button>
|
||||||
{#if novelId}
|
|
||||||
Viewing novel ID: <code class="rounded bg-muted px-1 py-0.5">{novelId}</code>
|
<!-- 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
|
||||||
|
<a
|
||||||
|
href="/novels?author={encodeURIComponent(novel.author.name)}"
|
||||||
|
class="text-primary hover:underline"
|
||||||
|
>
|
||||||
|
{novel.author.name}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Badges -->
|
||||||
|
<div class="flex flex-wrap gap-2 items-center">
|
||||||
|
<Badge class={statusColor}>{statusLabel}</Badge>
|
||||||
|
{#if isNsfw}
|
||||||
|
<Badge class="bg-red-600 text-white">NSFW</Badge>
|
||||||
|
{/if}
|
||||||
|
<Badge variant="outline">{languageLabel}</Badge>
|
||||||
|
{#if $isAuthenticated}
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onclick={refreshNovel}
|
||||||
|
disabled={refreshing || !canRefresh()}
|
||||||
|
class="gap-1.5 h-6 text-xs"
|
||||||
|
>
|
||||||
|
<RefreshCw class="h-3 w-3 {refreshing ? 'animate-spin' : ''}" />
|
||||||
|
{refreshing ? 'Refreshing...' : 'Refresh'}
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
{#if !canRefresh()}
|
||||||
|
<TooltipContent>
|
||||||
|
Updated less than 6 hours ago
|
||||||
|
</TooltipContent>
|
||||||
|
{/if}
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
<Button
|
||||||
|
variant="destructive"
|
||||||
|
size="sm"
|
||||||
|
onclick={() => (showDeleteConfirm = true)}
|
||||||
|
class="gap-1.5 h-6 text-xs"
|
||||||
|
>
|
||||||
|
<Trash2 class="h-3 w-3" />
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
{#if refreshSuccess}
|
||||||
|
<Badge variant="outline" class="bg-green-500/10 text-green-600 border-green-500/30">
|
||||||
|
Refresh queued
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
|
{#if refreshError}
|
||||||
|
<Badge variant="outline" class="bg-destructive/10 text-destructive border-destructive/30">
|
||||||
|
{refreshError}
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
|
</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 displayTags.length > 0}
|
||||||
|
<div class="flex flex-wrap gap-1.5 pt-1">
|
||||||
|
{#each displayTags 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 bind:value={activeTab} 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 ({chapterCount})
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger
|
||||||
|
value="gallery"
|
||||||
|
class="rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm px-3 py-1.5 text-sm font-medium transition-all"
|
||||||
|
>
|
||||||
|
Gallery ({imageCount})
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger
|
||||||
|
value="bookmarks"
|
||||||
|
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"
|
||||||
|
>
|
||||||
|
Bookmarks
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent class="pt-4">
|
||||||
|
<TabsContent value="chapters" class="mt-0">
|
||||||
|
{#if chapterCount === 0}
|
||||||
|
<p class="text-muted-foreground text-sm py-4 text-center">
|
||||||
|
No chapters available yet.
|
||||||
|
</p>
|
||||||
|
{:else if isSingleVolume}
|
||||||
|
<!-- Single volume: flat chapter list -->
|
||||||
|
{@const singleVolumeChapters = [...(sortedVolumes[0]?.chapters ?? [])].sort((a, b) => a.order - b.order)}
|
||||||
|
<div class="max-h-96 overflow-y-auto -mx-2">
|
||||||
|
{#each singleVolumeChapters as chapter (chapter.id)}
|
||||||
|
{@const chapterDate = chapter.lastUpdatedTime ? new Date(chapter.lastUpdatedTime) : null}
|
||||||
|
<a
|
||||||
|
href="/novels/{novelId}/volumes/{sortedVolumes[0]?.order}/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>
|
||||||
|
{:else}
|
||||||
|
<!-- Multiple volumes: accordion display -->
|
||||||
|
<div class="max-h-96 overflow-y-auto -mx-2">
|
||||||
|
<Accordion type="single">
|
||||||
|
{#each sortedVolumes as volume (volume.id)}
|
||||||
|
{@const volumeChapters = [...volume.chapters].sort((a, b) => a.order - b.order)}
|
||||||
|
<AccordionItem value="volume-{volume.id}">
|
||||||
|
<AccordionTrigger class="px-3">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<span class="font-medium">{volume.name}</span>
|
||||||
|
<span class="text-xs text-muted-foreground">
|
||||||
|
({volumeChapters.length} chapters)
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</AccordionTrigger>
|
||||||
|
<AccordionContent>
|
||||||
|
<div class="space-y-0.5">
|
||||||
|
{#each volumeChapters as chapter (chapter.id)}
|
||||||
|
{@const chapterDate = chapter.lastUpdatedTime ? new Date(chapter.lastUpdatedTime) : null}
|
||||||
|
<a
|
||||||
|
href="/novels/{novelId}/volumes/{volume.order}/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>
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionItem>
|
||||||
|
{/each}
|
||||||
|
</Accordion>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="gallery" class="mt-0">
|
||||||
|
{#if galleryImages.length === 0}
|
||||||
|
<p class="text-muted-foreground text-sm py-4 text-center">
|
||||||
|
No images available.
|
||||||
|
</p>
|
||||||
|
{:else if galleryLoaded}
|
||||||
|
<div class="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2">
|
||||||
|
{#each galleryImages as image, index (image.src)}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={() => openImageViewer(index)}
|
||||||
|
class="relative aspect-square overflow-hidden rounded-md bg-muted/50 hover:ring-2 ring-primary transition-all"
|
||||||
|
>
|
||||||
|
<img src={image.src} alt={image.alt} class="h-full w-full object-cover" loading="lazy" />
|
||||||
|
{#if image.isCover}
|
||||||
|
<Badge class="absolute top-1 left-1 text-xs">Cover</Badge>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex items-center justify-center py-8">
|
||||||
|
<div
|
||||||
|
class="border-primary h-8 w-8 animate-spin rounded-full border-2 border-t-transparent"
|
||||||
|
aria-label="Loading gallery"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="bookmarks" class="mt-0">
|
||||||
|
<p class="text-muted-foreground text-sm py-8 text-center">
|
||||||
|
Bookmarks coming soon.
|
||||||
|
</p>
|
||||||
|
</TabsContent>
|
||||||
|
</CardContent>
|
||||||
|
</Tabs>
|
||||||
|
</Card>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Image Viewer Modal -->
|
||||||
|
{#if viewerOpen && currentImage}
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/90 backdrop-blur-sm"
|
||||||
|
onclick={closeViewer}
|
||||||
|
onkeydown={handleViewerKeydown}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<!-- Close button -->
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
class="absolute top-4 right-4 text-white hover:bg-white/10"
|
||||||
|
onclick={closeViewer}
|
||||||
|
>
|
||||||
|
<X class="h-6 w-6" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<!-- Navigation arrows -->
|
||||||
|
{#if galleryImages.length > 1}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
class="absolute left-4 text-white hover:bg-white/10 h-12 w-12"
|
||||||
|
onclick={(e: MouseEvent) => { e.stopPropagation(); prevImage(); }}
|
||||||
|
>
|
||||||
|
<ChevronLeft class="h-8 w-8" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
class="absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/10 h-12 w-12"
|
||||||
|
onclick={(e: MouseEvent) => { e.stopPropagation(); nextImage(); }}
|
||||||
|
>
|
||||||
|
<ChevronRight class="h-8 w-8" />
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Image container -->
|
||||||
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div class="flex flex-col items-center max-w-[90vw] max-h-[90vh]" onclick={(e: MouseEvent) => e.stopPropagation()}>
|
||||||
|
<img
|
||||||
|
src={currentImage.src}
|
||||||
|
alt={currentImage.alt}
|
||||||
|
class="max-w-full max-h-[80vh] object-contain rounded-lg"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Chapter link (if not cover) -->
|
||||||
|
{#if !currentImage.isCover && currentImage.volumeOrder != null && currentImage.chapterOrder}
|
||||||
|
<a
|
||||||
|
href="/novels/{novelId}/volumes/{currentImage.volumeOrder}/chapters/{currentImage.chapterOrder}"
|
||||||
|
class="text-white/80 hover:text-white text-sm inline-flex items-center gap-1 mt-3"
|
||||||
|
>
|
||||||
|
From: Ch. {currentImage.chapterOrder} - {currentImage.chapterName}
|
||||||
|
<ExternalLink class="h-3 w-3" />
|
||||||
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</p>
|
|
||||||
<p class="mt-2 text-sm text-muted-foreground">
|
<!-- Image counter -->
|
||||||
Detail view coming soon. Select a novel to explore chapters and metadata once implemented.
|
<div class="text-white/60 text-sm mt-2">
|
||||||
</p>
|
{viewerIndex + 1} / {galleryImages.length}
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Delete Confirmation Modal -->
|
||||||
|
{#if showDeleteConfirm && novel}
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"
|
||||||
|
onclick={() => !deleting && (showDeleteConfirm = false)}
|
||||||
|
onkeydown={(e) => e.key === 'Escape' && !deleting && (showDeleteConfirm = false)}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="delete-modal-title"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div onclick={(e: MouseEvent) => e.stopPropagation()}>
|
||||||
|
<Card class="w-full max-w-md mx-4 shadow-xl">
|
||||||
|
<CardHeader>
|
||||||
|
<h2 id="delete-modal-title" class="text-lg font-semibold">Delete Novel</h2>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent class="space-y-4">
|
||||||
|
<p class="text-muted-foreground">
|
||||||
|
Are you sure you want to delete <strong class="text-foreground">{novel.name}</strong>?
|
||||||
|
</p>
|
||||||
|
<p class="text-sm text-muted-foreground">
|
||||||
|
This will permanently delete the novel, all chapters, images, and translations. This action cannot be undone.
|
||||||
|
</p>
|
||||||
|
{#if deleteError}
|
||||||
|
<p class="text-sm text-destructive">{deleteError}</p>
|
||||||
|
{/if}
|
||||||
|
<div class="flex justify-end gap-2 pt-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onclick={() => (showDeleteConfirm = false)}
|
||||||
|
disabled={deleting}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="destructive"
|
||||||
|
onclick={deleteNovel}
|
||||||
|
disabled={deleting}
|
||||||
|
>
|
||||||
|
{deleting ? 'Deleting...' : 'Delete'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|||||||
320
fictionarchive-web-astro/src/lib/components/NovelFilters.svelte
Normal file
320
fictionarchive-web-astro/src/lib/components/NovelFilters.svelte
Normal file
@@ -0,0 +1,320 @@
|
|||||||
|
<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, type SortField, type SortDirection, 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 authorInput = $state(filters.authorName);
|
||||||
|
let searchTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
let authorTimeout: 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' }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Sort options
|
||||||
|
const sortOptions: { value: `${SortField}-${SortDirection}`; label: string }[] = [
|
||||||
|
{ value: 'lastUpdatedTime-DESC', label: 'Recently Updated' },
|
||||||
|
{ value: 'lastUpdatedTime-ASC', label: 'Oldest Updated' },
|
||||||
|
{ value: 'createdTime-DESC', label: 'Recently Added' },
|
||||||
|
{ value: 'createdTime-ASC', label: 'Oldest Added' },
|
||||||
|
{ value: 'name-ASC', label: 'Name (A-Z)' },
|
||||||
|
{ value: 'name-DESC', label: 'Name (Z-A)' }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Current sort value as combined string for the select
|
||||||
|
const currentSortValue = $derived(`${filters.sort.field}-${filters.sort.direction}` as const);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debounced author handler
|
||||||
|
function handleAuthorInput(value: string) {
|
||||||
|
authorInput = value;
|
||||||
|
if (authorTimeout) clearTimeout(authorTimeout);
|
||||||
|
authorTimeout = setTimeout(() => {
|
||||||
|
onFilterChange({ ...filters, authorName: value });
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status selection handler
|
||||||
|
function handleStatusChange(selected: NovelStatus[]) {
|
||||||
|
onFilterChange({ ...filters, statuses: selected });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tag selection handler
|
||||||
|
function handleTagChange(selected: string[]) {
|
||||||
|
onFilterChange({ ...filters, tags: selected });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort selection handler
|
||||||
|
function handleSortChange(value: string) {
|
||||||
|
const [field, direction] = value.split('-') as [SortField, SortDirection];
|
||||||
|
onFilterChange({ ...filters, sort: { field, direction } });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear all filters
|
||||||
|
function clearFilters() {
|
||||||
|
searchInput = '';
|
||||||
|
authorInput = '';
|
||||||
|
onFilterChange({ ...EMPTY_FILTERS });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync search input when filters prop changes externally
|
||||||
|
$effect(() => {
|
||||||
|
if (filters.search !== searchInput && !searchTimeout) {
|
||||||
|
searchInput = filters.search;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sync author input when filters prop changes externally
|
||||||
|
$effect(() => {
|
||||||
|
if (filters.authorName !== authorInput && !authorTimeout) {
|
||||||
|
authorInput = filters.authorName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<!-- Author Input -->
|
||||||
|
<div class="min-w-[150px]">
|
||||||
|
<Input
|
||||||
|
type="text"
|
||||||
|
placeholder="Author..."
|
||||||
|
value={authorInput}
|
||||||
|
oninput={(e) => handleAuthorInput(e.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
</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}
|
||||||
|
|
||||||
|
<!-- Sort Dropdown -->
|
||||||
|
<Select.Root
|
||||||
|
type="single"
|
||||||
|
value={currentSortValue}
|
||||||
|
onValueChange={(v) => v && handleSortChange(v)}
|
||||||
|
>
|
||||||
|
<Select.Trigger
|
||||||
|
class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 min-w-[160px] 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">
|
||||||
|
{sortOptions.find((o) => o.value === currentSortValue)?.label ?? 'Sort by'}
|
||||||
|
</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-[160px] overflow-auto rounded-md border p-1 shadow-md"
|
||||||
|
>
|
||||||
|
{#each sortOptions 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="flex h-4 w-4 items-center justify-center">
|
||||||
|
{#if selected}
|
||||||
|
<Check class="h-3 w-3" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<span>{option.label}</span>
|
||||||
|
{/snippet}
|
||||||
|
</Select.Item>
|
||||||
|
{/each}
|
||||||
|
</Select.Content>
|
||||||
|
</Select.Root>
|
||||||
|
|
||||||
|
<!-- 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}
|
||||||
|
|
||||||
|
{#if filters.authorName}
|
||||||
|
<Badge variant="secondary" class="gap-1">
|
||||||
|
Author: {filters.authorName}
|
||||||
|
<button
|
||||||
|
onclick={() => {
|
||||||
|
authorInput = '';
|
||||||
|
onFilterChange({ ...filters, authorName: '' });
|
||||||
|
}}
|
||||||
|
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,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { SvelteMap } from 'svelte/reactivity';
|
||||||
import { client } from '$lib/graphql/client';
|
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 NovelCard from './NovelCard.svelte';
|
||||||
|
import NovelFilters from './NovelFilters.svelte';
|
||||||
|
import ImportNovelModal from './ImportNovelModal.svelte';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
import { isAuthenticated } from '$lib/auth/authStore';
|
||||||
|
import {
|
||||||
|
type NovelFilters as NovelFiltersType,
|
||||||
|
parseFiltersFromURL,
|
||||||
|
syncFiltersToURL,
|
||||||
|
filtersToGraphQLWhere,
|
||||||
|
sortToGraphQLOrder,
|
||||||
|
hasActiveFilters,
|
||||||
|
EMPTY_FILTERS
|
||||||
|
} from '$lib/utils/filterParams';
|
||||||
|
|
||||||
const PAGE_SIZE = 12;
|
const PAGE_SIZE = 12;
|
||||||
|
|
||||||
@@ -15,16 +28,35 @@
|
|||||||
let fetching = $state(false);
|
let fetching = $state(false);
|
||||||
let error: string | null = $state(null);
|
let error: string | null = $state(null);
|
||||||
let initialLoad = $state(true);
|
let initialLoad = $state(true);
|
||||||
|
let filters: NovelFiltersType = $state({ ...EMPTY_FILTERS });
|
||||||
|
let showImportModal = $state(false);
|
||||||
|
|
||||||
const hasNextPage = $derived(pageInfo?.hasNextPage ?? false);
|
const hasNextPage = $derived(pageInfo?.hasNextPage ?? false);
|
||||||
const novels = $derived(edges.map((edge) => edge.node).filter(Boolean));
|
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) {
|
async function fetchNovels(after: string | null = null) {
|
||||||
fetching = true;
|
fetching = true;
|
||||||
error = null;
|
error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await client.query(NovelsDocument, { first: PAGE_SIZE, after }).toPromise();
|
const where = filtersToGraphQLWhere(filters);
|
||||||
|
const order = sortToGraphQLOrder(filters.sort);
|
||||||
|
const result = await client
|
||||||
|
.query(NovelsDocument, { first: PAGE_SIZE, after, where, order })
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
error = result.error.message;
|
error = result.error.message;
|
||||||
@@ -36,7 +68,7 @@
|
|||||||
// Append for pagination
|
// Append for pagination
|
||||||
edges = [...edges, ...result.data.novels.edges];
|
edges = [...edges, ...result.data.novels.edges];
|
||||||
} else {
|
} else {
|
||||||
// Initial load
|
// Initial load or filter change
|
||||||
edges = result.data.novels.edges;
|
edges = result.data.novels.edges;
|
||||||
}
|
}
|
||||||
pageInfo = result.data.novels.pageInfo;
|
pageInfo = result.data.novels.pageInfo;
|
||||||
@@ -55,17 +87,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
function handleFilterChange(newFilters: NovelFiltersType) {
|
||||||
|
filters = newFilters;
|
||||||
|
// Reset pagination and refetch
|
||||||
|
edges = [];
|
||||||
|
pageInfo = null;
|
||||||
|
syncFiltersToURL(filters);
|
||||||
fetchNovels();
|
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>
|
</script>
|
||||||
|
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<Card class="shadow-md shadow-primary/10">
|
<Card class="shadow-md shadow-primary/10">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Latest Novels</CardTitle>
|
<div class="flex items-center justify-between">
|
||||||
<p class="text-sm text-muted-foreground">Novels that have recently been updated.</p>
|
<CardTitle>Controls</CardTitle>
|
||||||
|
{#if $isAuthenticated}
|
||||||
|
<Button variant="outline" onclick={() => (showImportModal = true)}>
|
||||||
|
Import Novel
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<NovelFilters {filters} onFilterChange={handleFilterChange} availableTags={availableTags()} />
|
||||||
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{#if fetching && initialLoad}
|
{#if fetching && initialLoad}
|
||||||
@@ -73,7 +136,7 @@
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div class="flex items-center justify-center py-8">
|
<div class="flex items-center justify-center py-8">
|
||||||
<div
|
<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"
|
aria-label="Loading novels"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -84,7 +147,7 @@
|
|||||||
{#if error}
|
{#if error}
|
||||||
<Card class="border-destructive/40 bg-destructive/5">
|
<Card class="border-destructive/40 bg-destructive/5">
|
||||||
<CardContent>
|
<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>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -92,8 +155,12 @@
|
|||||||
{#if !fetching && novels.length === 0 && !error && !initialLoad}
|
{#if !fetching && novels.length === 0 && !error && !initialLoad}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<p class="py-4 text-sm text-muted-foreground">
|
<p class="text-muted-foreground py-4 text-sm">
|
||||||
No novels found yet. Try adding content to the gateway.
|
{#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>
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -115,3 +182,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ImportNovelModal
|
||||||
|
bind:open={showImportModal}
|
||||||
|
onClose={() => (showImportModal = false)}
|
||||||
|
onSuccess={() => fetchNovels()}
|
||||||
|
/>
|
||||||
|
|||||||
@@ -18,7 +18,12 @@
|
|||||||
error = null;
|
error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await client.query(NovelsDocument, { first: 5 }).toPromise();
|
const result = await client
|
||||||
|
.query(NovelsDocument, {
|
||||||
|
first: 5,
|
||||||
|
order: [{ lastUpdatedTime: 'DESC' }]
|
||||||
|
})
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
error = result.error.message;
|
error = result.error.message;
|
||||||
|
|||||||
141
fictionarchive-web-astro/src/lib/components/SearchBar.svelte
Normal file
141
fictionarchive-web-astro/src/lib/components/SearchBar.svelte
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Search from '@lucide/svelte/icons/search';
|
||||||
|
import { Input } from '$lib/components/ui/input';
|
||||||
|
import { NovelsDocument, type NovelDto } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import { client } from '$lib/graphql/client';
|
||||||
|
|
||||||
|
let searchTerm = $state('');
|
||||||
|
let results = $state<NovelDto[]>([]);
|
||||||
|
let isOpen = $state(false);
|
||||||
|
let fetching = $state(false);
|
||||||
|
let searchTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
let containerRef: HTMLDivElement;
|
||||||
|
|
||||||
|
async function fetchResults(term: string) {
|
||||||
|
if (!term.trim()) {
|
||||||
|
results = [];
|
||||||
|
isOpen = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetching = true;
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.query(NovelsDocument, {
|
||||||
|
first: 4,
|
||||||
|
where: { name: { contains: term } }
|
||||||
|
})
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.data?.novels?.edges) {
|
||||||
|
results = result.data.novels.edges.map((edge) => edge.node);
|
||||||
|
isOpen = results.length > 0;
|
||||||
|
} else {
|
||||||
|
results = [];
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Search error:', error);
|
||||||
|
results = [];
|
||||||
|
isOpen = false;
|
||||||
|
} finally {
|
||||||
|
fetching = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleInput(value: string) {
|
||||||
|
searchTerm = value;
|
||||||
|
if (searchTimeout) clearTimeout(searchTimeout);
|
||||||
|
searchTimeout = setTimeout(() => {
|
||||||
|
fetchResults(value);
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'Enter' && searchTerm.trim()) {
|
||||||
|
event.preventDefault();
|
||||||
|
isOpen = false;
|
||||||
|
window.location.href = `/novels?search=${encodeURIComponent(searchTerm.trim())}`;
|
||||||
|
} else if (event.key === 'Escape') {
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResultClick() {
|
||||||
|
isOpen = false;
|
||||||
|
searchTerm = '';
|
||||||
|
results = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFocus() {
|
||||||
|
if (results.length > 0) {
|
||||||
|
isOpen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClickOutside(event: MouseEvent) {
|
||||||
|
if (containerRef && !containerRef.contains(event.target as Node)) {
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCoverSrc(novel: NovelDto): string | undefined {
|
||||||
|
return novel.coverImage?.newPath ?? novel.coverImage?.originalPath ?? undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
document.addEventListener('click', handleClickOutside);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('click', handleClickOutside);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="relative max-w-xs" bind:this={containerRef}>
|
||||||
|
<div class="relative">
|
||||||
|
<Search class="absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
|
<Input
|
||||||
|
type="search"
|
||||||
|
placeholder="Search..."
|
||||||
|
class="pl-8"
|
||||||
|
value={searchTerm}
|
||||||
|
oninput={(e) => handleInput(e.currentTarget.value)}
|
||||||
|
onkeydown={handleKeydown}
|
||||||
|
onfocus={handleFocus}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if isOpen}
|
||||||
|
<div
|
||||||
|
class="absolute top-full left-0 right-0 z-50 mt-1 overflow-hidden rounded-md border bg-white shadow-lg dark:bg-gray-900"
|
||||||
|
>
|
||||||
|
{#if fetching}
|
||||||
|
<div class="px-4 py-3 text-sm text-muted-foreground">Searching...</div>
|
||||||
|
{:else if results.length === 0}
|
||||||
|
<div class="px-4 py-3 text-sm text-muted-foreground">No results found</div>
|
||||||
|
{:else}
|
||||||
|
{#each results as novel (novel.id)}
|
||||||
|
<a
|
||||||
|
href="/novels/{novel.id}"
|
||||||
|
class="flex items-center gap-3 px-3 py-2 hover:bg-muted transition-colors"
|
||||||
|
onclick={handleResultClick}
|
||||||
|
>
|
||||||
|
{#if getCoverSrc(novel)}
|
||||||
|
<img
|
||||||
|
src={getCoverSrc(novel)}
|
||||||
|
alt=""
|
||||||
|
class="h-12 w-9 rounded object-cover flex-shrink-0"
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="h-12 w-9 rounded bg-muted flex-shrink-0"></div>
|
||||||
|
{/if}
|
||||||
|
<span class="text-sm font-medium truncate">{novel.name}</span>
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
211
fictionarchive-web-astro/src/lib/components/SettingsPage.svelte
Normal file
211
fictionarchive-web-astro/src/lib/components/SettingsPage.svelte
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { client } from '$lib/graphql/client';
|
||||||
|
import {
|
||||||
|
GetSettingsPageDataDocument,
|
||||||
|
InviteUserDocument,
|
||||||
|
type GetSettingsPageDataQuery
|
||||||
|
} from '$lib/graphql/__generated__/graphql';
|
||||||
|
import * as Tabs from '$lib/components/ui/tabs';
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
import { Input } from '$lib/components/ui/input';
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
import { Badge } from '$lib/components/ui/badge';
|
||||||
|
|
||||||
|
let currentUser: GetSettingsPageDataQuery['currentUser'] | null = $state(null);
|
||||||
|
let fetching = $state(true);
|
||||||
|
let error: string | null = $state(null);
|
||||||
|
|
||||||
|
// Form state
|
||||||
|
let email = $state('');
|
||||||
|
let username = $state('');
|
||||||
|
let submitting = $state(false);
|
||||||
|
let formError: string | null = $state(null);
|
||||||
|
let formSuccess = $state(false);
|
||||||
|
|
||||||
|
const availableInvites = $derived(currentUser?.availableInvites ?? 0);
|
||||||
|
const canInvite = $derived(availableInvites > 0 && !submitting && !formSuccess);
|
||||||
|
|
||||||
|
async function fetchData() {
|
||||||
|
fetching = true;
|
||||||
|
error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client.query(GetSettingsPageDataDocument, {}).toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
error = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data) {
|
||||||
|
currentUser = result.data.currentUser;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = e instanceof Error ? e.message : 'Unknown error';
|
||||||
|
} finally {
|
||||||
|
fetching = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleInvite(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!email.trim() || !username.trim()) {
|
||||||
|
formError = 'Please fill in all fields';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitting = true;
|
||||||
|
formError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client
|
||||||
|
.mutation(InviteUserDocument, {
|
||||||
|
input: { email: email.trim(), username: username.trim() }
|
||||||
|
})
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
formError = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data?.inviteUser?.errors?.length) {
|
||||||
|
formError = result.data.inviteUser.errors[0].message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data?.inviteUser?.userDto) {
|
||||||
|
formSuccess = true;
|
||||||
|
// Refresh data to update invite count and list
|
||||||
|
await fetchData();
|
||||||
|
// Reset form after delay
|
||||||
|
setTimeout(() => {
|
||||||
|
email = '';
|
||||||
|
username = '';
|
||||||
|
formSuccess = false;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
formError = e instanceof Error ? e.message : 'Unknown error occurred';
|
||||||
|
} finally {
|
||||||
|
submitting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
fetchData();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="space-y-6">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-3xl font-bold">Settings</h1>
|
||||||
|
<p class="text-muted-foreground">Manage your account settings</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if fetching}
|
||||||
|
<div class="flex items-center justify-center py-12">
|
||||||
|
<div class="text-muted-foreground">Loading...</div>
|
||||||
|
</div>
|
||||||
|
{:else if error}
|
||||||
|
<Card>
|
||||||
|
<CardContent class="py-6">
|
||||||
|
<p class="text-destructive">{error}</p>
|
||||||
|
<Button class="mt-4" onclick={fetchData}>Try Again</Button>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{:else}
|
||||||
|
<Tabs.Root value="invites">
|
||||||
|
<Tabs.List class="mb-6">
|
||||||
|
<Tabs.Trigger value="invites">Invites</Tabs.Trigger>
|
||||||
|
</Tabs.List>
|
||||||
|
|
||||||
|
<Tabs.Content value="invites" class="space-y-6">
|
||||||
|
<!-- Invite Form -->
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle class="flex items-center gap-3">
|
||||||
|
Invite a User
|
||||||
|
<Badge variant={availableInvites > 0 ? 'default' : 'secondary'}>
|
||||||
|
{availableInvites} remaining
|
||||||
|
</Badge>
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onsubmit={handleInvite} class="space-y-4">
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label for="invite-email" class="text-sm font-medium">Email</label>
|
||||||
|
<Input
|
||||||
|
id="invite-email"
|
||||||
|
type="email"
|
||||||
|
placeholder="user@example.com"
|
||||||
|
bind:value={email}
|
||||||
|
disabled={!canInvite}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label for="invite-username" class="text-sm font-medium">Username</label>
|
||||||
|
<Input
|
||||||
|
id="invite-username"
|
||||||
|
type="text"
|
||||||
|
placeholder="username"
|
||||||
|
bind:value={username}
|
||||||
|
disabled={!canInvite}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if formError}
|
||||||
|
<p class="text-destructive text-sm">{formError}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if formSuccess}
|
||||||
|
<p class="text-green-600 dark:text-green-400 text-sm">
|
||||||
|
Invitation sent successfully! The user will receive an email to set up their account.
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Button type="submit" disabled={!canInvite || !email.trim() || !username.trim()}>
|
||||||
|
{#if submitting}
|
||||||
|
Sending...
|
||||||
|
{:else if formSuccess}
|
||||||
|
Sent!
|
||||||
|
{:else}
|
||||||
|
Send Invite
|
||||||
|
{/if}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<!-- Invited Users List -->
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Invited Users</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
{#if !currentUser?.invitedUsers?.length}
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
You haven't invited anyone yet.
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<div class="divide-y">
|
||||||
|
{#each currentUser.invitedUsers as user (user.username)}
|
||||||
|
<div class="flex items-center justify-between py-3 first:pt-0 last:pb-0">
|
||||||
|
<div>
|
||||||
|
<p class="font-medium">{user.username}</p>
|
||||||
|
<p class="text-muted-foreground text-sm">{user.email}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</Tabs.Content>
|
||||||
|
</Tabs.Root>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Accordion as AccordionPrimitive } from 'bits-ui';
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
|
import type { ComponentProps } from 'svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: ComponentProps<typeof AccordionPrimitive.Content> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<AccordionPrimitive.Content
|
||||||
|
class={cn('overflow-hidden text-sm transition-all', className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
<div class="pb-4 pt-0">
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
|
</AccordionPrimitive.Content>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Accordion as AccordionPrimitive } from 'bits-ui';
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
|
import type { ComponentProps } from 'svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: ComponentProps<typeof AccordionPrimitive.Item> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<AccordionPrimitive.Item class={cn('border-b', className)} {...restProps}>
|
||||||
|
{@render children?.()}
|
||||||
|
</AccordionPrimitive.Item>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Accordion as AccordionPrimitive } from 'bits-ui';
|
||||||
|
import { cn } from '$lib/utils.js';
|
||||||
|
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||||
|
import type { ComponentProps } from 'svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: ComponentProps<typeof AccordionPrimitive.Trigger> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<AccordionPrimitive.Header class="flex">
|
||||||
|
<AccordionPrimitive.Trigger
|
||||||
|
class={cn(
|
||||||
|
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
<ChevronDown class="h-4 w-4 shrink-0 transition-transform duration-200" />
|
||||||
|
</AccordionPrimitive.Trigger>
|
||||||
|
</AccordionPrimitive.Header>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Accordion as AccordionPrimitive } from 'bits-ui';
|
||||||
|
import Item from './accordion-item.svelte';
|
||||||
|
import Trigger from './accordion-trigger.svelte';
|
||||||
|
import Content from './accordion-content.svelte';
|
||||||
|
|
||||||
|
const Root = AccordionPrimitive.Root;
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
Item,
|
||||||
|
Trigger,
|
||||||
|
Content,
|
||||||
|
//
|
||||||
|
Root as Accordion,
|
||||||
|
Item as AccordionItem,
|
||||||
|
Trigger as AccordionTrigger,
|
||||||
|
Content as AccordionContent
|
||||||
|
};
|
||||||
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
|
||||||
|
};
|
||||||
3
fictionarchive-web-astro/src/lib/constants/systemTags.ts
Normal file
3
fictionarchive-web-astro/src/lib/constants/systemTags.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const SystemTags = {
|
||||||
|
Nsfw: 'Nsfw'
|
||||||
|
} as const;
|
||||||
@@ -29,46 +29,58 @@ export const ApplyPolicy = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type ApplyPolicy = typeof ApplyPolicy[keyof typeof ApplyPolicy];
|
export type ApplyPolicy = typeof ApplyPolicy[keyof typeof ApplyPolicy];
|
||||||
export type Chapter = {
|
export type ChapterDto = {
|
||||||
body: LocalizationKey;
|
body: Scalars['String']['output'];
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
id: Scalars['UnsignedInt']['output'];
|
id: Scalars['UnsignedInt']['output'];
|
||||||
images: Array<Image>;
|
images: Array<ImageDto>;
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
name: LocalizationKey;
|
name: Scalars['String']['output'];
|
||||||
order: Scalars['UnsignedInt']['output'];
|
order: Scalars['UnsignedInt']['output'];
|
||||||
revision: Scalars['UnsignedInt']['output'];
|
revision: Scalars['UnsignedInt']['output'];
|
||||||
url: Maybe<Scalars['String']['output']>;
|
url: Maybe<Scalars['String']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChapterFilterInput = {
|
export type ChapterDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<ChapterFilterInput>>;
|
and?: InputMaybe<Array<ChapterDtoFilterInput>>;
|
||||||
body?: InputMaybe<LocalizationKeyFilterInput>;
|
body?: InputMaybe<StringOperationFilterInput>;
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
images?: InputMaybe<ListFilterInputTypeOfImageFilterInput>;
|
images?: InputMaybe<ListFilterInputTypeOfImageDtoFilterInput>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
name?: InputMaybe<StringOperationFilterInput>;
|
||||||
or?: InputMaybe<Array<ChapterFilterInput>>;
|
or?: InputMaybe<Array<ChapterDtoFilterInput>>;
|
||||||
order?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
order?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
revision?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
revision?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
url?: InputMaybe<StringOperationFilterInput>;
|
url?: InputMaybe<StringOperationFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChapterPullRequestedEvent = {
|
export type ChapterPullRequestedEvent = {
|
||||||
chapterNumber: Scalars['UnsignedInt']['output'];
|
chapterOrder: Scalars['UnsignedInt']['output'];
|
||||||
novelId: Scalars['UnsignedInt']['output'];
|
novelId: Scalars['UnsignedInt']['output'];
|
||||||
|
volumeId: Scalars['UnsignedInt']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChapterSortInput = {
|
export type ChapterReaderDto = {
|
||||||
body?: InputMaybe<LocalizationKeySortInput>;
|
body: Scalars['String']['output'];
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime: Scalars['Instant']['output'];
|
||||||
id?: InputMaybe<SortEnumType>;
|
id: Scalars['UnsignedInt']['output'];
|
||||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
images: Array<ImageDto>;
|
||||||
name?: InputMaybe<LocalizationKeySortInput>;
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
order?: InputMaybe<SortEnumType>;
|
name: Scalars['String']['output'];
|
||||||
revision?: InputMaybe<SortEnumType>;
|
nextChapterOrder: Maybe<Scalars['UnsignedInt']['output']>;
|
||||||
url?: InputMaybe<SortEnumType>;
|
nextChapterVolumeOrder: Maybe<Scalars['Int']['output']>;
|
||||||
|
novelId: Scalars['UnsignedInt']['output'];
|
||||||
|
novelName: Scalars['String']['output'];
|
||||||
|
order: Scalars['UnsignedInt']['output'];
|
||||||
|
prevChapterOrder: Maybe<Scalars['UnsignedInt']['output']>;
|
||||||
|
prevChapterVolumeOrder: Maybe<Scalars['Int']['output']>;
|
||||||
|
revision: Scalars['UnsignedInt']['output'];
|
||||||
|
totalChaptersInVolume: Scalars['Int']['output'];
|
||||||
|
url: Maybe<Scalars['String']['output']>;
|
||||||
|
volumeId: Scalars['UnsignedInt']['output'];
|
||||||
|
volumeName: Scalars['String']['output'];
|
||||||
|
volumeOrder: Scalars['Int']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteJobError = KeyNotFoundError;
|
export type DeleteJobError = KeyNotFoundError;
|
||||||
@@ -82,6 +94,17 @@ export type DeleteJobPayload = {
|
|||||||
errors: Maybe<Array<DeleteJobError>>;
|
errors: Maybe<Array<DeleteJobError>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DeleteNovelError = KeyNotFoundError;
|
||||||
|
|
||||||
|
export type DeleteNovelInput = {
|
||||||
|
novelId: Scalars['UnsignedInt']['input'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteNovelPayload = {
|
||||||
|
boolean: Maybe<Scalars['Boolean']['output']>;
|
||||||
|
errors: Maybe<Array<DeleteNovelError>>;
|
||||||
|
};
|
||||||
|
|
||||||
export type DuplicateNameError = Error & {
|
export type DuplicateNameError = Error & {
|
||||||
message: Scalars['String']['output'];
|
message: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
@@ -91,8 +114,9 @@ export type Error = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type FetchChapterContentsInput = {
|
export type FetchChapterContentsInput = {
|
||||||
chapterNumber: Scalars['UnsignedInt']['input'];
|
chapterOrder: Scalars['UnsignedInt']['input'];
|
||||||
novelId: Scalars['UnsignedInt']['input'];
|
novelId: Scalars['UnsignedInt']['input'];
|
||||||
|
volumeId: Scalars['UnsignedInt']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FetchChapterContentsPayload = {
|
export type FetchChapterContentsPayload = {
|
||||||
@@ -103,33 +127,27 @@ export type FormatError = Error & {
|
|||||||
message: Scalars['String']['output'];
|
message: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Image = {
|
export type ImageDto = {
|
||||||
chapter: Maybe<Chapter>;
|
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
id: Scalars['UUID']['output'];
|
id: Scalars['UUID']['output'];
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
newPath: Maybe<Scalars['String']['output']>;
|
newPath: Maybe<Scalars['String']['output']>;
|
||||||
originalPath: Scalars['String']['output'];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImageFilterInput = {
|
export type ImageDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<ImageFilterInput>>;
|
and?: InputMaybe<Array<ImageDtoFilterInput>>;
|
||||||
chapter?: InputMaybe<ChapterFilterInput>;
|
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
id?: InputMaybe<UuidOperationFilterInput>;
|
id?: InputMaybe<UuidOperationFilterInput>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
newPath?: InputMaybe<StringOperationFilterInput>;
|
newPath?: InputMaybe<StringOperationFilterInput>;
|
||||||
or?: InputMaybe<Array<ImageFilterInput>>;
|
or?: InputMaybe<Array<ImageDtoFilterInput>>;
|
||||||
originalPath?: InputMaybe<StringOperationFilterInput>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImageSortInput = {
|
export type ImageDtoSortInput = {
|
||||||
chapter?: InputMaybe<ChapterSortInput>;
|
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime?: InputMaybe<SortEnumType>;
|
||||||
id?: InputMaybe<SortEnumType>;
|
id?: InputMaybe<SortEnumType>;
|
||||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||||
newPath?: InputMaybe<SortEnumType>;
|
newPath?: InputMaybe<SortEnumType>;
|
||||||
originalPath?: InputMaybe<SortEnumType>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImportNovelInput = {
|
export type ImportNovelInput = {
|
||||||
@@ -145,6 +163,42 @@ export type InstantFilterInput = {
|
|||||||
or?: InputMaybe<Array<InstantFilterInput>>;
|
or?: InputMaybe<Array<InstantFilterInput>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type IntOperationFilterInput = {
|
||||||
|
eq?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
gt?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
gte?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
in?: InputMaybe<Array<InputMaybe<Scalars['Int']['input']>>>;
|
||||||
|
lt?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
lte?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
neq?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
ngt?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
ngte?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
nin?: InputMaybe<Array<InputMaybe<Scalars['Int']['input']>>>;
|
||||||
|
nlt?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
nlte?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InvalidOperationError = Error & {
|
||||||
|
message: Scalars['String']['output'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InviteUserError = InvalidOperationError;
|
||||||
|
|
||||||
|
export type InviteUserInput = {
|
||||||
|
email: Scalars['String']['input'];
|
||||||
|
username: Scalars['String']['input'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InviteUserPayload = {
|
||||||
|
errors: Maybe<Array<InviteUserError>>;
|
||||||
|
userDto: Maybe<UserDto>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InvitedUserDto = {
|
||||||
|
email: Scalars['String']['output'];
|
||||||
|
username: Scalars['String']['output'];
|
||||||
|
};
|
||||||
|
|
||||||
export type JobKey = {
|
export type JobKey = {
|
||||||
group: Scalars['String']['output'];
|
group: Scalars['String']['output'];
|
||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
@@ -178,88 +232,40 @@ export type LanguageOperationFilterInput = {
|
|||||||
nin?: InputMaybe<Array<Language>>;
|
nin?: InputMaybe<Array<Language>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListFilterInputTypeOfChapterFilterInput = {
|
export type ListFilterInputTypeOfChapterDtoFilterInput = {
|
||||||
all?: InputMaybe<ChapterFilterInput>;
|
all?: InputMaybe<ChapterDtoFilterInput>;
|
||||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
none?: InputMaybe<ChapterFilterInput>;
|
none?: InputMaybe<ChapterDtoFilterInput>;
|
||||||
some?: InputMaybe<ChapterFilterInput>;
|
some?: InputMaybe<ChapterDtoFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListFilterInputTypeOfImageFilterInput = {
|
export type ListFilterInputTypeOfImageDtoFilterInput = {
|
||||||
all?: InputMaybe<ImageFilterInput>;
|
all?: InputMaybe<ImageDtoFilterInput>;
|
||||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
none?: InputMaybe<ImageFilterInput>;
|
none?: InputMaybe<ImageDtoFilterInput>;
|
||||||
some?: InputMaybe<ImageFilterInput>;
|
some?: InputMaybe<ImageDtoFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListFilterInputTypeOfLocalizationTextFilterInput = {
|
export type ListFilterInputTypeOfNovelTagDtoFilterInput = {
|
||||||
all?: InputMaybe<LocalizationTextFilterInput>;
|
all?: InputMaybe<NovelTagDtoFilterInput>;
|
||||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
none?: InputMaybe<LocalizationTextFilterInput>;
|
none?: InputMaybe<NovelTagDtoFilterInput>;
|
||||||
some?: InputMaybe<LocalizationTextFilterInput>;
|
some?: InputMaybe<NovelTagDtoFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListFilterInputTypeOfNovelFilterInput = {
|
export type ListFilterInputTypeOfVolumeDtoFilterInput = {
|
||||||
all?: InputMaybe<NovelFilterInput>;
|
all?: InputMaybe<VolumeDtoFilterInput>;
|
||||||
any?: InputMaybe<Scalars['Boolean']['input']>;
|
any?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
none?: InputMaybe<NovelFilterInput>;
|
none?: InputMaybe<VolumeDtoFilterInput>;
|
||||||
some?: InputMaybe<NovelFilterInput>;
|
some?: InputMaybe<VolumeDtoFilterInput>;
|
||||||
};
|
|
||||||
|
|
||||||
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>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Mutation = {
|
export type Mutation = {
|
||||||
deleteJob: DeleteJobPayload;
|
deleteJob: DeleteJobPayload;
|
||||||
|
deleteNovel: DeleteNovelPayload;
|
||||||
fetchChapterContents: FetchChapterContentsPayload;
|
fetchChapterContents: FetchChapterContentsPayload;
|
||||||
importNovel: ImportNovelPayload;
|
importNovel: ImportNovelPayload;
|
||||||
registerUser: RegisterUserPayload;
|
inviteUser: InviteUserPayload;
|
||||||
runJob: RunJobPayload;
|
runJob: RunJobPayload;
|
||||||
scheduleEventJob: ScheduleEventJobPayload;
|
scheduleEventJob: ScheduleEventJobPayload;
|
||||||
translateText: TranslateTextPayload;
|
translateText: TranslateTextPayload;
|
||||||
@@ -271,6 +277,11 @@ export type MutationDeleteJobArgs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type MutationDeleteNovelArgs = {
|
||||||
|
input: DeleteNovelInput;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationFetchChapterContentsArgs = {
|
export type MutationFetchChapterContentsArgs = {
|
||||||
input: FetchChapterContentsInput;
|
input: FetchChapterContentsInput;
|
||||||
};
|
};
|
||||||
@@ -281,8 +292,8 @@ export type MutationImportNovelArgs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationRegisterUserArgs = {
|
export type MutationInviteUserArgs = {
|
||||||
input: RegisterUserInput;
|
input: InviteUserInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -300,56 +311,56 @@ export type MutationTranslateTextArgs = {
|
|||||||
input: TranslateTextInput;
|
input: TranslateTextInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Novel = {
|
export type NovelDto = {
|
||||||
author: Person;
|
author: PersonDto;
|
||||||
chapters: Array<Chapter>;
|
coverImage: Maybe<ImageDto>;
|
||||||
coverImage: Maybe<Image>;
|
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
description: LocalizationKey;
|
description: Scalars['String']['output'];
|
||||||
externalId: Scalars['String']['output'];
|
externalId: Scalars['String']['output'];
|
||||||
id: Scalars['UnsignedInt']['output'];
|
id: Scalars['UnsignedInt']['output'];
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
name: LocalizationKey;
|
name: Scalars['String']['output'];
|
||||||
rawLanguage: Language;
|
rawLanguage: Language;
|
||||||
rawStatus: NovelStatus;
|
rawStatus: NovelStatus;
|
||||||
source: Source;
|
source: SourceDto;
|
||||||
statusOverride: Maybe<NovelStatus>;
|
statusOverride: Maybe<NovelStatus>;
|
||||||
tags: Array<NovelTag>;
|
tags: Array<NovelTagDto>;
|
||||||
url: Scalars['String']['output'];
|
url: Scalars['String']['output'];
|
||||||
|
volumes: Array<VolumeDto>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NovelFilterInput = {
|
export type NovelDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<NovelFilterInput>>;
|
and?: InputMaybe<Array<NovelDtoFilterInput>>;
|
||||||
author?: InputMaybe<PersonFilterInput>;
|
author?: InputMaybe<PersonDtoFilterInput>;
|
||||||
chapters?: InputMaybe<ListFilterInputTypeOfChapterFilterInput>;
|
coverImage?: InputMaybe<ImageDtoFilterInput>;
|
||||||
coverImage?: InputMaybe<ImageFilterInput>;
|
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
description?: InputMaybe<LocalizationKeyFilterInput>;
|
description?: InputMaybe<StringOperationFilterInput>;
|
||||||
externalId?: InputMaybe<StringOperationFilterInput>;
|
externalId?: InputMaybe<StringOperationFilterInput>;
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
name?: InputMaybe<StringOperationFilterInput>;
|
||||||
or?: InputMaybe<Array<NovelFilterInput>>;
|
or?: InputMaybe<Array<NovelDtoFilterInput>>;
|
||||||
rawLanguage?: InputMaybe<LanguageOperationFilterInput>;
|
rawLanguage?: InputMaybe<LanguageOperationFilterInput>;
|
||||||
rawStatus?: InputMaybe<NovelStatusOperationFilterInput>;
|
rawStatus?: InputMaybe<NovelStatusOperationFilterInput>;
|
||||||
source?: InputMaybe<SourceFilterInput>;
|
source?: InputMaybe<SourceDtoFilterInput>;
|
||||||
statusOverride?: InputMaybe<NullableOfNovelStatusOperationFilterInput>;
|
statusOverride?: InputMaybe<NullableOfNovelStatusOperationFilterInput>;
|
||||||
tags?: InputMaybe<ListFilterInputTypeOfNovelTagFilterInput>;
|
tags?: InputMaybe<ListFilterInputTypeOfNovelTagDtoFilterInput>;
|
||||||
url?: InputMaybe<StringOperationFilterInput>;
|
url?: InputMaybe<StringOperationFilterInput>;
|
||||||
|
volumes?: InputMaybe<ListFilterInputTypeOfVolumeDtoFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NovelSortInput = {
|
export type NovelDtoSortInput = {
|
||||||
author?: InputMaybe<PersonSortInput>;
|
author?: InputMaybe<PersonDtoSortInput>;
|
||||||
coverImage?: InputMaybe<ImageSortInput>;
|
coverImage?: InputMaybe<ImageDtoSortInput>;
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime?: InputMaybe<SortEnumType>;
|
||||||
description?: InputMaybe<LocalizationKeySortInput>;
|
description?: InputMaybe<SortEnumType>;
|
||||||
externalId?: InputMaybe<SortEnumType>;
|
externalId?: InputMaybe<SortEnumType>;
|
||||||
id?: InputMaybe<SortEnumType>;
|
id?: InputMaybe<SortEnumType>;
|
||||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||||
name?: InputMaybe<LocalizationKeySortInput>;
|
name?: InputMaybe<SortEnumType>;
|
||||||
rawLanguage?: InputMaybe<SortEnumType>;
|
rawLanguage?: InputMaybe<SortEnumType>;
|
||||||
rawStatus?: InputMaybe<SortEnumType>;
|
rawStatus?: InputMaybe<SortEnumType>;
|
||||||
source?: InputMaybe<SourceSortInput>;
|
source?: InputMaybe<SourceDtoSortInput>;
|
||||||
statusOverride?: InputMaybe<SortEnumType>;
|
statusOverride?: InputMaybe<SortEnumType>;
|
||||||
url?: InputMaybe<SortEnumType>;
|
url?: InputMaybe<SortEnumType>;
|
||||||
};
|
};
|
||||||
@@ -370,27 +381,25 @@ export type NovelStatusOperationFilterInput = {
|
|||||||
nin?: InputMaybe<Array<NovelStatus>>;
|
nin?: InputMaybe<Array<NovelStatus>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NovelTag = {
|
export type NovelTagDto = {
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
displayName: LocalizationKey;
|
displayName: Scalars['String']['output'];
|
||||||
id: Scalars['UnsignedInt']['output'];
|
id: Scalars['UnsignedInt']['output'];
|
||||||
key: Scalars['String']['output'];
|
key: Scalars['String']['output'];
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
novels: Array<Novel>;
|
source: Maybe<SourceDto>;
|
||||||
source: Maybe<Source>;
|
|
||||||
tagType: TagType;
|
tagType: TagType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NovelTagFilterInput = {
|
export type NovelTagDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<NovelTagFilterInput>>;
|
and?: InputMaybe<Array<NovelTagDtoFilterInput>>;
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
displayName?: InputMaybe<LocalizationKeyFilterInput>;
|
displayName?: InputMaybe<StringOperationFilterInput>;
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
key?: InputMaybe<StringOperationFilterInput>;
|
key?: InputMaybe<StringOperationFilterInput>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
novels?: InputMaybe<ListFilterInputTypeOfNovelFilterInput>;
|
or?: InputMaybe<Array<NovelTagDtoFilterInput>>;
|
||||||
or?: InputMaybe<Array<NovelTagFilterInput>>;
|
source?: InputMaybe<SourceDtoFilterInput>;
|
||||||
source?: InputMaybe<SourceFilterInput>;
|
|
||||||
tagType?: InputMaybe<TagTypeOperationFilterInput>;
|
tagType?: InputMaybe<TagTypeOperationFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -403,7 +412,7 @@ export type NovelsConnection = {
|
|||||||
/** A list of edges. */
|
/** A list of edges. */
|
||||||
edges: Maybe<Array<NovelsEdge>>;
|
edges: Maybe<Array<NovelsEdge>>;
|
||||||
/** A flattened list of the nodes. */
|
/** A flattened list of the nodes. */
|
||||||
nodes: Maybe<Array<Novel>>;
|
nodes: Maybe<Array<NovelDto>>;
|
||||||
/** Information to aid in pagination. */
|
/** Information to aid in pagination. */
|
||||||
pageInfo: PageInfo;
|
pageInfo: PageInfo;
|
||||||
};
|
};
|
||||||
@@ -413,7 +422,7 @@ export type NovelsEdge = {
|
|||||||
/** A cursor for use in pagination. */
|
/** A cursor for use in pagination. */
|
||||||
cursor: Scalars['String']['output'];
|
cursor: Scalars['String']['output'];
|
||||||
/** The item at the end of the edge. */
|
/** The item at the end of the edge. */
|
||||||
node: Novel;
|
node: NovelDto;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NullableOfNovelStatusOperationFilterInput = {
|
export type NullableOfNovelStatusOperationFilterInput = {
|
||||||
@@ -435,38 +444,47 @@ export type PageInfo = {
|
|||||||
startCursor: Maybe<Scalars['String']['output']>;
|
startCursor: Maybe<Scalars['String']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Person = {
|
export type PersonDto = {
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
externalUrl: Maybe<Scalars['String']['output']>;
|
externalUrl: Maybe<Scalars['String']['output']>;
|
||||||
id: Scalars['UnsignedInt']['output'];
|
id: Scalars['UnsignedInt']['output'];
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
name: LocalizationKey;
|
name: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PersonFilterInput = {
|
export type PersonDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<PersonFilterInput>>;
|
and?: InputMaybe<Array<PersonDtoFilterInput>>;
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
externalUrl?: InputMaybe<StringOperationFilterInput>;
|
externalUrl?: InputMaybe<StringOperationFilterInput>;
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
name?: InputMaybe<LocalizationKeyFilterInput>;
|
name?: InputMaybe<StringOperationFilterInput>;
|
||||||
or?: InputMaybe<Array<PersonFilterInput>>;
|
or?: InputMaybe<Array<PersonDtoFilterInput>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PersonSortInput = {
|
export type PersonDtoSortInput = {
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime?: InputMaybe<SortEnumType>;
|
||||||
externalUrl?: InputMaybe<SortEnumType>;
|
externalUrl?: InputMaybe<SortEnumType>;
|
||||||
id?: InputMaybe<SortEnumType>;
|
id?: InputMaybe<SortEnumType>;
|
||||||
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
lastUpdatedTime?: InputMaybe<SortEnumType>;
|
||||||
name?: InputMaybe<LocalizationKeySortInput>;
|
name?: InputMaybe<SortEnumType>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Query = {
|
export type Query = {
|
||||||
|
chapter: Maybe<ChapterReaderDto>;
|
||||||
|
currentUser: Maybe<UserDto>;
|
||||||
jobs: Array<SchedulerJob>;
|
jobs: Array<SchedulerJob>;
|
||||||
novels: Maybe<NovelsConnection>;
|
novels: Maybe<NovelsConnection>;
|
||||||
translationEngines: Array<TranslationEngineDescriptor>;
|
translationEngines: Array<TranslationEngineDescriptor>;
|
||||||
translationRequests: Maybe<TranslationRequestsConnection>;
|
translationRequests: Maybe<TranslationRequestsConnection>;
|
||||||
users: Array<User>;
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type QueryChapterArgs = {
|
||||||
|
chapterOrder: Scalars['UnsignedInt']['input'];
|
||||||
|
novelId: Scalars['UnsignedInt']['input'];
|
||||||
|
preferredLanguage?: Language;
|
||||||
|
volumeOrder: Scalars['UnsignedInt']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -475,8 +493,9 @@ export type QueryNovelsArgs = {
|
|||||||
before?: InputMaybe<Scalars['String']['input']>;
|
before?: InputMaybe<Scalars['String']['input']>;
|
||||||
first?: InputMaybe<Scalars['Int']['input']>;
|
first?: InputMaybe<Scalars['Int']['input']>;
|
||||||
last?: InputMaybe<Scalars['Int']['input']>;
|
last?: InputMaybe<Scalars['Int']['input']>;
|
||||||
order?: InputMaybe<Array<NovelSortInput>>;
|
order?: InputMaybe<Array<NovelDtoSortInput>>;
|
||||||
where?: InputMaybe<NovelFilterInput>;
|
preferredLanguage?: Language;
|
||||||
|
where?: InputMaybe<NovelDtoFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -491,19 +510,8 @@ export type QueryTranslationRequestsArgs = {
|
|||||||
before?: InputMaybe<Scalars['String']['input']>;
|
before?: InputMaybe<Scalars['String']['input']>;
|
||||||
first?: InputMaybe<Scalars['Int']['input']>;
|
first?: InputMaybe<Scalars['Int']['input']>;
|
||||||
last?: InputMaybe<Scalars['Int']['input']>;
|
last?: InputMaybe<Scalars['Int']['input']>;
|
||||||
order?: InputMaybe<Array<TranslationRequestSortInput>>;
|
order?: InputMaybe<Array<TranslationRequestDtoSortInput>>;
|
||||||
where?: InputMaybe<TranslationRequestFilterInput>;
|
where?: InputMaybe<TranslationRequestDtoFilterInput>;
|
||||||
};
|
|
||||||
|
|
||||||
export type RegisterUserInput = {
|
|
||||||
email: Scalars['String']['input'];
|
|
||||||
inviterOAuthProviderId?: InputMaybe<Scalars['String']['input']>;
|
|
||||||
oAuthProviderId: Scalars['String']['input'];
|
|
||||||
username: Scalars['String']['input'];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RegisterUserPayload = {
|
|
||||||
user: Maybe<User>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RunJobError = JobPersistenceError;
|
export type RunJobError = JobPersistenceError;
|
||||||
@@ -546,7 +554,7 @@ export const SortEnumType = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type SortEnumType = typeof SortEnumType[keyof typeof SortEnumType];
|
export type SortEnumType = typeof SortEnumType[keyof typeof SortEnumType];
|
||||||
export type Source = {
|
export type SourceDto = {
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
id: Scalars['UnsignedInt']['output'];
|
id: Scalars['UnsignedInt']['output'];
|
||||||
key: Scalars['String']['output'];
|
key: Scalars['String']['output'];
|
||||||
@@ -555,18 +563,18 @@ export type Source = {
|
|||||||
url: Scalars['String']['output'];
|
url: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SourceFilterInput = {
|
export type SourceDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<SourceFilterInput>>;
|
and?: InputMaybe<Array<SourceDtoFilterInput>>;
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
key?: InputMaybe<StringOperationFilterInput>;
|
key?: InputMaybe<StringOperationFilterInput>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
name?: InputMaybe<StringOperationFilterInput>;
|
name?: InputMaybe<StringOperationFilterInput>;
|
||||||
or?: InputMaybe<Array<SourceFilterInput>>;
|
or?: InputMaybe<Array<SourceDtoFilterInput>>;
|
||||||
url?: InputMaybe<StringOperationFilterInput>;
|
url?: InputMaybe<StringOperationFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SourceSortInput = {
|
export type SourceDtoSortInput = {
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime?: InputMaybe<SortEnumType>;
|
||||||
id?: InputMaybe<SortEnumType>;
|
id?: InputMaybe<SortEnumType>;
|
||||||
key?: InputMaybe<SortEnumType>;
|
key?: InputMaybe<SortEnumType>;
|
||||||
@@ -616,13 +624,6 @@ export type TranslateTextPayload = {
|
|||||||
translationResult: Maybe<TranslationResult>;
|
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 = {
|
export type TranslationEngineDescriptor = {
|
||||||
displayName: Scalars['String']['output'];
|
displayName: Scalars['String']['output'];
|
||||||
key: Scalars['String']['output'];
|
key: Scalars['String']['output'];
|
||||||
@@ -640,16 +641,7 @@ export type TranslationEngineDescriptorSortInput = {
|
|||||||
key?: InputMaybe<SortEnumType>;
|
key?: InputMaybe<SortEnumType>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TranslationEngineFilterInput = {
|
export type TranslationRequestDto = {
|
||||||
and?: InputMaybe<Array<TranslationEngineFilterInput>>;
|
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
|
||||||
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
|
||||||
key?: InputMaybe<StringOperationFilterInput>;
|
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
|
||||||
or?: InputMaybe<Array<TranslationEngineFilterInput>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type TranslationRequest = {
|
|
||||||
billedCharacterCount: Scalars['UnsignedInt']['output'];
|
billedCharacterCount: Scalars['UnsignedInt']['output'];
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
from: Language;
|
from: Language;
|
||||||
@@ -662,14 +654,14 @@ export type TranslationRequest = {
|
|||||||
translationEngineKey: Scalars['String']['output'];
|
translationEngineKey: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TranslationRequestFilterInput = {
|
export type TranslationRequestDtoFilterInput = {
|
||||||
and?: InputMaybe<Array<TranslationRequestFilterInput>>;
|
and?: InputMaybe<Array<TranslationRequestDtoFilterInput>>;
|
||||||
billedCharacterCount?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
billedCharacterCount?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
createdTime?: InputMaybe<InstantFilterInput>;
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
from?: InputMaybe<LanguageOperationFilterInput>;
|
from?: InputMaybe<LanguageOperationFilterInput>;
|
||||||
id?: InputMaybe<UuidOperationFilterInput>;
|
id?: InputMaybe<UuidOperationFilterInput>;
|
||||||
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
or?: InputMaybe<Array<TranslationRequestFilterInput>>;
|
or?: InputMaybe<Array<TranslationRequestDtoFilterInput>>;
|
||||||
originalText?: InputMaybe<StringOperationFilterInput>;
|
originalText?: InputMaybe<StringOperationFilterInput>;
|
||||||
status?: InputMaybe<TranslationRequestStatusOperationFilterInput>;
|
status?: InputMaybe<TranslationRequestStatusOperationFilterInput>;
|
||||||
to?: InputMaybe<LanguageOperationFilterInput>;
|
to?: InputMaybe<LanguageOperationFilterInput>;
|
||||||
@@ -677,7 +669,7 @@ export type TranslationRequestFilterInput = {
|
|||||||
translationEngineKey?: InputMaybe<StringOperationFilterInput>;
|
translationEngineKey?: InputMaybe<StringOperationFilterInput>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TranslationRequestSortInput = {
|
export type TranslationRequestDtoSortInput = {
|
||||||
billedCharacterCount?: InputMaybe<SortEnumType>;
|
billedCharacterCount?: InputMaybe<SortEnumType>;
|
||||||
createdTime?: InputMaybe<SortEnumType>;
|
createdTime?: InputMaybe<SortEnumType>;
|
||||||
from?: InputMaybe<SortEnumType>;
|
from?: InputMaybe<SortEnumType>;
|
||||||
@@ -709,7 +701,7 @@ export type TranslationRequestsConnection = {
|
|||||||
/** A list of edges. */
|
/** A list of edges. */
|
||||||
edges: Maybe<Array<TranslationRequestsEdge>>;
|
edges: Maybe<Array<TranslationRequestsEdge>>;
|
||||||
/** A flattened list of the nodes. */
|
/** A flattened list of the nodes. */
|
||||||
nodes: Maybe<Array<TranslationRequest>>;
|
nodes: Maybe<Array<TranslationRequestDto>>;
|
||||||
/** Information to aid in pagination. */
|
/** Information to aid in pagination. */
|
||||||
pageInfo: PageInfo;
|
pageInfo: PageInfo;
|
||||||
};
|
};
|
||||||
@@ -719,7 +711,7 @@ export type TranslationRequestsEdge = {
|
|||||||
/** A cursor for use in pagination. */
|
/** A cursor for use in pagination. */
|
||||||
cursor: Scalars['String']['output'];
|
cursor: Scalars['String']['output'];
|
||||||
/** The item at the end of the edge. */
|
/** The item at the end of the edge. */
|
||||||
node: TranslationRequest;
|
node: TranslationRequestDto;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TranslationResult = {
|
export type TranslationResult = {
|
||||||
@@ -747,14 +739,15 @@ export type UnsignedIntOperationFilterInputType = {
|
|||||||
nlte?: InputMaybe<Scalars['UnsignedInt']['input']>;
|
nlte?: InputMaybe<Scalars['UnsignedInt']['input']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type User = {
|
export type UserDto = {
|
||||||
|
availableInvites: Scalars['Int']['output'];
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
disabled: Scalars['Boolean']['output'];
|
disabled: Scalars['Boolean']['output'];
|
||||||
email: Scalars['String']['output'];
|
email: Scalars['String']['output'];
|
||||||
id: Scalars['UUID']['output'];
|
id: Scalars['UUID']['output'];
|
||||||
inviter: Maybe<User>;
|
invitedUsers: Maybe<Array<InvitedUserDto>>;
|
||||||
|
inviterId: Maybe<Scalars['UUID']['output']>;
|
||||||
lastUpdatedTime: Scalars['Instant']['output'];
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
oAuthProviderId: Scalars['String']['output'];
|
|
||||||
username: Scalars['String']['output'];
|
username: Scalars['String']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -773,13 +766,83 @@ export type UuidOperationFilterInput = {
|
|||||||
nlte?: InputMaybe<Scalars['UUID']['input']>;
|
nlte?: InputMaybe<Scalars['UUID']['input']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NovelsQueryVariables = Exact<{
|
export type VolumeDto = {
|
||||||
first?: InputMaybe<Scalars['Int']['input']>;
|
chapters: Array<ChapterDto>;
|
||||||
after?: InputMaybe<Scalars['String']['input']>;
|
createdTime: Scalars['Instant']['output'];
|
||||||
|
id: Scalars['UnsignedInt']['output'];
|
||||||
|
lastUpdatedTime: Scalars['Instant']['output'];
|
||||||
|
name: Scalars['String']['output'];
|
||||||
|
order: Scalars['Int']['output'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type VolumeDtoFilterInput = {
|
||||||
|
and?: InputMaybe<Array<VolumeDtoFilterInput>>;
|
||||||
|
chapters?: InputMaybe<ListFilterInputTypeOfChapterDtoFilterInput>;
|
||||||
|
createdTime?: InputMaybe<InstantFilterInput>;
|
||||||
|
id?: InputMaybe<UnsignedIntOperationFilterInputType>;
|
||||||
|
lastUpdatedTime?: InputMaybe<InstantFilterInput>;
|
||||||
|
name?: InputMaybe<StringOperationFilterInput>;
|
||||||
|
or?: InputMaybe<Array<VolumeDtoFilterInput>>;
|
||||||
|
order?: InputMaybe<IntOperationFilterInput>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteNovelMutationVariables = Exact<{
|
||||||
|
input: DeleteNovelInput;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
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 DeleteNovelMutation = { deleteNovel: { boolean: boolean | null, errors: Array<{ message: string }> | null } };
|
||||||
|
|
||||||
|
export type ImportNovelMutationVariables = Exact<{
|
||||||
|
input: ImportNovelInput;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
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 ImportNovelMutation = { importNovel: { novelUpdateRequestedEvent: { novelUrl: string } | null } };
|
||||||
|
|
||||||
|
export type InviteUserMutationVariables = Exact<{
|
||||||
|
input: InviteUserInput;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
export type InviteUserMutation = { inviteUser: { userDto: { id: any, username: string, email: string } | null, errors: Array<{ message: string }> | null } };
|
||||||
|
|
||||||
|
export type GetChapterQueryVariables = Exact<{
|
||||||
|
novelId: Scalars['UnsignedInt']['input'];
|
||||||
|
volumeOrder: Scalars['UnsignedInt']['input'];
|
||||||
|
chapterOrder: Scalars['UnsignedInt']['input'];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
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, volumeId: any, volumeName: string, volumeOrder: number, totalChaptersInVolume: number, prevChapterVolumeOrder: number | null, prevChapterOrder: any | null, nextChapterVolumeOrder: number | null, nextChapterOrder: any | null, images: Array<{ id: any, newPath: string | null }> } | null };
|
||||||
|
|
||||||
|
export type NovelQueryVariables = Exact<{
|
||||||
|
id: Scalars['UnsignedInt']['input'];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
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 }>, volumes: Array<{ id: any, order: number, name: string, createdTime: any, lastUpdatedTime: any, chapters: Array<{ id: any, order: any, name: string, lastUpdatedTime: any, images: Array<{ id: any, newPath: string | null }> }> }> }> | null } | null };
|
||||||
|
|
||||||
|
export type NovelsQueryVariables = Exact<{
|
||||||
|
first?: InputMaybe<Scalars['Int']['input']>;
|
||||||
|
after?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
where?: InputMaybe<NovelDtoFilterInput>;
|
||||||
|
order?: InputMaybe<Array<NovelDtoSortInput> | NovelDtoSortInput>;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
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, volumes: Array<{ id: any, order: number, name: string, chapters: Array<{ order: any, name: string }> }>, tags: Array<{ key: string, displayName: string, tagType: TagType }> } }> | null, pageInfo: { hasNextPage: boolean, endCursor: string | null } } | null };
|
||||||
|
|
||||||
|
export type GetSettingsPageDataQueryVariables = Exact<{ [key: string]: never; }>;
|
||||||
|
|
||||||
|
|
||||||
|
export type GetSettingsPageDataQuery = { currentUser: { id: any, username: string, availableInvites: number, invitedUsers: Array<{ username: string, email: string }> | null } | null };
|
||||||
|
|
||||||
|
|
||||||
|
export const DeleteNovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNovel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteNovelInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNovel"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"boolean"}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Error"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]}}]}}]} as unknown as DocumentNode<DeleteNovelMutation, DeleteNovelMutationVariables>;
|
||||||
|
export const ImportNovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ImportNovel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ImportNovelInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"importNovel"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novelUpdateRequestedEvent"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novelUrl"}}]}}]}}]}}]} as unknown as DocumentNode<ImportNovelMutation, ImportNovelMutationVariables>;
|
||||||
|
export const InviteUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"InviteUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"InviteUserInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"inviteUser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userDto"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"InvalidOperationError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]}}]}}]} as unknown as DocumentNode<InviteUserMutation, InviteUserMutationVariables>;
|
||||||
|
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":"volumeOrder"}},"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":"volumeOrder"},"value":{"kind":"Variable","name":{"kind":"Name","value":"volumeOrder"}}},{"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":"volumeId"}},{"kind":"Field","name":{"kind":"Name","value":"volumeName"}},{"kind":"Field","name":{"kind":"Name","value":"volumeOrder"}},{"kind":"Field","name":{"kind":"Name","value":"totalChaptersInVolume"}},{"kind":"Field","name":{"kind":"Name","value":"prevChapterVolumeOrder"}},{"kind":"Field","name":{"kind":"Name","value":"prevChapterOrder"}},{"kind":"Field","name":{"kind":"Name","value":"nextChapterVolumeOrder"}},{"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":"volumes"},"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":"createdTime"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"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"}},{"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"}}]}}]}}]}}]}}]}}]}}]} 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"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"order"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"NovelDtoSortInput"}}}}}],"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"}}},{"kind":"Argument","name":{"kind":"Name","value":"order"},"value":{"kind":"Variable","name":{"kind":"Name","value":"order"}}}],"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":"volumes"},"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":"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":"tagType"}}]}}]}}]}},{"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 const GetSettingsPageDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSettingsPageData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentUser"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"availableInvites"}},{"kind":"Field","name":{"kind":"Name","value":"invitedUsers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}}]}}]}}]} as unknown as DocumentNode<GetSettingsPageDataQuery, GetSettingsPageDataQueryVariables>;
|
||||||
@@ -1,19 +1,36 @@
|
|||||||
import { Client, cacheExchange, fetchExchange } from '@urql/core';
|
import { Client, cacheExchange, fetchExchange } from '@urql/core';
|
||||||
|
import { authExchange } from '@urql/exchange-auth';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import { user } from '../auth/authStore';
|
import { user, refreshToken } from '../auth/authStore';
|
||||||
|
|
||||||
export function createClient() {
|
export function createClient() {
|
||||||
return new Client({
|
return new Client({
|
||||||
url: import.meta.env.PUBLIC_GRAPHQL_URI,
|
url: import.meta.env.PUBLIC_GRAPHQL_URI,
|
||||||
exchanges: [cacheExchange, fetchExchange],
|
exchanges: [
|
||||||
fetchOptions: () => {
|
cacheExchange,
|
||||||
const currentUser = get(user);
|
authExchange(async (utils) => ({
|
||||||
return {
|
addAuthToOperation(operation) {
|
||||||
headers: currentUser?.access_token
|
const currentUser = get(user);
|
||||||
? { Authorization: `Bearer ${currentUser.access_token}` }
|
if (!currentUser?.access_token) return operation;
|
||||||
: {},
|
return utils.appendHeaders(operation, {
|
||||||
};
|
Authorization: `Bearer ${currentUser.access_token}`,
|
||||||
},
|
});
|
||||||
|
},
|
||||||
|
didAuthError(error) {
|
||||||
|
return error.graphQLErrors?.some(
|
||||||
|
(e) => e.extensions?.code === 'AUTH_NOT_AUTHENTICATED'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
async refreshAuth() {
|
||||||
|
const newUser = await refreshToken();
|
||||||
|
if (!newUser) {
|
||||||
|
// Refresh failed, redirect to login
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
fetchExchange,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
mutation DeleteNovel($input: DeleteNovelInput!) {
|
||||||
|
deleteNovel(input: $input) {
|
||||||
|
boolean
|
||||||
|
errors {
|
||||||
|
... on Error {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
mutation ImportNovel($input: ImportNovelInput!) {
|
||||||
|
importNovel(input: $input) {
|
||||||
|
novelUpdateRequestedEvent {
|
||||||
|
novelUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
mutation InviteUser($input: InviteUserInput!) {
|
||||||
|
inviteUser(input: $input) {
|
||||||
|
userDto {
|
||||||
|
id
|
||||||
|
username
|
||||||
|
email
|
||||||
|
}
|
||||||
|
errors {
|
||||||
|
... on InvalidOperationError {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
query GetChapter($novelId: UnsignedInt!, $volumeOrder: UnsignedInt!, $chapterOrder: UnsignedInt!) {
|
||||||
|
chapter(novelId: $novelId, volumeOrder: $volumeOrder, chapterOrder: $chapterOrder) {
|
||||||
|
id
|
||||||
|
order
|
||||||
|
name
|
||||||
|
body
|
||||||
|
url
|
||||||
|
revision
|
||||||
|
createdTime
|
||||||
|
lastUpdatedTime
|
||||||
|
|
||||||
|
images {
|
||||||
|
id
|
||||||
|
newPath
|
||||||
|
}
|
||||||
|
|
||||||
|
novelId
|
||||||
|
novelName
|
||||||
|
volumeId
|
||||||
|
volumeName
|
||||||
|
volumeOrder
|
||||||
|
totalChaptersInVolume
|
||||||
|
prevChapterVolumeOrder
|
||||||
|
prevChapterOrder
|
||||||
|
nextChapterVolumeOrder
|
||||||
|
nextChapterOrder
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
volumes {
|
||||||
|
id
|
||||||
|
order
|
||||||
|
name
|
||||||
|
createdTime
|
||||||
|
lastUpdatedTime
|
||||||
|
chapters {
|
||||||
|
id
|
||||||
|
order
|
||||||
|
name
|
||||||
|
lastUpdatedTime
|
||||||
|
images {
|
||||||
|
id
|
||||||
|
newPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +1,31 @@
|
|||||||
query Novels($first: Int, $after: String) {
|
query Novels($first: Int, $after: String, $where: NovelDtoFilterInput, $order: [NovelDtoSortInput!]) {
|
||||||
novels(first: $first, after: $after) {
|
novels(first: $first, after: $after, where: $where, order: $order) {
|
||||||
edges {
|
edges {
|
||||||
cursor
|
cursor
|
||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
url
|
url
|
||||||
name {
|
name
|
||||||
texts {
|
description
|
||||||
language
|
|
||||||
text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
description {
|
|
||||||
texts {
|
|
||||||
language
|
|
||||||
text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
coverImage {
|
coverImage {
|
||||||
originalPath
|
|
||||||
newPath
|
newPath
|
||||||
}
|
}
|
||||||
rawStatus
|
rawStatus
|
||||||
lastUpdatedTime
|
lastUpdatedTime
|
||||||
chapters {
|
volumes {
|
||||||
|
id
|
||||||
order
|
order
|
||||||
name {
|
name
|
||||||
texts {
|
chapters {
|
||||||
language
|
order
|
||||||
text
|
name
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tags {
|
||||||
|
key
|
||||||
|
displayName
|
||||||
|
tagType
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageInfo {
|
pageInfo {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
query GetSettingsPageData {
|
||||||
|
currentUser {
|
||||||
|
id
|
||||||
|
username
|
||||||
|
availableInvites
|
||||||
|
invitedUsers {
|
||||||
|
username
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
175
fictionarchive-web-astro/src/lib/utils/filterParams.ts
Normal file
175
fictionarchive-web-astro/src/lib/utils/filterParams.ts
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
import type { NovelDtoFilterInput, NovelDtoSortInput, NovelStatus, SortEnumType } from '$lib/graphql/__generated__/graphql';
|
||||||
|
|
||||||
|
export type SortField = 'lastUpdatedTime' | 'createdTime' | 'name';
|
||||||
|
export type SortDirection = SortEnumType;
|
||||||
|
|
||||||
|
export interface NovelSort {
|
||||||
|
field: SortField;
|
||||||
|
direction: SortDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NovelFilters {
|
||||||
|
search: string;
|
||||||
|
statuses: NovelStatus[];
|
||||||
|
tags: string[];
|
||||||
|
authorName: string;
|
||||||
|
sort: NovelSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_SORT: NovelSort = {
|
||||||
|
field: 'lastUpdatedTime',
|
||||||
|
direction: 'DESC'
|
||||||
|
};
|
||||||
|
|
||||||
|
export const EMPTY_FILTERS: NovelFilters = {
|
||||||
|
search: '',
|
||||||
|
statuses: [],
|
||||||
|
tags: [],
|
||||||
|
authorName: '',
|
||||||
|
sort: DEFAULT_SORT
|
||||||
|
};
|
||||||
|
|
||||||
|
const VALID_STATUSES: NovelStatus[] = ['ABANDONED', 'COMPLETED', 'HIATUS', 'IN_PROGRESS', 'UNKNOWN'];
|
||||||
|
const VALID_SORT_FIELDS: SortField[] = ['lastUpdatedTime', 'createdTime', 'name'];
|
||||||
|
const VALID_SORT_DIRECTIONS: SortDirection[] = ['ASC', 'DESC'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
const authorName = params.get('author') ?? '';
|
||||||
|
|
||||||
|
// Parse sort parameters
|
||||||
|
const sortField = params.get('sortBy') as SortField | null;
|
||||||
|
const sortDir = params.get('sortDir') as SortDirection | null;
|
||||||
|
const sort: NovelSort = {
|
||||||
|
field: sortField && VALID_SORT_FIELDS.includes(sortField) ? sortField : DEFAULT_SORT.field,
|
||||||
|
direction: sortDir && VALID_SORT_DIRECTIONS.includes(sortDir) ? sortDir : DEFAULT_SORT.direction
|
||||||
|
};
|
||||||
|
|
||||||
|
return { search, statuses, tags, authorName, sort };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filters.authorName.trim()) {
|
||||||
|
params.set('author', filters.authorName.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only include sort params if different from default
|
||||||
|
if (filters.sort.field !== DEFAULT_SORT.field || filters.sort.direction !== DEFAULT_SORT.direction) {
|
||||||
|
params.set('sortBy', filters.sort.field);
|
||||||
|
params.set('sortDir', filters.sort.direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Author filter (exact match on author name)
|
||||||
|
if (filters.authorName.trim()) {
|
||||||
|
conditions.push({
|
||||||
|
author: {
|
||||||
|
name: { eq: filters.authorName.trim() }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 ||
|
||||||
|
filters.authorName.trim().length > 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert sort state to GraphQL order input
|
||||||
|
*/
|
||||||
|
export function sortToGraphQLOrder(sort: NovelSort): NovelDtoSortInput[] {
|
||||||
|
return [{ [sort.field]: sort.direction }];
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitizes HTML content, allowing only safe inline formatting elements.
|
* Sanitizes HTML content, allowing only safe inline formatting elements.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user