Files
orca/src/shared/runtime-environment-host-kind.ts
T
Neil c57e530a50 refactor(runtime-environments): one exhaustive host-kind classifier for connect, remove, call readiness, hint and phone relay (#29500)
* test(runtime-environments): pin connect, remove, call readiness, hint and phone relay per host kind

* refactor(runtime-environments): dispatch on one exhaustive host-kind classifier

* test: avoid type assertions in host-kind characterization fakes

* refactor(runtime-environments): keep service-owned connect/remove in one module; tighten characterization tests

* style: break, not bare return, in host service ops switches
2026-10-16 00:51:10 -07:00

30 lines
1.1 KiB
TypeScript

import type { OrcadDeploymentLink } from './runtime-environments'
import type { OrcadWslDeploymentLink } from './wsl-host-deployment-link'
/**
* What kind of host serves a runtime environment. Switch on `kind` (lint requires the switch to be
* exhaustive), so a new kind fails the build at every switch on it.
* `network`: reached over the network or an SSH tunnel (paired, SSH access, SSH-managed).
* `wsl`: a distro on this computer, reached over the wsl.exe bridge.
*/
export type RuntimeEnvironmentHost<T> =
| { kind: 'network'; environment: T }
| { kind: 'wsl'; environment: T; deployment: OrcadWslDeploymentLink }
export function classifyRuntimeEnvironmentHost<
T extends { orcadDeployment?: OrcadDeploymentLink | null }
>(environment: T): RuntimeEnvironmentHost<T> {
const deployment = environment.orcadDeployment
if (!deployment) {
return { kind: 'network', environment }
}
switch (deployment.kind) {
// Why undefined: SSH deployment links are persisted without their kind.
case undefined:
case 'ssh':
return { kind: 'network', environment }
case 'wsl':
return { kind: 'wsl', environment, deployment }
}
}