@appthen/sdk-node
v0.0.2
Published
AppThen Conversation Hub SDK - Node.js server adapter
Readme
@appthen/chat-hub-node
Node.js 服务端集成方适配包。
它复用 @appthen/chat-hub-core 的业务 API,并提供:
- Node
fetchHTTP adapter - 内存 token provider
- AK/SK 自动换取并缓存 tenant app token
createChatHubNodeClientcreateChatHubNodeRuntime
Usage
import { createChatHubNodeClient } from '@appthen/chat-hub-node';
const client = createChatHubNodeClient({
baseUrl: 'http://127.0.0.1:1626',
tenantApp: {
accessKey: process.env.APPTHEN_ACCESS_KEY!,
accessSecret: process.env.APPTHEN_ACCESS_SECRET!,
actingMode: 'subject',
actingSubjectId: 'subject_customer_1',
requestedScopes: ['conversation.write'],
},
});
await client.conversationTypes.create({
typeId: 'support_room',
label: 'Support Room',
status: 'active',
});Verification
pnpm --filter @appthen/chat-hub-node test
pnpm --filter @appthen/chat-hub-node typecheck当前 smoke tests 覆盖:
NodeFetchHttpAdapter的 base URL、query、headers、JSON body 拼接。- HTTP 非 2xx 时抛错并保留响应 payload。
TenantAppAuthProvider通过 AK/SK 换取 tenant app token,并在过期前复用缓存。createChatHubNodeClient()能把 tenant app auth provider 接入ChatHubClient。
