@rdcp.dev/client
v1.1.0
Published
Typed RDCP client SDK for Node 18+ and modern browsers. Uses native fetch; no polyfills.
Downloads
18
Readme
@rdcp.dev/client
Typed RDCP client SDK for Node 18+ and modern browsers. Uses native fetch; no polyfills.
- Node.js 18+ (native fetch)
- Browsers (native fetch)
Install
npm install @rdcp.dev/client @rdcp.dev/core zodQuick start
import { createRDCPClient } from '@rdcp.dev/client'
const rdcp = createRDCPClient({ baseUrl: 'http://localhost:3000' })
const discovery = await rdcp.getDiscovery()
const status = await rdcp.getStatus()
// Modern key/value control (PUT)
await rdcp.putControl('DATABASE', true)
// Legacy format (POST)
await rdcp.postControl({ action: 'enable', categories: ['DATABASE'] })API
- createRDCPClient(options)
- options.baseUrl: string
- options.headers?: Record<string, string>
- options.fetch?: typeof fetch (optional override)
Methods:
- getDiscovery(): Promise
- getStatus(): Promise
- putControl(key: string, value: boolean | number | string, options?): Promise
- postControl(body: ControlRequest): Promise
Errors
Errors are thrown as RDCPClientError with fields:
- code?: RDCP error code (string)
- status?: HTTP status
- details?: unknown
