-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create formatters for timers, external workflows & childworkflows (#683)
* create formatter functions for workflow execution events * type cancel request event api * format activities and decision tasks * add formatters for remaining files
- Loading branch information
1 parent
e290f21
commit 4ce4839
Showing
33 changed files
with
1,472 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...a-formatters/format-workflow-history-event/format-activity-task-cancel-requested-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskCancelRequestedEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskCancelRequestedEvent = ({ | ||
activityTaskCancelRequestedEventAttributes: { | ||
decisionTaskCompletedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskCancelRequestedEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
decisionTaskCompletedEventId: parseInt(decisionTaskCompletedEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskCancelRequestedEvent; |
47 changes: 47 additions & 0 deletions
47
...tils/data-formatters/format-workflow-history-event/format-activity-task-canceled-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatPayload from '../format-payload'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskCanceledEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskCanceledEvent = ({ | ||
activityTaskCanceledEventAttributes: { | ||
details, | ||
latestCancelRequestedEventId, | ||
scheduledEventId, | ||
startedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskCanceledEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
details: formatPayload(details), | ||
latestCancelRequestedEventId: parseInt(latestCancelRequestedEventId), | ||
scheduledEventId: parseInt(scheduledEventId), | ||
startedEventId: parseInt(startedEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskCanceledEvent; |
45 changes: 45 additions & 0 deletions
45
...ils/data-formatters/format-workflow-history-event/format-activity-task-completed-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatPayload from '../format-payload'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskCompletedEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskCompletedEvent = ({ | ||
activityTaskCompletedEventAttributes: { | ||
result, | ||
scheduledEventId, | ||
startedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskCompletedEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
result: formatPayload(result), | ||
scheduledEventId: parseInt(scheduledEventId), | ||
startedEventId: parseInt(startedEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskCompletedEvent; |
46 changes: 46 additions & 0 deletions
46
src/utils/data-formatters/format-workflow-history-event/format-activity-task-failed-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatFailureDetails from '../format-failure-details'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskFailedEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskFailedEvent = ({ | ||
activityTaskFailedEventAttributes: { | ||
failure, | ||
scheduledEventId, | ||
startedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskFailedEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
details: formatFailureDetails(failure), | ||
reason: failure?.reason || '', | ||
scheduledEventId: parseInt(scheduledEventId), | ||
startedEventId: parseInt(startedEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskFailedEvent; |
70 changes: 70 additions & 0 deletions
70
...ils/data-formatters/format-workflow-history-event/format-activity-task-scheduled-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatDurationToSeconds from '../format-duration-to-seconds'; | ||
import formatEnum from '../format-enum'; | ||
import formatPayload from '../format-payload'; | ||
import formatPayloadMap from '../format-payload-map'; | ||
import formatRetryPolicy from '../format-retry-policy'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskScheduledEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskScheduledEvent = ({ | ||
activityTaskScheduledEventAttributes: { | ||
decisionTaskCompletedEventId, | ||
domain, | ||
header, | ||
heartbeatTimeout, | ||
input, | ||
retryPolicy, | ||
scheduleToCloseTimeout, | ||
scheduleToStartTimeout, | ||
startToCloseTimeout, | ||
taskList, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskScheduledEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
decisionTaskCompletedEventId: parseInt(decisionTaskCompletedEventId), | ||
domain: domain || null, | ||
header: formatPayloadMap(header, 'fields'), | ||
heartbeatTimeoutSeconds: formatDurationToSeconds(heartbeatTimeout), | ||
input: formatPayload(input), | ||
retryPolicy: formatRetryPolicy(retryPolicy), | ||
scheduleToCloseTimeoutSeconds: formatDurationToSeconds( | ||
scheduleToCloseTimeout | ||
), | ||
scheduleToStartTimeoutSeconds: formatDurationToSeconds( | ||
scheduleToStartTimeout | ||
), | ||
startToCloseTimeoutSeconds: formatDurationToSeconds(startToCloseTimeout), | ||
taskList: { | ||
kind: formatEnum(taskList?.kind, 'TASK_LIST_KIND'), | ||
name: taskList?.name || null, | ||
}, | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskScheduledEvent; |
44 changes: 44 additions & 0 deletions
44
...utils/data-formatters/format-workflow-history-event/format-activity-task-started-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatFailureDetails from '../format-failure-details'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskStartedEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskStartedEvent = ({ | ||
activityTaskStartedEventAttributes: { | ||
lastFailure, | ||
scheduledEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskStartedEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
lastFailureDetails: formatFailureDetails(lastFailure), | ||
lastFailureReason: lastFailure?.reason || '', | ||
scheduledEventId: parseInt(scheduledEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskStartedEvent; |
49 changes: 49 additions & 0 deletions
49
...ils/data-formatters/format-workflow-history-event/format-activity-task-timed-out-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatFailureDetails from '../format-failure-details'; | ||
import formatPayload from '../format-payload'; | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type ActivityTaskTimedOutEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatActivityTaskTimedOutEvent = ({ | ||
activityTaskTimedOutEventAttributes: { | ||
details, | ||
lastFailure, | ||
scheduledEventId, | ||
startedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: ActivityTaskTimedOutEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
details: formatPayload(details), | ||
lastFailureDetails: formatFailureDetails(lastFailure), | ||
lastFailureReason: lastFailure?.reason || '', | ||
scheduledEventId: parseInt(scheduledEventId), | ||
startedEventId: parseInt(startedEventId), | ||
}; | ||
}; | ||
|
||
export default formatActivityTaskTimedOutEvent; |
39 changes: 39 additions & 0 deletions
39
src/utils/data-formatters/format-workflow-history-event/format-cancel-timer-failed-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2022-2024 Uber Technologies Inc. | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import formatWorkflowCommonEventFields from './format-workflow-common-event-fields'; | ||
import { type CancelTimerFailedEvent } from './format-workflow-history-event.type'; | ||
|
||
const formatCancelTimerFailedEvent = ({ | ||
cancelTimerFailedEventAttributes: { | ||
decisionTaskCompletedEventId, | ||
...eventAttributes | ||
}, | ||
...eventFields | ||
}: CancelTimerFailedEvent) => { | ||
return { | ||
...formatWorkflowCommonEventFields(eventFields), | ||
...eventAttributes, | ||
decisionTaskCompletedEventId: parseInt(decisionTaskCompletedEventId), | ||
}; | ||
}; | ||
|
||
export default formatCancelTimerFailedEvent; |
Oops, something went wrong.