Skip to main content

Overview

NodeRegistry manages all node definitions. It’s generic over node type strings for type-safe lookups.
import { NodeRegistry } from '@jam-nodes/core';

const registry = new NodeRegistry();
You can optionally constrain type strings:
const registry = new NodeRegistry<'conditional' | 'end' | 'custom'>();

Methods

register

Register a single node definition. Throws if the type is already registered.
register<TInput, TOutput>(definition: NodeDefinition<TInput, TOutput>): this

registerAll

Register multiple nodes at once.
registerAll(definitions: NodeDefinition[]): this
import { builtInNodes } from '@jam-nodes/nodes';
registry.registerAll(builtInNodes);

unregister

Remove a registered node type. Returns true if it existed.
unregister(type: string): boolean

has

Check if a type is registered.
has(type: string): boolean

getDefinition

Get the full definition including executor.
getDefinition(type: string): NodeDefinition | undefined

getMetadata

Get client-safe metadata (no executor). Safe to send to the browser.
getMetadata(type: string): NodeMetadata | undefined

getExecutor

Get just the executor function.
getExecutor(type: string): NodeExecutor | undefined

getNodeTypes

Get all registered type identifiers.
getNodeTypes(): string[]

getAllDefinitions / getAllMetadata

getAllDefinitions(): NodeDefinition[]
getAllMetadata(): NodeMetadata[]

getByCategory / getMetadataByCategory

Filter definitions or metadata by category.
getByCategory(category: NodeCategory): NodeDefinition[]
getMetadataByCategory(category: NodeCategory): NodeMetadata[]

validateInput / validateOutput

Validate data against a node’s Zod schema. Throws ZodError on failure.
validateInput<TInput>(type: string, input: unknown): TInput
validateOutput<TOutput>(type: string, output: unknown): TOutput

size

get size(): number

Example

const registry = new NodeRegistry();
registry.registerAll(builtInNodes);

const def = registry.getDefinition('conditional');
const executor = registry.getExecutor('filter');
const logicNodes = registry.getByCategory('logic');
const validated = registry.validateInput('delay', { durationMs: 5000 });

console.log(registry.size); // 16

Factory Function

createRegistry<TNodeType>() creates a new empty NodeRegistry.
import { createRegistry } from '@jam-nodes/core';
const registry = createRegistry();