# Module: main

Contains all customer facing functions to are used to interface with the rest of the application framework.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - main.js, line 3

### Requires

- module:warden
- module:loggers
- module:prompt
- module:allConstantsValidationMetadata
- module:data
- haystacks
- @haystacks/constants
- url
- dotenv
- path

### Methods

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

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 317

##### Returns:

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

Type
  boolean

#### (inner) consoleLog(theNamespacePrefix, theFunctionName, message) → {void}

A wrapper function to expose the loggers.consoleLog function to the client application.

##### Parameters:

Name | Type | Description
--- | --- | ---
`theNamespacePrefix` | string | The namespace of the log that is being sent. Ex: folder.filename
`theFunctionName` | string | The name of the function that log is being called from.
`message` | string | object | The message that should be logged.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 640

##### 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 warden.enqueueCommand function.

##### Parameters:

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 528

##### Returns:

Type
  void

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

A wrapper call to a business rule from the warden.executeBusinessRules.

##### 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 of rule name(s) that should be executed.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 504

##### Returns:

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

Type
  string

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

This is just a wrapper for the warden.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:
  - main.js, line 615

##### Returns:

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

Type
  string | integer | boolean | double | object

#### (inner) initFramework(clientConfiguration) → {void}

Initializes the framework systems.

##### Parameters:

Name | Type | Description
--- | --- | ---
`clientConfiguration` | object | A configuration data object that contains all the data needed to bootstrap the framework for a client application.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 41

##### Returns:

Type
  void

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

Determines if the command queue is empty or not empty. This is a wrapper function for the warden.isCommandQueueEmpty function.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 549

##### Returns:

True or False to indicate if the command execution queue is empty or not. Useful to determine if the command queue should continue executing or not.

Type
  boolean

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

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 170

##### 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 warden.listAllPluginsInRegistryPath. Which is in-turn a wrapper function for chiefPlugin.getAllPluginsInRegistryPath. Which is in-turn a wrapper function for pluginBroker.listPluginsInRegistryPath.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 189

##### Returns:

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

Type
  array.<string>

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

Loads and merges a set of client command aliases with the framework command aliases. This function acts as a wrapper for calling the warden.loadCommandAliases function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandAliasesPath` | string | The path to where the commands aliases XML file is stored, that should be loaded.
`contextName` | string | A name for the set of command aliases that should be used to store the path in the configuration system so it can be loaded by the framework.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 124

##### Returns:

Type
  void

#### (inner) loadCommandWorkflows(workflowPath, contextName) → {void}

Loads and merges a set of client workflows with the framework workflows. This function acts as a wrapper for calling the warden.loadCommandWorkflows function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`workflowPath` | string | The path to where the workflows file is stored, that should be loaded.
`contextName` | string | A name for the workflows that should be used to store the path in the configuration system so it can be loaded by the framework.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 147

##### Returns:

Type
  void

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

A wrapper call to the warden.loadPlugin function. Calls various functions in the chiefPlugn and pluginBroker to load plugin metaData and data: Business 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:
  - main.js, line 355

##### Returns:

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

Type
  boolean

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

A wrapper call to the warden.loadPluginResourceData function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`contextName` | string | The type of resource that is being loaded, eg: configuration, commandAliases, workflows, ect...
`pluginConfigPath` | string | The fully qualified path to where the plugin data is located and should be loaded from.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 481

##### Returns:

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

Type
  object

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

A wrapper call to the warden.loadPlugins function. Calls various functions in the chiefPlugin and pluginBroker to load plugin metaData and data: Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

##### Parameters:

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 377

##### Returns:

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

Type
  boolean

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

A wrapper call to warden.loadPluginsFromRegistry function. Calls various functions in the cief Plugin and pluginBroker to oad plugin metaData and data: Business rules, Commands, Workflows, Constants, Configurations, dependencies ist (dependant plugns), etc...

Author:
  - Seth Hollingsead
Source:
  - main.js, line 399

##### Returns:

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

Type
  boolean

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

A wrapper function to expose the warden.mergeClientBusinessRules functionality.

##### 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:
  - main.js, line 94

##### Returns:

Type
  void

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

A wrapper function to expose the warden.mergeClientCommands functionality.

##### Parameters:

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 109

##### Returns:

Type
  void

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

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 208

##### 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 warden.numberOfPluginsInRegistryPath. Which is in-turn a wrapper function for chiefPlugin.countAllPlugnsInRegistryPath. Which is in-turn a wrapper function for pluginBroker.countPluginsInRegistryPath.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 227

##### Returns:

Teh count of the number of plugn sub-folders in the plugins path listed in the plugn registry data hive.

Type
  integer

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

This is a wrapper function for the warden.processCommandQueue. This leads to a call to the 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:
  - main.js, line 568

##### 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) registerPluginByNameAndPath(pluginName, pluginPath) → {boolean}

This is a wrapper function for warden.registerPluginByNameAndPath. Which is in-turn 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:
  - main.js, line 246

##### 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 warden.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 | object | The value of the configuration setting.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 589

##### Returns:

Type
  void

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

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

Author:
  - Seth Hollingsead
Source:
  - main.js, line 294

##### Returns:

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

Type
  boolean

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

A wrapper call to the warden.unloadAllPlugins function. Calls various functions in the chiefPlugin and pluginBroker to unload and remove all plugin metaData and data: Business rules, Commands, Workflows, Constants, Configurations, dependencies list (dependant plugins), etc...

Author:
  - Seth Hollingsead
Source:
  - main.js, line 462

##### Returns:

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

Type
  boolean

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

A wrapper call to the warden.unloadPlugin function. Calls various functions in the chiefPlugin and pluginBroker to unload and remove metaData and data: 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:
  - main.js, line 418

##### Returns:

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

Type
  boolean

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

A wrapper call to the warden.unloadPlugins function. Calls various functions in 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 list of names of plugins that should be unloaded.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 440

##### 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 warden.unregisterPluginByName. Which is in-turn 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:
  - main.js, line 272

##### 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 warden.writePluginRegistryToDisk. Which is in-turn a wrapper function for chiefPlugin.savePluginRegistryDisk. Which is in-turn a wrapper function for pluginBroker.savePluginRegistry.

Author:
  - Seth Hollingsead
Source:
  - main.js, line 336

##### Returns:

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

Type
  boolean