Merge branch 'rebase/integration/refactors' of github.com:Start9Labs/start-os into rebase/feat/domains

This commit is contained in:
Aiden McClelland
2023-08-08 10:17:28 -06:00
34 changed files with 412 additions and 190 deletions

View File

@@ -379,19 +379,14 @@ export module RR {
// marketplace
export type EnvInfo = {
'server-id': string
'eos-version': string
}
export type GetMarketplaceInfoReq = EnvInfo
export type GetMarketplaceInfoReq = { 'server-id': string }
export type GetMarketplaceInfoRes = StoreInfo
export type GetMarketplaceEosReq = EnvInfo
export type GetMarketplaceEosReq = { 'server-id': string }
export type GetMarketplaceEosRes = MarketplaceEOS
export type GetMarketplacePackagesReq = {
ids?: { id: string; version: string }[]
'eos-version-compat': string
// iff !ids
category?: string
query?: string

View File

@@ -135,7 +135,6 @@ export abstract class ApiService {
path: string,
params: Record<string, unknown>,
url: string,
arch?: string,
): Promise<T>
abstract getEos(): Promise<RR.GetMarketplaceEosRes>

View File

@@ -245,10 +245,7 @@ export class LiveApiService extends ApiService {
path: string,
qp: Record<string, string>,
baseUrl: string,
arch: string = this.config.packageArch,
): Promise<T> {
// Object.assign(qp, { arch })
qp['arch'] = arch
const fullUrl = `${baseUrl}${path}?${new URLSearchParams(qp).toString()}`
return this.rpcRequest({
method: 'marketplace.get',
@@ -257,17 +254,13 @@ export class LiveApiService extends ApiService {
}
async getEos(): Promise<RR.GetMarketplaceEosRes> {
const { id, version } = await getServerInfo(this.patch)
const qp: RR.GetMarketplaceEosReq = {
'server-id': id,
'eos-version': version,
}
const { id } = await getServerInfo(this.patch)
const qp: RR.GetMarketplaceEosReq = { 'server-id': id }
return this.marketplaceProxy(
'/eos/v0/latest',
qp,
this.config.marketplace.start9,
this.config.osArch,
)
}

View File

@@ -393,7 +393,6 @@ export class MockApiService extends ApiService {
path: string,
params: Record<string, string>,
url: string,
arch = '',
): Promise<any> {
await pauseFor(2000)

View File

@@ -215,10 +215,7 @@ export class MarketplaceService implements AbstractMarketplaceService {
return this.patch.watch$('server-info').pipe(
take(1),
switchMap(serverInfo => {
const qp: RR.GetMarketplaceInfoReq = {
'server-id': serverInfo.id,
'eos-version': serverInfo.version,
}
const qp: RR.GetMarketplaceInfoReq = { 'server-id': serverInfo.id }
return this.api.marketplaceProxy<RR.GetMarketplaceInfoRes>(
'/package/v0/info',
qp,
@@ -272,28 +269,21 @@ export class MarketplaceService implements AbstractMarketplaceService {
private fetchPackages$(
url: string,
params: Omit<
RR.GetMarketplacePackagesReq,
'eos-version-compat' | 'page' | 'per-page'
> = {},
params: Omit<RR.GetMarketplacePackagesReq, 'page' | 'per-page'> = {},
): Observable<MarketplacePkg[]> {
return this.patch.watch$('server-info', 'eos-version-compat').pipe(
take(1),
switchMap(versionCompat => {
const qp: RR.GetMarketplacePackagesReq = {
...params,
'eos-version-compat': versionCompat,
page: 1,
'per-page': 100,
}
if (qp.ids) qp.ids = JSON.stringify(qp.ids)
const qp: RR.GetMarketplacePackagesReq = {
...params,
page: 1,
'per-page': 100,
}
if (qp.ids) qp.ids = JSON.stringify(qp.ids)
return this.api.marketplaceProxy<RR.GetMarketplacePackagesRes>(
'/package/v0/index',
qp,
url,
)
}),
return from(
this.api.marketplaceProxy<RR.GetMarketplacePackagesRes>(
'/package/v0/index',
qp,
url,
),
)
}