Packages
Beyond the base hapic client, the project ships a family of service clients under the @hapic/* scope. Each one extends the same base Client with a typed, domain-oriented API for a specific backend — so they share the transport, hooks, authorization helpers, and instance registry you already know.
The family
| Package | For | Highlights |
|---|---|---|
@hapic/harbor | Harbor container registry | projects, repositories, artifacts, robot accounts, webhooks |
@hapic/oauth2 | OAuth2 / OpenID Connect | every token grant, introspection, userinfo, OpenID discovery |
@hapic/vault | HashiCorp Vault | key-value v1 & v2 secret engines, mount management |
@hapic/loki | Grafana Loki | push streams, LogQL instant & range queries, deletion requests |
@hapic/victorialogs | VictoriaLogs | JSON-line ingestion, LogsQL queries |
What they all share
Because every service client is a Client, the patterns are identical across the family:
- Construction —
new <Service>Client(config)or the package'screateClient(config). - Instance registry — each package exports its own
createClient/useClient/setClient/hasClient/unsetClient/isClient. - Domain APIs — endpoints are grouped into
*APIobjects exposed as properties (e.g.client.project,client.token,client.keyValueV2). - The base client underneath — set headers, register hooks, add transformers, and catch
ClientErrorexactly as documented in the guide.
// the same mental model, whichever package you pick
import { createClient } from '@hapic/harbor';
const client = createClient({
connectionString: 'admin:secret@https://registry.example.com/api/v2.0/',
});
// a base-client hook still works on a service client
client.on('responseError', (error) => { throw error; });
const projects = await client.project.getMany();Configuration
Service clients take a ConfigInput (a partial Config). It threads base request options straight to the Client, and resolves connection details into a baseURL + auth header:
type Config = {
request: RequestBaseOptions; // baseURL, headers, proxy, transformers…
connectionString?: string; // "user:password@host" (where supported)
connectionOptions?: ConnectionOptions; // structured host/credentials
options?: ServiceSpecificOptions; // e.g. OAuth2 endpoints, Loki component URLs
};The exact fields differ per service — each package page documents its own. Re-exported base types (Response, ClientError, RequestBaseOptions, the isClientError* guards) come straight from hapic, so you never duplicate them.
Building your own
Want a typed client for an API that isn't in the list? The Building a Service Client guide walks through the exact pattern these packages use.