UNPKG

@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_.

31 lines (28 loc) 1.41 kB
import { SelectOption } from '@prefecthq/prefect-design' import { BlockDocumentResponse } from '@/models/api/BlockDocumentResponse' import { BlockDocument } from '@/models/BlockDocument' import { createObjectLevelCan } from '@/models/ObjectLevelCan' import { MapFunction } from '@/services/Mapper' export const mapBlockDocumentResponseToBlockDocument: MapFunction<BlockDocumentResponse, BlockDocument> = function(source) { const blockSchema = this.map('BlockSchemaResponse', source.block_schema, 'BlockSchema') return new BlockDocument({ id: source.id, name: source.name, isAnonymous: source.is_anonymous, blockSchemaId: source.block_schema_id, blockTypeId: source.block_type_id, created: this.map('string', source.created, 'Date'), updated: this.map('string', source.updated, 'Date'), blockDocumentReferences: this.map('BlockDocumentReferencesResponse', source.block_document_references, 'BlockDocumentReferences'), blockType: this.map('BlockTypeResponse', source.block_type, 'BlockType'), blockSchema, data: this.map('SchemaValuesResponse', { values: source.data, references: source.block_document_references, schema: blockSchema.fields }, 'SchemaValues'), can: createObjectLevelCan(), }) } export const mapBlockDocumentToSelectOption: MapFunction<BlockDocument, SelectOption> = function({ name, id }) { return { label: name, value: id, } }