api

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api provides the JSON API for the node admin surface — POST endpoints returning gouniverse/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

func RegisterNodeSchema(typeID string, schema map[string]interface{})

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 pkg/nodestore/nodes (QueueInspector, RunJournalEntry).

type NodeType

type NodeType struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Category    string `json:"category"`
	Set         string `json:"set,omitempty"`
}

NodeType represents metadata about a node type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL