@junpenn/xbridge-sdk
v1.1.3
Published
Type-safe SDK for XBridge. It exposes the same actions, execution modes, DTOs, errors, pagination, and capability metadata used by the XBridge CLI, API, and Cloudflare Worker.
Readme
@junpenn/xbridge-sdk
English
Type-safe SDK for XBridge. It exposes the same actions, execution modes, DTOs, errors, pagination, and capability metadata used by the XBridge CLI, API, and Cloudflare Worker.
Requires Node.js 26.8.1 or newer.
Install
npm install @junpenn/xbridge-sdkRead a public profile
XBridge is an orchestration SDK: your application supplies the Guest transport and query-ID resolver.
import { createXBridgeClient } from '@junpenn/xbridge-sdk';
import { XClient } from '@junpenn/xbridge-sdk/core';
const coreClient = new XClient({
transports: { guest },
queryIds,
});
const xbridge = createXBridgeClient({
client: coreClient,
authentication: { guestToken },
});
try {
const result = await xbridge.profile.get(
{ username: 'openai' },
{ mode: 'guest' },
);
console.log(result.data);
} finally {
// Close the network dispatcher created by your transport adapter.
await dispatcher.close();
}guest, queryIds, guestToken, and the optional dispatcher are application-owned values. For a ready-to-run command, use @junpenn/xbridge-cli.
Public entry points
@junpenn/xbridge-sdk/coreandcore/worker@junpenn/xbridge-sdk/actions@junpenn/xbridge-sdk/storageandstorage/d1@junpenn/xbridge-sdk/browser@junpenn/xbridge-sdk/cloudflare@junpenn/xbridge-sdk/configandtypes
Project documentation: https://heyjunpenn.github.io/xbridge/
中文
XBridge 的类型安全 SDK。它与 XBridge CLI、API 和 Cloudflare Worker 共享 Actions、执行模式、DTO、错误、分页与 capability 元数据。
要求 Node.js 26.8.1 或更高版本。
安装
npm install @junpenn/xbridge-sdk读取公开资料
XBridge SDK 负责编排;Guest transport 和 query-ID resolver 由应用提供。
import { createXBridgeClient } from '@junpenn/xbridge-sdk';
import { XClient } from '@junpenn/xbridge-sdk/core';
const coreClient = new XClient({
transports: { guest },
queryIds,
});
const xbridge = createXBridgeClient({
client: coreClient,
authentication: { guestToken },
});
try {
const result = await xbridge.profile.get(
{ username: 'openai' },
{ mode: 'guest' },
);
console.log(result.data);
} finally {
// 释放 transport adapter 创建的网络 dispatcher。
await dispatcher.close();
}guest、queryIds、guestToken 和可选的 dispatcher 都属于应用侧配置。需要开箱即用的命令时,请使用 @junpenn/xbridge-cli。
公开入口
@junpenn/xbridge-sdk/core与core/worker@junpenn/xbridge-sdk/actions@junpenn/xbridge-sdk/storage与storage/d1@junpenn/xbridge-sdk/browser@junpenn/xbridge-sdk/cloudflare@junpenn/xbridge-sdk/config与types
