From d3b96088abb70d1716bbc3f748df82d1d50a6fe6 Mon Sep 17 00:00:00 2001
From: Paul Schneider
Date: Tue, 25 Apr 2023 22:40:58 +0100
Subject: [PATCH] a better result
---
src/isn.abst/APIKO.cs | 11 ++++
src/isn.abst/ApiIndexViewModel.cs | 9 ++--
src/isn.abst/Constants.cs | 2 +-
src/isn.abst/HappyIdOwner.cs | 23 ++++++--
src/isn.abst/Resource.cs | 8 +--
src/isn/Program.cs | 3 --
src/isn/SourceHelpers.cs | 13 +++++
src/isn/UploadFilesToServerUsingHttpClient.cs | 31 +++--------
src/isn/commands/PushCommand.cs | 2 +-
src/isn/commands/push.cs | 1 -
.../{set-api-key.cs => store-api-key.cs} | 2 +-
src/isn/model/PushReport.cs | 30 +++++++----
src/isnd/Controllers/Packages/ApiIndex.cs | 2 +-
.../PackagesController.AutoComplete.cs | 2 +-
.../Packages/PackagesController.Catalog.cs | 8 +--
.../Packages/PackagesController.Delete.cs | 2 +-
.../Packages/PackagesController.GetPackage.cs | 4 +-
.../Packages/PackagesController.Put.cs | 26 +++++++--
.../Packages/PackagesController.Search.cs | 2 +-
.../Packages/PackagesController.WebViews.cs | 26 ++++-----
src/isnd/Data/Catalog/CatalogEntry.cs | 20 +------
...ionPageIndex.cs => PackageRegistration.cs} | 14 ++---
src/isnd/Data/Catalog/RegistratioinLeave.cs | 14 ++++-
src/isnd/Data/Catalog/RegistrationPage.cs | 42 ++++++++-------
.../Catalog/RegistrationPageIndexQuery.cs | 4 +-
.../{PackageRef.cs => PackageDetails.cs} | 4 +-
.../Data/Packages/Catalog/PackageEntry.cs | 12 +++++
src/isnd/Data/Packages/Catalog/Page.cs | 21 --------
src/isnd/Data/Packages/Package.cs | 2 +
src/isnd/Data/Packages/PackageVersion.cs | 20 +++----
src/isnd/Interfaces/IPackageManager.cs | 12 ++---
src/isnd/NSJWebApiReferenceResolver.cs | 14 ++---
src/isnd/Services/PackageManager.cs | 53 ++++++++++---------
src/isnd/ViewModels/PackageDetailViewModel.cs | 7 +--
.../RegistrationPageIndexQueryAndResult.cs | 4 +-
src/isnd/Views/Home/Index.cshtml | 1 +
src/isnd/Views/PackageVersion/Details.cshtml | 4 +-
src/isnd/Views/PackageVersion/Index.cshtml | 5 +-
src/isnd/Views/Packages/Details.cshtml | 4 +-
src/isnd/Views/Packages/Index.cshtml | 4 +-
src/isnd/Views/_ViewImports.cshtml | 2 +
src/isnd/WebApiReferenceResolver.cs | 14 ++---
test/data/test-isn/ANuGet.Config | 4 +-
test/data/test-isn/testcmd | 2 +-
test/data/test-isn/urls | 4 ++
test/isn.tests/PushTest.cs | 2 +-
test/isnd.tests/UnitTestWebHost.cs | 10 ++--
47 files changed, 268 insertions(+), 238 deletions(-)
create mode 100644 src/isn.abst/APIKO.cs
rename src/isn/commands/{set-api-key.cs => store-api-key.cs} (96%)
rename src/isnd/Data/Catalog/{RegistrationPageIndex.cs => PackageRegistration.cs} (70%)
rename src/isnd/Data/Packages/Catalog/{PackageRef.cs => PackageDetails.cs} (96%)
create mode 100644 src/isnd/Data/Packages/Catalog/PackageEntry.cs
delete mode 100644 src/isnd/Data/Packages/Catalog/Page.cs
create mode 100644 test/data/test-isn/urls
diff --git a/src/isn.abst/APIKO.cs b/src/isn.abst/APIKO.cs
new file mode 100644
index 0000000..530efd4
--- /dev/null
+++ b/src/isn.abst/APIKO.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+
+namespace isn
+{
+ public class APIKO
+ {
+ public string Context { get; set; }
+ public Dictionary Errors { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/isn.abst/ApiIndexViewModel.cs b/src/isn.abst/ApiIndexViewModel.cs
index a8e9709..2b5ce05 100644
--- a/src/isn.abst/ApiIndexViewModel.cs
+++ b/src/isn.abst/ApiIndexViewModel.cs
@@ -3,15 +3,12 @@ using Newtonsoft.Json;
namespace isn.Abstract
{
- public class ApiIndexViewModel : HappyIdOwner
+ public class ApiIndexViewModel : Permalink
{
- public ApiIndexViewModel(string id) : base(id)
+ public ApiIndexViewModel(string id) : base(id, "ApiIndex")
{
}
-
- [JsonProperty("@id")]
- public string Id { get => GetId(); }
-
+
[JsonProperty("version")]
public string Version { get; set; }
diff --git a/src/isn.abst/Constants.cs b/src/isn.abst/Constants.cs
index 2df9fa6..215d61b 100644
--- a/src/isn.abst/Constants.cs
+++ b/src/isn.abst/Constants.cs
@@ -4,6 +4,6 @@ namespace isn.abst
{
public const string PaquetFileEstension = "nupkg";
public const string SpecFileEstension = "nuspec";
- public const string ApiVersion = "/v3";
+ public const string ApiVersionPrefix = "/v3";
}
}
\ No newline at end of file
diff --git a/src/isn.abst/HappyIdOwner.cs b/src/isn.abst/HappyIdOwner.cs
index 253faac..1a1ed00 100644
--- a/src/isn.abst/HappyIdOwner.cs
+++ b/src/isn.abst/HappyIdOwner.cs
@@ -2,15 +2,28 @@ using Newtonsoft.Json;
namespace isnd.Data.Catalog
{
- public class HappyIdOwner
+ public abstract class Permalink
{
- public HappyIdOwner(string id)
+
+ public Permalink(string id, string type)
{
+ Type = type;
this.id = id;
}
+
+ public Permalink(string id)
+ {
+ Type = GetType().Name;
+ this.id = id;
+ }
+
+ [JsonProperty("@type")]
+ public virtual string Type { get; set; }
+
-
- private string id;
+ [JsonProperty("@id")]
+ public string Id { get => GetId(); }
+ private readonly string id;
public string GetId() { return id; }
@@ -20,7 +33,7 @@ namespace isnd.Data.Catalog
{
if (GetType().IsAssignableFrom(obj.GetType()))
{
- var rpobj = (HappyIdOwner) obj;
+ var rpobj = (Permalink) obj;
return this.id == rpobj.id;
}
}
diff --git a/src/isn.abst/Resource.cs b/src/isn.abst/Resource.cs
index ab069a5..c3ccafe 100644
--- a/src/isn.abst/Resource.cs
+++ b/src/isn.abst/Resource.cs
@@ -3,19 +3,13 @@ using Newtonsoft.Json;
namespace isn.Abstract
{
- public class Resource : HappyIdOwner
+ public class Resource : Permalink
{
public Resource(string id, string typename) : base(id)
{
Type = typename;
- Id = id;
}
- [JsonProperty("@id")]
- public string Id {get; set; }
-
- [JsonProperty("@type")]
- public string Type {get; set; }
[JsonProperty("comment")]
public string Comment {get; set; }
diff --git a/src/isn/Program.cs b/src/isn/Program.cs
index 20391a0..d57ef13 100644
--- a/src/isn/Program.cs
+++ b/src/isn/Program.cs
@@ -216,9 +216,6 @@ namespace isn
{
Console.WriteLine("isn version " + GitVersionInformation.AssemblySemFileVer);
}
-
-
-
return commandSet.Run(args);
}
diff --git a/src/isn/SourceHelpers.cs b/src/isn/SourceHelpers.cs
index ba8762b..2fba5ca 100644
--- a/src/isn/SourceHelpers.cs
+++ b/src/isn/SourceHelpers.cs
@@ -17,8 +17,21 @@ namespace isn
// var json = await client.GetStringAsync(new System.Uri(url));
Task.Run(async ()=> {
+ try {
var response = await client.GetStringAsync(url);
result = JsonConvert.DeserializeObject(response);
+
+ } catch (HttpRequestException ex)
+ {
+ if (ex.StatusCode==HttpStatusCode.NotFound)
+ {
+ Console.Error.WriteLine("Not found ... server's down ?");
+ }
+ else
+ {
+ Console.Error.WriteLine($"{ex.StatusCode} : {ex.Message}");
+ }
+ }
}).Wait();
return result;
diff --git a/src/isn/UploadFilesToServerUsingHttpClient.cs b/src/isn/UploadFilesToServerUsingHttpClient.cs
index ce51297..b357580 100644
--- a/src/isn/UploadFilesToServerUsingHttpClient.cs
+++ b/src/isn/UploadFilesToServerUsingHttpClient.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
+using Newtonsoft.Json;
namespace isn
{
@@ -24,35 +25,19 @@ namespace isn
using (var multipartFormDataContent = new MultipartFormDataContent())
{
- /* var values = new[]
- {
- new KeyValuePair("Id", Guid.NewGuid().ToString()),
- new KeyValuePair("Key", "awesome"),
- new KeyValuePair("From", "khalid@home.com")
- //other values
- };foreach (var keyValuePair in values)
- {
- multipartFormDataContent.Add(new StringContent(keyValuePair.Value),
- String.Format("\"{0}\"", keyValuePair.Key));
- } */
multipartFormDataContent.Add(new ByteArrayContent(File.ReadAllBytes(fi.FullName)),
'"' + "File" + '"',
'"' + fi.Name + '"');
var result = await client.PutAsync(uri, multipartFormDataContent);
-
- if (result.IsSuccessStatusCode)
- {
- string report = await result.Content.ReadAsStringAsync();
- Console.WriteLine(report);
-
- }
+ if (result.IsSuccessStatusCode) return
+ new PushReport() {
+ KO = JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync())
+ };
else
- {
- string ereport = await result.Content.ReadAsStringAsync();
- Console.WriteLine(ereport);
- }
- return new PushReport();
+ return new PushReport() {
+ OK = true
+ };
}
}
}
diff --git a/src/isn/commands/PushCommand.cs b/src/isn/commands/PushCommand.cs
index e593a0a..7d64f66 100644
--- a/src/isn/commands/PushCommand.cs
+++ b/src/isn/commands/PushCommand.cs
@@ -21,6 +21,7 @@ namespace isn
{
var resources = SourceHelpers.GetServerResources(source);
+ if (resources == null) return null;
if (resources.Resources == null)
throw new InvalidOperationException("source gave no resource");
if (!resources.Resources.Any(res => res.Type == "PackagePublish/2.0.0"))
@@ -39,7 +40,6 @@ namespace isn
using (var client = new HttpClient())
try
{
- Console.WriteLine("Connecting to "+ pubRes.Id);
return client.UploadFilesToServer(new Uri(pubRes.Id), fi, settings.Sources[source].GetClearApiKey());
}
catch (HttpRequestException hrex)
diff --git a/src/isn/commands/push.cs b/src/isn/commands/push.cs
index 4e84e0d..5f40156 100644
--- a/src/isn/commands/push.cs
+++ b/src/isn/commands/push.cs
@@ -19,7 +19,6 @@ namespace isn
foreach (string pkg in pkgs)
{
var report = cmd.Run(pkg, CurrentSource, apiKey);
- Console.WriteLine(report.ToDoc());
pushReports.Add(report);
}
return pushReports;
diff --git a/src/isn/commands/set-api-key.cs b/src/isn/commands/store-api-key.cs
similarity index 96%
rename from src/isn/commands/set-api-key.cs
rename to src/isn/commands/store-api-key.cs
index 09ffca8..33231f6 100644
--- a/src/isn/commands/set-api-key.cs
+++ b/src/isn/commands/store-api-key.cs
@@ -40,7 +40,7 @@ namespace isn
Settings,
Formatting.Indented
));
-
+ Console.WriteLine("config saved .");
}
}
}
\ No newline at end of file
diff --git a/src/isn/model/PushReport.cs b/src/isn/model/PushReport.cs
index d8e082e..a42b7a6 100644
--- a/src/isn/model/PushReport.cs
+++ b/src/isn/model/PushReport.cs
@@ -1,29 +1,41 @@
+using System.Threading.Tasks.Dataflow;
using System.Net;
using System.Text;
+using Newtonsoft.Json;
namespace isn
{
public class PushReport
{
+ public PushReport()
+ {
+
+
+ }
+
public string PkgName { get; set; }
- public bool Executed { get; internal set; }
- public bool OK { get; internal set; }
- public bool AlreadyPresent { get; internal set; }
- public string Message { get; internal set; }
- public string StatusCode { get; internal set; }
- public string StackTrace { get; internal set; }
+ public bool Executed { get; set; }
+ public bool OK { get; set; }
+ public bool AlreadyPresent { get; set; }
+ public string Message { get; set; }
+ public string StatusCode { get; set; }
+ public string StackTrace { get; set; }
+ public APIKO KO { get; set; }
public string ToDoc()
{
- StringBuilder sb = new StringBuilder($"= Pushing {PkgName}\n\n");
+ StringBuilder sb = new StringBuilder($"= push {PkgName}\n\n");
if (Executed) sb.AppendLine("* Executed");
if (OK) sb.AppendLine("* OK");
if (!string.IsNullOrWhiteSpace(Message))
- sb.AppendLine(Message);
+ sb.AppendLine("* Message :" + Message);
if (!string.IsNullOrWhiteSpace(StatusCode))
sb.AppendLine($"* Status Code : ");
if (!string.IsNullOrWhiteSpace(StackTrace))
- sb.AppendLine($"* StackTrace : ");
+ sb.AppendLine($"* StackTrace : " + StackTrace);
+ if (KO!=null)
+ sb.AppendLine($"* KO : " + KO.Context);
+
return sb.ToString();
}
}
diff --git a/src/isnd/Controllers/Packages/ApiIndex.cs b/src/isnd/Controllers/Packages/ApiIndex.cs
index 003479a..0c23c08 100644
--- a/src/isnd/Controllers/Packages/ApiIndex.cs
+++ b/src/isnd/Controllers/Packages/ApiIndex.cs
@@ -33,7 +33,7 @@ namespace isnd.Controllers
/// API index
///
///
- [HttpGet("~" + Constants.ApiVersion + "/index")]
+ [HttpGet("~" + Constants.ApiVersionPrefix + "/index")]
public IActionResult ApiIndex()
{
return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl){ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
diff --git a/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs b/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs
index 7276542..f03eba5 100644
--- a/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs
@@ -9,7 +9,7 @@ namespace isnd.Controllers
{
// GET /autocomplete?id=isn.protocol&prerelease=true
- [HttpGet("~" + Constants.ApiVersion + ApiConfig.AutoComplete)]
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.AutoComplete)]
public IActionResult AutoComplete(
string id,
string semVerLevel,
diff --git a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
index 33c5eec..f3c4488 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
@@ -16,19 +16,19 @@ namespace isnd.Controllers
{
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
- [HttpGet("~" + Constants.ApiVersion + ApiConfig.Catalog)]
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Catalog)]
public async Task CatalogIndex()
{
return Ok(await packageManager.GetCatalogIndexAsync());
}
- [HttpGet("~" + Constants.ApiVersion + ApiConfig.Registration + "/{id}/{version?}")]
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Registration + "/{id}/{version}.json")]
public async Task CatalogRegistration(string id, string version)
{
- if (string.IsNullOrWhiteSpace(version))
+ if ("index" == version)
{
- var query = new Data.Catalog.RegistrationPageIndexQuery
+ var query = new Data.Catalog.PackageRegistrationQuery
{
Query = id,
Prerelease = true
diff --git a/src/isnd/Controllers/Packages/PackagesController.Delete.cs b/src/isnd/Controllers/Packages/PackagesController.Delete.cs
index 0b5ea62..ab43748 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Delete.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Delete.cs
@@ -11,7 +11,7 @@ namespace isnd.Controllers
{
public partial class PackagesController
{
- [HttpDelete("~" + Constants.ApiVersion + ApiConfig.Package + "/{id}/{lower?}/{type?}")]
+ [HttpDelete("~" + Constants.ApiVersionPrefix + ApiConfig.Package + "/{id}/{lower?}/{type?}")]
public async Task ApiDelete(
[FromRoute][SafeName][Required] string id,
[FromRoute][SafeName][Required] string lower,
diff --git a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs
index a37ad28..e4cea10 100644
--- a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs
@@ -11,7 +11,7 @@ namespace isnd.Controllers
public partial class PackagesController
{
// Web get the paquet
- [HttpGet("~" + Constants.ApiVersion + ApiConfig.Package + "/{id}/{lower}/{idf}-{lowerf}."
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuget + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.PaquetFileEstension)]
public IActionResult GetPackage(
[FromRoute][SafeName][Required] string id,
@@ -32,7 +32,7 @@ namespace isnd.Controllers
}
// Web get spec
- [HttpGet("~" + Constants.ApiVersion + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuspec + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.SpecFileEstension)]
public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id,
diff --git a/src/isnd/Controllers/Packages/PackagesController.Put.cs b/src/isnd/Controllers/Packages/PackagesController.Put.cs
index 2c216ff..512ae42 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Put.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Put.cs
@@ -1,3 +1,4 @@
+using System.Linq.Expressions;
using System;
using System.Collections.Generic;
@@ -18,14 +19,18 @@ using Microsoft.AspNetCore.Http;
using isn.abst;
using isnd.Data.Packages;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using isn;
namespace isnd.Controllers
{
public partial class PackagesController
{
- // TODO [Authorize(Policy = IsndConstants.RequireValidApiKey)]
- [HttpPut("~" + Constants.ApiVersion + ApiConfig.Package)]
+
+
+ // TODO [Authorize(Policy = IsndConstants.RequireValidApiKey)]
+ [HttpPut("~" + Constants.ApiVersionPrefix + ApiConfig.Package)]
public async Task Put()
{
try
@@ -130,7 +135,7 @@ namespace isnd.Controllers
else {
logger.LogWarning("400 : pkgversion:existant");
ModelState.AddModelError("pkgversion", "existant" );
- return BadRequest(ModelState);
+ return BadRequest(CreateAPIKO("existant", ModelState));
}
}
{
@@ -206,9 +211,8 @@ namespace isnd.Controllers
nfpi.Delete();
spec.ExtractToFile(nuspecfullpath);
}
-
}
- return Ok(ViewData);
+ return Ok();
}
catch (Exception ex)
{
@@ -218,5 +222,17 @@ namespace isnd.Controllers
{ StatusCode = 500 };
}
}
+
+ public APIKO CreateAPIKO(string context, ModelStateDictionary modelState)
+ {
+ Dictionary errors = new();
+
+ foreach (var elt in modelState)
+ {
+ errors[elt.Key] = elt.Value.Errors.Select( e => e.ErrorMessage).ToArray();
+ }
+ return new APIKO{ Context = context, Errors = errors };
+ }
+
}
}
diff --git a/src/isnd/Controllers/Packages/PackagesController.Search.cs b/src/isnd/Controllers/Packages/PackagesController.Search.cs
index bffc995..907d63a 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Search.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Search.cs
@@ -11,7 +11,7 @@ namespace isnd.Controllers
public partial class PackagesController
{
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
- [HttpGet("~" + Constants.ApiVersion + ApiConfig.Search)]
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Search)]
public IActionResult Search(
string q,
int skip = 0,
diff --git a/src/isnd/Controllers/Packages/PackagesController.WebViews.cs b/src/isnd/Controllers/Packages/PackagesController.WebViews.cs
index eb6c477..2f67281 100644
--- a/src/isnd/Controllers/Packages/PackagesController.WebViews.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.WebViews.cs
@@ -1,6 +1,7 @@
-using System;
+
using System.Linq;
using System.Threading.Tasks;
+using isn.abst;
using isnd.Data;
using isnd.Data.Catalog;
using isnd.Helpers;
@@ -15,22 +16,22 @@ namespace isnd.Controllers
public partial class PackagesController
{
// Web search
- public async Task Index(RegistrationPageIndexQuery model)
+ public async Task Index(PackageRegistrationQuery model)
{
return View(new RegistrationPageIndexQueryAndResult{Query = model,
Result = await packageManager.SearchPackageAsync(model)});
}
- public async Task Details(string pkgid)
+ public async Task Details(PackageDetailViewModel model)
{
- if (pkgid == null)
+ if (model.pkgid == null)
{
return NotFound();
}
var packageVersion = dbContext.PackageVersions
.Include(p => p.Package)
- .Where(m => m.PackageId == pkgid)
+ .Where(m => m.PackageId == model.pkgid)
.OrderByDescending(p => p)
;
@@ -39,17 +40,11 @@ namespace isnd.Controllers
return NotFound();
}
bool results = await packageVersion.AnyAsync();
- var latest = await packageVersion.FirstAsync();
-
- return View("Details", new PackageDetailViewModel
- {
- ExternalUrl = isndSettings.ExternalUrl,
- latest = latest,
- pkgid = pkgid,
- totalHits = packageVersion.Count(),
- data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray()
- });
+ model.latest = await packageVersion.FirstAsync();
+ model.totalHits = packageVersion.Count();
+ model.data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray();
+ return View("Details", model);
}
const int MAX_PKG_VERSION_LIST = 50;
@@ -60,7 +55,6 @@ namespace isnd.Controllers
{
return NotFound();
}
- // var report = await packageManager.DeletePackageAsync(id, lower, type);
var packageVersion = await dbContext.PackageVersions.Include(p => p.Package)
.FirstOrDefaultAsync(m => m.PackageId == pkgid
diff --git a/src/isnd/Data/Catalog/CatalogEntry.cs b/src/isnd/Data/Catalog/CatalogEntry.cs
index f99964e..0067936 100644
--- a/src/isnd/Data/Catalog/CatalogEntry.cs
+++ b/src/isnd/Data/Catalog/CatalogEntry.cs
@@ -9,7 +9,7 @@ using isnd.Interfaces;
namespace isnd.Data.Catalog
{
- public class CatalogEntry : HappyIdOwner , IObject// , IPackageDetails
+ public class CatalogEntry : Permalink, IObject// , IPackageDetails
{
///
/// Creates a catalog entry
@@ -20,25 +20,10 @@ namespace isnd.Data.Catalog
{
}
- ///
- /// The ID of the package
- ///
- ///
-
- [JsonProperty("id")]
- public string Id { get; set; }
-
- ///
- /// The Package details url
- ///
- ///
-
- [JsonProperty("@id")]
- public string refid { get => GetId(); }
[JsonProperty("@type")]
- public string[] RefType { get; protected set; } = new string[] { "PackageDetail" };
+ public string[] RefType { get; protected set; } = new string[] { "PackageDetails" };
[JsonProperty("commitId")]
public string CommitId { get; set; }
@@ -98,7 +83,6 @@ namespace isnd.Data.Catalog
public Vulnerabilitie[] vulnerabilities { get; set; }
public string packageContent { get; set; }
-
///
/// A string containing a ISO 8601 timestamp of when the package was published
diff --git a/src/isnd/Data/Catalog/RegistrationPageIndex.cs b/src/isnd/Data/Catalog/PackageRegistration.cs
similarity index 70%
rename from src/isnd/Data/Catalog/RegistrationPageIndex.cs
rename to src/isnd/Data/Catalog/PackageRegistration.cs
index 00b10c2..e6f5f05 100644
--- a/src/isnd/Data/Catalog/RegistrationPageIndex.cs
+++ b/src/isnd/Data/Catalog/PackageRegistration.cs
@@ -6,17 +6,17 @@ using System.Linq;
namespace isnd.Data.Catalog
{
- public class RegistrationPageIndex : HappyIdOwner
+ public class PackageRegistration : Permalink
{
- public RegistrationPageIndex(string url) : base(url)
+ public PackageRegistration(string url) : base(url)
{
- Items = new List();
+ Items = new List();
}
- public RegistrationPageIndex(string bid, string id, string extUrl, IEnumerable pkgs) : base(bid + $"/{id}/index.json")
+ public PackageRegistration(string bid, string id, string apiBase, IEnumerable pkgs) : base(bid + $"/{id}/index.json")
{
- Items = new List();
+ Items = new List();
long cnid = 0;
var pkgsGroups = pkgs.GroupBy(l => l.Id);
// Pour tous les groupes par Id
@@ -36,7 +36,7 @@ namespace isnd.Data.Catalog
}
}
}
- Items.Add(new RegistrationPage(bid, gsp.Key, extUrl, versions));
+ Items.Add(new CatalogPage(bid, gsp.Key, apiBase, versions));
}
CommitId = cnid.ToString();
}
@@ -45,7 +45,7 @@ namespace isnd.Data.Catalog
public int Count { get => Items.Count; }
[JsonProperty("items")]
- public List Items { get; set; }
+ public List Items { get; set; }
public string CommitId { get; set; }
public DateTimeOffset CommitTimeStamp { get; internal set; }
diff --git a/src/isnd/Data/Catalog/RegistratioinLeave.cs b/src/isnd/Data/Catalog/RegistratioinLeave.cs
index 1248175..c604cbb 100644
--- a/src/isnd/Data/Catalog/RegistratioinLeave.cs
+++ b/src/isnd/Data/Catalog/RegistratioinLeave.cs
@@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations;
+using isnd.Entities;
using Newtonsoft.Json;
+using isn.abst;
namespace isnd.Data.Catalog
{
@@ -7,8 +9,16 @@ namespace isnd.Data.Catalog
/// Hosts a catalog entry,
/// the atomic content reference
///
- public class RegistrationLeaf
+ public class Package
{
+ public Package(string apiBase, string pkgId, string fullVersionString, CatalogEntry entry)
+ {
+ this.registration = apiBase + ApiConfig.Registration + "/" + pkgId + "/index.json";
+ this.PackageContent = apiBase + ApiConfig.Nuget + "/" + pkgId + "/" + fullVersionString
+ + "/" + pkgId + "-" + fullVersionString + "." + Constants.PaquetFileEstension;
+ Entry = entry;
+ }
+
/*
@id string yes
catalogEntry object yes
@@ -36,5 +46,7 @@ namespace isnd.Data.Catalog
///
[JsonProperty("packageContent")]
public string PackageContent { get; set; }
+
+ public string registration { get; set; }
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Catalog/RegistrationPage.cs b/src/isnd/Data/Catalog/RegistrationPage.cs
index a341454..5785916 100644
--- a/src/isnd/Data/Catalog/RegistrationPage.cs
+++ b/src/isnd/Data/Catalog/RegistrationPage.cs
@@ -7,26 +7,23 @@ using NuGet.Versioning;
namespace isnd.Data.Catalog
{
- public class RegistrationPage : HappyIdOwner
+ public class CatalogPage : Permalink
{
- [JsonProperty("@id")]
- public string Id { get => GetId(); }
private readonly string pkgid;
- private readonly List items;
+ private readonly List items;
- protected string Bid { get ; private set; }
- protected string ExternalUrl { get; }
+ private readonly string apiBase;
- public RegistrationPage (string bid, string pkgid, string extUrl) : base(bid + "/" + pkgid + "/index.json")
+
+ public CatalogPage (string pkgid, string apiBase) : base(apiBase + $"/registration/{pkgid}/index.json")
{
- Bid = bid;
- Parent = Bid + $"/{pkgid}/index.json";
- ExternalUrl = extUrl;
- this.items = new List();
+ Parent = apiBase + $"/registration/{pkgid}/index.json";
+ this.items = new List();
this.pkgid = pkgid;
+ this.apiBase = apiBase;
}
- public RegistrationPage(string bid, string pkgid, string extUrl, List versions) : this(bid, pkgid, extUrl)
+ public CatalogPage(string bid, string pkgid, string apiBase, List versions) : this(pkgid, apiBase)
{
AddVersionRange(versions);
}
@@ -42,13 +39,14 @@ namespace isnd.Data.Catalog
///
[JsonProperty("items")]
- public CatalogEntry[] Items { get => items.Select((p) => p.ToLeave(Bid, ExternalUrl)).ToArray(); }
+ public Package[] Items { get => items.ToArray(); }
public void AddVersionRange(IEnumerable vitems)
{
if (vitems.Count() == 0) return;
NuGetVersion upper = null;
NuGetVersion lower = null;
+ PackageVersion latest = null;
if (Lower!=null) lower = new NuGetVersion(Lower);
if (Upper!=null) upper = new NuGetVersion(Upper);
@@ -56,7 +54,8 @@ namespace isnd.Data.Catalog
long commitMax = 0;
foreach (var p in vitems)
{
- if (items.Contains(p)) continue;
+ var pkg = p.ToPackage(apiBase);
+ if (items.Contains(pkg)) continue;
if (upper == null) upper = p.NugetVersion;
else if ( upper < p.NugetVersion) upper = p.NugetVersion;
@@ -64,12 +63,19 @@ namespace isnd.Data.Catalog
if (lower == null) lower = p.NugetVersion;
else if (lower > p.NugetVersion) lower = p.NugetVersion;
- if (p.CommitNId > commitMax) commitMax = p.CommitNId;
- items.Add(p);
+ if (p.CommitNId > commitMax)
+ {
+ latest = p;
+ }
+ items.Add(pkg);
}
Upper = upper.ToFullString();
Lower = lower.ToFullString();
- CommitId = commitMax.ToString();
+ if (latest != null)
+ {
+ CommitId = latest.CommitId;
+ CommitTimeStamp = latest.LatestCommit.CommitTimeStamp;
+ }
}
///
@@ -95,6 +101,6 @@ namespace isnd.Data.Catalog
[JsonProperty("count")]
public int Count { get => items.Count; }
public string CommitId { get; internal set; }
- public DateTime CommitTimeStamp { get; internal set; }
+ public DateTimeOffset CommitTimeStamp { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Catalog/RegistrationPageIndexQuery.cs b/src/isnd/Data/Catalog/RegistrationPageIndexQuery.cs
index 33d5696..75414dc 100644
--- a/src/isnd/Data/Catalog/RegistrationPageIndexQuery.cs
+++ b/src/isnd/Data/Catalog/RegistrationPageIndexQuery.cs
@@ -4,9 +4,9 @@ using Newtonsoft.Json;
namespace isnd.Data.Catalog
{
- public class RegistrationPageIndexQuery
+ public class PackageRegistrationQuery
{
- public RegistrationPageIndexQuery()
+ public PackageRegistrationQuery()
{
}
diff --git a/src/isnd/Data/Packages/Catalog/PackageRef.cs b/src/isnd/Data/Packages/Catalog/PackageDetails.cs
similarity index 96%
rename from src/isnd/Data/Packages/Catalog/PackageRef.cs
rename to src/isnd/Data/Packages/Catalog/PackageDetails.cs
index 7af2bbc..f5de553 100644
--- a/src/isnd/Data/Packages/Catalog/PackageRef.cs
+++ b/src/isnd/Data/Packages/Catalog/PackageDetails.cs
@@ -10,10 +10,9 @@ namespace isnd.Data.Packages.Catalog
/// for availability, or deletion,
///
///
- public class PackageRef : IObject
+ public class PackageDetails : IObject
{
-
[JsonProperty("@id")]
public string RefId { get; set; }
@@ -48,5 +47,6 @@ namespace isnd.Data.Packages.Catalog
[JsonProperty("commitTimeStamp")]
public DateTimeOffset CommitTimeStamp { get; set; }
+
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Packages/Catalog/PackageEntry.cs b/src/isnd/Data/Packages/Catalog/PackageEntry.cs
new file mode 100644
index 0000000..81182af
--- /dev/null
+++ b/src/isnd/Data/Packages/Catalog/PackageEntry.cs
@@ -0,0 +1,12 @@
+using System;
+using isnd.Interfaces;
+
+namespace isnd.Data.Packages.Catalog
+{
+ public class PackageEntry : IObject
+ {
+ public string CommitId => throw new NotImplementedException();
+
+ public DateTimeOffset CommitTimeStamp => throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/src/isnd/Data/Packages/Catalog/Page.cs b/src/isnd/Data/Packages/Catalog/Page.cs
deleted file mode 100644
index 2a43f9a..0000000
--- a/src/isnd/Data/Packages/Catalog/Page.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using isnd.Interfaces;
-using Newtonsoft.Json;
-
-namespace isnd.Data.Packages.Catalog
-{
- public class Page : IObject
- {
- [JsonProperty("@id")]
- public string Id { get; set; }
-
- [JsonProperty("parent")]
- public string Parent { get; set; }
-
- [JsonProperty("items")]
- public virtual List Items { get; set; }
- public string CommitId { get; set; }
- public DateTimeOffset CommitTimeStamp { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/isnd/Data/Packages/Package.cs b/src/isnd/Data/Packages/Package.cs
index d376908..21e37ee 100644
--- a/src/isnd/Data/Packages/Package.cs
+++ b/src/isnd/Data/Packages/Package.cs
@@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using isnd.Data.Catalog;
+using isnd.Data.Packages.Catalog;
using isnd.Interfaces;
using Newtonsoft.Json;
@@ -62,5 +63,6 @@ namespace isnd.Data.Packages
public virtual Commit LatestVersion { get; set; }
public DateTimeOffset CommitTimeStamp { get; set; }
+
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Packages/PackageVersion.cs b/src/isnd/Data/Packages/PackageVersion.cs
index 9120d93..ceccc16 100644
--- a/src/isnd/Data/Packages/PackageVersion.cs
+++ b/src/isnd/Data/Packages/PackageVersion.cs
@@ -5,13 +5,12 @@ using isn.abst;
using isnd.Data.Catalog;
using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
+using isnd.Entities;
using Newtonsoft.Json;
using NuGet.Versioning;
namespace isnd.Data
{
-
-
public class PackageVersion
{
[Required]
@@ -46,7 +45,7 @@ namespace isnd.Data
public string Type { get; set; }
[JsonIgnore]
- public virtual Package Package { get; set; }
+ public virtual Packages.Package Package { get; set; }
[Required]
[JsonIgnore]
@@ -58,23 +57,24 @@ namespace isnd.Data
public string CommitId { get => CommitNId.ToString(); }
public virtual Commit LatestCommit { get; set; }
- public string NugetLink => $"{Constants.PaquetFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ public string NugetLink => $"{ApiConfig.Nuget}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ Constants.PaquetFileEstension;
- public string NuspecLink => $"{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ public string NuspecLink => $"{ApiConfig.Nuspec}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ Constants.SpecFileEstension;
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
public NuGetVersion NugetVersion { get => new NuGetVersion(FullString); }
- public CatalogEntry ToLeave(string bid, string extUrl)
+ public Catalog.Package ToPackage(string apiBase)
{
- return new CatalogEntry(bid + "/" + this.PackageId + "/" + FullString + ".json")
+ return new Catalog.Package(apiBase ,this.PackageId , FullString,
+ new CatalogEntry(apiBase + ApiConfig.Registration + "/" + this.PackageId + "/" + FullString + ".json")
{
- Id = PackageId,
Version = FullString,
authors = $"{this.Package.Owner.FullName} <${Package.Owner.Email}>",
- packageContent = extUrl + this.NugetLink
- };
+ packageContent = apiBase + this.NugetLink
+ }
+ );
}
}
}
\ No newline at end of file
diff --git a/src/isnd/Interfaces/IPackageManager.cs b/src/isnd/Interfaces/IPackageManager.cs
index 8e5c2b2..7410d2a 100644
--- a/src/isnd/Interfaces/IPackageManager.cs
+++ b/src/isnd/Interfaces/IPackageManager.cs
@@ -20,17 +20,17 @@ namespace isnd.Interfaces
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
IEnumerable GetResources(IUnleash unleashĈlient);
- Task ÛpdateCatalogForAsync(Commit commit);
+ Task ÛpdateCatalogForAsync(Commit commit);
Task DeletePackageAsync(string pkgid, string version, string type);
Task UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
Task GetPackageAsync(string pkgid, string version, string type);
- Task GetCatalogEntryAsync(string pkgId, string version, string pkgType);
- IEnumerable SearchCatalogEntriesById(string pkgId, string semver, string pkgType);
+ Task GetCatalogEntryAsync(string pkgId, string version, string pkgType);
+ IEnumerable SearchCatalogEntriesById(string pkgId, string semver, string pkgType);
- Task GetCatalogIndexAsync();
- Task GetPackageRegistrationIndexAsync(RegistrationPageIndexQuery query);
+ Task GetCatalogIndexAsync();
+ Task GetPackageRegistrationIndexAsync(PackageRegistrationQuery query);
- Task SearchPackageAsync(RegistrationPageIndexQuery query);
+ Task SearchPackageAsync(PackageRegistrationQuery query);
}
}
\ No newline at end of file
diff --git a/src/isnd/NSJWebApiReferenceResolver.cs b/src/isnd/NSJWebApiReferenceResolver.cs
index 3e6a884..07d4bb7 100644
--- a/src/isnd/NSJWebApiReferenceResolver.cs
+++ b/src/isnd/NSJWebApiReferenceResolver.cs
@@ -9,26 +9,26 @@ namespace isnd
{
private int delautIdCounter;
- Dictionary HappyIdOwners { get; set; }
+ Dictionary HappyIdOwners { get; set; }
Dictionary Objects {get; set;}
internal NSJWebApiReferenceResolver()
{
delautIdCounter = 0;
- HappyIdOwners = new Dictionary();
+ HappyIdOwners = new Dictionary();
Objects = new Dictionary();
}
public void AddReference(object context, string reference, object value)
{
- if (value is HappyIdOwner)
+ if (value is Permalink)
{
- string hoi = (value as HappyIdOwner).GetId();
+ string hoi = (value as Permalink).GetId();
if (HappyIdOwners.ContainsKey(hoi))
{
return;
}
- HappyIdOwners[hoi] = value as HappyIdOwner;
+ HappyIdOwners[hoi] = value as Permalink;
}
else
{
@@ -45,9 +45,9 @@ namespace isnd
public string GetReference(object context, object value)
{
bool alreadyExists;
- if (value is HappyIdOwner)
+ if (value is Permalink)
{
- string oid = (value as HappyIdOwner).GetId();
+ string oid = (value as Permalink).GetId();
if (oid == null)
throw new System.Exception("HappyIdOwner Id property is null");
if (HappyIdOwners.ContainsKey(oid))
diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs
index 99fa5dd..020141d 100644
--- a/src/isnd/Services/PackageManager.cs
+++ b/src/isnd/Services/PackageManager.cs
@@ -27,7 +27,7 @@ namespace isnd.Services
{
this.dbContext = dbContext;
isndSettings = siteConfigOptionsOptions.Value;
- apiBase = isndSettings.ExternalUrl + Constants.ApiVersion;
+ apiBase = isndSettings.ExternalUrl + Constants.ApiVersionPrefix;
}
public IEnumerable GetResources(IUnleash unleashClient)
@@ -126,19 +126,19 @@ namespace isnd.Services
private IsndSettings isndSettings;
private readonly string apiBase;
- public virtual async Task GetCatalogIndexAsync()
+ public virtual async Task GetCatalogIndexAsync()
{
return await ÛpdateCatalogForAsync(null);
}
- public async Task ÛpdateCatalogForAsync
+ public async Task ÛpdateCatalogForAsync
(Commit reason = null)
{
int i = 0;
string baseid = apiBase + ApiConfig.Catalog;
- string bidreg = $"{apiBase}v3.4.0/{ApiConfig.Registration}";
- RegistrationPageIndex index = new RegistrationPageIndex(baseid);
+ string bidreg = $"{apiBase}{ApiConfig.Registration}";
+ PackageRegistration index = new PackageRegistration(baseid);
var scope = await dbContext.Commits.OrderBy(c => c.TimeStamp).ToArrayAsync();
@@ -157,11 +157,11 @@ namespace isnd.Services
foreach (var pkgid in validPkgs)
{
- RegistrationPage page = index.Items.FirstOrDefault
+ CatalogPage page = index.Items.FirstOrDefault
(p => p.GetPackageId() == pkgid.Key);
if (page == null)
{
- page = new RegistrationPage(bidreg, pkgid.Key, apiBase);
+ page = new CatalogPage(pkgid.Key, apiBase);
index.Items.Add(page);
}
@@ -222,15 +222,13 @@ namespace isnd.Services
);
}
- public async Task GetCatalogEntryAsync
+ public async Task GetCatalogEntryAsync
(string pkgId, string semver = null, string pkgType = null)
{
return (await dbContext.PackageVersions
- .Include(v => v.Package)
- .Include(v => v.LatestCommit)
- .Where(v => v.PackageId == pkgId
- && semver == v.SementicVersionString
- && (pkgType == null || pkgType == v.Type)).SingleOrDefaultAsync()).ToLeave(BID,
+ .Include(v => v.Package).Include(v => v.Package.Owner)
+ .Where(v => v.PackageId == pkgId
+ && v.FullString == semver).SingleOrDefaultAsync()).ToPackage(
apiBase);
}
@@ -246,9 +244,8 @@ namespace isnd.Services
return new PackageDeletionReport { Deleted = true, DeletedVersion = packageVersion };
}
- public string BID { get => $"{apiBase}v3.4.0/{ApiConfig.Registration}"; }
- public IEnumerable SearchCatalogEntriesById
+ public IEnumerable SearchCatalogEntriesById
(string pkgId, string semver, string pkgType)
{
@@ -259,7 +256,7 @@ namespace isnd.Services
.Where(v => v.PackageId == pkgId && semver == v.FullString
&& (pkgType == null || pkgType == v.Type))
.OrderByDescending(p => p.CommitNId)
- .Select(p => p.ToLeave(BID, apiBase))
+ .Select(p => p.ToPackage(apiBase))
;
}
public PackageVersion GetPackage(string pkgId, string semver, string pkgType)
@@ -271,25 +268,29 @@ namespace isnd.Services
&& (pkgType == null || pkgType == v.Type));
}
- public async Task GetPackageRegistrationIndexAsync
- (RegistrationPageIndexQuery query)
+ public async Task GetPackageRegistrationIndexAsync
+ (PackageRegistrationQuery query)
{
// RegistrationPageIndexAndQuery
if (string.IsNullOrWhiteSpace(query.Query)) return null;
query.Query = query.Query.ToLower();
var scope = await dbContext.Packages.Include(p => p.Versions).Include(p => p.Owner)
+ .Include(p=>p.LatestVersion)
.Where(p => p.Id.ToLower() == query.Query).Skip(query.Skip).Take(query.Take).ToListAsync();
- string bid = $"{apiBase}v3.4.0/{ApiConfig.Registration}";
+ string bid = $"{apiBase}{ApiConfig.Registration}";
return
- new RegistrationPageIndex(bid, query.Query, apiBase, scope);
+ new PackageRegistration(bid, query.Query, apiBase, scope);
}
- public async Task SearchPackageAsync(RegistrationPageIndexQuery query)
+ public async Task SearchPackageAsync(PackageRegistrationQuery query)
{
- string bid = $"{apiBase}v3.4.0/{ApiConfig.Registration}";
+ string bid = $"{apiBase}{ApiConfig.Registration}";
if (query.Query == null) query.Query = "";
- var scope = (await dbContext.Packages.Include(p => p.Versions).Include(p => p.Owner)
+ var scope = (await dbContext.Packages
+ .Include(p => p.Versions)
+ .Include(p => p.Owner)
+ .Include(p=>p.LatestVersion)
.ToListAsync())
.Where(p => Matching(p, query))
;
@@ -297,17 +298,17 @@ namespace isnd.Services
var pkgs = scope.Skip(query.Skip).Take(query.Take);
return
- new RegistrationPageIndex(bid, query.Query, apiBase, pkgs);
+ new PackageRegistration(bid, query.Query, apiBase, pkgs);
}
- private static bool MatchingExact(Package p, RegistrationPageIndexQuery query)
+ private static bool MatchingExact(Data.Packages.Package p, PackageRegistrationQuery query)
{
return
p.Id == query.Query
&& (query.Prerelease || p.Versions.Any(v => !v.IsPrerelease));
}
- private static bool Matching(Package p, RegistrationPageIndexQuery query)
+ private static bool Matching(Data.Packages.Package p, PackageRegistrationQuery query)
{
return p.Id.StartsWith(query.Query)
&& (query.Prerelease || p.Versions.Any(v => !v.IsPrerelease));
diff --git a/src/isnd/ViewModels/PackageDetailViewModel.cs b/src/isnd/ViewModels/PackageDetailViewModel.cs
index f49ab02..9ab5885 100644
--- a/src/isnd/ViewModels/PackageDetailViewModel.cs
+++ b/src/isnd/ViewModels/PackageDetailViewModel.cs
@@ -1,7 +1,11 @@
+using isn.abst;
using isnd.Data;
+using isnd.Entities;
+using Microsoft.Extensions.Options;
namespace isnd.ViewModels
{
+
public class PackageDetailViewModel
{
public PackageVersion latest { get; set; }
@@ -10,8 +14,5 @@ namespace isnd.ViewModels
public int totalHits { get; set; }
public PackageVersion[] data { get; set; }
- public string ExternalUrl { get; set; }
-
-
}
}
\ No newline at end of file
diff --git a/src/isnd/ViewModels/RegistrationPageIndexQueryAndResult.cs b/src/isnd/ViewModels/RegistrationPageIndexQueryAndResult.cs
index 25a2965..e9aec7c 100644
--- a/src/isnd/ViewModels/RegistrationPageIndexQueryAndResult.cs
+++ b/src/isnd/ViewModels/RegistrationPageIndexQueryAndResult.cs
@@ -4,7 +4,7 @@ namespace isnd
{
public class RegistrationPageIndexQueryAndResult
{
- public RegistrationPageIndexQuery Query { get; set; }
- public RegistrationPageIndex Result { get; set; }
+ public PackageRegistrationQuery Query { get; set; }
+ public PackageRegistration Result { get; set; }
}
}
\ No newline at end of file
diff --git a/src/isnd/Views/Home/Index.cshtml b/src/isnd/Views/Home/Index.cshtml
index d6b8afe..3b7c4c6 100644
--- a/src/isnd/Views/Home/Index.cshtml
+++ b/src/isnd/Views/Home/Index.cshtml
@@ -10,5 +10,6 @@
+
\ No newline at end of file
diff --git a/src/isnd/Views/PackageVersion/Details.cshtml b/src/isnd/Views/PackageVersion/Details.cshtml
index 93f5d3c..da66bbd 100644
--- a/src/isnd/Views/PackageVersion/Details.cshtml
+++ b/src/isnd/Views/PackageVersion/Details.cshtml
@@ -26,8 +26,8 @@
@Html.DisplayNameFor(model => model.FullString)
- @Html.DisplayFor(model => model.FullString)
- nuspec
+ @Html.DisplayFor(model => model.FullString)
+ nuspec
diff --git a/src/isnd/Views/PackageVersion/Index.cshtml b/src/isnd/Views/PackageVersion/Index.cshtml
index b2457d7..d695926 100644
--- a/src/isnd/Views/PackageVersion/Index.cshtml
+++ b/src/isnd/Views/PackageVersion/Index.cshtml
@@ -2,6 +2,7 @@
@{
ViewData["Title"] = "Index";
+ var apiBaseUrl = "/v3";
}
Index
@@ -44,11 +45,11 @@
@Html.DisplayFor(modelItem => item.PackageId)
-
+
nuget
-
+
nuspec
|
diff --git a/src/isnd/Views/Packages/Details.cshtml b/src/isnd/Views/Packages/Details.cshtml
index beb27fe..7655c79 100644
--- a/src/isnd/Views/Packages/Details.cshtml
+++ b/src/isnd/Views/Packages/Details.cshtml
@@ -25,8 +25,8 @@
@Html.DisplayNameFor(model => model.latest.FullString)
- @Html.DisplayFor(model => model.latest.FullString)
- nuspec
+ @Html.DisplayFor(model => model.latest.FullString)
+ nuspec
(version count : @Model.totalHits)
diff --git a/src/isnd/Views/Packages/Index.cshtml b/src/isnd/Views/Packages/Index.cshtml
index aa544e9..6e679e2 100644
--- a/src/isnd/Views/Packages/Index.cshtml
+++ b/src/isnd/Views/Packages/Index.cshtml
@@ -10,10 +10,10 @@
- @Html.DisplayNameFor(model => model.Result.Items[0].Items[0].refid)
+ @Html.DisplayNameFor(model => model.Result.Items[0].Items[0].Id)
|
- @Html.DisplayNameFor(model => model.Result.Items[0].Items[0].Description)
+ @Html.DisplayNameFor(model => model.Result.Items[0].Items[0].Entry.Description)
|
|
diff --git a/src/isnd/Views/_ViewImports.cshtml b/src/isnd/Views/_ViewImports.cshtml
index 9f3044d..8cfb510 100644
--- a/src/isnd/Views/_ViewImports.cshtml
+++ b/src/isnd/Views/_ViewImports.cshtml
@@ -2,4 +2,6 @@
@using isnd.ViewModels
@using isnd.Helpers
@using isnd.Data.Catalog;
+@using isn.abst;
+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
diff --git a/src/isnd/WebApiReferenceResolver.cs b/src/isnd/WebApiReferenceResolver.cs
index bd0e690..f6a4b11 100644
--- a/src/isnd/WebApiReferenceResolver.cs
+++ b/src/isnd/WebApiReferenceResolver.cs
@@ -17,27 +17,27 @@ namespace isnd
{
private int delautIdCounter;
- Dictionary HappyIdOwners { get; set; }
+ Dictionary HappyIdOwners { get; set; }
Dictionary Objects {get; set;}
public WebApiReferenceResolver()
{
delautIdCounter = 0;
- HappyIdOwners = new Dictionary();
+ HappyIdOwners = new Dictionary();
Objects = new Dictionary();
}
public override void AddReference(string referenceId, object value)
{
- if (value is HappyIdOwner)
+ if (value is Permalink)
{
- string hoi = (value as HappyIdOwner).GetId();
+ string hoi = (value as Permalink).GetId();
if (HappyIdOwners.ContainsKey(hoi))
{
return;
}
- HappyIdOwners[hoi] = value as HappyIdOwner;
+ HappyIdOwners[hoi] = value as Permalink;
}
else
{
@@ -53,9 +53,9 @@ namespace isnd
public override string GetReference(object value, out bool alreadyExists)
{
- if (value is HappyIdOwner)
+ if (value is Permalink)
{
- string oid = (value as HappyIdOwner).GetId();
+ string oid = (value as Permalink).GetId();
if (oid == null)
throw new System.Exception("HappyIdOwner Id property is null");
if (HappyIdOwners.ContainsKey(oid))
diff --git a/test/data/test-isn/ANuGet.Config b/test/data/test-isn/ANuGet.Config
index 072ade1..ec3aa41 100644
--- a/test/data/test-isn/ANuGet.Config
+++ b/test/data/test-isn/ANuGet.Config
@@ -3,8 +3,6 @@
-
-
+
diff --git a/test/data/test-isn/testcmd b/test/data/test-isn/testcmd
index 2127221..c32ec0c 100644
--- a/test/data/test-isn/testcmd
+++ b/test/data/test-isn/testcmd
@@ -1 +1 @@
-nuget install -NoCache -Verbosity detailed -ConfigFile ANuGet.Config Yavsc.Abstract
+nuget install -NoCache -Verbosity detailed -ConfigFile ANuGet.Config isn.abst
diff --git a/test/data/test-isn/urls b/test/data/test-isn/urls
new file mode 100644
index 0000000..d9c31a5
--- /dev/null
+++ b/test/data/test-isn/urls
@@ -0,0 +1,4 @@
+https://api.nuget.org/v3/registration5-gz-semver2/yavsc.abstract/index.json
+https://api.nuget.org/v3/catalog0/data/2019.09.17.10.18.17/yavsc.abstract.1.0.6-rc07.json
+http://localhost:5000/v3/index
+http://localhost:5000/v3/registration/isn.abst/index.json
diff --git a/test/isn.tests/PushTest.cs b/test/isn.tests/PushTest.cs
index b31f45a..5a7585c 100644
--- a/test/isn.tests/PushTest.cs
+++ b/test/isn.tests/PushTest.cs
@@ -33,7 +33,7 @@ namespace isn.tests
[Fact]
public async Task TestHttpClient()
{
- string url = "https://isn.pschneider.fr/v3/index.json" ;
+ string url = "https://isn.pschneider.fr"+Constants.ApiVersionPrefix+"/index.json" ;
HttpClient client = new HttpClient();
// var json = await client.GetStringAsync(new System.Uri(url));
var response = await client.GetAsync(url);
diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs
index d5da373..2e65f1c 100644
--- a/test/isnd.tests/UnitTestWebHost.cs
+++ b/test/isnd.tests/UnitTestWebHost.cs
@@ -1,28 +1,24 @@
using System.Threading;
using System;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore;
using Xunit;
using isnd.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System.Diagnostics;
-using Microsoft.AspNetCore.Hosting.Server;
-using Microsoft.AspNetCore.Hosting.Server.Features;
-using Microsoft.Extensions.Configuration;
using isnd.tests;
using NuGet.Protocol;
using NuGet.Configuration;
using System.Threading.Tasks;
using NuGet.Protocol.Core.Types;
+using isn.abst;
namespace isnd.host.tests
{
[Collection("Web server collection")]
public class UnitTestWebHost : IClassFixture
{
- const string apiindex = "/v3/index";
+ const string apiindex = Constants.ApiVersionPrefix + "/index";
WebServerFixture server;
public UnitTestWebHost(WebServerFixture server)
{
@@ -88,7 +84,7 @@ namespace isnd.host.tests
PackageSource packageSource = new PackageSource(pkgSourceUrl);
HttpSource client = new HttpSource(packageSource, PkgSourceMessageHandler, throttle);
NuGet.Protocol.RegistrationResourceV3 res = new NuGet.Protocol.RegistrationResourceV3(client ,
- new Uri(isnSettings.ExternalUrl + "/v3/registration"));
+ new Uri(isnSettings.ExternalUrl + Constants.ApiVersionPrefix + "/registration"));
}
}