Gaps fill up, fixes, ui restructuring
This commit is contained in:
@@ -19,9 +19,11 @@ using StellaOps.Attestor.Core.Storage;
|
||||
using StellaOps.Attestor.Core.Submission;
|
||||
using StellaOps.Attestor.Core.Verification;
|
||||
using StellaOps.Attestor.Infrastructure;
|
||||
using StellaOps.Attestor.Persistence;
|
||||
using StellaOps.Attestor.ProofChain;
|
||||
using StellaOps.Attestor.Spdx3;
|
||||
using StellaOps.Attestor.Watchlist;
|
||||
using StellaOps.Attestor.WebService.Endpoints;
|
||||
using StellaOps.Attestor.WebService.Options;
|
||||
using StellaOps.Auth.ServerIntegration;
|
||||
using StellaOps.Configuration;
|
||||
@@ -141,6 +143,13 @@ internal static class AttestorWebServiceComposition
|
||||
builder.Services.AddAttestorInfrastructure();
|
||||
builder.Services.AddProofChainServices();
|
||||
|
||||
// Predicate type registry (Sprint: SPRINT_20260219_010, PSR-02)
|
||||
var postgresConnectionString = builder.Configuration["attestor:postgres:connectionString"];
|
||||
if (!string.IsNullOrWhiteSpace(postgresConnectionString))
|
||||
{
|
||||
builder.Services.AddPredicateTypeRegistry(postgresConnectionString);
|
||||
}
|
||||
|
||||
builder.Services.AddScoped<Services.IProofChainQueryService, Services.ProofChainQueryService>();
|
||||
builder.Services.AddScoped<Services.IProofVerificationService, Services.ProofVerificationService>();
|
||||
|
||||
@@ -410,6 +419,7 @@ internal static class AttestorWebServiceComposition
|
||||
app.MapControllers();
|
||||
app.MapAttestorEndpoints(attestorOptions);
|
||||
app.MapWatchlistEndpoints();
|
||||
app.MapPredicateRegistryEndpoints();
|
||||
|
||||
app.TryRefreshStellaRouterEndpoints(routerOptions);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// PredicateRegistryEndpoints.cs
|
||||
// Sprint: SPRINT_20260219_010 (PSR-02)
|
||||
// Task: PSR-02 - Create Predicate Schema Registry endpoints and repository
|
||||
// Description: REST API endpoints for the predicate type schema registry
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using StellaOps.Attestor.Persistence.Repositories;
|
||||
|
||||
namespace StellaOps.Attestor.WebService.Endpoints;
|
||||
|
||||
/// <summary>
|
||||
/// Endpoints for the predicate type schema registry.
|
||||
/// Sprint: SPRINT_20260219_010 (PSR-02)
|
||||
/// </summary>
|
||||
public static class PredicateRegistryEndpoints
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps predicate registry endpoints.
|
||||
/// </summary>
|
||||
public static void MapPredicateRegistryEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.MapGroup("/api/v1/attestor/predicates")
|
||||
.WithTags("Predicate Registry")
|
||||
.WithOpenApi();
|
||||
|
||||
group.MapGet("/", ListPredicateTypes)
|
||||
.WithName("ListPredicateTypes")
|
||||
.WithSummary("List all registered predicate types")
|
||||
.Produces<PredicateTypeListResponse>(StatusCodes.Status200OK);
|
||||
|
||||
group.MapGet("/{uri}", GetPredicateType)
|
||||
.WithName("GetPredicateType")
|
||||
.WithSummary("Get predicate type schema by URI")
|
||||
.Produces<PredicateTypeRegistryEntry>(StatusCodes.Status200OK)
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
private static async Task<IResult> ListPredicateTypes(
|
||||
IPredicateTypeRegistryRepository repository,
|
||||
string? category = null,
|
||||
bool? isActive = null,
|
||||
int offset = 0,
|
||||
int limit = 100,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var entries = await repository.ListAsync(category, isActive, offset, limit, ct);
|
||||
return Results.Ok(new PredicateTypeListResponse
|
||||
{
|
||||
Items = entries,
|
||||
Offset = offset,
|
||||
Limit = limit,
|
||||
Count = entries.Count,
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetPredicateType(
|
||||
string uri,
|
||||
IPredicateTypeRegistryRepository repository,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var decoded = Uri.UnescapeDataString(uri);
|
||||
var entry = await repository.GetByUriAsync(decoded, ct);
|
||||
if (entry is null)
|
||||
{
|
||||
return Results.NotFound(new { error = "Predicate type not found", uri = decoded });
|
||||
}
|
||||
|
||||
return Results.Ok(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Response for listing predicate types.
|
||||
/// </summary>
|
||||
public sealed record PredicateTypeListResponse
|
||||
{
|
||||
/// <summary>The predicate type entries.</summary>
|
||||
public required IReadOnlyList<PredicateTypeRegistryEntry> Items { get; init; }
|
||||
|
||||
/// <summary>Pagination offset.</summary>
|
||||
public int Offset { get; init; }
|
||||
|
||||
/// <summary>Pagination limit.</summary>
|
||||
public int Limit { get; init; }
|
||||
|
||||
/// <summary>Number of items returned.</summary>
|
||||
public int Count { get; init; }
|
||||
}
|
||||
@@ -32,5 +32,6 @@
|
||||
<ProjectReference Include="..\..\__Libraries\StellaOps.Attestor.Bundling\StellaOps.Attestor.Bundling.csproj" />
|
||||
<ProjectReference Include="..\..\__Libraries\StellaOps.Attestor.Spdx3\StellaOps.Attestor.Spdx3.csproj" />
|
||||
<ProjectReference Include="..\..\__Libraries\StellaOps.Attestor.Watchlist\StellaOps.Attestor.Watchlist.csproj" />
|
||||
<ProjectReference Include="..\..\__Libraries\StellaOps.Attestor.Persistence\StellaOps.Attestor.Persistence.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user