@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_.
40 lines (37 loc) • 1.5 kB
text/typescript
import { StateCreate, StateRequest } from '@/models'
import { StateResponse } from '@/models/api/StateResponse'
import { State } from '@/models/State'
import { MapFunction } from '@/services/Mapper'
export const mapStateResponseToState: MapFunction<StateResponse, State> = function(source) {
return {
id: source.id,
type: this.map('ServerStateType', source.type, 'StateType'),
kind: 'state',
message: source.message,
stateDetails: this.map('StateDetailsResponse', source.state_details, 'StateDetails'),
data: source.data,
timestamp: this.map('string', source.timestamp, 'Date'),
name: source.name,
}
}
export const mapStateToStateResponse: MapFunction<State, StateResponse> = function(source) {
return {
id: source.id,
type: this.map('StateType', source.type, 'ServerStateType'),
message: source.message,
state_details: this.map('StateDetails', source.stateDetails, 'StateDetailsResponse'),
data: source.data,
timestamp: this.map('Date', source.timestamp, 'string'),
name: source.name,
}
}
export const mapStateCreateToStateRequest: MapFunction<StateCreate, StateRequest> = function(source) {
return {
type: this.map('StateType', source.type, 'ServerStateType'),
message: source.message,
state_details: source.stateDetails ? this.map('StateDetailsCreate', source.stateDetails, 'StateDetailsRequest') : {},
data: source.data,
timestamp: this.map('Date', source.timestamp, 'string'),
name: source.name,
}
}