npm package: @huumun/lyra
Description: Client package for accessing data/content from LYRA - huumun Data Management solution
Author: Sahil David, Margarida López
Latest version: 8.4.3


*Author: Sahil David, Margarida López | Date: August 17th, 2020 | Last updated: June 14th 2022*
# LYRA Integration

## Overview

LYRA is a Content Management Solution which is one of the solutions as a part of huumun Platform Suite. LYRA provides variable yet flexible data structures which gives the unique edge and ability to store data/content suited to your application.

LYRA offers keys in the form of, `brandKey` and `projectKey` which are generated automatically during the setup. These keys are required to make a connection to LYRA Platform from an application. 

For details about access keys please contact *Margarida Lopez <margarida.lopez@huumun.com>* or *huumun Developers <developers@huumun.com>*

## Using the package

LYRA offers an npm package for Integrating Vue application with LYRA

*Following are the steps to use LYRA client npm package:*

To install package:
```powershell
npm i @huumun/lyra
```

Once installed LYRA can be installed into Vue App.

You also need to create `lyra.config.js` file in your root folder of Vue App. This serves as configuration file for package
```js
module.exports = {
	brandKey: 'brandKey from LYRA',
	projectKey: 'projectKey from LYRA',
	localisations: [
		{ localisation: 'localisation-code', default: 'boolean', newInstance: 'boolean' }
	]
};

```

```js
import lyraConfig from './lyra.config';
import { vueLyra } from '@huumun/lyra';

Vue.use(vueLyra, lyraConfig);
``` 

The above install step will expose methods to Vue prototype which can be used to access the data required.
Following are the methods exposed

*Assets Methods*
- `Vue.prototype.$lyra.asset(key: string)`: Returns asset value with key
- `Vue.prototype.$lyra.assetExist(key: string)`: Returns true/false if asset exist with key
- `Vue.prototype.$lyra.assetsAll()`: Returns all the assets with key/value

*Citations Methods*
- `Vue.prototype.$lyra.citation()`: Returns citation value with key
- `Vue.prototype.$lyra.citationExist(key: string)`: Returns true/false if citation exist with key
- `Vue.prototype.$lyra.citationsAll()`: Returns all the citations with key/value
- `Vue.prototype.$lyra.citationsAll(type: string)`: Returns all the citations with citation type

*App Manager Methods*
- `Vue.prototype.$lyra.appManager()`: Returns complete App Manager
- `Vue.prototype.$lyra.appManager(tierId: string)`: Return Tier specific data
- `Vue.prototype.$lyra.endpoints({ tierId: string })`: Return endpoints data for specific tier
- `Vue.prototype.$lyra.endpoints({ tierId: string, endpointId: string })`: Return endpoint data for specific tier and endpoint

The $lyra methods are asynchronous in nature and returns a promise, with the value required.

## Download content locally

LYRA npm package also allows to download the data/content locally to the projects directory in the form of JSON file. There are two modes for using LYRA. Package offers npm scripts to achieve required implementation.

- `Live mode:` Get content directly from LYRA CMS. 
```powershell
# Script: lyra-live
# Usage in Client App: 
npm explore @huumun/lyra -- npm run lyra-live
```

- `Production mode:` Content is downloaded and saved locally in the JSON files. The methods then serve local JSON files as database. This steps needs to be included before the Vue build phase.
```powershell
# Script: lyra-prod
# Usage in Client App: 
npm explore @huumun/lyra -- npm run lyra-prod
```

### Arguments

These are the arguments you can pass to your node script to configure your LYRA setup.

You should follow `key=value` syntax.

|Key|Mode|Value|Default value|Description|
|---|---|---|---|---|
|`mode`||`production`, `live`|`production`|Defines the LYRA content mode: `live` for live connection, `production` to download content locally.|
|`localisation`||`String`|`-`|Defines the localisation it should get/download the content from.|
|`status`|`production`|`String`||If specified, will only download endpoints from specified tier (and its corresponding child tiers) and value. Usage `status:{{tierId}}:{{endpoint status meta value}}`. As an example, having a Studies tier with endpoints marked with `status` as `live`, we will use `status=studies:live`|