Documentation / @super-line/server / PluginContext
Interface: PluginContext
Defined in: index.ts:450
The capabilities handed to a plugin's setup/handlers: the server's public surface minus the footguns (implement/close), plus a privileged block — a plugin-private adapter PluginChannel, node identity, the serializer, a read-only conns view, and the raw contract for reflection. Sized to the inspector's audited needs; grows case-by-case.
Properties
cluster
readonlycluster:ClusterView
Defined in: index.ts:474
Cluster-wide presence introspection (rejects without a presence-capable adapter).
collectionCoordination?
readonlyoptionalcollectionCoordination?:"local"|"cluster"
Defined in: index.ts:500
Whether conditional collection writes are serialized locally or cluster-wide.
conns
readonlyconns: readonlyConn<Record<string,ServerMessageDef>,unknown,string,unknown,unknown>[]
Defined in: index.ts:470
Connections accepted on THIS node (read-only snapshot; excludes reserved conns).
contract
readonlycontract:Contract
Defined in: index.ts:462
The raw contract, for reflection (e.g. classifyContract).
instanceId
readonlyinstanceId:string
Defined in: index.ts:458
Alias of PluginContext.nodeId — the per-process instance id used to tag cluster fan-out.
local
readonlylocal:LocalView
Defined in: index.ts:472
Node-local introspection (connections, rooms, topics on this process).
nodeId
readonlynodeId:string
Defined in: index.ts:452
This node's stable id (equals srv.nodeId).
nodeKey?
readonlyoptionalnodeKey?:string
Defined in: index.ts:456
Stable replica identity supplied by the host, if configured.
nodeName
readonlynodeName:string
Defined in: index.ts:454
This node's friendly name (equals srv.nodeName).
plugins
readonlyplugins: readonlystring[]
Defined in: index.ts:468
Names of every plugin registered on this server, in registration order — including this one, and including plugins that contribute no contract fragment. Distinct from contract.plugins, which is the contract-time half (ADR-0016).
serializer
readonlyserializer:Serializer
Defined in: index.ts:460
The wire serializer configured on the server.
Methods
batch()
batch(
ops):Promise<void>
Defined in: index.ts:496
Apply one atomic, schema-validated server batch across row collections.
Parameters
ops
Returns
Promise<void>
channel()
channel(
name):PluginChannel
Defined in: index.ts:508
A plugin-private, cluster-wide adapter channel under the reserved x:<plugin>: prefix.
Parameters
name
string
Returns
collection()
collection(
name):ServerCollectionHandle
Defined in: index.ts:494
Server-authoritative handle for a contract collection (loosely typed here as the LWW row handle — the surface plugins/inspector use); throws if none is configured.
Parameters
name
string
Returns
collectionInfos()
collectionInfos():
object[]
Defined in: index.ts:502
Declared collections (name + key + advisory references) for the schema graph.
Returns
object[]
conditionalBatch()
conditionalBatch(
conditions,ops):Promise<boolean>
Defined in: index.ts:498
Atomically apply a server batch only while every stored row still matches its predicate.
Parameters
conditions
ops
Returns
Promise<boolean>
connectionById()
connectionById(
id):Promise<ConnDescriptor|undefined>
Defined in: index.ts:506
A connection's descriptor anywhere in the cluster (rejects without presence support); undefined if absent.
Parameters
id
string
Returns
Promise<ConnDescriptor | undefined>
describe()
describe(
conn):ConnDescriptor
Defined in: index.ts:504
Full cluster descriptor for a local connection (identity + rooms + describeConn extras).
Parameters
conn
Returns
isOnline()
isOnline(
userId):Promise<boolean>
Defined in: index.ts:476
Whether a user (by identify key) has at least one live connection anywhere.
Parameters
userId
string
Returns
Promise<boolean>
publish()
publish(
topic,data):void
Defined in: index.ts:478
Publish a shared topic (server-only publish).
Parameters
topic
string
data
unknown
Returns
void
room()
room(
name):object
Defined in: index.ts:486
Server-controlled room membership + broadcast (loosely typed, mirroring toConn/toUser).
Parameters
name
string
Returns
object
connections
readonlyconnections: readonlyConn<Record<string,ServerMessageDef>,unknown,string,unknown,unknown>[]
size
readonlysize:number
add()
add(
conn):void|Promise<void>
Parameters
conn
Returns
void | Promise<void>
broadcast()
broadcast(
event,data):void
Parameters
event
string
data
unknown
Returns
void
remove()
remove(
conn):void
Parameters
conn
Returns
void
subscribe()
subscribe(
topic,handler):Unsubscribe
Defined in: index.ts:480
Subscribe server-side to a shared topic, cluster-wide (local echo). Await .ready before publishing from elsewhere.
Parameters
topic
string
handler
(data, meta) => void
Returns
toConn()
toConn(
id):object
Defined in: index.ts:482
Target a single connection by id, on whatever node holds it.
Parameters
id
string
Returns
object
close()
close():
void
Returns
void
emit()
emit(
event,data):void
Parameters
event
string
data
unknown
Returns
void
setEnv()
setEnv(
env):void
Parameters
env
unknown
Returns
void
toUser()
toUser(
userId):object
Defined in: index.ts:484
Target all of a user's connections across nodes.
Parameters
userId
string
Returns
object
disconnect()
disconnect():
void
Returns
void
emit()
emit(
event,data):void
Parameters
event
string
data
unknown
Returns
void
setEnv()
setEnv(
env):void
Parameters
env
unknown
Returns
void