53 lines · 1.5 KB · TypeScript
RawDownload
import type { EnvironmentId, ExecutionEnvironmentDescriptor } from "@t3tools/contracts"; export interface KnownEnvironmentConnectionTarget {  readonly httpBaseUrl: string;  readonly wsBaseUrl: string;} export type KnownEnvironmentSource = "configured" | "desktop-managed" | "manual" | "window-origin"; export interface KnownEnvironment {  readonly id: string;  readonly label: string;  readonly source: KnownEnvironmentSource;  readonly environmentId?: EnvironmentId;  readonly target: KnownEnvironmentConnectionTarget;} export function createKnownEnvironment(input: {  readonly id?: string;  readonly label: string;  readonly source?: KnownEnvironmentSource;  readonly target: KnownEnvironmentConnectionTarget;}): KnownEnvironment {  return {    id: input.id ?? `ws:${input.label}`,    label: input.label,    source: input.source ?? "manual",    target: input.target,  };} export function getKnownEnvironmentWsBaseUrl(  environment: KnownEnvironment | null | undefined,): string | null {  return environment?.target.wsBaseUrl ?? null;} export function getKnownEnvironmentHttpBaseUrl(  environment: KnownEnvironment | null | undefined,): string | null {  return environment?.target.httpBaseUrl ?? null;} export function attachEnvironmentDescriptor(  environment: KnownEnvironment,  descriptor: ExecutionEnvironmentDescriptor,): KnownEnvironment {  return {    ...environment,    environmentId: descriptor.environmentId,    label: descriptor.label,  };}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t