Skip to content

SDK overview

The ReelVault SDK is published to npm as the @reelvault/sdk package, developed in its own ReelVault/sdk repository and consumed through subpath exports. The server's own frontend, plugins and any third-party tooling all use the same published package, so nothing drifts between them.

Entry points

ImportWhat you get
@reelvault/sdkRoot — re-exports the client (ReelVaultClient), validation errors and all shared contracts
@reelvault/sdk/clientThe typed HTTP client: ReelVaultClient, 25 resource clients, and the error, cache and token types
@reelvault/sdk/commonShared request/response contracts — Elysia TypeBox schemas and their inferred TypeScript types
@reelvault/sdk/pluginThe server-side plugin SDK: definePlugin, PluginHost and every contract a plugin uses
@reelvault/sdk/uiThe client-side UI kit: definePluginElement, ReelVaultElement, mountShadow, schema builders
@reelvault/sdk/ui/schemaJust the declarative schema builders (tree-shakeable)
@reelvault/sdk/testingPluginTestHost — an in-memory plugin host for unit tests

Every entry point is dual-format (ESM + CJS) with full .d.ts declarations.

Source layout

All SDK sources live in the ReelVault/sdk repository:

@reelvault/sdk/
├── package.json      # published as @reelvault/sdk
├── index.ts          # root entry
├── client/           # transport (core/) + one class per API area (resources/)
│   ├── core/         # HttpClient, TtlCache, dedup, TokenManager, errors, retry
│   └── resources/    # admin, auth, libraries, media, metadata, playback-sessions, …
├── common/           # 58 contract files: schemas + types (auth, media, playback, providers, admin…)
├── plugin/           # plugin contracts: types.ts (PluginHost), manifest, http, hooks, events,
│                     #   storage, access, config, ui-host, ui-manifest, ui-schema
├── ui/               # custom-element kit + schema builders
└── testing/          # PluginTestHost

Routes validate with the same TypeBox schemas the client types are inferred from, so the server and its clients cannot disagree about a contract.

Building

bash
cd sdk
bun run build   # tsdown → dist/ (root, client, common, plugin, ui, testing)

The output is unbundled — one file per source module — minified for dead-code elimination only, targeting ESNext.

Consuming the package

From the website (development setup)

The website uses the published package as a regular dependency:

bash
bun add @reelvault/sdk

While co-developing the SDK and the website, link a local checkout instead — bun link in the SDK repository overrides the registry version until you unlink.

From a plugin

Plugin sources import the SDK for types and builds only — add it as a devDependency:

bash
bun add -d @reelvault/sdk

Keep @reelvault/sdk/* external in your bundler config: at runtime the host resolves those imports itself, writing a node_modules/@reelvault/sdk shim into the plugins directory and re-exporting its own build. That way a plugin always runs against the exact SDK the server runs. You just import:

ts
import { definePlugin } from "@reelvault/sdk/plugin";

Keep @reelvault/sdk/* external in your bundler config and bundle everything else into your entry. See Publishing & catalogs.

Standalone

Install the package from npm (bun add @reelvault/sdk) — or link a local build, see above — then:

ts
import { ReelVaultClient } from "@reelvault/sdk/client";
import type { MovieDetail } from "@reelvault/sdk/common";

Where to go next

Released under the GNU GPL v3.