@brigadecore/brigade-sdk

中文文档
2.4.1发布于 2022/06/01Apache-2.0TypeScriptCommonJS近 30 天下载 2974

build slack

原始使用文档
文档目录7 节
  1. Supported Runtimes
  2. Installation
  3. Basic Use
  4. Further Examples
  5. Contributing
  6. Support & Feedback
  7. Code of Conduct

Brigade SDK for JavaScript

build slack

This is a Brigade 2-compatible SDK for JavaScript and TypeScript.

Supported Runtimes

Great care has been taken to ensure this SDK works within recent versions of Node as well as modern browsers (latest versions of Firefox, Chrome, Edge, Safari, etc.) if properly transpiled with webpack or similar.

Installation

Install into your project using your favorite package manager.

For instance:

$ npm install --save @brigadecore/brigade-sdk

Or:

$ yarn add @brigadecore/brigade-sdk

Basic Use

Note: All examples that follow use TypeScript.

A Brigade API client can be obtained as follows:

import { APIClient } from "@brigadecore/brigade-sdk"

// ...

const client = new APIClient(apiAddress, apiToken, opts)

In the example above, it is assumed:

  • apiAddress points to a Brigade 2 API server. The address must include the protocol (i.e. must be prefixed with http:// or https://).
  • apiToken is:
    • A valid API token. It is probably best to use a non-expiring service account token. Refer to Brigade's own documentation on how to obtain such a token.
    • The empty string is acceptable, but only API operations not requiring authorization will then be supported by the client.
  • opts, as one might infer, is an optional parameter. If included, it must be an object, which may have a single field allowInsecureConnections containing the value true or false to indicate whether SSL errors should be tolerated by the client. If not specified, SSL errors will not be tolerated. This option is only applicable when the value of the apiAddress argument uses https:// as the scheme.

The client returned from the call to the new APIClient(...) constructor is the root in a tree of more specialized clients.

To obtain a client for working with the "core" components of Brigade (Projects, Events, etc.):

const coreClient = client.core()

The coreClient permits navigation to even more specialized clients, for example:

const projectsClient = coreClient.projects()

If your program needs to interact with only a specific subset of the Brigade API, it is possible and encouraged to directly instantiate just the specific subset of the client tree that is needed.

For instance, this example shows instantiation of only the Events client-- something that might be practical for a program such as a Brigade gateway, whose only interaction with Brigade involves the creation of new Events:

import { core } from "@brigadecore/brigade-sdk"

// ...

const eventsClient = new core.EventsClient(apiAddress, apiToken, opts)

The arguments passed above are the same as in our initial example.

Further Examples

Working Node and browser-based examples are available in the examples directory.

Contributing

The Brigade project accepts contributions via GitHub pull requests. The Contributing document outlines the process to help get your contribution accepted.

Support & Feedback

We have a slack channel! Kubernetes/#brigade Feel free to join for any support questions or feedback, we are happy to help. To report an issue or to request a feature open an issue here

Code of Conduct

Participation in the Brigade project is governed by the CNCF Code of Conduct.

版本与发布记录

@brigadecore/brigade-sdk 共发布 18 个版本,首次发布于 2021/02/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.4.1latest2022/06/014 年前
2.4.02022/04/094 年前
2.3.12022/03/024 年前
2.3.02022/02/154 年前
2.2.02022/02/034 年前
2.1.02022/01/254 年前

关于 @brigadecore/brigade-sdk 的常见问题

如何安装 @brigadecore/brigade-sdk?

在项目目录运行 npm install @brigadecore/brigade-sdk,或使用 pnpm add / yarn add / bun add。

@brigadecore/brigade-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@brigadecore/brigade-sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@brigadecore/brigade-sdk 可以商用吗?

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

@brigadecore/brigade-sdk 的下载量有多少?

根据 npm 官方下载统计,@brigadecore/brigade-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,974 次,日均约 99 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@brigadecore/brigade-sdk 还在维护吗?

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