Package

@epheme/plugin-sdk

Type definitions and contracts for plugin authors (backend & browser).

manifest.ts — plugin manifest and events

/**
 * EphemePluginManifest
 *
 * Declared in the plugin's package.json under the "epheme" key.
 */
export interface EphemePluginManifest {
  pluginId: string;
  displayName: string;
  backendEntry?: string;
  browserEntry?: string;
  requiredCoreVersion?: string;
  hubEvents?: HubEventName[];
  licenseFeatures?: string[];
}

export type HubEventName =
  | 'device.registered'
  | 'device.activated'
  | 'device.revoked'
  | 'device.authenticated'
  | 'room.created'
  | 'room.deleted'
  | 'invite.redeemed'
  | 'tools.data.written';

backend.ts — PluginContext & types

Typed API surface available to backend plugins.

import type { PluginDb } from './db';
import type { HubEventName, HubEventPayloads } from './manifest';

export type ExpressRequestHandler = (req: any, res: any, next: any) => void;

export interface PluginContext {
  router: unknown;
  hub: PluginHubEmitter;
  kv: PluginKv;
  db: PluginDb;
  license: PluginLicense;
  metrics: PluginMetrics;
  config: PluginConfig;
  logger: PluginLogger;
}

export interface PluginHubEmitter {
  on<E extends HubEventName>(event: E, handler: (payload: HubEventPayloads[E]) => void | Promise<void>): void;
  off<E extends HubEventName>(event: E, handler: (payload: HubEventPayloads[E]) => void | Promise<void>): void;
}

export interface PluginKv { get(deviceId: string, key: string): Promise<string | null>; set(deviceId: string, key: string, value: string, ttlSeconds?: number): Promise<void>; del(deviceId: string, key: string): Promise<void>; keys(deviceId: string): Promise<string[]>; }

index.ts — SDK entry

export type { EphemePluginManifest, HubEventName, HubEventPayloads } from './manifest';
export type { EphemeBackendPlugin, PluginContext } from './backend';
export type { PluginDb } from './db';
export type { EphemeBrowserPlugin, EphemePluginPanel, EphemeSlot } from './browser';

db.ts — PluginDb interface

Dialect-neutral database interface for plugins: query, run, transaction, migrate.

/**
 * PluginDb — dialect-neutral database interface for BafGo plugins.
 */
export interface PluginDb {
  query>(sql: string, params?: unknown[]): Promise;
  run(sql: string, params?: unknown[]): Promise;
  transaction(fn: (db: PluginDb) => Promise): Promise;
  migrate(steps: string[]): Promise;
}

browser.ts — Browser plugin types

Types for browser-side plugins: slots, panels, and EphemeBrowserPlugin interface.

/**
 * Browser-side plugin interface for Epheme Angular host applications.
 */
export type EphemeSlot = 'hub.sidebar' | 'hub.room.toolbar' | 'hub.settings' | 'tool.header' | 'tool.sidebar';
export interface EphemePluginPanel { slot: EphemeSlot; component: any; requiredFeature?: string; order?: number; }
export interface EphemeBrowserPlugin { id: string; panels?: EphemePluginPanel[]; routes?: unknown[]; providers?: unknown[]; }

package.json

{
  "name": "@epheme/plugin-sdk",
  "version": "0.1.0",
  "description": "Type definitions and contracts for Epheme plugin authors",
  "license": "MIT",
  "private": true
}