# connector-builder

> CLI tool for Connector Generation

Latest version **1.1.2** (published 2017-12-21) · 0 weekly downloads

## Install

```sh
npm install connector-builder
pnpm add connector-builder
yarn add connector-builder
bun add connector-builder
```

Provides the command `connector-builder`.

## 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 | 1.1.2 |
| Published | 2017-12-21 |
| First published | 2017-12-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| Author | Axway R&D |
| Maintainers | axway |
| Keywords | connector, utilities, api |

## Links

- npm: https://www.npmjs.com/package/connector-builder
- Repository: https://git.ecd.axway.int/Api-Builder/connector-builder
- npm.io page: https://npm.io/package/connector-builder

## Dependencies (11)

- [ajv](https://npm.io/package/ajv.md) 5.5.2
- [chalk](https://npm.io/package/chalk.md) 2.3.0
- [shelljs](https://npm.io/package/shelljs.md) 0.7.8
- [inquirer](https://npm.io/package/inquirer.md) 4.0.1
- [minimist](https://npm.io/package/minimist.md) 1.2.0
- [pretty-js](https://npm.io/package/pretty-js.md) 0.2.0
- [valid-url](https://npm.io/package/valid-url.md) 1.0.9
- [capitalize](https://npm.io/package/capitalize.md) 1.0.0
- [node-emoji](https://npm.io/package/node-emoji.md) 1.8.1
- [superagent](https://npm.io/package/superagent.md) 3.8.2
- [swagger-parser](https://npm.io/package/swagger-parser.md) 4.0.1

## Recent versions

- 1.1.2 (latest) — 2017-12-21
- 2.0.0-7 (v4-preview2) — 2018-04-26
- 2.0.0-4 (v4-preview1) — 2018-04-18
- 2.0.0-6 — 2018-04-26
- 1.1.1 — 2017-12-14

## README

# Connector Builder

__CLI__ tool for Connector Generation.

Generates __API-First Connectors__ with a specified name based on provided **_API definition_**.

API-First Connector is an __SDK__ that expose a set of functions for communiaction with third party API.

# Table of Contents

* [How To Install?](#how-to-install)
    * [Prerequisites](#prerequisites)
    * [Installation](#installation)
* [How To Generate Connector?](#how-to-generate-connector)
    * [Using Interactive Wizard](#using-interactive-wizard)
    * [Using Command Line](#using-command-line)
* [How To Refresh Connector?](#how-to-refresh-connector)
* [Supported API Definitions](#supported-api-definitions)
* [Author](#author)
* [License](#license)

# How To Install?

## Prerequisites

Both the CLI and generated project have dependencies that require `Node 8.9.1` or higher, together with `NPM 5` or higher.

## Installation

* Install globally `connector-builder`

```sh 
npm i connector-builder -g
```
>**NOTE**: if you have any issue due to the installation process, you can use **`sudo`** command. It is needed in case of installing `npm modules` in default folders that need permission. You may need to fill your administrator password.
Please find additional information on the following link [sudo](http://www.linuxdevcenter.com/cmd/cmd.csp?path=s/sudo)


As a result you should have __`connector-builder`__ command in your terminal.

## How to Update the CLI
If you're using old CLI version, you need to uninstall `connector-builder` package and to install it globally again:
```sh
npm uninstall -g connector-builder
npm install -g connector-builder
```


# How to Generate Connector?

To list the available options run:

```sh
connector-builder h
```

## Using Interactive Wizard

```sh
connector-builder i
```

>**_Will start a step by step wizard for filling the necessary information for connector generation._**

### Steps
* **_Provide the name of the connector you want to generate_** - the naming convention is to use `appc.` like prefix and lowercase letters e.g. `appc.mynewconnector`
* **_Provide the URL or the path (absolute or relative) to the API definition_** - e.g. `/Users/Documents/swagger.json`
* **_Select the Connector Type_** - there are two given options _Cloud Elements_ or _Open API_.
* **_Select the Context_** - there are two given options _API Builder_ or _Plain JS_. Selecting the first one means that the connector is going to be used within API Builder and the second one means that the connector is going to be used in plain javascript application.
* **_Enter the absolute path to the location where the connector will be generated (leave empty for current dir)_** - by default the connector will be generated in your current directory in its own folder otherwise you could specify the location where the connector must be generated.
* **_Do you want to remove previous connector if it is already exist_** - there are two options `Y/N`

> After the above steps you will have successfully generated connector.

## Manual Usage
Available is a second approach for the generation of a new connector. You need to set all required parameters and connector type. Please find the examples below.

### Mandatory Parameters

> **name** - the connector name

> **api** - path or URL to the API definition

### Optional Parameters

> **type** - defines the specifics of API definition and how the connector talks to the underlying service. Please find available connector types below.

> **context** - defines where the connector will be used - API Builder application or Plain JavaScript program. Default choice is API Builder application.

> **dest** - the absolute path to the directory where the connector will be generated

### Available Connector Types

> **openapi** - generates connector based on Open API Definitions and standard `HTTP` communication mechanism

### Examples of the generation options

#### Valid flag values:
* `--name` - the connector name. Cannot be an empty string, space or cannot have unallowed special characters except `.`, `-`, `_`.
* `__api` - url or path to the swagger definition file (absolute or relative)
* `--type` - describe the type of the service connector. Two available options: ce (Cloud Elements connector) or openapi (Open API Definitions)

#### Generation options:
- **_standard generation with no overwrite in the current directory:_**

```sh
connector-builder --name [Connector Name] --api [Path or URL to the API Definition] --type [Connector Type]
```

- **_standard generation with overwrite in the current directory:_**

```sh
connector-builder --name [Connector Name] --api [Path or URL to the API Definition] --type [Connector Type] --force
```

- **_generation with default connector type with no overwrite in the current directory:_**

```sh
connector-builder --name [Connector Name] --api [Path or URL of the API Definition]
```

- **_generation with default connector type with overwrite in the current directory:_**

```sh
connector-builder --name [Connector Name] --api [Path or URL of the API Definition] --force
```

- **_generation with default connector type with no overwrite in specified directory:_**

```sh
connector-builder --name [Connector Name] --api [Path or URL of the API Definition] --dest [Absolute Path]
```
# How To Refresh Connector?
If you need to generate the connector again due to changes or if there is more recent versions of your API, please update the content of config/swagger.json file and you can regenerate it via __refresh__  functionality. You won't lose any test data from your Test Suite. Please follow the steps below:

* navigate to the root directory of the connector
* execute the `refresh` command

```
connector-builder refresh
```

> As a result, you should have successfully regenerated connector

# Supported API Definitions

Currently supported standards are:

* [Swagger 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md)

>**_The files describing the RESTful API in accordance with the Swagger specification are represented as JSON objects and conform to the JSON standards_**


## Author

Axway R&D <support@axway.com> https://axway.com

## License

This code is closed source and Confidential and Proprietary to Axway, Inc. All Rights Reserved. This code MUST not be modified, copied or otherwise redistributed without express written permission of Axway. This file is licensed as part of the Axway Platform and governed under the terms of the Axway license agreement. Your right to use this software terminates when you terminate your Axway subscription.

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