# Module: dataStringParsing

Contains all system defined business rules for parsing strings as related to data.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 1

### Requires

- module:ruleParsing
- module:loggers
- @haystacks/constants
- crypto
- buffer
- path

### Methods

#### (inner) decryptStringAes256(inputData, inputMetaData) → {string}

Takes an encrypted string and decrypts it using the AES-256 algorithm, returning the original string.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The encrypted string to decrypt.
`inputMetaData` | string | The string used as the decryption seed (same key used for encryption).

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 354

##### Returns:

The decrypted string.

Type
  string

#### (inner) encryptStringAes256(inputData, inputMetaData) → {string}

Takes a string and runs it through an encryption algorithm, returning an encrypted version of the string. The algorithm used for the encryption is AES-256, I've included it as part of the function/rule name because we want to be able to distinguish it from other algorithms that might implement other encryption algorithms, such as RSA.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string to be encrypted.
`inputMetaData` | string | Another string that will be used as the encryption seed. Can be formatted with and "_", with a prefix and post-fix for public/private keys.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 305

##### Returns:

The encrypted string.

Type
  string

#### (inner) getAttributeName(inputData, inputMetaData) → {string}

Takes a string representation of a JSON attribute and gets the name (left hand assignment key).

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string representation of the JSON attribute that should be parsed.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 30

##### Returns:

The name of the attribute.

Type
  string

#### (inner) getAttributeValue(inputData, inputMetaData) → {string}

Takes a string representation of a JSON attribute and gets the value (Right hand assignment value).

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string representation of the JSON attribute that should be parsed.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 59

##### Returns:

The value of the attribute.

Type
  string

#### (inner) getDataCategoryDetailNameFromDataContextName(inputData, inputMetaData) → {string}

Gets the data category detail name from the context name, E.G. Input: Page_ProjectList, data category is 'ProjectList'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The data context name, which should also contain the data category and data category detail name separated by an underscore.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 140

##### Returns:

The data category detail name, such as ProjectDetails or ProjectList.

Type
  string

#### (inner) getDataCategoryFromDataContextName(inputData, inputMetaData) → {string}

Gets the data category from the context name, E.g. Input: Page_ProjectList, data category is 'Page'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The data context name, which should also contain the data category separated by underscore.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 114

##### Returns:

The data category, such as Page or Test.

Type
  string

#### (inner) getKeywordNameFromDataContextName(inputData, inputMetaData) → {string}

Gets the keyword name from the context name, E.g. Input: Keywords_ProjectDetails_DeleteEntireProject, keyword is: 'DeleteEntireProject'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The data context name, which should also contain the data category and data category detail name and keyword name separated by an underscore.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 167

##### Returns:

The keyword name, such as DeleteEntireProject or EditProjectInfoClick.

Type
  string

#### (inner) getUserNameFromEmail(inputData, inputMetaData) → {string}

Converts an email input into a username.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | A string that contains an email address value.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 280

##### Returns:

A string value of the sub-string from before the '@' symbol.

Type
  string

#### (inner) getValueFromAssignmentOperationString(inputData, inputMetaData) → {string}

Parses the input string and finds the value on the right side of the '=' sign.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string that should be parsed for the value on the right side of the assignment operator.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 88

##### Returns:

The string value of whatever is on the right side of the assignment operator.

Type
  string

#### (inner) loadDataFile(inputData, inputMetaData) → {boolean}

Loads data from a specified file and stores it in the specified data hive path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The full path and file name for the file that should be loaded into memory.
`inputMetaData` | string | The data hive path where the data should be stored once it is loaded.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 194

##### Returns:

The data that was loaded, because sometimes a client command might need to use this to load data.

Type
  boolean

#### (inner) obfuscateString(inputData, inputMetaData) → {string}

Takes a string and converts it to an obfuscated version of the same string. This means converting the string into something that is unintelligible or unreadable from the original string. In our case we will convert the string into all stars '*', just like as if the string was a password.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string to be obfuscated, or converted into all stars of the same length.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 405

##### Returns:

A string of '*' characters of the same length as the input string.

Type
  string

#### (inner) saveDataFile(inputData, inputMetaData) → {boolean}

Saves data from a specified data to a specified path and file name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The full path and file name were the data should be saved.
`inputMetaData` | object | The data that should be saved out to the specified file.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/dataStringParsing.js, line 242

##### Returns:

True or False value to indicate if the file was saved successfully or not.

Type
  boolean