diff --git a/FictionArchive.API/build_gateway.bat b/FictionArchive.API/build_gateway.bat new file mode 100644 index 0000000..598d0e6 --- /dev/null +++ b/FictionArchive.API/build_gateway.bat @@ -0,0 +1,99 @@ +@echo off +setlocal enabledelayedexpansion + +set ROOT=%~dp0 + +for %%A in ("%ROOT%..") do set SERVICES_DIR=%%~fA\ + +REM ---------------------------------------- +REM List of project names to skip +REM (space-separated, match folder names exactly) +REM ---------------------------------------- +set SKIP_PROJECTS=FictionArchive.Service.Shared FictionArchive.Service.AuthenticationService + +echo ---------------------------------------- +echo Finding GraphQL services... +echo ---------------------------------------- + +set SERVICE_LIST= + +for /d %%F in ("%SERVICES_DIR%FictionArchive.Service.*") do ( + set "PROJECT_NAME=%%~nxF" + set "SKIP=0" + + REM Check if this project name is in the skip list + for %%X in (%SKIP_PROJECTS%) do ( + if /I "!PROJECT_NAME!"=="%%X" ( + set "SKIP=1" + ) + ) + + if !SKIP!==0 ( + echo Found service: !PROJECT_NAME! + set SERVICE_LIST=!SERVICE_LIST! %%F + ) else ( + echo Skipping service: !PROJECT_NAME! + ) +) + +echo: +echo ---------------------------------------- +echo Exporting schemas and packing subgraphs... +echo ---------------------------------------- + +for %%S in (%SERVICE_LIST%) do ( + echo Processing service folder: %%S + pushd "%%S" + + echo Running schema export... + dotnet run -- schema export --output schema.graphql + if errorlevel 1 ( + echo ERROR during schema export in %%S + popd + exit /b 1 + ) + + echo Running fusion subgraph pack... + fusion subgraph pack + if errorlevel 1 ( + echo ERROR during subgraph pack in %%S + popd + exit /b 1 + ) + + popd + echo Completed: %%S + echo. +) + +echo ---------------------------------------- +echo Running fusion compose... +echo ---------------------------------------- + +pushd "%ROOT%" + +if exist gateway.fgp del gateway.fgp + +for %%S in (%SERVICE_LIST%) do ( + REM Extract the full folder name WITH dots preserved + set "SERVICE_NAME=%%~nxS" + + echo Composing subgraph: !SERVICE_NAME! + + fusion compose -p gateway.fgp -s "..\!SERVICE_NAME!" + if errorlevel 1 ( + echo ERROR during fusion compose + popd + exit /b 1 + ) +) + +popd + + +echo ---------------------------------------- +echo Fusion build complete! +echo ---------------------------------------- + +endlocal +exit /b 0 diff --git a/FictionArchive.API/build_gateway.sh b/FictionArchive.API/build_gateway.sh new file mode 100644 index 0000000..f6ed69a --- /dev/null +++ b/FictionArchive.API/build_gateway.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +set -euo pipefail + +############################################### +# Resolve important directories +############################################### + +# Directory where this script lives +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Services live one directory above the script's directory +SERVICES_DIR="$(cd "$ROOT/.." && pwd)" + +############################################### +# Skip list (folder names, match exactly) +############################################### +SKIP_PROJECTS=( + "FictionArchive.Service.Shared" + "FictionArchive.Service.Legacy" +) + +echo "----------------------------------------" +echo " Finding GraphQL services..." +echo "----------------------------------------" + +SERVICE_LIST=() + +# Convert skip projects into a single searchable string +SKIP_STRING=" ${SKIP_PROJECTS[*]} " + +# Find service directories +shopt -s nullglob +for FOLDER in "$SERVICES_DIR"/FictionArchive.Service.*; do + [ -d "$FOLDER" ] || continue + + PROJECT_NAME="$(basename "$FOLDER")" + + # Skip entries that match the skip list + if [[ "$SKIP_STRING" == *" $PROJECT_NAME "* ]]; then + echo "Skipping service: $PROJECT_NAME" + continue + fi + + echo "Found service: $PROJECT_NAME" + SERVICE_LIST+=("$FOLDER") +done +shopt -u nullglob + +echo +echo "----------------------------------------" +echo " Exporting schemas and packing subgraphs..." +echo "----------------------------------------" + +for SERVICE in "${SERVICE_LIST[@]}"; do + PROJECT_NAME="$(basename "$SERVICE")" + + echo "Processing service: $PROJECT_NAME" + pushd "$SERVICE" >/dev/null + + echo "Building service..." + dotnet build -c Release >/dev/null + + # Automatically detect built DLL in bin/Release// + DLL_PATH="$(find "bin/Release" -maxdepth 3 -name '*.dll' | head -n 1)" + if [[ -z "$DLL_PATH" ]]; then + echo "ERROR: Could not locate DLL for $PROJECT_NAME" + popd >/dev/null + exit 1 + fi + + echo "Running schema export..." + dotnet exec "$DLL_PATH" schema export --output schema.graphql + + echo "Running subgraph pack..." + fusion subgraph pack + + popd >/dev/null + echo "Completed: $PROJECT_NAME" + echo +done + +echo "----------------------------------------" +echo " Running fusion compose..." +echo "----------------------------------------" + +pushd "$ROOT" >/dev/null + +# Remove old composition file +rm -f gateway.fgp + +for SERVICE in "${SERVICE_LIST[@]}"; do + SERVICE_NAME="$(basename "$SERVICE")" + + echo "Composing subgraph: $SERVICE_NAME" + + # Note: Fusion compose must reference parent dir (services live above ROOT) + fusion compose -p gateway.fgp -s "../$SERVICE_NAME" +done + +popd >/dev/null + +echo "----------------------------------------" +echo " Fusion build complete!" +echo "----------------------------------------" diff --git a/FictionArchive.API/gateway.fgp b/FictionArchive.API/gateway.fgp index fd770eb..4eb467a 100644 Binary files a/FictionArchive.API/gateway.fgp and b/FictionArchive.API/gateway.fgp differ diff --git a/FictionArchive.Service.NovelService/Program.cs b/FictionArchive.Service.NovelService/Program.cs index 5592c15..233118f 100644 --- a/FictionArchive.Service.NovelService/Program.cs +++ b/FictionArchive.Service.NovelService/Program.cs @@ -76,9 +76,7 @@ public class Program app.MapHealthChecks("/healthz"); app.MapGraphQL(); - - app.RunWithGraphQLCommands(args); - app.Run(); + app.RunWithGraphQLCommands(args); } } \ No newline at end of file diff --git a/FictionArchive.Service.SchedulerService/Program.cs b/FictionArchive.Service.SchedulerService/Program.cs index 1710637..9d40de1 100644 --- a/FictionArchive.Service.SchedulerService/Program.cs +++ b/FictionArchive.Service.SchedulerService/Program.cs @@ -69,6 +69,6 @@ public class Program app.MapGraphQL(); - app.Run(); + app.RunWithGraphQLCommands(args); } } \ No newline at end of file diff --git a/FictionArchive.Service.SchedulerService/subgraph-config.json b/FictionArchive.Service.SchedulerService/subgraph-config.json new file mode 100644 index 0000000..146a0b6 --- /dev/null +++ b/FictionArchive.Service.SchedulerService/subgraph-config.json @@ -0,0 +1,6 @@ +{ + "subgraph": "Scheduler", + "http": { + "baseAddress": "http://localhost:5213/graphql" + } +} \ No newline at end of file diff --git a/FictionArchive.Service.Shared/FictionArchive.Service.Shared.csproj b/FictionArchive.Service.Shared/FictionArchive.Service.Shared.csproj index e27a5be..da7c156 100644 --- a/FictionArchive.Service.Shared/FictionArchive.Service.Shared.csproj +++ b/FictionArchive.Service.Shared/FictionArchive.Service.Shared.csproj @@ -9,6 +9,7 @@ + diff --git a/FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.Designer.cs b/FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.Designer.cs similarity index 90% rename from FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.Designer.cs rename to FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.Designer.cs index e0cb23b..449648b 100644 --- a/FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.Designer.cs +++ b/FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.Designer.cs @@ -1,4 +1,5 @@ // +using System; using FictionArchive.Service.TranslationService.Services.Database; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -12,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FictionArchive.Service.TranslationService.Migrations { [DbContext(typeof(TranslationServiceDbContext))] - [Migration("20251118052322_Initial")] + [Migration("20251122225458_Initial")] partial class Initial { /// @@ -27,11 +28,9 @@ namespace FictionArchive.Service.TranslationService.Migrations modelBuilder.Entity("FictionArchive.Service.TranslationService.Models.Database.TranslationRequest", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + .HasColumnType("uuid"); b.Property("BilledCharacterCount") .HasColumnType("bigint"); diff --git a/FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.cs b/FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.cs similarity index 84% rename from FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.cs rename to FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.cs index 4018158..2ea589a 100644 --- a/FictionArchive.Service.TranslationService/Migrations/20251118052322_Initial.cs +++ b/FictionArchive.Service.TranslationService/Migrations/20251122225458_Initial.cs @@ -1,6 +1,6 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System; +using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -16,8 +16,7 @@ namespace FictionArchive.Service.TranslationService.Migrations name: "TranslationRequests", columns: table => new { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Id = table.Column(type: "uuid", nullable: false), OriginalText = table.Column(type: "text", nullable: false), TranslatedText = table.Column(type: "text", nullable: true), From = table.Column(type: "integer", nullable: false), diff --git a/FictionArchive.Service.TranslationService/Migrations/TranslationServiceDbContextModelSnapshot.cs b/FictionArchive.Service.TranslationService/Migrations/TranslationServiceDbContextModelSnapshot.cs index d06ce38..3a18060 100644 --- a/FictionArchive.Service.TranslationService/Migrations/TranslationServiceDbContextModelSnapshot.cs +++ b/FictionArchive.Service.TranslationService/Migrations/TranslationServiceDbContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using FictionArchive.Service.TranslationService.Services.Database; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -24,11 +25,9 @@ namespace FictionArchive.Service.TranslationService.Migrations modelBuilder.Entity("FictionArchive.Service.TranslationService.Models.Database.TranslationRequest", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + .HasColumnType("uuid"); b.Property("BilledCharacterCount") .HasColumnType("bigint"); diff --git a/FictionArchive.Service.TranslationService/Program.cs b/FictionArchive.Service.TranslationService/Program.cs index 4a632bb..3fb305c 100644 --- a/FictionArchive.Service.TranslationService/Program.cs +++ b/FictionArchive.Service.TranslationService/Program.cs @@ -73,6 +73,6 @@ public class Program app.MapGraphQL(); - app.Run(); + app.RunWithGraphQLCommands(args); } } \ No newline at end of file diff --git a/FictionArchive.Service.TranslationService/subgraph-config.json b/FictionArchive.Service.TranslationService/subgraph-config.json new file mode 100644 index 0000000..5a031b3 --- /dev/null +++ b/FictionArchive.Service.TranslationService/subgraph-config.json @@ -0,0 +1,6 @@ +{ + "subgraph": "Translation", + "http": { + "baseAddress": "http://localhost:5234/graphql" + } +} \ No newline at end of file diff --git a/FictionArchive.Service.UserService/Program.cs b/FictionArchive.Service.UserService/Program.cs index fa035a4..13c397d 100644 --- a/FictionArchive.Service.UserService/Program.cs +++ b/FictionArchive.Service.UserService/Program.cs @@ -47,6 +47,6 @@ public class Program app.MapHealthChecks("/healthz"); - app.Run(); + app.RunWithGraphQLCommands(args); } } \ No newline at end of file diff --git a/FictionArchive.Service.UserService/subgraph-config.json b/FictionArchive.Service.UserService/subgraph-config.json new file mode 100644 index 0000000..38e8311 --- /dev/null +++ b/FictionArchive.Service.UserService/subgraph-config.json @@ -0,0 +1,6 @@ +{ + "subgraph": "User", + "http": { + "baseAddress": "http://localhost:5145/graphql" + } +} \ No newline at end of file