-
-const formatInputData = (inputs: CommandInputParameter[], auth: AuthState): ProcessIOParameter[] => {
- return inputs.map(input => {
- return {
- id: getInputId(input),
- doc: input.label || "",
- value: getInputDisplayValue(auth, input)
- };
- });
-};
-
-const formatOutputData = (rawData: any, pdh: string | undefined, auth: AuthState): ProcessIOParameter[] => {
- if (!rawData) { return []; }
- return Object.keys(rawData).map((id): ProcessIOParameter => {
- const multiple = rawData[id].length > 0;
- const outputArray = multiple ? rawData[id] : [rawData[id]];
- return {
- id,
- doc: outputArray.map((outputParam: CommandOutputParameter) => (outputParam.doc))
- // Doc can be string or string[], concat conveniently works with both
- .reduce((acc: string[], input: string | string[]) => (acc.concat(input)), [])
- // Remove undefined and empty doc strings
- .filter(str => str)
- .join(", "),
- value: outputArray.map(outputParam => getInputDisplayValue(auth, {
- type: outputParam.class,
- value: outputParam,
- ...outputParam
- }, pdh, outputParam.secondaryFiles))
- .reduce((acc: ProcessIOParameter[], params: ProcessIOParameter[]) => (acc.concat(params)), [])
- };
- });
-};