mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
pre-download static files, and add api versioning
This commit is contained in:
committed by
Aiden McClelland
parent
01d766fce9
commit
d3c5648608
@@ -23,14 +23,14 @@ export class MarketplaceService {
|
||||
} = {}
|
||||
marketplaceUrl: string
|
||||
|
||||
constructor(
|
||||
constructor (
|
||||
private readonly api: ApiService,
|
||||
private readonly emver: Emver,
|
||||
private readonly patch: PatchDbService,
|
||||
private readonly config: ConfigService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async init() {
|
||||
async init () {
|
||||
this.patch.watch$('ui', 'marketplace').subscribe(marketplace => {
|
||||
if (!marketplace || !marketplace['selected-id']) {
|
||||
this.marketplaceUrl = this.config.marketplace.url
|
||||
@@ -41,7 +41,7 @@ export class MarketplaceService {
|
||||
})
|
||||
}
|
||||
|
||||
async load(): Promise<void> {
|
||||
async load (): Promise<void> {
|
||||
try {
|
||||
const [data, pkgs] = await Promise.all([
|
||||
this.getMarketplaceData({}),
|
||||
@@ -66,7 +66,7 @@ export class MarketplaceService {
|
||||
}
|
||||
}
|
||||
|
||||
async getUpdates(localPkgs: {
|
||||
async getUpdates (localPkgs: {
|
||||
[id: string]: PackageDataEntry
|
||||
}): Promise<MarketplacePkg[]> {
|
||||
const id = this.patch.getData().ui.marketplace?.['selected-id']
|
||||
@@ -96,7 +96,7 @@ export class MarketplaceService {
|
||||
})
|
||||
}
|
||||
|
||||
async getPkg(id: string, version = '*'): Promise<MarketplacePkg> {
|
||||
async getPkg (id: string, version = '*'): Promise<MarketplacePkg> {
|
||||
const pkgs = await this.getMarketplacePkgs({
|
||||
ids: [{ id, version }],
|
||||
'eos-version-compat':
|
||||
@@ -111,11 +111,11 @@ export class MarketplaceService {
|
||||
}
|
||||
}
|
||||
|
||||
async cacheReleaseNotes(id: string): Promise<void> {
|
||||
async cacheReleaseNotes (id: string): Promise<void> {
|
||||
this.releaseNotes[id] = await this.getReleaseNotes({ id })
|
||||
}
|
||||
|
||||
private async getPkgs(
|
||||
private async getPkgs (
|
||||
page: number,
|
||||
perPage: number,
|
||||
): Promise<MarketplacePkg[]> {
|
||||
@@ -129,20 +129,20 @@ export class MarketplaceService {
|
||||
return pkgs
|
||||
}
|
||||
|
||||
async getMarketplaceData(
|
||||
async getMarketplaceData (
|
||||
params: RR.GetMarketplaceDataReq,
|
||||
url?: string,
|
||||
): Promise<RR.GetMarketplaceDataRes> {
|
||||
url = url || this.marketplaceUrl
|
||||
return this.api.marketplaceProxy('/package/data', params, url)
|
||||
return this.api.marketplaceProxy('/package/v0/data', params, url)
|
||||
}
|
||||
|
||||
async getMarketplacePkgs(
|
||||
async getMarketplacePkgs (
|
||||
params: RR.GetMarketplacePackagesReq,
|
||||
): Promise<RR.GetMarketplacePackagesRes> {
|
||||
if (params.query) params.category = undefined
|
||||
return this.api.marketplaceProxy(
|
||||
'/package/index',
|
||||
'/package/v0/index',
|
||||
{
|
||||
...params,
|
||||
ids: JSON.stringify(params.ids),
|
||||
@@ -151,11 +151,11 @@ export class MarketplaceService {
|
||||
)
|
||||
}
|
||||
|
||||
async getReleaseNotes(
|
||||
async getReleaseNotes (
|
||||
params: RR.GetReleaseNotesReq,
|
||||
): Promise<RR.GetReleaseNotesRes> {
|
||||
return this.api.marketplaceProxy(
|
||||
'/package/release-notes',
|
||||
'/package/v0/release-notes',
|
||||
params,
|
||||
this.marketplaceUrl,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user