From e1d35aa87328b6ee3ba9f14dc268eb94b1aede98 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Fri, 26 Apr 2024 19:10:38 -0500 Subject: [PATCH] fix API model imports, remove unused function from `useInvocationGraph` --- client/src/api/invocations.ts | 10 +++++++ client/src/api/workflows.ts | 4 ++- .../Invocation/Graph/InvocationGraph.vue | 4 +-- .../Graph/WorkflowInvocationSteps.vue | 4 +-- .../WorkflowInvocationState.vue | 6 ++-- client/src/composables/useInvocationGraph.ts | 29 ++----------------- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/client/src/api/invocations.ts b/client/src/api/invocations.ts index 88c34695fb8c..2196f9a9254e 100644 --- a/client/src/api/invocations.ts +++ b/client/src/api/invocations.ts @@ -9,8 +9,18 @@ export type WorkflowInvocationCollectionView = components["schemas"]["WorkflowIn export type InvocationJobsSummary = components["schemas"]["InvocationJobsResponse"]; export type InvocationStep = components["schemas"]["InvocationStep"]; +export type StepJobSummary = + | components["schemas"]["InvocationStepJobsResponseStepModel"] + | components["schemas"]["InvocationStepJobsResponseJobModel"] + | components["schemas"]["InvocationStepJobsResponseCollectionJobsModel"]; + export const invocationsFetcher = fetcher.path("/api/invocations").method("get").create(); +export const stepJobsSummaryFetcher = fetcher + .path("/api/invocations/{invocation_id}/step_jobs_summary") + .method("get") + .create(); + export type WorkflowInvocation = WorkflowInvocationElementView | WorkflowInvocationCollectionView; export interface WorkflowInvocationJobsSummary { diff --git a/client/src/api/workflows.ts b/client/src/api/workflows.ts index 0082f1db63f9..e532b4499c1b 100644 --- a/client/src/api/workflows.ts +++ b/client/src/api/workflows.ts @@ -1,4 +1,6 @@ -import { fetcher } from "@/api/schema"; +import { components, fetcher } from "@/api/schema"; + +export type StoredWorkflowDetailed = components["schemas"]["StoredWorkflowDetailed"]; export const workflowsFetcher = fetcher.path("/api/workflows").method("get").create(); diff --git a/client/src/components/Workflow/Invocation/Graph/InvocationGraph.vue b/client/src/components/Workflow/Invocation/Graph/InvocationGraph.vue index e6cc72869223..1584f526ecc7 100644 --- a/client/src/components/Workflow/Invocation/Graph/InvocationGraph.vue +++ b/client/src/components/Workflow/Invocation/Graph/InvocationGraph.vue @@ -14,7 +14,7 @@ import { BAlert, BButton, BCard, BCardBody, BCardHeader } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed, onUnmounted, ref, watch } from "vue"; -import { components } from "@/api/schema"; +import type { WorkflowInvocationElementView } from "@/api/invocations"; import { JobProvider } from "@/components/providers"; import { useDatatypesMapper } from "@/composables/datatypesMapper"; import { useInvocationGraph } from "@/composables/useInvocationGraph"; @@ -35,7 +35,7 @@ library.add(faArrowDown, faChevronDown, faChevronUp, faSignInAlt, faSitemap, faT interface Props { /** The invocation to display */ - invocation: components["schemas"]["WorkflowInvocationElementView"]; + invocation: WorkflowInvocationElementView; /** The workflow which was run */ workflow: Workflow; /** Whether the invocation is terminal */ diff --git a/client/src/components/Workflow/Invocation/Graph/WorkflowInvocationSteps.vue b/client/src/components/Workflow/Invocation/Graph/WorkflowInvocationSteps.vue index 59b56aabe376..005f86c74eec 100644 --- a/client/src/components/Workflow/Invocation/Graph/WorkflowInvocationSteps.vue +++ b/client/src/components/Workflow/Invocation/Graph/WorkflowInvocationSteps.vue @@ -4,7 +4,7 @@ import { faChevronDown, faChevronUp, faSignInAlt } from "@fortawesome/free-solid import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { computed, ref, watch } from "vue"; -import { components } from "@/api/schema"; +import { WorkflowInvocationElementView } from "@/api/invocations"; import { isWorkflowInput } from "@/components/Workflow/constants"; import type { GraphStep } from "@/composables/useInvocationGraph"; import type { Workflow } from "@/stores/workflowStore"; @@ -19,7 +19,7 @@ interface Props { /** The store id for the invocation graph */ storeId: string; /** The invocation to display */ - invocation: components["schemas"]["WorkflowInvocationElementView"]; + invocation: WorkflowInvocationElementView; /** The workflow which was run */ workflow: Workflow; /** Whether the invocation graph is hidden */ diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue index b59e37db136c..628923665e33 100644 --- a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue @@ -5,8 +5,8 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BAlert, BButton, BButtonGroup, BTab, BTabs } from "bootstrap-vue"; import { computed, onMounted, onUnmounted, ref, watch } from "vue"; -import { InvocationJobsSummary, WorkflowInvocationElementView } from "@/api/invocations"; -import { components } from "@/api/schema"; +import { type InvocationJobsSummary, type WorkflowInvocationElementView } from "@/api/invocations"; +import type { StoredWorkflowDetailed } from "@/api/workflows"; import { useAnimationFrameResizeObserver } from "@/composables/sensors/animationFrameResizeObserver"; import { useInvocationStore } from "@/stores/invocationStore"; import { useWorkflowStore } from "@/stores/workflowStore"; @@ -27,8 +27,6 @@ import LoadingSpan from "@/components/LoadingSpan.vue"; library.add(faArrowLeft, faClock, faEdit, faEye, faHdd, faPlay, faSitemap); -type StoredWorkflowDetailed = components["schemas"]["StoredWorkflowDetailed"]; - interface Props { invocationId: string; index?: number; diff --git a/client/src/composables/useInvocationGraph.ts b/client/src/composables/useInvocationGraph.ts index 18fb3ed3d7cd..dc3a58d88478 100644 --- a/client/src/composables/useInvocationGraph.ts +++ b/client/src/composables/useInvocationGraph.ts @@ -10,7 +10,7 @@ import { } from "@fortawesome/free-solid-svg-icons"; import Vue, { computed, type Ref, ref } from "vue"; -import { components, fetcher } from "@/api/schema"; +import { stepJobsSummaryFetcher, type StepJobSummary, type WorkflowInvocationElementView } from "@/api/invocations"; import { isWorkflowInput } from "@/components/Workflow/constants"; import { fromSimple } from "@/components/Workflow/Editor/modules/model"; import { getWorkflowFull } from "@/components/Workflow/workflows.services"; @@ -20,11 +20,6 @@ import { rethrowSimple } from "@/utils/simple-error"; import { provideScopedWorkflowStores } from "./workflowStores"; -// Type Definitions -type StepJobSummary = - | components["schemas"]["InvocationStepJobsResponseStepModel"] - | components["schemas"]["InvocationStepJobsResponseJobModel"] - | components["schemas"]["InvocationStepJobsResponseCollectionJobsModel"]; export interface GraphStep extends Step { state?: | "new" @@ -48,13 +43,6 @@ interface InvocationGraph extends Workflow { steps: { [index: number]: GraphStep }; } -// Fetchers -const stepJobsSummaryFetcher = fetcher - .path("/api/invocations/{invocation_id}/step_jobs_summary") - .method("get") - .create(); -const invocationStepFetcher = fetcher.path("/api/invocations/steps/{step_id}").method("get").create(); - /** Classes for states' icons */ export const iconClasses: Record = { ok: { icon: faCheckCircle, class: "text-success" }, @@ -78,7 +66,7 @@ const ALL_INSTANCES_STATES = ["deleted", "skipped", "new", "queued"]; * @param workflowId - The id of the workflow that was invoked */ export function useInvocationGraph( - invocation: Ref, + invocation: Ref, workflowId: string | undefined, workflowVersion: number | undefined ) { @@ -265,24 +253,11 @@ export function useInvocationGraph( // await fromSimple(storeId.value, invocationGraph.value as any); // } - async function getInvocationStep(name: string, id: number) { - const step_id = invocation.value.steps[id]?.id; - if (step_id) { - try { - const { data: invocationStep } = await invocationStepFetcher({ step_id }); - return invocationStep; - } catch (e) { - rethrowSimple(e); - } - } - } - return { /** An id used to scope the store to the invocation's id */ storeId, /** The steps of the invocation graph */ steps, - getInvocationStep, /** Fetches the original workflow structure (once) and the step job summaries for each step in the invocation, * and displays the job states on the workflow graph steps. */