Compare commits
1 Commits
epic/FA-mi
...
feature/FA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f88f340d0a |
@@ -0,0 +1,35 @@
|
||||
using FictionArchive.Service.AuthenticationService.Models.Requests;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace FictionArchive.Service.AuthenticationService.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class AuthenticationWebhookController : ControllerBase
|
||||
{
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
|
||||
public AuthenticationWebhookController(IPublishEndpoint publishEndpoint)
|
||||
{
|
||||
_publishEndpoint = publishEndpoint;
|
||||
}
|
||||
|
||||
[HttpPost(nameof(UserRegistered))]
|
||||
public async Task<ActionResult> UserRegistered([FromBody] UserRegisteredWebhookPayload payload)
|
||||
{
|
||||
var authUserAddedEvent = new AuthUserAddedEvent
|
||||
{
|
||||
OAuthProviderId = payload.OAuthProviderId,
|
||||
InviterOAuthProviderId = payload.InviterOAuthProviderId,
|
||||
EventUserEmail = payload.EventUserEmail,
|
||||
EventUserUsername = payload.EventUserUsername
|
||||
};
|
||||
|
||||
await _publishEndpoint.Publish(authUserAddedEvent);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
FictionArchive.Service.AuthenticationService/Dockerfile
Normal file
23
FictionArchive.Service.AuthenticationService/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["FictionArchive.Service.AuthenticationService/FictionArchive.Service.AuthenticationService.csproj", "FictionArchive.Service.AuthenticationService/"]
|
||||
RUN dotnet restore "FictionArchive.Service.AuthenticationService/FictionArchive.Service.AuthenticationService.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/FictionArchive.Service.AuthenticationService"
|
||||
RUN dotnet build "./FictionArchive.Service.AuthenticationService.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./FictionArchive.Service.AuthenticationService.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "FictionArchive.Service.AuthenticationService.dll"]
|
||||
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FictionArchive.Service.Shared\FictionArchive.Service.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@FictionArchive.Service.AuthenticationService_HostAddress = http://localhost:5091
|
||||
|
||||
GET {{FictionArchive.Service.AuthenticationService_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace FictionArchive.Service.AuthenticationService.Models.Requests;
|
||||
|
||||
public class UserRegisteredWebhookPayload
|
||||
{
|
||||
// The body of the notification message
|
||||
public string Body { get; set; }
|
||||
|
||||
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; }
|
||||
}
|
||||
45
FictionArchive.Service.AuthenticationService/Program.cs
Normal file
45
FictionArchive.Service.AuthenticationService/Program.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.AuthenticationService;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
#region MassTransit
|
||||
|
||||
builder.Services.AddFictionArchiveMassTransit(builder.Configuration);
|
||||
|
||||
#endregion
|
||||
|
||||
builder.Services.AddHealthChecks();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapHealthChecks("/healthz");
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:23522",
|
||||
"sslPort": 44397
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5091",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7223;http://localhost:5091",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using Amazon.S3;
|
||||
using Amazon.S3.Model;
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.FileService.Contracts;
|
||||
using FictionArchive.Service.FileService.Models;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FictionArchive.Service.FileService.Consumers;
|
||||
|
||||
public class FileUploadRequestCreatedConsumer : IConsumer<IFileUploadRequestCreated>
|
||||
{
|
||||
private readonly ILogger<FileUploadRequestCreatedConsumer> _logger;
|
||||
private readonly AmazonS3Client _amazonS3Client;
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
private readonly S3Configuration _s3Configuration;
|
||||
private readonly ProxyConfiguration _proxyConfiguration;
|
||||
|
||||
public FileUploadRequestCreatedConsumer(
|
||||
ILogger<FileUploadRequestCreatedConsumer> logger,
|
||||
AmazonS3Client amazonS3Client,
|
||||
IPublishEndpoint publishEndpoint,
|
||||
IOptions<S3Configuration> s3Configuration,
|
||||
IOptions<ProxyConfiguration> proxyConfiguration)
|
||||
{
|
||||
_logger = logger;
|
||||
_amazonS3Client = amazonS3Client;
|
||||
_publishEndpoint = publishEndpoint;
|
||||
_s3Configuration = s3Configuration.Value;
|
||||
_proxyConfiguration = proxyConfiguration.Value;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IFileUploadRequestCreated> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
var putObjectRequest = new PutObjectRequest
|
||||
{
|
||||
BucketName = _s3Configuration.Bucket,
|
||||
Key = message.FilePath
|
||||
};
|
||||
|
||||
using var memoryStream = new MemoryStream(message.FileData);
|
||||
putObjectRequest.InputStream = memoryStream;
|
||||
|
||||
var s3Response = await _amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
|
||||
if (s3Response.HttpStatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogError("Failed to upload file {FilePath} to S3", message.FilePath);
|
||||
|
||||
await _publishEndpoint.Publish<IFileUploadRequestStatusUpdate>(
|
||||
new FileUploadRequestStatusUpdate(
|
||||
RequestId: message.RequestId,
|
||||
Status: RequestStatus.Failed,
|
||||
FileAccessUrl: null,
|
||||
ErrorMessage: "An error occurred while uploading file to S3."));
|
||||
return;
|
||||
}
|
||||
|
||||
var fileAccessUrl = _proxyConfiguration.BaseUrl + "/" + message.FilePath;
|
||||
|
||||
_logger.LogInformation("Successfully uploaded file {FilePath} to S3", message.FilePath);
|
||||
|
||||
await _publishEndpoint.Publish<IFileUploadRequestStatusUpdate>(
|
||||
new FileUploadRequestStatusUpdate(
|
||||
RequestId: message.RequestId,
|
||||
Status: RequestStatus.Success,
|
||||
FileAccessUrl: fileAccessUrl,
|
||||
ErrorMessage: null));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.FileService.Contracts;
|
||||
|
||||
public record FileUploadRequestStatusUpdate(
|
||||
Guid RequestId,
|
||||
RequestStatus Status,
|
||||
string? FileAccessUrl,
|
||||
string? ErrorMessage) : IFileUploadRequestStatusUpdate;
|
||||
@@ -1,9 +1,10 @@
|
||||
using Amazon.Runtime;
|
||||
using Amazon.S3;
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.FileService.Consumers;
|
||||
using FictionArchive.Service.FileService.Models;
|
||||
using FictionArchive.Service.FileService.Services.EventHandlers;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FictionArchive.Service.FileService;
|
||||
@@ -28,7 +29,7 @@ public class Program
|
||||
builder.Configuration,
|
||||
x =>
|
||||
{
|
||||
x.AddConsumer<FileUploadRequestCreatedConsumer>();
|
||||
x.AddConsumer<UploadFileCommandConsumer>();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using Amazon.S3;
|
||||
using Amazon.S3.Model;
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.FileService.Models;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FictionArchive.Service.FileService.Services.EventHandlers;
|
||||
|
||||
public class UploadFileCommandConsumer : IConsumer<UploadFileCommand>
|
||||
{
|
||||
private readonly ILogger<UploadFileCommandConsumer> _logger;
|
||||
private readonly AmazonS3Client _amazonS3Client;
|
||||
private readonly S3Configuration _s3Configuration;
|
||||
private readonly ProxyConfiguration _proxyConfiguration;
|
||||
|
||||
public UploadFileCommandConsumer(
|
||||
ILogger<UploadFileCommandConsumer> logger,
|
||||
AmazonS3Client amazonS3Client,
|
||||
IOptions<S3Configuration> s3Configuration,
|
||||
IOptions<ProxyConfiguration> proxyConfiguration)
|
||||
{
|
||||
_logger = logger;
|
||||
_amazonS3Client = amazonS3Client;
|
||||
_proxyConfiguration = proxyConfiguration.Value;
|
||||
_s3Configuration = s3Configuration.Value;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<UploadFileCommand> context)
|
||||
{
|
||||
var command = context.Message;
|
||||
|
||||
var putObjectRequest = new PutObjectRequest();
|
||||
putObjectRequest.BucketName = _s3Configuration.Bucket;
|
||||
putObjectRequest.Key = command.FilePath;
|
||||
putObjectRequest.UseChunkEncoding = false; // Needed to avoid an error with Garage
|
||||
|
||||
using MemoryStream memoryStream = new MemoryStream(command.FileData);
|
||||
putObjectRequest.InputStream = memoryStream;
|
||||
|
||||
var s3Response = await _amazonS3Client.PutObjectAsync(putObjectRequest);
|
||||
if (s3Response.HttpStatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogError("An error occurred while uploading file to S3. Response code: {responsecode}", s3Response.HttpStatusCode);
|
||||
await context.Publish(new FileUploadCompletedEvent
|
||||
{
|
||||
RequestId = command.RequestId,
|
||||
Status = RequestStatus.Failed,
|
||||
ErrorMessage = "An error occurred while uploading file to S3."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await context.Publish(new FileUploadCompletedEvent
|
||||
{
|
||||
Status = RequestStatus.Success,
|
||||
RequestId = command.RequestId,
|
||||
FileAccessUrl = _proxyConfiguration.BaseUrl + "/" + command.FilePath
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,17 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ProxyConfiguration": {
|
||||
"BaseUrl": "https://localhost:7247/api"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "FileService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"S3": {
|
||||
"Url": "https://s3.orfl.xyz",
|
||||
|
||||
@@ -7,10 +7,10 @@ using FictionArchive.Service.NovelService.Models.Novels;
|
||||
using FictionArchive.Service.NovelService.Models.SourceAdapters;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using FluentAssertions;
|
||||
using HtmlAgilityPack;
|
||||
using MassTransit;
|
||||
using HtmlAgilityPack;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -73,6 +73,7 @@ public class NovelUpdateServiceTests
|
||||
NovelServiceDbContext dbContext,
|
||||
ISourceAdapter adapter,
|
||||
IPublishEndpoint publishEndpoint,
|
||||
ISendEndpointProvider sendEndpointProvider,
|
||||
string pendingImageUrl = "https://pending/placeholder.jpg")
|
||||
{
|
||||
var options = Options.Create(new NovelUpdateServiceConfiguration
|
||||
@@ -80,7 +81,7 @@ public class NovelUpdateServiceTests
|
||||
PendingImageUrl = pendingImageUrl
|
||||
});
|
||||
|
||||
return new NovelUpdateService(dbContext, NullLogger<NovelUpdateService>.Instance, new[] { adapter }, publishEndpoint, options);
|
||||
return new NovelUpdateService(dbContext, NullLogger<NovelUpdateService>.Instance, new[] { adapter }, publishEndpoint, sendEndpointProvider, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -102,13 +103,15 @@ public class NovelUpdateServiceTests
|
||||
ImageData = new List<ImageData> { image1, image2 }
|
||||
}));
|
||||
|
||||
var publishedEvents = new List<IFileUploadRequestCreated>();
|
||||
var publishedCommands = new List<UploadFileCommand>();
|
||||
var publishEndpoint = Substitute.For<IPublishEndpoint>();
|
||||
publishEndpoint.Publish(Arg.Do<IFileUploadRequestCreated>(e => publishedEvents.Add(e)), Arg.Any<CancellationToken>())
|
||||
.Returns(Task.CompletedTask);
|
||||
var sendEndpointProvider = Substitute.For<ISendEndpointProvider>();
|
||||
var sendEndpoint = Substitute.For<ISendEndpoint>();
|
||||
sendEndpointProvider.GetSendEndpoint(Arg.Any<Uri>()).Returns(Task.FromResult(sendEndpoint));
|
||||
sendEndpoint.Send(Arg.Do<UploadFileCommand>(publishedCommands.Add), Arg.Any<CancellationToken>()).Returns(Task.CompletedTask);
|
||||
|
||||
var pendingImageUrl = "https://pending/placeholder.jpg";
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, pendingImageUrl);
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, sendEndpointProvider, pendingImageUrl);
|
||||
|
||||
var updatedChapter = await service.PullChapterContents(novel.Id, volume.Id, chapter.Order);
|
||||
|
||||
@@ -127,10 +130,10 @@ public class NovelUpdateServiceTests
|
||||
.Should()
|
||||
.BeEquivalentTo(updatedChapter.Images.Select(img => img.Id.ToString()));
|
||||
|
||||
publishedEvents.Should().HaveCount(2);
|
||||
publishedEvents.Select(e => e.RequestId).Should().BeEquivalentTo(updatedChapter.Images.Select(i => i.Id));
|
||||
publishedEvents.Select(e => e.FileData).Should().BeEquivalentTo(new[] { image1.Data, image2.Data });
|
||||
publishedEvents.Should().OnlyContain(e => e.FilePath.StartsWith($"{novel.Id}/Images/Chapter-{updatedChapter.Id}/"));
|
||||
publishedCommands.Should().HaveCount(2);
|
||||
publishedCommands.Select(e => e.RequestId).Should().BeEquivalentTo(updatedChapter.Images.Select(i => i.Id));
|
||||
publishedCommands.Select(e => e.FileData).Should().BeEquivalentTo(new[] { image1.Data, image2.Data });
|
||||
publishedCommands.Should().OnlyContain(e => e.FilePath.StartsWith($"{novel.Id}/Images/Chapter-{updatedChapter.Id}/"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -152,8 +155,11 @@ public class NovelUpdateServiceTests
|
||||
}));
|
||||
|
||||
var publishEndpoint = Substitute.For<IPublishEndpoint>();
|
||||
var sendEndpointProvider = Substitute.For<ISendEndpointProvider>();
|
||||
var sendEndpoint = Substitute.For<ISendEndpoint>();
|
||||
sendEndpointProvider.GetSendEndpoint(Arg.Any<Uri>()).Returns(Task.FromResult(sendEndpoint));
|
||||
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint);
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, sendEndpointProvider);
|
||||
|
||||
var updatedChapter = await service.PullChapterContents(novel.Id, volume.Id, chapter.Order);
|
||||
|
||||
@@ -185,7 +191,8 @@ public class NovelUpdateServiceTests
|
||||
|
||||
var adapter = Substitute.For<ISourceAdapter>();
|
||||
var publishEndpoint = Substitute.For<IPublishEndpoint>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint);
|
||||
var sendEndpointProvider = Substitute.For<ISendEndpointProvider>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, sendEndpointProvider);
|
||||
|
||||
var newUrl = "https://cdn.example.com/uploaded/cover.jpg";
|
||||
|
||||
@@ -227,7 +234,8 @@ public class NovelUpdateServiceTests
|
||||
|
||||
var adapter = Substitute.For<ISourceAdapter>();
|
||||
var publishEndpoint = Substitute.For<IPublishEndpoint>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, pendingUrl);
|
||||
var sendEndpointProvider = Substitute.For<ISendEndpointProvider>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, sendEndpointProvider, pendingUrl);
|
||||
|
||||
var newUrl = "https://cdn.example.com/uploaded/image.jpg";
|
||||
|
||||
@@ -276,7 +284,8 @@ public class NovelUpdateServiceTests
|
||||
|
||||
var adapter = Substitute.For<ISourceAdapter>();
|
||||
var publishEndpoint = Substitute.For<IPublishEndpoint>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, pendingUrl);
|
||||
var sendEndpointProvider = Substitute.For<ISendEndpointProvider>();
|
||||
var service = CreateService(dbContext, adapter, publishEndpoint, sendEndpointProvider, pendingUrl);
|
||||
|
||||
var newUrl = "https://cdn.example.com/uploaded/img1.jpg";
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Consumers;
|
||||
|
||||
public class ChapterPullRequestedConsumer : IConsumer<IChapterPullRequested>
|
||||
{
|
||||
private readonly ILogger<ChapterPullRequestedConsumer> _logger;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public ChapterPullRequestedConsumer(
|
||||
ILogger<ChapterPullRequestedConsumer> logger,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IChapterPullRequested> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
await _novelUpdateService.PullChapterContents(message.NovelId, message.VolumeId, message.ChapterOrder);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Consumers;
|
||||
|
||||
public class FileUploadRequestStatusUpdateConsumer : IConsumer<IFileUploadRequestStatusUpdate>
|
||||
{
|
||||
private readonly ILogger<FileUploadRequestStatusUpdateConsumer> _logger;
|
||||
private readonly NovelServiceDbContext _dbContext;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public FileUploadRequestStatusUpdateConsumer(
|
||||
ILogger<FileUploadRequestStatusUpdateConsumer> logger,
|
||||
NovelServiceDbContext dbContext,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IFileUploadRequestStatusUpdate> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
var image = await _dbContext.Images.FindAsync(message.RequestId);
|
||||
if (image == null)
|
||||
{
|
||||
// Not a request we care about.
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.Status == RequestStatus.Failed)
|
||||
{
|
||||
_logger.LogError("Image upload failed for image with id {imageId}", image.Id);
|
||||
return;
|
||||
}
|
||||
else if (message.Status == RequestStatus.Success)
|
||||
{
|
||||
_logger.LogInformation("Image upload succeeded for image with id {imageId}", image.Id);
|
||||
await _novelUpdateService.UpdateImage(image.Id, message.FileAccessUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Consumers;
|
||||
|
||||
public class NovelUpdateRequestedConsumer : IConsumer<INovelUpdateRequested>
|
||||
{
|
||||
private readonly ILogger<NovelUpdateRequestedConsumer> _logger;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public NovelUpdateRequestedConsumer(
|
||||
ILogger<NovelUpdateRequestedConsumer> logger,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<INovelUpdateRequested> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
await _novelUpdateService.ImportNovel(message.NovelUrl);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
using FictionArchive.Service.NovelService.Models.Localization;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Consumers;
|
||||
|
||||
public class TranslationRequestCompletedConsumer : IConsumer<ITranslationRequestCompleted>
|
||||
{
|
||||
private readonly ILogger<TranslationRequestCompletedConsumer> _logger;
|
||||
private readonly NovelServiceDbContext _dbContext;
|
||||
|
||||
public TranslationRequestCompletedConsumer(
|
||||
ILogger<TranslationRequestCompletedConsumer> logger,
|
||||
NovelServiceDbContext dbContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ITranslationRequestCompleted> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
var localizationRequest = await _dbContext.LocalizationRequests
|
||||
.Include(r => r.KeyRequestedForTranslation)
|
||||
.ThenInclude(lk => lk.Texts)
|
||||
.FirstOrDefaultAsync(lk => lk.Id == message.TranslationRequestId);
|
||||
|
||||
if (localizationRequest == null)
|
||||
{
|
||||
// Not one of our requests, discard it
|
||||
return;
|
||||
}
|
||||
|
||||
localizationRequest.KeyRequestedForTranslation.Texts.Add(new LocalizationText
|
||||
{
|
||||
Language = localizationRequest.TranslateTo,
|
||||
Text = message.TranslatedText,
|
||||
TranslationEngine = localizationRequest.Engine
|
||||
});
|
||||
|
||||
_dbContext.LocalizationRequests.Remove(localizationRequest);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record ChapterCreated(
|
||||
uint ChapterId,
|
||||
uint NovelId,
|
||||
uint VolumeId,
|
||||
uint VolumeOrder,
|
||||
uint ChapterOrder,
|
||||
string ChapterTitle) : IChapterCreated;
|
||||
@@ -1,8 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record ChapterPullRequested(
|
||||
uint NovelId,
|
||||
uint VolumeId,
|
||||
uint ChapterOrder) : IChapterPullRequested;
|
||||
@@ -1,8 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record FileUploadRequestCreated(
|
||||
Guid RequestId,
|
||||
string FilePath,
|
||||
byte[] FileData) : IFileUploadRequestCreated;
|
||||
@@ -1,11 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record NovelCreated(
|
||||
uint NovelId,
|
||||
string Title,
|
||||
Language OriginalLanguage,
|
||||
string Source,
|
||||
string AuthorName) : INovelCreated;
|
||||
@@ -1,6 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record NovelUpdateRequested(
|
||||
string NovelUrl) : INovelUpdateRequested;
|
||||
@@ -1,11 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Contracts;
|
||||
|
||||
public record TranslationRequestCreated(
|
||||
Guid TranslationRequestId,
|
||||
Language From,
|
||||
Language To,
|
||||
string Body,
|
||||
string TranslationEngineKey) : ITranslationRequestCreated;
|
||||
@@ -1,26 +1,20 @@
|
||||
using FictionArchive.Service.NovelService.Contracts;
|
||||
using FictionArchive.Service.NovelService.Models.Enums;
|
||||
using FictionArchive.Service.NovelService.Models.Localization;
|
||||
using FictionArchive.Service.NovelService.Models.Novels;
|
||||
using FictionArchive.Service.NovelService.Models.SourceAdapters;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using HotChocolate.Authorization;
|
||||
using HotChocolate.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.GraphQL;
|
||||
|
||||
public class Mutation
|
||||
{
|
||||
[Authorize]
|
||||
public async Task<NovelUpdateRequested> ImportNovel(string novelUrl, NovelUpdateService service)
|
||||
public async Task<ImportNovelCommand> ImportNovel(string novelUrl, NovelUpdateService service)
|
||||
{
|
||||
return await service.QueueNovelImport(novelUrl);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public async Task<ChapterPullRequested> FetchChapterContents(
|
||||
public async Task<PullChapterContentCommand> FetchChapterContents(
|
||||
uint novelId,
|
||||
uint volumeId,
|
||||
uint chapterOrder,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.NovelService.Consumers;
|
||||
using FictionArchive.Service.NovelService.GraphQL;
|
||||
using FictionArchive.Service.NovelService.Models.Configuration;
|
||||
using FictionArchive.Service.NovelService.Services;
|
||||
using FictionArchive.Service.NovelService.Services.Consumers;
|
||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||
using FictionArchive.Service.NovelService.Services.SourceAdapters.Novelpia;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using FictionArchive.Service.Shared.Services.GraphQL;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -27,14 +28,14 @@ public class Program
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddFictionArchiveMassTransit(
|
||||
builder.Services.AddFictionArchiveMassTransit<NovelServiceDbContext>(
|
||||
builder.Configuration,
|
||||
x =>
|
||||
cfg =>
|
||||
{
|
||||
x.AddConsumer<TranslationRequestCompletedConsumer>();
|
||||
x.AddConsumer<FileUploadRequestStatusUpdateConsumer>();
|
||||
x.AddConsumer<NovelUpdateRequestedConsumer>();
|
||||
x.AddConsumer<ChapterPullRequestedConsumer>();
|
||||
cfg.AddConsumer<ImportNovelCommandConsumer>();
|
||||
cfg.AddConsumer<PullChapterContentCommandConsumer>();
|
||||
cfg.AddConsumer<TranslationCompletedEventConsumer>();
|
||||
cfg.AddConsumer<FileUploadCompletedEventConsumer>();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Services.Consumers;
|
||||
|
||||
public class FileUploadCompletedEventConsumer : IConsumer<FileUploadCompletedEvent>
|
||||
{
|
||||
private readonly ILogger<FileUploadCompletedEventConsumer> _logger;
|
||||
private readonly NovelServiceDbContext _dbContext;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public FileUploadCompletedEventConsumer(
|
||||
ILogger<FileUploadCompletedEventConsumer> logger,
|
||||
NovelServiceDbContext dbContext,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<FileUploadCompletedEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
|
||||
var image = await _dbContext.Images.FindAsync(@event.RequestId);
|
||||
if (image == null)
|
||||
{
|
||||
// Not a request we care about.
|
||||
_logger.LogDebug(
|
||||
"FileUploadCompletedEvent received for unknown image: {RequestId}",
|
||||
@event.RequestId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (@event.Status == RequestStatus.Failed)
|
||||
{
|
||||
_logger.LogError(
|
||||
"Image upload failed for image with id {ImageId}: {ErrorMessage}",
|
||||
image.Id, @event.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (@event.Status == RequestStatus.Success)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
"Image upload succeeded for image with id {ImageId}",
|
||||
image.Id);
|
||||
await _novelUpdateService.UpdateImage(image.Id, @event.FileAccessUrl!);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Services.Consumers;
|
||||
|
||||
public class ImportNovelCommandConsumer : IConsumer<ImportNovelCommand>
|
||||
{
|
||||
private readonly ILogger<ImportNovelCommandConsumer> _logger;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public ImportNovelCommandConsumer(
|
||||
ILogger<ImportNovelCommandConsumer> logger,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ImportNovelCommand> context)
|
||||
{
|
||||
var command = context.Message;
|
||||
_logger.LogInformation("Processing ImportNovelCommand for URL: {NovelUrl}", command.NovelUrl);
|
||||
|
||||
await _novelUpdateService.ImportNovel(command.NovelUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Services.Consumers;
|
||||
|
||||
public class PullChapterContentCommandConsumer : IConsumer<PullChapterContentCommand>
|
||||
{
|
||||
private readonly ILogger<PullChapterContentCommandConsumer> _logger;
|
||||
private readonly NovelUpdateService _novelUpdateService;
|
||||
|
||||
public PullChapterContentCommandConsumer(
|
||||
ILogger<PullChapterContentCommandConsumer> logger,
|
||||
NovelUpdateService novelUpdateService)
|
||||
{
|
||||
_logger = logger;
|
||||
_novelUpdateService = novelUpdateService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<PullChapterContentCommand> context)
|
||||
{
|
||||
var command = context.Message;
|
||||
_logger.LogInformation(
|
||||
"Processing PullChapterContentCommand for Novel: {NovelId}, Volume: {VolumeId}, Chapter: {ChapterOrder}",
|
||||
command.NovelId, command.VolumeId, command.ChapterOrder);
|
||||
|
||||
await _novelUpdateService.PullChapterContents(command.NovelId, command.VolumeId, command.ChapterOrder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using FictionArchive.Service.NovelService.Models.Localization;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.NovelService.Services.Consumers;
|
||||
|
||||
public class TranslationCompletedEventConsumer : IConsumer<TranslationCompletedEvent>
|
||||
{
|
||||
private readonly ILogger<TranslationCompletedEventConsumer> _logger;
|
||||
private readonly NovelServiceDbContext _dbContext;
|
||||
|
||||
public TranslationCompletedEventConsumer(
|
||||
ILogger<TranslationCompletedEventConsumer> logger,
|
||||
NovelServiceDbContext dbContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<TranslationCompletedEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
|
||||
var localizationRequest = await _dbContext.LocalizationRequests
|
||||
.Include(r => r.KeyRequestedForTranslation)
|
||||
.ThenInclude(lk => lk.Texts)
|
||||
.FirstOrDefaultAsync(lk => lk.Id == @event.TranslationRequestId);
|
||||
|
||||
if (localizationRequest == null)
|
||||
{
|
||||
// Not one of our requests, discard it
|
||||
_logger.LogDebug(
|
||||
"TranslationCompletedEvent received for unknown request: {RequestId}",
|
||||
@event.TranslationRequestId);
|
||||
return;
|
||||
}
|
||||
|
||||
localizationRequest.KeyRequestedForTranslation.Texts.Add(new LocalizationText()
|
||||
{
|
||||
Language = localizationRequest.TranslateTo,
|
||||
Text = @event.TranslatedText,
|
||||
TranslationEngine = localizationRequest.Engine
|
||||
});
|
||||
_dbContext.LocalizationRequests.Remove(localizationRequest);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation(
|
||||
"Completed translation for request: {RequestId}",
|
||||
@event.TranslationRequestId);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.NovelService.Contracts;
|
||||
using FictionArchive.Service.NovelService.Models.Configuration;
|
||||
using FictionArchive.Service.NovelService.Models.Enums;
|
||||
using FictionArchive.Service.NovelService.Models.Images;
|
||||
@@ -7,7 +6,8 @@ using FictionArchive.Service.NovelService.Models.Localization;
|
||||
using FictionArchive.Service.NovelService.Models.Novels;
|
||||
using FictionArchive.Service.NovelService.Models.SourceAdapters;
|
||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using HtmlAgilityPack;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -21,14 +21,22 @@ public class NovelUpdateService
|
||||
private readonly ILogger<NovelUpdateService> _logger;
|
||||
private readonly IEnumerable<ISourceAdapter> _sourceAdapters;
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
private readonly ISendEndpointProvider _sendEndpointProvider;
|
||||
private readonly NovelUpdateServiceConfiguration _novelUpdateServiceConfiguration;
|
||||
|
||||
public NovelUpdateService(NovelServiceDbContext dbContext, ILogger<NovelUpdateService> logger, IEnumerable<ISourceAdapter> sourceAdapters, IPublishEndpoint publishEndpoint, IOptions<NovelUpdateServiceConfiguration> novelUpdateServiceConfiguration)
|
||||
public NovelUpdateService(
|
||||
NovelServiceDbContext dbContext,
|
||||
ILogger<NovelUpdateService> logger,
|
||||
IEnumerable<ISourceAdapter> sourceAdapters,
|
||||
IPublishEndpoint publishEndpoint,
|
||||
ISendEndpointProvider sendEndpointProvider,
|
||||
IOptions<NovelUpdateServiceConfiguration> novelUpdateServiceConfiguration)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
_sourceAdapters = sourceAdapters;
|
||||
_publishEndpoint = publishEndpoint;
|
||||
_sendEndpointProvider = sendEndpointProvider;
|
||||
_novelUpdateServiceConfiguration = novelUpdateServiceConfiguration.Value;
|
||||
}
|
||||
|
||||
@@ -335,8 +343,7 @@ public class NovelUpdateService
|
||||
.ThenInclude(volume => volume.Chapters)
|
||||
.ThenInclude(chapter => chapter.Body)
|
||||
.ThenInclude(localizationKey => localizationKey.Texts)
|
||||
.Include(n => n.CoverImage).Include(novel => novel.Volumes).ThenInclude(volume => volume.Chapters)
|
||||
.ThenInclude(chapter => chapter.Name)
|
||||
.Include(n => n.CoverImage)
|
||||
.FirstOrDefaultAsync(n =>
|
||||
n.ExternalId == metadata.ExternalId &&
|
||||
n.Source.Key == metadata.SourceDescriptor.Key);
|
||||
@@ -394,12 +401,14 @@ public class NovelUpdateService
|
||||
// Publish novel created event for new novels
|
||||
if (existingNovel == null)
|
||||
{
|
||||
await _publishEndpoint.Publish<INovelCreated>(new NovelCreated(
|
||||
novel.Id,
|
||||
novel.Name.Texts.First(t => t.Language == novel.RawLanguage).Text,
|
||||
novel.RawLanguage,
|
||||
novel.Source.Key,
|
||||
novel.Author.Name.Texts.First(t => t.Language == novel.RawLanguage).Text));
|
||||
await _publishEndpoint.Publish(new NovelCreatedEvent
|
||||
{
|
||||
NovelId = novel.Id,
|
||||
Title = novel.Name.Texts.First(t => t.Language == novel.RawLanguage).Text,
|
||||
OriginalLanguage = novel.RawLanguage,
|
||||
Source = novel.Source.Key,
|
||||
AuthorName = novel.Author.Name.Texts.First(t => t.Language == novel.RawLanguage).Text
|
||||
});
|
||||
}
|
||||
|
||||
// Publish chapter created events for new chapters
|
||||
@@ -407,26 +416,32 @@ public class NovelUpdateService
|
||||
{
|
||||
foreach (var chapter in volume.Chapters.Where(c => !existingChapterIds.Contains(c.Id)))
|
||||
{
|
||||
await _publishEndpoint.Publish<IChapterCreated>(new ChapterCreated(
|
||||
chapter.Id,
|
||||
novel.Id,
|
||||
volume.Id,
|
||||
(uint)volume.Order,
|
||||
chapter.Order,
|
||||
chapter.Name.Texts.First(t => t.Language == novel.RawLanguage).Text));
|
||||
await _publishEndpoint.Publish(new ChapterCreatedEvent
|
||||
{
|
||||
ChapterId = chapter.Id,
|
||||
NovelId = novel.Id,
|
||||
VolumeId = volume.Id,
|
||||
VolumeOrder = volume.Order,
|
||||
ChapterOrder = chapter.Order,
|
||||
ChapterTitle = chapter.Name.Texts.First(t => t.Language == novel.RawLanguage).Text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Publish cover image event if needed
|
||||
// Send cover image upload command if needed
|
||||
if (shouldPublishCoverEvent && novel.CoverImage != null && metadata.CoverImage != null)
|
||||
{
|
||||
await _publishEndpoint.Publish<IFileUploadRequestCreated>(new FileUploadRequestCreated(
|
||||
novel.CoverImage.Id,
|
||||
$"Novels/{novel.Id}/Images/cover.jpg",
|
||||
metadata.CoverImage.Data));
|
||||
var uploadEndpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("queue:upload-file-command"));
|
||||
await uploadEndpoint.Send(new UploadFileCommand
|
||||
{
|
||||
RequestId = novel.CoverImage.Id,
|
||||
FileData = metadata.CoverImage.Data,
|
||||
FilePath = $"Novels/{novel.Id}/Images/cover.jpg"
|
||||
});
|
||||
}
|
||||
|
||||
// Publish chapter pull events for chapters without body content
|
||||
// Send chapter pull commands for chapters without body content
|
||||
var pullChapterEndpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("queue:pull-chapter-content-command"));
|
||||
foreach (var volume in novel.Volumes)
|
||||
{
|
||||
var chaptersNeedingPull = volume.Chapters
|
||||
@@ -435,10 +450,12 @@ public class NovelUpdateService
|
||||
|
||||
foreach (var chapter in chaptersNeedingPull)
|
||||
{
|
||||
await _publishEndpoint.Publish<IChapterPullRequested>(new ChapterPullRequested(
|
||||
novel.Id,
|
||||
volume.Id,
|
||||
chapter.Order));
|
||||
await pullChapterEndpoint.Send(new PullChapterContentCommand
|
||||
{
|
||||
NovelId = novel.Id,
|
||||
VolumeId = volume.Id,
|
||||
ChapterOrder = chapter.Order
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,15 +523,18 @@ public class NovelUpdateService
|
||||
localizationText.Text = chapterDoc.DocumentNode.OuterHtml;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
// Body was updated, raise image request
|
||||
// Body was updated, send upload commands for images
|
||||
var uploadEndpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("queue:upload-file-command"));
|
||||
int imgCount = 0;
|
||||
foreach (var image in chapter.Images)
|
||||
{
|
||||
var data = rawChapter.ImageData.FirstOrDefault(img => img.Url == image.OriginalPath);
|
||||
await _publishEndpoint.Publish<IFileUploadRequestCreated>(new FileUploadRequestCreated(
|
||||
image.Id,
|
||||
$"Novels/{novel.Id}/Images/Chapter-{chapter.Id}/{imgCount++}.jpg",
|
||||
data.Data));
|
||||
await uploadEndpoint.Send(new UploadFileCommand
|
||||
{
|
||||
FileData = data.Data,
|
||||
FilePath = $"{novel.Id}/Images/Chapter-{chapter.Id}/{imgCount++}.jpg",
|
||||
RequestId = image.Id
|
||||
});
|
||||
}
|
||||
|
||||
return chapter;
|
||||
@@ -548,18 +568,28 @@ public class NovelUpdateService
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<NovelUpdateRequested> QueueNovelImport(string novelUrl)
|
||||
public async Task<ImportNovelCommand> QueueNovelImport(string novelUrl)
|
||||
{
|
||||
var importNovelRequestEvent = new NovelUpdateRequested(novelUrl);
|
||||
await _publishEndpoint.Publish<INovelUpdateRequested>(importNovelRequestEvent);
|
||||
return importNovelRequestEvent;
|
||||
var command = new ImportNovelCommand
|
||||
{
|
||||
NovelUrl = novelUrl
|
||||
};
|
||||
var endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("queue:import-novel-command"));
|
||||
await endpoint.Send(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
public async Task<ChapterPullRequested> QueueChapterPull(uint novelId, uint volumeId, uint chapterOrder)
|
||||
public async Task<PullChapterContentCommand> QueueChapterPull(uint novelId, uint volumeId, uint chapterOrder)
|
||||
{
|
||||
var chapterPullEvent = new ChapterPullRequested(novelId, volumeId, chapterOrder);
|
||||
await _publishEndpoint.Publish<IChapterPullRequested>(chapterPullEvent);
|
||||
return chapterPullEvent;
|
||||
var command = new PullChapterContentCommand
|
||||
{
|
||||
NovelId = novelId,
|
||||
VolumeId = volumeId,
|
||||
ChapterOrder = chapterOrder
|
||||
};
|
||||
var endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("queue:pull-chapter-content-command"));
|
||||
await endpoint.Send(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
public async Task DeleteNovel(uint novelId)
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"Novelpia": {
|
||||
@@ -17,8 +16,10 @@
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_NovelService;Username=postgres;password=postgres"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "NovelService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"OIDC": {
|
||||
|
||||
23
FictionArchive.Service.ReportingService/Dockerfile
Normal file
23
FictionArchive.Service.ReportingService/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["FictionArchive.Service.ReportingService/FictionArchive.Service.ReportingService.csproj", "FictionArchive.Service.ReportingService/"]
|
||||
RUN dotnet restore "FictionArchive.Service.ReportingService/FictionArchive.Service.ReportingService.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/FictionArchive.Service.ReportingService"
|
||||
RUN dotnet build "./FictionArchive.Service.ReportingService.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./FictionArchive.Service.ReportingService.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "FictionArchive.Service.ReportingService.dll"]
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FictionArchive.Service.Shared\FictionArchive.Service.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
15
FictionArchive.Service.ReportingService/GraphQL/Mutation.cs
Normal file
15
FictionArchive.Service.ReportingService/GraphQL/Mutation.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using HotChocolate;
|
||||
using HotChocolate.Authorization;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.GraphQL;
|
||||
|
||||
public class Mutation
|
||||
{
|
||||
/// <summary>
|
||||
/// Placeholder mutation for GraphQL schema requirements.
|
||||
/// The ReportingService is primarily read-only, consuming events from other services.
|
||||
/// </summary>
|
||||
[Authorize(Roles = ["admin"])]
|
||||
[GraphQLDescription("Placeholder mutation. ReportingService is primarily read-only.")]
|
||||
public bool Ping() => true;
|
||||
}
|
||||
52
FictionArchive.Service.ReportingService/GraphQL/Query.cs
Normal file
52
FictionArchive.Service.ReportingService/GraphQL/Query.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Text.Json;
|
||||
using FictionArchive.Service.ReportingService.Models.Database;
|
||||
using FictionArchive.Service.ReportingService.Models.DTOs;
|
||||
using FictionArchive.Service.ReportingService.Services;
|
||||
using HotChocolate;
|
||||
using HotChocolate.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.GraphQL;
|
||||
|
||||
public class Query
|
||||
{
|
||||
[UseProjection]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
[GraphQLName("reportingJobs")]
|
||||
public IQueryable<Job> GetReportingJobs(ReportingServiceDbContext dbContext)
|
||||
=> dbContext.Jobs.Include(j => j.History);
|
||||
|
||||
[GraphQLName("reportingJob")]
|
||||
public async Task<JobDto?> GetReportingJob(Guid id, ReportingServiceDbContext dbContext)
|
||||
{
|
||||
var job = await dbContext.Jobs
|
||||
.Include(j => j.History.OrderBy(h => h.Timestamp))
|
||||
.FirstOrDefaultAsync(j => j.Id == id);
|
||||
|
||||
if (job == null) return null;
|
||||
|
||||
return new JobDto
|
||||
{
|
||||
Id = job.Id,
|
||||
JobType = job.JobType,
|
||||
Status = job.Status,
|
||||
CurrentStep = job.CurrentStep,
|
||||
ErrorMessage = job.ErrorMessage,
|
||||
Metadata = job.Metadata != null
|
||||
? JsonSerializer.Deserialize<Dictionary<string, object>>(job.Metadata.RootElement.GetRawText())
|
||||
: null,
|
||||
History = job.History.Select(h => new JobHistoryEntryDto
|
||||
{
|
||||
FromState = h.FromState,
|
||||
ToState = h.ToState,
|
||||
Message = h.Message,
|
||||
Error = h.Error,
|
||||
Timestamp = h.Timestamp
|
||||
}).ToList(),
|
||||
CreatedTime = job.CreatedTime,
|
||||
UpdatedTime = job.UpdatedTime,
|
||||
CompletedTime = job.CompletedTime
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Models.DTOs;
|
||||
|
||||
public class JobDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string JobType { get; set; }
|
||||
public required string Status { get; set; }
|
||||
public string? CurrentStep { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public Dictionary<string, object>? Metadata { get; set; }
|
||||
public List<JobHistoryEntryDto> History { get; set; } = new();
|
||||
public Instant CreatedTime { get; set; }
|
||||
public Instant UpdatedTime { get; set; }
|
||||
public Instant? CompletedTime { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Models.DTOs;
|
||||
|
||||
public class JobHistoryEntryDto
|
||||
{
|
||||
public required string FromState { get; set; }
|
||||
public required string ToState { get; set; }
|
||||
public string? Message { get; set; }
|
||||
public string? Error { get; set; }
|
||||
public Instant Timestamp { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json;
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Models.Database;
|
||||
|
||||
public class Job
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string JobType { get; set; }
|
||||
public required string Status { get; set; }
|
||||
public string? CurrentStep { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public JsonDocument? Metadata { get; set; }
|
||||
public Instant CreatedTime { get; set; }
|
||||
public Instant UpdatedTime { get; set; }
|
||||
public Instant? CompletedTime { get; set; }
|
||||
|
||||
public ICollection<JobHistoryEntry> History { get; set; } = new List<JobHistoryEntry>();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Models.Database;
|
||||
|
||||
public class JobHistoryEntry
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid JobId { get; set; }
|
||||
public required string FromState { get; set; }
|
||||
public required string ToState { get; set; }
|
||||
public string? Message { get; set; }
|
||||
public string? Error { get; set; }
|
||||
public Instant Timestamp { get; set; }
|
||||
|
||||
public Job Job { get; set; } = null!;
|
||||
}
|
||||
76
FictionArchive.Service.ReportingService/Program.cs
Normal file
76
FictionArchive.Service.ReportingService/Program.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.ReportingService.GraphQL;
|
||||
using FictionArchive.Service.ReportingService.Services;
|
||||
using FictionArchive.Service.ReportingService.Services.Consumers;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var isSchemaExport = SchemaExportDetector.IsSchemaExportMode(args);
|
||||
|
||||
builder.AddLocalAppsettings();
|
||||
|
||||
builder.Services.AddHealthChecks();
|
||||
|
||||
#region Database
|
||||
|
||||
builder.Services.RegisterDbContext<ReportingServiceDbContext>(
|
||||
builder.Configuration.GetConnectionString("DefaultConnection")!,
|
||||
skipInfrastructure: isSchemaExport);
|
||||
|
||||
#endregion
|
||||
|
||||
#region MassTransit
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddFictionArchiveMassTransit<ReportingServiceDbContext>(
|
||||
builder.Configuration,
|
||||
x =>
|
||||
{
|
||||
x.AddConsumer<JobStateChangedEventConsumer>();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GraphQL
|
||||
|
||||
builder.Services.AddDefaultGraphQl<Query, Mutation>()
|
||||
.AddAuthorization();
|
||||
|
||||
#endregion
|
||||
|
||||
// Authentication & Authorization
|
||||
builder.Services.AddOidcAuthentication(builder.Configuration);
|
||||
builder.Services.AddFictionArchiveAuthorization();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<ReportingServiceDbContext>();
|
||||
dbContext.UpdateDatabase();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapHealthChecks("/healthz");
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapGraphQL();
|
||||
|
||||
app.RunWithGraphQLCommands(args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:45320",
|
||||
"sslPort": 44320
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5180",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "graphql",
|
||||
"applicationUrl": "https://localhost:7320;http://localhost:5180",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Text.Json;
|
||||
using FictionArchive.Service.ReportingService.Models.Database;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Services.Consumers;
|
||||
|
||||
public class JobStateChangedEventConsumer : IConsumer<JobStateChangedEvent>
|
||||
{
|
||||
private readonly ReportingServiceDbContext _dbContext;
|
||||
private readonly ILogger<JobStateChangedEventConsumer> _logger;
|
||||
|
||||
public JobStateChangedEventConsumer(
|
||||
ReportingServiceDbContext dbContext,
|
||||
ILogger<JobStateChangedEventConsumer> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<JobStateChangedEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
|
||||
var job = await _dbContext.Jobs.FindAsync(@event.JobId);
|
||||
|
||||
if (job == null)
|
||||
{
|
||||
job = new Job
|
||||
{
|
||||
Id = @event.JobId,
|
||||
JobType = @event.JobType,
|
||||
Status = @event.ToState,
|
||||
CreatedTime = @event.Timestamp,
|
||||
UpdatedTime = @event.Timestamp,
|
||||
Metadata = @event.Metadata != null
|
||||
? JsonSerializer.SerializeToDocument(@event.Metadata)
|
||||
: null
|
||||
};
|
||||
_dbContext.Jobs.Add(job);
|
||||
}
|
||||
else
|
||||
{
|
||||
job.Status = @event.ToState;
|
||||
job.UpdatedTime = @event.Timestamp;
|
||||
|
||||
if (@event.Error != null)
|
||||
{
|
||||
job.ErrorMessage = @event.Error;
|
||||
}
|
||||
|
||||
if (@event.ToState is "Completed" or "Failed")
|
||||
{
|
||||
job.CompletedTime = @event.Timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
var historyEntry = new JobHistoryEntry
|
||||
{
|
||||
JobId = @event.JobId,
|
||||
FromState = @event.FromState,
|
||||
ToState = @event.ToState,
|
||||
Message = @event.Message,
|
||||
Error = @event.Error,
|
||||
Timestamp = @event.Timestamp
|
||||
};
|
||||
_dbContext.JobHistoryEntries.Add(historyEntry);
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogDebug("Recorded job state change: {JobId} {FromState} -> {ToState}",
|
||||
@event.JobId, @event.FromState, @event.ToState);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using FictionArchive.Service.ReportingService.Models.Database;
|
||||
using FictionArchive.Service.Shared.Services.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Services;
|
||||
|
||||
public class ReportingServiceDbContext : FictionArchiveDbContext
|
||||
{
|
||||
public ReportingServiceDbContext(DbContextOptions options, ILogger<ReportingServiceDbContext> logger)
|
||||
: base(options, logger) { }
|
||||
|
||||
public DbSet<Job> Jobs => Set<Job>();
|
||||
public DbSet<JobHistoryEntry> JobHistoryEntries => Set<JobHistoryEntry>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Job>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasIndex(e => e.JobType);
|
||||
entity.HasIndex(e => e.Status);
|
||||
entity.HasIndex(e => e.CreatedTime);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<JobHistoryEntry>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasOne(e => e.Job)
|
||||
.WithMany(j => j.History)
|
||||
.HasForeignKey(e => e.JobId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
FictionArchive.Service.ReportingService/appsettings.json
Normal file
28
FictionArchive.Service.ReportingService/appsettings.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_ReportingService;Username=postgres;password=postgres"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"OIDC": {
|
||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||
"ValidateIssuer": true,
|
||||
"ValidateAudience": true,
|
||||
"ValidateLifetime": true,
|
||||
"ValidateIssuerSigningKey": true
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"subgraph": "Reporting",
|
||||
"http": {
|
||||
"baseAddress": "http://localhost:5180/graphql"
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AppAny.Quartz.EntityFrameworkCore.Migrations.PostgreSQL" Version="0.5.1" />
|
||||
<PackageReference Include="MassTransit" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -6,15 +6,22 @@ namespace FictionArchive.Service.SchedulerService.Models.JobTemplates;
|
||||
|
||||
public class EventJobTemplate : IJob
|
||||
{
|
||||
private readonly IBus _bus;
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
private readonly ISendEndpointProvider _sendEndpointProvider;
|
||||
private readonly ILogger<EventJobTemplate> _logger;
|
||||
|
||||
public const string EventTypeParameter = "RoutingKey";
|
||||
public const string EventTypeParameter = "MessageType";
|
||||
public const string EventDataParameter = "MessageData";
|
||||
public const string IsCommandParameter = "IsCommand";
|
||||
public const string DestinationQueueParameter = "DestinationQueue";
|
||||
|
||||
public EventJobTemplate(IBus bus, ILogger<EventJobTemplate> logger)
|
||||
public EventJobTemplate(
|
||||
IPublishEndpoint publishEndpoint,
|
||||
ISendEndpointProvider sendEndpointProvider,
|
||||
ILogger<EventJobTemplate> logger)
|
||||
{
|
||||
_bus = bus;
|
||||
_publishEndpoint = publishEndpoint;
|
||||
_sendEndpointProvider = sendEndpointProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -22,14 +29,47 @@ public class EventJobTemplate : IJob
|
||||
{
|
||||
try
|
||||
{
|
||||
var eventData = context.MergedJobDataMap.GetString(EventDataParameter);
|
||||
var eventType = context.MergedJobDataMap.GetString(EventTypeParameter);
|
||||
var eventObject = JsonConvert.DeserializeObject(eventData);
|
||||
await _bus.Publish(eventObject);
|
||||
var messageData = context.MergedJobDataMap.GetString(EventDataParameter);
|
||||
var messageTypeName = context.MergedJobDataMap.GetString(EventTypeParameter);
|
||||
var isCommand = context.MergedJobDataMap.GetBoolean(IsCommandParameter);
|
||||
|
||||
var messageType = Type.GetType(messageTypeName!);
|
||||
if (messageType == null)
|
||||
{
|
||||
_logger.LogError("Could not resolve message type: {MessageType}", messageTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
var message = JsonConvert.DeserializeObject(messageData!, messageType);
|
||||
if (message == null)
|
||||
{
|
||||
_logger.LogError("Could not deserialize message data for type: {MessageType}", messageTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCommand)
|
||||
{
|
||||
var destinationQueue = context.MergedJobDataMap.GetString(DestinationQueueParameter);
|
||||
if (string.IsNullOrEmpty(destinationQueue))
|
||||
{
|
||||
_logger.LogError("Destination queue not specified for command message");
|
||||
return;
|
||||
}
|
||||
|
||||
var endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri($"queue:{destinationQueue}"));
|
||||
await endpoint.Send(message, messageType);
|
||||
_logger.LogInformation("Sent command {MessageType} to queue {Queue}", messageTypeName, destinationQueue);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _publishEndpoint.Publish(message, messageType);
|
||||
_logger.LogInformation("Published event {MessageType}", messageTypeName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "An error occurred while running an event job.");
|
||||
throw; // Re-throw to let Quartz handle retries
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using FictionArchive.Service.SchedulerService.GraphQL;
|
||||
using FictionArchive.Service.SchedulerService.Services;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using Quartz;
|
||||
using Quartz.Impl.AdoJobStore;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class Program
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Bus
|
||||
#region MassTransit
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "SchedulerService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_SchedulerService;Username=postgres;password=postgres"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IChapterCreated
|
||||
{
|
||||
uint ChapterId { get; }
|
||||
uint NovelId { get; }
|
||||
uint VolumeId { get; }
|
||||
uint VolumeOrder { get; }
|
||||
uint ChapterOrder { get; }
|
||||
string ChapterTitle { get; }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IChapterPullRequested
|
||||
{
|
||||
uint NovelId { get; }
|
||||
uint VolumeId { get; }
|
||||
uint ChapterOrder { get; }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IFileUploadRequestCreated
|
||||
{
|
||||
Guid RequestId { get; }
|
||||
string FilePath { get; }
|
||||
byte[] FileData { get; }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IFileUploadRequestStatusUpdate
|
||||
{
|
||||
Guid RequestId { get; }
|
||||
RequestStatus Status { get; }
|
||||
string? FileAccessUrl { get; }
|
||||
string? ErrorMessage { get; }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface INovelCreated
|
||||
{
|
||||
uint NovelId { get; }
|
||||
string Title { get; }
|
||||
Language OriginalLanguage { get; }
|
||||
string Source { get; }
|
||||
string AuthorName { get; }
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface INovelUpdateRequested
|
||||
{
|
||||
string NovelUrl { get; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface ITranslationRequestCompleted
|
||||
{
|
||||
Guid? TranslationRequestId { get; }
|
||||
string? TranslatedText { get; }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface ITranslationRequestCreated
|
||||
{
|
||||
Guid TranslationRequestId { get; }
|
||||
Language From { get; }
|
||||
Language To { get; }
|
||||
string Body { get; }
|
||||
string TranslationEngineKey { get; }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IUserInvited
|
||||
{
|
||||
string InvitedUserId { get; }
|
||||
string InvitedUsername { get; }
|
||||
string InvitedEmail { get; }
|
||||
string InvitedOAuthProviderId { get; }
|
||||
string InviterId { get; }
|
||||
string InviterUsername { get; }
|
||||
string InviterOAuthProviderId { get; }
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using FictionArchive.Service.Shared.Services.Filters;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Extensions;
|
||||
|
||||
public static class MassTransitExtensions
|
||||
{
|
||||
public static IServiceCollection AddFictionArchiveMassTransit(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
Action<IBusRegistrationConfigurator>? configureConsumers = null)
|
||||
{
|
||||
services.AddMassTransit(x =>
|
||||
{
|
||||
configureConsumers?.Invoke(x);
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
var (host, username, password) = ParseRabbitMqConfiguration(configuration);
|
||||
|
||||
cfg.Host(host, h =>
|
||||
{
|
||||
h.Username(username);
|
||||
h.Password(password);
|
||||
});
|
||||
|
||||
cfg.UseMessageRetry(r => r.Exponential(
|
||||
retryLimit: 5,
|
||||
minInterval: TimeSpan.FromSeconds(1),
|
||||
maxInterval: TimeSpan.FromMinutes(1),
|
||||
intervalDelta: TimeSpan.FromSeconds(2)));
|
||||
|
||||
cfg.UseConsumeFilter(typeof(LoggingConsumeFilter<>), context);
|
||||
|
||||
// Process one message at a time per consumer (matches old EventBus behavior)
|
||||
cfg.PrefetchCount = 1;
|
||||
|
||||
cfg.ConfigureEndpoints(context);
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses RabbitMQ configuration from either ConnectionString format or separate Host/Username/Password keys.
|
||||
/// ConnectionString format: amqp://[username:password@]host[:port]
|
||||
/// </summary>
|
||||
private static (string Host, string Username, string Password) ParseRabbitMqConfiguration(IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration["RabbitMQ:ConnectionString"];
|
||||
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
return ParseConnectionString(connectionString);
|
||||
}
|
||||
|
||||
// Fallback to separate configuration keys
|
||||
var host = configuration["RabbitMQ:Host"] ?? "localhost";
|
||||
var username = configuration["RabbitMQ:Username"] ?? "guest";
|
||||
var password = configuration["RabbitMQ:Password"] ?? "guest";
|
||||
|
||||
return (host, username, password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses an AMQP connection string into host, username, and password components.
|
||||
/// Supports formats:
|
||||
/// - amqp://host
|
||||
/// - amqp://host:port
|
||||
/// - amqp://username:password@host
|
||||
/// - amqp://username:password@host:port
|
||||
/// </summary>
|
||||
private static (string Host, string Username, string Password) ParseConnectionString(string connectionString)
|
||||
{
|
||||
var username = "guest";
|
||||
var password = "guest";
|
||||
var host = "localhost";
|
||||
|
||||
// Try to parse as URI first
|
||||
if (Uri.TryCreate(connectionString, UriKind.Absolute, out var uri))
|
||||
{
|
||||
host = uri.Host;
|
||||
|
||||
if (!string.IsNullOrEmpty(uri.UserInfo))
|
||||
{
|
||||
var userInfoParts = uri.UserInfo.Split(':', 2);
|
||||
username = Uri.UnescapeDataString(userInfoParts[0]);
|
||||
if (userInfoParts.Length > 1)
|
||||
{
|
||||
password = Uri.UnescapeDataString(userInfoParts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback regex parsing for edge cases
|
||||
var match = Regex.Match(connectionString, @"amqp://(?:([^:]+):([^@]+)@)?([^:/]+)");
|
||||
if (match.Success)
|
||||
{
|
||||
if (match.Groups[1].Success && match.Groups[2].Success)
|
||||
{
|
||||
username = match.Groups[1].Value;
|
||||
password = match.Groups[2].Value;
|
||||
}
|
||||
if (match.Groups[3].Success)
|
||||
{
|
||||
host = match.Groups[3].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (host, username, password);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,9 @@
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="9.0.4" />
|
||||
<PackageReference Include="Polly" Version="8.6.5" />
|
||||
<PackageReference Include="MassTransit.RabbitMQ" Version="8.*" />
|
||||
<PackageReference Include="MassTransit" Version="8.4.0" />
|
||||
<PackageReference Include="MassTransit.RabbitMQ" Version="8.4.0" />
|
||||
<PackageReference Include="MassTransit.EntityFrameworkCore" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Configuration;
|
||||
|
||||
public class MassTransitOptions
|
||||
{
|
||||
public string Host { get; set; } = "localhost";
|
||||
public string VirtualHost { get; set; } = "/";
|
||||
public string Username { get; set; } = "guest";
|
||||
public string Password { get; set; } = "guest";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
|
||||
public record ImportNovelCommand : ICommand
|
||||
{
|
||||
public required string NovelUrl { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
|
||||
public record PullChapterContentCommand : ICommand
|
||||
{
|
||||
public required uint NovelId { get; init; }
|
||||
public required uint VolumeId { get; init; }
|
||||
public required uint ChapterOrder { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
|
||||
public record TranslateTextCommand : ICommand
|
||||
{
|
||||
public Guid TranslationRequestId { get; init; }
|
||||
public Language From { get; init; }
|
||||
public Language To { get; init; }
|
||||
public required string Body { get; init; }
|
||||
public required string TranslationEngineKey { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
|
||||
public record UploadFileCommand : ICommand
|
||||
{
|
||||
public Guid RequestId { get; init; }
|
||||
public required string FilePath { get; init; }
|
||||
public required byte[] FileData { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record AuthUserAddedEvent : IEvent
|
||||
{
|
||||
public required string OAuthProviderId { get; init; }
|
||||
public required string InviterOAuthProviderId { get; init; }
|
||||
public required string EventUserEmail { get; init; }
|
||||
public required string EventUserUsername { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record ChapterCreatedEvent : IEvent
|
||||
{
|
||||
public required uint ChapterId { get; init; }
|
||||
public required uint NovelId { get; init; }
|
||||
public required uint VolumeId { get; init; }
|
||||
public required int VolumeOrder { get; init; }
|
||||
public required uint ChapterOrder { get; init; }
|
||||
public required string ChapterTitle { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record FileUploadCompletedEvent : IEvent
|
||||
{
|
||||
public Guid RequestId { get; init; }
|
||||
public RequestStatus Status { get; init; }
|
||||
public string? FileAccessUrl { get; init; }
|
||||
public string? ErrorMessage { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record NovelCreatedEvent : IEvent
|
||||
{
|
||||
public required uint NovelId { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public required Language OriginalLanguage { get; init; }
|
||||
public required string Source { get; init; }
|
||||
public required string AuthorName { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record TranslationCompletedEvent : IEvent
|
||||
{
|
||||
public Guid TranslationRequestId { get; init; }
|
||||
public required string TranslatedText { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
|
||||
public record UserInvitedEvent : IEvent
|
||||
{
|
||||
public Guid InvitedUserId { get; init; }
|
||||
public required string InvitedUsername { get; init; }
|
||||
public required string InvitedEmail { get; init; }
|
||||
public required string InvitedOAuthProviderId { get; init; }
|
||||
|
||||
public Guid InviterId { get; init; }
|
||||
public required string InviterUsername { get; init; }
|
||||
public required string InviterOAuthProviderId { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Marker interface for commands (do something, single consumer)
|
||||
/// </summary>
|
||||
public interface ICommand { }
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Marker interface for events (something happened, multiple subscribers)
|
||||
/// </summary>
|
||||
public interface IEvent { }
|
||||
@@ -0,0 +1,18 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.Shared.MassTransit.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Published by sagas on state transitions for centralized job tracking
|
||||
/// </summary>
|
||||
public record JobStateChangedEvent : IEvent
|
||||
{
|
||||
public Guid JobId { get; init; }
|
||||
public required string JobType { get; init; }
|
||||
public required string FromState { get; init; }
|
||||
public required string ToState { get; init; }
|
||||
public string? Message { get; init; }
|
||||
public string? Error { get; init; }
|
||||
public Instant Timestamp { get; init; }
|
||||
public Dictionary<string, object>? Metadata { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Configuration;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FictionArchive.Service.Shared.MassTransit;
|
||||
|
||||
public static class MassTransitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds MassTransit with RabbitMQ and Entity Framework outbox
|
||||
/// </summary>
|
||||
public static IServiceCollection AddFictionArchiveMassTransit<TDbContext>(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
Action<IBusRegistrationConfigurator>? configureConsumers = null)
|
||||
where TDbContext : DbContext
|
||||
{
|
||||
services.AddMassTransit(x =>
|
||||
{
|
||||
configureConsumers?.Invoke(x);
|
||||
|
||||
x.AddEntityFrameworkOutbox<TDbContext>(o =>
|
||||
{
|
||||
o.UsePostgres();
|
||||
o.UseBusOutbox();
|
||||
});
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
var options = configuration.GetSection("RabbitMQ").Get<MassTransitOptions>()
|
||||
?? new MassTransitOptions();
|
||||
|
||||
cfg.Host(options.Host, options.VirtualHost, h =>
|
||||
{
|
||||
h.Username(options.Username);
|
||||
h.Password(options.Password);
|
||||
});
|
||||
|
||||
// Immediate retries for transient failures
|
||||
cfg.UseMessageRetry(r => r.Intervals(
|
||||
TimeSpan.FromSeconds(1),
|
||||
TimeSpan.FromSeconds(1),
|
||||
TimeSpan.FromSeconds(1)));
|
||||
|
||||
// Delayed redelivery for longer outages
|
||||
cfg.UseDelayedRedelivery(r => r.Intervals(
|
||||
TimeSpan.FromSeconds(5),
|
||||
TimeSpan.FromSeconds(30),
|
||||
TimeSpan.FromMinutes(2),
|
||||
TimeSpan.FromMinutes(10),
|
||||
TimeSpan.FromMinutes(30)));
|
||||
|
||||
cfg.ConfigureEndpoints(context);
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds MassTransit with RabbitMQ without outbox (for services without EF)
|
||||
/// </summary>
|
||||
public static IServiceCollection AddFictionArchiveMassTransit(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
Action<IBusRegistrationConfigurator>? configureConsumers = null)
|
||||
{
|
||||
services.AddMassTransit(x =>
|
||||
{
|
||||
configureConsumers?.Invoke(x);
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
var options = configuration.GetSection("RabbitMQ").Get<MassTransitOptions>()
|
||||
?? new MassTransitOptions();
|
||||
|
||||
cfg.Host(options.Host, options.VirtualHost, h =>
|
||||
{
|
||||
h.Username(options.Username);
|
||||
h.Password(options.Password);
|
||||
});
|
||||
|
||||
cfg.UseMessageRetry(r => r.Intervals(
|
||||
TimeSpan.FromSeconds(1),
|
||||
TimeSpan.FromSeconds(1),
|
||||
TimeSpan.FromSeconds(1)));
|
||||
|
||||
cfg.UseDelayedRedelivery(r => r.Intervals(
|
||||
TimeSpan.FromSeconds(5),
|
||||
TimeSpan.FromSeconds(30),
|
||||
TimeSpan.FromMinutes(2),
|
||||
TimeSpan.FromMinutes(10),
|
||||
TimeSpan.FromMinutes(30)));
|
||||
|
||||
cfg.ConfigureEndpoints(context);
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Services.Filters;
|
||||
|
||||
public class LoggingConsumeFilter<T> : IFilter<ConsumeContext<T>> where T : class
|
||||
{
|
||||
private readonly ILogger<LoggingConsumeFilter<T>> _logger;
|
||||
|
||||
public LoggingConsumeFilter(ILogger<LoggingConsumeFilter<T>> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Send(ConsumeContext<T> context, IPipe<ConsumeContext<T>> next)
|
||||
{
|
||||
try
|
||||
{
|
||||
await next.Send(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex,
|
||||
"Message {MessageType} failed after all retries. MessageId: {MessageId}, ConversationId: {ConversationId}",
|
||||
typeof(T).Name,
|
||||
context.MessageId,
|
||||
context.ConversationId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Probe(ProbeContext context) => context.CreateFilterScope("logging");
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.TranslationService.Contracts;
|
||||
using FictionArchive.Service.TranslationService.Models.Enums;
|
||||
using FictionArchive.Service.TranslationService.Services;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Consumers;
|
||||
|
||||
public class TranslationRequestCreatedConsumer : IConsumer<ITranslationRequestCreated>
|
||||
{
|
||||
private readonly ILogger<TranslationRequestCreatedConsumer> _logger;
|
||||
private readonly TranslationEngineService _translationEngineService;
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
|
||||
public TranslationRequestCreatedConsumer(
|
||||
ILogger<TranslationRequestCreatedConsumer> logger,
|
||||
TranslationEngineService translationEngineService,
|
||||
IPublishEndpoint publishEndpoint)
|
||||
{
|
||||
_logger = logger;
|
||||
_translationEngineService = translationEngineService;
|
||||
_publishEndpoint = publishEndpoint;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ITranslationRequestCreated> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
_logger.LogInformation("Processing translation request {TranslationRequestId}", message.TranslationRequestId);
|
||||
|
||||
var result = await _translationEngineService.Translate(
|
||||
message.From,
|
||||
message.To,
|
||||
message.Body,
|
||||
message.TranslationEngineKey);
|
||||
|
||||
if (result.Status == TranslationRequestStatus.Success)
|
||||
{
|
||||
await _publishEndpoint.Publish<ITranslationRequestCompleted>(
|
||||
new TranslationRequestCompleted(
|
||||
TranslationRequestId: message.TranslationRequestId,
|
||||
TranslatedText: result.TranslatedText));
|
||||
|
||||
_logger.LogInformation("Translation completed for request {TranslationRequestId}", message.TranslationRequestId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError("Translation failed for request {TranslationRequestId}", message.TranslationRequestId);
|
||||
throw new InvalidOperationException($"Translation failed for request {message.TranslationRequestId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Contracts;
|
||||
|
||||
public record TranslationRequestCompleted(
|
||||
Guid? TranslationRequestId,
|
||||
string? TranslatedText) : ITranslationRequestCompleted;
|
||||
@@ -23,6 +23,7 @@
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="DeepL.net" Version="1.17.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
|
||||
<PackageReference Include="MassTransit" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,11 +2,12 @@ using DeepL;
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using FictionArchive.Service.Shared.Services.GraphQL;
|
||||
using FictionArchive.Service.TranslationService.Consumers;
|
||||
using FictionArchive.Service.TranslationService.GraphQL;
|
||||
using FictionArchive.Service.TranslationService.Services;
|
||||
using FictionArchive.Service.TranslationService.Services.Database;
|
||||
using FictionArchive.Service.TranslationService.Services.EventHandlers;
|
||||
using FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
||||
using FictionArchive.Service.TranslationService.Services.TranslationEngines.DeepLTranslate;
|
||||
|
||||
@@ -27,11 +28,11 @@ public class Program
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddFictionArchiveMassTransit(
|
||||
builder.Services.AddFictionArchiveMassTransit<TranslationServiceDbContext>(
|
||||
builder.Configuration,
|
||||
x =>
|
||||
{
|
||||
x.AddConsumer<TranslationRequestCreatedConsumer>();
|
||||
x.AddConsumer<TranslateTextCommandConsumer>();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Commands;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using FictionArchive.Service.TranslationService.Models.Enums;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.TranslationService.Services.EventHandlers;
|
||||
|
||||
public class TranslateTextCommandConsumer : IConsumer<TranslateTextCommand>
|
||||
{
|
||||
private readonly ILogger<TranslateTextCommandConsumer> _logger;
|
||||
private readonly TranslationEngineService _translationEngineService;
|
||||
|
||||
public TranslateTextCommandConsumer(
|
||||
ILogger<TranslateTextCommandConsumer> logger,
|
||||
TranslationEngineService translationEngineService)
|
||||
{
|
||||
_logger = logger;
|
||||
_translationEngineService = translationEngineService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<TranslateTextCommand> context)
|
||||
{
|
||||
var command = context.Message;
|
||||
|
||||
var result = await _translationEngineService.Translate(
|
||||
command.From,
|
||||
command.To,
|
||||
command.Body,
|
||||
command.TranslationEngineKey);
|
||||
|
||||
if (result.Status == TranslationRequestStatus.Success)
|
||||
{
|
||||
await context.Publish(new TranslationCompletedEvent
|
||||
{
|
||||
TranslatedText = result.TranslatedText!,
|
||||
TranslationRequestId = command.TranslationRequestId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"DeepL": {
|
||||
@@ -13,8 +12,10 @@
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_NovelService;Username=postgres;password=postgres"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "TranslationService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"OIDC": {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.UserNovelDataService.Models.Database;
|
||||
using FictionArchive.Service.UserNovelDataService.Services;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService.Consumers;
|
||||
|
||||
public class NovelCreatedConsumer : IConsumer<INovelCreated>
|
||||
{
|
||||
private readonly ILogger<NovelCreatedConsumer> _logger;
|
||||
private readonly UserNovelDataServiceDbContext _dbContext;
|
||||
|
||||
public NovelCreatedConsumer(
|
||||
ILogger<NovelCreatedConsumer> logger,
|
||||
UserNovelDataServiceDbContext dbContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<INovelCreated> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
var exists = await _dbContext.Novels.AnyAsync(n => n.Id == message.NovelId);
|
||||
if (exists)
|
||||
{
|
||||
_logger.LogDebug("Novel {NovelId} already exists, skipping", message.NovelId);
|
||||
return;
|
||||
}
|
||||
|
||||
var novel = new Novel { Id = message.NovelId };
|
||||
_dbContext.Novels.Add(novel);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Created novel stub for {NovelId}", message.NovelId);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.UserNovelDataService.Models.Database;
|
||||
using FictionArchive.Service.UserNovelDataService.Services;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService.Consumers;
|
||||
|
||||
public class UserInvitedConsumer : IConsumer<IUserInvited>
|
||||
{
|
||||
private readonly ILogger<UserInvitedConsumer> _logger;
|
||||
private readonly UserNovelDataServiceDbContext _dbContext;
|
||||
|
||||
public UserInvitedConsumer(
|
||||
ILogger<UserInvitedConsumer> logger,
|
||||
UserNovelDataServiceDbContext dbContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IUserInvited> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
|
||||
var userId = Guid.Parse(message.InvitedUserId);
|
||||
var exists = await _dbContext.Users.AnyAsync(u => u.Id == userId);
|
||||
if (exists)
|
||||
{
|
||||
_logger.LogDebug("User {UserId} already exists, skipping", message.InvitedUserId);
|
||||
return;
|
||||
}
|
||||
|
||||
var user = new User
|
||||
{
|
||||
Id = userId,
|
||||
OAuthProviderId = message.InvitedOAuthProviderId
|
||||
};
|
||||
_dbContext.Users.Add(user);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Created user stub for {UserId}", message.InvitedUserId);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.UserNovelDataService.Consumers;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using FictionArchive.Service.UserNovelDataService.GraphQL;
|
||||
using FictionArchive.Service.UserNovelDataService.Services;
|
||||
using FictionArchive.Service.UserNovelDataService.Services.EventHandlers;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService;
|
||||
|
||||
@@ -24,13 +25,13 @@ public class Program
|
||||
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddFictionArchiveMassTransit(
|
||||
builder.Services.AddFictionArchiveMassTransit<UserNovelDataServiceDbContext>(
|
||||
builder.Configuration,
|
||||
x =>
|
||||
{
|
||||
x.AddConsumer<NovelCreatedConsumer>();
|
||||
x.AddConsumer<ChapterCreatedConsumer>();
|
||||
x.AddConsumer<UserInvitedConsumer>();
|
||||
x.AddConsumer<NovelCreatedEventConsumer>();
|
||||
x.AddConsumer<ChapterCreatedEventConsumer>();
|
||||
x.AddConsumer<UserInvitedEventConsumer>();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +1,55 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using FictionArchive.Service.UserNovelDataService.Models.Database;
|
||||
using FictionArchive.Service.UserNovelDataService.Services;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService.Consumers;
|
||||
namespace FictionArchive.Service.UserNovelDataService.Services.EventHandlers;
|
||||
|
||||
public class ChapterCreatedConsumer : IConsumer<IChapterCreated>
|
||||
public class ChapterCreatedEventConsumer : IConsumer<ChapterCreatedEvent>
|
||||
{
|
||||
private readonly ILogger<ChapterCreatedConsumer> _logger;
|
||||
private readonly UserNovelDataServiceDbContext _dbContext;
|
||||
private readonly ILogger<ChapterCreatedEventConsumer> _logger;
|
||||
|
||||
public ChapterCreatedConsumer(
|
||||
ILogger<ChapterCreatedConsumer> logger,
|
||||
UserNovelDataServiceDbContext dbContext)
|
||||
public ChapterCreatedEventConsumer(
|
||||
UserNovelDataServiceDbContext dbContext,
|
||||
ILogger<ChapterCreatedEventConsumer> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IChapterCreated> context)
|
||||
public async Task Consume(ConsumeContext<ChapterCreatedEvent> context)
|
||||
{
|
||||
var message = context.Message;
|
||||
var @event = context.Message;
|
||||
|
||||
// Ensure novel exists
|
||||
var novelExists = await _dbContext.Novels.AnyAsync(n => n.Id == message.NovelId);
|
||||
var novelExists = await _dbContext.Novels.AnyAsync(n => n.Id == @event.NovelId);
|
||||
if (!novelExists)
|
||||
{
|
||||
var novel = new Novel { Id = message.NovelId };
|
||||
var novel = new Novel { Id = @event.NovelId };
|
||||
_dbContext.Novels.Add(novel);
|
||||
}
|
||||
|
||||
// Ensure volume exists
|
||||
var volumeExists = await _dbContext.Volumes.AnyAsync(v => v.Id == message.VolumeId);
|
||||
var volumeExists = await _dbContext.Volumes.AnyAsync(v => v.Id == @event.VolumeId);
|
||||
if (!volumeExists)
|
||||
{
|
||||
var volume = new Volume { Id = message.VolumeId };
|
||||
var volume = new Volume { Id = @event.VolumeId };
|
||||
_dbContext.Volumes.Add(volume);
|
||||
}
|
||||
|
||||
// Create chapter if not exists
|
||||
var chapterExists = await _dbContext.Chapters.AnyAsync(c => c.Id == message.ChapterId);
|
||||
var chapterExists = await _dbContext.Chapters.AnyAsync(c => c.Id == @event.ChapterId);
|
||||
if (chapterExists)
|
||||
{
|
||||
_logger.LogDebug("Chapter {ChapterId} already exists, skipping", message.ChapterId);
|
||||
_logger.LogDebug("Chapter {ChapterId} already exists, skipping", @event.ChapterId);
|
||||
return;
|
||||
}
|
||||
|
||||
var chapter = new Chapter { Id = message.ChapterId };
|
||||
var chapter = new Chapter { Id = @event.ChapterId };
|
||||
_dbContext.Chapters.Add(chapter);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Created chapter stub for {ChapterId} in novel {NovelId}", message.ChapterId, message.NovelId);
|
||||
_logger.LogInformation("Created chapter stub for {ChapterId} in novel {NovelId}", @event.ChapterId, @event.NovelId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using FictionArchive.Service.UserNovelDataService.Models.Database;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService.Services.EventHandlers;
|
||||
|
||||
public class NovelCreatedEventConsumer : IConsumer<NovelCreatedEvent>
|
||||
{
|
||||
private readonly UserNovelDataServiceDbContext _dbContext;
|
||||
private readonly ILogger<NovelCreatedEventConsumer> _logger;
|
||||
|
||||
public NovelCreatedEventConsumer(
|
||||
UserNovelDataServiceDbContext dbContext,
|
||||
ILogger<NovelCreatedEventConsumer> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<NovelCreatedEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
|
||||
var exists = await _dbContext.Novels.AnyAsync(n => n.Id == @event.NovelId);
|
||||
if (exists)
|
||||
{
|
||||
_logger.LogDebug("Novel {NovelId} already exists, skipping", @event.NovelId);
|
||||
return;
|
||||
}
|
||||
|
||||
var novel = new Novel { Id = @event.NovelId };
|
||||
_dbContext.Novels.Add(novel);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Created novel stub for {NovelId}", @event.NovelId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using FictionArchive.Service.UserNovelDataService.Models.Database;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserNovelDataService.Services.EventHandlers;
|
||||
|
||||
public class UserInvitedEventConsumer : IConsumer<UserInvitedEvent>
|
||||
{
|
||||
private readonly UserNovelDataServiceDbContext _dbContext;
|
||||
private readonly ILogger<UserInvitedEventConsumer> _logger;
|
||||
|
||||
public UserInvitedEventConsumer(
|
||||
UserNovelDataServiceDbContext dbContext,
|
||||
ILogger<UserInvitedEventConsumer> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<UserInvitedEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
|
||||
var exists = await _dbContext.Users.AnyAsync(u => u.Id == @event.InvitedUserId);
|
||||
if (exists)
|
||||
{
|
||||
_logger.LogDebug("User {UserId} already exists, skipping", @event.InvitedUserId);
|
||||
return;
|
||||
}
|
||||
|
||||
var user = new User
|
||||
{
|
||||
Id = @event.InvitedUserId,
|
||||
OAuthProviderId = @event.InvitedOAuthProviderId
|
||||
};
|
||||
_dbContext.Users.Add(user);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("Created user stub for {UserId}", @event.InvitedUserId);
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,17 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_UserNovelDataService;Username=postgres;password=postgres"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "UserNovelDataService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"OIDC": {
|
||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
namespace FictionArchive.Service.UserService.Contracts;
|
||||
|
||||
public record UserInvited(
|
||||
string InvitedUserId,
|
||||
string InvitedUsername,
|
||||
string InvitedEmail,
|
||||
string InvitedOAuthProviderId,
|
||||
string InviterId,
|
||||
string InviterUsername,
|
||||
string InviterOAuthProviderId) : IUserInvited;
|
||||
@@ -2,6 +2,7 @@ using System.Net.Http.Headers;
|
||||
using FictionArchive.Common.Extensions;
|
||||
using FictionArchive.Service.Shared;
|
||||
using FictionArchive.Service.Shared.Extensions;
|
||||
using FictionArchive.Service.Shared.MassTransit;
|
||||
using FictionArchive.Service.UserService.GraphQL;
|
||||
using FictionArchive.Service.UserService.Services;
|
||||
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||
@@ -20,7 +21,10 @@ public class Program
|
||||
|
||||
#region MassTransit
|
||||
|
||||
builder.Services.AddFictionArchiveMassTransit(builder.Configuration);
|
||||
if (!isSchemaExport)
|
||||
{
|
||||
builder.Services.AddFictionArchiveMassTransit<UserServiceDbContext>(builder.Configuration);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.UserService.Contracts;
|
||||
using FictionArchive.Service.Shared.MassTransit.Contracts.Events;
|
||||
using FictionArchive.Service.UserService.Models.Database;
|
||||
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||
using MassTransit;
|
||||
@@ -100,14 +99,16 @@ public class UserManagementService
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
await _publishEndpoint.Publish<IUserInvited>(new UserInvited(
|
||||
InvitedUserId: newUser.Id.ToString(),
|
||||
InvitedUsername: newUser.Username,
|
||||
InvitedEmail: newUser.Email,
|
||||
InvitedOAuthProviderId: newUser.OAuthProviderId,
|
||||
InviterId: inviter.Id.ToString(),
|
||||
InviterUsername: inviter.Username,
|
||||
InviterOAuthProviderId: inviter.OAuthProviderId));
|
||||
await _publishEndpoint.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}",
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=localhost;Database=FictionArchive_UserService;Username=postgres;password=postgres"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"ConnectionString": "amqp://localhost",
|
||||
"ClientIdentifier": "UserService"
|
||||
"Host": "localhost",
|
||||
"VirtualHost": "/",
|
||||
"Username": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"Authentik": {
|
||||
"BaseUrl": "https://auth.orfl.xyz",
|
||||
|
||||
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.User
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.UserNovelDataService", "FictionArchive.Service.UserNovelDataService\FictionArchive.Service.UserNovelDataService.csproj", "{A278565B-D440-4AB9-B2E2-41BA3B3AD82A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FictionArchive.Service.ReportingService", "FictionArchive.Service.ReportingService\FictionArchive.Service.ReportingService.csproj", "{24C8871B-1ECA-47A0-92DC-AD155C17EDF0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -73,5 +75,9 @@ Global
|
||||
{A278565B-D440-4AB9-B2E2-41BA3B3AD82A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A278565B-D440-4AB9-B2E2-41BA3B3AD82A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A278565B-D440-4AB9-B2E2-41BA3B3AD82A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{24C8871B-1ECA-47A0-92DC-AD155C17EDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{24C8871B-1ECA-47A0-92DC-AD155C17EDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{24C8871B-1ECA-47A0-92DC-AD155C17EDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{24C8871B-1ECA-47A0-92DC-AD155C17EDF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -136,6 +136,22 @@ services:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
reporting-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: FictionArchive.Service.ReportingService/Dockerfile
|
||||
networks:
|
||||
- fictionarchive
|
||||
environment:
|
||||
ConnectionStrings__DefaultConnection: Host=postgres;Database=FictionArchive_ReportingService;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:-postgres}
|
||||
RabbitMQ__ConnectionString: amqp://${RABBITMQ_USER:-guest}:${RABBITMQ_PASSWORD:-guest}@rabbitmq
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
rabbitmq:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
file-service:
|
||||
image: git.orfl.xyz/conco/fictionarchive-file-service:latest
|
||||
networks:
|
||||
|
||||
662
fictionarchive-web-astro/package-lock.json
generated
662
fictionarchive-web-astro/package-lock.json
generated
@@ -8,7 +8,6 @@
|
||||
"name": "fictionarchive-web-astro",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@astrojs/check": "^0.9.6",
|
||||
"@astrojs/node": "^9.5.1",
|
||||
"@astrojs/svelte": "^7.2.2",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
@@ -143,24 +142,6 @@
|
||||
"integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@astrojs/check": {
|
||||
"version": "0.9.6",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/check/-/check-0.9.6.tgz",
|
||||
"integrity": "sha512-jlaEu5SxvSgmfGIFfNgcn5/f+29H61NJzEMfAZ82Xopr4XBchXB1GVlcJsE+elUlsYSbXlptZLX+JMG3b/wZEA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@astrojs/language-server": "^2.16.1",
|
||||
"chokidar": "^4.0.1",
|
||||
"kleur": "^4.1.5",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"bin": {
|
||||
"astro-check": "bin/astro-check.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@astrojs/compiler": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz",
|
||||
@@ -174,47 +155,6 @@
|
||||
"integrity": "sha512-vreGnYSSKhAjFJCWAwe/CNhONvoc5lokxtRoZims+0wa3KbHBdPHSSthJsKxPd8d/aic6lWKpRTYGY/hsgK6EA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@astrojs/language-server": {
|
||||
"version": "2.16.3",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/language-server/-/language-server-2.16.3.tgz",
|
||||
"integrity": "sha512-yO5K7RYCMXUfeDlnU6UnmtnoXzpuQc0yhlaCNZ67k1C/MiwwwvMZz+LGa+H35c49w5QBfvtr4w4Zcf5PcH8uYA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@astrojs/compiler": "^2.13.0",
|
||||
"@astrojs/yaml2ts": "^0.2.2",
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5",
|
||||
"@volar/kit": "~2.4.27",
|
||||
"@volar/language-core": "~2.4.27",
|
||||
"@volar/language-server": "~2.4.27",
|
||||
"@volar/language-service": "~2.4.27",
|
||||
"muggle-string": "^0.4.1",
|
||||
"tinyglobby": "^0.2.15",
|
||||
"volar-service-css": "0.0.68",
|
||||
"volar-service-emmet": "0.0.68",
|
||||
"volar-service-html": "0.0.68",
|
||||
"volar-service-prettier": "0.0.68",
|
||||
"volar-service-typescript": "0.0.68",
|
||||
"volar-service-typescript-twoslash-queries": "0.0.68",
|
||||
"volar-service-yaml": "0.0.68",
|
||||
"vscode-html-languageservice": "^5.6.1",
|
||||
"vscode-uri": "^3.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"astro-ls": "bin/nodeServer.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "^3.0.0",
|
||||
"prettier-plugin-astro": ">=0.11.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"prettier": {
|
||||
"optional": true
|
||||
},
|
||||
"prettier-plugin-astro": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@astrojs/markdown-remark": {
|
||||
"version": "6.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-6.3.9.tgz",
|
||||
@@ -307,15 +247,6 @@
|
||||
"node": "18.20.8 || ^20.3.0 || >=22.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@astrojs/yaml2ts": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@astrojs/yaml2ts/-/yaml2ts-0.2.2.tgz",
|
||||
"integrity": "sha512-GOfvSr5Nqy2z5XiwqTouBBpy5FyI6DEe+/g/Mk5am9SjILN1S5fOEvYK0GuWHg98yS/dobP4m8qyqw/URW35fQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"yaml": "^2.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz",
|
||||
@@ -735,61 +666,6 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@emmetio/abbreviation": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.3.3.tgz",
|
||||
"integrity": "sha512-mgv58UrU3rh4YgbE/TzgLQwJ3pFsHHhCLqY20aJq+9comytTXUDNGG/SMtSeMJdkpxgXSXunBGLD8Boka3JyVA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emmetio/scanner": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@emmetio/css-abbreviation": {
|
||||
"version": "2.1.8",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/css-abbreviation/-/css-abbreviation-2.1.8.tgz",
|
||||
"integrity": "sha512-s9yjhJ6saOO/uk1V74eifykk2CBYi01STTK3WlXWGOepyKa23ymJ053+DNQjpFcy1ingpaO7AxCcwLvHFY9tuw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emmetio/scanner": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@emmetio/css-parser": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/css-parser/-/css-parser-0.4.1.tgz",
|
||||
"integrity": "sha512-2bC6m0MV/voF4CTZiAbG5MWKbq5EBmDPKu9Sb7s7nVcEzNQlrZP6mFFFlIaISM8X6514H9shWMme1fCm8cWAfQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emmetio/stream-reader": "^2.2.0",
|
||||
"@emmetio/stream-reader-utils": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emmetio/html-matcher": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/html-matcher/-/html-matcher-1.3.0.tgz",
|
||||
"integrity": "sha512-NTbsvppE5eVyBMuyGfVu2CRrLvo7J4YHb6t9sBFLyY03WYhXET37qA4zOYUjBWFCRHO7pS1B9khERtY0f5JXPQ==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@emmetio/scanner": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emmetio/scanner": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/scanner/-/scanner-1.0.4.tgz",
|
||||
"integrity": "sha512-IqRuJtQff7YHHBk4G8YZ45uB9BaAGcwQeVzgj/zj8/UdOhtQpEIupUhSk8dys6spFIWVZVeK20CzGEnqR5SbqA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@emmetio/stream-reader": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/stream-reader/-/stream-reader-2.2.0.tgz",
|
||||
"integrity": "sha512-fXVXEyFA5Yv3M3n8sUGT7+fvecGrZP4k6FnWWMSZVQf69kAq0LLpaBQLGcPR30m3zMmKYhECP4k/ZkzvhEW5kw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@emmetio/stream-reader-utils": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@emmetio/stream-reader-utils/-/stream-reader-utils-0.1.0.tgz",
|
||||
"integrity": "sha512-ZsZ2I9Vzso3Ho/pjZFsmmZ++FWeEd/txqybHTm4OgaZzdS8V9V/YYWQwg5TC38Z7uLWUV1vavpLLbjJtKubR1A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
|
||||
@@ -4456,96 +4332,6 @@
|
||||
"svelte": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@volar/kit": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/kit/-/kit-2.4.27.tgz",
|
||||
"integrity": "sha512-ilZoQDMLzqmSsImJRWx4YiZ4FcvvPrPnFVmL6hSsIWB6Bn3qc7k88J9yP32dagrs5Y8EXIlvvD/mAFaiuEOACQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/language-service": "2.4.27",
|
||||
"@volar/typescript": "2.4.27",
|
||||
"typesafe-path": "^0.2.2",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@volar/language-core": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.27.tgz",
|
||||
"integrity": "sha512-DjmjBWZ4tJKxfNC1F6HyYERNHPYS7L7OPFyCrestykNdUZMFYzI9WTyvwPcaNaHlrEUwESHYsfEw3isInncZxQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/source-map": "2.4.27"
|
||||
}
|
||||
},
|
||||
"node_modules/@volar/language-server": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/language-server/-/language-server-2.4.27.tgz",
|
||||
"integrity": "sha512-SymGNkErcHg8GjiG65iQN8sLkhqu1pwKhFySmxeBuYq5xFYagKBW36eiNITXQTdvT0tutI1GXcXdq/FdE/IyjA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/language-core": "2.4.27",
|
||||
"@volar/language-service": "2.4.27",
|
||||
"@volar/typescript": "2.4.27",
|
||||
"path-browserify": "^1.0.1",
|
||||
"request-light": "^0.7.0",
|
||||
"vscode-languageserver": "^9.0.1",
|
||||
"vscode-languageserver-protocol": "^3.17.5",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-uri": "^3.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@volar/language-service": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.27.tgz",
|
||||
"integrity": "sha512-SxKZ8yLhpWa7Y5e/RDxtNfm7j7xsXp/uf2urijXEffRNpPSmVdfzQrFFy5d7l8PNpZy+bHg+yakmqBPjQN+MOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/language-core": "2.4.27",
|
||||
"vscode-languageserver-protocol": "^3.17.5",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-uri": "^3.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@volar/source-map": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.27.tgz",
|
||||
"integrity": "sha512-ynlcBReMgOZj2i6po+qVswtDUeeBRCTgDurjMGShbm8WYZgJ0PA4RmtebBJ0BCYol1qPv3GQF6jK7C9qoVc7lg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@volar/typescript": {
|
||||
"version": "2.4.27",
|
||||
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.27.tgz",
|
||||
"integrity": "sha512-eWaYCcl/uAPInSK2Lze6IqVWaBu/itVqR5InXcHXFyles4zO++Mglt3oxdgj75BDcv1Knr9Y93nowS8U3wqhxg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/language-core": "2.4.27",
|
||||
"path-browserify": "^1.0.1",
|
||||
"vscode-uri": "^3.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@vscode/emmet-helper": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@vscode/emmet-helper/-/emmet-helper-2.11.0.tgz",
|
||||
"integrity": "sha512-QLxjQR3imPZPQltfbWRnHU6JecWTF1QSWhx3GAKQpslx7y3Dp6sIIXhKjiUJ/BR9FX8PVthjr9PD6pNwOJfAzw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emmet": "^2.4.3",
|
||||
"jsonc-parser": "^2.3.0",
|
||||
"vscode-languageserver-textdocument": "^1.0.1",
|
||||
"vscode-languageserver-types": "^3.15.1",
|
||||
"vscode-uri": "^3.0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@vscode/l10n": {
|
||||
"version": "0.0.18",
|
||||
"resolved": "https://registry.npmjs.org/@vscode/l10n/-/l10n-0.0.18.tgz",
|
||||
"integrity": "sha512-KYSIHVmslkaCDyw013pphY+d7x1qV8IZupYfeIfzNA+nsaWHbn5uPuQRvdRFsa9zFzGeudPuoGoZ1Op4jrJXIQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@whatwg-node/disposablestack": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@whatwg-node/disposablestack/-/disposablestack-0.0.6.tgz",
|
||||
@@ -4743,6 +4529,7 @@
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
@@ -5558,6 +5345,7 @@
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
@@ -5572,6 +5360,7 @@
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -5581,12 +5370,14 @@
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cliui/node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -5596,6 +5387,7 @@
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
@@ -5610,6 +5402,7 @@
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
@@ -5622,6 +5415,7 @@
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
@@ -5657,6 +5451,7 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
@@ -5669,6 +5464,7 @@
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/colorette": {
|
||||
@@ -6323,22 +6119,6 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/emmet": {
|
||||
"version": "2.4.11",
|
||||
"resolved": "https://registry.npmjs.org/emmet/-/emmet-2.4.11.tgz",
|
||||
"integrity": "sha512-23QPJB3moh/U9sT4rQzGgeyyGIrcM+GH5uVYg2C6wZIxAIJq7Ng3QLT79tl8FUwDXhyq9SusfknOrofAKqvgyQ==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"./packages/scanner",
|
||||
"./packages/abbreviation",
|
||||
"./packages/css-abbreviation",
|
||||
"./"
|
||||
],
|
||||
"dependencies": {
|
||||
"@emmetio/abbreviation": "^2.3.3",
|
||||
"@emmetio/css-abbreviation": "^2.1.8"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
@@ -6463,6 +6243,7 @@
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -6875,22 +6656,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-uri": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
|
||||
"integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz",
|
||||
@@ -7125,6 +6890,7 @@
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
@@ -8379,12 +8145,6 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonc-parser": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz",
|
||||
"integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jwt-decode": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
|
||||
@@ -8775,6 +8535,7 @@
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash.merge": {
|
||||
@@ -9880,12 +9641,6 @@
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/muggle-string": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.4.1.tgz",
|
||||
"integrity": "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mute-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz",
|
||||
@@ -10327,12 +10082,6 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/path-browserify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
|
||||
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz",
|
||||
@@ -10568,22 +10317,6 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
|
||||
"integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.30.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz",
|
||||
@@ -10895,16 +10628,11 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/request-light": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/request-light/-/request-light-0.7.0.tgz",
|
||||
"integrity": "sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@@ -11993,12 +11721,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/typesafe-path": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typesafe-path/-/typesafe-path-0.2.2.tgz",
|
||||
"integrity": "sha512-OJabfkAg1WLZSqJAJ0Z6Sdt3utnbzr/jh+NAHoyWHJe8CMSy79Gm085094M9nvTPy22KzTVn5Zq5mbapCI/hPA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
@@ -12013,27 +11735,6 @@
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-auto-import-cache": {
|
||||
"version": "0.3.6",
|
||||
"resolved": "https://registry.npmjs.org/typescript-auto-import-cache/-/typescript-auto-import-cache-0.3.6.tgz",
|
||||
"integrity": "sha512-RpuHXrknHdVdK7wv/8ug3Fr0WNsNi5l5aB8MYYuXhq2UH5lnEB1htJ1smhtD5VeCsGr2p8mUDtd83LCQDFVgjQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"semver": "^7.3.8"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-auto-import-cache/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.48.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.48.0.tgz",
|
||||
@@ -12618,255 +12319,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-css": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.68.tgz",
|
||||
"integrity": "sha512-lJSMh6f3QzZ1tdLOZOzovLX0xzAadPhx8EKwraDLPxBndLCYfoTvnNuiFFV8FARrpAlW5C0WkH+TstPaCxr00Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-css-languageservice": "^6.3.0",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-emmet": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-emmet/-/volar-service-emmet-0.0.68.tgz",
|
||||
"integrity": "sha512-nHvixrRQ83EzkQ4G/jFxu9Y4eSsXS/X2cltEPDM+K9qZmIv+Ey1w0tg1+6caSe8TU5Hgw4oSTwNMf/6cQb3LzQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emmetio/css-parser": "^0.4.1",
|
||||
"@emmetio/html-matcher": "^1.3.0",
|
||||
"@vscode/emmet-helper": "^2.9.3",
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-html": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-html/-/volar-service-html-0.0.68.tgz",
|
||||
"integrity": "sha512-fru9gsLJxy33xAltXOh4TEdi312HP80hpuKhpYQD4O5hDnkNPEBdcQkpB+gcX0oK0VxRv1UOzcGQEUzWCVHLfA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-html-languageservice": "^5.3.0",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-prettier": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-prettier/-/volar-service-prettier-0.0.68.tgz",
|
||||
"integrity": "sha512-grUmWHkHlebMOd6V8vXs2eNQUw/bJGJMjekh/EPf/p2ZNTK0Uyz7hoBRngcvGfJHMsSXZH8w/dZTForIW/4ihw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0",
|
||||
"prettier": "^2.2 || ^3.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
},
|
||||
"prettier": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-typescript": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-typescript/-/volar-service-typescript-0.0.68.tgz",
|
||||
"integrity": "sha512-z7B/7CnJ0+TWWFp/gh2r5/QwMObHNDiQiv4C9pTBNI2Wxuwymd4bjEORzrJ/hJ5Yd5+OzeYK+nFCKevoGEEeKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"path-browserify": "^1.0.1",
|
||||
"semver": "^7.6.2",
|
||||
"typescript-auto-import-cache": "^0.3.5",
|
||||
"vscode-languageserver-textdocument": "^1.0.11",
|
||||
"vscode-nls": "^5.2.0",
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-typescript-twoslash-queries": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-typescript-twoslash-queries/-/volar-service-typescript-twoslash-queries-0.0.68.tgz",
|
||||
"integrity": "sha512-NugzXcM0iwuZFLCJg47vI93su5YhTIweQuLmZxvz5ZPTaman16JCvmDZexx2rd5T/75SNuvvZmrTOTNYUsfe5w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-uri": "^3.0.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-typescript/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/volar-service-yaml": {
|
||||
"version": "0.0.68",
|
||||
"resolved": "https://registry.npmjs.org/volar-service-yaml/-/volar-service-yaml-0.0.68.tgz",
|
||||
"integrity": "sha512-84XgE02LV0OvTcwfqhcSwVg4of3MLNUWPMArO6Aj8YXqyEVnPu8xTEMY2btKSq37mVAPuaEVASI4e3ptObmqcA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-uri": "^3.0.8",
|
||||
"yaml-language-server": "~1.19.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@volar/language-service": "~2.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@volar/language-service": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-css-languageservice": {
|
||||
"version": "6.3.9",
|
||||
"resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-6.3.9.tgz",
|
||||
"integrity": "sha512-1tLWfp+TDM5ZuVWht3jmaY5y7O6aZmpeXLoHl5bv1QtRsRKt4xYGRMmdJa5Pqx/FTkgRbsna9R+Gn2xE+evVuA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vscode/l10n": "^0.0.18",
|
||||
"vscode-languageserver-textdocument": "^1.0.12",
|
||||
"vscode-languageserver-types": "3.17.5",
|
||||
"vscode-uri": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-html-languageservice": {
|
||||
"version": "5.6.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-html-languageservice/-/vscode-html-languageservice-5.6.1.tgz",
|
||||
"integrity": "sha512-5Mrqy5CLfFZUgkyhNZLA1Ye5g12Cb/v6VM7SxUzZUaRKWMDz4md+y26PrfRTSU0/eQAl3XpO9m2og+GGtDMuaA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vscode/l10n": "^0.0.18",
|
||||
"vscode-languageserver-textdocument": "^1.0.12",
|
||||
"vscode-languageserver-types": "^3.17.5",
|
||||
"vscode-uri": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-json-languageservice": {
|
||||
"version": "4.1.8",
|
||||
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-4.1.8.tgz",
|
||||
"integrity": "sha512-0vSpg6Xd9hfV+eZAaYN63xVVMOTmJ4GgHxXnkLCh+9RsQBkWKIghzLhW2B9ebfG+LQQg8uLtsQ2aUKjTgE+QOg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"vscode-languageserver-textdocument": "^1.0.1",
|
||||
"vscode-languageserver-types": "^3.16.0",
|
||||
"vscode-nls": "^5.0.0",
|
||||
"vscode-uri": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-json-languageservice/node_modules/jsonc-parser": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz",
|
||||
"integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vscode-jsonrpc": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz",
|
||||
"integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-languageserver": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz",
|
||||
"integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-languageserver-protocol": "3.17.5"
|
||||
},
|
||||
"bin": {
|
||||
"installServerIntoExtension": "bin/installServerIntoExtension"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-languageserver-protocol": {
|
||||
"version": "3.17.5",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz",
|
||||
"integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-jsonrpc": "8.2.0",
|
||||
"vscode-languageserver-types": "3.17.5"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-languageserver-textdocument": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz",
|
||||
"integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vscode-languageserver-types": {
|
||||
"version": "3.17.5",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz",
|
||||
"integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vscode-nls": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz",
|
||||
"integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vscode-uri": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz",
|
||||
"integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/w3c-xmlserializer": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
|
||||
@@ -13123,6 +12575,7 @@
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
@@ -13139,6 +12592,7 @@
|
||||
"version": "2.8.2",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
|
||||
"integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==",
|
||||
"devOptional": true,
|
||||
"license": "ISC",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
@@ -13151,88 +12605,11 @@
|
||||
"url": "https://github.com/sponsors/eemeli"
|
||||
}
|
||||
},
|
||||
"node_modules/yaml-language-server": {
|
||||
"version": "1.19.2",
|
||||
"resolved": "https://registry.npmjs.org/yaml-language-server/-/yaml-language-server-1.19.2.tgz",
|
||||
"integrity": "sha512-9F3myNmJzUN/679jycdMxqtydPSDRAarSj3wPiF7pchEPnO9Dg07Oc+gIYLqXR4L+g+FSEVXXv2+mr54StLFOg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vscode/l10n": "^0.0.18",
|
||||
"ajv": "^8.17.1",
|
||||
"ajv-draft-04": "^1.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"prettier": "^3.5.0",
|
||||
"request-light": "^0.5.7",
|
||||
"vscode-json-languageservice": "4.1.8",
|
||||
"vscode-languageserver": "^9.0.0",
|
||||
"vscode-languageserver-textdocument": "^1.0.1",
|
||||
"vscode-languageserver-types": "^3.16.0",
|
||||
"vscode-uri": "^3.0.2",
|
||||
"yaml": "2.7.1"
|
||||
},
|
||||
"bin": {
|
||||
"yaml-language-server": "bin/yaml-language-server"
|
||||
}
|
||||
},
|
||||
"node_modules/yaml-language-server/node_modules/ajv": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
|
||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fast-uri": "^3.0.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
"require-from-string": "^2.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/epoberezkin"
|
||||
}
|
||||
},
|
||||
"node_modules/yaml-language-server/node_modules/ajv-draft-04": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv-draft-04/-/ajv-draft-04-1.0.0.tgz",
|
||||
"integrity": "sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"ajv": "^8.5.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"ajv": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/yaml-language-server/node_modules/json-schema-traverse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/yaml-language-server/node_modules/request-light": {
|
||||
"version": "0.5.8",
|
||||
"resolved": "https://registry.npmjs.org/request-light/-/request-light-0.5.8.tgz",
|
||||
"integrity": "sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/yaml-language-server/node_modules/yaml": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz",
|
||||
"integrity": "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^8.0.1",
|
||||
@@ -13260,6 +12637,7 @@
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -13269,12 +12647,14 @@
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/yargs/node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -13284,6 +12664,7 @@
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
@@ -13298,6 +12679,7 @@
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "node --env-file=.env node_modules/astro/astro.js dev",
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro",
|
||||
@@ -12,7 +12,6 @@
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/check": "^0.9.6",
|
||||
"@astrojs/node": "^9.5.1",
|
||||
"@astrojs/svelte": "^7.2.2",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user