feat(web-probe): add semantic YAML origins
This commit is contained in:
@@ -991,6 +991,11 @@ export function readWebObserveIndex(): Record<string, WebObserveIndexEntry> {
|
||||
workspace,
|
||||
stateDir,
|
||||
url: typeof recordValue.url === "string" ? recordValue.url : "",
|
||||
originName: recordValue.originName === "internal" || recordValue.originName === "public" || recordValue.originName === "custom" ? recordValue.originName : null,
|
||||
originMode: recordValue.originMode === "k8s-service-cluster-ip" || recordValue.originMode === "public" || recordValue.originMode === "custom-url" ? recordValue.originMode : null,
|
||||
originConfigPath: typeof recordValue.originConfigPath === "string" ? recordValue.originConfigPath : null,
|
||||
browserProxyMode: recordValue.browserProxyMode === "auto" || recordValue.browserProxyMode === "direct" ? recordValue.browserProxyMode : null,
|
||||
browserProxyModeSource: recordValue.browserProxyModeSource === "cli" || recordValue.browserProxyModeSource === "yaml-origin" || recordValue.browserProxyModeSource === "yaml-web-probe" || recordValue.browserProxyModeSource === "default" ? recordValue.browserProxyModeSource : null,
|
||||
targetPath: typeof recordValue.targetPath === "string" ? recordValue.targetPath : "",
|
||||
status: typeof recordValue.status === "string" ? recordValue.status : null,
|
||||
pid: typeof recordValue.pid === "number" ? recordValue.pid : null,
|
||||
@@ -1079,6 +1084,11 @@ export function discoverWebObserveIndexEntryOnTarget(id: string, node: string, l
|
||||
" id: jobId,",
|
||||
" stateDir,",
|
||||
" url: typeof manifest.baseUrl === 'string' ? manifest.baseUrl : '',",
|
||||
" originName: typeof manifest.origin?.name === 'string' ? manifest.origin.name : null,",
|
||||
" originMode: typeof manifest.origin?.mode === 'string' ? manifest.origin.mode : null,",
|
||||
" originConfigPath: typeof manifest.origin?.configPath === 'string' ? manifest.origin.configPath : null,",
|
||||
" browserProxyMode: typeof manifest.origin?.browserProxyMode === 'string' ? manifest.origin.browserProxyMode : null,",
|
||||
" browserProxyModeSource: typeof manifest.origin?.browserProxyModeSource === 'string' ? manifest.origin.browserProxyModeSource : null,",
|
||||
" targetPath: typeof manifest.targetPath === 'string' ? manifest.targetPath : '',",
|
||||
" status: typeof manifest.status === 'string' ? manifest.status : null,",
|
||||
" pid,",
|
||||
@@ -1111,6 +1121,11 @@ export function discoverWebObserveIndexEntryOnTarget(id: string, node: string, l
|
||||
workspace: spec.workspace,
|
||||
stateDir,
|
||||
url: typeof entry.url === "string" ? entry.url : "",
|
||||
originName: entry.originName === "internal" || entry.originName === "public" || entry.originName === "custom" ? entry.originName : null,
|
||||
originMode: entry.originMode === "k8s-service-cluster-ip" || entry.originMode === "public" || entry.originMode === "custom-url" ? entry.originMode : null,
|
||||
originConfigPath: typeof entry.originConfigPath === "string" ? entry.originConfigPath : null,
|
||||
browserProxyMode: entry.browserProxyMode === "auto" || entry.browserProxyMode === "direct" ? entry.browserProxyMode : null,
|
||||
browserProxyModeSource: entry.browserProxyModeSource === "cli" || entry.browserProxyModeSource === "yaml-origin" || entry.browserProxyModeSource === "yaml-web-probe" || entry.browserProxyModeSource === "default" ? entry.browserProxyModeSource : null,
|
||||
targetPath: typeof entry.targetPath === "string" ? entry.targetPath : "",
|
||||
status: typeof entry.status === "string" ? entry.status : null,
|
||||
pid: typeof entry.pid === "number" ? entry.pid : null,
|
||||
@@ -1161,6 +1176,7 @@ export function webObserveIdFromStatus(status: Record<string, unknown> | null, o
|
||||
|
||||
export function webObserveIndexEntryFromOptions(options: NodeWebProbeObserveOptions, spec: HwlabRuntimeLaneSpec, id: string, status: Record<string, unknown>): WebObserveIndexEntry {
|
||||
const manifest = record(status.manifest);
|
||||
const manifestOrigin = record(manifest.origin);
|
||||
const heartbeat = record(status.heartbeat);
|
||||
return {
|
||||
id,
|
||||
@@ -1169,6 +1185,11 @@ export function webObserveIndexEntryFromOptions(options: NodeWebProbeObserveOpti
|
||||
workspace: spec.workspace,
|
||||
stateDir: options.stateDir ?? "",
|
||||
url: typeof manifest.baseUrl === "string" ? manifest.baseUrl : options.url,
|
||||
originName: webObserveOriginName(manifestOrigin.name) ?? options.originName,
|
||||
originMode: webObserveOriginMode(manifestOrigin.mode) ?? options.originMode,
|
||||
originConfigPath: typeof manifestOrigin.configPath === "string" ? manifestOrigin.configPath : options.originConfigPath,
|
||||
browserProxyMode: webObserveBrowserProxyMode(manifestOrigin.browserProxyMode) ?? options.browserProxyMode,
|
||||
browserProxyModeSource: webObserveBrowserProxyModeSource(manifestOrigin.browserProxyModeSource) ?? options.browserProxyModeSource,
|
||||
targetPath: typeof manifest.targetPath === "string" ? manifest.targetPath : options.targetPath,
|
||||
status: typeof manifest.status === "string" ? manifest.status : null,
|
||||
pid: typeof status.pid === "number" ? status.pid : null,
|
||||
@@ -1177,6 +1198,22 @@ export function webObserveIndexEntryFromOptions(options: NodeWebProbeObserveOpti
|
||||
};
|
||||
}
|
||||
|
||||
function webObserveOriginName(value: unknown): WebObserveIndexEntry["originName"] {
|
||||
return value === "internal" || value === "public" || value === "custom" ? value : null;
|
||||
}
|
||||
|
||||
function webObserveOriginMode(value: unknown): WebObserveIndexEntry["originMode"] {
|
||||
return value === "k8s-service-cluster-ip" || value === "public" || value === "custom-url" ? value : null;
|
||||
}
|
||||
|
||||
function webObserveBrowserProxyMode(value: unknown): WebObserveIndexEntry["browserProxyMode"] {
|
||||
return value === "auto" || value === "direct" ? value : null;
|
||||
}
|
||||
|
||||
function webObserveBrowserProxyModeSource(value: unknown): WebObserveIndexEntry["browserProxyModeSource"] {
|
||||
return value === "cli" || value === "yaml-origin" || value === "yaml-web-probe" || value === "default" ? value : null;
|
||||
}
|
||||
|
||||
export function webObserveCommandLabel(action: NodeWebProbeObserveAction, options: Pick<NodeWebProbeObserveOptions, "id" | "jobId" | "node" | "lane">): string {
|
||||
const id = webObserveIdFromOptions(options);
|
||||
return id === null
|
||||
|
||||
Reference in New Issue
Block a user