Lyo.Api.Reporting
1.0.1
dotnet add package Lyo.Api.Reporting --version 1.0.1
NuGet\Install-Package Lyo.Api.Reporting -Version 1.0.1
<PackageReference Include="Lyo.Api.Reporting" Version="1.0.1" />
<PackageVersion Include="Lyo.Api.Reporting" Version="1.0.1" />
<PackageReference Include="Lyo.Api.Reporting" />
paket add Lyo.Api.Reporting --version 1.0.1
#r "nuget: Lyo.Api.Reporting, 1.0.1"
#:package Lyo.Api.Reporting@1.0.1
#addin nuget:?package=Lyo.Api.Reporting&version=1.0.1
#tool nuget:?package=Lyo.Api.Reporting&version=1.0.1
Lyo.Api.Reporting
Authenticated HTTP surface for Lyo Reporting. Postgres stays service-only (ReportService + EF); this package owns BuildReportingGroup.
Examples
Host setup
// One call registers Postgres management (DbContext factory, migrations, CRUD services,
// CSV/XLSX/JSON renderers, ReportService, retention, throttle) plus the API export contributor.
// Equivalent to AddPostgresReportingManagement + AddLyoApiReporting.
services.AddReportingApi(o => {
o.ConnectionString = cs;
o.EnableAutoMigrations = true;
});
// Or bind from appsettings ("PostgresReporting" section by default):
// services.AddReportingApiFromConfiguration(builder.Configuration);
services.AddReportingMaintenanceWorker(); // optional retention cleanup + stuck-run sweeper
services.AddReportingWebRenderer(); // optional HTML/PDF
services.AddReportDataProvider<MyReportDataProvider>();
services.AddReportingGenerationProfile("email-client-message", p => p
.DefaultFormat(ReportFormat.Csv)
.DefaultFileName("report.csv")
.DefaultPathPrefix("reports/email"));
// Worker / Discord policy example:
services.AddAuthorization(o => {
o.AddPolicy("ReportingGenerate", p => p.RequireAuthenticatedUser());
});
var app = builder.Build();
app.BuildReportingGroup(new ReportingApiOptions {
DefinitionAuth = EndpointAuth.RequireAuthenticatedUser(),
GenerationAuth = EndpointAuth.RequireAuthenticatedUser(),
GenerateAuth = EndpointAuth.RequireAuthorization("ReportingGenerate"),
DownloadAuth = EndpointAuth.RequireAuthenticatedUser(),
// Download endpoint is only mapped when this factory is set:
DownloadStreamFactory = (ctx, ct) => {
var storage = ctx.Services.GetRequiredService<IFileStorageService>();
return storage.GetFileStreamAsync(ctx.OutputFileId, ct: ct);
}
});
Worker flow
await reporting.Generations.GenerateAsync(new GenerateReportReq {
ReportDefinitionId = definitionId,
Parameters = [new() { Key = "ClientId", Type = ReportParameterType.Guid, Value = clientId.ToString() }],
Format = ReportFormat.Csv
});
// Re-run a past generation and stream its output:
var rerun = await reporting.Generations.RerunAsync(generationId);
var (stream, fileName, length) = await reporting.Generations.DownloadAsync(rerun.Id);
Auth matrix
| Surface | Options property | Endpoints |
|---|---|---|
| Definitions | DefinitionAuth |
CRUD + Export |
| Definition parameters | DefinitionAuth |
CRUD under Reporting/Definition/Parameter |
| Generations | GenerationAuth |
Query / Get only (read-only; include Parameters) |
| Generate | GenerateAuth |
POST Reporting/Generation/Generate (body Parameters list) |
| Rerun | GenerateAuth |
POST Reporting/Generation/{id}/Rerun |
| Download | DownloadAuth |
GET Reporting/Generation/{id}/Download (mapped only when DownloadStreamFactory is set) |
When every surface shares one policy, use ReportingApiOptions.WithAuth(auth, downloadStreamFactory) instead of setting all four properties.
All auth surfaces default to EndpointAuth.RequireAuthorization() (authenticated user). Breaking change: previously the defaults were null (endpoint fell through to the
builder/host default); anonymous access now requires an explicit EndpointAuth.Anonymous() per surface. Setting a property to null restores the old fall-through behavior, but
prefer explicit values for production Worker/Discord hosts.
CreatedBy
The authenticated identity always wins: when the caller is authenticated, GenerateReportReq.CreatedBy is overwritten with User.Identity.Name. Client-supplied CreatedBy is only honored for unauthenticated/service callers, falling back to "Unknown".
Status codes
- Validation failures (
ReportValidationException: bad parameters, unknown keys, malformed/oversized JSON, inactive or missing definition, ad-hoc disabled) → 400 ProblemDetails. - Concurrency saturation (
ReportBusyException, seePostgresReportingOptions.MaxConcurrentGenerations) → 503 ProblemDetails. - Download: 404 when the generation or blob is missing, 409 when the generation has no downloadable output (not
Succeededor noOutputFileId).
Definition write-time validation
ReportDataJsonmust parse as JSON and respectMaxReportDataJsonBytes.DefaultFormatand parameterTypemust be valid enum values.ValidationRegexmust compile (1s timeout) and stay within the 500-char cap.MinLength/MaxLengthmust be non-negative and coherent.
Sensitive field protection
QueryProject and projected Export read raw entities and bypass the response mapper's masking, so the reporting surfaces deny selecting EncryptedValue/Value on parameter paths (including nested paths like Parameters.EncryptedValue and computed-field templates) via DeniedSelectFields. QueryConcrete/Get map through the response types, which mask parameter values (*** for encrypted-backed values, EncryptedValue never returned).
Definition delete cleanup
Deleting a definition cascades its generation rows. Before the delete, the host ReportGenerationHooks.OnCleanupAsync runs for each generation with an OutputFileId so the persisted blob can be removed; a hook failure aborts the delete rather than orphaning storage.
Worker flow
Workers call IReportingClient.Generations.GenerateAsync with a bearer token that satisfies GenerateAuth:
Data providers, renderers, and FileStorage hooks run on the API host — not in the worker process.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Api— (direct, lyo)Lyo.Api.Export— (direct, lyo)Lyo.Reporting.Models— (direct, lyo)Lyo.Reporting.Postgres— (direct, lyo)Lyo.Api.Models— (transitive, lyo)Lyo.Audit— (transitive, lyo)Lyo.Cache— (transitive, lyo)Lyo.Common— (transitive, lyo)Lyo.Compression— (transitive, lyo)Lyo.Csv— (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.Exceptions— (transitive, lyo)Lyo.Formatter— (transitive, lyo)Lyo.Hashing— (transitive, lyo)Lyo.Health— (transitive, lyo)Lyo.IO.Temp— (transitive, lyo)Lyo.KeyStore— (transitive, lyo)Lyo.Metrics— (transitive, lyo)Lyo.PackageMetadata— (transitive, lyo)Lyo.Postgres— (transitive, lyo)Lyo.Query— (transitive, lyo)Lyo.Query.Models— (transitive, lyo)Lyo.Result— (transitive, lyo)Lyo.Streams— (transitive, lyo)Lyo.Validation— (transitive, lyo)Lyo.Xlsx— (transitive, lyo)Lyo.Xlsx.Models— (transitive, lyo)BouncyCastle.Cryptography2.6.2— (transitive, third-party, netstandard2.0)ClosedXML0.105.0— (transitive, third-party)DocumentFormat.OpenXml3.1.1— (transitive, third-party)EasyCompressor2.1.0— (transitive, third-party)ExcelDataReader3.9.0— (transitive, third-party)ExcelDataReader.DataSet3.9.0— (transitive, third-party)Konscious.Security.Cryptography.Argon21.3.1— (transitive, third-party)Microsoft.AspNetCore.Authorization10.0.5— (transitive, microsoft)Microsoft.AspNetCore.Http.Abstractions2.*— (transitive, microsoft)Microsoft.AspNetCore.OpenApi10.0.5— (transitive, microsoft)Microsoft.Bcl.AsyncInterfaces10.0.5— (transitive, microsoft, netstandard2.0)Microsoft.EntityFrameworkCore10.0.5— (transitive, microsoft)Microsoft.EntityFrameworkCore.Analyzers10.0.5— (transitive, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5— (transitive, microsoft)Microsoft.EntityFrameworkCore.Relational10.0.5— (transitive, microsoft)Microsoft.Extensions.Caching.Memory10.0.5— (transitive, microsoft)Microsoft.Extensions.Configuration10.0.5— (transitive, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (transitive, microsoft, net10.0, netstandard2.0)Microsoft.Extensions.Hosting.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Options10.0.5— (transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)Npgsql.EntityFrameworkCore.PostgreSQL10.0.3— (transitive, third-party)SmartFormat.NET3.6.1— (transitive, third-party)System.Buffers4.6.1— (transitive, microsoft, netstandard2.0)System.ComponentModel.Annotations5.0.0— (transitive, microsoft)System.IO.Hashing10.0.5— (transitive, microsoft, net10.0)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Encoding.CodePages10.0.5— (transitive, microsoft)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)System.Threading.Tasks.Extensions4.6.3— (transitive, microsoft, netstandard2.0)
| Product | Versions 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. |
-
net10.0
- Lyo.Api (>= 1.0.1)
- Lyo.Api.Export (>= 1.0.1)
- Lyo.Reporting.Models (>= 1.0.1)
- Lyo.Reporting.Postgres (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.