WIP NuGet API 3.5.0
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,7 +2,6 @@ src/isnd/bin/
|
||||
src/isnd/obj/
|
||||
src/isn/obj
|
||||
src/isn/bin
|
||||
.vscode/launch.json
|
||||
src/isn/.vscode/
|
||||
test/isnd.tests/obj/
|
||||
test/isnd.tests/bin/
|
||||
@ -10,7 +9,8 @@ packages/
|
||||
bower_components/
|
||||
test/isn.tests/bin
|
||||
test/isn.tests/obj/
|
||||
test/isnd.tests/appsettings.Testing.json
|
||||
appsettings.Testing.json
|
||||
appsettings.Development.json
|
||||
wwwroot/.sass-cache/
|
||||
src/isnd/wwwroot/.sass-cache/
|
||||
src/isn.abst/bin
|
||||
|
48
.vscode/launch.json
vendored
Normal file
48
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
|
||||
// Pointez pour afficher la description des attributs existants.
|
||||
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
},
|
||||
{
|
||||
"name": "push",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/src/isn/bin/Debug/netcoreapp2.1/isn.dll",
|
||||
"requireExactSource": false,
|
||||
"args": [
|
||||
"push", "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/src/isn",
|
||||
"stopAtEntry": false,
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"name": "web",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/src/isnd/bin/Debug/netcoreapp2.1/isnd.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/src/isnd",
|
||||
"stopAtEntry": false,
|
||||
"requireExactSource": false,
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
namespace isn.abst
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string PublishCommandId = "PackagePublish/2.0.0";
|
||||
|
||||
}
|
||||
}
|
@ -91,7 +91,7 @@ namespace isnd
|
||||
public async Task<IActionResult> DeleteConfirmed(string PackageId, string FullString,
|
||||
string Type)
|
||||
{
|
||||
PackageVersion packageVersion = await _context.PackageVersions.Include(p => p.Package)
|
||||
PackageVersion packageVersion = await _context.PackageVersions
|
||||
.FirstOrDefaultAsync(m => m.PackageId == PackageId
|
||||
&& m.FullString == FullString && m.Type == Type);
|
||||
if (packageVersion == null) return NotFound();
|
||||
|
31
src/isnd/Controllers/PackagesController.AutoComplete.cs
Normal file
31
src/isnd/Controllers/PackagesController.AutoComplete.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// GET /autocomplete?id=isn.protocol&prerelease=true
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)]
|
||||
public IActionResult AutoComplete(
|
||||
string id,
|
||||
string semVerLevel,
|
||||
bool prerelease = false,
|
||||
string packageType = null,
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
if (semVerLevel != defaultSemVer)
|
||||
{
|
||||
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
||||
}
|
||||
|
||||
return Ok(_packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ namespace isnd.Controllers
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgVersion = await _dbContext.PackageVersions
|
||||
.Include(v => v.LatestCommit)
|
||||
.Include(v => v.Package)
|
||||
.SingleOrDefaultAsync(
|
||||
v => v.PackageId == id &&
|
||||
v.FullString == lower &&
|
||||
|
37
src/isnd/Controllers/PackagesController.GetVersions.cs
Normal file
37
src/isnd/Controllers/PackagesController.GetVersions.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
bool prerelease = false,
|
||||
string packageType = null,
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
}
|
||||
// NugetVersion
|
||||
if (!NuGetVersion.TryParse(lower, out NuGetVersion parsedVersion))
|
||||
{
|
||||
ModelState.AddModelError("lower", "invalid version string");
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
versions = _packageManager.GetVersions(
|
||||
id, parsedVersion, prerelease, packageType, skip, take)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
28
src/isnd/Controllers/PackagesController.Search.cs
Normal file
28
src/isnd/Controllers/PackagesController.Search.cs
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Search)]
|
||||
public async Task<IActionResult> Search(
|
||||
|
||||
string q,
|
||||
int skip = 0,
|
||||
int take = 25,
|
||||
bool prerelease = false,
|
||||
string semVerLevel = null,
|
||||
string packageType = null
|
||||
)
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.ViewModels;
|
||||
@ -9,7 +10,6 @@ namespace isnd.Controllers
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// GET: PackageVersion
|
||||
public async Task<IActionResult> Index(PackageIndexViewModel model)
|
||||
{
|
||||
|
@ -57,59 +57,6 @@ namespace isnd.Controllers
|
||||
{
|
||||
return Ok(new ApiIndexViewModel{ Version = "3.0.0", Resources = _resources });
|
||||
}
|
||||
|
||||
// GET /autocomplete?id=isn.protocol&prerelease=true
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)]
|
||||
public IActionResult AutoComplete(
|
||||
string id,
|
||||
string semVerLevel,
|
||||
bool prerelease = false,
|
||||
string packageType = null,
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
if (semVerLevel != defaultSemVer)
|
||||
{
|
||||
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
||||
}
|
||||
|
||||
return Ok(_packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
||||
}
|
||||
// TODO GET {@id}/{LOWER_ID}/index.json
|
||||
// LOWER_ID URL string yes The package ID, lowercased
|
||||
// response : versions array of strings yes The versions available
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
bool prerelease = false,
|
||||
string packageType = null,
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
}
|
||||
// NugetVersion
|
||||
if (!NuGetVersion.TryParse(lower, out NuGetVersion parsedVersion))
|
||||
{
|
||||
ModelState.AddModelError("lower", "invalid version string");
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
return Ok(new
|
||||
{
|
||||
versions = _packageManager.GetVersions(
|
||||
id, parsedVersion, prerelease, packageType, skip, take)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,9 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using isn.abst;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Entities;
|
||||
@ -21,6 +19,7 @@ namespace isnd.Services
|
||||
{
|
||||
public class PackageManager : IPackageManager
|
||||
{
|
||||
public const string BASE_API_LEVEL = "3.5.0";
|
||||
ApplicationDbContext dbContext;
|
||||
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
@ -43,7 +42,7 @@ namespace isnd.Services
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Publish,
|
||||
Type = Constants.PublishCommandId,
|
||||
Type = "PackagePublish/2.0.0", // TODO BASE_API_LEVEL
|
||||
Comment = "Package Publish service"
|
||||
});
|
||||
// under dev, only leash in release mode
|
||||
@ -52,7 +51,7 @@ namespace isnd.Services
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Base,
|
||||
Type = "PackageBaseAddress/3.0.0",
|
||||
Type = "PackageBaseAddress/" + BASE_API_LEVEL,
|
||||
Comment = "Package Base Address service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||
@ -60,17 +59,23 @@ namespace isnd.Services
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.AutoComplete,
|
||||
Type = "SearchAutocompleteService/3.5.0",
|
||||
Type = "SearchAutocompleteService/" + BASE_API_LEVEL,
|
||||
Comment = "Auto complete service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-search", false))
|
||||
if (unleashClient.IsEnabled("pkg-search", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Search,
|
||||
Type = "SearchQueryService/3.5.0",
|
||||
Type = "SearchQueryService/" + BASE_API_LEVEL,
|
||||
Comment = "Search Query service"
|
||||
});
|
||||
/*
|
||||
{
|
||||
"@id": "https://api-v2v3search-0.nuget.org/query",
|
||||
"@type": "SearchQueryService/3.0.0-rc",
|
||||
"comment": "Query endpoint of NuGet Search service (primary) used by RC clients"
|
||||
},
|
||||
|
||||
if (unleashClient.IsEnabled("pkg-catalog", false))
|
||||
res.Add(
|
||||
@ -79,7 +84,17 @@ namespace isnd.Services
|
||||
Id = extUrl + ApiConfig.Catalog,
|
||||
Type = "Catalog/3.0.0",
|
||||
Comment = "Package Catalog Index"
|
||||
});
|
||||
});*/
|
||||
|
||||
/* TODO ? {
|
||||
|
||||
"@id": "https://api.nuget.org/v3/registration5-gz-semver2/",
|
||||
"@type": "RegistrationsBaseUrl/Versioned",
|
||||
"clientVersion": "4.3.0-alpha",
|
||||
"comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
|
||||
|
||||
},
|
||||
*/
|
||||
return res;
|
||||
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"AdminStartupList": {
|
||||
"Users": [
|
||||
"paul@pschneider.fr"
|
||||
]
|
||||
},
|
||||
"Isn": {
|
||||
"ExternalUrl": "http://localhost:5000",
|
||||
"PackagesRootDir" : "packages",
|
||||
"ProtectionTitle": "protected-data-v1",
|
||||
"MaxUserKeyCount": 5
|
||||
},
|
||||
"Smtp": {
|
||||
"Server": "localhost",
|
||||
"Port": 25,
|
||||
"SenderName": "Paul Schneider",
|
||||
"SenderEmail": "paul@pschneider.fr"
|
||||
},
|
||||
"Unleash":
|
||||
{
|
||||
"ClientApiKey": "6f08a4b280ec4d4fd58b8a471fee4d0ceeb9b665ffd45dc957f8e695e0a0dfa6"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user