DarhimLabs API
Node.js SDK
Oficjalny TypeScript-first SDK @darhimlabs/node: client, resources, retry, pagination i webhook verify.
Node.js SDK
@darhimlabs/node jest oficjalnym SDK dla Node.js i TypeScript. Uzywa fetch, ma retry z exponential backoff, obsluge Idempotency-Key, mapowanie bledow API i timing-safe webhook verification.
Instalacja
npm install @darhimlabs/node
Pierwszy call
import { DarhimLabs } from "@darhimlabs/node";
const client = new DarhimLabs(process.env.DARHIMLABS_API_KEY!);
const page = await client.inbox.conversations.list({
status: "open",
limit: 10
});
console.log(page.data);
Resources
SDK wystawia zasoby wysokiego poziomu:
client.inbox.conversations.list/get/sendMessage/iterateclient.bots.list/get/create/updateclient.agents.list/runs/dryRunclient.leads.list/create/updateclient.knowledge.sources.list/createclient.voice.calls.list/getclient.webhookEndpoints.list/createclient.workspaces.current/members
Auto-pagination
for await (const conversation of client.inbox.conversations.iterate({ status: "open" })) {
console.log(conversation.id);
}
Idempotency
await client.inbox.conversations.sendMessage(
"conv_123",
{ content: "Czesc! Czym moge pomoc?" },
{ idempotencyKey: "message_123" }
);
Webhook verification
const { event } = client.webhooks.verifySignature({
payload: rawBody,
signatureHeader: req.headers["dl-status-signature"],
secret: process.env.DARHIMLABS_WEBHOOK_SECRET!
});
Generowane typy
Metadane operacji i schematow sa generowane z specs/openapi.json:
npm run build:openapi
npm run sdk:types
W paczce znajdziesz DARHIMLABS_OPERATIONS, DARHIMLABS_OPERATION_IDS i DARHIMLABS_SCHEMA_NAMES, synchronizowane z OpenAPI.
Release
Publikacja do npm jest obslugiwana przez .github/workflows/sdk-release.yml. Tag sdk-node-v0.1.0 uruchamia build, generowanie typow i npm publish --access public.