@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_.
28 lines (25 loc) • 1.11 kB
text/typescript
import { CollectionItem, CollectionItemResponse, CollectionsResponse } from '@/models'
import { MapFunction } from '@/services/Mapper'
export const mapCollectionItemResponseToCollectionItem: MapFunction<CollectionItemResponse, CollectionItem> = function(source) {
return {
collectionType: 'flow',
name: source.name,
description: source.description.summary,
returns: source.description.returns,
examples: source.description.examples,
documentationUrl: source.documentation_url,
entrypoint: source.entrypoint,
installCommand: source.install_command,
logoUrl: source.logo_url,
parameters: source.parameters,
path: source.path_containing_flow,
repositoryUrl: source.repo_url,
slug: source.slug,
}
}
export const mapCollectionResponseToCollectionItems: MapFunction<CollectionsResponse, CollectionItem[]> = function(source) {
return Object.entries(source).flatMap(([category, collection]) => {
const mapped = this.map('CollectionItemResponse', Object.values(collection), 'CollectionItem')
return mapped.map(item => ({ ...item, category }))
})
}