Skip to content

Commit

Permalink
refactor: Cleanup workflow management models (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
daryllimyt authored Dec 24, 2024
1 parent 712d69d commit f09eef2
Show file tree
Hide file tree
Showing 14 changed files with 372 additions and 372 deletions.
448 changes: 225 additions & 223 deletions frontend/src/client/schemas.gen.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions frontend/src/client/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const workspacesDeleteWorkspaceMembership = (data: WorkspacesDeleteWorksp
* @param data The data for the request.
* @param data.workspaceId
* @param data.tag Filter workflows by tags
* @returns WorkflowMetadataResponse Successful Response
* @returns WorkflowReadMinimal Successful Response
* @throws ApiError
*/
export const workflowsListWorkflows = (data: WorkflowsListWorkflowsData): CancelablePromise<WorkflowsListWorkflowsResponse> => { return __request(OpenAPI, {
Expand All @@ -291,7 +291,7 @@ export const workflowsListWorkflows = (data: WorkflowsListWorkflowsData): Cancel
* @param data The data for the request.
* @param data.workspaceId
* @param data.formData
* @returns WorkflowMetadataResponse Successful Response
* @returns WorkflowReadMinimal Successful Response
* @throws ApiError
*/
export const workflowsCreateWorkflow = (data: WorkflowsCreateWorkflowData): CancelablePromise<WorkflowsCreateWorkflowResponse> => { return __request(OpenAPI, {
Expand All @@ -313,7 +313,7 @@ export const workflowsCreateWorkflow = (data: WorkflowsCreateWorkflowData): Canc
* @param data The data for the request.
* @param data.workflowId
* @param data.workspaceId
* @returns WorkflowResponse Successful Response
* @returns WorkflowRead Successful Response
* @throws ApiError
*/
export const workflowsGetWorkflow = (data: WorkflowsGetWorkflowData): CancelablePromise<WorkflowsGetWorkflowResponse> => { return __request(OpenAPI, {
Expand Down Expand Up @@ -387,7 +387,7 @@ export const workflowsDeleteWorkflow = (data: WorkflowsDeleteWorkflowData): Canc
* @param data The data for the request.
* @param data.workflowId
* @param data.workspaceId
* @returns CommitWorkflowResponse Successful Response
* @returns WorkflowCommitResponse Successful Response
* @throws ApiError
*/
export const workflowsCommitWorkflow = (data: WorkflowsCommitWorkflowData): CancelablePromise<WorkflowsCommitWorkflowResponse> => { return __request(OpenAPI, {
Expand Down
110 changes: 55 additions & 55 deletions frontend/src/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,6 @@ export type Body_workflows_create_workflow = {
file?: (Blob | File) | null;
};

export type CommitWorkflowResponse = {
workflow_id: string;
status: 'success' | 'failure';
message: string;
errors?: Array<RegistryActionValidateResponse> | null;
metadata?: {
[key: string]: unknown;
} | null;
};

export type status = 'success' | 'failure';

export type CreateWorkflowExecutionParams = {
workflow_id: string;
inputs?: unknown | null;
Expand Down Expand Up @@ -753,7 +741,7 @@ export type ScheduleCreate = {
timeout?: number;
};

export type status2 = 'online' | 'offline';
export type status = 'online' | 'offline';

export type ScheduleSearch = {
workflow_id?: string | null;
Expand Down Expand Up @@ -958,26 +946,6 @@ export type Trigger = {

export type type3 = 'schedule' | 'webhook';

export type UpdateWorkflowParams = {
title?: string | null;
description?: string | null;
status?: 'online' | 'offline' | null;
object?: {
[key: string]: unknown;
} | null;
version?: number | null;
entrypoint?: string | null;
icon_url?: string | null;
static_inputs?: {
[key: string]: unknown;
} | null;
expects?: {
[key: string]: ExpectedField;
} | null;
returns?: unknown | null;
config?: DSLConfig_Input | null;
};

export type UpdateWorkspaceParams = {
name?: string | null;
settings?: {
Expand Down Expand Up @@ -1056,6 +1024,18 @@ export type WebhookResponse = {

export type method = 'GET' | 'POST';

export type WorkflowCommitResponse = {
workflow_id: string;
status: 'success' | 'failure';
message: string;
errors?: Array<RegistryActionValidateResponse> | null;
metadata?: {
[key: string]: unknown;
} | null;
};

export type status2 = 'success' | 'failure';

/**
* A workflow definition.
*
Expand Down Expand Up @@ -1123,19 +1103,7 @@ export type WorkflowExecutionResponse = {

export type status3 = 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELED' | 'TERMINATED' | 'CONTINUED_AS_NEW' | 'TIMED_OUT';

export type WorkflowMetadataResponse = {
id: string;
title: string;
description: string;
status: string;
icon_url: string | null;
created_at: string;
updated_at: string;
version: number | null;
tags?: Array<TagRead> | null;
};

export type WorkflowResponse = {
export type WorkflowRead = {
id: string;
title: string;
description: string;
Expand All @@ -1161,10 +1129,42 @@ export type WorkflowResponse = {
config: DSLConfig_Output | null;
};

export type WorkflowReadMinimal = {
id: string;
title: string;
description: string;
status: string;
icon_url: string | null;
created_at: string;
updated_at: string;
version: number | null;
tags?: Array<TagRead> | null;
};

export type WorkflowTagCreate = {
tag_id: string;
};

export type WorkflowUpdate = {
title?: string | null;
description?: string | null;
status?: 'online' | 'offline' | null;
object?: {
[key: string]: unknown;
} | null;
version?: number | null;
entrypoint?: string | null;
icon_url?: string | null;
static_inputs?: {
[key: string]: unknown;
} | null;
expects?: {
[key: string]: ExpectedField;
} | null;
returns?: unknown | null;
config?: DSLConfig_Input | null;
};

export type WorkspaceMember = {
user_id: string;
first_name: string | null;
Expand Down Expand Up @@ -1288,24 +1288,24 @@ export type WorkflowsListWorkflowsData = {
workspaceId: string;
};

export type WorkflowsListWorkflowsResponse = Array<WorkflowMetadataResponse>;
export type WorkflowsListWorkflowsResponse = Array<WorkflowReadMinimal>;

export type WorkflowsCreateWorkflowData = {
formData?: Body_workflows_create_workflow;
workspaceId: string;
};

export type WorkflowsCreateWorkflowResponse = WorkflowMetadataResponse;
export type WorkflowsCreateWorkflowResponse = WorkflowReadMinimal;

export type WorkflowsGetWorkflowData = {
workflowId: string;
workspaceId: string;
};

export type WorkflowsGetWorkflowResponse = WorkflowResponse;
export type WorkflowsGetWorkflowResponse = WorkflowRead;

export type WorkflowsUpdateWorkflowData = {
requestBody: UpdateWorkflowParams;
requestBody: WorkflowUpdate;
workflowId: string;
workspaceId: string;
};
Expand All @@ -1324,7 +1324,7 @@ export type WorkflowsCommitWorkflowData = {
workspaceId: string;
};

export type WorkflowsCommitWorkflowResponse = CommitWorkflowResponse;
export type WorkflowsCommitWorkflowResponse = WorkflowCommitResponse;

export type WorkflowsExportWorkflowData = {
/**
Expand Down Expand Up @@ -1999,7 +1999,7 @@ export type $OpenApiTs = {
/**
* Successful Response
*/
200: Array<WorkflowMetadataResponse>;
200: Array<WorkflowReadMinimal>;
/**
* Validation Error
*/
Expand All @@ -2012,7 +2012,7 @@ export type $OpenApiTs = {
/**
* Successful Response
*/
201: WorkflowMetadataResponse;
201: WorkflowReadMinimal;
/**
* Validation Error
*/
Expand All @@ -2027,7 +2027,7 @@ export type $OpenApiTs = {
/**
* Successful Response
*/
200: WorkflowResponse;
200: WorkflowRead;
/**
* Validation Error
*/
Expand Down Expand Up @@ -2068,7 +2068,7 @@ export type $OpenApiTs = {
/**
* Successful Response
*/
200: CommitWorkflowResponse;
200: WorkflowCommitResponse;
/**
* Validation Error
*/
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/components/dashboard/dashboard-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, { useState } from "react"
import { useRouter, useSearchParams } from "next/navigation"
import { TagRead, WorkflowMetadataResponse } from "@/client"
import { TagRead, WorkflowReadMinimal } from "@/client"
import { useWorkspace } from "@/providers/workspace"
import { DotsHorizontalIcon } from "@radix-ui/react-icons"
import { Row } from "@tanstack/react-table"
Expand Down Expand Up @@ -50,10 +50,10 @@ export function WorkflowsDashboardTable() {
removeWorkflowTag,
} = useWorkflowManager({ tag: queryTags })
const [selectedWorkflow, setSelectedWorkflow] =
useState<WorkflowMetadataResponse | null>(null)
useState<WorkflowReadMinimal | null>(null)
const { tags } = useTags(workspaceId)

const handleOnClickRow = (row: Row<WorkflowMetadataResponse>) => () => {
const handleOnClickRow = (row: Row<WorkflowReadMinimal>) => () => {
// Link to workflow detail page
console.debug("Clicked row", row)
router.push(`/workspaces/${workspaceId}/workflows/${row.original.id}`)
Expand Down Expand Up @@ -82,7 +82,7 @@ export function WorkflowsDashboardTable() {
),
cell: ({ row }) => (
<div className="text-xs text-foreground/80">
{row.getValue<WorkflowMetadataResponse["title"]>("title")}
{row.getValue<WorkflowReadMinimal["title"]>("title")}
</div>
),
enableSorting: true,
Expand All @@ -99,7 +99,7 @@ export function WorkflowsDashboardTable() {
),
cell: ({ row }) => (
<div className="text-xs text-foreground/80">
{row.getValue<WorkflowMetadataResponse["description"]>(
{row.getValue<WorkflowReadMinimal["description"]>(
"description"
) || "-"}
</div>
Expand All @@ -118,7 +118,7 @@ export function WorkflowsDashboardTable() {
),
cell: ({ row }) => {
const status =
row.getValue<WorkflowMetadataResponse["status"]>("status")
row.getValue<WorkflowReadMinimal["status"]>("status")
return (
<div className="flex-auto space-x-4 text-xs">
<div className="ml-auto flex items-center space-x-2">
Expand Down Expand Up @@ -151,10 +151,9 @@ export function WorkflowsDashboardTable() {
),
cell: ({ row }) => (
<div className="flex flex-wrap gap-1">
{row.getValue<WorkflowMetadataResponse["tags"]>("tags")
?.length ? (
{row.getValue<WorkflowReadMinimal["tags"]>("tags")?.length ? (
row
.getValue<WorkflowMetadataResponse["tags"]>("tags")
.getValue<WorkflowReadMinimal["tags"]>("tags")
?.map((tag) => <TagBadge key={tag.id} tag={tag} />)
) : (
<span className="text-xs text-muted-foreground">-</span>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/dashboard/delete-workflow-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"

import React from "react"
import { WorkflowMetadataResponse } from "@/client"
import { WorkflowReadMinimal } from "@/client"

import { useWorkflowManager } from "@/lib/hooks"
import {
Expand All @@ -21,8 +21,8 @@ export function DeleteWorkflowAlertDialog({
setSelectedWorkflow,
children,
}: React.PropsWithChildren<{
selectedWorkflow: WorkflowMetadataResponse | null
setSelectedWorkflow: (selectedSecret: WorkflowMetadataResponse | null) => void
selectedWorkflow: WorkflowReadMinimal | null
setSelectedWorkflow: (selectedSecret: WorkflowReadMinimal | null) => void
}>) {
const { deleteWorkflow } = useWorkflowManager()
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "next/link"
import { WorkflowMetadataResponse } from "@/client"
import { WorkflowReadMinimal } from "@/client"

import { cn } from "@/lib/utils"

Expand All @@ -8,7 +8,7 @@ export function WorkflowItem({
workflow,
}: {
workspaceId: string
workflow: WorkflowMetadataResponse
workflow: WorkflowReadMinimal
}) {
return (
<Link
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/workbench/panel/trigger-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import "react18-json-view/src/style.css"

import React from "react"
import { ApiError, WebhookResponse, WorkflowResponse } from "@/client"
import { ApiError, WebhookResponse, WorkflowRead } from "@/client"
import { useWorkspace } from "@/providers/workspace"
import { zodResolver } from "@hookform/resolvers/zod"
import { DotsHorizontalIcon } from "@radix-ui/react-icons"
Expand Down Expand Up @@ -87,7 +87,7 @@ import { CenteredSpinner } from "@/components/loading/spinner"
import { AlertNotification } from "@/components/notifications"
import { TriggerTypename } from "@/components/workbench/canvas/trigger-node"

export function TriggerPanel({ workflow }: { workflow: WorkflowResponse }) {
export function TriggerPanel({ workflow }: { workflow: WorkflowRead }) {
return (
<div className="size-full overflow-auto">
<div className="grid grid-cols-3">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/workbench/panel/workbench-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { WorkflowResponse } from "@/client"
import { WorkflowRead } from "@/client"
import { useWorkflowBuilder } from "@/providers/builder"
import { useWorkflow } from "@/providers/workflow"

Expand Down Expand Up @@ -51,7 +51,7 @@ function NodePanel({
workflow,
}: {
node: NodeType
workflow: WorkflowResponse
workflow: WorkflowRead
}) {
switch (node.type) {
case "udf":
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/workbench/panel/workflow-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { zodResolver } from "@hookform/resolvers/zod"

import "@radix-ui/react-dialog"

import { ApiError, WorkflowResponse } from "@/client"
import { ApiError, WorkflowRead } from "@/client"
import { useWorkflow } from "@/providers/workflow"
import { useWorkspace } from "@/providers/workspace"
import {
Expand Down Expand Up @@ -107,7 +107,7 @@ type WorkflowConfigForm = z.infer<typeof workflowConfigFormSchema>
export function WorkflowPanel({
workflow,
}: {
workflow: WorkflowResponse
workflow: WorkflowRead
}): React.JSX.Element {
const { workspaceId } = useWorkspace()
const { workflowId } = useWorkflow()
Expand Down
Loading

0 comments on commit f09eef2

Please sign in to comment.