{"modulePath":"github.com/dracory/nodebase","version":"v0.7.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package nodebase\n\n## Constants\n\n```go\nconst (\n\tContextScopeNode   = \"node\"\n\tContextScopeFlow   = \"flow\"\n\tContextScopeGlobal = \"global\"\n)\n```\nContext scopes — Node-RED parity. The scope ID namespaces entries within a scope: node scope uses \"\\\u003cworkflowID\u003e/\\\u003cnodeID\u003e\", flow scope uses the workflow ID, and the global scope uses \"\" (shared by every flow).\n\n```go\nconst CredentialSentinel = nodestore.CredentialSentinel\n```\nCredentialSentinel is the marker stored in node.Data in place of a real credential value (the same convention Node-RED's editor uses, \"\\_\\_PWRD\\_\\_\"). Stored workflows and editor payloads carry the sentinel where a secret exists; the actual value lives in server-side credential storage and is merged back into node.Data at deploy time. Exports must strip sentinel values and credential keys entirely.\n\nThe canonical registry lives in nodestore so flow documents and the runner share one credential-key set; these are thin aliases.\n\n```go\nconst DefaultLinkCallFunctionTimeout = 5 * time.Second\n```\nDefaultLinkCallFunctionTimeout is Node-RED's function-node node.linkcall default timeout (5s — shorter than the node's own 30s default).\n\n```go\nconst DefaultLinkCallTimeout = 30 * time.Second\n```\ndefaultLinkCallTimeout bounds the wait for a linkOut return when the node configures no explicit timeout.\n\n```go\nconst LinkCallStackKey = \"linkCallStack\"\n```\nlinkCallStackKey is the Metadata key holding the link call stack.\n\n```go\nconst MQTTBrokerType = \"mqttBroker\"\n```\nMQTTBrokerType is the registered type id of the shared broker config node (Node-RED \\`mqtt-broker\\`).\n\n```go\nconst MQTTClientsKey = \"__mqttClients__\"\n```\n\n```go\nconst RunJournalSize = 20\n```\nRunJournalSize is the runner-agnostic bound for per-node execution journals: how many recent run records an engine keeps per (workflow, node) for the run-details endpoint.\n\n```go\nconst TCPSessionsKey = \"__tcpSessions__\"\n```\n\n```go\nconst WSSessionsKey = \"__websocketSessions__\"\n```\n\n```go\nconst WebSocketClientType = \"websocketClient\"\n```\nWebSocketClientType is the engine type of the shared-client config node (Node-RED \"websocket-client\").\n\n```go\nconst WebSocketListenerType = \"websocketListener\"\n```\nWebSocketListenerType is the engine type of the shared-listener config node (Node-RED \"websocket-listener\").\n\n## Variables\n\n```go\nvar ReadHeaderTimeout = 10 * time.Second\n```\nReadHeaderTimeout guards against slowloris clients (stalled headers). A package var so tests can shorten it.\n\n## Functions\n\n```go\nfunc BindUIWidgetSink(host NodeHost, sink UIWidgetSink) (unbind func())\n```\nBindUIWidgetSink registers sink as the dashboard state sink for host — the host-side equivalent of constructing the dashboard hub. It returns an unbind function the caller invokes on hub teardown. One sink per host: a second bind replaces the first.\n\n```go\nfunc ClampQoS(qos int) int\n```\nClampQoS constrains QoS to the MQTT range 0-2.\n\n```go\nfunc CloneMetadata(input nodestore.MessageInterface) map[string]interface{}\n```\ncloneMetadata shallow-copies a payload's metadata so the delayed timer's payload doesn't share the (later mutated) map.\n\n```go\nfunc ClonePayload(p nodestore.MessageInterface) nodestore.MessageInterface\n```\nClonePayload deep-copies a payload for a fan-out branch: Payload is copied via JSON round-trip (so sibling branches can't share maps), Metadata is shallow-copied preserving the msgId needed by response nodes — shallow deliberately: the JSON round-trip would coerce non-JSON-safe types (int64→float64), and nested-map mutations are the mutating node's job to detach (see sort.emitSequence). A clone is a new message instance: it gets a fresh envelope ID and records the producing instance's ID in metadata.parentMsgId.\n\n```go\nfunc CompileJSONata(expr string) error\n```\nCompileJSONata validates a JSONata expression without evaluating it; the error is non-nil exactly when the expression fails to parse. Deploy-time checks use it so unsupported syntax fails loudly.\n\n```go\nfunc CompileRuleExpr(src string) error\n```\nCompileRuleExpr validates an expression at deploy time without evaluating it; the error is non-nil exactly when EvalRuleExpr would fail to compile.\n\n```go\nfunc CompileSeqExpr(src string) error\n```\nCompileSeqExpr validates a sequence expression without evaluating it; the error is non-nil exactly when evaluation would fail to parse.\n\n```go\nfunc CredentialKeys(nodeType string) []string\n```\nCredentialKeys returns the config keys of a node type that are treated as credentials (masked in the editor, stored outside the exported flow document, stripped from exports).\n\n```go\nfunc DecodeConfig(node nodestore.NodeInterface, cfg interface{}) error\n```\nDecodeConfig maps the node's stored Data map onto the typed config struct via JSON — the decoding every built-in factory applies.\n\n```go\nfunc DeletePath(data interface{}, path string)\n```\ndeletePath removes the value at the dotted path inside data\n\n```go\nfunc EncodeFilePayload(data interface{}, encoding string) ([]byte, error)\n```\nencodeFilePayload converts message data into bytes per encoding: strings/\\[]byte pass through, other values are JSON-marshalled; base64/hex decode a string payload first. Shared by the file and fsOut nodes.\n\n```go\nfunc ErrorCatchSchemaField() map[string]interface{}\n```\nerrorCatchSchemaField returns the shared \"errorCatch\" schema field for the external-facing built-ins that support the opt-in error output port (task error\\_catch\\_port): when enabled the node gains a dedicated \"error\" port after its normal outputs; a node failure emits msg.error={text,node,full} on it when wired, else falls through to the catch/problem-queue ladder.\n\n```go\nfunc EvalJSONata(expr string, msg nodestore.MessageInterface) (interface{}, error)\n```\nEvalJSONata evaluates expr against the whole message, Node-RED semantics: the message is a flat object where \"payload\" is the payload and every metadata key (topic, parts, …) is a root key. An expression that resolves to \"undefined\" (a missing path) returns (nil, nil) — matching upstream where undefined is not an error.\n\n```go\nfunc EvalJSONataCtx(expr string, msg nodestore.MessageInterface, rc *RuleContext) (interface{}, error)\n```\nEvalJSONataCtx is EvalJSONata with the Node-RED context functions bound through rc: $flowContext(\"key\"), $globalContext(\"key\") and $env(\"NAME\"). A nil rc leaves them unregistered — an expression calling them then fails at evaluation, as it would upstream without a runtime.\n\n```go\nfunc EvalRuleExpr(src string, rc *RuleContext) (interface{}, error)\n```\nEvalRuleExpr evaluates the small expression subset rules accept for value type \"jsonata\": numeric and string literals, parentheses, the arithmetic operators + - \\* / %, and the context functions $flowContext(\"key\"), $globalContext(\"key\") and $env(\"NAME\"). Anything else — variables, \u0026 concatenation, comparisons, the wider JSONata language — fails to compile so deploy still errors loudly on unsupported expressions. An operand that resolves to \"undefined\" (a missing context key) makes the whole expression undefined (nil), matching upstream semantics where undefined propagates.\n\n```go\nfunc EvalSeqExpr(src string, ctx interface{}, vars map[string]interface{}) (interface{}, error)\n```\nEvalSeqExpr evaluates src against ctx — a map\\[string]interface{} whose keys form the root scope (for message evaluation: \"payload\", \"topic\", \"parts\", …). vars binds the $-variables ($A accumulator, $I index, $N count). A path that does not resolve evaluates to \"undefined\" (nil), matching JSONata semantics.\n\n```go\nfunc EvalSwitchRule(rule SwitchRule, payload nodestore.MessageInterface) bool\n```\nEvalSwitchRule evaluates a single rule against the payload's data — the host-less variant kept for callers that never reference context.\n\n```go\nfunc EvalSwitchRuleCtx(rule SwitchRule, payload nodestore.MessageInterface, rc *RuleContext) bool\n```\nEvalSwitchRuleCtx is EvalSwitchRule with the host seam attached: rules whose property or comparison value reads flow/global context or an environment variable resolve through rc.\n\n```go\nfunc FileFilename(configured, filenameType string, input nodestore.MessageInterface, host NodeHost, workflowID string) (string, error)\n```\nfileFilename resolves the node's target filename per the filename source (see FileFilenameValue), then applies the host FileRoot restriction. workflowID scopes \"flow\" context lookups; an empty workflowID leaves the flow namespace unscoped.\n\n```go\nfunc FileFilenameValue(configured, filenameType string, input nodestore.MessageInterface, host NodeHost, workflowID string) (string, error)\n```\nFileFilenameValue resolves the raw filename string a filename typedInput produces, before any FileRoot sandboxing. \"msg\" reads the message's filename property (via lookupProperty); \"flow\"/\"global\" read the configured value as a context key through the host's context store; anything else (\"fixed\", \"\", NR's \"str\") is the fixed configured filename itself.\n\n```go\nfunc GenerateID() string\n```\nGenerateID returns a fresh unique ID (UUIDv7 — time-ordered, so persisted rows sort by creation).\n\n```go\nfunc GetPath(m map[string]interface{}, path string) (interface{}, bool)\n```\ngetPath reads the value at the dotted path inside m\n\n```go\nfunc IsCredentialKey(nodeType, key string) bool\n```\nIsCredentialKey reports whether key is a credential field on the given node type.\n\n```go\nfunc IsCredentialSentinel(v interface{}) bool\n```\nIsCredentialSentinel reports whether v is the sentinel string left in place of a stored credential value.\n\n```go\nfunc IsUIWidget(typeID string) bool\n```\nIsUIWidget reports whether typeID is a registered dashboard widget node type. The editor/API uses it to group widget types in the palette (convention: NodeType.Category \"Dashboard\", ui\\* naming).\n\n```go\nfunc JSCompare(a, b interface{}) int\n```\nJSCompare orders two values with JavaScript's \u003e semantics: two strings compare lexically; otherwise both sides coerce through Number() (NaN makes the comparison equal-ish — it returns -1 like a failed \u003e does through the caller). Returns -1, 0 or 1.\n\n```go\nfunc JSNumber(v interface{}) (float64, bool)\n```\nJSNumber coerces a value like JavaScript's Number(): strings parse (empty → 0), bools become 0/1, nil becomes 0. ok is false when the coercion yields NaN.\n\n```go\nfunc JSONSource(input nodestore.MessageInterface, property string) (interface{}, bool)\n```\njsonSource resolves the value to convert. When property is \"payload\" (or empty) the whole Data is used; otherwise the dotted path is read inside the data map. Returns the value plus whether it lives on Data.\n\n```go\nfunc JSString(v interface{}) string\n```\nJSString renders a value the way JavaScript's String() / template coercion does: numbers drop trailing \".0\", nil becomes \"\" (the Array.join convention — null/undefined join as empty), objects and arrays become compact JSON, everything else uses %v.\n\n```go\nfunc LinkCallInto(host NodeHost, workflowID, callerID, target string, msg nodestore.MessageInterface, timeout time.Duration) (nodestore.MessageInterface, error)\n```\nLinkCallInto injects msg into the resolved linkIn target and awaits the matching linkOut return — the shared request/response machinery behind the linkCall node and the function node's node.linkcall. The message's link call stack gets the caller's entry appended before injection (mirroring Node-RED's msg.\\_linkSource push).\n\n```go\nfunc LookupProperty(input nodestore.MessageInterface, path string) (interface{}, bool)\n```\nlookupProperty resolves a simple property path against the payload: \"payload\" → Data; otherwise checks Metadata\\[key] first, then a dotted path inside a map-typed Data.\n\n```go\nfunc MQTTClientOptions(o *MQTTOpts, clientID string) *mqtt.ClientOptions\n```\nMQTTClientOptions builds the paho client options for resolved dial options — exported so dial-option construction is testable without a broker.\n\n```go\nfunc MQTTConnect(broker, clientID, username, password string) (mqtt.Client, error)\n```\nMQTTConnect builds a paho client for the given broker (host:port is normalized to tcp://host:port) and connects, surfacing broker unavailability as an error. Kept as the plain-address convenience form; richer connections go through MQTTConnectOpts.\n\n```go\nfunc MQTTConnectOpts(o *MQTTOpts, clientID string) (mqtt.Client, error)\n```\nMQTTConnectOpts dials a broker with the resolved options. clientID is the caller's default (per node id); o.ClientID wins when configured.\n\n```go\nfunc MQTTPayloadBytes(input nodestore.MessageInterface) ([]byte, error)\n```\nMQTTPayloadBytes converts message Data into publish bytes: strings and \\[]byte pass through, anything else is JSON-marshaled.\n\n```go\nfunc MessageMap(input nodestore.MessageInterface) map[string]interface{}\n```\nMessageMap exposes a message as a Node-RED-style plain object — every metadata key plus \"payload\" — for expression evaluation.\n\n```go\nfunc MsgPath(field string) (string, bool)\n```\nmsgPath strips the \"msg.\" prefix that targets message-level properties (Metadata), e.g. \"msg.statusCode\" -\u003e \"statusCode\".\n\n```go\nfunc MustRegisterNode(reg NodeRegistration)\n```\nMustRegisterNode is RegisterNode for built-in registration: a duplicate typeID is a programming error and panics.\n\n```go\nfunc MuxPattern(path string) (string, []string)\n```\nMuxPattern converts a Node-RED-style path with \":name\" segments into a Go 1.22 ServeMux pattern with \"{name}\" wildcards, returning the pattern and the parameter names in order.\n\n```go\nfunc NewID() string\n```\nNewID returns a fresh unique ID for workflow elements.\n\n```go\nfunc NewMemoryContextStore() *memoryContextStore\n```\nNewMemoryContextStore creates an empty in-memory context store.\n\n```go\nfunc NextGroupSeq() int64\n```\nNextGroupSeq returns the next group sequence number — unique ids for split-family operations (split, csv) that fan one message out into a numbered group.\n\n```go\nfunc NodeName(node nodestore.NodeInterface) string\n```\nNodeName returns the display name of a workflow node.\n\n```go\nfunc NodeProperty(input nodestore.MessageInterface, path string) (interface{}, bool)\n```\nNodeProperty resolves a Node-RED message property path: \"payload\" returns the payload, \"payload.x\" walks inside it, anything else resolves as a dotted path inside metadata.\n\n```go\nfunc NodeSchemaFor(typeID string) (map[string]interface{}, bool)\n```\nNodeSchemaFor returns the JSON schema registered for typeID, if any.\n\n```go\nfunc NodeSetProperty(input nodestore.MessageInterface, path string, value interface{})\n```\nNodeSetProperty writes a Node-RED message property path: \"payload\" replaces the payload, \"payload.x\" writes inside it, anything else writes a dotted path inside metadata.\n\n```go\nfunc ParseCheckpointRoutes(v interface{}) []string\n```\nParseCheckpointRoutes normalizes the loose \\`routes\\` config value into an ordered label list. Entries may be blank (the port falls back to its \"output\\_N\" key as the label).\n\n```go\nfunc ParseFsLocator(locator string) (scheme, dir string, u *url.URL, err error)\n```\nParseFsLocator splits a locator into (scheme, dir). A plain path or a file:// URI is local. sftp://\\[user\\[:pass]@]host\\[:port]/path and ftp://… select remote adapters. s3:// and unknown schemes error. Returned dir uses the backend's native separator.\n\n```go\nfunc ParseJSONOrString(s string) interface{}\n```\nparseJSONOrString returns the decoded JSON value when s parses as JSON, otherwise s itself\n\n```go\nfunc ParseLinkList(v interface{}) []string\n```\nParseLinkList accepts links configured either as a JSON array of node ids or as a comma-separated string (the editor's textarea first pass).\n\n```go\nfunc ParseNumeric(value interface{}) (float64, bool)\n```\nParseNumeric coerces a value to a number with JS Number() semantics. Strings are trimmed (whitespace + BOM) and honour 0x/0o/0b radix prefixes before delegating to cast; everything else defers to cast.ToFloat64E. The second return value is false when the value cannot be coerced (NaN).\n\n```go\nfunc ParseNumericString(s string) (float64, bool)\n```\nParseNumericString parses a string like JS Number(): trims whitespace and a leading BOM, honours 0x/0o/0b radix prefixes, otherwise defers to standard float parsing.\n\n```go\nfunc PushUIState(host NodeHost, workflowID, nodeID string, state map[string]interface{})\n```\nPushUIState delivers a widget state update to the dashboard sink bound to host. It is a no-op when the host has no bound sink (no dashboard mounted) or the workflow has no dashboard scope.\n\n```go\nfunc RangeProperty(input nodestore.MessageInterface, property string) (interface{}, bool)\n```\nrangeProperty extracts the watched value: \"payload\" returns the whole Data, other paths read a dotted path inside the data map.\n\n```go\nfunc RegisterCredentialKeys(typeID string, keys []string)\n```\nRegisterCredentialKeys marks config keys of a node type as credentials — the same treatment built-in types get: the editor masks them, storage moves them out of the flow document behind the CredentialSentinel marker, and exports strip them. Node packs call this alongside RegisterNodeType (typically from init()). Re-calling replaces the key list for the type.\n\n```go\nfunc RegisterNode(reg NodeRegistration) error\n```\nRegisterNode adds reg to the global node registry — the path both built-ins and node packs take, so every host can deploy the type and editors can show it in the palette. Registering an already-registered typeID is an error (use UpsertNode to deliberately replace).\n\n```go\nfunc RegisterNodeType(typeID string, factory NodeFactory) error\n```\nRegisterNodeType registers factory under typeID in the global node type registry — the minimal pack path equivalent to RegisterNode with an empty descriptor. Registering an already-registered typeID is an error.\n\n```go\nfunc RegisterUIWidget(typeID string, describer UIWidgetDescriber) error\n```\nRegisterUIWidget registers describer under typeID in the global dashboard widget registry. Re-registering replaces the previous describer. Returns an error for empty typeID/nil describer.\n\n```go\nfunc ResolveFilePath(root, name string) (string, error)\n```\nresolveFilePath applies the host's FileRoot sandbox. When FileRoot is empty the path passes through unchanged (unrestricted — document at deploy time by the consuming application). When set, the cleaned absolute path must stay under the root; \"..\" escapes are rejected.\n\n```go\nfunc ResolveLinkInTarget(host NodeHost, workflowID, target string, dynamic bool) (string, error)\n```\nResolveLinkInTarget resolves a link target to a linkIn node id, implementing Node-RED's linkcallTargets.getTargetNode: a direct node id wins (static choice); otherwise, when dynamic is true, the target is treated as a linkIn NAME — unique within the caller's flow first, then globally across non-component linkIns; zero or many matches fail.\n\nSince this engine folds every Node-RED tab into one workflow, the flow-scoped and global lookups are the same scan.\n\n```go\nfunc ResolveWSClient(host NodeHost, workflowID, ref string) (*WSClientState, *WSClientConfig, error)\n```\nResolveWSClient resolves ref to a websocketClient config node and returns its shared state plus decoded config. ref empty returns (nil, nil, nil).\n\n```go\nfunc ResolveWSListener(host NodeHost, workflowID, ref string) (*WSListenerState, *WSListenerConfig, error)\n```\nResolveWSListener resolves ref to a websocketListener config node and returns its shared state plus decoded config. ref empty returns (nil, nil, nil) — the caller is not in shared-config mode.\n\n```go\nfunc SetPath(m map[string]interface{}, path string, value interface{})\n```\nsetPath sets value at the dotted path inside m, creating nested maps as needed\n\n```go\nfunc SortedKeys(m map[string]interface{}) []string\n```\nsortedKeys returns the map keys in deterministic (sorted) order\n\n```go\nfunc SplitPath(path string) []string\n```\nsplitPath splits a dotted field path into non-empty segments\n\n```go\nfunc StringOf(v any) string\n```\nStringOf returns v as a string when it is one, \"\" otherwise.\n\n```go\nfunc TCPPayloadBytes(input nodestore.MessageInterface) ([]byte, error)\n```\nTCPPayloadBytes converts the message Data into bytes to send: strings pass through, \\[]byte as-is, anything else as JSON with a trailing newline.\n\n```go\nfunc ToFloat(value interface{}) (float64, error)\n```\nToFloat parses a payload value as a float64\n\n```go\nfunc UIApplyOverrides(state map[string]interface{}, ui map[string]interface{})\n```\nUIApplyOverrides merges the Data\\[\"ui\"] override map into state — only keys the state already carries may be overridden, so a message cannot invent arbitrary render directives.\n\n```go\nfunc UIFormatValue(v interface{}) string\n```\nUIFormatValue renders a display value as text: strings pass through, numbers print compactly, anything else is JSON-encoded.\n\n```go\nfunc UILayoutSchemaFields() map[string]interface{}\n```\nUILayoutSchemaFields returns the shared widget layout properties — plain string/number fields matching the convention the dashboard manifest reads (page/group/label/order; no config nodes).\n\n```go\nfunc UINumberSlice(v interface{}) []float64\n```\nUINumberSlice coerces a display value to a float slice — arrays element-wise (non-numeric entries dropped), a scalar to a single-element slice.\n\n```go\nfunc UINumberValue(v interface{}) (float64, bool)\n```\nUINumberValue coerces a display value to float64 — numbers pass through, numeric strings parse, anything else reports ok=false.\n\n```go\nfunc UIOverrides(data interface{}) map[string]interface{}\n```\nUIOverrides returns the optional per-message override map carried in Data\\[\"ui\"] (merged over computed widget state by the executor).\n\n```go\nfunc UIPayloadValue(data interface{}) interface{}\n```\nUIPayloadValue extracts the display value from message Data: Data\\[\"payload\"] wins when Data is a map carrying the key (the inject/client-input convention); otherwise Data itself is the value.\n\n```go\nfunc UIWithLayout(extra map[string]interface{}) map[string]interface{}\n```\nUIWithLayout returns a schema properties map = layout fields + extra type-specific fields.\n\n```go\nfunc UnescapeDelim(s string) string\n```\nunescapeDelim converts literal escape sequences (\"\\\\n\", \"\\\\t\", \"\\\\r\", \"\\\\0\", \"\\\\\\\\\") stored in the config into real characters\n\n```go\nfunc UnescapeTCP(s string) string\n```\nUnescapeTCP decodes the common escape sequences config fields accept (same convention as the split node's delimiter).\n\n```go\nfunc UpsertNode(reg NodeRegistration) error\n```\nUpsertNode registers or replaces a registration — the compatibility path for metadata-only palette entries which historically replaced existing entries.\n\n```go\nfunc WorkflowNodeDisabled(workflow nodestore.WorkflowInterface, node nodestore.NodeInterface) bool\n```\nWorkflowNodeDisabled reports whether node is inert for a deploy — the runner-agnostic disabled predicate so optional packages (the dashboard hub) that collect node subsets of a deployed workflow honor the same semantics the engine applies.\n\nA node is disabled when its own \"d\"/\"disabled\" data flag is set (Node-RED parity), when its child flow (data.childFlow — an id under the id-keyed model, a name in legacy documents) is listed in workflow.GetView()\\[\"disabledFlows\"] or flagged enabled:false in workflow.GetView()\\[\"childFlows\"], or when a view group containing it (workflow.GetView()\\[\"groups\"] entry with disabled:true) is disabled. noderunner's deploy-time predicate delegates here so the semantics stay single-sourced in the nodebase.\n\n## Types\n\n```go\ntype Activator interface {\n\tActivate(ctx context.Context) error\n}\n```\nActivator is an optional companion to Stopper. When implemented, the deploy-time activation pass calls Activate instead of Execute, so nodes that ALSO receive wired messages (e.g. queue) can tell the activation call apart from a message delivery.\n\n```go\ntype BaseNode struct {\n\tnodestore.NodeInterface\n}\n```\nBaseNode provides the shared executor behavior every node type builds on. It carries no identity of its own: it wraps the nodestore.NodeInterface entity, so the node's id, type, position and config Data live in exactly one place — the executor is a behavior shell over the entity, not a shadow copy of it.\n\n```go\nfunc NewBaseNode(node nodestore.NodeInterface) *BaseNode\n```\nNewBaseNode creates a new BaseNode wrapping node.\n\n```go\nfunc (n *BaseNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)\n```\nExecute is a default implementation that can be overridden by specific nodes\n\n```go\nfunc (n *BaseNode) ID() string\n```\nID returns the node's ID (NodeExecutor contract over the entity).\n\n```go\nfunc (n *BaseNode) Type() string\n```\nType returns the node's type (NodeExecutor contract over the entity).\n\n```go\nfunc (n *BaseNode) Validate() error\n```\nValidate performs basic validation that all nodes should pass\n\n```go\ntype CheckpointConfig struct {\n\tQueueConfig\n\t// Routes is the ordered list of route labels; routes[i] labels\n\t// output_{i+1}. Accepts a JSON array or a comma-separated string.\n\tRoutes interface{} `json:\"routes\"`\n}\n```\nCheckpointConfig holds the node.GetData() fields of a checkpoint node: the queue's capacity/policy/backend/dir fields plus the ordered route labels. There is no \\`hold\\` — a checkpoint is always held.\n\n```go\ntype ContextStore interface {\n\t// GetContext returns the value stored under key in the given\n\t// scope; ok is false when the key has never been set.\n\tGetContext(scope, scopeID, key string) (value interface{}, ok bool, err error)\n\t// SetContext stores value under key in the given scope.\n\tSetContext(scope, scopeID, key string, value interface{}) error\n\t// DeleteContext removes a single key (no error when absent).\n\tDeleteContext(scope, scopeID, key string) error\n\t// DeleteContextScope removes every key in the scope\n\t// (e.g. when a workflow is deleted).\n\tDeleteContextScope(scope, scopeID string) error\n\t// ContextKeys lists the keys stored in the scope (Node-RED\n\t// context.keys() / flow.keys() parity).\n\tContextKeys(scope, scopeID string) ([]string, error)\n}\n```\nContextStore is the persistence contract behind the function node's context API (context.get/set = node scope, flow.get/set, global.get/set). It lives in flowrunner — like DurableInboxStore and LeaseStore — because the import direction is flowadmin/storage -\u003e flowrunner. Implementations must tolerate values that are arbitrary goja exports (map\\[string]interface{}, \\[]interface{}, float64, string, bool, nil); disk-backed stores serialize them as JSON.\n\n```go\ntype Fs interface {\n\t// Join joins a directory and a base name using the backend's\n\t// path convention (OS separator locally, \"/\" remotely).\n\tJoin(dir, name string) string\n\t// MkdirAll creates dir and any missing parents.\n\tMkdirAll(dir string) error\n\t// List returns the direct children of dir.\n\tList(dir string) ([]FsEntry, error)\n\t// ReadFile reads the whole file.\n\tReadFile(name string) ([]byte, error)\n\t// WriteFile writes data to name, creating or truncating.\n\tWriteFile(name string, data []byte) error\n\t// AppendFile appends data to name, creating it if needed.\n\tAppendFile(name string, data []byte) error\n\t// Rename moves old to new. Atomic on local and sftp; NOT atomic\n\t// on ftp (documented — never yields a partial final file).\n\tRename(oldName, newName string) error\n\t// Remove deletes a file. A missing file is not an error.\n\tRemove(name string) error\n\t// Close releases any connection. Local is a no-op.\n\tClose() error\n}\n```\nFs is the filesystem seam: the minimal surface DirQueueStore and the fsIn/fsOut nodes need.\n\n```go\nfunc OpenFs(locator string, creds *FsCredentials) (Fs, string, error)\n```\nOpenFs resolves a locator to a connected Fs plus the directory the locator pointed at. Remote locators are dialed once here so config errors surface at deploy; the returned Fs transparently re-dials if the connection later drops (see redialFs). creds may be nil. The caller owns the Fs and should Close it when done.\n\n```go\ntype FsCredentials struct {\n\t// Password authenticates password login (credential field).\n\tPassword string\n\t// KeyFile is a LOCAL path to an SSH private key (sftp only). An\n\t// optional passphrase rides in Password.\n\tKeyFile string\n\t// HostKey pins the expected SSH host public key — authorized_keys\n\t// line or base64 wire format. ftp ignores it.\n\tHostKey string\n\t// AcceptAnyHostKey disables SSH host-key verification when\n\t// HostKey is empty (INSECURE — explicit opt-out required; sftp\n\t// otherwise refuses to connect without a pinned key).\n\tAcceptAnyHostKey bool\n}\n```\nFsCredentials carries the secret/auth material for remote locators. Password is credential-typed on every node schema; host keys are public information and travel as plain config.\n\n```go\nfunc FsCredentialsFromData(data map[string]interface{}) *FsCredentials\n```\nFsCredentialsFromData extracts the credential/config keys shared by the queue dir backend and the fsIn/fsOut nodes.\n\n```go\ntype FsEntry struct {\n\tName    string\n\tSize    int64\n\tModTime time.Time\n\tIsDir   bool\n}\n```\nFsEntry describes one directory entry or file.\n\n```go\ntype HTTPRouter interface {\n\t// Handle mounts handler for pattern. A conflict with an already\n\t// mounted route is returned as an error, never panicked.\n\tHandle(pattern string, handler http.Handler) error\n\t// Unregister removes the route mounted for pattern (a no-op when\n\t// the pattern was never mounted).\n\tUnregister(pattern string)\n}\n```\nHTTPRouter is the host's shared-listener seam: an optional router the host installs (same optional-field contract as HTTPAuthenticator, ContextStore or DeployObserver) so HTTP-serving nodes can mount routes on the host's own HTTP server instead of binding a private TCP listener — the Node-RED model where an http-in node just names a path and serves it on the admin port. Nil — the default — means no shared router exists; a node configured for shared-listener mode then fails activation with an explicit error rather than silently falling back to a private listener (the caller asked for the host's auth/TLS surface; serving the route unauthenticated on another port would surprise).\n\nPatterns are Go 1.22 ServeMux patterns (e.g. \"GET /hello\", \"POST /submit/{job}\"). Handle must report a route conflict as an error — the host surfaces it as a deploy failure on the second registrant. Unregister removes a previously mounted pattern and must tolerate patterns that were never mounted (Stop is idempotent).\n\nRoutes mounted here serve inside whatever middleware the host applies — for the flowadmin adapter that means admin auth when an auth file is configured. There is no per-route opt-out in v1.\n\n```go\ntype LocalFs struct{}\n```\nLocalFs wraps the native os package — the pre-task DirQueueStore behaviour, byte for byte.\n\n```go\nfunc (LocalFs) AppendFile(name string, data []byte) error\n```\n\n```go\nfunc (LocalFs) Close() error\n```\n\n```go\nfunc (LocalFs) Join(dir, name string) string\n```\n\n```go\nfunc (LocalFs) List(dir string) ([]FsEntry, error)\n```\n\n```go\nfunc (LocalFs) MkdirAll(dir string) error\n```\n\n```go\nfunc (LocalFs) ReadFile(name string) ([]byte, error)\n```\n\n```go\nfunc (LocalFs) Remove(name string) error\n```\n\n```go\nfunc (LocalFs) Rename(oldName, newName string) error\n```\n\n```go\nfunc (LocalFs) WriteFile(name string, data []byte) error\n```\n\n```go\ntype MQTTBrokerConfig struct {\n\t// Broker is the broker host, host:port or a URL\n\t// (tcp://, ssl://, ws://, wss://). Port may also be supplied\n\t// separately in Port (Node-RED keeps them as two fields).\n\tBroker string `json:\"broker\"`\n\t// Port is the optional separate broker port; applied when Broker\n\t// carries no :port suffix and no URL scheme.\n\tPort string `json:\"port\"`\n\t// ClientID is the MQTT client identifier; empty lets the library\n\t// generate one per connect.\n\tClientID string `json:\"clientid\"`\n\t// User/Password are optional broker credentials (the Node-RED\n\t// mqtt-broker field names). Both are credential-typed keys.\n\tUser     string `json:\"user\"`\n\tPassword string `json:\"password\"`\n\t// CleanSession requests a fresh broker session (default true —\n\t// Node-RED field cleansession). Pointer so import can distinguish\n\t// \"unset\" from an explicit false.\n\tCleanSession *bool `json:\"cleansession\"`\n\t// KeepAlive is the MQTT keepalive in seconds (0 → library default).\n\tKeepAlive int `json:\"keepalive\"`\n\t// UseTLS forces TLS even for a tcp:// address (Node-RED usetls).\n\tUseTLS bool `json:\"usetls\"`\n\t// VerifyServerCert enables peer verification (default true —\n\t// Node-RED verifyservercert). Pointer for the same unset/false\n\t// distinction as CleanSession.\n\tVerifyServerCert *bool `json:\"verifyservercert\"`\n\t// TLS references a tlsConfig node id for shared certificate\n\t// material; takes precedence over the inline tlsca/tlscert/tlskey\n\t// fields below.\n\tTLS string `json:\"tls\"`\n\t// TLSCA/TLSCert/TLSKey are inline PEM paths used when no tlsConfig\n\t// reference is configured.\n\tTLSCA   string `json:\"tlsca\"`\n\tTLSCert string `json:\"tlscert\"`\n\tTLSKey  string `json:\"tlskey\"`\n\t// TLSServerName overrides the verification hostname.\n\tTLSServerName string `json:\"tlsservername\"`\n\t// Will* describe the MQTT last-will published by the broker when\n\t// this client disconnects ungracefully.\n\tWillTopic   string `json:\"willtopic\"`\n\tWillPayload string `json:\"willpayload\"`\n\tWillQoS     int    `json:\"willqos\"`\n\tWillRetain  bool   `json:\"willretain\"`\n}\n```\nMQTTBrokerConfig holds configuration for the mqttBroker config node — a shared connection description referenced by mqttIn/mqttOut nodes via their \"broker\" field (which then holds the config node's id instead of an address). Field spellings follow the Node-RED export format.\n\n```go\ntype MQTTClientPool struct {\n\t// contains filtered or unexported fields\n}\n```\nMQTTClientPool is the workflow-level registry of shared broker connections keyed by broker address, so mqttIn/mqttOut nodes against the same broker share one TCP connection. Stored in host node state under MQTTClientsKey — rebuilt per workflow run.\n\n```go\nfunc NewMQTTClientPool() *MQTTClientPool\n```\nNewMQTTClientPool returns an empty pool (the value stored under MQTTClientsKey in host node state).\n\n```go\nfunc (p *MQTTClientPool) Client(opts *MQTTOpts, clientID string) (mqtt.Client, error)\n```\nClient returns a connected client for the resolved dial options, connecting and caching it on first use. The pool key includes the username, client id and a TLS marker so nodes against the same broker with different credentials, identities or transports get separate connections.\n\n```go\ntype MQTTConnConfig struct {\n\t// Broker is host:port, a full URL, or an mqttBroker node id.\n\tBroker string `json:\"broker\"`\n\t// ClientID is the MQTT client identifier.\n\tClientID string `json:\"clientid\"`\n\t// CleanSession requests a fresh broker session (default true).\n\tCleanSession *bool `json:\"cleansession\"`\n\t// KeepAlive is the MQTT keepalive in seconds.\n\tKeepAlive int `json:\"keepalive\"`\n\t// UseTLS forces TLS even for a tcp:// address.\n\tUseTLS bool `json:\"usetls\"`\n\t// TLSInsecure disables peer verification (insecure opt-out).\n\tTLSInsecure bool `json:\"tlsinsecure\"`\n\t// TLS references a tlsConfig node id for shared certificate\n\t// material.\n\tTLS string `json:\"tls\"`\n\t// TLSCA/TLSCert/TLSKey are inline PEM paths used when no tlsConfig\n\t// reference is configured.\n\tTLSCA   string `json:\"tlsca\"`\n\tTLSCert string `json:\"tlscert\"`\n\tTLSKey  string `json:\"tlskey\"`\n\t// TLSServerName overrides the verification hostname.\n\tTLSServerName string `json:\"tlsservername\"`\n\t// Username/Password are optional broker credentials. They are\n\t// credential-typed fields: stored outside the exported flow\n\t// document and merged back in at deploy time.\n\tUsername string `json:\"username,omitempty\"`\n\tPassword string `json:\"password,omitempty\"`\n\t// Will* describe the MQTT last-will.\n\tWillTopic   string `json:\"willtopic\"`\n\tWillPayload string `json:\"willpayload\"`\n\tWillQoS     int    `json:\"willqos\"`\n\tWillRetain  bool   `json:\"willretain\"`\n}\n```\nMQTTConnConfig is the inline connection block embedded in the mqttIn/mqttOut node configs. Broker holds either an address (host:port or URL) or the id of an mqttBroker config node; in the latter case the config node's fields win, with these inline fields used only where the config node leaves them empty.\n\n```go\ntype MQTTOpts struct {\n\t// Broker is the normalized address: host:port or scheme URL.\n\tBroker string\n\t// ClientID is the MQTT client identifier (empty → generated).\n\tClientID     string\n\tUsername     string\n\tPassword     string\n\tCleanSession bool\n\t// KeepAlive seconds; 0 → library default.\n\tKeepAlive int\n\t// TLS is the transport config; nil for plain TCP.\n\tTLS *tls.Config\n\t// Will* describe the last-will; WillTopic empty → no will.\n\tWillTopic   string\n\tWillPayload string\n\tWillQoS     int\n\tWillRetain  bool\n}\n```\nMQTTOpts is the resolved dial configuration — an address plus every connection option a real flow needs.\n\n```go\nfunc ResolveMQTTOpts(host NodeHost, workflowID string, c *MQTTConnConfig) (*MQTTOpts, error)\n```\nResolveMQTTOpts merges an mqtt node's inline connection block with a referenced mqttBroker config node (when Broker holds a node id) and materializes the TLS material, returning ready dial options. When Broker is an address it is used verbatim and only the inline fields apply — the previous single-node behaviour.\n\n```go\ntype MessageExpander interface {\n\t// Expand returns the messages that replace the node's single output.\n\t// An empty result means no message continues downstream.\n\tExpand(output nodestore.MessageInterface) []nodestore.MessageInterface\n}\n```\nMessageExpander is implemented by nodes that turn a single output message into a sequence of messages (e.g. the split node). After the node executes, each returned payload is enqueued separately on the node's selected outgoing edges — routing via PortRouter still applies.\n\n```go\ntype NodeDescriptor 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\tSchema      map[string]interface{} `json:\"schema,omitempty\"`\n\tEditorHTML  string                 `json:\"editorHtml,omitempty\"`\n}\n```\nNodeDescriptor is the editor-facing metadata a registration carries: what the palette shows for the type. Schema is the JSON schema served to editors — including the editor extensions \"format\":\"credential\" and \"showIf\". Set groups registrations Node-RED nodeSet-style (\"core\" for built-ins, the pack name for third-party) so the palette can group and a future enable/disable can operate per set. EditorHTML optionally carries the node's Node-RED-style editor bundle (config dialog markup + help text); the built-in folders embed theirs from editor.html.\n\n```go\ntype NodeEvent struct {\n\tSeq      int64     `json:\"seq\"`\n\tTime     time.Time `json:\"time\"`\n\tNodeID   string    `json:\"node_id,omitempty\"`\n\tNodeName string    `json:\"node_name,omitempty\"`\n\tLevel    string    `json:\"level\"` // info | warn | error | debug\n\tMessage  string    `json:\"message\"`\n}\n```\nNodeEvent is a single timestamped entry in a workflow's execution log. Events feed the editor's debug panel and per-node status indicators; the workflow-status endpoint returns the ones recorded since a caller-supplied sequence number.\n\n```go\ntype NodeExecutor interface {\n\t// ID returns the unique identifier for the node.\n\tID() string\n\n\t// Type returns the type of the node.\n\tType() string\n\n\t// Execute performs the node's operation.\n\tExecute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)\n\n\t// Validate checks if the node is properly configured.\n\tValidate() error\n}\n```\nNodeExecutor defines the interface that all nodes must implement.\n\n```go\ntype NodeFactory func(node nodestore.NodeInterface, host NodeHost) (NodeExecutor, error)\n```\nNodeFactory builds a NodeExecutor for one workflow node instance. It is the stable public contract for node registration. The signature is frozen.\n\nnode carries the stored definition (ID, Type, WorkflowID, Data config map); host is the runtime seam the node executes against — the runner passes itself in, so long-lived nodes can emit messages, consult LookupNode, or use host services (context store, HTTP router, TLS config, queue service) without ever holding a concrete host type.\n\n```go\ntype NodeHost interface {\n\t// Emit routes payload out of nodeID's outgoing edges (all of them\n\t// when ports is nil) inside the running workflow.\n\tEmit(workflowID, nodeID string, payload nodestore.MessageInterface, ports []string) error\n\n\t// EmitEvent appends a timestamped log entry (info|warn|error|debug)\n\t// for the node — feeds the editor's debug panel and status badges.\n\tEmitEvent(workflowID, nodeID, nodeName, level, message string)\n\n\t// InjectMessage routes an externally-originated payload (e.g. an\n\t// HTTP trigger request) through the nodes downstream of fromNodeID.\n\t// It returns a message ID whose response can be awaited via\n\t// ResolveResponse — used by response-style nodes to reply to the\n\t// original request.\n\tInjectMessage(workflowID, fromNodeID string, payload nodestore.MessageInterface) (string, chan nodestore.MessageInterface, error)\n\n\t// ResolveResponse delivers payload to the party awaiting the\n\t// response channel returned by InjectMessage.\n\tResolveResponse(msgID string, payload nodestore.MessageInterface) error\n\n\t// DiscardPending drops the response correlation registered under\n\t// msgID (response node fired with nothing waiting, or a timeout).\n\tDiscardPending(msgID string)\n\n\t// LookupNode returns the stored definition of nodeID within the\n\t// running workflow — used for link targets and config-node\n\t// references (e.g. tlsConfig).\n\tLookupNode(workflowID, nodeID string) (nodestore.NodeInterface, bool)\n\n\t// RunningFlow returns the expanded in-memory workflow definition\n\t// the run is executing. ok is false when the workflow is not\n\t// running on this host.\n\tRunningFlow(workflowID string) (nodestore.WorkflowInterface, bool)\n\n\t// RunContext returns the per-run context cancelled when the\n\t// workflow stops — long-lived nodes select on it so in-flight\n\t// work stops promptly on undeploy.\n\tRunContext(workflowID string) context.Context\n\n\t// GetOrCreateNodeState returns the per-run state slot for\n\t// (workflowID, nodeID), calling factory to create it on first use.\n\t// Executors are rebuilt per message, so stateful nodes keep their\n\t// buffers here.\n\tGetOrCreateNodeState(workflowID, nodeID string, factory func() interface{}) interface{}\n\n\t// ExecuteDownstream continues the traversal downstream of\n\t// fromNodeID on a separate path — for nodes that emit outside the\n\t// synchronous Execute return (e.g. linkCall's deferred fan-out).\n\tExecuteDownstream(ctx context.Context, workflowID, fromNodeID string, workflow nodestore.WorkflowInterface, payload nodestore.MessageInterface, ports []string)\n\n\t// NodeEnv resolves an environment variable in node scope\n\t// (Node-RED env.get: group/component/flow layers, then global env,\n\t// then the OS environment).\n\tNodeEnv(workflowID, nodeID, name string) (interface{}, bool)\n\n\t// ResolvedContextStore returns the store backing function-node\n\t// context (node/flow/global scopes): the host's configured store,\n\t// or a process-local in-memory one when none is wired.\n\tResolvedContextStore() ContextStore\n\n\t// LoadTLSConfig resolves a tlsConfig node reference (node id\n\t// within the workflow) into a ready *tls.Config for a client\n\t// dial.\n\tLoadTLSConfig(workflowID, ref string) (*tls.Config, error)\n\n\t// FileRootPath returns the root directory file nodes are\n\t// restricted to. Empty means unrestricted.\n\tFileRootPath() string\n\n\t// ExecAllowed reports whether the exec node may run arbitrary\n\t// system commands on this host.\n\tExecAllowed() bool\n\n\t// SharedHTTPRouter returns the host's shared-listener seam: an\n\t// optional router HTTP-serving nodes mount routes on instead of\n\t// binding a private TCP listener (the Node-RED model where an\n\t// http-in node names a path served on the host's own port).\n\t// Nil means no shared router exists.\n\tSharedHTTPRouter() HTTPRouter\n\n\t// HTTPAuthFunc authenticates requests arriving at node-served\n\t// HTTP listeners (submitIn auth \"admin\"), returning the\n\t// authenticated username. Nil means no credentials are\n\t// configured.\n\tHTTPAuthFunc() func(r *http.Request) (username string, ok bool)\n\n\t// QueueService returns the host's staging-queue service backing\n\t// the queue and checkpoint nodes. Nil means the host offers no\n\t// queue service; queue-family nodes then fail activation with an\n\t// explicit error.\n\tQueueService() QueueService\n}\n```\nNodeHost is the runtime seam between an executor and the runner that hosts it. It is the ONLY thing an executor sees of its host: every built-in node is written against NodeHost, never against a concrete host type, so any runner implementing NodeHost can host this pack and any pack written against NodeHost runs on any such runner.\n\nThe surface covers the four things executors legitimately need — emission back into the graph (Emit, InjectMessage, DeliverSync-style helpers), run state (node state slots, running flow, run context), host services (HTTP router/authenticator, TLS config resolution, context store, file root, exec gate, env lookup) and lifecycle correlation (pending responses, queue service).\n\n```go\ntype NodeRegistration struct {\n\tDescriptor NodeDescriptor\n\tFactory    NodeFactory // nil for palette-only registrations\n}\n```\nNodeRegistration bundles a type's factory with its editor descriptor — the single registration unit for both the runtime (deploy) and the palette (nodeadmin).\n\n```go\nfunc RegisteredNode(typeID string) (NodeRegistration, bool)\n```\nRegisteredNode returns the registration for typeID, if any.\n\n```go\nfunc RegisteredNodes() []NodeRegistration\n```\nRegisteredNodes returns a snapshot of every globally registered node type, sorted by type id — what editors serve through /api/node-fetch-all.\n\n```go\ntype OverflowPolicy string\n```\nOverflowPolicy selects what happens when a message is offered to a node inbox that has reached its configured capacity.\n\n```go\nconst (\n\t// OverflowBlock parks the message until the node's pending count\n\t// drops below capacity.\n\tOverflowBlock OverflowPolicy = \"block\"\n\t// OverflowDropNewest discards the incoming message.\n\tOverflowDropNewest OverflowPolicy = \"drop-newest\"\n\t// OverflowDropOldest evicts the node's oldest queued message to\n\t// make room for the incoming one.\n\tOverflowDropOldest OverflowPolicy = \"drop-oldest\"\n\t// OverflowRouteToCatch discards the incoming message and reports it\n\t// to in-scope catch nodes as an error event.\n\tOverflowRouteToCatch OverflowPolicy = \"route-to-catch\"\n)\n```\n\n```go\nfunc ParseOverflowPolicy(value interface{}) (OverflowPolicy, bool)\n```\nParseOverflowPolicy normalizes a config value into an OverflowPolicy.\n\n```go\ntype PassThroughNode struct {\n\t*BaseNode\n}\n```\nPassThroughNode is the executor for node types without payload logic (junction, event sources, legacy internal types).\n\n```go\nfunc NewPassThroughNode(node nodestore.NodeInterface) *PassThroughNode\n```\nNewPassThroughNode creates the pass-through executor for node.\n\n```go\nfunc (n *PassThroughNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)\n```\nExecute returns the input unchanged.\n\n```go\ntype PortRouter interface {\n\t// SelectPorts returns the output port keys (e.g. \"output_1\") that\n\t// the produced message should be routed to. An empty result means\n\t// the message dies at this node (Node-RED switch behaviour).\n\tSelectPorts(input, output nodestore.MessageInterface) []string\n}\n```\nPortRouter is implemented by nodes that route their output to specific ports (e.g. the switch node). After such a node executes, only edges whose SourceKey is in the returned set are followed; other wired branches receive no message.\n\n```go\ntype QueueConfig struct {\n\t// Capacity is the max queued items (\u003c=0 unbounded). Alias for\n\t// inboxCapacity. Kept interface{} so a loosely-typed editor value\n\t// cannot fail the config decode — the authoritative parse is the\n\t// host's queue-config resolution.\n\tCapacity interface{} `json:\"capacity\"`\n\t// Policy is the overflow policy: block | drop-newest | drop-oldest |\n\t// route-to-catch. Alias for inboxPolicy. interface{} for the same\n\t// loose-typing reason as Capacity.\n\tPolicy interface{} `json:\"policy\"`\n\t// Hold starts the queue held: deliveries enqueue but nothing\n\t// drains. interface{} — truthy parsing accepts bools, strings and\n\t// numbers.\n\tHold interface{} `json:\"hold\"`\n\t// Backend selects where items are persisted: \"durable\" (default,\n\t// the host's durable inbox store — multi-runner) or \"dir\" (one\n\t// file per item under Dir — materialized for OS tooling).\n\tBackend interface{} `json:\"backend\"`\n\t// Dir is the target directory for backend=\"dir\". A local path (or\n\t// NFS/SMB/SSHFS mount) uses the local adapter; an sftp:// or\n\t// ftp:// locator stores item files on the remote directory\n\t// through the Fs seam — remote backends are POLLING.\n\tDir string `json:\"dir\"`\n\t// Password authenticates remote locators (credential field —\n\t// masked, stored outside the exported flow document).\n\tPassword string `json:\"password\"`\n\t// KeyFile is a local path to an SSH private key for sftp locators\n\t// (Password doubles as the key passphrase).\n\tKeyFile string `json:\"keyFile\"`\n\t// HostKey pins the expected sftp host public key (authorized_keys\n\t// or base64 form); empty accepts any key (insecure, logged).\n\tHostKey string `json:\"hostKey\"`\n}\n```\nQueueConfig holds the node.GetData() fields of a queue node.\n\n```go\ntype QueueContract interface {\n\t// Arm starts the drainer once and recovers surviving durable\n\t// rows. Idempotent — the deploy-time activation path calls it.\n\tArm(ctx context.Context)\n\n\t// Enqueue stages a delivered payload under the queue's capacity\n\t// and overflow policy.\n\tEnqueue(p nodestore.MessageInterface) error\n\n\t// Stop shuts the drainer down (idempotent) and releases the\n\t// queue's resources.\n\tStop()\n}\n```\nQueueContract is the executor-facing surface of a host staging queue: the queue/checkpoint shells stage and drain through it; the inspection API (item listing, hold, per-item release) is a host-internal concern and intentionally not part of this contract.\n\n```go\ntype QueueInspector interface {\n\t// Items returns the queued entries in FIFO order.\n\tItems() []QueueItem\n\t// Count reports the queued depth (excluding any waitlist).\n\tCount() int\n\t// Held reports whether the queue is held (accepting, not draining).\n\tHeld() bool\n\t// SetHold toggles the hold gate at runtime.\n\tSetHold(hold bool)\n\t// Enqueue stages a payload under the queue's capacity/policy.\n\tEnqueue(p nodestore.MessageInterface) error\n\t// DeleteItem drops the queued item with the given seq.\n\tDeleteItem(seq int64) error\n\t// RequeueItem releases one queued item downstream on all edges.\n\tRequeueItem(seq int64) error\n\t// ReleaseItem releases one queued item; route picks the outgoing\n\t// edge for checkpoint queues (empty = all edges), approvedBy is\n\t// recorded in the released payload's checkpoint metadata.\n\tReleaseItem(seq int64, route string, approvedBy string) error\n\t// RouteLabels returns the checkpoint's named release routes in\n\t// port order; plain queues report nil.\n\tRouteLabels() []string\n}\n```\nQueueInspector is the read/control surface a runner exposes for a queue node's live staging queue: depth and item listing, the hold/release gate, and per-item delete/requeue (the same endpoint serves checkpoint route releases via ReleaseItem's route parameter).\n\n```go\ntype QueueItem struct {\n\tSeq        int64                      `json:\"seq\"`\n\tEnqueuedAt time.Time                  `json:\"enqueued_at\"`\n\tPayload    nodestore.MessageInterface `json:\"-\"`\n}\n```\nQueueItem is one queued entry as exposed to the inspection API.\n\n```go\ntype QueueNode struct {\n\t*BaseNode\n\t// contains filtered or unexported fields\n}\n```\nQueueNode is the executor shell for the queue (and checkpoint) node types. It is a Stopper + Activator: activation (deploy) arms the shared drainer; message-time Execute stages the payload into the queue.\n\n```go\nfunc NewCheckpointNode(node nodestore.NodeInterface, config *CheckpointConfig, host NodeHost) *QueueNode\n```\nNewCheckpointNode creates the executor shell for a checkpoint node. It reuses QueueNode wholesale — the difference lives on the shared queue (manual + routes).\n\n```go\nfunc NewQueueNode(node nodestore.NodeInterface, config *QueueConfig, host NodeHost) *QueueNode\n```\nNewQueueNode creates a new queue node executor shell.\n\n```go\nfunc (n *QueueNode) Activate(ctx context.Context) error\n```\nActivate implements Activator: the deploy-time call arms the shared drainer and recovers surviving durable rows. It never stages the activation payload. The initial hold state was already resolved into the queue at creation (node.GetData()\\[\"hold\"]).\n\n```go\nfunc (n *QueueNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)\n```\nExecute stages the delivered payload into the queue. Output is nil — the message was staged, not passed through; the drainer emits it downstream later under the hold/release gate.\n\n```go\nfunc (n *QueueNode) Stop() error\n```\nStop implements Stopper: shuts down the shared drainer. Must not recreate host state — it may already be wiped, in which case the cached queue is the only reference to the live drainer.\n\n```go\nfunc (n *QueueNode) StopKey() string\n```\nStopKey dedupes stopper registration: executors are rebuilt per message, but all shells of one queue share the queue's drainer.\n\n```go\nfunc (n *QueueNode) Validate() error\n```\nValidate enforces the queue's hard durability requirement and normalizes policy config early (deploy-time failure, not message-time).\n\n```go\ntype QueueService interface {\n\t// EnsureQueue returns the shared staging queue behind node,\n\t// creating it on first use. checkpoint marks the queue manual\n\t// (never drains on its own — items leave only via route releases)\n\t// and routes carries the checkpoint's named release choices in\n\t// port order.\n\tEnsureQueue(node nodestore.NodeInterface, checkpoint bool, routes []string) (QueueContract, error)\n\n\t// HasDurableStore reports whether a durable inbox store is wired.\n\t// The queue node's default \"durable\" backend requires it; dir\n\t// backends do not.\n\tHasDurableStore() bool\n}\n```\nQueueService is the host's staging-queue service — a structural capability NodeHost exposes so the queue and checkpoint executors can stage, hold and release messages without knowing the concrete queue implementation (durable table, directory backend, …).\n\n```go\ntype RuleContext struct {\n\tHost       NodeHost\n\tWorkflowID string\n\tNodeID     string\n}\n```\nRuleContext carries the host seam and node identity a change or switch rule needs to resolve environment variables and flow/global context at runtime — the same seam the function node's env.get/flow.get/global.get use. A nil \\*RuleContext disables those resolutions: context reads miss, context writes are skipped and env lookups fail, matching the behaviour of a host-less executor.\n\n```go\nfunc (rc *RuleContext) ContextAvailable(scope string) bool\n```\nContextAvailable reports whether the host actually provides a context store — deploy-time checks use it to fail loud on rules that would otherwise silently no-op.\n\n```go\nfunc (rc *RuleContext) ContextDelete(scope, key string)\n```\nContextDelete removes a key from flow/global context.\n\n```go\nfunc (rc *RuleContext) ContextGet(scope, key string) (interface{}, bool)\n```\nContextGet reads a key from flow/global context; ok is false when no host store is wired or the key is absent.\n\n```go\nfunc (rc *RuleContext) ContextSet(scope, key string, value interface{})\n```\nContextSet writes a key into flow/global context; a no-op when the host offers no store.\n\n```go\nfunc (rc *RuleContext) Env(name string) (interface{}, bool)\n```\nEnv resolves an environment variable the way env.get does: the host's layered node env first, then the process environment when the host opts in via OSEnvAllowed.\n\n```go\ntype RunEvent struct {\n\tLevel   string // info | warn | error | debug\n\tMessage string\n}\n```\nRunEvent is an extra event an executor may emit after a successful run (e.g. the debug node's formatted payload, the log node's configured message). The runner appends each returned event under the node that produced it.\n\n```go\ntype RunEventer interface {\n\t// PostRunEvents returns the events to append after a successful\n\t// run. The implementation may also produce side effects (e.g. the\n\t// debug node's console print).\n\tPostRunEvents(node nodestore.NodeInterface, out nodestore.MessageInterface) []RunEvent\n}\n```\nRunEventer is implemented by executors that emit extra events after a successful Execute. The runner emits each returned event under the node that produced it.\n\n```go\ntype RunJournalEntry struct {\n\tSeq        int64       `json:\"seq\"`\n\tTime       time.Time   `json:\"time\"`\n\tDurationMs float64     `json:\"duration_ms\"`\n\tInput      interface{} `json:\"input\"`\n\tOutput     interface{} `json:\"output\"`\n\tError      string      `json:\"error,omitempty\"`\n}\n```\nRunJournalEntry records one node execution: when it ran, how long it took, a summarized credential-safe copy of the input and output payloads, and the error text when the node failed.\n\n```go\ntype StopKeyer interface {\n\t// StopKey returns the deduplication key for stopper registration.\n\tStopKey() string\n}\n```\nStopKeyer lets a Stopper dedupe itself in the runner's per-run stopper registry: nodes whose executors are rebuilt per message but share one underlying resource (e.g. the queue drainer) return a stable key so only the first instance is registered.\n\n```go\ntype Stopper interface {\n\tStop() error\n}\n```\nStopper is implemented by nodes that hold long-lived resources (e.g. an HTTP trigger's listener) which must be shut down when the workflow stops or restarts.\n\n```go\ntype SwitchRule struct {\n\tProperty     string `json:\"property\"`\n\tPropertyType string `json:\"propertyType,omitempty\"` // \"\"|\"msg\" (default) | \"flow\" | \"global\"\n\tOp           string `json:\"op\"`                     // eq | neq | gt | lt | lte | gte | contains | empty | nempty | regex | istype | true | false | null | nnull | else | btwn | hask | head | tail | index\n\tValue        string `json:\"value\"`\n\tValueType    string `json:\"valueType,omitempty\"`\n\tValue2       string `json:\"value2,omitempty\"`\n\tValue2Type   string `json:\"value2Type,omitempty\"`\n}\n```\nSwitchRule is a single ordered rule evaluated against the incoming payload. Property is a dotted path into msg.Payload (e.g. \"path\" or \"body.user.role\") — or a context key when PropertyType is \"flow\"/\"global\", or a sequence expression evaluated against the whole message when PropertyType is \"jsonata\". Rule index i maps to output port \"output\\_{i+1}\". ValueType is Node-RED's vt: how Value is interpreted — \"str\" (default), \"num\", \"bool\", \"json\", \"msg\" (a message property path), \"env\" (environment variable name) or \"flow\"/\"global\" (context key). Value2/Value2Type hold the second comparison value (Node-RED's v2/vt2) used by the range ops \"btwn\" and \"index\".\n\n```go\ntype TCPSessions struct {\n\t// contains filtered or unexported fields\n}\n```\ntcpSessions is the workflow-level registry of accepted TCP connections, keyed by remote \"ip:port\". It lives in the host's node-state map under a reserved key so tcpOut can reply on the connection that produced a message (Node-RED \\_session semantics).\n\n```go\nfunc NewTCPSessions() *TCPSessions\n```\nNewTCPSessions returns an empty session registry (the value stored under TCPSessionsKey in host node state).\n\n```go\nfunc (s *TCPSessions) CloseAll()\n```\nCloseAll closes and removes every registered connection.\n\n```go\nfunc (s *TCPSessions) DeleteIf(key string, conn net.Conn)\n```\nDeleteIf removes key only when it still maps to conn.\n\n```go\nfunc (s *TCPSessions) Each(fn func(key string, conn net.Conn))\n```\nEach calls fn for every registered connection — tcpOut reply mode broadcasts to all pooled sessions when the message carries no ip/port metadata (Node-RED connectionPool semantics).\n\n```go\nfunc (s *TCPSessions) Get(key string) (net.Conn, bool)\n```\nGet returns the connection registered under key.\n\n```go\nfunc (s *TCPSessions) Put(key string, conn net.Conn)\n```\nPut registers conn under key.\n\n```go\ntype TLSConfig struct {\n\t// CertPath is the client/server certificate file (PEM).\n\tCertPath string `json:\"cert\"`\n\t// KeyPath is the private key file paired with CertPath (PEM).\n\tKeyPath string `json:\"key\"`\n\t// CAPath is an optional CA bundle used to verify the peer (PEM).\n\tCAPath string `json:\"ca\"`\n\t// ServerName overrides the SNI / verification hostname\n\t// (default: the dialed host).\n\tServerName string `json:\"servername\"`\n\t// VerifyServerCert disables peer verification when false\n\t// (Node-RED field name: verifyservercert).\n\tVerifyServerCert bool `json:\"verifyservercert\"`\n}\n```\nTLSConfig holds configuration for the tlsConfig node — the Node-RED \\`tls-config\\` config node equivalent. It is a shared config entity: tcp nodes reference it by node id via their \"tls\" field, and the host materializes a \\*tls.Config from its stored paths at message time (NodeHost.LoadTLSConfig). It has no ports and never executes.\n\n```go\nfunc (c *TLSConfig) Build() (*tls.Config, error)\n```\nBuild loads the configured material into a \\*tls.Config.\n\n```go\ntype UIFormField struct {\n\t// Name is the msg.payload object key (required — nameless\n\t// entries are dropped by the describer).\n\tName string `json:\"name\"`\n\t// Label is the control caption; falls back to Name.\n\tLabel string `json:\"label,omitempty\"`\n\t// Type is text (default) | number | checkbox | select.\n\tType string `json:\"type\"`\n\t// Options lists the select choices (select only).\n\tOptions []string `json:\"options,omitempty\"`\n\t// Value is the initial/default control value.\n\tValue interface{} `json:\"value,omitempty\"`\n}\n```\nUIFormField is one normalized form field in the uiForm manifest config; the client renderer generates a control per entry.\n\n```go\nfunc UIFormFields(data map[string]interface{}) []UIFormField\n```\nUIFormFields normalizes node data\\[\"fields\"] into a typed slice — shared by the manifest describer and kept tolerant of hand-edited node JSON.\n\n```go\ntype UIWidgetDescriber func(node nodestore.NodeInterface) UIWidgetManifest\n```\nUIWidgetDescriber extracts a widget's manifest entry from its stored node definition. Registered per node type via RegisterUIWidget — the \"small internal interface\" widget node types implement so the hub stays type-agnostic.\n\nImplementations read layout fields through UIWidgetLayout and add type-specific keys to Config.\n\n```go\ntype UIWidgetManifest struct {\n\tID     string                 `json:\"id\"`\n\tType   string                 `json:\"type\"`\n\tPage   string                 `json:\"page\"`\n\tGroup  string                 `json:\"group,omitempty\"`\n\tLabel  string                 `json:\"label,omitempty\"`\n\tOrder  int                    `json:\"order,omitempty\"`\n\tConfig map[string]interface{} `json:\"config,omitempty\"`\n}\n```\nUIWidgetManifest is the manifest entry for one dashboard widget node instance: everything the dashboard page needs to render it.\n\nPage/Group/Label/Order come from the node's layout fields (see UIWidgetLayout); Config carries type-specific settings the widget's client-side renderer understands (e.g. min/max for a gauge).\n\n```go\nfunc CollectUIWidgets(workflow nodestore.WorkflowInterface) []UIWidgetManifest\n```\nCollectUIWidgets builds the manifest for a deployed workflow: every enabled node whose type has a registered describer, sorted by page → group → order → id for a stable render order.\n\n```go\nfunc UIWidgetLayout(node nodestore.NodeInterface) UIWidgetManifest\n```\nUIWidgetLayout pulls the shared layout fields every widget node carries (page, group, label, order) out of node.GetData(). Widget describers call it and then fill Type/Config.\n\nConvention (documented for widget implementers): data keys \"page\" (string, default \"default\"), \"group\" (string, optional section inside the page), \"label\" (string, falls back to \"name\" then the node id), \"order\" (number, optional sort hint within the group).\n\n```go\ntype UIWidgetNode struct {\n\t*BaseNode\n\t// contains filtered or unexported fields\n}\n```\nUIWidgetNode is the shared executor core for ui\\* widgets: it carries the host reference and the node's workflow id (resolved at factory time from the node entity — the NodeFactory signature carries no workflow parameter) and turns a computed state map into a sink push.\n\n```go\nfunc NewUIWidgetNode(node nodestore.NodeInterface, host NodeHost) *UIWidgetNode\n```\nNewUIWidgetNode creates the shared widget core for node on host.\n\n```go\nfunc (n *UIWidgetNode) Push(state map[string]interface{})\n```\nPush stores state on the bound sink and broadcasts it to the workflow's dashboard clients. No-op when no sink is bound.\n\n```go\ntype UIWidgetSink interface {\n\t// UpdateWidget stores state for nodeID in workflowID and\n\t// broadcasts it to that workflow's dashboard clients.\n\tUpdateWidget(workflowID, nodeID string, state map[string]interface{})\n}\n```\nUIWidgetSink is the host-side bridge a dashboard hub implements to receive per-widget state updates from ui\\* executors. The hub keeps retained state and broadcasts to connected clients; the contract is deliberately one method so any dashboard implementation can bind.\n\n```go\ntype WSClientConfig struct {\n\t// Path is the full ws:// or wss:// URL to dial.\n\tPath string `json:\"path\"`\n\t// TLS optionally references a tlsConfig node id.\n\tTLS string `json:\"tls\"`\n\t// WholeMsg selects Node-RED \"entire message\" mode; accepted for\n\t// parity, payload-only delivery is used either way.\n\tWholeMsg string `json:\"wholemsg\"`\n}\n```\nWSClientConfig is the shared outbound-client description a websocket in/out node references via its \"client\" field.\n\n```go\ntype WSClientState struct {\n\t// contains filtered or unexported fields\n}\n```\nWSClientState is the runtime half of a websocketClient config node: one shared outbound connection plus the subscriptions of dependent websocketIn nodes.\n\n```go\nfunc (s *WSClientState) Attach()\n```\nAttach registers one more dependent on the shared connection.\n\n```go\nfunc (s *WSClientState) Close()\n```\nClose drops the shared connection (idempotent).\n\n```go\nfunc (s *WSClientState) Conn() *websocket.Conn\n```\nConn returns the dialed connection, or nil while unconnected.\n\n```go\nfunc (s *WSClientState) Connect(ctx context.Context) error\n```\nConnect dials the configured URL once, then runs the read pump that fans received frames out to subscribers. A failed dial leaves the state unconnected; callers retry on their own schedule. Calls while another dial is in flight return nil immediately.\n\n```go\nfunc (s *WSClientState) Release()\n```\nRelease detaches one dependent; the last release drops the conn.\n\n```go\nfunc (s *WSClientState) Subscribe(id string, fn WSSub)\n```\nSubscribe registers fn for frames received on the client connection; id is the subscribing node's id.\n\n```go\nfunc (s *WSClientState) Unsubscribe(id string)\n```\nUnsubscribe detaches the subscriber registered under id.\n\n```go\ntype WSListenerConfig struct {\n\t// Path is the endpoint path served on the host's shared HTTP\n\t// router (Node-RED serves it on the admin port).\n\tPath string `json:\"path\"`\n\t// WholeMsg selects Node-RED \"entire message\" mode; accepted for\n\t// parity, payload-only delivery is used either way.\n\tWholeMsg string `json:\"wholemsg\"`\n}\n```\nWSListenerConfig is the shared listener description a websocket in/out node references via its \"server\" field.\n\n```go\ntype WSListenerState struct {\n\t// contains filtered or unexported fields\n}\n```\nWSListenerState is the runtime half of a websocketListener config node: the upgrade route mounted on the host's shared HTTP router, the accepted connections and every dependent node's subscription.\n\n```go\nfunc (s *WSListenerState) Attach(host NodeHost) error\n```\nAttach mounts the upgrade handler on the host's shared HTTP router on first use and registers one more dependent. The listener model has no private port — a host without a shared router cannot serve it and the deploy fails loud.\n\n```go\nfunc (s *WSListenerState) Close()\n```\nClose unmounts the route and closes every connection (idempotent).\n\n```go\nfunc (s *WSListenerState) Conn(sessionID string) (*websocket.Conn, bool)\n```\nConn returns the connection registered under sessionID.\n\n```go\nfunc (s *WSListenerState) Conns() []string\n```\nConns returns a snapshot of the mounted connection ids.\n\n```go\nfunc (s *WSListenerState) Release()\n```\nRelease detaches one dependent; the last release unmounts the route and closes every connection.\n\n```go\nfunc (s *WSListenerState) Sessions() *WSSessions\n```\nSessions returns the WSSessions view of the mounted connections.\n\n```go\nfunc (s *WSListenerState) Subscribe(id string, fn WSSub)\n```\nSubscribe registers fn for frames received on this listener; id is the subscribing node's id so Unsubscribe can detach it.\n\n```go\nfunc (s *WSListenerState) Unsubscribe(id string)\n```\nUnsubscribe detaches the subscriber registered under id.\n\n```go\ntype WSSessions struct {\n\t// contains filtered or unexported fields\n}\n```\nwsSessions is the workflow-level registry of open websocket connections keyed by session id. It lives in host node state (like tcpSessions) so websocketOut — a different executor instance — can write back to the session that produced a message.\n\n```go\nfunc NewWSSessions() *WSSessions\n```\nNewWSSessions returns an empty session registry (the value stored under WSSessionsKey in host node state).\n\n```go\nfunc (s *WSSessions) All() []*websocket.Conn\n```\nAll returns a snapshot of every registered connection.\n\n```go\nfunc (s *WSSessions) CloseAll()\n```\nCloseAll closes and removes every registered connection.\n\n```go\nfunc (s *WSSessions) CloseAllWith(code websocket.StatusCode, reason string)\n```\nCloseAllWith closes and removes every registered connection using the supplied close status and reason.\n\n```go\nfunc (s *WSSessions) DeleteIf(id string, conn *websocket.Conn)\n```\nDeleteIf removes id only when it still maps to conn.\n\n```go\nfunc (s *WSSessions) Get(id string) (*websocket.Conn, bool)\n```\nGet returns the connection registered under id.\n\n```go\nfunc (s *WSSessions) Put(id string, conn *websocket.Conn)\n```\nPut registers conn under id.\n\n```go\ntype WSSub func(sessionID string, typ websocket.MessageType, data []byte)\n```\nWSSub is the message sink a websocketIn registers on shared state: the connection's session id plus the received frame.\n\n","path":"github.com/dracory/nodebase","name":"nodebase","synopsis":"","isRedistributable":true}
