npm package: @gatekeeper_technology/report-utils
Description: Gatekeeper's pdf/email Utils - shared in NPM
Author: David Holtzhausen
Latest version: 1.3.2

# Gatekeeper's report utils
Gatekeeper's pdf/email Utils - shared in NPM

## Set-up
1. Create a `.npmrc` file containing: `//registry.npmjs.org/:_authToken=<publish-npm-token>`. You can find the *publish* `npm-token` on onePassword.

## Updating
1. Put your code changes in `index.js`.
	- If you added a new function, write jest test cases for it.
2. Update the version number in the `package.json`.
3. Describe your changes in the `README.md` changelog.
4. Test your code before publishing:
	- Navigate one directory back
	- Open the terminal.
	- Execute `npm install @gatekeeper_technology/report-utils`.
	- If any error fix them.
	- Navigate back into the `report-utils` directory
    	- Make sure you have jest installed on your machine.
	- run `npm test` to test that all the functions are working correctly.
5. Execute `cd report-utils` and `npm publish` in the terminal.
6. Commit & Push your changes to GitHub.

## Using this package in a JourneyApps CloudCode Task.
- In your CloudCode, open the `package.json` file and make sure you have the following code:
	```
	"dependencies": {
		"@gatekeeper_technology/report-utils": "<current-version-number>"
	}
	```
	, where `<current-version-number>` is the version number saved in this repo's `package.json` file.
- In the JavaScript code add the following line at the top of the page: `const utils = require("@gatekeeper_technology/report-utils");`.
- Create a `.npmrc` file (in the CC task) containing: `//registry.npmjs.org/:_authToken=<read-only-npm-token>`. You can find the *read-only* `npm-token` on 1Password.
- You can check at the top of this repo's `index.js` file to see which functions we export. We should update the list of functionality soon.
- Happy coding!

## Functionality
This package has three parts
 - date_time_utils - Functions that format JavaScript datetime objects to a readable/printable format
 - email_utils - These functions ensure that the specified email addresses do not violate any of the SendGrid v3 requirements and implements whitelisting 
 - photo_attachment_utils - 
## Changelog
### [1.3.1]
#### Removed
- Updated the rollbar-utils version

### [1.2.1]
#### Removed
- `dist` ignore file in `.npmignore`.

### [1.2.0]
#### Added
- Added `postToJourneyBackend` function
- Added `journeyApps` npm packages as dependencies to assist with the reportUtil package.
- Added `sortArrayByField` function
- Added `generateHTML` function
- Added `formatText` function
- Added `getImageContentForPDF` function

#### Changed
- Migrated to TypeScript
- All date functions should now be able to accept `Day` variables.
- `.gitignore` file now ignores compiled files.
- `isAttachment(s)Uploaded` functions no longer reschedules. It now throws an error with the cause = `attachments-uploading`

### [1.1.10]
#### Removed
- Removed `loadBase64` function in a race against time.

### [1.1.9]
#### Added
- Jest Test cases
- formatText, sortArrayByField and generateHTML functions
- .d.ts files.
  
### [1.1.8]
#### Changed
- Added more validation on general utils
  
#### Added
- Unit Tests on General Utils.
  
#### Removed
- console.error() on date Utils.

### [1.1.7]
#### Changed
- Fixed funky way of throwing errors
- Added a new utils folder with small internal utils

### [1.1.6]
#### Changed
- When retrying a task, we don't need to specify the CloudCode task name as we can access it programmatically

### [1.1.5]
#### Added
- isSameDay: Checks if the given two dates falls on the same day (second date value defaults to now).
- compareDates: Checks if the given two dates falls on the same date and time (return 0), date 1 is before date 2 (returns -1), otherwise returns 1 (second date value defaults to now).
#### Removed
- isToday: Can be used via the isSameDay() function
- isPastDate and isFutureDate: Can be user via the compareDates() function
#### Changed
- Improved Test file (WIP)

### [1.1.4]
#### Added
- areEqualDates
- areEqualDateTimes
- isToday
- getStartOfWeek
- getEndOfWeek
- getWeekNumber
- isFutureDate
- isPastDate

### [1.1.3]
#### Fixed
- A bug where you cannot import the `report-utils` package in the `/mobile` side of an App.

### [1.1.2]
#### Changed
- [TESTING] Moved the `loadImageBase64` function to `index.js` to see if the required("fs") problem is fixed.

### [1.1.1]
#### Changed
- [TESTING] Moved the require("fs") out of the function.

### [1.1.0]
#### Changed
 - Refactored the file structure to separate the concerns.
 - Replaced `displayPhoto` with `journeyPhotoToBase64`, it now has a more descriptive name
 - Replaced  `loadPhotoOrSignature` with  `getPhotoOrSignatureData`, it's now up to the developer to load the data into a data hash.
 - Replaced  `loadSignatureBase64` with  `encodeBase64ImagePNG`, renamed function and changed the input parameter to the actual image data.

### [1.00.07]
#### Added
- `index.js`: Added the ability to specify in which environments to enable email whitelisting.

### [1.00.06]
#### Changed
- `index.js`: Emails are first trimmed and toLowerCase'd before checking if it is valid.

### [1.00.05]
#### Changed
- `index.js`: Changed the way `loadAttachments` function receives retry_count value. 

### [1.00.04]
#### Fixed
- `index.js`: a Bug where the `loadPhotoOrSignature` function was out of date.

### [1.00.03]
#### Changed
- `index.js`: Emails check now convert all emails to lowercase before checking for duplicates.

### [1.00.02]
#### Added
- `index.js`: Added function `displayTimeWithSeconds`.
#### Changed
- `index.js`: improved javadocs commenting .

### [1.00.01]
#### Changed
- `Readme.md`: explanation improved.
- `index.js`: Added functions `displayDateTime` and `displayTime`.

### [1.00.00]
#### Added
- `package.json`: Added.
- `index.js`: Added and populated with Gatekeeper's handlebarUtil functions.
- `.npmignore`: Added.
- `.gitignore`: Added.
- `README.md`: Added with description, set-up and change-log.