[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![npm version](https://badge.fury.io/js/pds4-product-registry.svg)](https://badge.fury.io/js/pds4-product-registry)
[![npm](https://img.shields.io/npm/dt/pds4-product-registry.svg)](https://www.npmjs.com/package/pds4-product-registry)

PDS4 Product Registry
=================================
A data product level registry and related tools. 

## Installation

  `npm install pds4-product-registry -g`
  
## Tools
[pds-reg-build-index](src/tools/build-index.js): Build a product index. Extract information from a PDS4 label and generate index files suitable to load into a Level database.

[pds-reg-find-index](src/tools/find-index.js): Search the index of a database. Search the index of a database for entries that begin with a value.

[pds-reg-load-index](src/tools/load-index.js): Load index into database. Load an index generated with "build-index" into a database.

[pds-reg-check-inventory](src/tools/check-inventory.js): Scan a collection or bundle inventory and check that each entry is valid.

[pds-reg-status](src/tools/status.js): Check the status of one or more product registries. A valid responses includes the number of keys present.

[pds-reg-product-server](src/product-server): Run the product-server web services.

## Getting Started
1. Run pds-build-index on a collection of PDS4 labeled products
```
pds-build-index -o listing.txt -p http://some.where.org/data
```
2. Load index into a database (example "./db")
```
pds-load-index -d ./db listing.txt
```
3. Perform a search 
```
pds-find-index -d ./db some-key-to-find-index
```

## Run the product-registry service
**Run service on port 3130**
```
pds-product-server -n brand-name -p 3130 -d ./db
```

**Running with [pm2](http://pm2.keymetrics.io/) on port 8800**
```
sudo pm2 start pds-product-server -- -p 8800 -d /var/product/db -n "My"
```

### End points
\find?lidvid={lidvid}

Retrieve information on a product given it's {lidvid}. A partial {lidvid} will return all products that match. Return and array of JSON records.

\label?lidvid={lidvid}</dt>

Return the label for a product with a specific {lidvid}.

\product?lidvid={lidvid}[&format=zip|tar]

Retrieve a product with a specific {lidvid} as a zip or tar bundle. Default is to return a zip file.

\lookup

Perform a search through a web browser.

## Project Requirements
- Query of product registry for LIDs with common collection.
- Output of collection query in collection inventory format
- Command Line Features
   - Load product registry
   - Inventory query product registry
   - Collection label generation
- Web Interface
   - Load product registry.
   - Query and list contents of product registry
- Web API
   - Resolve LID or LIDVID to product metadata
   - Resolve LID or LID to product URL
- Supports Registry API (TBD)
   - Given LID or LIDVID provide product metadata (label)
   - Given LID or LIDVID provide URL to product
- Scaleable to 10s of millions of products in the product registry

## License
This repository is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html).

## Contributors and Acknowledgments 
This package has been developed by [T. A. King](https://github.com/toddking).

Work on this project is sponsored by NASA.
