# Module: workflowBroker

Holds all fo the low level functions that manage the workflows, system defined workflows, client defined workflows, setting the workflow data and getting the workflow data.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - brokers/workflowBroker.js, line 1

### Requires

- module:loggers
- module:data
- path

### Methods

#### (inner) doesWorkflowExist(workflowName) → {boolean}

Uses the recursive searchWorkflow function to determine if the workflow can be found in the workflow data structure.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowName` | string | The name of the workflow that should be searched for.

Author:
  - Seth Hollingsead
Source:
  - brokers/workflowBroker.js, line 52

##### Returns:

True or False to indicate if the workflow already exists or not.

Type
  boolean

#### (inner) doesWorkflowExistInWorkflowData(workflowData, workflowName) → {boolean}

Searches through a data structure to determine if the specified workflow exists within it.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowData` | object | The workflow data structure that should be searched for the specified workflow.
`workflowName` | string | The name of the workflow that should be searched for in the workflow data structure.

Source:
  - brokers/workflowBroker.js, line 76

##### Returns:

True or False to indicate if the workflow was found or not.

Type
  boolean

#### (inner) getAllWorkflows(workflowDataStructure) → {array.<string>|boolean}

Recursively gets all of the workflows from all levels and flattens them into a single array for printing out to the workflow help command.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowDataStructure` | object | The workflow data structure that should be recursively flattened into a single array for output. If the input is undefined then the main CommandWorkflows data structure will be used at the root of the workflows data hive.

Author:
  - Seth Hollingsead
Source:
  - brokers/workflowBroker.js, line 142

##### Returns:

An array of all the workflows currently loaded into the D-data structure under the CommandWorkflows data hive or a boolean True or False to indicate that a leaf-node has been found by the recursive caller.

Type
  array.<string> | boolean

#### (inner) getWorkflow(workflowName) → {string|boolean}

Given the name of the workflow that is being requested, get that workflow from the D-data structure workflows data hive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowName` | string | The name of the workflow we should get workflow data for.

Author:
  - Seth Hollingsead
Source:
  - brokers/workflowBroker.js, line 27

##### Returns:

The workflow value, which ideally would be a list of commands and command parameters. False if no workflow by the specified name was found.

Type
  string | boolean

#### (inner) getWorkflowNamespaceDataObject(workflowDataStructure, namespaceToFind) → {object|boolean}

Recursively scans through the entire workflow metaData data structure looking for an object that matches the input namespace name. When that namespace is found, the entire object is returned.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowDataStructure` | object | The workflow data structure that should be recursively searched for the namespace specified. If the input is undefined then the main CommandWorkflows data structure will be used at the root of the workflows data hive.
`namespaceToFind` | string | The namespace to look for in the workflow metaData data structure.

Author:
  - Seth Hollingsead
Source:
  - brokers/workflowBroker.js, line 203

##### Returns:

The namespace object if it is found, or False if the namespace object was not found.

Type
  object | boolean

#### (inner) searchWorkflow(allWorkflows, workflowName) → {object}

This is a recursive function that searches through all the workflow data structures and returns the one workflow data object that matches the input name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`allWorkflows` | object | The workflow data that should be searched recursively for the specified workflow.
`workflowName` | string | The name of the workflow that should be found.

Author:
  - Seth Hollingsead
Source:
  - brokers/workflowBroker.js, line 99

##### Returns:

The workflow object that corresponds to the input workflow name.

Type
  object