@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_.
32 lines (29 loc) • 1.14 kB
text/typescript
import { sortStringArray } from '@prefecthq/prefect-design'
import { Variable, VariableCreate, VariableEdit } from '@/models'
import { VariableCreateRequest, VariableEditRequest } from '@/models/api/VariableRequest'
import { VariableResponse } from '@/models/api/VariableResponse'
import { MapFunction } from '@/services/Mapper'
export const mapVariableResponseToVariable: MapFunction<VariableResponse, Variable> = function(source) {
return new Variable({
id: source.id,
name: source.name,
value: source.value,
tags: sortStringArray(source.tags ?? []),
created: this.map('string', source.created, 'Date'),
updated: this.map('string', source.updated, 'Date'),
})
}
export const mapVariableEditToVariableEditRequest: MapFunction<VariableEdit, VariableEditRequest> = function(source) {
return {
name: source.name,
value: JSON.parse(source.value),
tags: source.tags,
}
}
export const mapVariableCreateToVariableCreateRequest: MapFunction<VariableCreate, VariableCreateRequest> = function(source) {
return {
name: source.name,
value: JSON.parse(source.value),
tags: source.tags,
}
}