Exports and events ​
Server exports are integration APIs for trusted server resources. getCall and getOpenCalls return server-side call
records; never pass those objects directly to a client or public log. Use the NUI/client route or construct a deliberate
public view.
Publish incidents ​
lua
local callId, result = exports.np_dispatch:publish({
type = 'police.shots_fired',
title = 'Shots reported',
message = 'Two reports from nearby sensors',
coords = { x = 400.0, y = -980.0, z = 29.0 },
priority = 1, -- P1
dedupeKey = 'sensor-zone-17',
data = { sourceCount = 2 },
})
The server validates the registered type, channels, priority, title and coordinates. channels is normally inherited
from the registered alert type. Do not use client payloads as authoritative coordinates or caller identity.
Server exports ​
| Export | Result / purpose |
|---|---|
publish(alert) / alert(alert) / Alert(alert) |
Create or merge a typed incident; returns call id, or nil, reason |
update(callId, patch) |
Update title, message, priority, coordinates, location, data or open status |
addReport(callId, report) |
Add a bounded unit/witness report |
close(callId, disposition) |
Close a call and clear its attached units |
getCall(callId) / getOpenCalls(filter?) |
Read trusted server-side records |
getChannels() |
Get sorted public channel definitions |
wouldReceive(src, typeOrCall, coords?) |
Test feature and routing eligibility |
panic(src, opts) |
Feature-gated P0 panic; returns id or nil, reason |
attach(src, callId, role?) / detach(src, callId?) |
Attach or detach a unit after call-level routing checks |
setStatus(src, status) / getStatus(src) / getUnit(src) / getCallsign(src) |
Unit controls and public unit view |
registerAlertType(def) / registerChannel(def) |
Owner-tracked np_addon registrations |
registerContextProvider(name, fn) / registerStatusPreset(id, codes) |
Register trusted extension providers/presets |
addHook(name, fn) / onCall(filter, fn) |
Owner-tracked event hooks and call subscriptions |
fromLegacy(payload) |
Compatibility adapter for the old np_drugs:Dispatch payload shape |
createCall(incident) / getActiveCalls(src) |
Envelope-compatible exports for np_np-remake migration |
Events ​
Server-local lifecycle events:
np_dispatch:call:created(call),np_dispatch:call:updated(call),np_dispatch:call:merged(call),np_dispatch:call:closed(call)np_dispatch:unit:status(unit),np_dispatch:unit:attached(call, extra),np_dispatch:unit:detached(call, unit)np_dispatch:panic(callId, source, callsign)andnp_dispatch:broadcast(channel, text, source)- Minimized MDT adapter events:
np_mdt:dispatch:callCreated(dto),:callUpdated(dto),:callClosed(dto)
Client events are server-to-client presentation: np_dispatch:client:snapshot, :alert, :update, :unit,
:visibility, :waypoint, :broadcast, :notify. The client-to-server action event is re-authorized by np_jobs on
every action.