@faiber/faiber-flow

中文文档
2.7.0发布于 2026/11/05TypeScriptES Module近 30 天下载 3816

Typed Flow definitions, graph validation, event execution, catalog synchronization, active trigger discovery, run details and integration metadata.

原始使用文档

@faiber/faiber-flow

Typed Flow definitions, graph validation, event execution, catalog synchronization, active trigger discovery, run details and integration metadata.

npm install @faiber/faiber-flow
import { FaiberClient, MemoryTokenProvider } from '@faiber/sdk-core';
import { FlowApi } from '@faiber/faiber-flow';

const client = new FaiberClient('flow', {
  domains: { flow: process.env.FAIBER_FLOW_URL! },
  tokenProvider: new MemoryTokenProvider(),
  axios: { withCredentials: true, timeout: 15_000 },
});
const api = new FlowApi(client);
const created = await api.flows.create({
  name: 'Checkout completed',
  trigger_key: 'event.checkout.completed',
  enabled: false,
});
const validation = await api.validate(created.data.data.id);
const registry = await api.activeTriggers({ service: 'ledger' });
const runs = await api.runs.list({ limit: 20 });
// Run detail includes flattened run fields, nullable context and ordered steps.
if (runs.data.data[0]) {
  const detail = await api.runs.show(runs.data.data[0].id);
  console.log(detail.data.data.status, detail.data.data.steps);
}

All 18 mounted HTTP operations are callable on api.operations, with named exported inputs, queries and responses. Convenience methods include flows, runs, validate, triggers, actions, activeTriggers, syncCatalog, importFlows, emitEvent and integration. All calls retain the complete Axios response, status, headers and request IDs. Successful data is wrapped as {status: 'success', message: 'ok', data}. Lists are arrays inside that envelope; Flow does not provide a pagination envelope. Run limit defaults to 50 and has no application clamp.

Flow creation uses name, trigger_key, optional slug, enabled and graph; enabled defaults false and an omitted graph creates a single trigger node. A graph has nodes and edges. Editor positions, node data, edge data, downstream payloads and historical execution context are deliberately JSON values because the service stores extensible JSON documents. PUT updates are partial; null and omitted fields preserve existing values. Graph or trigger changes increment the version. Delete returns an envelope containing {deleted: true}.

importFlows accepts flow entries, event bridges and bridge groups. Use dry_run: true to validate and report proposed changes with transaction rollback. Normal imports upsert by normalized slug; identical retries report unchanged entries. Import bridge enabled defaults true, unlike direct creation. version and source are accepted metadata and currently ignored by the backend.

emitEvent(eventKey, json) accepts any JSON value, including null. The event key must contain 1–200 ASCII letters, numbers, dots, underscores or hyphens, with no leading/trailing/double dots. The response is HTTP 200 with {accepted: true, event_id, trigger_key}. Individual flow execution failures can still produce an accepted response; inspect runs afterward. Each repeated event call creates a fresh event and can duplicate downstream actions. Mutations persist before registry notifications, so a notification error can follow a committed change. Reconcile state before retrying. Catalog sync returns counts and per-service failures even under HTTP 200; it does not return a single synced boolean.

Configure a TokenProvider for Bearer authorization, or withCredentials for secure HttpOnly cookie sessions. Prefer cookies or in-memory tokens; persistent browser storage is an explicit security tradeoff. Every SDK call uses the shared FaiberClient. Declared route permissions are flow:read/create/update/delete, flow_run:read, catalog:sync, and flow:execute; import declares both create and update. Event emit explicitly checks flow:execute or * in AuthContext. Other handlers have no local permission/owner/tenant checks. Flow installs imported global auth extraction, with the external dependency pinned to 291c81a67bc302d667fb807da2af3240598bee52 in the production manifest and committed lockfile. Inspected shared IDP source registers permission metadata and trusts gateway identity headers with development fallback; enforce identity and permissions at your gateway. Sending credentials alone does not establish backend authorization enforcement.

Axios options, headers, adapters, interceptors, timeouts and AbortSignal cancellation are accepted as the final argument. Application errors use {error: string}: validation 400, missing UUID records 404, duplicate slugs 409, persistence/broker 500; malformed extractors may instead use Axum rejection bodies. Axios errors retain response.status and the original error body. An invalid saved graph returns HTTP 200 with valid: false and errors.

const controller = new AbortController();
try {
  await api.emitEvent('checkout.completed', { total: 1200 }, { signal: controller.signal });
} catch (error) {
  // Inspect the Axios error response; check current runs before retrying execution.
}

Use @faiber/faiber-ts-sdk for multiple Faiber services in one client configuration.

版本与发布记录

@faiber/faiber-flow 共发布 65 个版本,首次发布于 2026/07/18;过去 12 个月发布了 65 个版本。

版本发布日期距今
2.7.0latest2026/11/059 天前
2.6.02026/11/049 天前
2.5.02026/11/049 天前
2.4.02026/11/0310 天前
2.3.02026/11/0211 天前
2.2.02026/11/0212 天前

关于 @faiber/faiber-flow 的常见问题

@faiber/faiber-flow 是什么?

Typed Flow definitions, graph validation, event execution, catalog synchronization, active trigger discovery, run details and integration metadata.

如何安装 @faiber/faiber-flow?

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

@faiber/faiber-flow 支持 TypeScript 吗?

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

@faiber/faiber-flow 支持 ESM 还是 CommonJS?

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

@faiber/faiber-flow 可以商用吗?

@faiber/faiber-flow 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@faiber/faiber-flow 的下载量有多少?

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

@faiber/faiber-flow 还在维护吗?

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