Catalog++

broken/ef
Paul Schneider 2 years ago
parent 58f49af5f0
commit fcea41f8c1
8 changed files with 48 additions and 76 deletions

@ -24,24 +24,20 @@ namespace isnd.Controllers
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]); return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
} }
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration [HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/index.json")]
+ "/{id}/index.json")] public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id)
public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id, string lower)
{ {
bool askForindex = lower == null; var pkgs = packageManager.SearchById(id, null, null);
if (askForindex) if (pkgs == null) return NotFound();
{ return Ok(pkgs);
string sublower = lower.Substring(0, lower.Length - ApiConfig.IndexDotJson.Length); }
var pkgFromname = packageManager.SearchByName(id, 0, 1); [HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
if (pkgFromname == null) return NotFound(); public async Task<IActionResult> CatalogLeafAsync(string id, string pversion, string lower)
foreach (var item in pkgFromname.Items)
{ {
item.Id = this.Url.Action();
} bool askForindex = lower == null;
return Ok(pkgFromname); if (false)
}
else
{ {
if (!NuGetVersion.TryParse(lower, out NuGetVersion version)) if (!NuGetVersion.TryParse(lower, out NuGetVersion version))
return BadRequest(lower); return BadRequest(lower);
@ -50,12 +46,7 @@ namespace isnd.Controllers
if (pkgFromname == null) return NotFound(); if (pkgFromname == null) return NotFound();
return Ok(pkgFromname); return Ok(pkgFromname);
} }
} var pkgvs = this.packageManager.GetCatalogLeaf(id, pversion, lower).ToArray();
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
{
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower).ToArray();
if (pkgvs.Count() == 0) return NotFound(); if (pkgvs.Count() == 0) return NotFound();
List<string> types = pkgvs.Select( List<string> types = pkgvs.Select(
v => v.Type ?? "Dependency" v => v.Type ?? "Dependency"

@ -51,7 +51,7 @@ namespace isnd.Data.Packages
/// </summary> /// </summary>
/// <param name="bid">base url tu use for building the id property</param> /// <param name="bid">base url tu use for building the id property</param>
/// <returns></returns> /// <returns></returns>
internal RegistrationLeaf ToLeave(string bid) public RegistrationLeaf ToLeave(string bid)
{ {
if (Versions.Count == 0) throw new Exception("NO VERSION"); if (Versions.Count == 0) throw new Exception("NO VERSION");
var v = Versions.First(); var v = Versions.First();

@ -49,5 +49,6 @@ namespace isnd.Data
public string NuspecLink => $"/{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}." public string NuspecLink => $"/{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ Constants.SpecFileEstension; + Constants.SpecFileEstension;
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
} }
} }

@ -2,6 +2,10 @@ namespace isnd.Helpers
{ {
public static class SiteHelpers public static class SiteHelpers
{ {
/// <summary>
/// The Git Sementic version (from GitVersion.MsBuild)[published]
/// </summary>
/// <value></value>
public static string SemVer { public static string SemVer {
get => GitVersionInformation.SemVer; get => GitVersionInformation.SemVer;
} }

@ -24,9 +24,10 @@ namespace isnd.Interfaces
IEnumerable<Resource> GetResources(IUnleash unleashĈlient); IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
void ÛpdateCatalogFor(Commit commit); void ÛpdateCatalogFor(Commit commit);
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type); Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string uid, string id, string lower, string type); Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type); Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower); IEnumerable<PackageVersion> GetCatalogLeaf(string pkgId, string semver, string pkgType);
IEnumerable<RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType);
} }
} }

@ -323,13 +323,15 @@ namespace isnd.Services
); );
} }
public IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower) public IEnumerable<PackageVersion> GetCatalogLeaf(string pkgId, string semver, string pkgType)
{ {
return dbContext.PackageVersions return dbContext.PackageVersions
.Include(v => v.Package) .Include(v => v.Package)
.Include(v => v.LatestCommit) .Include(v => v.LatestCommit)
.Where(v => v.PackageId == id && v.FullString == version .Where(v => v.PackageId == pkgId
&& (lower == null || lower == v.Type)); && (semver == null ||
semver.StartsWith(v.SementicVersionString))
&& (pkgType == null || pkgType == v.Type));
} }
@ -344,5 +346,23 @@ namespace isnd.Services
if (packageVersion.Package.OwnerId != uid) return null; if (packageVersion.Package.OwnerId != uid) return null;
return new PackageDeletionReport { Deleted = true, DeletedVersion = packageVersion }; return new PackageDeletionReport { Deleted = true, DeletedVersion = packageVersion };
} }
public IEnumerable<Data.Catalog.RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType)
{
string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/";
return dbContext.PackageVersions
.Include(v => v.Package)
.Include(v => v.LatestCommit)
.Where(v => v.PackageId == pkgId && semver.StartsWith(v.SementicVersionString)
&& (pkgType == null || pkgType == v.Type)).Select(p => p.Package.ToLeave(bid));
}
public PackageVersion GetPackage(string pkgId, string semver, string pkgType)
{
return dbContext.PackageVersions
.Include(v => v.Package)
.Include(v => v.LatestCommit)
.Single(v => v.PackageId == pkgId && semver == v.FullString
&& (pkgType == null || pkgType == v.Type));
}
} }
} }

@ -1,45 +0,0 @@
using isnd.Data.Packages;
namespace isnd.ViewModels
{
public class RegistrationLeaf
{
/*
@id string yes The URL to the registration leaf
catalogEntry object yes The catalog entry containing the package metadata
packageContent string yes The URL to the package content (.nupkg)
*/
public static RegistrationLeaf FromPackage(Package p)
{
RegistrationLeaf v = new RegistrationLeaf
{
};
return v;
}
}
public class CatalogEntry
{
/*
@id string yes The URL to the document used to produce this object
authors string or array of strings no
dependencyGroups array of objects no The dependencies of the package, grouped by target framework
deprecation object no The deprecation associated with the package
description string no
iconUrl string no
id string yes The ID of the package
licenseUrl string no
licenseExpression string no
listed boolean no Should be considered as listed if absent
minClientVersion string no
projectUrl string no
published string no A string containing a ISO 8601 timestamp of when the package was published
requireLicenseAcceptance boolean no
summary string no
tags string or array of string no
title string no
version string yes The full version string after normalization
vulnerabilities array of objects no The security vulnerabilities of the package
*/
}
}

@ -17,9 +17,9 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="2.1.11" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="2.1.11" />
<PackageReference Include="Microsoft.AspNetCore.All" /> <PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="NuGet.Packaging.Core" Version="5.9.0" /> <PackageReference Include="NuGet.Packaging.Core" Version="5.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.30" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.30" />
<PackageReference Include="MailKit" Version="2.11.1" /> <PackageReference Include="MailKit" Version="2.8.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2" IncludeAssets="All" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2" IncludeAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.14" IncludeAssets="All" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.14" IncludeAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.10" IncludeAssets="All" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.10" IncludeAssets="All" />
@ -28,7 +28,7 @@
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*"> <PackageReference Include="GitVersion.MsBuild" Version="5.6.10*">
<PrivateAssets>All</PrivateAssets> <PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="5.0.0" /> <PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Loading…