feat(core): extract params from workflow
This commit is contained in:
@@ -46,5 +46,28 @@ export default class Preprocessor {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts parameter names from the workflow.
|
||||
* @param {WorkflowFile} workflow The given workflow
|
||||
* @returns {String[]} List of parameters' names.
|
||||
*/
|
||||
static getParams(workflow: WorkflowFile) : string[] {
|
||||
const getParamsRecurse = (object : any) : string[] => {
|
||||
if (typeof object === 'object') {
|
||||
// Recursion base case
|
||||
if (object.$param) {
|
||||
return [object.$param];
|
||||
}
|
||||
|
||||
// Recursion general case
|
||||
return Object.values(object)
|
||||
.reduce((p: string[], v : any) : string[] => [...p, ...getParamsRecurse(v)], []);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
return getParamsRecurse(workflow.workflow);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user