# @itexpert-dev/keyvalue-cli

> KeyValueStore service tools

Latest version **0.2.0** (published 2018-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @itexpert-dev/keyvalue-cli
pnpm add @itexpert-dev/keyvalue-cli
yarn add @itexpert-dev/keyvalue-cli
bun add @itexpert-dev/keyvalue-cli
```

Provides the command `kvs`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-10-24 |
| First published | 2018-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 46 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ITExpert |
| Maintainers | itexpert-dev |

## Links

- npm: https://www.npmjs.com/package/@itexpert-dev/keyvalue-cli
- npm.io page: https://npm.io/package/@itexpert-dev/keyvalue-cli

## Dependencies (5)

- [ajv](https://npm.io/package/ajv.md) ^6.5.4
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [signale](https://npm.io/package/signale.md) ^1.3.0
- [commander](https://npm.io/package/commander.md) ^2.18.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.2.0

## Recent versions

- 0.2.0 (latest) — 2018-10-24
- 0.1.0 — 2018-10-08
- 0.0.1 — 2018-10-08

## README

# KeyValueStore Migration Tool

## Getting started

1. Install via npm

```
$ npm install --global @itexpert-dev/keyvalue-cli
```

2. Run `kvs --help` in terminal for help
3. To use most of the commands you need config-file. `./kvs.json` is used by default. 
   You can change the path with `--config` option. 
   For the list of available options see Config section below.


## Features

> See `kvs --help` for the list of available commands.
> See `kvs <command> --help` for additional information about the command.

* run - Runs migration scripts in specified directory
* test - Checks if specified service can execute without errors. If JSON Schema provided with the script, test also checks if produced result match the schema.
* sample - Prints random value from given set.
* show - Prints all keys in given set or key-value if full key is specified
* history-down - Removes all set migration history after specified version (exclusive).
* history-show - Shows migration history of a given set.

## Config

Available options:
* host (_required_) - KeyValueStore service address
* auth (_required_) - KeyValueStore authentication method
    * schema - HTTP authentication schema (e.g. `Bearer` or `Basic`)
    * value - HTTP authentication value (e.g. token or basic credentials)

```json
{
    "host": "http://localhost:6480",
    "auth": {
        "schema": "Bearer",
        "value": "token"
    }
}
```

## Samples

### Basic script

```js
// Script is executed in Node environment,
// so no `export` syntax, use `module.exports` instead.
module.exports.view = {
    // Migrated set name
    set: 'view',

    // Script version
    version: '0.1.0',

    // Function to transform one key-value from specified set.
    // If same key-value, null or undefined returned, key-value stays in the store stays the same.
    // If if `{key, value: null}` is returned, key-value is removed from the store.
    map({key, value}) {
        return {key, value};
    }
};
```

### JSON Schema for validation

```js
const stringField = {type: 'string'};
module.exports.view = {
    set: 'view',
    version: '0.1.0',
    map({key, value}) {
        value = {'a': 123};
        return {key, value};
    },
    schema: {
        type: 'object',
        required: ['data'],
        properties: {
            data: {
                type: 'object',
                properties: {
                    id: stringField,
                    name: stringField,
                    isShared: {type: 'boolean'},
                    fields: {
                        type: 'array',
                        item: stringField
                    }
                }
            }
        },
        additionalProperties: true
    }
};
```

---
_Source: https://npm.io/package/@itexpert-dev/keyvalue-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
