@bb-cli/bb-convert

Converts a RAML API specification into a javascript module

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@bb-cli/bb-convert
Minified + gzip package size for @bb-cli/bb-convert in KB

Readme

NAME

bb-convert - Converts a RAML API specification into a javascript module

SYNOPSIS

bb-convert [--help] [-v|--version]
bb-convert raml [--help] [--template <template>] [--semver <version>]
    [-o|--output <path>] [-y|--yes] [--transform-plugins <file|node_module>]
    [--disable-challengeable] [-f|--format <format>] <raml-file>

OPTIONS

Option Description
-v, --version output the version number
--help Output usage information

COMMANDS

NAME

bb-convert raml - Convert RAML to javascript

SYNOPSIS

bb-convert raml [--help] [--template <template>] [--semver <version>]
    [-o|--output <path>] [-y|--yes] [--transform-plugins <file|node_module>]
    [--disable-challengeable] [-f|--format <format>] <raml-file>

DESCRIPTION

Create an angular data module with methods to connect to a backend service, as described by a given RAML specificiation.

OPTIONS

Option Description
--template <template> Specify which transformer template to use (Use mock-ng for mock modules)
--semver <version> Package version to pass to template
-o, --output <path> Converted output path
-y, --yes Confirm with yes is the output folder already exists and replace it
--transform-plugins <file|node_module> Comma separated list of files or node_modules to load as middleware plugins for the transform template
--disable-challengeable Disable check for challenge headers in RAML spec
-f, --format <format> Display output format
--help Output usage information

JS API

All RAML resources and HTTP methods are converted to functions on an angular service.

In order to best understand the javascript API that is created, you can refer to the JSDOC tags that are created. You can use the bb-doc CLI tool to create markdown docs for the generated javascript (see usage examples).

MOCK MODULES

The default template used to generated the data module is "http-ng". But there is another template available, "mock-ng", which produces a module with the same interface as "http-ng", but doesn't actually make any HTTP requests. Instead it uses the example responses in the RAML to fake the HTTP requests. This is useful for developing/demoing data modules without needing to have a server running.

Mock modules are named as "mock.". Since Frontend Building Blocks v2.3.0 the mock modules can be automatically loaded by adding an ?enable-mocks flag to the URL.

MULTIFACTOR AUTHENTICATION

Whether a presentation service supports MFA is defined by the "challengable" trait in the RAML spec. By default bb-convert will automatically include the "lib-bb-challenge-ng" library (available since widget collection >=2.9.0) and enable the HTTP interceptor that handles challengable requests via the intent library.

Read more at my.backbase: https://my.backbase.com/docs/product-documentation/documentation//Retail-Banking/latest/how-to-implement-mfa.html

This behaviour can be disabled in the generated data modules by specifying the --disable-challengeable flag.

EXAMPLES

Creates data module in dist/:

  $ bb-convert raml api.raml

Creates a mock module in mocks/:

  $ bb-convert raml api.raml -o mocks --template mock-ng

Create documentation in dist/data-bb-mymodule-http-ng/docs/README.md (requires bb-doc):

  $ bb-convert raml api.raml
  $ bb-doc js -o dist/data-bb-mymodule-http-ng/docs dist/data-bb-mymodule-http-ng

Disable intercepting of multi-factor challenge responses:

  $ bb-convert raml api.raml --disable-challengeable

ENVIRONMENT VARIABLES

Set the amount of log output

LOG_LEVEL=silly|verbose|info|warn|error

Set whether or not to use colors in output

COLOR=false|true

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.