# Module: warden

Contains all the functions to manage the entire application framework at the highest level. Also provides an interface to easily manage all the framework features & various functionality from a single entry point.

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

### Requires

- module:dataBroker
- module:ruleBroker
- module:chiefCommander
- module:chiefConfiguration
- module:chiefData
- module:chiefWorkflow
- module:configurator
- module:loggers
- @haystacks/constants
- path

### Methods

#### (inner) consoleLog(classPath, message) → {void}

This is just a wrapper for the loggers.consoleLog function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`classPath` | string | The class path fro the caller of this function file.function or class.method.
`message` | string | boolean | integer | object | The message or data content that should be dumped to the output.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 428

##### Returns:

Type
  void

#### (inner) enqueueCommand(command) → {void}

Adds a command to the command queue. It is worth noting that a command could actually load a whole workflow of commands. So one command can spawn into many commands that cause the command queue to be very full with a very complicated workflow. This also acts as a wrapper for the chiefCommander.enqueueCommand function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`command` | string | The command to add to the command queue for executing.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 315

##### Returns:

Type
  void

#### (inner) executeBusinessRules(inputs, businessRules) → {string}

A wrapper to call a business rule from the application level code.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputs` | array.<(string|integer|boolean|object|function()), (string|integer|boolean|object|function())> | The array of inputs: inputs[0] = inputData - The input to the rule that is being called. inputs[1] = inputMetaData - Additional data the input to the rule.
`businessRules` | array.<string> | The array that contains the name(s) of the business rule that should be executed.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 290

##### Returns:

The value that is returned from the rule is also returned.

Type
  string

#### (inner) getConfigurationSetting(configurationNamespace, configurationName) → {string|integer|boolean|double}

This is just a wrapper for the configurator getConfigurationSetting function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`configurationNamespace` | string | The path in the configuration JSON object where the configuration setting should be found.
`configurationName` | string | The key of the configuration setting.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 403

##### Returns:

The value of whatever was stored in the D[configuration].

Type
  string | integer | boolean | double

#### (inner) initFrameworkSchema(configData) → {void}

Setup all the framework data and configuration settings.

##### Parameters:

Name | Type | Description
--- | --- | ---
`configData` | object | All of the configuration data that should be parsed as part of the setup process.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 68

##### Returns:

Type
  void

#### (inner) isCommandQueueEmpty() → {boolean}

This is a wrapper for the chiefCommander.isCommandQueueEmpty function. Determines if the command queue is empty or not, which also determines if the application should continue executing commands from the command queue in sequential order or prompt for another command or exit.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 336

##### Returns:

True or False to indicate if command execution should continue or not.

Type
  boolean

#### (inner) loadCommandAliases(commandAliasesPath) → {void}

Loads and merges both the system defined command aliases XML file and the client defined command aliases XML file, or an optional user defined command aliases path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandAliasesPath` | string | The configuration name of the configuration setting where the path to the commands aliases XML file is stored, that should be loaded (OPTIONAL).

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 217

##### Returns:

Type
  void

#### (inner) loadCommandWorkflows(workflowPathConfigName) → {void}

Loads and merges both the system defined command workflows XML file and client defined command workflows XML file, or an optional user defined workflow path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowPathConfigName` | string | The configuration name of the configuration setting where the path to the workflows XML file is stored, that should be loaded (OPTIONAL).

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 254

##### Returns:

Type
  void

#### (inner) mergeClientBusinessRules(clientBusinessRules) → {void}

Merges the map of client defined business rule names and client defined business rule function calls with the existing D-data structure that should already have all of the system defined business rule.

##### Parameters:

Name | Type | Description
--- | --- | ---
`clientBusinessRules` | object | A map of client defined business rule names and client defined business rule function calls.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 183

##### Returns:

Type
  void

#### (inner) mergeClientCommands(clientCommands) → {void}

Merges the map of client defined command names and client defined command function calls with the existing D-data structure that should already have all of the system defined commands.

##### Parameters:

Name | Type | Description
--- | --- | ---
`clientCommands` | object | A map of client defined command names and client defined command function calls.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 200

##### Returns:

Type
  void

#### (inner) processCommandQueue() → {array.<boolean, (string|integer|boolean|object|array)>}

This is just a wrapper for the chiefCommander.processCommandQueue function, which will ultimately call chiefCommander.processCommand to process an individual command. This is because a command could actually invoke a command workflow that might enqueue a bunch of commands to the command queue. All of them must be executed in sequence as part of the main application loop.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 356

##### Returns:

An array with a boolean True or False value to indicate if the application should exit or not exit, followed by the command output.

Type
  array.<boolean, (string|integer|boolean|object|array)>

#### (inner) processRootPath(inputPath, actualFrameworkName) → {string}

Processes the root path of the application using business rules.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputPath` | string | The path for the entry point to the framework, ie: main.js
`actualFrameworkName` | string | The name of the framework that the application is expecting to use.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 40

##### Returns:

the true root path of the application.

Type
  string

#### (inner) setConfigurationSetting(configurationNamespace, configurationName, configurationValue) → {void}

This is just a wrapper for the configurator setConfigurationSetting function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`configurationNamespace` | string | The path in the configuration JSON object where the configuration setting should be set. Ex: businessRules.rules.stringParsing.countCamelCaseWords
`configurationName` | string | The key of the configuration setting.
`configurationValue` | string | integer | boolean | double | The value of the configuration setting.

Author:
  - Seth Hollingsead
Source:
  - controllers/warden.js, line 377

##### Returns:

Type
  void