# @nuskin/solace-sync

> Sync functionality between solace and Nu Skin microservices

Latest version **2.0.0** (published 2023-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nuskin/solace-sync
pnpm add @nuskin/solace-sync
yarn add @nuskin/solace-sync
bun add @nuskin/solace-sync
```

Provides the command `solace-sync`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-05-22 |
| First published | 2022-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 49.6 KB |
| Known vulnerabilities | 0 (+28 in 3 direct dependencies) |
| Install scripts | no |
| Author | Bryce Sheffield |
| Maintainers | nkranendonk, emoore, nuskin-cws, klau, rellenberger |

## Links

- npm: https://www.npmjs.com/package/@nuskin/solace-sync
- Repository: git@code.tls.nuskin.io:nextgen-development/platform/integration/solace-sync
- Homepage: https://code.tls.nuskin.io/nextgen-development/platform/integration/solace-sync/-/blob/master/README.md
- npm.io page: https://npm.io/package/@nuskin/solace-sync

## Dependencies (7)

- [yaml](https://npm.io/package/yaml.md) 2.1.1
- [axios](https://npm.io/package/axios.md) 0.27.2
- [yargs](https://npm.io/package/yargs.md) 17.5.1
- [config](https://npm.io/package/config.md) 3.3.7
- [dotenv](https://npm.io/package/dotenv.md) 16.0.1
- [lodash](https://npm.io/package/lodash.md) 4.17.21
- [@nuskin/ns-common-lib](https://npm.io/package/@nuskin/ns-common-lib.md) 1.4.5

## Recent versions

- 2.0.0 (latest) — 2023-05-22
- 1.3.4-ngei-317.5 (prerelease) — 2022-08-16
- 1.4.1 — 2023-05-18
- 1.4.0 — 2023-05-16
- 1.3.7 — 2023-03-31
- 1.3.6 — 2022-12-07
- 1.3.5 — 2022-09-01
- 1.3.4 — 2022-08-16
- 1.3.4-ngei-317.4 — 2022-08-14
- 1.3.4-ngei-317.3 — 2022-08-12
- 1.3.4-ngei-317.2 — 2022-08-12
- 1.3.4-ngei-317.1 — 2022-08-12
- 1.3.3 — 2022-07-29
- 1.3.2 — 2022-07-27
- 1.3.1 — 2022-07-27
- … 4 more at https://npm.io/package/@nuskin/solace-sync/versions

## README

# Solace Sync Library

## Purpose
This package provides a series of Configuration as Code solutions for building out resources in Solace:
- application
  - deleteSolaceApplication
  - getSolaceApplications
  - parseConfig
  - syncApplication
- queue
  - createQueue
  - deleteSolaceQueue
  - syncQueues
  - getSolaceQueue
  - getSolaceQueues
- subscription
  - createQueueSubscription
  - deleteSolaceQueueSubscription
  - getSolaceQueueSubscription
  - getSolaceQueueSubscriptions
  - syncQueueSubscriptions
- event
  - syncEvent
- schema
  - syncSchema
- applicationDomain

# Install
```sh
yarn add @nuskin/solace-sync
```

## Usage
```js
'use strict';

// Import library
const solaceSync = require('@nuskin/solace-sync');

// Get list of applications on Solace
const solaceApplications = await getSolaceApplications();

// Sync applications between config and Solace
const application = await syncApplication(config, solaceApplications);

// Sync queues between config and Solace
const queues = await syncQueues(config['queues']);

// Sync queue subscriptions
const queueSubscriptions = await config['queues'].reduce(
  async (promise, queue) => {
    const accum = await promise;
    if (_.isEmpty(queue['subscriptions'])) return accum;
    const subs = await syncQueueSubscriptions(
      queue['queueName'],
      queue['subscriptions']
    );
    return _.union(accum, subs);
  },
  Promise.resolve([])
);

// Sync events between config and Solace, {source} is the path to begin search for .yaml configuration files
await syncEvents(source);

// Sync schemas between config and Solace, {source} is the path to begin search for .json configuration files
await syncSchemas(source);
```
# Environment vars
This project uses the following environment variables:

| Name             | Description                                      | Required  |Default Value  | Accepted Values
| ---              | ---                                              | ---       | ---           | ---
| NODE_ENV         | specifies the environment in which the application is running | Yes | ---    | dev, test, stage, prod
| SOLACE_API_TOKEN | Solace rest API token                            | Yes       | ---           | 
| SEMP_BASIC_AUTH  | Encoded Basic Auth Credentials for SEMP access   | Yes       | ---           |


# Pre-requisites
- Install [Node.js](https://nodejs.org/en/) version 14.0.0

# Install

```
yarn add @nuskin/solace-sync
```

## Project Structure
The folder structure of this app is explained below:

| Name | Description
| --- | ---
| **\_\_mocks\_\_**        | Contains jest mocks
| **\_\_tests\_\_**        | Contains jest tests
| **src**                  | Contains source code
| .gitignore               | List of files and directories for Git to ignore
| jest.config.js            | Configuration options for Jest
| jest.util.js             | Configuration options for Jest
| .eslintrc                | Configuration options for ES Lint
| .prettierrc              | Configuration options for prettier
| package.json             | Contains npm dependencies as well as build scripts
| .prettierignore          | List of files and directories for prettier to ignore
| cx.config                 | File needed for common pipeline to pass
| yarn.lock                | Yarn state snapshot
| .gitlab-ci.yml           | CI pipeline configuration
| application.yaml    | Configuration file

## Building the project
### Running the build
All the different build steps are orchestrated via [yarn scripts](https://docs.npmjs.com/misc/scripts).
yarn scripts basically allow us to call (and chain) terminal commands via npm.

| yarn Script | Description
| --- | ---
| `test`    | Runs tests with coverage using jest. Can be invoked with `yarn test`
| `lint`    | Runs ESLint on project files. Can be invoked with `yarn lint`

## Testing
The tests and assertions use Jest. Testing also utilizes eslint and prettier plugins.

```
"@babel/core": "7.18.5",
"@jest/globals": "28.1.1",
"@nuskin/docdash": "1.0.1",
"eslint": "8.18.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "28.1.1",
"jest-runner-eslint": "1.0.1",
"jest-runner-prettier": "1.0.0",
"jest-sonar-reporter": "2.0.0",
"jsdoc": "3.6.10",
"prettier": "2.7.1"
```

### Running tests using yarn Scripts
````
yarn test
````

# ESLint
ESLint is a code linter that helps catch minor code quality and style issues.

## ESLint rules
All rules are configured through `.eslintrc`.


## Running ESLint
To run ESLint you can call the ESLint task.
```
yarn lint  // runs only ES lint
```


# Common Issues

---
_Source: https://npm.io/package/@nuskin/solace-sync · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
