mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
marketplace updates
This commit is contained in:
committed by
Aiden McClelland
parent
b07c9c2d69
commit
b9972285a9
@@ -168,10 +168,7 @@ export module RR {
|
||||
export type GetMarketplaceEOSRes = MarketplaceEOS
|
||||
|
||||
export type GetMarketplacePackagesReq = {
|
||||
ids?: string[]
|
||||
id?: string
|
||||
// iff id
|
||||
version?: string
|
||||
ids?: { id: string, version: string }[]
|
||||
// iff !id
|
||||
category?: string
|
||||
query?: string
|
||||
@@ -182,13 +179,17 @@ export module RR {
|
||||
|
||||
export type GetReleaseNotesReq = { id: string }
|
||||
export type GetReleaseNotesRes = { [version: string]: string}
|
||||
|
||||
export type GetLatestVersionReq = { ids: string[] }
|
||||
export type GetLatestVersionRes = { [id: string]: string}
|
||||
|
||||
}
|
||||
|
||||
export type WithExpire<T> = { 'expire-id'?: string } & T
|
||||
export type WithRevision<T> = { response: T, revision?: Revision }
|
||||
|
||||
export interface MarketplaceData {
|
||||
categories: string[]
|
||||
categories: string[],
|
||||
}
|
||||
|
||||
export interface MarketplaceEOS {
|
||||
|
||||
@@ -60,10 +60,10 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
() => this.setEosMarketplaceRaw(isTor),
|
||||
)()
|
||||
|
||||
protected abstract setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes>
|
||||
setPackageMarketplace = (params: RR.SetPackageMarketplaceReq) => this.syncResponse(
|
||||
() => this.setPackageMarketplaceRaw(params),
|
||||
)()
|
||||
// protected abstract setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes>
|
||||
// setPackageMarketplace = (params: RR.SetPackageMarketplaceReq) => this.syncResponse(
|
||||
// () => this.setPackageMarketplaceRaw(params),
|
||||
// )()
|
||||
|
||||
// password
|
||||
abstract updatePassword (params: RR.UpdatePasswordReq): Promise<RR.UpdatePasswordRes>
|
||||
|
||||
@@ -78,9 +78,9 @@ export class LiveApiService extends ApiService {
|
||||
return this.http.rpcRequest({ method: 'marketplace.eos.set', params })
|
||||
}
|
||||
|
||||
async setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes> {
|
||||
return this.http.rpcRequest({ method: 'marketplace.package.set', params })
|
||||
}
|
||||
// async setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes> {
|
||||
// return this.http.rpcRequest({ method: 'marketplace.package.set', params })
|
||||
// }
|
||||
|
||||
// password
|
||||
async updatePassword (params: RR.UpdatePasswordReq): Promise<RR.UpdatePasswordRes> {
|
||||
|
||||
@@ -138,17 +138,17 @@ export class MockApiService extends ApiService {
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes> {
|
||||
await pauseFor(2000)
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/package-marketplace',
|
||||
value: params.url,
|
||||
},
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
// async setPackageMarketplaceRaw (params: RR.SetPackageMarketplaceReq): Promise<RR.SetPackageMarketplaceRes> {
|
||||
// await pauseFor(2000)
|
||||
// const patch = [
|
||||
// {
|
||||
// op: PatchOp.REPLACE,
|
||||
// path: '/server-info/package-marketplace',
|
||||
// value: params.url,
|
||||
// },
|
||||
// ]
|
||||
// return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
// }
|
||||
|
||||
// password
|
||||
async updatePassword (params: RR.UpdatePasswordReq): Promise<RR.UpdatePasswordRes> {
|
||||
|
||||
@@ -17,12 +17,17 @@ export abstract class MarketplaceApiService {
|
||||
|
||||
abstract getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes>
|
||||
|
||||
getMarketplaceURL (type: 'eos' | 'package'): string {
|
||||
abstract getLatestVersion (params: RR.GetLatestVersionReq): Promise<RR.GetLatestVersionRes>
|
||||
|
||||
getMarketplaceURL (type: 'eos' | 'package', defaultToTor = false): string {
|
||||
const packageMarketplace = this.patch.data['server-info']['package-marketplace']
|
||||
if (defaultToTor && !packageMarketplace) {
|
||||
return this.config.start9Marketplace.tor
|
||||
}
|
||||
const eosMarketplace = this.patch.data['server-info']['eos-marketplace'] || this.config.start9Marketplace.clearnet
|
||||
if (type === 'eos') {
|
||||
return eosMarketplace
|
||||
} else {
|
||||
const packageMarketplace = this.patch.data['server-info']['package-marketplace']
|
||||
return packageMarketplace || eosMarketplace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,21 @@ export class MarketplaceLiveApiService extends MarketplaceApiService {
|
||||
}
|
||||
|
||||
async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise<RR.GetMarketplacePackagesRes> {
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(this.getMarketplaceURL('package'), params)
|
||||
const url = this.getMarketplaceURL('package', params.ids?.length > 1)
|
||||
const threadParams = {
|
||||
...params,
|
||||
ids: JSON.stringify(params.ids),
|
||||
}
|
||||
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(url, threadParams)
|
||||
}
|
||||
|
||||
async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes> {
|
||||
return this.http.simpleGet<RR.GetReleaseNotesRes>(this.getMarketplaceURL('package'), params)
|
||||
}
|
||||
|
||||
async getLatestVersion (params: RR.GetLatestVersionReq): Promise<RR.GetLatestVersionRes> {
|
||||
const url = this.getMarketplaceURL('package', params.ids?.length > 1)
|
||||
return this.http.simpleGet<RR.GetLatestVersionRes>(url, params)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import { HttpService } from '../../http.service'
|
||||
import { MarketplaceApiService } from './marketplace-api.service'
|
||||
import { PatchDbService } from '../../patch-db/patch-db.service'
|
||||
import { ConfigService } from '../../config.service'
|
||||
import { Storage } from '@ionic/storage'
|
||||
|
||||
@Injectable()
|
||||
export class MarketplaceMockApiService extends MarketplaceApiService {
|
||||
CONTENT_KEY = 'marketplace-cache'
|
||||
|
||||
constructor (
|
||||
private readonly http: HttpService,
|
||||
@@ -38,18 +40,22 @@ export class MarketplaceMockApiService extends MarketplaceApiService {
|
||||
categories: ['featured', 'bitcoin', 'lightning', 'data', 'messaging', 'social', 'alt coin'],
|
||||
}
|
||||
}
|
||||
url = `${url}/marketplace/data`
|
||||
url = `${url}/data`
|
||||
return this.http.simpleGet<RR.GetMarketplaceDataRes>(url)
|
||||
}
|
||||
|
||||
async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise<RR.GetMarketplacePackagesRes> {
|
||||
let url = this.getMarketplaceURL('package')
|
||||
let url = this.getMarketplaceURL('package', params.ids?.length > 1)
|
||||
const threadParams = {
|
||||
...params,
|
||||
ids: JSON.stringify(params.ids),
|
||||
}
|
||||
if (this.useLocal(url)) {
|
||||
await pauseFor(2000)
|
||||
return Mock.AvailableList
|
||||
}
|
||||
url = `${url}/marketplace/packages`
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(url, params)
|
||||
url = `${url}/packages`
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(url, threadParams)
|
||||
}
|
||||
|
||||
async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes> {
|
||||
@@ -58,8 +64,21 @@ export class MarketplaceMockApiService extends MarketplaceApiService {
|
||||
await pauseFor(2000)
|
||||
return Mock.ReleaseNotes
|
||||
}
|
||||
url = `${url}/marketplace/release-notes`
|
||||
return this.http.simpleGet<RR.GetReleaseNotesRes>(url)
|
||||
url = `${url}/release-notes`
|
||||
return this.http.simpleGet<RR.GetReleaseNotesRes>(url, params)
|
||||
}
|
||||
|
||||
async getLatestVersion (params: RR.GetLatestVersionReq): Promise<RR.GetLatestVersionRes> {
|
||||
let url = this.getMarketplaceURL('package', params.ids?.length > 1)
|
||||
if (this.useLocal(url)) {
|
||||
await pauseFor(2000)
|
||||
return params.ids.reduce((obj, id) => {
|
||||
obj[id] = this.patch.data['package-data']?.[id]?.manifest.version.replace('0', '1')
|
||||
return obj
|
||||
}, { })
|
||||
}
|
||||
url = `${url}/latest-version`
|
||||
return this.http.simpleGet<RR.GetLatestVersionRes>(url)
|
||||
}
|
||||
|
||||
private useLocal (url: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user