From 11742db15a7a2410c7bf8ff60ff37b4edfecdb93 Mon Sep 17 00:00:00 2001 From: Ross Edfort Date: Fri, 4 Oct 2024 09:39:20 -0600 Subject: [PATCH] DT-2502 - handle WorkflowExecutionUpdateAdmitted events (#2364) * handle WorkflowExecutionUpdateAdmitted events this event type is only used on post-reset workflows when updates are reapplied, but we still want to show their attributes in the event history * fix dots and lines labels * make initialEvent prop optional, remove comment * optional --- .../models/event-groups/create-event-group.ts | 7 +++--- src/lib/models/event-groups/get-group-name.ts | 22 ++++++++++++++----- src/lib/types/events.ts | 2 ++ src/lib/utilities/is-event-type.ts | 7 ++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/lib/models/event-groups/create-event-group.ts b/src/lib/models/event-groups/create-event-group.ts index 897bfe08d..e43cc489b 100644 --- a/src/lib/models/event-groups/create-event-group.ts +++ b/src/lib/models/event-groups/create-event-group.ts @@ -69,14 +69,13 @@ const createGroupFor = ( events?: CommonHistoryEvent[], ): EventGroup => { const id = getGroupId(event); - const name = getEventGroupName(event); + const initialEvent = getInitialEvent(event, events); + const name = getEventGroupName(event, initialEvent); const label = getEventGroupLabel(event); - const displayName = getEventGroupDisplayName(event); + const displayName = getEventGroupDisplayName(event, initialEvent); const { timestamp, category, classification } = event; - const initialEvent = getInitialEvent(event, events); - const groupEvents: EventGroup['events'] = new Map(); const groupEventIds: EventGroup['eventIds'] = new Set(); diff --git a/src/lib/models/event-groups/get-group-name.ts b/src/lib/models/event-groups/get-group-name.ts index 8d0af5267..33cdf42b9 100644 --- a/src/lib/models/event-groups/get-group-name.ts +++ b/src/lib/models/event-groups/get-group-name.ts @@ -12,9 +12,13 @@ import { isTimerStartedEvent, isWorkflowExecutionSignaledEvent, isWorkflowExecutionUpdateAcceptedEvent, + isWorkflowExecutionUpdateAdmittedEvent, } from '$lib/utilities/is-event-type'; -export const getEventGroupName = (event: CommonHistoryEvent): string => { +export const getEventGroupName = ( + event: CommonHistoryEvent, + initialEvent?: CommonHistoryEvent, +): string => { if (!event) return ''; if (isActivityTaskScheduledEvent(event)) { @@ -50,8 +54,13 @@ export const getEventGroupName = (event: CommonHistoryEvent): string => { } if (isWorkflowExecutionUpdateAcceptedEvent(event)) { - return event.workflowExecutionUpdateAcceptedEventAttributes?.acceptedRequest - ?.input?.name; + if (isWorkflowExecutionUpdateAdmittedEvent(initialEvent)) { + return initialEvent.workflowExecutionUpdateAdmittedEventAttributes + ?.request?.input?.name; + } else { + return event.workflowExecutionUpdateAcceptedEventAttributes + ?.acceptedRequest?.input?.name; + } } if (isNexusOperationScheduledEvent(event)) { @@ -102,12 +111,15 @@ export const getEventGroupLabel = (event: CommonHistoryEvent): string => { } }; -export const getEventGroupDisplayName = (event: CommonHistoryEvent): string => { +export const getEventGroupDisplayName = ( + event: CommonHistoryEvent, + initialEvent?: CommonHistoryEvent, +): string => { if (!event) return ''; if (isLocalActivityMarkerEvent(event)) { return getSummaryAttribute(event)?.value?.toString() ?? 'Local Activity'; } - return getEventGroupName(event); + return getEventGroupName(event, initialEvent); }; diff --git a/src/lib/types/events.ts b/src/lib/types/events.ts index 9339956c9..2c8cbf12b 100644 --- a/src/lib/types/events.ts +++ b/src/lib/types/events.ts @@ -241,6 +241,8 @@ export type ExternalWorkflowExecutionSignaledEvent = EventWithAttributes<'externalWorkflowExecutionSignaledEventAttributes'>; export type UpsertWorkflowSearchAttributesEvent = EventWithAttributes<'upsertWorkflowSearchAttributesEventAttributes'>; +export type WorkflowExecutionUpdateAdmittedEvent = + EventWithAttributes<'workflowExecutionUpdateAdmittedEventAttributes'>; export type WorkflowExecutionUpdateAcceptedEvent = EventWithAttributes<'workflowExecutionUpdateAcceptedEventAttributes'>; export type WorkflowExecutionUpdateCompletedEvent = diff --git a/src/lib/utilities/is-event-type.ts b/src/lib/utilities/is-event-type.ts index 5027aeaf9..fa9e6ffa1 100644 --- a/src/lib/utilities/is-event-type.ts +++ b/src/lib/utilities/is-event-type.ts @@ -49,6 +49,7 @@ import type { WorkflowExecutionTerminatedEvent, WorkflowExecutionTimedOutEvent, WorkflowExecutionUpdateAcceptedEvent, + WorkflowExecutionUpdateAdmittedEvent, WorkflowExecutionUpdateCompletedEvent, WorkflowTaskCompletedEvent, WorkflowTaskFailedEvent, @@ -162,6 +163,7 @@ export const eventAttributeKeys: Readonly = [ 'markerRecordedEventAttributes', 'workflowExecutionSignaledEventAttributes', 'workflowExecutionTerminatedEventAttributes', + 'workflowExecutionUpdateAdmittedEventAttributes', 'workflowExecutionUpdateAcceptedEventAttributes', 'workflowExecutionUpdateCompletedEventAttributes', 'workflowExecutionUpdateRejectedEventAttributes', @@ -453,6 +455,11 @@ export const isWorkflowExecutionUpdateAcceptedEvent = 'workflowExecutionUpdateAcceptedEventAttributes', ); +export const isWorkflowExecutionUpdateAdmittedEvent = + hasAttributes( + 'workflowExecutionUpdateAdmittedEventAttributes', + ); + export const isWorkflowExecutionUpdateCompletedEvent = hasAttributes( 'workflowExecutionUpdateCompletedEventAttributes',