npm package: @metabocloud/microservices-clients-library
Description: <!-- Put your badges here: --> [![pipeline status](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/badges/dev/pipeline.svg)](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/commits/dev) [![coverage
Latest version: 0.0.4

# MetaboCloud - Microservices Clients - Library

<!-- Put your badges here: -->
[![pipeline status](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/badges/dev/pipeline.svg)](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/commits/dev)
[![coverage report](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/badges/dev/coverage.svg)](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/commits/dev)
[![Latest Release](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/badges/release.svg)](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/releases)
<!-- 
please choose a license badge; 
full list: https://gist.github.com/lukas-h/2a5d00690736b4c3a7ba
-->
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<!-- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -->
<!-- [![License: CC BY 4.0](https://licensebuttons.net/l/by/4.0/80x15.png)](https://creativecommons.org/licenses/by/4.0/) -->
<!-- [![License](https://img.shields.io/badge/License-CeCILL_2.1-blue.svg)](https://opensource.org/license/cecill-2-1) -->

<!-- If your software has been certified by MetaboHUB, put the following badge here : -->
[![MetaboHUB Logo](https://forge.inrae.fr/metabohub/e-tools/template-readme-mth/-/raw/main/logos/metabohub_logo-20x20.png)![MetaboHUB title](https://img.shields.io/badge/MetaboHub-Software-0066cc?style=flat-square)](https://www.metabohub.fr)

## Metadata

- authors: <nils.paulhe@inrae.fr>, <celian.barbe@inrae.fr>
- creation date: `2023-05-26`
- main usage: Vue.js webcomponents use for [PeakForest V3 Web-Applications](https://apis.peakforest.org/pforest-v3/) and MetaboHUB WebApp

## Description

<!-- NOTE: this section is required -->

This project hosts webcomponents that can be re-used in any Vue3 libraries or WebApps.
These webcomponents are designed to

- interact with MetaboCloud microservices (send data, compute, ...).
- display information fetched from MetaboCloud microservices.

## Features

<!-- NOTE: this section is required -->

- :information_source: display property: display compounds chemical information
- :atom: display compounds: viewer for compounds, using their identifier as key
- :arrows_counterclockwise: convert: convert compounds from a chemical format to an other one

## Getting Started

This WebComponent library is compatible with projects using [Vue.js 3](https://vuejs.org/) and [TypeScript](https://www.typescriptlang.org/).
This project is based on [Vue.js](https://vuejs.org/), [Vite](https://vitejs.dev/guide/) and [Vuetify](https://vuetifyjs.com/en/) frameworks.

### Prerequisites

<!-- NOTE: this section is required; list what things you need to install the software and how to install them -->
Note: this section is for developers who want to get involved into this project.

Before you begin, ensure you have met the following requirements:

- **Programming Language**: [NodeJS](https://nodejs.org/en) version 20.19+ and npm version 11.7 or higher
- **Frameworks**: [Vue.js](https://vuejs.org/) version 3.4+, [Vuetify.js](https://vuetifyjs.com/en/) version 3.5+

### Installing

<!-- NOTE: this section is required -->

Note: this section is for developers who want to implement and use this library into their own project(s).
To add the library to your [Node.js](https://nodejs.org/) project, 
please enter the following commands: `npm i @metabocloud/microservices-clients-library`

Then you must import the library in your `src/main.ts` file:


```js
// import the library and its styles
import { MetaboCloudMicroservicesClientsLibrary } from '@metabocloud/microservices-clients-library';
import '@metabocloud/microservices-clients-library/dist/src/components/main.css';

const app = createApp(App);
registerPlugins(app); // <= import your plugin like vuetify, ...
app.use(MetaboCloudMicroservicesClientsLibrary); // <= add this line!
app.mount('#app');
```

Finally you can add our WebComponent in you own Vue components:

```html
<template>
  <div class="demo">
    <mth-pf-display-property property-label="Hello" property-value="World" />
  </div>
</template>

<script lang="ts">

// from Vue core
import { ref } from "vue";

export default {
  name: "Demo",
  setup() {};
};
</script>
<style lang="scss"></style>
```

### Running the tests

<!-- NOTE: this section is required -->

You can run unit tests with the following commands:

```bash
# run unit tests
npm run test:unit
# run unit tests with coverage report
npm run test:coverage
```

You can run e2e tests with the following commands:
 
```bash
# launch the library as showcase mode in a first terminal...
npm run dev
# ... in a second terminal, run e2e tests
npm run test:e2e
```

:warning: you can update OpenAPI generated code with the following commands

```bash
# update CDK REST API client generated code
npm run openapi-generator:cdk
# update Goslin REST API client generated code
npm run openapi-generator:goslin
# update InChI REST API client generated code
npm run openapi-generator:inchi
# update InDex REST API client generated code
npm run openapi-generator:index
```

:warning: you can update in-house MetaboHUB libraries with the following command

```bash
# update basal lib
npm remove @metabohub/peakforest-basal-library &&\
  npm config set @metabohub:registry https://forge.inrae.fr/api/v4/projects/11779/packages/npm/ &&\
  npm i --save @metabohub/peakforest-basal-library
# update chemical lib
npm remove @metabohub/peakforest-chemical-library &&\
  npm config set @metabohub:registry https://forge.inrae.fr/api/v4/projects/11788/packages/npm/ &&\
  npm i --save @metabohub/peakforest-chemical-library
```

## Deployment

<!-- NOTE: this section is optional -->

Build and publish the library

```bash
# install node modules listed into 'package.json' / 'package-lock.json' files
npm install
# build the library
npm run build:lib
npm pack
# publish the library
npm publish
```

### Library build and publish

Build and publish the library

```bash
# install node modules listed into 'package.json' / 'package-lock.json' files
npm install
# build the library
npm run build:lib
npm pack
# publish the library
npm publish
```

Notes:

- the publication registry is set into these files:
  - [.npmrc](.npmrc) (note in this projects, created during CI/CD by [init-npmrc-file.sh](.scripts/init-npmrc-file.sh) script).
  - [package.json](package.json) - key "publishConfig".
- the publication is automatic during CI/CD process; see [.gitlab-ci.yml](.gitlab-ci.yml) file.
- during the GitLab CI/CD pipeline, the previous package with the same version identifier is removed thanks:
  - `curl` commands - to get all published packages in targeted GitLab packages registry and remove a specific one\
  (it require a GitLab API token with correct authorizations)

You can use non-stable version of the library using the GitLab npm package registry:

```bash
# if you already have installed the library, you must remove the previous one:
npm remove @metabocloud/microservices-clients-library
# config GitLab npm registry
npm config set @metabocloud:registry https://git.mesocentre.uca.fr/api/v4/projects/241/packages/npm/
# to install the library in your current Node.js project:
npm i --save @metabocloud/microservices-clients-library
```

### Standalone showcase build

Build the standalone version with these commands

```bash
# install node modules listed into 'package.json' / 'package-lock.json' files
npm install
# either build the DEV standalone version
npm run build:dev
# or build the PROD standalone version
npm run build:prod
```

Please refer to [.env](.env), [.env.development](.env.development) and [.env.production](.env.production) files to see changes between PROD and DEV versions.

Note: you can run the standalone version into "dev mode" thanks `npm run dev` command.

## Contributing

<!-- NOTE: this section is optional -->

We welcome contributions! 
Please follow these steps:

### How to Contribute

<!-- Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. -->
- create you own development branch
- before pushing it to the repository, please run the `npm run lint` command and check/ fix any error
- once your developments done, please create a merge request on gitlab

### Development Guidelines

Please read [Development Guidelines](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

### Code Style

- Use [Visual Studio Code](https://code.visualstudio.com/) IDE
- Use [ESLint](https://eslint.org/) for JavaScript
- Use [Prettier](https://prettier.io/) for code formatting
- Run `npm run lint` before committing

## Changelog

<!-- NOTE: this section is optional -->

All notable changes to this project will be documented in [CHANGELOG.md](CHANGELOG.md).
For the versions available, see the [releases on this repository](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/releases).

## Authors

<!-- NOTE: list all authors, maintainers, relevant contributors, ... with their MAIN ROLES and MAIN AFFILIATIONS. -->

- **Nils Paulhe** - *Initial work, support, project management* - MetaboHUB, INRAE, PFEM.
- **Célian Barbe** - *Initial work* - MetaboHUB, INRAE, PFEM.
- **Thomas Bellembois** - *project management, technical support* - UCA
- **Faustine Souc** - *Microservices OpenAPI files definition* - MetaboHUB, INRAE, PFEM.
- **Franck Giacomoni** - *project management* - MetaboHUB, INRAE, PFEM.
- **Nadia Goué, Antoine Mahul** - *project management* - MetaboCloud, UCA.

<!-- optional: add all contributors in a specific markdown file -->
<!-- See also the list of [contributors](CONTRIBUTORS.md) who participated in this project. -->
See also the list of [contributors](https://git.mesocentre.uca.fr/unh-metabocloud/mtc-microservices-clients-lib/-/graphs/dev) who participated in this project.

## License

<!-- NOTE: this section is required; we recommend Cecill License -->

**MetaboCloud - Microservice Clients - Library** is distributed under the `MIT` license.
<!--
Please choose one of the following license:
- open license CeCILL-2.1 (compatible GNU-GPL)
- MIT License
- Creative Commons Attribution-ShareAlike 4.0 International license (CC-BY-SA 4.0)
-->
Please refer to [LICENSE.md](LICENSE.md) file for further details.

## Support &amp; External resources

<!-- NOTE: this section is facultative; customize / remove useless / add relevant / ... items in the list below -->
You can find installation procedure and code sample/snippet on this project's [GitLab pages](https://unh-metabocloud.pages.mesocentre.uca.fr/mtc-microservices-clients-lib/).

<!-- - :page_facing_up: **CheatSheet** - [MTH CheatSheet](https://todo-link-to-this-resource)
- :scroll: **Wiki**
  - [Wiki for Users](https://todo-link-to-this-resource)
  - [Wiki for Developers](https://todo-link-to-this-resource)
- :question: **Frequently Asked Questions** - [FAQ](https://todo-link-to-this-resource)
- :book: **Documentation** - [Full documentation](https://docs.projectname.com)
- :bug: **Bug Reports** - [GitHub Issues](https://github.com/username/project-name/issues)
- :speech_balloon: **Discussions** - [GitHub Discussions](https://github.com/username/project-name/discussions)
- :email: **Email** - <support@projectname.com> -->

## Acknowledgments

<!-- NOTE: this section is required -->

- [MetaboCloud](https://metabocloud.mesocentre.uca.fr/)
- [MetaboHUB](https://www.metabohub.fr/home.html)
- [Mesocentre](https://mesocentre.uca.fr/)
- [INRAE](https://www.inrae.fr/en) and [UCA](https://www.uca.fr/)


## Additional Resources

<!-- NOTE: this section is optional -->

- [Showcases - Library showcases and code snippets](https://unh-metabocloud.pages.mesocentre.uca.fr/mtc-microservices-clients-lib/showcases)
- [Coverage - code coverage reports](https://unh-metabocloud.pages.mesocentre.uca.fr/mtc-microservices-clients-lib/coverage/)

---