feat(workbench): integrate operational workflows and map state
This commit is contained in:
@@ -202,19 +202,7 @@ export type WorkbenchAnalysisProjection = {
|
||||
|
||||
const SERVER_API_BASE_URL = env.TJWATER_SERVER_API_BASE_URL.replace(/\/$/, "");
|
||||
|
||||
export async function fetchWorkbenchRuntimeSnapshot(
|
||||
getAccessToken?: AccessTokenProvider,
|
||||
signal?: AbortSignal
|
||||
): Promise<WorkbenchRuntimeSnapshot> {
|
||||
const { project, accessToken } = await findOwnedWorkbenchProject(getAccessToken, signal);
|
||||
const response = await fetch(`${SERVER_API_BASE_URL}/api/v1/workbench/runtime`, {
|
||||
headers: createWorkbenchHeaders(accessToken, project.project_id),
|
||||
signal
|
||||
});
|
||||
const payload: unknown = await response.json().catch(() => null);
|
||||
if (!response.ok) {
|
||||
throw new Error(getServerError(payload, response.status, "工作台运行态请求"));
|
||||
}
|
||||
export function parseWorkbenchRuntimeSnapshot(payload: unknown): WorkbenchRuntimeSnapshot {
|
||||
const snapshot = runtimeSnapshotSchema.parse(payload);
|
||||
const latestAnalysis = snapshot.latest_analysis
|
||||
? projectWorkbenchAnalysis(snapshot.latest_analysis)
|
||||
@@ -274,7 +262,7 @@ export async function fetchWorkbenchRuntimeSnapshot(
|
||||
latestAnalysisArtifact: latestAnalysis?.artifact ?? null,
|
||||
simulationOverlay: latestAnalysis?.simulationOverlay ?? null,
|
||||
workOrders: snapshot.work_orders.map((workOrder) => ({
|
||||
id: workOrder.id,
|
||||
id: `demo-work-order:${workOrder.id}`,
|
||||
kind: "work_order",
|
||||
code: workOrder.code,
|
||||
scheduledAt: workOrder.scheduled_at,
|
||||
@@ -289,6 +277,7 @@ export async function fetchWorkbenchRuntimeSnapshot(
|
||||
source: workOrder.source,
|
||||
dispatcher: workOrder.dispatcher,
|
||||
priority: workOrder.priority,
|
||||
dataSource: "backend",
|
||||
subtasks: workOrder.subtasks.map((subtask) => ({
|
||||
id: subtask.id,
|
||||
title: subtask.title,
|
||||
|
||||
Reference in New Issue
Block a user