import { IHandlerParameters , ImperativeError } from "@zowe/imperative" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; import { ListWorkflows , IWorkflowInfo , IStepSummary , PropertiesWorkflow } from "@zowe/zos-workflows-for-zowe-sdk" ; /**
 * A Handler for listing details of a workflow instance in z/OSMF in zosworkflows package.
 * This is not something that is intended to be used outside of this npm package.
 */ export default class ActiveWorkflowDetails extends ZosmfBaseHandler { private type { * } memberof private arguments : any ; param { IHandlerParameters } params returns { Promise < void > } memberof public async processCmd ( params ) { this . arguments = params . arguments ; let workflowKey ; let response ; let requireSteps ; let stepSummaries = [ ] ; let error ; if ( this . arguments . workflowKey ) { workflowKey = this . arguments . workflowKey ; } else if ( this . arguments . workflowName ) { workflowKey = await ListWorkflows . getWfKey ( this . mSession , this . arguments . workflowName , undefined ) ; if ( ! workflowKey ) { throw new ImperativeError ( { msg : `No workflows match the provided workflow name.` , additionalDetails : JSON . stringify ( params ) } ) ; } } this . arguments . listSteps || this . arguments . stepsSummaryOnly ? requireSteps = true : requireSteps = false ; try { response = await PropertiesWorkflow . getWorkflowProperties ( this . mSession , workflowKey , undefined , requireSteps , this . arguments . listVariables ) ; if ( this . arguments . stepsSummaryOnly && response . steps ) { stepSummaries = await PropertiesWorkflow . processStepSummaries ( response . steps ) ; } else { stepSummaries = response . steps ; } } catch ( err ) { error = "List workflow details error: " + err ; throw error ; } params . response . data . setObj ( response ) ; if ( ! this . arguments . skipWorkflowSummary && ! this . arguments . stepsSummaryOnly ) { params . response . console . log ( "\nWorkflow Details: " ) ; params . response . format . output ( { fields : [ "workflowName" , "workflowKey" , response . automationStatus ? "automationStatus.messageText" : "automationStatus" ] , output : response , format : "object" } ) ; } if ( response . steps ) { params . response . console . log ( "\nWorkflow Steps: " ) ; params . response . format . output ( { fields : [ "name" , "state" , "stepNumber" , this . arguments . stepsSummaryOnly ? "misc" : "" ] , output : stepSummaries , format : "table" , header : true } ) ; } if ( this . arguments . listVariables && response . variables ) { params . response . console . log ( "\nWorkflow Variables: " ) ; params . response . format . output ( { fields : [ "name" , "value" , "type" ] , output : response . variables , format : "table" , header : true } ) ; } } }