Skip to content

Commit

Permalink
refactor(app): Rename EventHistoryType -> WorkflowEventType (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
daryllimyt authored Jan 17, 2025
1 parent 27066e1 commit 645d42a
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 93 deletions.
44 changes: 22 additions & 22 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4314,27 +4314,6 @@ components:
- udf_key
- action_input
title: EventGroup
EventHistoryType:
type: string
enum:
- WORKFLOW_EXECUTION_STARTED
- WORKFLOW_EXECUTION_COMPLETED
- WORKFLOW_EXECUTION_FAILED
- WORKFLOW_EXECUTION_TERMINATED
- WORKFLOW_EXECUTION_CANCELED
- WORKFLOW_EXECUTION_CONTINUED_AS_NEW
- WORKFLOW_EXECUTION_TIMED_OUT
- ACTIVITY_TASK_SCHEDULED
- ACTIVITY_TASK_STARTED
- ACTIVITY_TASK_COMPLETED
- ACTIVITY_TASK_FAILED
- ACTIVITY_TASK_TIMED_OUT
- CHILD_WORKFLOW_EXECUTION_STARTED
- CHILD_WORKFLOW_EXECUTION_COMPLETED
- CHILD_WORKFLOW_EXECUTION_FAILED
- START_CHILD_WORKFLOW_EXECUTION_INITIATED
title: EventHistoryType
description: The event types we care about.
ExpectedField:
properties:
type:
Expand Down Expand Up @@ -6202,6 +6181,27 @@ components:
-------------
- 1 Workflow to many WorkflowDefinitions'
WorkflowEventType:
type: string
enum:
- WORKFLOW_EXECUTION_STARTED
- WORKFLOW_EXECUTION_COMPLETED
- WORKFLOW_EXECUTION_FAILED
- WORKFLOW_EXECUTION_TERMINATED
- WORKFLOW_EXECUTION_CANCELED
- WORKFLOW_EXECUTION_CONTINUED_AS_NEW
- WORKFLOW_EXECUTION_TIMED_OUT
- ACTIVITY_TASK_SCHEDULED
- ACTIVITY_TASK_STARTED
- ACTIVITY_TASK_COMPLETED
- ACTIVITY_TASK_FAILED
- ACTIVITY_TASK_TIMED_OUT
- CHILD_WORKFLOW_EXECUTION_STARTED
- CHILD_WORKFLOW_EXECUTION_COMPLETED
- CHILD_WORKFLOW_EXECUTION_FAILED
- START_CHILD_WORKFLOW_EXECUTION_INITIATED
title: WorkflowEventType
description: The event types we care about.
WorkflowExecutionCreate:
properties:
workflow_id:
Expand Down Expand Up @@ -6246,7 +6246,7 @@ components:
format: date-time
title: Event Time
event_type:
$ref: '#/components/schemas/EventHistoryType'
$ref: '#/components/schemas/WorkflowEventType'
task_id:
type: integer
title: Task Id
Expand Down
50 changes: 25 additions & 25 deletions frontend/src/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,30 +1072,6 @@ export const $EventGroup = {
title: "EventGroup",
} as const

export const $EventHistoryType = {
type: "string",
enum: [
"WORKFLOW_EXECUTION_STARTED",
"WORKFLOW_EXECUTION_COMPLETED",
"WORKFLOW_EXECUTION_FAILED",
"WORKFLOW_EXECUTION_TERMINATED",
"WORKFLOW_EXECUTION_CANCELED",
"WORKFLOW_EXECUTION_CONTINUED_AS_NEW",
"WORKFLOW_EXECUTION_TIMED_OUT",
"ACTIVITY_TASK_SCHEDULED",
"ACTIVITY_TASK_STARTED",
"ACTIVITY_TASK_COMPLETED",
"ACTIVITY_TASK_FAILED",
"ACTIVITY_TASK_TIMED_OUT",
"CHILD_WORKFLOW_EXECUTION_STARTED",
"CHILD_WORKFLOW_EXECUTION_COMPLETED",
"CHILD_WORKFLOW_EXECUTION_FAILED",
"START_CHILD_WORKFLOW_EXECUTION_INITIATED",
],
title: "EventHistoryType",
description: "The event types we care about.",
} as const

export const $ExpectedField = {
properties: {
type: {
Expand Down Expand Up @@ -3935,6 +3911,30 @@ Relationships
- 1 Workflow to many WorkflowDefinitions`,
} as const

export const $WorkflowEventType = {
type: "string",
enum: [
"WORKFLOW_EXECUTION_STARTED",
"WORKFLOW_EXECUTION_COMPLETED",
"WORKFLOW_EXECUTION_FAILED",
"WORKFLOW_EXECUTION_TERMINATED",
"WORKFLOW_EXECUTION_CANCELED",
"WORKFLOW_EXECUTION_CONTINUED_AS_NEW",
"WORKFLOW_EXECUTION_TIMED_OUT",
"ACTIVITY_TASK_SCHEDULED",
"ACTIVITY_TASK_STARTED",
"ACTIVITY_TASK_COMPLETED",
"ACTIVITY_TASK_FAILED",
"ACTIVITY_TASK_TIMED_OUT",
"CHILD_WORKFLOW_EXECUTION_STARTED",
"CHILD_WORKFLOW_EXECUTION_COMPLETED",
"CHILD_WORKFLOW_EXECUTION_FAILED",
"START_CHILD_WORKFLOW_EXECUTION_INITIATED",
],
title: "WorkflowEventType",
description: "The event types we care about.",
} as const

export const $WorkflowExecutionCreate = {
properties: {
workflow_id: {
Expand Down Expand Up @@ -3991,7 +3991,7 @@ export const $WorkflowExecutionEvent = {
title: "Event Time",
},
event_type: {
$ref: "#/components/schemas/EventHistoryType",
$ref: "#/components/schemas/WorkflowEventType",
},
task_id: {
type: "integer",
Expand Down
44 changes: 22 additions & 22 deletions frontend/src/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,27 +349,6 @@ export type EventGroup = {
related_wf_exec_id?: string | null
}

/**
* The event types we care about.
*/
export type EventHistoryType =
| "WORKFLOW_EXECUTION_STARTED"
| "WORKFLOW_EXECUTION_COMPLETED"
| "WORKFLOW_EXECUTION_FAILED"
| "WORKFLOW_EXECUTION_TERMINATED"
| "WORKFLOW_EXECUTION_CANCELED"
| "WORKFLOW_EXECUTION_CONTINUED_AS_NEW"
| "WORKFLOW_EXECUTION_TIMED_OUT"
| "ACTIVITY_TASK_SCHEDULED"
| "ACTIVITY_TASK_STARTED"
| "ACTIVITY_TASK_COMPLETED"
| "ACTIVITY_TASK_FAILED"
| "ACTIVITY_TASK_TIMED_OUT"
| "CHILD_WORKFLOW_EXECUTION_STARTED"
| "CHILD_WORKFLOW_EXECUTION_COMPLETED"
| "CHILD_WORKFLOW_EXECUTION_FAILED"
| "START_CHILD_WORKFLOW_EXECUTION_INITIATED"

export type ExpectedField = {
type: string
description?: string | null
Expand Down Expand Up @@ -1239,6 +1218,27 @@ export type WorkflowDefinition = {
}
}

/**
* The event types we care about.
*/
export type WorkflowEventType =
| "WORKFLOW_EXECUTION_STARTED"
| "WORKFLOW_EXECUTION_COMPLETED"
| "WORKFLOW_EXECUTION_FAILED"
| "WORKFLOW_EXECUTION_TERMINATED"
| "WORKFLOW_EXECUTION_CANCELED"
| "WORKFLOW_EXECUTION_CONTINUED_AS_NEW"
| "WORKFLOW_EXECUTION_TIMED_OUT"
| "ACTIVITY_TASK_SCHEDULED"
| "ACTIVITY_TASK_STARTED"
| "ACTIVITY_TASK_COMPLETED"
| "ACTIVITY_TASK_FAILED"
| "ACTIVITY_TASK_TIMED_OUT"
| "CHILD_WORKFLOW_EXECUTION_STARTED"
| "CHILD_WORKFLOW_EXECUTION_COMPLETED"
| "CHILD_WORKFLOW_EXECUTION_FAILED"
| "START_CHILD_WORKFLOW_EXECUTION_INITIATED"

export type WorkflowExecutionCreate = {
workflow_id: string
inputs?: unknown | null
Expand All @@ -1253,7 +1253,7 @@ export type WorkflowExecutionCreateResponse = {
export type WorkflowExecutionEvent = {
event_id: number
event_time: string
event_type: EventHistoryType
event_type: WorkflowEventType
task_id: number
/**
* The action group of the event. We use this to keep track of what events are related to each other.
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from tracecat.types.auth import Role
from tracecat.workflow.executions.models import (
EventGroup,
EventHistoryType,
WorkflowEventType,
WorkflowExecutionEvent,
)
from tracecat.workflow.executions.service import WorkflowExecutionsService
Expand Down Expand Up @@ -2440,7 +2440,7 @@ def assert_erroneous_task_failed_correctly(
event
for event in events
if (
event.event_type == EventHistoryType.ACTIVITY_TASK_FAILED
event.event_type == WorkflowEventType.ACTIVITY_TASK_FAILED
and event.event_group
and event.event_group.action_ref == "failing_action"
)
Expand Down Expand Up @@ -2491,7 +2491,7 @@ def assert_error_handler_initiated_correctly(
for event in events
if (
event.event_type
== EventHistoryType.START_CHILD_WORKFLOW_EXECUTION_INITIATED
== WorkflowEventType.START_CHILD_WORKFLOW_EXECUTION_INITIATED
and event.event_group
and event.event_group.action_ref is None
and event.event_group.action_title == "Testing Error Handler"
Expand Down Expand Up @@ -2544,7 +2544,7 @@ def assert_error_handler_started(
event
for event in events
if (
event.event_type == EventHistoryType.CHILD_WORKFLOW_EXECUTION_STARTED
event.event_type == WorkflowEventType.CHILD_WORKFLOW_EXECUTION_STARTED
and event.event_group
and event.event_group.action_ref is None
and event.event_group.action_title == "Testing Error Handler"
Expand All @@ -2564,7 +2564,7 @@ def assert_error_handler_completed(
event
for event in events
if (
event.event_type == EventHistoryType.CHILD_WORKFLOW_EXECUTION_COMPLETED
event.event_type == WorkflowEventType.CHILD_WORKFLOW_EXECUTION_COMPLETED
and event.event_group
and event.event_group.action_ref is None
and event.event_group.action_title == "Testing Error Handler"
Expand Down
4 changes: 2 additions & 2 deletions tracecat/workflow/executions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"""Mapped literal types for workflow execution statuses."""


class EventHistoryType(StrEnum):
class WorkflowEventType(StrEnum):
"""The event types we care about."""

WORKFLOW_EXECUTION_STARTED = "WORKFLOW_EXECUTION_STARTED"
Expand Down Expand Up @@ -268,7 +268,7 @@ class WorkflowExecutionEvent(BaseModel, Generic[EventInput]):
model_config = ConfigDict(arbitrary_types_allowed=True)
event_id: int
event_time: datetime
event_type: EventHistoryType
event_type: WorkflowEventType
task_id: int
event_group: EventGroup[EventInput] | None = Field(
default=None,
Expand Down
Loading

0 comments on commit 645d42a

Please sign in to comment.