npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@advanced-rest-client/arc-definitions

v3.1.1

Published

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

Downloads

1,726

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