# 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) 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 306

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

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

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

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

##### 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) 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) 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) 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 234

##### 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) 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 255

##### Returns:

Type
  void