Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@advanced-rest-client/arc-definitions

advanced-rest-client2.7kApache-2.03.1.1TypeScript support: included

Internal data definitions used in ARC. Contains definitions for status codes and request and response headers.

web-components, data, definitions, headers, status-code

readme

Published on NPM

Build Status

Published on webcomponents.org

arc-definitions

Request / response headers and status codes definitions database used in Adavanced REST Client and API Console.

The <arc-definitions> element listens for query events. Other elements can dispatch the query-headers and query-status-codes events that are handled by this element. Events are stopped from propagation. Handled event receives new property on the detail object with the query result.

Usage

Dispatching query events

Querying for headers data

Each header definition item has the following properties:

  • key - String, The name of the header
  • desc - String, The documentation for the header
  • example - String, Example value of the header
  • autocomplete - Array of String, list of possible/example values for autocomplete functions. This property is not available for response headers.
{
  "key": "Accept-Charset",
  "desc": "Character sets that are acceptable",
  "example": "Accept-Charset: utf-8",
  "autocomplete": ["utf-8"]
}

To query for the headers data dispatch query-headers event:

const e = new CustomEvent('query-headers', {
  detail: {
    type: 'request', // or "response"
    query: 'Acce'
  },
  bubbles: true,
  cancelable: true
});
document.body.dispatchEvent(e);
console.log(event.defaultPrevented); // true
const headers = event.detail.headers;  // Array[...]

or use imperative API:

const data = document.querySelector('arc-definitions').queryHeaders('A', 'response');
console.log(data); // list of headers with "A" in the name

Querying for status code data

Status code definition item has the following properties:

  • key - Number, Code value
  • desc - String, The documentation for the status code
  • label - String, Status label associated with the code
{
  "key": 101,
  "label": "Switching Protocols",
  "desc":"This means the requester has asked the server to switch protocols and the server is acknowledging that it will do so"
}

To query for the status code definition dispatch query-status-codes event:

const e = new CustomEvent('query-status-codes', {
  detail: {
    code: 200
  },
  bubbles: true,
  cancelable: true
});
document.body.dispatchEvent(e);
console.log(event.defaultPrevented); // true
const statusCode = event.detail.statusCode; // {...}

or use imperative API:

const status = document.querySelector('arc-definitions').getStatusCode(201);
console.log(status); // Status code definition for 201

Installation

npm install --save @advanced-rest-client/arc-definitions

In an html file

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/arc-definitions/arc-definitions.js';
    </script>
  </head>
  <body>
    <arc-definitions></arc-definitions>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/arc-definitions/arc-definitions.js';

class SampleElement extends LitElement {
  render() {
    return html`
    <arc-definitions></arc-definitions>
    `;
  }
}
customElements.define('sample-element', SampleElement);

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@advanced-rest-client/arc-definitions/arc-definitions.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
    <arc-definitions></arc-definitions>
    `;
  }

  _authChanged(e) {
    console.log(e.detail);
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/advanced-rest-client/arc-definitions
cd arc-definitions
npm install

Running the demo locally

npm start

Running the tests

npm test

changelog

2.0.2 (2018-05-17)

2.0.1 (2018-03-08)

1.0.9 (2017-11-28)

New

Update

1.0.8 (2017-07-12)

1.0.7 (2017-07-12)

Breaking

New

Update

1.0.6 (2017-03-13)

Update

1.0.5 (2016-12-07)

1.0.4 (2016-12-07)

Fix

Update

1.0.3 (2016-10-06)

New

1.0.2 (2016-09-29)

1.0.1 (2016-09-21)

Docs

New

3.0.0 (2019-07-30)

3.1.0 (2020-05-15)

Build

Features

  • adding export functions to access the data 132ff1f by Pawel

Refactor

  • upgrading to final WC spec 31dcc61 by Pawel Psztyc

Other

  • New: Adding npm ignore file 902e255 by Pawel Psztyc
  • New: Adding npm ignore file 6f923d6 by Pawel Psztyc
  • Breaking: Updating component to Polymer 3 1cb2e01 by Pawel Psztyc
  • New: Added autocomplete values for request headers definitions. 2406f0c by Pawel Psztyc
  • Update: Adding json file for support for linter when editing the data. 5945fae by Pawel Psztyc
  • Update: Added loading on demand option. e365da3 by Pawel Psztyc
  • Update: Updated element Travis and tests configuration to current state. 7ea9ae0 by Pawel Psztyc
  • New: Added more detailed tests. 7faae00 by Pawel Psztyc
  • Breaking: Query events now returns all type list values if query value is not set. a33c802 by Pawel Psztyc
  • New: Added event.preventDefault() to the events to determine that the event has been handled. cbba79a by Pawel Psztyc
  • Update: Updated travis configuration 1cf0c62 by Pawel Psztyc
  • Update: Removed JSON file download and put the definitions into the element body for faster initialization. 1a52115 by Pawel Psztyc
  • Update: updated tests. I must have been very tired when I wrote the previous version... 76bcd78 by Pawel Psztyc
  • Fix: Updated script location path 281f9ad by jarrodek
  • Fix: Fixed travis configuration a2104d3 by jarrodek
  • Fix: fixed issues causing test to fail 2f3f574 by jarrodek
  • Update: Added new Travis configuration ce3aa1a by jarrodek
  • New: Added hero image aa813f4 by jarrodek
  • Docs: Updated docs e4346cc by jarrodek
  • New: Initial commit for first release 10f9d04 by jarrodek

3.1.1 (2020-10-04)

Build

Update

  • updating types, spelling, wc file c0a66ae by Pawel
  • [ci skip] automated merge master->stage. syncing main branches acd7a8b by Ci agent

Features

  • adding export functions to access the data 132ff1f by Pawel