Lyo.Reporting.Postgres 1.0.2

dotnet add package Lyo.Reporting.Postgres --version 1.0.2
                    
NuGet\Install-Package Lyo.Reporting.Postgres -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lyo.Reporting.Postgres" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Reporting.Postgres" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Reporting.Postgres" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lyo.Reporting.Postgres --version 1.0.2
                    
#r "nuget: Lyo.Reporting.Postgres, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lyo.Reporting.Postgres@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lyo.Reporting.Postgres&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Reporting.Postgres&version=1.0.2
                    
Install as a Cake Tool

Lyo.Reporting.Postgres

PostgreSQL schema (reporting), EF migrations, CSV/XLSX/JSON renderers, ReportService generation pipeline, and ReportRetentionService cleanup.

HTTP endpoints live in Lyo.Api.Reporting (BuildReportingGroup). This package is service + EF only.

Examples

Register with DI

services.AddLyoQueryServices();
services.AddLocalCache();
services.AddIOTempService();
services.AddPostgresReportingManagement(o => {
    o.ConnectionString = cs;
    o.EnableAutoMigrations = true;
    o.MaxReportDataJsonBytes = 5_000_000;
    o.MaxOutputFileBytes = 50_000_000;
    o.AllowAdHocGeneration = true; // false = saved definitions only, no JSON overrides
    o.MaxConcurrentGenerations = 4; // 0 = unlimited; saturation throws ReportBusyException (HTTP 503)
    o.GenerationRetention = TimeSpan.FromDays(90); // null = retention cleanup disabled
});

services.AddReportingWebRenderer(); // optional HTML/PDF
services.AddReportDataProvider<MyProvider>();
services.AddReportingGenerationProfile("my-profile", p => p.DefaultFormat(ReportFormat.Csv));

services.AddReportingGenerationHooks(new ReportGenerationHooks {
    AfterRenderAsync = async (ctx, ct) => {
        var storage = ctx.Services.GetRequiredService<IFileStorageService>();
        var saved = await storage.SaveFileAsync(
            ctx.StagedFilePath!,
            ctx.FileName,
            pathPrefix: ctx.PathPrefix ?? ctx.Request.PathPrefix,
            contentType: ctx.ContentType,
            ct: ct);
        ctx.OutputFileId = saved.Id;
    },
    // Called before a generation row is removed (retention cleanup or definition delete):
    OnCleanupAsync = async (ctx, ct) => {
        if (ctx.OutputFileId is Guid fileId) {
            var storage = ctx.Services.GetRequiredService<IFileStorageService>();
            await storage.DeleteFileAsync(fileId, ct: ct);
        }
    }
});

services.AddLyoApiReporting();
app.BuildReportingGroup(new ReportingApiOptions {
    DefinitionAuth = EndpointAuth.RequireAuthenticatedUser(),
    GenerationAuth = EndpointAuth.RequireAuthenticatedUser(),
    GenerateAuth = EndpointAuth.RequireAuthorization("ReportingGenerate")
});

Run retention cleanup

// e.g. inside a scheduled job handler
var retention = scope.ServiceProvider.GetRequiredService<ReportRetentionService>();
var deleted = await retention.CleanupAsync(ct);

Design-time migrations

export REPORTING_CONNECTION_STRING="Host=localhost;Database=postgres;..."
dotnet ef migrations add YourMigration --project Integration/Reporting/Lyo.Reporting.Postgres

Rendering

ReportService resolves IEnumerable<IReportRenderer> from DI — it does not project-reference Lyo.Reporting.Web.

Format Package Registration
CSV this package AddPostgresReportingManagementCsvReportRenderer (first grid)
XLSX this package AddPostgresReportingManagementXlsxReportRenderer (one worksheet per grid)
JSON this package AddPostgresReportingManagementJsonReportRenderer (composition JSON verbatim)
HTML / PDF Lyo.Reporting.Web host calls AddReportingWebRenderer() (+ AddWebRenderer)

Optional host IReportDataProvider / ReportingGenerationProfile (keyed by definition GenerationProfileKey) supply domain data or pre-rendered files before render.

Hardening options

  • AllowAdHocGeneration (default true): when false, GenerateAsync requires a saved ReportDefinitionId and rejects ReportDataJson / OverrideReportDataJson payloads. Reruns of stored snapshots remain allowed.
  • MaxConcurrentGenerations (default 0 = unlimited): gates the provider + render section via a process-wide ReportGenerationThrottle. When saturated, generate waits briefly then throws ReportBusyException (mapped to HTTP 503 by the API).
  • GenerationRetention (default null = disabled): age after which terminal generations are eligible for ReportRetentionService cleanup.
  • Input hygiene: request file names are sanitized (directory segments, .., invalid/control characters stripped; length capped) and ReportDataJson must parse as JSON — malformed payloads fail fast with ReportValidationException before a generation row is persisted.
  • Failure resilience: Failed status is persisted with CancellationToken.None, so client disconnects can't strand generations in Running.

Parameters

  • Definition schema: report_definition_parameter (Key, Type, default Value, Required, validation, EncryptedValue, Options JSON picker source)
  • Generation instance: report_generation_parameter (Key, Type, Value, EncryptedValue)
  • ReportService.GenerateAsync merges request Parameters over definition defaults, validates, persists generation rows, and passes typed params plus a synthesized Key→Value JSON map to providers/renderers for transition. AllowMultiple keys serialize as JSON arrays in that map, so no value is lost.

Parameters — Validation semantics

  • Values are validated against the declared ReportParameterType (Guid, Int, Long, Decimal, Bool, DateTime, DateOnly, TimeOnly, Json, Regex, Xml); String/ Enum/Unknown accept any string (Enum is constrained via AllowedValues).
  • ValidationRegex runs with a 1-second match timeout and a 500-character pattern cap; a timeout or invalid pattern is reported as a validation error, never an unhandled exception (ReDoS-safe).
  • When generating from a definition, request parameter keys not declared on the definition are rejected with a clear error listing the unknown keys. Definition-less (ad-hoc) generates accept any keys.
  • A required parameter is satisfied by either Value or EncryptedValue.
  • Validation failures throw ReportValidationException, which the API maps to HTTP 400.

Rerun

ReportService.RerunAsync(generationId, createdBy) replays a past generation from its stored snapshot (composition JSON, format, file name, path prefix, parameters) into a new generation row. The saved definition is intentionally not re-read, so a since-changed or deactivated definition cannot alter the rerun.

Retention cleanup

ReportRetentionService.CleanupAsync batch-deletes terminal (Succeeded/Failed) generations older than GenerationRetention, oldest first, keeping in-flight (Pending/ Running) rows. Before each row is removed, ReportGenerationHooks.OnCleanupAsync runs so the host can delete the persisted output blob; a hook failure logs and retains that row. Emits the reporting.generation.cleaned metric. The service is registered by AddPostgresReportingManagement but not scheduled — hosts trigger it themselves, e.g. via Lyo.Scheduler or a Lyo.Job interval job:

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Api — (direct, lyo)
  • Lyo.Audit — (direct, lyo)
  • Lyo.Common — (direct, lyo)
  • Lyo.Csv — (direct, lyo)
  • Lyo.Exceptions — (direct, lyo)
  • Lyo.IO.Temp — (direct, lyo)
  • Lyo.Metrics — (direct, lyo)
  • Lyo.Postgres — (direct, lyo)
  • Lyo.Query.Models — (direct, lyo)
  • Lyo.Reporting.Models — (direct, lyo)
  • Lyo.Xlsx — (direct, lyo)
  • Microsoft.EntityFrameworkCore 10.0.5 — (direct, microsoft)
  • Microsoft.EntityFrameworkCore.Design 10.0.5 — (direct, microsoft)
  • Microsoft.Extensions.Configuration.Binder 10.0.5 — (direct, microsoft)
  • Lyo.Api.Models — (transitive, lyo)
  • Lyo.Cache — (transitive, lyo)
  • Lyo.Compression — (transitive, lyo)
  • Lyo.Csv.Models — (transitive, lyo)
  • Lyo.DataTable.Models — (transitive, lyo)
  • Lyo.DateAndTime — (transitive, lyo)
  • Lyo.Diagnostic — (transitive, lyo)
  • Lyo.Diagnostic.AspNetCore — (transitive, lyo)
  • Lyo.Diff — (transitive, lyo)
  • Lyo.Encryption — (transitive, lyo)
  • Lyo.EntityReference.Models — (transitive, lyo)
  • Lyo.Formatter — (transitive, lyo)
  • Lyo.Hashing — (transitive, lyo)
  • Lyo.Health — (transitive, lyo)
  • Lyo.KeyStore — (transitive, lyo)
  • Lyo.PackageMetadata — (transitive, lyo)
  • Lyo.Query — (transitive, lyo)
  • Lyo.Result — (transitive, lyo)
  • Lyo.Streams — (transitive, lyo)
  • Lyo.Validation — (transitive, lyo)
  • Lyo.Xlsx.Models — (transitive, lyo)
  • BouncyCastle.Cryptography 2.6.2 — (transitive, third-party, netstandard2.0)
  • ClosedXML 0.105.0 — (transitive, third-party)
  • DocumentFormat.OpenXml 3.1.1 — (transitive, third-party)
  • EasyCompressor 2.1.0 — (transitive, third-party)
  • ExcelDataReader 3.9.0 — (transitive, third-party)
  • ExcelDataReader.DataSet 3.9.0 — (transitive, third-party)
  • Konscious.Security.Cryptography.Argon2 1.3.1 — (transitive, third-party)
  • Microsoft.AspNetCore.Authorization 10.0.5 — (transitive, microsoft)
  • Microsoft.AspNetCore.Http.Abstractions 2.* — (transitive, microsoft)
  • Microsoft.AspNetCore.OpenApi 10.0.5 — (transitive, microsoft)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 — (transitive, microsoft, netstandard2.0)
  • Microsoft.EntityFrameworkCore.Analyzers 10.0.5 — (transitive, microsoft)
  • Microsoft.EntityFrameworkCore.Relational 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Caching.Memory 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Configuration 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.DependencyInjection 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 — (transitive, microsoft, net10.0, netstandard2.0)
  • Microsoft.Extensions.Hosting.Abstractions 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Options 10.0.5 — (transitive, microsoft)
  • Microsoft.Extensions.Options.ConfigurationExtensions 10.0.5 — (transitive, microsoft)
  • Npgsql.EntityFrameworkCore.PostgreSQL 10.0.3 — (transitive, third-party)
  • SmartFormat.NET 3.6.1 — (transitive, third-party)
  • System.Buffers 4.6.1 — (transitive, microsoft, netstandard2.0)
  • System.ComponentModel.Annotations 5.0.0 — (transitive, microsoft)
  • System.IO.Hashing 10.0.5 — (transitive, microsoft, net10.0)
  • System.Memory 4.6.3 — (transitive, microsoft, netstandard2.0)
  • System.Text.Encoding.CodePages 10.0.5 — (transitive, microsoft)
  • System.Text.Json 10.0.5 — (transitive, microsoft, netstandard2.0)
  • System.Threading.Tasks.Extensions 4.6.3 — (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Lyo.Reporting.Postgres:

Package Downloads
Lyo.Api.Reporting

HTTP API surface for Lyo Reporting: authenticated definition CRUD, read-only generations, and Generate.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 0 8/19/2026
1.0.1 63 8/18/2026
1.0.0 94 8/16/2026