FPSMS-frontend
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

compileTraceGraph.ts 963 B

1 settimana fa
123456789101112131415161718192021222324252627282930313233
  1. import { ItemLotTraceResponse } from "@/app/api/itemTracing";
  2. import {
  3. buildTraceGraphLayout,
  4. TraceGraphLayout,
  5. TraceGraphLayoutNode,
  6. } from "./traceGraphLayout";
  7. import { resolveTraceFlowEdgePairs } from "./traceGraphSemantics";
  8. import type { TraceGraphCompileLabels } from "./traceGraphLabels";
  9. export type TraceFlowEdgePair = { fromId: string; toId: string };
  10. export type CompiledTraceGraph = {
  11. layout: TraceGraphLayout;
  12. edgePairs: TraceFlowEdgePair[];
  13. nodes: TraceGraphLayoutNode[];
  14. };
  15. export const compileTraceGraph = (
  16. data: ItemLotTraceResponse,
  17. labels: TraceGraphCompileLabels,
  18. ): CompiledTraceGraph => {
  19. const layout = buildTraceGraphLayout(data, labels);
  20. const backendEdges = data.traceGraph?.edges?.map((e) => ({
  21. fromKey: e.fromKey,
  22. toKey: e.toKey,
  23. }));
  24. const edgePairs = resolveTraceFlowEdgePairs(layout.nodes, layout.phaseOrder, backendEdges);
  25. return {
  26. layout,
  27. edgePairs,
  28. nodes: layout.nodes,
  29. };
  30. };