# 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:chiefPlugin
- module:chiefWorkflow
- module:configurator
- module:loggers
- @haystacks/constants
- path

### Methods

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

This is a wrapper function for chiefPlugin.clearPluginRegistry. Which is in-turn a wrapper function for pluginBroker.unregisterAllPlugins.

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

##### Returns:

True or False to indicate if the plugin registry data hive was cleared successfully or not.

Type
  boolean

#### (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 854

##### 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 741

##### 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 716

##### 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 829

##### 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 71

##### 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 762

##### Returns:

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

Type
  boolean

#### (inner) listAllPluginsInRegistry() → {array.<string>}

This is a wrapper function for chiefPlugin.getAllPluginsInRegistry. Which is in-turn a wrapper function for pluginBroker.listPluginsInRegistry.

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

##### Returns:

A list array of the names of the plugins in the plugin registry.

Type
  array.<string>

#### (inner) listAllPluginsInRegistryPath() → {array.<string>}

This is a wrapper function for chiefPlugin.getAllPluginsInRegistryPath. Which is in-turn a wrapper function for pluginBroker.listPluginsInRegistryPath.

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

##### Returns:

A list array of the names of the plugins in the plugin registry.

Type
  array.<string>

#### (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 271

##### 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 308

##### Returns:

Type
  void

#### (inner) loadPlugin(pluginPath) → {boolean}

Calls the plugin initializePlugin function to get the plugin data: Busienss rules, Commands, Workflows, Constants, Configurations, dependencies ist (dependant plugins), etc...

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginPath` | string | The fully qualified path where to load the plugin from.

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

##### Returns:

True or False to indicate if the plugin was loaded successfully or not.

Type
  boolean

#### (inner) loadPluginResourceData(contextName, pluginResourcePath) → {object}

Calls the necessary functions to load and parse the resource data from the specified path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`contextName` | string | The type of resource that is being loaded, eg: configuration, commandAliases, workflows, ect...
`pluginResourcePath` | string | The fully qualified path to the plugin resource data.

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

##### Returns:

The JSON data that is loaded and parsed from the plugin path.

Type
  object

#### (inner) loadPlugins(pluginsPaths) → {boolean}

Calls the plugin initializePlugin function to get the plugin data, for each of the plugins in the input array of plugin paths: Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginsPaths` | array.<string> | An array of fully qualified paths where to load the plugins from.

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

##### Returns:

True or False to indicate if all the plugins were loaded or not.

Type
  boolean

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

Calls the plugin initializePlugin function to get teh plugin data, for each of the plugins and their paths from the plugin registry. Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

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

##### Returns:

True or False to ndicate if all the plugins were loaded or not.

Type
  boolean

#### (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 237

##### 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 254

##### Returns:

Type
  void

#### (inner) numberOfPluginsInRegistry() → {integer}

This is a wrapper function for chiefPlugin.countAllPluginsInRegistry. Which is in-turn a wrapper function for pluginBroker.countPluginsInRegistry.

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

##### Returns:

The count of the number of plugins listed in the plugin registry data hive.

Type
  integer

#### (inner) numberOfPluginsInRegistryPath() → {integer}

This is a wrapper function for chiefPlugin.countAllPluginsInRegistryPath. Which is in-turn a wrapper function for pluginBroker.countPluginsInRegistryPath.

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

##### Returns:

The count of the number of plugin sub-folders in the plugins path listed in the plugin registry data hive.

Type
  integer

#### (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 782

##### 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 43

##### Returns:

the true root path of the application.

Type
  string

#### (inner) registerPluginByNameAndPath(pluginName, pluginPath) → {boolean}

This is a wrapper function for chiefPlugin.registerNamedPlugin. Which is in-turn a wrapper function for pluginBroker.registerPlugin.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginName` | string | The name of the plugin that should be registered.
`pluginPath` | string | The path to the plugin, to be added to the plugin registry. This should be the path to the plugin/package.json file, but not including the package.json as part of the path URI.

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

##### Returns:

True or False to indicate if the plugin was added to the plugin registry successfully or not.

Type
  boolean

#### (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 803

##### Returns:

Type
  void

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

This is a wrapper function for chiefPlugin.synchronizePluginRegistryWithPath Which is in-turn a wrapper function for pluginBroker.synchPluginRegistryWithPluginRegistryPath.

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

##### Returns:

True or False to indicate if the synchronization was performed successfully or not.

Type
  boolean

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

Calls various functions in the chiefPlugin and pluginBroker to unload and remove all plugin metaData and data: Business rules, Commands, Workflows, Constants, Configurations, dependencies ist (dependant plugins), etc...

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

##### Returns:

True or False to indicate if all the plugins were unloaded successfully or not.

Type
  boolean

#### (inner) unloadPlugin(pluginName) → {boolean}

Calls various functions in the chiefPlugin and pluginBroker to unload and remove all plugin metaData and data for the specified plugin: Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginName` | string | The name of the plugin that should be unloaded.

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

##### Returns:

True or False to indicate if the plugin was unloaded successfully or not.

Type
  boolean

#### (inner) unloadPlugins(pluginNames) → {boolean}

Calls various functions n the chiefPlugin and pluginBroker to unload and remove all the metaData and data for a list of plugins: Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginNames` | array.<string> | An array ist of names of plugins that should be unloaded.

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

##### Returns:

True or False to indicate if all the plugins were unloaded successfully or not.

Type
  boolean

#### (inner) unregisterPluginByName(pluginName) → {boolean}

This is a wrapper function for chiefPlugin.unregisterNamedPlugin. Which is in-turn a wrapper function for pluginBroker.unregisterPlugin.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pluginName` | string | The name of the plugin that should be removed from the plugin registry.

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

##### Returns:

True or False to indicate if the plugin was removed from the plugin registry successfully or not.

Type
  boolean

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

This is a wrapper function for chiefPlugin.savePluginRegistryDisk. Which is in-turn a wrapper function for pluginBroker.savePluginRegistry.

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

##### Returns:

True or False to indicate if the plugin registry was successfully saved to the disk or not.

Type
  boolean