Lyo.Reporting.Api
2.0.0
dotnet add package Lyo.Reporting.Api --version 2.0.0
NuGet\Install-Package Lyo.Reporting.Api -Version 2.0.0
<PackageReference Include="Lyo.Reporting.Api" Version="2.0.0" />
<PackageVersion Include="Lyo.Reporting.Api" Version="2.0.0" />
<PackageReference Include="Lyo.Reporting.Api" />
paket add Lyo.Reporting.Api --version 2.0.0
#r "nuget: Lyo.Reporting.Api, 2.0.0"
#:package Lyo.Reporting.Api@2.0.0
#addin nuget:?package=Lyo.Reporting.Api&version=2.0.0
#tool nuget:?package=Lyo.Reporting.Api&version=2.0.0
Lyo.Reporting.Api
Authenticated HTTP endpoints for Lyo Reporting. Postgres stays service-only (ReportService + EF). BuildReportingGroup lives in this package.
Examples
Set up the host
// 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);
}
});
How a worker calls it
await reporting.Generations.GenerateAsync(new GenerateReportReq {
ReportDefinitionId = definitionId,
Parameters = [new() { Key = "ClientId", Type = LyoTypeInfo.Guid.FullName, Value = LyoTypeInfo.Guid.ToJson(clientId) }],
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);
Authorization matrix
| Surface | Options property | Endpoints |
|---|---|---|
| Definitions | DefinitionAuth |
Export + CRUD |
| Parameters on a definition | DefinitionAuth |
CRUD under Reporting/Definition/Parameter |
| Generations | GenerationAuth |
Get / Query / Delete / DeleteBulk (include Parameters). Delete runs OnCleanupAsync so persisted output is removed from storage. |
| Generate | GenerateAuth |
POST Reporting/Generation/Generate (Parameters list in the body) |
| Resolve parameter Options | DefinitionAuth |
POST Reporting/ResolveParameterOptions (Sproc/Query picker rows for the workbench; not a public execute-any-sproc API) |
| Rerun | GenerateAuth |
POST Reporting/Generation/{id}/Rerun |
| Download | DownloadAuth |
GET Reporting/Generation/{id}/Download (mapped only when DownloadStreamFactory is set) |
If every auth slot shares one policy, prefer ReportingApiOptions.WithAuth(auth, downloadStreamFactory) over setting all four properties.
All auth slots 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 slot. Setting a property to null restores the old fall-through behavior, but
prefer explicit values for Worker and Discord hosts.
CreatedBy
The authenticated identity always wins: GenerateReportReq.CreatedBy is overwritten with User.Identity.Name when the caller is authenticated. Client-supplied CreatedBy is only honored for unauthenticated/service callers, falling back to "Unknown".
HTTP status codes
- Validation failures (
ReportValidationException: unknown keys, bad parameters, 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).
Validating definition writes
ReportDataJsonmust parse as JSON and stay underMaxReportDataJsonBytes.- Parameter
TypeandDefaultFormatmust be valid enum values. ValidationRegexmust compile (1s timeout) and stay within the 500-char cap.MaxLength/MinLengthmust be non-negative and coherent.
Protecting sensitive fields
QueryProject and projected Export read raw entities and skip the response mapper's masking, so reporting endpoints deny selecting Value/EncryptedValue on parameter paths (including nested paths like Parameters.EncryptedValue and computed-field templates) via DeniedSelectFields. Get/QueryConcrete map through the response types, which mask parameter values (*** for encrypted-backed values, EncryptedValue never returned).
Cleanup when a definition is deleted
Deleting a definition cascades its generation rows. Before the delete, 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.
How a worker calls it
Workers call IReportingClient.Generations.GenerateAsync with a bearer token that satisfies GenerateAuth:
FileStorage hooks, renderers, and data providers 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.Common.Metadata(direct, lyo)Lyo.Configuration(direct, lyo)Lyo.Query.Models(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.Core(transitive, lyo)Lyo.Common.Json(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.Parameters(transitive, lyo)Lyo.Postgres(transitive, lyo)Lyo.Query(transitive, lyo)Lyo.Query.Evaluation(transitive, lyo)Lyo.Result(transitive, lyo)Lyo.Streams(transitive, lyo)Lyo.Validation(transitive, lyo)Lyo.Validation.Models(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)DynamicExpresso.Core2.19.3(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.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 (>= 2.0.0)
- Lyo.Api.Export (>= 2.0.0)
- Lyo.Common.Metadata (>= 2.0.0)
- Lyo.Configuration (>= 2.0.0)
- Lyo.Query.Models (>= 2.0.0)
- Lyo.Reporting.Models (>= 2.0.0)
- Lyo.Reporting.Postgres (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 49 | 9/9/2026 |