@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
13 lines (12 loc) • 696 B
text/typescript
import { UiTaskRunCountsByStateResponse } from '@/models/api/UiTaskRunCountsByStateResponse'
import { ServerStateType, isServerStateType } from '@/models/StateType'
import { UiTaskRunCountsByState } from '@/models/UiTaskRunCountsByState'
import { MapFunction, mapper } from '@/services/Mapper'
export const mapUiTaskRunCountsByStateResponseToUiTaskRunCountsByState: MapFunction<UiTaskRunCountsByStateResponse, UiTaskRunCountsByState> = function(source) {
return Object.entries(source).reduce <UiTaskRunCountsByState>((acc, [key, value]) => {
if (isServerStateType(key)) {
acc[mapper.map('ServerStateType', key as ServerStateType, 'StateType')] = value
}
return acc
}, {})
}