@forge-dashboard/sdk-node

中文文档
25.18.0发布于 2026/11/15MITTypeScriptES Module构建来源已验证近 30 天下载 2.6万

Node/TypeScript client for forge-dashboard's REST API, generated from its OpenAPI spec.

原始使用文档
文档目录8 节
  1. Requirements
  2. Installation
  3. Alternative registry: GitHub Packages
  4. Authentication
  5. Usage
  6. Regenerating the types
  7. Contributing
  8. License

forge-dashboard-sdk-node

CI npm Codecov docs License: MIT

A Node/TypeScript client for forge-dashboard's REST API, generated from its OpenAPI spec with openapi-typescript and openapi-fetch. It saves you from hand-rolling HTTP requests and retries against the API yourself.

Full API reference: https://alrayyes.github.io/forge-dashboard-sdk-node/

Test and coverage reports from the latest green run on main: https://apis.ryankes.eu/forge-dashboard-sdk-node/reports/

Requirements

  • Node.js 20+ or Bun 1.1+ — anything with a native fetch.
  • A running forge-dashboard instance.
  • A personal API token for that instance (see "Authentication" below) — every endpoint except /healthz and /api/version needs one.

Installation

bun add @forge-dashboard/sdk-node
# or: npm install @forge-dashboard/sdk-node

Alternative registry: GitHub Packages

Every release also publishes to GitHub Packages under @alrayyes/forge-dashboard-sdk-node — the same code, a different scope, because GitHub Packages' npm registry requires a package scoped to the repo owner rather than the forge-dashboard npm org. Worth it if you're already authenticated to GitHub (CI in another of your own repos, say) and would rather not hold a separate npmjs.com credential just to install this one package.

Add a .npmrc pointing that scope at GitHub Packages:

@alrayyes:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

then install the scoped name instead:

npm install @alrayyes/forge-dashboard-sdk-node

Authentication

forge-dashboard authenticates browsers with passkeys (WebAuthn) and a session cookie, but its spec documents a real headless alternative: a personal API token, generated from the dashboard's own Settings page (POST /api/tokens, signed in as yourself first) and sent as Authorization: Bearer <token> on every request after. Pass it to createForgeDashboardClient or set FORGE_DASHBOARD_TOKEN in the environment:

import { createForgeDashboardClient } from "@forge-dashboard/sdk-node";

const client = createForgeDashboardClient("https://dashboard.example.com", {
  token: process.env.FORGE_DASHBOARD_TOKEN,
});

A token is revocable from Settings at any point; there's nothing in this SDK to refresh one automatically once it's gone.

Usage

GET /api/version needs no token and is a good first call to prove the client reaches the server at all. The client is a typed openapi-fetch instance, so every operation is client.GET(path, ...) / client.POST(path, ...), returning { data, error, response }:

import { createForgeDashboardClient } from "@forge-dashboard/sdk-node";

const client = createForgeDashboardClient("https://dashboard.example.com");

const { data } = await client.GET("/api/version", {});
console.log("server version:", data?.version);

Fetching your own dashboard needs a token, and demonstrates typed error handling:

import {
  ApiError,
  createForgeDashboardClient,
  decodeError,
} from "@forge-dashboard/sdk-node";

const client = createForgeDashboardClient("https://dashboard.example.com", {
  token: process.env.FORGE_DASHBOARD_TOKEN,
});

const { data, error, response } = await client.GET("/api/dashboard", {});
if (error) {
  const apiErr = decodeError(response, error);
  if (apiErr instanceof ApiError && apiErr.statusCode === 401) {
    throw new Error("token expired or invalid");
  }
  throw apiErr;
}
for (const pr of data.pullRequests) {
  console.log(`${pr.repo}#${pr.number}: ${pr.title} (${pr.ci})`);
}

Every other operation follows the same client.GET/client.POST/... pattern. Use decodeError to turn any failed response into a @forge-dashboard/sdk-node ApiError uniformly, as shown above.

The client retries a 429 or 5xx response with exponential backoff and jitter (honoring a server-sent Retry-After), and never retries any other 4xx. Tune it with the retry option, or swap the underlying fetch entirely with the fetch option.

Regenerating the types

See CONTRIBUTING.md — the generated types are pinned to a specific forge-dashboard commit and shouldn't drift from it silently.

Contributing

See CONTRIBUTING.md for building, testing and the release process.

License

MIT — a permissive license for the client, independent of forge-dashboard's own AGPL-3.0. x

版本与发布记录

@forge-dashboard/sdk-node 共发布 188 个版本,首次发布于 2026/09/21;过去 12 个月发布了 188 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
25.18.0latest2026/11/151 天前
25.17.02026/11/141 天前
25.16.02026/11/141 天前
25.15.02026/11/141 天前
25.14.02026/11/132 天前
25.13.02026/11/132 天前

关于 @forge-dashboard/sdk-node 的常见问题

@forge-dashboard/sdk-node 是什么?

Node/TypeScript client for forge-dashboard's REST API, generated from its OpenAPI spec.

如何安装 @forge-dashboard/sdk-node?

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

@forge-dashboard/sdk-node 支持 TypeScript 吗?

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

@forge-dashboard/sdk-node 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@forge-dashboard/sdk-node 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@forge-dashboard/sdk-node 可以商用吗?

@forge-dashboard/sdk-node 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@forge-dashboard/sdk-node 的下载量有多少?

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

@forge-dashboard/sdk-node 还在维护吗?

最新版本 25.18.0 发布于 2026/11/15(1 天前);至今共发布 188 个版本,其中过去 12 个月发布了 188 个;首次发布于 2026/09/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。