Skip to content
3 min read · 504 words

Class: NodeRef

Defined in: src/batteries/orchestration/encoding.ts:42

A serializable reference to another node's output — a CLASS, not a record.

Remarks

Why a class rather than a record with a marker field: a plain record can wear {kind: 'nodeRef', node, select, …} — it is an ordinary encodable record — so a marker property cannot separate a reference from a literal that happens to look like one, and a resolver keying on it would silently rewrite the literal. instanceof is unforgeable: no record can satisfy NodeRef.isNodeRef, and the encoder round-trips instances as custom:NodeRef rather than as records. Same mechanism core uses for Media/Tokenizable.

branchId identifies WHICH EXECUTION of node to read — the same path identity NodeOutput and FrameRef carry. Omitted means "do not filter".

Constructors

Constructor

ts
new NodeRef(
   node: string,
   select:
  | "last"
  | "first"
  | "all"
  | {
  index: number;
},
   path?: string,
   branchId?: BranchId): NodeRef;

Defined in: src/batteries/orchestration/encoding.ts:68

Construct a NodeRef.

Parameters

ParameterTypeDescription
nodestringThe id of the node whose output this reference reads.
select| "last" | "first" | "all" | { index: number; }Which item of that node's output to take: 'first', 'last', 'all', or an explicit {index}.
path?stringAn optional dot-path into the selected item's value.
branchId?BranchIdWhich execution of the node to read, as a path identity; omitted means "do not filter".

Returns

NodeRef

Properties

PropertyTypeDescriptionDefined in
branchId?BranchIdWHICH EXECUTION of the node to read, as a path identity. Remarks This is NOT an outgoing branch of that node: a node fanning out to two successors still runs once and produces one output; what creates several outputs for one node is that node being REACHED by several paths. Omitted means "do not filter" — fine when exactly one path reaches the node, and refused at freeze when more than one does.src/batteries/orchestration/encoding.ts:58
nodestringThe id of the node whose output this reference reads.src/batteries/orchestration/encoding.ts:44
path?stringAn optional dot-path into the selected item's value.src/batteries/orchestration/encoding.ts:48
select| "last" | "first" | "all" | { index: number; }Which item of that node's output to take: 'first', 'last', 'all', or an explicit {index}.src/batteries/orchestration/encoding.ts:46

Methods

[ENCODE_METHOD]()

ts
ENCODE_METHOD: Record<string, unknown>;

Defined in: src/batteries/orchestration/encoding.ts:86

Emit a plain snapshot of the fields for the encoder.

Returns

Record<string, unknown>


[DECODE_METHOD]()

ts
static DECODE_METHOD: NodeRef;

Defined in: src/batteries/orchestration/encoding.ts:91

Rebuild an instance from a NodeRef.[ENCODE_METHOD] snapshot.

Parameters

ParameterType
dataunknown

Returns

NodeRef


isNodeRef()

ts
static isNodeRef(v: unknown): v is NodeRef;

Defined in: src/batteries/orchestration/encoding.ts:81

instanceof guard — a look-alike record cannot pass.

Parameters

ParameterType
vunknown

Returns

v is NodeRef