fix: fix build after minor merged into major

This commit is contained in:
waterplea
2024-08-15 12:40:49 +04:00
parent b43ad93c54
commit a730543c76
189 changed files with 714 additions and 3652 deletions

View File

@@ -24,7 +24,7 @@ export class ActionsService {
private readonly loader = inject(LoadingService)
private readonly api = inject(ApiService)
private readonly formDialog = inject(FormDialogService)
private readonly patch = inject(PatchDB<DataModel>)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
configure(manifest: T.Manifest): void {
this.formDialog.open<PackageConfigData>(ConfigModal, {

View File

@@ -1021,7 +1021,7 @@ export module Mock {
username: 'TestUser',
mountable: false,
// @TODO Matt Provide mock for startOs
startOs: null,
startOs: {},
},
{
id: 'ftcvewdnkemfksdm',
@@ -1030,7 +1030,7 @@ export module Mock {
provider: 'dropbox',
path: '/Home/backups',
mountable: true,
startOs: null,
startOs: {},
},
{
id: 'csgashbdjkasnd',
@@ -1040,7 +1040,7 @@ export module Mock {
path: '/Desktop/embassy-backups-2',
username: 'TestUser',
mountable: true,
startOs: null,
startOs: {},
},
{
id: 'powjefhjbnwhdva',

View File

@@ -418,7 +418,8 @@ export module RR {
// marketplace
export type GetMarketplaceInfoReq = { serverId: string }
export type GetMarketplaceInfoRes = StoreInfo
// @TODO Matt fix type
export type GetMarketplaceInfoRes = any
export type GetMarketplaceEosReq = { serverId: string }
// @TODO Matt fix type

View File

@@ -3,10 +3,11 @@ import {
GetPackagesRes,
MarketplacePkg,
} from '@start9labs/marketplace'
import { RPCOptions } from '@start9labs/shared'
import { Log, RPCOptions } from '@start9labs/shared'
import { T } from '@start9labs/start-sdk'
import { Observable } from 'rxjs'
import { BackupTargetType, RR } from './api.types'
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
import { BackupTargetType, Metrics, RR } from './api.types'
export abstract class ApiService {
// http
@@ -84,6 +85,13 @@ export abstract class ApiService {
): Promise<RR.FollowServerLogsRes>
// server
abstract openLogsWebsocket$(
config: WebSocketSubjectConfig<Log>,
): Observable<Log>
abstract openMetricsWebsocket$(
config: WebSocketSubjectConfig<Metrics>,
): Observable<Metrics>
abstract getSystemTime(
params: RR.GetSystemTimeReq,

View File

@@ -3,15 +3,16 @@ import {
HttpOptions,
HttpService,
isRpcError,
Log,
Method,
RpcError,
RPCOptions,
} from '@start9labs/shared'
import { PATCH_CACHE } from 'src/app/services/patch-db/patch-db-source'
import { ApiService } from './embassy-api.service'
import { BackupTargetType, RR } from './api.types'
import { BackupTargetType, Metrics, RR } from './api.types'
import { ConfigService } from '../config.service'
import { webSocket } from 'rxjs/webSocket'
import { webSocket, WebSocketSubjectConfig } from 'rxjs/webSocket'
import { Observable, filter, firstValueFrom } from 'rxjs'
import { AuthService } from '../auth.service'
import { DOCUMENT } from '@angular/common'
@@ -92,6 +93,16 @@ export class LiveApiService extends ApiService {
}
// websocket
// @TODO Matt which of these 2 APIs should we use?
private openWebsocket<T>(config: WebSocketSubjectConfig<T>): Observable<T> {
const { location } = this.document.defaultView!
const protocol = location.protocol === 'http:' ? 'ws' : 'wss'
const host = location.host
config.url = `${protocol}://${host}/ws${config.url}`
return webSocket(config)
}
openWebsocket$<T>(
guid: string,
@@ -210,6 +221,15 @@ export class LiveApiService extends ApiService {
}
// server
openLogsWebsocket$(config: WebSocketSubjectConfig<Log>): Observable<Log> {
return this.openWebsocket(config)
}
openMetricsWebsocket$(
config: WebSocketSubjectConfig<Metrics>,
): Observable<Metrics> {
return this.openWebsocket(config)
}
async getSystemTime(
params: RR.GetSystemTimeReq,

View File

@@ -1,10 +1,5 @@
import { Injectable } from '@angular/core'
import {
pauseFor,
Log,
RPCErrorDetails,
RPCOptions,
} from '@start9labs/shared'
import { pauseFor, Log, RPCErrorDetails, RPCOptions } from '@start9labs/shared'
import { ApiService } from './embassy-api.service'
import {
Operation,
@@ -281,6 +276,17 @@ export class MockApiService extends ApiService {
// server
openLogsWebsocket$(config: WebSocketSubjectConfig<Log>): Observable<Log> {
return interval(50).pipe(
map((_, index) => {
// mock fire open observer
if (index === 0) config.openObserver?.next(new Event(''))
if (index === 100) throw new Error('HAAHHA')
return Mock.ServerLogs[0]
}),
)
}
openMetricsWebsocket$(
config: WebSocketSubjectConfig<Metrics>,
): Observable<Metrics> {

View File

@@ -1,6 +1,6 @@
import { inject, Injectable } from '@angular/core'
import { AbstractMarketplaceService } from '@start9labs/marketplace'
import { Emver } from '@start9labs/shared'
import { Exver } from '@start9labs/shared'
import { PatchDB } from 'patch-db-client'
import {
combineLatest,
@@ -26,8 +26,8 @@ import { getManifest } from 'src/app/utils/get-package-data'
})
export class BadgeService {
private readonly notifications = inject(NotificationService)
private readonly emver = inject(Emver)
private readonly patch = inject(PatchDB<DataModel>)
private readonly exver = inject(Exver)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
private readonly settings$ = combineLatest([
this.patch.watch$('serverInfo', 'ntpSynced'),
inject(EOSService).updateAvailable$,
@@ -36,7 +36,7 @@ export class BadgeService {
AbstractMarketplaceService,
) as MarketplaceService
private readonly local$ = inject(ConnectionService).connected$.pipe(
private readonly local$ = inject(ConnectionService).pipe(
filter(Boolean),
switchMap(() => this.patch.watch$('packageData').pipe(first())),
switchMap(outer =>
@@ -67,10 +67,12 @@ export class BadgeService {
Object.entries(marketplace).reduce(
(list, [_, store]) =>
store?.packages.reduce(
(result, { manifest: { id, version } }) =>
(result, { id, version }) =>
local[id] &&
this.emver.compare(version, getManifest(local[id]).version) ===
1
this.exver.compareExver(
version,
getManifest(local[id]).version,
) === 1
? result.add(id)
: result,
list,

View File

@@ -20,7 +20,7 @@ export interface Breadcrumb {
providedIn: 'root',
})
export class BreadcrumbsService extends BehaviorSubject<readonly Breadcrumb[]> {
private readonly patch = inject(PatchDB<DataModel>)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
constructor() {
super([])

View File

@@ -82,17 +82,14 @@ export class ConfigService {
/** ${scheme}://${username}@${host}:${externalPort}${suffix} */
launchableAddress(
interfaces: PackageDataEntry['serviceInterfaces'],
ui: T.ServiceInterface,
hosts: PackageDataEntry['hosts'],
): string {
const ui = Object.values(interfaces).find(
i =>
i.type === 'ui' &&
(i.addressInfo.scheme === 'http' ||
i.addressInfo.sslScheme === 'https'),
) // TODO select if multiple
if (!ui) return ''
if (
ui.type !== 'ui' ||
(ui.addressInfo.scheme !== 'http' && ui.addressInfo.sslScheme !== 'https')
)
return ''
const hostnameInfo =
hosts[ui.addressInfo.hostId]?.hostnameInfo[ui.addressInfo.internalPort]

View File

@@ -168,21 +168,11 @@ export class MarketplaceService implements AbstractMarketplaceService {
this.marketplace$.pipe(
map(m => m[url]),
filter(Boolean),
map(({ info, packages }) => {
const categories = new Set<string>()
if (info.categories.includes('featured')) categories.add('featured')
categories.add('all')
info.categories.forEach(c => categories.add(c))
return {
url,
info: {
...info,
categories: Array.from(categories),
},
packages,
}
}),
map(({ info, packages }) => ({
url,
info,
packages,
})),
),
),
)

View File

@@ -1,11 +1,11 @@
import { inject, Injectable } from '@angular/core'
import { WINDOW } from '@ng-web-apis/common'
import { WA_WINDOW } from '@ng-web-apis/common'
import { fromEvent, merge, Observable, shareReplay } from 'rxjs'
import { distinctUntilChanged, map, startWith } from 'rxjs/operators'
@Injectable({ providedIn: 'root' })
export class NetworkService extends Observable<boolean> {
private readonly win = inject(WINDOW)
private readonly win = inject(WA_WINDOW)
private readonly stream$ = merge(
fromEvent(this.win, 'online'),
fromEvent(this.win, 'offline'),

View File

@@ -14,7 +14,7 @@ import { DataModel } from 'src/app/services/patch-db/data-model'
@Injectable({ providedIn: 'root' })
export class NotificationService {
private readonly patch = inject(PatchDB<DataModel>)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
private readonly errorService = inject(ErrorService)
private readonly api = inject(ApiService)
private readonly dialogs = inject(TuiDialogService)

View File

@@ -1,16 +0,0 @@
import { PatchDB } from 'patch-db-client'
import { Injector } from '@angular/core'
import { PATCH_SOURCE, sourceFactory } from './patch-db.factory'
export const PATCH_DB_PROVIDERS = [
{
provide: PATCH_SOURCE,
deps: [Injector],
useFactory: sourceFactory,
},
{
provide: PatchDB,
deps: [PATCH_SOURCE],
useClass: PatchDB,
},
]

View File

@@ -1,7 +1,7 @@
import { inject, Injectable } from '@angular/core'
import { CanActivateFn, IsActiveMatchOptions, Router } from '@angular/router'
import { ALWAYS_TRUE_HANDLER } from '@taiga-ui/cdk'
import { TuiAlertService, TuiNotification } from '@taiga-ui/core'
import { TUI_TRUE_HANDLER } from '@taiga-ui/cdk'
import { TuiAlertService } from '@taiga-ui/core'
import {
BehaviorSubject,
combineLatest,
@@ -94,8 +94,8 @@ export class StateService extends Observable<RR.ServerState | null> {
this.alerts
.open('Trying to reach server', {
label: 'State unknown',
autoClose: false,
status: TuiNotification.Error,
autoClose: 0,
status: 'error',
})
.pipe(
takeUntil(
@@ -106,7 +106,7 @@ export class StateService extends Observable<RR.ServerState | null> {
),
this.alerts.open('Connection restored', {
label: 'Server reached',
status: TuiNotification.Success,
status: 'success',
}),
),
),
@@ -131,6 +131,6 @@ export function stateNot(state: RR.ServerState[]): CanActivateFn {
return () =>
inject(StateService).pipe(
filter(current => !current || !state.includes(current)),
map(ALWAYS_TRUE_HANDLER),
map(TUI_TRUE_HANDLER),
)
}

View File

@@ -1,5 +1,5 @@
import { Inject, Injectable } from '@angular/core'
import { WINDOW } from '@ng-web-apis/common'
import { WA_WINDOW } from '@ng-web-apis/common'
import { PatchDB } from 'patch-db-client'
import { filter, take, BehaviorSubject } from 'rxjs'
import { ApiService } from './api/embassy-api.service'
@@ -12,7 +12,7 @@ export class ThemeSwitcherService extends BehaviorSubject<string> {
constructor(
private readonly patch: PatchDB<DataModel>,
private readonly embassyApi: ApiService,
@Inject(WINDOW) private readonly windowRef: Window,
@Inject(WA_WINDOW) private readonly windowRef: Window,
) {
super('Dark')

View File

@@ -16,7 +16,7 @@ import { DataModel } from 'src/app/services/patch-db/data-model'
providedIn: 'root',
})
export class TimeService {
private readonly patch = inject(PatchDB<DataModel>)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
private readonly time$ = defer(() =>
inject(ApiService).getSystemTime({}),
).pipe(