mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
Feature/hw filtering (#2368)
* update deno * add proxy * remove query params, now auto added by BE * add hardware requirements and BE reg query params * update query params for BE requests * allow multiple arches in hw reqs * explain git hash mismatch * require lshw --------- Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
@@ -259,19 +259,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
|
||||
|
||||
@@ -125,7 +125,6 @@ export abstract class ApiService {
|
||||
path: string,
|
||||
params: Record<string, unknown>,
|
||||
url: string,
|
||||
arch?: string,
|
||||
): Promise<T>
|
||||
|
||||
abstract getEos(): Promise<RR.GetMarketplaceEosRes>
|
||||
|
||||
@@ -212,10 +212,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',
|
||||
@@ -224,17 +221,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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,6 @@ export class MockApiService extends ApiService {
|
||||
path: string,
|
||||
params: Record<string, string>,
|
||||
url: string,
|
||||
arch = '',
|
||||
): Promise<any> {
|
||||
await pauseFor(2000)
|
||||
|
||||
|
||||
@@ -217,10 +217,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,
|
||||
@@ -274,28 +271,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,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user