X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/952aa1c7170d4b24951f40ed66b5f19a53d11daf..refs/heads/14433_properties_inside_projects:/src/models/workflow.ts diff --git a/src/models/workflow.ts b/src/models/workflow.ts index 923a9cbd..3a38348e 100644 --- a/src/models/workflow.ts +++ b/src/models/workflow.ts @@ -31,13 +31,21 @@ export interface CommandLineTool { outputs: any[]; } -export interface CommandInputParameter { - id: string; - label?: string; - doc?: string | string[]; - default?: any; - type?: CWLType | CWLType[] | CommandInputEnumSchema | CommandInputArraySchema; -} +export type CommandInputParameter = + BooleanCommandInputParameter | + IntCommandInputParameter | + LongCommandInputParameter | + FloatCommandInputParameter | + DoubleCommandInputParameter | + StringCommandInputParameter | + FileCommandInputParameter | + DirectoryCommandInputParameter | + StringArrayCommandInputParameter | + IntArrayCommandInputParameter | + FloatArrayCommandInputParameter | + FileArrayCommandInputParameter | + DirectoryArrayCommandInputParameter | + EnumCommandInputParameter; export enum CWLType { NULL = 'null', @@ -58,8 +66,8 @@ export interface CommandInputEnumSchema { name?: string; } -export interface CommandInputArraySchema { - items: CWLType; +export interface CommandInputArraySchema { + items: ItemType; type: 'array'; label?: string; } @@ -78,6 +86,36 @@ export interface Directory { basename?: string; } +export interface GenericCommandInputParameter { + id: string; + label?: string; + doc?: string | string[]; + default?: Value; + type?: Type | Array; + value?: Value; + disabled?: boolean; +} +export type GenericArrayCommandInputParameter = GenericCommandInputParameter, Value[]>; + +export type BooleanCommandInputParameter = GenericCommandInputParameter; +export type IntCommandInputParameter = GenericCommandInputParameter; +export type LongCommandInputParameter = GenericCommandInputParameter; +export type FloatCommandInputParameter = GenericCommandInputParameter; +export type DoubleCommandInputParameter = GenericCommandInputParameter; +export type StringCommandInputParameter = GenericCommandInputParameter; +export type FileCommandInputParameter = GenericCommandInputParameter; +export type DirectoryCommandInputParameter = GenericCommandInputParameter; +export type EnumCommandInputParameter = GenericCommandInputParameter; + +export type StringArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type IntArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type FloatArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter; +export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter; + +export type WorkflowInputsData = { + [key: string]: boolean | number | string | File | Directory; +}; export const parseWorkflowDefinition = (workflow: WorkflowResource): WorkflowResoruceDefinition => { const definition = safeLoad(workflow.definition); return definition; @@ -89,6 +127,31 @@ export const getWorkflowInputs = (workflowDefinition: WorkflowResoruceDefinition ? mainWorkflow.inputs : undefined; }; +export const getInputLabel = (input: CommandInputParameter) => { + return `${input.label || input.id}`; +}; + +export const isRequiredInput = ({ type }: CommandInputParameter) => { + if (type instanceof Array) { + for (const t of type) { + if (t === CWLType.NULL) { + return false; + } + } + } + return true; +}; + +export const isPrimitiveOfType = (input: GenericCommandInputParameter, type: CWLType) => + input.type instanceof Array + ? input.type.indexOf(type) > -1 + : input.type === type; + +export const isArrayOfType = (input: GenericCommandInputParameter, type: CWLType) => + typeof input.type === 'object' && + input.type.type === 'array' + ? input.type.items === type + : false; export const stringifyInputType = ({ type }: CommandInputParameter) => { if (typeof type === 'string') {