Documentation
¶
Overview ¶
Package api provides the JSON API for the node admin surface — POST endpoints returning dracory/api envelopes, same convention as flowadmin/api but backed by nodestore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterNodeSchema ¶
RegisterNodeSchema registers a JSON schema for a custom node type, replacing any schema already registered under typeID. The schema is served by /api/node-schema-fetch, so the schema-driven properties form works for the custom type for free (including "showIf", "format": "credential", enums). It is a thin adapter over the unified noderunner registry: the type's factory registration (if any) is preserved.
func RegisterNodeType ¶
func RegisterNodeType(meta NodeType)
RegisterNodeType registers a custom node type's editor metadata so it appears in the node palette list (/api/node-fetch-all) — a thin adapter over the unified noderunner registry. Re-registering a Type replaces its metadata; the type's factory registration (if any) is preserved.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
Api is the node admin API
func New ¶
func New(store nodestore.StoreInterface, engine EngineInterface) *Api
New creates the API bound to a nodestore store and an engine. The engine may be nil — engine-bound endpoints then report "workflow engine not available" instead of pretending to work.
func (*Api) ServeHTTP ¶
func (a *Api) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler. Cross-site browser writes are blocked before routing: a "simple" cross-origin POST (e.g. a form or fetch with text/plain) needs no CORS preflight, so without these gates any web page could drive the admin API on localhost. JSON Content-Type forces a preflight this server never answers.
type EngineInterface ¶
type EngineInterface interface {
// DeployWorkflow starts a workflow and waits for activation to
// finish (full deploy: every node restarts).
DeployWorkflow(ctx context.Context, workflow nodestore.WorkflowInterface, input nodestore.MessageInterface) (string, error)
// DeployWorkflowPartial is DeployWorkflow with "modified nodes"
// semantics: a redeploy restarts only changed nodebase.
DeployWorkflowPartial(ctx context.Context, workflow nodestore.WorkflowInterface, input nodestore.MessageInterface) (string, error)
// StopWorkflow stops a running workflow.
StopWorkflow(workflowID string) error
// GetWorkflowStatus reports "running" | "stopped".
GetWorkflowStatus(workflowID string) (string, error)
// FireInjectNode fires a running inject node's own configured
// payload (the editor fire button).
FireInjectNode(workflowID, nodeID string) error
// InjectMessage injects an explicit payload downstream of a node.
InjectMessage(workflowID, fromNodeID string, payload nodestore.MessageInterface) (string, chan nodestore.MessageInterface, error)
// DiscardPending drops the response channel of a fire-and-forget
// injected message.
DiscardPending(msgID string)
// QueueHandle returns the live queue behind a queue node; ok is
// false when the workflow is not running or the node has no queue.
QueueHandle(workflowID, nodeID string) (nodebase.QueueInspector, bool)
// RunJournal returns the node's recorded execution journal
// (oldest first); ok is false when the workflow is not running.
RunJournal(workflowID, nodeID string) ([]nodebase.RunJournalEntry, bool)
// GetWorkflowSnapshot returns the workflow run status, per-node
// statuses and the events recorded since the given sequence
// number, plus the current last sequence for incremental
// polling (the editor's debug panel contract).
GetWorkflowSnapshot(workflowID string, since int64) (string, map[string]string, []nodebase.NodeEvent, int64)
// LeaseRunner returns the ID of the runner instance currently
// holding the workflow's execution lease ("" when not leased).
LeaseRunner(workflowID string) string
}
EngineInterface is the narrow engine contract the node admin API needs (GOD ruling 2026-11-24): workflow deploy/stop, manual inject, queue inspection and the per-node run journal. It is defined here — the API never names a concrete runner — and noderunner.WorkflowEngine satisfies it structurally. Queue and journal data travel through the runner-agnostic contract types in nodebase (QueueInspector, RunJournalEntry).