|
|
|
@ -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<Resource> GetResources(IUnleash unleashClient)
|
|
|
|
@ -126,19 +126,19 @@ namespace isnd.Services
|
|
|
|
|
private IsndSettings isndSettings;
|
|
|
|
|
private readonly string apiBase;
|
|
|
|
|
|
|
|
|
|
public virtual async Task<RegistrationPageIndex> GetCatalogIndexAsync()
|
|
|
|
|
public virtual async Task<PackageRegistration> GetCatalogIndexAsync()
|
|
|
|
|
{
|
|
|
|
|
return await ÛpdateCatalogForAsync(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<RegistrationPageIndex> ÛpdateCatalogForAsync
|
|
|
|
|
public async Task<PackageRegistration> Û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<CatalogEntry> GetCatalogEntryAsync
|
|
|
|
|
public async Task<Data.Catalog.Package> GetCatalogEntryAsync
|
|
|
|
|
(string pkgId, string semver = null, string pkgType = null)
|
|
|
|
|
{
|
|
|
|
|
return (await dbContext.PackageVersions
|
|
|
|
|
.Include(v => v.Package)
|
|
|
|
|
.Include(v => v.LatestCommit)
|
|
|
|
|
.Include(v => v.Package).Include(v => v.Package.Owner)
|
|
|
|
|
.Where(v => v.PackageId == pkgId
|
|
|
|
|
&& semver == v.SementicVersionString
|
|
|
|
|
&& (pkgType == null || pkgType == v.Type)).SingleOrDefaultAsync()).ToLeave(BID,
|
|
|
|
|
&& 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<CatalogEntry> SearchCatalogEntriesById
|
|
|
|
|
public IEnumerable<Data.Catalog.Package> 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<RegistrationPageIndex> GetPackageRegistrationIndexAsync
|
|
|
|
|
(RegistrationPageIndexQuery query)
|
|
|
|
|
public async Task<PackageRegistration> 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<RegistrationPageIndex> SearchPackageAsync(RegistrationPageIndexQuery query)
|
|
|
|
|
public async Task<PackageRegistration> 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));
|
|
|
|
|