AI Brief: hbf-core-api
TypeScript npm library that provides a typed HTTP client and shared data model for calling hbf-core. Every other Node.js service in the HBF platform imports this package to interact with hbf-core rather than making raw HTTP calls.
What This Repo Does
hbf-core-api wraps the hbf-core REST API in a typed, axios-based client. It exports one root class (HBFCoreApi) that constructs domain-specific sub-clients on demand (TenantsClient, BotDeploymentClient, etc.). It also exports all shared TypeScript interfaces and enums (Tenant, Organization, BotDeployment, MessagingBackends, Powerup, etc.) so consumers have consistent types across the HBF ecosystem. The library handles auth headers, automatic JSON serialization, retry on network failure (up to 3 attempts, exponential backoff), and response unwrapping.
Tech Stack
- Language: TypeScript 5.5
- Runtime: Node.js (CommonJS output via tsc)
- HTTP client: axios 1.9
- Utilities: lodash 4.17
- Testing: Jest 29 + ts-jest
- Linting: ESLint 9 + typescript-eslint
- Docs generation: TypeDoc
- Publish target: GitHub Packages (
@helvia/hbf-core-api)
Entry Points
- Main:
src/index.ts— re-exportsHBFCoreApi,HBFCoreApiResponse, and all datamodel types - Core:
src/core.ts—HBFCoreApiclass andHBFCoreApiResponseclass - Config:
package.json,tsconfig.json
Key Directories
| Directory | Purpose |
|---|---|
src/clients/ | One client class per hbf-core resource domain |
src/datamodel/ | TypeScript interfaces and enums matching hbf-core domain models |
src/operator/ | Higher-level operator utilities (e.g., BotContent manipulation helpers) |
src/core.ts | HBFCoreApi root class + HBFCoreApiResponse response wrapper |
src/index.ts | Public API surface — all exports |
test/ | Jest tests |
API Surface (if applicable)
HBFCoreApi is instantiated with (url, token) and exposes these clients as getters:
| Getter | Wraps hbf-core resource |
|---|---|
TenantsClient | /tenants — list, find, clone, create, update, delete, train NLU, stats, usage |
OrganizationsClient | /organizations — org CRUD |
BotContentClient | Bot content authoring endpoints |
BotDeploymentClient | /bot-deployments and org-scoped deployment endpoints |
ResponsesClient | Response template endpoints |
AnalyticsClient | Analytics queries |
BroadcastsClient | Broadcast CRUD |
GroupsClient | Group CRUD |
UsersClient | User management |
SubscribersClient | Subscriber CRUD |
UserGroupsClient | User group management |
HandoverClient | Agent handover management |
FbHandoverClient | Facebook-specific handover |
ChatSessionsClient | Chat session queries |
SurveyClient | Survey management |
MessagingAppsClient | Messaging app configuration |
ElasticSearchClient | Elasticsearch proxy endpoints |
NluDetectionClient | NLU intent detection |
NluAgentsClient | NLU agent management |
NlpPipelinesClient | NLP pipeline CRUD |
AuditLogsClient | Audit log access |
KnowledgeBaseArticleClient | Knowledge base article CRUD |
KnowledgeBaseClient | Knowledge base CRUD |
IntegrationClient | Integration config management |
TranslationsClient | Translation management |
KnowledgeBaseGroupClient | Knowledge base group CRUD |
HBFCoreApiResponse wraps every response and provides typed extraction:
.getValue<T>()— single object (throws on error).getOptionalValue<T>()— single object,undefinedon 404.getList<T>()— list response (readsbody.items).getVoid()— validates 2xx, returns nothing.getSavedId(resource)— extracts ID fromLocationheader or response body.getTotal()— extracts total count from response body.getFile()— returns{ data: ArrayBuffer, filename? }orundefinedon 404
External Dependencies
- hbf-core (the REST API this library wraps) — URL configured at instantiation
- hbf-auth (issues the JWT token passed to
HBFCoreApiconstructor) - No direct database or message queue connections
Running Locally
npm install
npm run build # compiles TypeScript to dist/
npm test # eslint + jest
Tests
npm test # eslint ./src/**/*.ts && jest