Merge branch 'next/minor' of github.com:Start9Labs/start-os into feat/boot-param

This commit is contained in:
Aiden McClelland
2024-07-10 12:18:48 -06:00
343 changed files with 13365 additions and 11747 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,9 @@
import { Dump } from 'patch-db-client'
import { MarketplacePkg, StoreInfo } from '@start9labs/marketplace'
import { PackagePropertiesVersioned } from 'src/app/util/properties.util'
import { ConfigSpec } from 'src/app/pkg-config/config-types'
import { DataModel } from 'src/app/services/patch-db/data-model'
import { StartOSDiskInfo, LogsRes, ServerLogsReq } from '@start9labs/shared'
import { T } from '@start9labs/start-sdk'
import { CT, T } from '@start9labs/start-sdk'
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
export module RR {
@@ -12,7 +11,10 @@ export module RR {
export type WebsocketConfig<T> = Omit<WebSocketSubjectConfig<T>, 'url'>
// server state
// state
export type EchoReq = { message: string } // server.echo
export type EchoRes = string
export type ServerState = 'initializing' | 'error' | 'running'
@@ -225,7 +227,7 @@ export module RR {
export type InstallPackageRes = null
export type GetPackageConfigReq = { id: string } // package.config.get
export type GetPackageConfigRes = { spec: ConfigSpec; config: object }
export type GetPackageConfigRes = { spec: CT.InputSpec; config: object }
export type DrySetPackageConfigReq = { id: string; config: object } // package.config.set.dry
export type DrySetPackageConfigRes = Breakages
@@ -268,14 +270,17 @@ export module RR {
export type DryConfigureDependencyRes = {
oldConfig: object
newConfig: object
spec: ConfigSpec
spec: CT.InputSpec
}
export type SideloadPackageReq = {
manifest: T.Manifest
icon: string // base64
}
export type SideloadPacakgeRes = string //guid
export type SideloadPackageRes = {
upload: string // guid
progress: string // guid
}
// marketplace

View File

@@ -10,6 +10,8 @@ export abstract class ApiService {
// for sideloading packages
abstract uploadPackage(guid: string, body: Blob): Promise<string>
abstract uploadFile(body: Blob): Promise<string>
// websocket
abstract openWebsocket$<T>(
@@ -17,7 +19,9 @@ export abstract class ApiService {
config: RR.WebsocketConfig<T>,
): Observable<T>
// server state
// state
abstract echo(params: RR.EchoReq, url: string): Promise<RR.EchoRes>
abstract getState(): Promise<RR.ServerState>
@@ -241,7 +245,5 @@ export abstract class ApiService {
params: RR.DryConfigureDependencyReq,
): Promise<RR.DryConfigureDependencyRes>
abstract sideloadPackage(
params: RR.SideloadPackageReq,
): Promise<RR.SideloadPacakgeRes>
abstract sideloadPackage(): Promise<RR.SideloadPackageRes>
}

View File

@@ -7,6 +7,7 @@ import {
RpcError,
RPCOptions,
} from '@start9labs/shared'
import { PATCH_CACHE } from 'src/app/services/patch-db/patch-db-source'
import { ApiService } from './embassy-api.service'
import { RR } from './api.types'
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
@@ -16,7 +17,7 @@ import { Observable, filter, firstValueFrom } from 'rxjs'
import { AuthService } from '../auth.service'
import { DOCUMENT } from '@angular/common'
import { DataModel } from '../patch-db/data-model'
import { PatchDB, pathFromArray } from 'patch-db-client'
import { Dump, pathFromArray } from 'patch-db-client'
@Injectable()
export class LiveApiService extends ApiService {
@@ -25,7 +26,7 @@ export class LiveApiService extends ApiService {
private readonly http: HttpService,
private readonly config: ConfigService,
private readonly auth: AuthService,
private readonly patch: PatchDB<DataModel>,
@Inject(PATCH_CACHE) private readonly cache$: Observable<Dump<DataModel>>,
) {
super()
; (window as any).rpcClient = this
@@ -52,6 +53,15 @@ export class LiveApiService extends ApiService {
})
}
async uploadFile(body: Blob): Promise<string> {
return this.httpRequest({
method: Method.POST,
body,
url: `/rest/upload`,
responseType: 'text',
})
}
// websocket
openWebsocket$<T>(
@@ -70,6 +80,10 @@ export class LiveApiService extends ApiService {
// state
async echo(params: RR.EchoReq, url: string): Promise<RR.EchoRes> {
return this.rpcRequest({ method: 'echo', params }, url)
}
async getState(): Promise<RR.ServerState> {
return this.rpcRequest({ method: 'state', params: {} })
}
@@ -457,12 +471,10 @@ export class LiveApiService extends ApiService {
})
}
async sideloadPackage(
params: RR.SideloadPackageReq,
): Promise<RR.SideloadPacakgeRes> {
async sideloadPackage(): Promise<RR.SideloadPackageRes> {
return this.rpcRequest({
method: 'package.sideload',
params,
params: {},
})
}
@@ -484,7 +496,7 @@ export class LiveApiService extends ApiService {
const patchSequence = res.headers.get('x-patch-sequence')
if (patchSequence)
await firstValueFrom(
this.patch.cache$.pipe(filter(({ id }) => id >= Number(patchSequence))),
this.cache$.pipe(filter(({ id }) => id >= Number(patchSequence))),
)
return body.result

View File

@@ -118,7 +118,17 @@ export class MockApiService extends ApiService {
}
}
// server state
// state
async echo(params: RR.EchoReq, url: string): Promise<RR.EchoRes> {
if (url) {
const num = Math.floor(Math.random() * 10) + 1
if (num > 8) return params.message
throw new Error()
}
await pauseFor(2000)
return params.message
}
private stateIndex = 0
async getState(): Promise<RR.ServerState> {
@@ -758,7 +768,7 @@ export class MockApiService extends ApiService {
await pauseFor(2000)
return {
config: Mock.MockConfig,
spec: Mock.ConfigSpec,
spec: await Mock.getInputSpec(),
}
}
@@ -1048,15 +1058,21 @@ export class MockApiService extends ApiService {
return {
oldConfig: Mock.MockConfig,
newConfig: Mock.MockDependencyConfig,
spec: Mock.ConfigSpec,
spec: await Mock.getInputSpec(),
}
}
async sideloadPackage(
params: RR.SideloadPackageReq,
): Promise<RR.SideloadPacakgeRes> {
async sideloadPackage(): Promise<RR.SideloadPackageRes> {
await pauseFor(2000)
return '4120e092-05ab-4de2-9fbd-c3f1f4b1df9e' // no significance, randomly generated
return {
upload: '4120e092-05ab-4de2-9fbd-c3f1f4b1df9e', // no significance, randomly generated
progress: '5120e092-05ab-4de2-9fbd-c3f1f4b1df9e', // no significance, randomly generated
}
}
async uploadFile(body: Blob): Promise<string> {
await pauseFor(2000)
return 'returnedhash'
}
private async initProgress(): Promise<T.FullProgress> {

View File

@@ -127,7 +127,7 @@ export const mockPatchData: DataModel = {
},
},
},
actions: {}, // @TODO
actions: {},
serviceInterfaces: {
ui: {
id: 'ui',
@@ -185,7 +185,107 @@ export const mockPatchData: DataModel = {
},
},
currentDependencies: {},
hosts: {},
hosts: {
abcdefg: {
kind: 'multi',
bindings: [],
addresses: [],
hostnameInfo: {
80: [
{
kind: 'ip',
networkInterfaceId: 'eth0',
public: false,
hostname: {
kind: 'local',
value: 'adjective-noun.local',
port: null,
sslPort: 1234,
},
},
{
kind: 'ip',
networkInterfaceId: 'wlan0',
public: false,
hostname: {
kind: 'local',
value: 'adjective-noun.local',
port: null,
sslPort: 1234,
},
},
{
kind: 'ip',
networkInterfaceId: 'eth0',
public: false,
hostname: {
kind: 'ipv4',
value: '10.0.0.1',
port: null,
sslPort: 1234,
},
},
{
kind: 'ip',
networkInterfaceId: 'wlan0',
public: false,
hostname: {
kind: 'ipv4',
value: '10.0.0.2',
port: null,
sslPort: 1234,
},
},
{
kind: 'ip',
networkInterfaceId: 'eth0',
public: false,
hostname: {
kind: 'ipv6',
value: '[FE80:CD00:0000:0CDE:1257:0000:211E:729CD]',
port: null,
sslPort: 1234,
},
},
{
kind: 'ip',
networkInterfaceId: 'wlan0',
public: false,
hostname: {
kind: 'ipv6',
value: '[FE80:CD00:0000:0CDE:1257:0000:211E:1234]',
port: null,
sslPort: 1234,
},
},
{
kind: 'onion',
hostname: {
value: 'bitcoin-p2p.onion',
port: 80,
sslPort: 443,
},
},
],
},
},
bcdefgh: {
kind: 'multi',
bindings: [],
addresses: [],
hostnameInfo: {
8332: [],
},
},
cdefghi: {
kind: 'multi',
bindings: [],
addresses: [],
hostnameInfo: {
8333: [],
},
},
},
storeExposedDependents: [],
registry: 'https://registry.start9.com/',
developerKey: 'developer-key',