This commit is contained in:
2022-07-03 14:50:57 +01:00
parent a84e1d9750
commit 2dcf1a2806
18 changed files with 166 additions and 98 deletions

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using isn.Abstract;
using isnd.Controllers;
using isnd.Data;
using isnd.Data.Catalog;
using isnd.Entities;
@ -51,8 +52,8 @@ namespace isnd.Services
res.Add(
new Resource
{
Id = extUrl + ApiConfig.Base,
Type = "PackageBaseAddress/" + BASE_API_LEVEL,
Id = extUrl + ApiConfig.GetPackage,
Type = "PackageBaseAddress/3.0.0" ,
Comment = "Package Base Address service"
});
if (unleashClient.IsEnabled("pkg-autocomplete", false))
@ -79,14 +80,14 @@ namespace isnd.Services
Type = "Catalog/"+ BASE_API_LEVEL,
Comment = "Package Catalog Index"
});
if (unleashClient.IsEnabled("pkg-registration", false))
res.Add(
/* FIXME res.Add(
new Resource
{
Id = extUrl + ApiConfig.Registration,
Type = "Catalog/" + BASE_API_LEVEL,
Type = "RegistrationsBaseUrl/3.6.0",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
}); */
return res;
}
@ -256,7 +257,7 @@ namespace isnd.Services
public async Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type)
{
// TODO package deletion on disk
// TODO deletion on disk
var commit = new Commit{
Action = PackageAction.DeletePackage,
TimeStamp = DateTime.Now
@ -285,5 +286,24 @@ namespace isnd.Services
v.Type == type
);
}
public async Task<CatalogRegistration> GetPackageRegistrationAsync(string pkgid, string version, string type)
{
var pkgVersion = await GetPackageAsync(pkgid, version, type);
return new CatalogRegistration
{
Id = pkgVersion.PackageId,
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp,
PackageContent = extUrl + pkgVersion.FullString
};
}
public IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower)
{
return dbContext.PackageVersions
.Include(v=>v.Package)
.Where(v => v.PackageId == id && v.FullString == version
&& (lower == null || lower == v.Type));
}
}
}