@advanced-rest-client/arc-definitions

中文文档
3.1.1发布于 2020/10/04Apache-2.0ESM + CJS零依赖近 30 天下载 3233

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

原始使用文档
文档目录9 节
  1. Usage
  2. Dispatching query events
  3. Installation
  4. In an html file
  5. In a LitElement
  6. In a Polymer 3 element
  7. Development
  8. Running the demo locally
  9. Running the tests

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

版本与发布记录

@advanced-rest-client/arc-definitions 共发布 6 个版本,首次发布于 2018/05/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.1latest2020/10/046 年前
3.1.02020/05/166 年前
3.0.02019/07/317 年前
3.0.0-preview.22019/04/067 年前
3.0.0-preview.12019/02/217 年前
2.0.22018/05/188 年前

关于 @advanced-rest-client/arc-definitions 的常见问题

@advanced-rest-client/arc-definitions 是什么?

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

如何安装 @advanced-rest-client/arc-definitions?

在项目目录运行 npm install @advanced-rest-client/arc-definitions,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/arc-definitions 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__arc-definitions 是否存在。

@advanced-rest-client/arc-definitions 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@advanced-rest-client/arc-definitions 可以商用吗?

@advanced-rest-client/arc-definitions 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@advanced-rest-client/arc-definitions 的下载量有多少?

根据 npm 官方下载统计,@advanced-rest-client/arc-definitions 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,233 次,日均约 108 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advanced-rest-client/arc-definitions 还在维护吗?

最新版本 3.1.1 发布于 2020/10/04(6 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/05/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。