mirror of
https://github.com/coder/coder.git
synced 2026-11-04 23:29:17 +08:00
23 lines
425 B
TypeScript
23 lines
425 B
TypeScript
import type {
|
|
Workspace,
|
|
WorkspaceAgent,
|
|
WorkspaceApp,
|
|
} from "#/api/typesGenerated";
|
|
|
|
export type WorkspaceAppWithAgent = WorkspaceApp & {
|
|
agent: WorkspaceAgent;
|
|
};
|
|
|
|
export function getAllAppsWithAgent(
|
|
workspace: Workspace,
|
|
): WorkspaceAppWithAgent[] {
|
|
return workspace.latest_build.resources
|
|
.flatMap((r) => r.agents ?? [])
|
|
.flatMap((agent) =>
|
|
agent.apps.map((app) => ({
|
|
...app,
|
|
agent,
|
|
})),
|
|
);
|
|
}
|