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;
export const getWorkflow = (workflowDefinition: WorkflowResourceDefinition) => {
if (!workflowDefinition.$graph) { return undefined; }
- const mainWorkflow = workflowDefinition.$graph.find(item => item.class === 'Workflow' && item.id === '#main');
+ const mainWorkflow = workflowDefinition.$graph.find(item => item.id === '#main');
return mainWorkflow
? mainWorkflow
: undefined;
: 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}`;
+ return `${input.label || input.id.split('/').pop()}`;
+};
+
+export const getIOParamId = (input: CommandInputParameter | CommandOutputParameter) => {
+ return `${input.id.split('/').pop()}`;
};
export const isRequiredInput = ({ type }: CommandInputParameter) => {
: input.type === type;
export const isArrayOfType = (input: GenericCommandInputParameter<any, any>, 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<any, any>) => {
+ 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') {