mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
ditch more FE enums for clarity and cleanliness
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
} from './patch-db/data-model'
|
||||
import * as deepEqual from 'fast-deep-equal'
|
||||
import { isInstalled } from '../util/get-package-data'
|
||||
import { DependencyError } from './api/api.types'
|
||||
|
||||
export type AllDependencyErrors = Record<string, PkgDependencyErrors>
|
||||
export type PkgDependencyErrors = Record<string, DependencyError | null>
|
||||
@@ -78,7 +79,7 @@ export class DepErrorService {
|
||||
// not installed
|
||||
if (!dep || dep.stateInfo.state !== 'installed') {
|
||||
return {
|
||||
type: DependencyErrorType.NotInstalled,
|
||||
type: 'notInstalled',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ export class DepErrorService {
|
||||
// incorrect version
|
||||
if (!this.emver.satisfies(depManifest.version, versionSpec)) {
|
||||
return {
|
||||
type: DependencyErrorType.IncorrectVersion,
|
||||
type: 'incorrectVersion',
|
||||
expected: versionSpec,
|
||||
received: depManifest.version,
|
||||
}
|
||||
@@ -97,7 +98,7 @@ export class DepErrorService {
|
||||
// invalid config
|
||||
if (Object.values(pkg.status.dependencyConfigErrors).some(err => !!err)) {
|
||||
return {
|
||||
type: DependencyErrorType.ConfigUnsatisfied,
|
||||
type: 'configUnsatisfied',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ export class DepErrorService {
|
||||
// not running
|
||||
if (depStatus !== 'running' && depStatus !== 'starting') {
|
||||
return {
|
||||
type: DependencyErrorType.NotRunning,
|
||||
type: 'notRunning',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +116,11 @@ export class DepErrorService {
|
||||
// health check failure
|
||||
if (depStatus === 'running' && currentDep.kind === 'running') {
|
||||
for (let id of currentDep.healthChecks) {
|
||||
if (dep.status.main.health[id]?.result !== 'success') {
|
||||
const check = dep.status.main.health[id]
|
||||
if (check?.result !== 'success') {
|
||||
return {
|
||||
type: DependencyErrorType.HealthChecksFailed,
|
||||
type: 'healthChecksFailed',
|
||||
check,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +133,7 @@ export class DepErrorService {
|
||||
|
||||
if (transitiveError) {
|
||||
return {
|
||||
type: DependencyErrorType.Transitive,
|
||||
type: 'transitive',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,46 +157,3 @@ function dependencyDepth(
|
||||
depth,
|
||||
)
|
||||
}
|
||||
|
||||
export type DependencyError =
|
||||
| DependencyErrorNotInstalled
|
||||
| DependencyErrorNotRunning
|
||||
| DependencyErrorIncorrectVersion
|
||||
| DependencyErrorConfigUnsatisfied
|
||||
| DependencyErrorHealthChecksFailed
|
||||
| DependencyErrorTransitive
|
||||
|
||||
export enum DependencyErrorType {
|
||||
NotInstalled = 'notInstalled',
|
||||
NotRunning = 'notRunning',
|
||||
IncorrectVersion = 'incorrectVersion',
|
||||
ConfigUnsatisfied = 'configUnsatisfied',
|
||||
HealthChecksFailed = 'healthChecksFailed',
|
||||
Transitive = 'transitive',
|
||||
}
|
||||
|
||||
export interface DependencyErrorNotInstalled {
|
||||
type: DependencyErrorType.NotInstalled
|
||||
}
|
||||
|
||||
export interface DependencyErrorNotRunning {
|
||||
type: DependencyErrorType.NotRunning
|
||||
}
|
||||
|
||||
export interface DependencyErrorIncorrectVersion {
|
||||
type: DependencyErrorType.IncorrectVersion
|
||||
expected: string // version range
|
||||
received: string // version
|
||||
}
|
||||
|
||||
export interface DependencyErrorConfigUnsatisfied {
|
||||
type: DependencyErrorType.ConfigUnsatisfied
|
||||
}
|
||||
|
||||
export interface DependencyErrorHealthChecksFailed {
|
||||
type: DependencyErrorType.HealthChecksFailed
|
||||
}
|
||||
|
||||
export interface DependencyErrorTransitive {
|
||||
type: DependencyErrorType.Transitive
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user