mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
rework endpoints and enable setting custom marketplace urls
This commit is contained in:
committed by
Aiden McClelland
parent
7253cd002e
commit
c4a5cf1c51
@@ -44,10 +44,17 @@ export module RR {
|
||||
export type RefreshLanReq = { } // network.lan.refresh
|
||||
export type RefreshLanRes = null
|
||||
|
||||
// registry
|
||||
// marketplace URLs
|
||||
|
||||
export type SetRegistryReq = WithExpire<{ url: string }> // registry.set
|
||||
export type SetRegistryRes = WithRevision<null>
|
||||
export type SetEosMarketplaceReq = WithExpire<{ url: string }> // marketplace.eos.set
|
||||
export type SetEosMarketplaceRes = WithRevision<null>
|
||||
|
||||
export type SetPackageMarketplaceReq = WithExpire<{ url: string }> // marketplace.package.set
|
||||
export type SetPackageMarketplaceRes = WithRevision<null>
|
||||
|
||||
// password
|
||||
export type UpdatePasswordReq = { password: string } // password.set
|
||||
export type UpdatePasswordRes = null
|
||||
|
||||
// notification
|
||||
|
||||
@@ -160,11 +167,11 @@ export module RR {
|
||||
export type GetMarketplaceEOSReq = { }
|
||||
export type GetMarketplaceEOSRes = MarketplaceEOS
|
||||
|
||||
export type GetAvailableListReq = { category?: string, query?: string, page: number, 'per-page': number }
|
||||
export type GetAvailableListRes = AvailablePreview[]
|
||||
export type GetMarketplacePackagesReq = { id?: string, version?: string, category?: string, query?: string, page?: string, 'per-page'?: string }
|
||||
export type GetMarketplacePackagesRes = MarketplacePkg[]
|
||||
|
||||
export type GetAvailableShowReq = { id: string, version?: string }
|
||||
export type GetAvailableShowRes = AvailableShow
|
||||
export type GetReleaseNotesReq = { id: string }
|
||||
export type GetReleaseNotesRes = { [version: string]: string}
|
||||
}
|
||||
|
||||
export type WithExpire<T> = { 'expire-id'?: string } & T
|
||||
@@ -180,15 +187,7 @@ export interface MarketplaceEOS {
|
||||
'release-notes': { [version: string]: string }
|
||||
}
|
||||
|
||||
export interface AvailablePreview {
|
||||
id: string
|
||||
title: string
|
||||
version: string
|
||||
icon: URL
|
||||
descriptionShort: string
|
||||
}
|
||||
|
||||
export interface AvailableShow {
|
||||
export interface MarketplacePkg {
|
||||
icon: URL
|
||||
license: URL
|
||||
instructions: URL
|
||||
@@ -201,7 +200,6 @@ export interface AvailableShow {
|
||||
icon: URL
|
||||
}
|
||||
},
|
||||
'release-notes': { [version: string]: string }
|
||||
}
|
||||
|
||||
export interface Breakages {
|
||||
|
||||
@@ -5,8 +5,8 @@ import { ConfigService } from '../config.service'
|
||||
|
||||
export function ApiServiceFactory (config: ConfigService, http: HttpService) {
|
||||
if (config.mocks.enabled) {
|
||||
return new MockApiService(http)
|
||||
return new MockApiService(config, http)
|
||||
} else {
|
||||
return new LiveApiService(http)
|
||||
return new LiveApiService(config, http)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,21 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
|
||||
abstract refreshLan (params: RR.RefreshLanReq): Promise<RR.RefreshLanRes>
|
||||
|
||||
// registry
|
||||
// marketplace URLs
|
||||
|
||||
protected abstract setRegistryRaw (params: RR.SetRegistryReq): Promise<RR.SetRegistryRes>
|
||||
setRegistry = (params: RR.SetRegistryReq) => this.syncResponse(
|
||||
() => this.setRegistryRaw(params),
|
||||
protected abstract setEosMarketplaceRaw (isTor: boolean): Promise<RR.SetEosMarketplaceRes>
|
||||
setEosMarketplace = (isTor: boolean) => this.syncResponse(
|
||||
() => this.setEosMarketplaceRaw(isTor),
|
||||
)()
|
||||
|
||||
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>
|
||||
|
||||
// notification
|
||||
|
||||
abstract getNotificationsRaw (params: RR.GetNotificationsReq): Promise<RR.GetNotificationsRes>
|
||||
@@ -165,9 +173,9 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
|
||||
abstract getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes>
|
||||
|
||||
abstract getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes>
|
||||
abstract getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise<RR.GetMarketplacePackagesRes>
|
||||
|
||||
abstract getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes>
|
||||
abstract getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes>
|
||||
|
||||
// Helper allowing quick decoration to sync the response patch and return the response contents.
|
||||
// Pass in a tempUpdate function which returns a UpdateTemp corresponding to a temporary
|
||||
@@ -187,3 +195,13 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getMarketURL (eosOrPackage: 'eos' | 'package', data: DataModel): string {
|
||||
const eosMarketplace = data['server-info']['eos-marketplace']
|
||||
if (eosOrPackage === 'eos') {
|
||||
return eosMarketplace
|
||||
} else {
|
||||
const packageMarketplace = data['server-info']['package-marketplace']
|
||||
return packageMarketplace || eosMarketplace
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { HttpService, Method } from '../http.service'
|
||||
import { ApiService } from './api.service'
|
||||
import { ApiService, getMarketURL } from './api.service'
|
||||
import { RR } from './api-types'
|
||||
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||
import { ConfigService } from '../config.service'
|
||||
|
||||
@Injectable()
|
||||
export class LiveApiService extends ApiService {
|
||||
|
||||
constructor (
|
||||
private readonly config: ConfigService,
|
||||
private readonly http: HttpService,
|
||||
) { super() }
|
||||
|
||||
@@ -66,10 +69,22 @@ export class LiveApiService extends ApiService {
|
||||
return this.http.rpcRequest({ method: 'network.lan.refresh', params })
|
||||
}
|
||||
|
||||
// registry
|
||||
// marketplace URLs
|
||||
|
||||
async setRegistryRaw (params: RR.SetRegistryReq): Promise<RR.SetRegistryRes> {
|
||||
return this.http.rpcRequest({ method: 'registry.set', params })
|
||||
async setEosMarketplaceRaw (isTor: boolean): Promise<RR.SetEosMarketplaceRes> {
|
||||
const params: RR.SetEosMarketplaceReq = {
|
||||
url: isTor ? this.config.start9Marketplace.tor : this.config.start9Marketplace.clearnet,
|
||||
}
|
||||
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 })
|
||||
}
|
||||
|
||||
// password
|
||||
async updatePassword (params: RR.UpdatePasswordReq): Promise<RR.UpdatePasswordRes> {
|
||||
return this.http.rpcRequest({ method: 'password.set', params })
|
||||
}
|
||||
|
||||
// notification
|
||||
@@ -200,18 +215,18 @@ export class LiveApiService extends ApiService {
|
||||
// marketplace
|
||||
|
||||
async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise<RR.GetMarketplaceDataRes> {
|
||||
return this.http.rpcRequest({ method: 'marketplace.data', params })
|
||||
return this.http.simpleGet<RR.GetMarketplaceDataRes>(getMarketURL('package', this.patch.data), params)
|
||||
}
|
||||
|
||||
async getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes> {
|
||||
return this.http.rpcRequest({ method: 'marketplace.eos', params })
|
||||
return this.http.simpleGet<RR.GetMarketplaceEOSRes>(getMarketURL('eos', this.patch.data), params)
|
||||
}
|
||||
|
||||
async getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes> {
|
||||
return this.http.rpcRequest({ method: 'marketplace.available.list', params })
|
||||
async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise<RR.GetMarketplacePackagesRes> {
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(getMarketURL('package', this.patch.data), params)
|
||||
}
|
||||
|
||||
async getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes> {
|
||||
return this.http.rpcRequest({ method: 'marketplace.available', params })
|
||||
async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes> {
|
||||
return this.http.simpleGet<RR.GetReleaseNotesRes>(getMarketURL('package', this.patch.data), params)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,24 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { pauseFor } from '../../util/misc.util'
|
||||
import { ApiService } from './api.service'
|
||||
import { Observable } from 'rxjs'
|
||||
import { PatchOp, Store, Update } from 'patch-db-client'
|
||||
import { DataModel, PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model'
|
||||
import { RR } from './api-types'
|
||||
import { ApiService, getMarketURL } from './api.service'
|
||||
import { PatchOp } from 'patch-db-client'
|
||||
import { PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model'
|
||||
import { RR, WithRevision } from './api-types'
|
||||
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||
import { Mock } from './mock-app-fixures'
|
||||
import { HttpService, Method } from '../http.service'
|
||||
import { HttpService } from '../http.service'
|
||||
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
|
||||
import { ConfigService } from '../config.service'
|
||||
const configService = new ConfigService()
|
||||
|
||||
@Injectable()
|
||||
export class MockApiService extends ApiService {
|
||||
sequence = 0
|
||||
welcomeAck = false
|
||||
|
||||
constructor (
|
||||
private readonly config: ConfigService,
|
||||
private readonly http: HttpService,
|
||||
) { super() }
|
||||
|
||||
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
|
||||
watch$ (store: Store<DataModel>): Observable<Update<DataModel>> {
|
||||
store.sequence$.subscribe(seq => {
|
||||
console.log('INCOMING: ', seq)
|
||||
if (this.sequence < seq) {
|
||||
this.sequence = seq
|
||||
}
|
||||
})
|
||||
return super.watch$()
|
||||
}
|
||||
|
||||
async getStatic (url: string): Promise<string> {
|
||||
await pauseFor(2000)
|
||||
return markdown
|
||||
@@ -106,20 +94,14 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async updateServerRaw (params: RR.UpdateServerReq): Promise<RR.UpdateServerRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.Updating,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.Updating,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async restartServer (params: RR.RestartServerReq): Promise<RR.RestartServerRes> {
|
||||
@@ -139,43 +121,56 @@ export class MockApiService extends ApiService {
|
||||
return null
|
||||
}
|
||||
|
||||
// registry
|
||||
// marketplace URLs
|
||||
|
||||
async setRegistryRaw (params: RR.SetRegistryReq): Promise<RR.SetRegistryRes> {
|
||||
async setEosMarketplaceRaw (isTor: boolean): Promise<RR.SetEosMarketplaceRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/registry',
|
||||
value: params.url,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
},
|
||||
const params: RR.SetEosMarketplaceReq = {
|
||||
url: isTor ? this.config.start9Marketplace.tor : this.config.start9Marketplace.clearnet,
|
||||
}
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/eos-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> {
|
||||
await pauseFor(2000)
|
||||
return null
|
||||
}
|
||||
|
||||
// notification
|
||||
|
||||
async getNotificationsRaw (params: RR.GetNotificationsReq): Promise<RR.GetNotificationsRes> {
|
||||
await pauseFor(2000)
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/unread-notification-count',
|
||||
value: 0,
|
||||
},
|
||||
]
|
||||
const { revision } = await this.http.rpcRequest({ method: 'db.patch', params: { patch } }) as WithRevision<null>
|
||||
return {
|
||||
response: Mock.Notifications,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/unread-notification-count',
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
},
|
||||
revision,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,48 +188,36 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async connectWifiRaw (params: RR.ConnectWifiReq): Promise<RR.ConnectWifiRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/selected',
|
||||
value: params.ssid,
|
||||
},
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/connected',
|
||||
value: params.ssid,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/selected',
|
||||
value: params.ssid,
|
||||
},
|
||||
}
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/connected',
|
||||
value: params.ssid,
|
||||
},
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async deleteWifiRaw (params: RR.DeleteWifiReq): Promise<RR.DeleteWifiRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/selected',
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/connected',
|
||||
value: null,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/selected',
|
||||
value: null,
|
||||
},
|
||||
}
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/wifi/connected',
|
||||
value: null,
|
||||
},
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
// ssh
|
||||
@@ -258,20 +241,14 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async createBackupRaw (params: RR.CreateBackupReq): Promise<RR.CreateBackupRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.BackingUp,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.BackingUp,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async restoreBackupRaw (params: RR.RestoreBackupReq): Promise<RR.RestoreBackupRes> {
|
||||
@@ -308,7 +285,6 @@ export class MockApiService extends ApiService {
|
||||
const pkg: PackageDataEntry = {
|
||||
...Mock.bitcoinproxy,
|
||||
state: PackageState.Installing,
|
||||
// installed: undefined,
|
||||
'install-progress': {
|
||||
size: 100,
|
||||
downloaded: 10,
|
||||
@@ -319,20 +295,14 @@ export class MockApiService extends ApiService {
|
||||
'read-complete': false,
|
||||
},
|
||||
}
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.ADD,
|
||||
path: `/package-data/${params.id}`,
|
||||
value: pkg,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.ADD,
|
||||
path: `/package-data/${params.id}`,
|
||||
value: pkg,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async dryUpdatePackage (params: RR.DryUpdatePackageReq): Promise<RR.DryUpdatePackageRes> {
|
||||
@@ -352,43 +322,31 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async setPackageConfigRaw (params: RR.SetPackageConfigReq): Promise<RR.SetPackageConfigRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/configured`,
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Running,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/configured`,
|
||||
value: true,
|
||||
},
|
||||
}
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Running,
|
||||
},
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async restorePackageRaw (params: RR.RestorePackageReq): Promise<RR.RestorePackageRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Restoring,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Restoring,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async executePackageAction (params: RR.ExecutePackageActionReq): Promise<RR.ExecutePackageActionRes> {
|
||||
@@ -403,20 +361,14 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async startPackageRaw (params: RR.StartPackageReq): Promise<RR.StartPackageRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Running,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Running,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async dryStopPackage (params: RR.DryStopPackageReq): Promise<RR.DryStopPackageRes> {
|
||||
@@ -426,20 +378,26 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async stopPackageRaw (params: RR.StopPackageReq): Promise<RR.StopPackageRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Stopping,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Stopping,
|
||||
},
|
||||
}
|
||||
]
|
||||
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
setTimeout(() => {
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/installed/status/main/status`,
|
||||
value: PackageMainStatus.Stopped,
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}, 2000)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
async dryRemovePackage (params: RR.DryRemovePackageReq): Promise<RR.DryRemovePackageRes> {
|
||||
@@ -449,20 +407,14 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async removePackageRaw (params: RR.RemovePackageReq): Promise<RR.RemovePackageRes> {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
response: null,
|
||||
revision: {
|
||||
id: this.nextSequence(),
|
||||
patch: [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/state`,
|
||||
value: PackageState.Removing,
|
||||
},
|
||||
],
|
||||
expireId: null,
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: `/package-data/${params.id}/state`,
|
||||
value: PackageState.Removing,
|
||||
},
|
||||
}
|
||||
]
|
||||
return this.http.rpcRequest({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise<RR.DryConfigureDependencyRes> {
|
||||
@@ -473,7 +425,7 @@ export class MockApiService extends ApiService {
|
||||
// marketplace
|
||||
|
||||
async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise<RR.GetMarketplaceDataRes> {
|
||||
const registryURL = configService.mocks.registryURL
|
||||
const registryURL = getMarketURL('package', this.patch.data)
|
||||
if (!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return {
|
||||
@@ -481,47 +433,36 @@ export class MockApiService extends ApiService {
|
||||
}
|
||||
}
|
||||
const url = `${registryURL}/marketplace/data`
|
||||
let md = await this.http.simpleGet(url)
|
||||
return (md as any)
|
||||
return this.http.simpleGet<RR.GetMarketplaceDataRes>(url)
|
||||
}
|
||||
|
||||
async getEos (params: RR.GetMarketplaceEOSReq): Promise<RR.GetMarketplaceEOSRes> {
|
||||
const registryURL = configService.mocks.registryURL
|
||||
const registryURL = getMarketURL('eos', this.patch.data)
|
||||
if (!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.MarketplaceEos
|
||||
}
|
||||
const url = `${registryURL}/sys/version/eos`
|
||||
let eos = await this.http.simpleGet(url)
|
||||
return (eos as any)
|
||||
return this.http.simpleGet<RR.GetMarketplaceEOSRes>(url)
|
||||
}
|
||||
|
||||
async getAvailableList (params: RR.GetAvailableListReq): Promise<RR.GetAvailableListRes> {
|
||||
const registryURL = configService.mocks.registryURL
|
||||
async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise<RR.GetMarketplacePackagesRes> {
|
||||
const registryURL = getMarketURL('package', this.patch.data)
|
||||
if (!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.AvailableList
|
||||
}
|
||||
const url = `${registryURL}/marketplace/available/list?${params.category ? `category=${params.category}` : ''}&per-page=${params['per-page'] || '20'}&page=${params.page || '1'}&query=${params.query || ''}`
|
||||
let av = await this.http.simpleGet(url)
|
||||
return (av as any).services
|
||||
const url = `${registryURL}/marketplace/packages`
|
||||
return this.http.simpleGet<RR.GetMarketplacePackagesRes>(url, params)
|
||||
}
|
||||
|
||||
async getAvailableShow (params: RR.GetAvailableShowReq): Promise<RR.GetAvailableShowRes> {
|
||||
const registryURL = configService.mocks.registryURL
|
||||
async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise<RR.GetReleaseNotesRes> {
|
||||
const registryURL = getMarketURL('package', this.patch.data)
|
||||
if (!registryURL) {
|
||||
await pauseFor(2000)
|
||||
return Mock.AvailableShow[params.id][params.version || 'latest']
|
||||
return Mock.ReleaseNotes
|
||||
}
|
||||
const url = `${registryURL}/marketplace/available?id=${params.id}`
|
||||
let res = await this.http.simpleGet(url)
|
||||
console.log('res RES RES', res)
|
||||
return (res as any)
|
||||
}
|
||||
|
||||
private nextSequence () {
|
||||
console.log('next')
|
||||
this.sequence++
|
||||
return this.sequence
|
||||
const url = `${registryURL}/marketplace/release-notes`
|
||||
return this.http.simpleGet<RR.GetReleaseNotesRes>(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DependencyErrorType, DockerIoFormat, Manifest, PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model'
|
||||
import { Metric, NotificationLevel, RR, ServerNotification, ServerNotifications } from './api-types'
|
||||
import { MarketplacePkg, Metric, NotificationLevel, RR, ServerNotification, ServerNotifications } from './api-types'
|
||||
|
||||
export module Mock {
|
||||
|
||||
@@ -9,29 +9,11 @@ export module Mock {
|
||||
'release-notes': { '1.0.0': 'Some **Markdown** release _notes_' },
|
||||
}
|
||||
|
||||
export const AvailableList: RR.GetAvailableListRes = [
|
||||
{
|
||||
id: 'bitcoind',
|
||||
title: 'Bitcoin Core',
|
||||
version: '0.21.1',
|
||||
descriptionShort: 'A Bitcoin full node by Bitcoin Core.',
|
||||
icon: 'assets/img/service-icons/bitcoind.png',
|
||||
},
|
||||
{
|
||||
id: 'lnd',
|
||||
title: 'LND',
|
||||
version: '0.11.1',
|
||||
descriptionShort: 'A BOLT-compliant, lightning network node.',
|
||||
icon: 'assets/img/service-icons/lnd.png',
|
||||
},
|
||||
{
|
||||
id: 'bitcoin-proxy',
|
||||
title: 'Bitcoin Proxy',
|
||||
version: '0.2.2',
|
||||
descriptionShort: 'A super charger for your Bitcoin node.',
|
||||
icon: 'assets/img/service-icons/bitcoin-proxy.png',
|
||||
},
|
||||
]
|
||||
export const ReleaseNotes: RR.GetReleaseNotesRes = {
|
||||
'0.19.2': 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
|
||||
'0.19.1': 'release notes for Bitcoin 0.19.1',
|
||||
'0.19.0': 'release notes for Bitcoin 0.19.0',
|
||||
}
|
||||
|
||||
export const MockManifestBitcoind: Manifest = {
|
||||
id: 'bitcoind',
|
||||
@@ -395,7 +377,7 @@ export module Mock {
|
||||
|
||||
export const AvailableShow: {
|
||||
[id: string]: {
|
||||
[version: string]: RR.GetAvailableShowRes
|
||||
[version: string]: MarketplacePkg
|
||||
}
|
||||
} = {
|
||||
'bitcoind': {
|
||||
@@ -410,11 +392,6 @@ export module Mock {
|
||||
categories: ['bitcoin', 'cryptocurrency'],
|
||||
versions: ['0.19.0', '0.20.0', '0.21.0'],
|
||||
'dependency-metadata': { },
|
||||
'release-notes': {
|
||||
'0.19.2': 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
|
||||
'0.19.1': 'release notes for Bitcoin 0.19.1',
|
||||
'0.19.0': 'release notes for Bitcoin 0.19.0',
|
||||
},
|
||||
},
|
||||
'0.20.0': {
|
||||
icon: 'assets/img/service-icons/bitcoind.png',
|
||||
@@ -427,11 +404,6 @@ export module Mock {
|
||||
categories: ['bitcoin', 'cryptocurrency'],
|
||||
versions: ['0.19.0', '0.20.0', '0.21.0'],
|
||||
'dependency-metadata': { },
|
||||
'release-notes': {
|
||||
'0.19.2': 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
|
||||
'0.19.1': 'release notes for Bitcoin 0.19.1',
|
||||
'0.19.0': 'release notes for Bitcoin 0.19.0',
|
||||
},
|
||||
},
|
||||
'0.21.0': {
|
||||
icon: 'assets/img/service-icons/bitcoind.png',
|
||||
@@ -445,11 +417,6 @@ export module Mock {
|
||||
categories: ['bitcoin', 'cryptocurrency'],
|
||||
versions: ['0.19.0', '0.20.0', '0.21.0'],
|
||||
'dependency-metadata': { },
|
||||
'release-notes': {
|
||||
'0.19.2': 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
|
||||
'0.19.1': 'release notes for Bitcoin 0.19.1',
|
||||
'0.19.0': 'release notes for Bitcoin 0.19.0',
|
||||
},
|
||||
},
|
||||
'latest': {
|
||||
icon: 'assets/img/service-icons/bitcoind.png',
|
||||
@@ -462,11 +429,6 @@ export module Mock {
|
||||
categories: ['bitcoin', 'cryptocurrency'],
|
||||
versions: ['0.19.0', '0.20.0', '0.21.0'],
|
||||
'dependency-metadata': { },
|
||||
'release-notes': {
|
||||
'0.21.0': 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
|
||||
'0.20.0': 'release notes for Bitcoin 0.20.0',
|
||||
'0.19.2': 'release notes for Bitcoin 0.19.2',
|
||||
},
|
||||
},
|
||||
},
|
||||
'lnd': {
|
||||
@@ -491,11 +453,6 @@ export module Mock {
|
||||
icon: 'assets/img/service-icons/bitcoin-proxy.png',
|
||||
},
|
||||
},
|
||||
'release-notes': {
|
||||
'0.19.2': 'release notes for LND 0.19.2',
|
||||
'0.19.1': 'release notes for LND 0.19.1',
|
||||
'0.19.0': 'release notes for LND 0.19.0',
|
||||
},
|
||||
},
|
||||
'0.11.1': {
|
||||
icon: 'assets/img/service-icons/lnd.png',
|
||||
@@ -518,11 +475,6 @@ export module Mock {
|
||||
icon: 'assets/img/service-icons/bitcoin-proxy.png',
|
||||
},
|
||||
},
|
||||
'release-notes': {
|
||||
'0.19.2': 'release notes for LND 0.19.2',
|
||||
'0.19.1': 'release notes for LND 0.19.1',
|
||||
'0.19.0': 'release notes for LND 0.19.0',
|
||||
},
|
||||
},
|
||||
'latest': {
|
||||
icon: 'assets/img/service-icons/lnd.png',
|
||||
@@ -541,11 +493,6 @@ export module Mock {
|
||||
icon: 'assets/img/service-icons/bitcoin-proxy.png',
|
||||
},
|
||||
},
|
||||
'release-notes': {
|
||||
'0.19.2': 'release notes for LND 0.19.2',
|
||||
'0.19.1': 'release notes for LND 0.19.1',
|
||||
'0.19.0': 'release notes for LND 0.19.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
'bitcoin-proxy': {
|
||||
@@ -562,15 +509,12 @@ export module Mock {
|
||||
icon: 'assets/img/service-icons/bitcoind.png',
|
||||
},
|
||||
},
|
||||
'release-notes': {
|
||||
'0.19.2': 'release notes for btc proxy 0.19.2',
|
||||
'0.19.1': 'release notes for btc proxy 0.19.1',
|
||||
'0.19.0': 'release notes for btc proxy 0.19.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export const AvailableList: RR.GetMarketplacePackagesRes = Object.values(Mock.AvailableShow).map(service => service['latest'])
|
||||
|
||||
export const bitcoind: PackageDataEntry = {
|
||||
state: PackageState.Installed,
|
||||
'static-files': {
|
||||
@@ -731,8 +675,8 @@ export module Mock {
|
||||
selected: 'Goosers5G',
|
||||
connected: 'Goosers5G',
|
||||
},
|
||||
'package-registry': 'https://registry.start9.com',
|
||||
'system-registry': 'https://registry.start9.com',
|
||||
'package-marketplace': 'https://registry.start9.com',
|
||||
'eos-marketplace': 'https://registry.start9.com',
|
||||
'unread-notification-count': 4,
|
||||
specs: {
|
||||
CPU: 'Cortex-A72: 4 Cores @1500MHz',
|
||||
|
||||
Reference in New Issue
Block a user