X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/55acac755ba2516c63e902a11e90c6e3754e5c48..cfa88a0915d5a49a6eb870505c346db2dbd58648:/src/models/workflow.ts diff --git a/src/models/workflow.ts b/src/models/workflow.ts index 12f253acfe..369db4c7c7 100644 --- a/src/models/workflow.ts +++ b/src/models/workflow.ts @@ -4,6 +4,7 @@ import { Resource, ResourceKind } from "./resource"; import { safeLoad } from 'js-yaml'; +import { CommandOutputParameter } from "cwlts/mappings/v1.0/CommandOutputParameter"; export interface WorkflowResource extends Resource { kind: ResourceKind.WORKFLOW; @@ -152,11 +153,18 @@ export const getWorkflowInputs = (workflowDefinition: WorkflowResourceDefinition : undefined; }; +export const getWorkflowOutputs = (workflowDefinition: WorkflowResourceDefinition) => { + if (!workflowDefinition) { return undefined; } + return getWorkflow(workflowDefinition) + ? getWorkflow(workflowDefinition)!.outputs + : undefined; +}; + export const getInputLabel = (input: CommandInputParameter) => { return `${input.label || input.id.split('/').pop()}`; }; -export const getInputId = (input: CommandInputParameter) => { +export const getIOParamId = (input: CommandInputParameter | CommandOutputParameter) => { return `${input.id.split('/').pop()}`; }; @@ -177,10 +185,31 @@ export const isPrimitiveOfType = (input: GenericCommandInputParameter, : input.type === type; export const isArrayOfType = (input: GenericCommandInputParameter, type: CWLType) => - typeof input.type === 'object' && - input.type.type === 'array' - ? input.type.items === type - : false; + input.type instanceof Array + ? (input.type.filter(t => typeof t === 'object' && + t.type === 'array' && + t.items === type).length > 0) + : (typeof input.type === 'object' && + input.type.type === 'array' && + input.type.items === type); + +export const getEnumType = (input: GenericCommandInputParameter) => { + if (input.type instanceof Array) { + const f = input.type.filter(t => typeof t === 'object' && + !(t instanceof Array) && + t.type === 'enum'); + if (f.length > 0) { + return f[0]; + } + } else { + if ((typeof input.type === 'object' && + !(input.type instanceof Array) && + input.type.type === 'enum')) { + return input.type; + } + } + return null; +}; export const stringifyInputType = ({ type }: CommandInputParameter) => { if (typeof type === 'string') {