Documentation / @super-line/server / SuperLinePlugin
Interface: SuperLinePlugin<S>
Defined in: index.ts:315
A named, declarative bundle of runtime contributions registered on plugins: [...]. All fields are optional; a plugin ships as a pair (this server half + an optional client half). See ADR-0005. The optional type param S is the plugin's paired surface — its handlers compile against S, and S's clientToServer keys are subtracted from the host's implement() obligation at compile time.
Type Parameters
S
S extends Directional = { }
Properties
connection?
optionalconnection?:PluginConnection
Defined in: index.ts:356
A plugin-owned (reserved) connection class — its own role, handshake negotiation, and parallel contract, served over observer-invisible connections. See PluginConnection. (Phase 2.)
handlers?
optionalhandlers?: (ctx) =>HandlersFor<S>
Defined in: index.ts:340
Request handlers for the plugin's paired surface S, built lazily with the PluginContext. Merged into dispatch under their method names; the host merges S into a role and these keys are subtracted from its implement() obligation. A key already handled by the host (or another plugin) throws at construction.
Parameters
ctx
Returns
HandlersFor<S>
name
name:
string
Defined in: index.ts:317
Unique among the server's plugins; a duplicate name throws at construction.
onConnection?
optionalonConnection?: (conn,ctx) =>void
Defined in: index.ts:327
Called once per accepted connection (multiplexed after the host's onConnection).
Parameters
conn
ctx
unknown
Returns
void
onDisconnect?
optionalonDisconnect?: (conn,ctx,code) =>Awaitable<void>
Defined in: index.ts:329
Called when a connection closes (multiplexed after the host's onDisconnect).
Parameters
conn
ctx
unknown
code
number
Returns
Awaitable<void>
onError?
optionalonError?: (error,info) =>void
Defined in: index.ts:333
Receives any error thrown in middleware/handlers/hooks (multiplexed with the host's onError).
Parameters
error
unknown
info
Returns
void
onEvent?
optionalonEvent?: (event) =>void
Defined in: index.ts:323
Node-local tap fired synchronously at each emit site with LIVE payload references (an observer must not mutate them). Reuses the TapEvent taxonomy; zero cost when no plugin taps. A throwing tap is isolated and routed to onError — it never fails the underlying operation.
Parameters
event
Returns
void
onHeartbeat?
optionalonHeartbeat?: (conn,ctx,at) =>Awaitable<void>
Defined in: index.ts:331
Called after a connection confirms a heartbeat ping with a pong.
Parameters
conn
ctx
unknown
at
number
Returns
Awaitable<void>
policies?
optionalpolicies?:Record<string,CrdtCollectionPolicy<unknown,unknown> |CollectionPolicy<unknown,unknown>>
Defined in: index.ts:351
Access policies for contract collections, keyed by collection name. LWW row collections take an RLS-style CollectionPolicy (read → filter); CRDT document collections take a guard-shaped CrdtCollectionPolicy (read → bool) — same one-map-two-shapes rule as the host option. Merged into the host's policies; a collection already policied by the host or another plugin throws at construction, and a policy for a collection no fragment declared throws too. Deny-by-default still holds — a collection nobody policies is server-only. A plugin may policy a collection it did NOT declare (e.g. chat's kind registry contributing membership gates onto host-declared CRDT collections) — the collision-throw is what keeps that unambiguous: whoever policies a collection owns its access story.
setup?
optionalsetup?: (ctx) =>void| (() =>void|Promise<void>)
Defined in: index.ts:362
Imperative escape hatch, run once at construction with the plugin's PluginContext. Return an optional dispose function, called on server.close(). Use for wiring cluster-wide views from local taps + a plugin channel (the inspector's pattern), timers, or background subscriptions.
Parameters
ctx
Returns
void | (() => void | Promise<void>)
use?
optionaluse?:PluginMiddleware[]
Defined in: index.ts:325
Middleware run before request/subscribe handlers, after the host chain, in plugin array order.