Skip to content

Commit

Permalink
Merge branch 'generic-extension-settings' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Wilms committed Jan 31, 2025
2 parents 0c89a92 + 59e18d4 commit c4b7acc
Show file tree
Hide file tree
Showing 44 changed files with 959 additions and 451 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v2.0.0-beta.46 - 2025-01-31
- Prepare strongly typed data source configuration

## v2.0.0-beta.45 - 2025-01-25
- Fix OIDC identifier claim definition

Expand All @@ -8,7 +11,7 @@
- Follow Apollo3zehn.PackageManagement changes

## v2.0.0-beta.42 - 2025-01-16
- Make Nexus.PackageManagement indepenent of Nexus.Extensibility
- Make Nexus.PackageManagement independent of Nexus.Extensibility

## v2.0.0-beta.41 - 2025-01-15
- Update Python libs
Expand Down
15 changes: 15 additions & 0 deletions Nexus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensibility", "extensibil
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-extensibility-tests", "tests\extensibility\dotnet-extensibility-tests\dotnet-extensibility-tests.csproj", "{25A65150-BC9F-4F92-9078-18ABA7444C21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-extensibility-analyzers", "src\extensibility\dotnet-extensibility-analyzers\dotnet-extensibility-analyzers.csproj", "{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -154,6 +156,18 @@ Global
{25A65150-BC9F-4F92-9078-18ABA7444C21}.Release|x64.Build.0 = Release|Any CPU
{25A65150-BC9F-4F92-9078-18ABA7444C21}.Release|x86.ActiveCfg = Release|Any CPU
{25A65150-BC9F-4F92-9078-18ABA7444C21}.Release|x86.Build.0 = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|x64.ActiveCfg = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|x64.Build.0 = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|x86.ActiveCfg = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Debug|x86.Build.0 = Debug|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|Any CPU.Build.0 = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|x64.ActiveCfg = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|x64.Build.0 = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|x86.ActiveCfg = Release|Any CPU
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -171,6 +185,7 @@ Global
{322CA18D-4C04-41DB-9D17-283FC53849CA} = {1C0BDA12-25B4-42F8-87B5-C3B3BEF417B2}
{6B7A5EC5-213A-44CC-B279-3E0C33082FC8} = {3DBD52E4-26F8-413F-A954-2BE86E572F3E}
{25A65150-BC9F-4F92-9078-18ABA7444C21} = {6B7A5EC5-213A-44CC-B279-3E0C33082FC8}
{FCA09ED9-A1B3-4BA9-AD9B-7381F999A83F} = {1C0BDA12-25B4-42F8-87B5-C3B3BEF417B2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F998BD6D-3E2B-4AA0-A7A4-FD84100C45A4}
Expand Down
108 changes: 57 additions & 51 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1031,18 +1031,18 @@
}
},
"/api/v1/sources/pipelines/{pipelineId}": {
"delete": {
"put": {
"tags": [
"Sources"
],
"summary": "Deletes a data source pipeline.",
"operationId": "Sources_DeletePipeline",
"summary": "Updates a data source pipeline.",
"operationId": "Sources_UpdatePipeline",
"parameters": [
{
"name": "pipelineId",
"in": "path",
"required": true,
"description": "The identifier of the pipeline.",
"description": "The identifier of the pipeline to update.",
"schema": {
"type": "string",
"format": "guid"
Expand All @@ -1057,9 +1057,22 @@
"type": "string",
"nullable": true
},
"x-position": 2
"x-position": 3
}
],
"requestBody": {
"x-name": "pipeline",
"description": "The new pipeline.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataSourcePipeline"
}
}
},
"required": true,
"x-position": 2
},
"responses": {
"200": {
"description": "",
Expand All @@ -1073,36 +1086,58 @@
}
}
}
}
},
"/api/v1/system/file-type": {
"get": {
},
"delete": {
"tags": [
"System"
"Sources"
],
"summary": "Deletes a data source pipeline.",
"operationId": "Sources_DeletePipeline",
"parameters": [
{
"name": "pipelineId",
"in": "path",
"required": true,
"description": "The identifier of the pipeline to delete.",
"schema": {
"type": "string",
"format": "guid"
},
"x-position": 1
},
{
"name": "userId",
"in": "query",
"description": "The optional user identifier. If not specified, the current user will be used.",
"schema": {
"type": "string",
"nullable": true
},
"x-position": 2
}
],
"summary": "Gets the default file type.",
"operationId": "System_GetDefaultFileType",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"application/octet-stream": {
"schema": {
"type": "string"
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/api/v1/system/help-link": {
"/api/v1/system/file-type": {
"get": {
"tags": [
"System"
],
"summary": "Gets the configured help link.",
"operationId": "System_GetHelpLink",
"summary": "Gets the default file type.",
"operationId": "System_GetDefaultFileType",
"responses": {
"200": {
"description": "",
Expand All @@ -1117,51 +1152,25 @@
}
}
},
"/api/v1/system/configuration": {
"/api/v1/system/help-link": {
"get": {
"tags": [
"System"
],
"summary": "Gets the system configuration.",
"operationId": "System_GetConfiguration",
"summary": "Gets the configured help link.",
"operationId": "System_GetHelpLink",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"nullable": true,
"additionalProperties": {}
"type": "string"
}
}
}
}
}
},
"put": {
"tags": [
"System"
],
"summary": "Sets the system configuration.",
"operationId": "System_SetConfiguration",
"requestBody": {
"x-name": "configuration",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {}
}
}
},
"x-position": 1
},
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/users/authenticate": {
Expand Down Expand Up @@ -2184,10 +2193,7 @@
"nullable": true
},
"configuration": {
"type": "object",
"description": "Configuration parameters for the instantiated source.",
"nullable": true,
"additionalProperties": {}
"description": "Configuration parameters for the instantiated source."
},
"infoUrl": {
"type": "string",
Expand Down
6 changes: 5 additions & 1 deletion src/Nexus.UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ public ExportParameters GetExportParameters()
var actualParameters = _appState.ExportParameters with
{
ResourcePaths = resourcePaths,
Configuration = _appState.Settings.Configuration.ToDictionary(entry => entry.Key, entry => JsonSerializer.SerializeToElement(entry.Value))
Configuration = _appState.Settings.Configuration
.ToDictionary(
entry => entry.Key,
entry => JsonSerializer.SerializeToElement(entry.Value)
)
};

return actualParameters;
Expand Down
1 change: 0 additions & 1 deletion src/Nexus/API/v1/CatalogsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Nexus.Core;
using Nexus.Core.V1;
Expand Down
30 changes: 29 additions & 1 deletion src/Nexus/API/v1/SourcesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ IPipelineService pipelineService
// GET /api/sources/descriptions
// GET /api/sources/pipelines
// POST /api/sources/pipelines
// PUT /api/sources/pipelines/{pipelineId}
// DELETE /api/sources/pipelines/{pipelineId}

private readonly IExtensionHive<IDataSource> _extensionHive = extensionHive;
Expand Down Expand Up @@ -79,10 +80,37 @@ public async Task<ActionResult<Guid>> CreatePipelineAsync(
return response;
}

/// <summary>
/// Updates a data source pipeline.
/// </summary>
/// <param name="pipelineId">The identifier of the pipeline to update.</param>
/// <param name="pipeline">The new pipeline.</param>
/// <param name="userId">The optional user identifier. If not specified, the current user will be used.</param>
[HttpPut("pipelines/{pipelineId}")]
public async Task<ActionResult> UpdatePipelineAsync(
Guid pipelineId,
DataSourcePipeline pipeline,
[FromQuery] string? userId = default)
{
if (TryAuthenticate(userId, out var actualUserId, out var response))
{
if (await _pipelineService.TryUpdateAsync(actualUserId, pipelineId, pipeline))
return Ok();

else
return NotFound();
}

else
{
return response;
}
}

/// <summary>
/// Deletes a data source pipeline.
/// </summary>
/// <param name="pipelineId">The identifier of the pipeline.</param>
/// <param name="pipelineId">The identifier of the pipeline to delete.</param>
/// <param name="userId">The optional user identifier. If not specified, the current user will be used.</param>
[HttpDelete("pipelines/{pipelineId}")]
public async Task<ActionResult> DeletePipelineAsync(
Expand Down
29 changes: 2 additions & 27 deletions src/Nexus/API/v1/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@ namespace Nexus.Controllers.V1;
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
internal class SystemController(
AppState appState,
AppStateManager appStateManager,
IOptions<GeneralOptions> generalOptions) : ControllerBase
IOptions<GeneralOptions> generalOptions
) : ControllerBase
{
// [authenticated]
// GET /api/system/configuration
// GET /api/system/file-type
// GET /api/system/help-link

// [privileged]
// PUT /api/system/configuration

private readonly AppState _appState = appState;
private readonly AppStateManager _appStateManager = appStateManager;
private readonly GeneralOptions _generalOptions = generalOptions.Value;

/// <summary>
Expand All @@ -51,23 +45,4 @@ internal class SystemController(
{
return _generalOptions.HelpLink;
}

/// <summary>
/// Gets the system configuration.
/// </summary>
[HttpGet("configuration")]
public IReadOnlyDictionary<string, JsonElement>? GetConfiguration()
{
return _appState.Project.SystemConfiguration;
}

/// <summary>
/// Sets the system configuration.
/// </summary>
[HttpPut("configuration")]
[Authorize(Policy = NexusPolicies.RequireAdmin)]
public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement>? configuration)
{
return _appStateManager.PutSystemConfigurationAsync(configuration);
}
}
3 changes: 0 additions & 3 deletions src/Nexus/Core/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public AppState()

public Task? ReloadPackagesTask { get; set; }

// these properties will be set during host startup
public NexusProject Project { get; set; } = default!;

public CatalogState CatalogState { get; set; } = default!;

public List<ExtensionDescription> DataWriterDescriptions { get; set; } = default!;
Expand Down
4 changes: 0 additions & 4 deletions src/Nexus/Core/Models_NonPublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Nexus.DataModel;
using Nexus.Extensibility;
using System.IO.Pipelines;
using System.Text.Json;

namespace Nexus.Core;

Expand All @@ -28,9 +27,6 @@ internal record CatalogItemRequest(
CatalogItem? BaseItem,
CatalogContainer Container);

internal record NexusProject(
IReadOnlyDictionary<string, JsonElement>? SystemConfiguration);

internal record CatalogState(
CatalogContainer Root,
CatalogCache Cache);
Expand Down
4 changes: 2 additions & 2 deletions src/Nexus/Core/Models_Public_v1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public record CatalogAvailability(
/// <param name="ReleasePattern">An optional regular expressions pattern to select the catalogs to be released. By default, all catalogs will be released.</param>
/// <param name="VisibilityPattern">An optional regular expressions pattern to select the catalogs to be visible. By default, all catalogs will be visible.</param>
public record DataSourcePipeline(
DataSourceRegistration[] Registrations,
IReadOnlyList<DataSourceRegistration> Registrations,
string? ReleasePattern = default,
string? VisibilityPattern = default);

Expand All @@ -216,7 +216,7 @@ public record DataSourcePipeline(
public record DataSourceRegistration(
string Type,
Uri? ResourceLocator,
IReadOnlyDictionary<string, JsonElement>? Configuration,
JsonElement Configuration,
string? InfoUrl = default);

/// <summary>
Expand Down
Loading

0 comments on commit c4b7acc

Please sign in to comment.