{"modulePath":"github.com/dracory/nodeadmin","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage 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.\n\n## Functions\n\n```go\nfunc RegisterNodeSchema(typeID string, schema map[string]interface{})\n```\nRegisterNodeSchema 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.\n\n```go\nfunc RegisterNodeType(meta NodeType)\n```\nRegisterNodeType 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.\n\n## Types\n\n```go\ntype Api struct {\n\t// contains filtered or unexported fields\n}\n```\nApi is the node admin API\n\n```go\nfunc New(store nodestore.StoreInterface, engine EngineInterface) *Api\n```\nNew 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.\n\n```go\nfunc (a *Api) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP 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.\n\n```go\ntype EngineInterface interface {\n\t// DeployWorkflow starts a workflow and waits for activation to\n\t// finish (full deploy: every node restarts).\n\tDeployWorkflow(ctx context.Context, workflow nodestore.WorkflowInterface, input nodestore.MessageInterface) (string, error)\n\t// DeployWorkflowPartial is DeployWorkflow with \"modified nodes\"\n\t// semantics: a redeploy restarts only changed nodebase.\n\tDeployWorkflowPartial(ctx context.Context, workflow nodestore.WorkflowInterface, input nodestore.MessageInterface) (string, error)\n\t// StopWorkflow stops a running workflow.\n\tStopWorkflow(workflowID string) error\n\t// GetWorkflowStatus reports \"running\" | \"stopped\".\n\tGetWorkflowStatus(workflowID string) (string, error)\n\t// FireInjectNode fires a running inject node's own configured\n\t// payload (the editor fire button).\n\tFireInjectNode(workflowID, nodeID string) error\n\t// InjectMessage injects an explicit payload downstream of a node.\n\tInjectMessage(workflowID, fromNodeID string, payload nodestore.MessageInterface) (string, chan nodestore.MessageInterface, error)\n\t// DiscardPending drops the response channel of a fire-and-forget\n\t// injected message.\n\tDiscardPending(msgID string)\n\t// QueueHandle returns the live queue behind a queue node; ok is\n\t// false when the workflow is not running or the node has no queue.\n\tQueueHandle(workflowID, nodeID string) (nodebase.QueueInspector, bool)\n\t// RunJournal returns the node's recorded execution journal\n\t// (oldest first); ok is false when the workflow is not running.\n\tRunJournal(workflowID, nodeID string) ([]nodebase.RunJournalEntry, bool)\n\t// GetWorkflowSnapshot returns the workflow run status, per-node\n\t// statuses and the events recorded since the given sequence\n\t// number, plus the current last sequence for incremental\n\t// polling (the editor's debug panel contract).\n\tGetWorkflowSnapshot(workflowID string, since int64) (string, map[string]string, []nodebase.NodeEvent, int64)\n\t// LeaseRunner returns the ID of the runner instance currently\n\t// holding the workflow's execution lease (\"\" when not leased).\n\tLeaseRunner(workflowID string) string\n}\n```\nEngineInterface 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).\n\n```go\ntype NodeType struct {\n\tType        string `json:\"type\"`\n\tName        string `json:\"name\"`\n\tDescription string `json:\"description\"`\n\tIcon        string `json:\"icon\"`\n\tCategory    string `json:\"category\"`\n\tSet         string `json:\"set,omitempty\"`\n}\n```\nNodeType represents metadata about a node type\n\n","path":"github.com/dracory/nodeadmin/api","name":"api","synopsis":"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.","isRedistributable":true}
